10 #include <marlin/AIDAProcessor.h>
11 #include <AIDA/IHistogramFactory.h>
12 #include <AIDA/ICloud1D.h>
16 #include <EVENT/LCCollection.h>
17 #include <IMPL/LCCollectionVec.h>
18 #include <EVENT/LCRelation.h>
19 #include <IMPL/LCRelationImpl.h>
20 #include <EVENT/MCParticle.h>
21 #include <EVENT/Track.h>
22 #include <EVENT/ReconstructedParticle.h>
23 #include <IMPL/ReconstructedParticleImpl.h>
24 #include <IMPL/TrackImpl.h>
25 #include "IMPL/LCFlagImpl.h"
26 #include "UTIL/LCRelationNavigator.h"
28 #include <marlinutil/GeometryUtil.h>
29 #include <marlin/Global.h>
30 #include "HelixClass.h"
33 #include "marlin/VerbosityLevels.h"
35 using namespace lcio ;
36 using namespace marlin ;
52 _description =
"PrepareRECParticles converts input to ReconstructedParticles and puts them into a new collection making sure all the information which is needed to run the TauFinder is provided. ";
55 registerInputCollection( LCIO::MCPARTICLE,
57 "Name of the MCParticle collection" ,
59 std::string(
"MCParticlesSkimmed") ) ;
61 registerInputCollection( LCIO::TRACK,
62 "TrackCollectionName" ,
63 "Name of the Track collection" ,
65 std::string(
"LDCTracks") ) ;
67 registerProcessorParameter(
"outputColMC" ,
68 "Name of the output Collection of refilled information" ,
70 std::string(
"MCParticles_tau")) ;
72 registerProcessorParameter(
"outputColTracks" ,
73 "Name of the output Collection of refilled information" ,
75 std::string(
"Tracks_tau")) ;
77 registerOutputCollection( LCIO::RECONSTRUCTEDPARTICLE,
79 "Collection of Rec Particles for TauFinder",
81 std::string(
"MCParticles_tau"));
83 registerOutputCollection( LCIO::RECONSTRUCTEDPARTICLE,
84 "RecCollection_Tracks",
85 "Collection of Rec Particles for TauFinder",
87 std::string(
"Tracks_tau"));
90 registerOutputCollection( LCIO::LCRELATION,
91 "MCRECLinkCollectionName" ,
92 "Name of the MC Truth ReconstructedParticle collection" ,
94 std::string(
"MCRecLink") ) ;
96 registerOutputCollection( LCIO::LCRELATION,
97 "TrackRECLinkCollectionName" ,
98 "Name of the Track Truth ReconstructedParticle collection" ,
100 std::string(
"TracksRecLink") ) ;
108 streamlog_out(DEBUG) <<
" init called "
113 _bField = MarlinUtil::getBzAtOrigin();
129 LCCollection *colMC, *colTrack;
132 }
catch (Exception&
e) {
138 }
catch (Exception& e) {
146 mc_relationcol->parameters().setValue(std::string(
"FromType"),LCIO::RECONSTRUCTEDPARTICLE);
147 mc_relationcol->parameters().setValue(std::string(
"ToType"),LCIO::MCPARTICLE);
149 track_relationcol->parameters().setValue(std::string(
"FromType"),LCIO::RECONSTRUCTEDPARTICLE);
150 track_relationcol->parameters().setValue(std::string(
"ToType"),LCIO::TRACK);
152 HelixClass *helix =
new HelixClass();
156 int nMCP = colMC->getNumberOfElements();
157 for(
int k=0;
k < nMCP;
k++)
159 MCParticle *mc =
static_cast<MCParticle*
>(colMC->getElementAt(
k));
160 if(mc->getGeneratorStatus()==1)
163 if( (mc->getMass()==0 && fabs(mc->getPDG())!=22)
164 || mc->getPDG()==1000022)
166 ReconstructedParticleImpl *rec =
new ReconstructedParticleImpl();
168 rec->setMomentum(mc->getMomentum());
169 rec->setType(mc->getPDG());
170 rec->setEnergy(mc->getEnergy());
171 rec->setMass(mc->getMass());
172 rec->setCharge(mc->getCharge());
176 TrackImpl *track=
new TrackImpl();
180 for(
int i=0;i<3;i++){
181 ver[i]=mc->getVertex()[i];
182 mom[i]=mc->getMomentum()[i];
184 helix->Initialize_VP(ver,mom,mc->getCharge(),
_bField);
186 rp[i]=helix->getReferencePoint()[i];
187 track->setReferencePoint(rp);
188 track->setD0(fabs(helix->getD0()));
189 track->setPhi (helix->getPhi0());
190 track->setOmega (helix->getOmega());
191 track->setZ0 (helix->getZ0());
192 track->setTanLambda (helix->getTanLambda());
193 rec->addTrack(track);
195 reccol->addElement( rec );
196 LCRelationImpl *rel =
new LCRelationImpl(rec,mc);
197 mc_relationcol->addElement( rel );
205 int nt=colTrack->getNumberOfElements();
206 for(
int n=0;n<nt;n++)
208 Track *tr=
static_cast<Track*
>(colTrack->getElementAt(n));
209 ReconstructedParticleImpl *trec =
new ReconstructedParticleImpl();
211 double pt=fabs(
_bField/tr->getOmega())*3e-4;
212 double p=fabs(pt/cos(atan(tr->getTanLambda())));
214 mom[0]=pt*cos(tr->getPhi());
215 mom[1]=pt*sin(tr->getPhi());
216 mom[2]=pt*tr->getTanLambda();
218 trec->setMomentum(mom);
221 trec->setCharge(charge);
223 trackcol->addElement( trec );
224 LCRelationImpl *rel =
new LCRelationImpl(trec,tr);
225 track_relationcol->addElement( rel );
249 streamlog_out( DEBUG ) <<
"PrepareRECParticles::end() " << name()
250 <<
" processed " <<
_nEvt <<
" events in " <<
_nRun <<
" runs "
virtual void init()
Called at the begin of the job before anything is read.
virtual void processEvent(LCEvent *evt)
Called for every event - the working horse.
PreProcessor for TauFinder to provide necessary information and create universal input for TauFinder...
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
std::vector< LCCollection * > LCCollectionVec
std::string _colNameTrackTruth
PrepareRECParticles aPrepareRECParticles
virtual void check(LCEvent *evt)
virtual void end()
Called after data processing for clean up.
std::string _colNameTrack
std::string _colNameMCTruth
std::string _outcolTracks
std::string _colNameMC
Input collection name.