All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
TrackToRecoParticleConverter.cc
Go to the documentation of this file.
2 
3 // ----- include for verbosity dependent logging ---------
4 //#include "marlin/VerbosityLevels.h"
5 //#include "marlin/StringParameters.h"
6 //#define SLM streamlog_out(MESSAGE)
7 
8 #include <marlin/Global.h>
9 #include <gear/BField.h>
10 
11 #include <EVENT/LCCollection.h>
12 #include <IMPL/LCCollectionVec.h>
13 #include <IMPL/ReconstructedParticleImpl.h>
14 #include <cmath>
15 
16 using namespace std;
17 using namespace lcio ;
18 using namespace marlin ;
19 
21 
22 TrackToRecoParticleConverter::TrackToRecoParticleConverter() : Processor("TrackToRecoParticleConverter") {
23 
24  // modify processor description
25  _description = "Processor to convert track collection into ReconstructedParticle collection" ;
26 
27  // input collections
28  registerInputCollection( LCIO::TRACK,
29  "InputTrackCollection",
30  "Input track collection to convert",
32  std::string("InputTracks") );
33 
34  // output collection
35  registerOutputCollection( LCIO::RECONSTRUCTEDPARTICLE,
36  "OutputPFOCollection",
37  "Ouptut collection",
39  std::string("ConvertedTrackAsPFO") );
40 }
41 
43 
45  // usually a good idea to
46  printParameters() ;
47 }
48 
49 void TrackToRecoParticleConverter::processRunHeader( LCRunHeader* /*run*/) {
50 }
51 
53  LCCollection* trkCol = evt->getCollection( _inputTrackCollectionName ) ;
54  LCCollectionVec* outCol = new LCCollectionVec( LCIO::RECONSTRUCTEDPARTICLE ) ;
55 
56  const double c = 2.99792458e8; // m*s^-1
57  const double B = 3.5; // Tesla
58  const double mm2m = 1e-3;
59  const double eV2GeV = 1e-9;
60  const double eB = B*c*mm2m*eV2GeV;
61  const double pi_mass = 0.13957018;
62  const double pi_mass_sq = pi_mass*pi_mass;
63 
64  unsigned int ntrk = trkCol->getNumberOfElements();
65  for ( unsigned int i = 0; i < ntrk; i++ ) {
66  Track* trk = dynamic_cast<Track*>( trkCol->getElementAt(i) );
67  ReconstructedParticleImpl* rp = new ReconstructedParticleImpl();
68  rp->addTrack( trk );
69 
70  double om = trk->getOmega();
71  double td = trk->getTanLambda();
72  double cd = 1./sqrt(1+td*td);
73  double sd = td*cd;
74  double cph = cos(trk->getPhi());
75  double sph = sin(trk->getPhi());
76  double pT = eB/fabs(om);
77  double p = pT/cd;
78 
79  double px = p*cd*cph;
80  double py = p*cd*sph;
81  double pz = p*sd;
82  double e = sqrt( pi_mass_sq + px*px + py*py + pz*pz );
83  double mom[3] = { px, py, pz };
84  rp->setMomentum(mom);
85  rp->setEnergy(e);
86 
87  // FIXME verify charge calculation
88  double bz = marlin::Global::GEAR->getBField().at(gear::Vector3D(0.,0.,0.)).z();
89  int signbz = (bz > 0 ? 1 : -1);
90  int signom = (om > 0 ? 1 : -1);
91 
92  double chrg = signbz * signom;
93  rp->setCharge( chrg );
94 
95  outCol->addElement( rp );
96  }
97 
98  evt->addCollection( outCol, _outputPFOCollectionName.c_str() );
99 }
100 
101 void TrackToRecoParticleConverter::check( LCEvent * /*evt*/ ) {
102  // nothing to check here - could be used to fill checkplots in reconstruction processor
103 }
104 
CLHEP::Hep3Vector Vector3D
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
virtual void end()
Called after data processing for clean up.
std::string _inputTrackCollectionName
Input collection name.
virtual void init()
Called at the begin of the job before anything is read.
static const float e
std::vector< LCCollection * > LCCollectionVec
Definition: SiStripClus.h:55
Simple creation of ReconstructedParticle collection encapsulating tracks.
TrackToRecoParticleConverter aTrackToRecoParticleConverter
virtual void processEvent(LCEvent *evt)
Called for every event - the working horse.