MarlinTrkProcessors  2.4.1
TruthTracker.h
1 #ifndef TruthTracker_h
2 #define TruthTracker_h 1
3 
4 #include "marlin/Processor.h"
5 #include "lcio.h"
6 #include <string>
7 
8 #include <EVENT/TrackerHit.h>
9 #include <EVENT/SimTrackerHit.h>
10 #include <IMPL/LCCollectionVec.h>
11 
12 #include <UTIL/BitField64.h>
13 #include <UTIL/ILDConf.h>
14 
15 namespace EVENT{
16  class MCParticle ;
17  class Track ;
18  class LCEvent;
19 }
20 
21 namespace IMPL {
22  class TrackImpl ;
23 }
24 
25 namespace UTIL{
26  class LCRelationNavigator ;
27 }
28 
29 
30 namespace MarlinTrk{
31  class IMarlinTrkSystem ;
32 }
33 
75 class TruthTracker : public marlin::Processor {
76 
77 public:
78 
79  virtual marlin::Processor* newProcessor() { return new TruthTracker ; }
80 
81 
82  TruthTracker() ;
83 
87  virtual void init() ;
88 
91  virtual void processRunHeader( LCRunHeader* run ) ;
92 
95  virtual void processEvent( LCEvent * evt ) ;
96 
97 
98  virtual void check( LCEvent * evt ) ;
99 
100 
103  virtual void end() ;
104 
106  bool operator()(std::pair<SimTrackerHit*, TrackerHit* > p1, std::pair<SimTrackerHit*, TrackerHit* > p2) {
107 
108  SimTrackerHit* simHit1 = p1.first;
109  SimTrackerHit* simHit2 = p2.first;
110 
111 
112  if( simHit1->getMCParticle() == simHit2->getMCParticle() ) {
113  return simHit1->getTime() < simHit2->getTime() ;
114  }
115  else {
116  return simHit1->getMCParticle() < simHit2->getMCParticle() ;
117  }
118  }
119  };
120 
121 
122 protected:
123 
124 
125  const LCObjectVec* getSimHits( TrackerHit* trkhit, const FloatVec* weights = NULL);
126 
127  UTIL::BitField64* _encoder;
128  int getDetectorID(TrackerHit* hit) { _encoder->setValue(hit->getCellID0()); return (*_encoder)[lcio::ILDCellID0::subdet]; }
129  int getSideID(TrackerHit* hit) { _encoder->setValue(hit->getCellID0()); return (*_encoder)[lcio::ILDCellID0::side]; };
130  int getLayerID(TrackerHit* hit) { _encoder->setValue(hit->getCellID0()); return (*_encoder)[lcio::ILDCellID0::layer]; };
131  int getModuleID(TrackerHit* hit) { _encoder->setValue(hit->getCellID0()); return (*_encoder)[lcio::ILDCellID0::module]; };
132  int getSensorID(TrackerHit* hit) { _encoder->setValue(hit->getCellID0()); return (*_encoder)[lcio::ILDCellID0::sensor]; };
133 
134 
136  LCCollection* GetCollection( LCEvent * evt, std::string colName ) ;
137 
139  LCRelationNavigator* GetRelations( LCEvent * evt, std::string RelName ) ;
140 
142  void SetupInputCollections( LCEvent * evt ) ;
143 
144  void createTrack( MCParticle* mcp, UTIL::BitField64& cellID_encoder, std::vector< std::pair<SimTrackerHit*, TrackerHit* > >& hit_list );
145 
146  void createTrack_old( MCParticle* mcp, UTIL::BitField64& cellID_encoder, std::vector<TrackerHit*>& hit_list );
147 
148  void createTrack_iterative( MCParticle* mcp, UTIL::BitField64& cellID_encoder, std::vector< std::pair<SimTrackerHit*, TrackerHit* > >& hit_list );
149 
150  void drawEvent();
151 
152 
155  std::string _colNameMCParticles;
156 
159  std::vector< std::string > _colNamesTrackerHits;
160 
163  std::vector< std::string > _colNamesTrackerHitRelations;
164 
165  std::vector< LCCollection* > _colTrackerHits;
166  std::vector< LCRelationNavigator* > _navTrackerHitRel;
167 
171  LCCollectionVec* _trackVec;
172 
176  LCCollectionVec* _trackRelVec;
177 
178 
182  LCCollectionVec* _trackSegmentsVec;
183 
187  LCCollectionVec* _trackSegmentsRelVec;
188 
189  int _nMCP;
190 
191  int _n_run ;
192  int _n_evt ;
193 
194  float _MCpThreshold ;
195 
196  bool _useMCParticleParametersFotInitOfFit;
197 
200  MarlinTrk::IMarlinTrkSystem* _trksystem ;
201  bool _runMarlinTrkDiagnostics;
202  std::string _MarlinTrkDiagnosticsName;
203 
204  bool _FitTracksWithMarlinTrk;
205  bool _create_prefit_using_MarlinTrk;
206 
207  bool _MSOn ;
208  bool _ElossOn ;
209  bool _SmoothOn ;
210 
211  float _initialTrackError_d0;
212  float _initialTrackError_phi0;
213  float _initialTrackError_omega;
214  float _initialTrackError_z0;
215  float _initialTrackError_tanL;
216 
217  bool _UseIterativeFitting;
218  bool _UseEventDisplay;
219 
220  double _maxChi2PerHit;
221 
222  double _Bz;
223 
224  unsigned _nCreatedTracks;
225 
226  EVENT::LCEvent* _current_event;
227 
228  int _detector_model_for_drawing;
229  std::vector<int> _colours;
230  float _helix_max_r;
231 
232  std::string _trkSystemName ;
233 
234  int _fitDirection ;
235 } ;
236 
237 #endif
238 
239 
240 
virtual void end()
Called after data processing for clean up.
Definition: TruthTracker.cc:607
void SetupInputCollections(LCEvent *evt)
sets up the different collections
Definition: TruthTracker.cc:623
virtual void init()
Called at the begin of the job before anything is read.
Definition: TruthTracker.cc:257
std::string _output_track_segments_col_name
output track segments collection, used for tracks which cannot be formed from a single fit ...
Definition: TruthTracker.h:181
std::string _output_track_rel_name
Output track relations.
Definition: TruthTracker.h:175
std::string _output_track_segment_rel_name
Output track segments relations, used for tracks which cannot be formed from a single fit...
Definition: TruthTracker.h:186
virtual void processEvent(LCEvent *evt)
Called for every event - the working horse.
Definition: TruthTracker.cc:317
LCRelationNavigator * GetRelations(LCEvent *evt, std::string RelName)
helper function to get relations using try catch block
Definition: TruthTracker.cc:2078
Track creation based on MC truth.
Definition: TruthTracker.h:75
std::string _colNameMCParticles
input MCParticle collection
Definition: TruthTracker.h:155
MarlinTrk::IMarlinTrkSystem * _trksystem
pointer to the IMarlinTrkSystem instance
Definition: TruthTracker.h:200
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
Definition: TruthTracker.cc:312
Definition: TruthTracker.h:105
std::vector< std::string > _colNamesTrackerHits
input TrackerHit collections
Definition: TruthTracker.h:159
LCCollection * GetCollection(LCEvent *evt, std::string colName)
helper function to get collection using try catch block
Definition: TruthTracker.cc:2059
std::vector< std::string > _colNamesTrackerHitRelations
input relation collections
Definition: TruthTracker.h:163
std::string _output_track_col_name
output track collection
Definition: TruthTracker.h:170