FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndGemTrackFinderIdeal Class Reference

Ideal track finding algorithm. More...

#include <PndGemTrackFinderIdeal.h>

Inheritance diagram for PndGemTrackFinderIdeal:
PndGemTrackFinder

Public Member Functions

 PndGemTrackFinderIdeal ()
 
virtual ~PndGemTrackFinderIdeal ()
 
virtual void Init ()
 
virtual Int_t DoFind (TClonesArray *hitArray, TClonesArray *trackArray, TClonesArray *trackCandArray)
 
void SetVerbose (const Int_t &verbose)
 
void SetPrimary (const Int_t &primary)
 
virtual void Finish ()
 
virtual void SetParContainers ()
 
 ClassDef (PndGemTrackFinder, 1)
 

Private Member Functions

 ClassDef (PndGemTrackFinderIdeal, 1)
 

Private Attributes

TClonesArray * fMCTrackArray
 
TClonesArray * fMCPointArray
 
Int_t fVerbose
 
Int_t fPrimary
 
Int_t fNofEvents
 event counter More...
 

Detailed Description

Ideal track finding algorithm.

Author
R. Karabowicz r.kar.nosp@m.abow.nosp@m.icz@g.nosp@m.si.d.nosp@m.e
Date
19.03.2009 Track finding procedure operates on mc data. Reads MC truth (MCTracks and MCPoints), creates one PndTrack for each MCTrack and attaches the hits according to the MCTrack of the corresponding MCPoint

Definition at line 28 of file PndGemTrackFinderIdeal.h.

Constructor & Destructor Documentation

PndGemTrackFinderIdeal::PndGemTrackFinderIdeal ( )

Default constructor

Definition at line 38 of file PndGemTrackFinderIdeal.cxx.

References fMCPointArray, fMCTrackArray, fNofEvents, fPrimary, and fVerbose.

38  {
39  fMCTrackArray = NULL;
40  fMCPointArray = NULL;
41  fNofEvents = 0;
42  fVerbose = 0;
43  fPrimary = 0;
44 }
Int_t fNofEvents
event counter
PndGemTrackFinderIdeal::~PndGemTrackFinderIdeal ( )
virtual

Destructor

Definition at line 47 of file PndGemTrackFinderIdeal.cxx.

47 { }

Member Function Documentation

PndGemTrackFinder::ClassDef ( PndGemTrackFinder  ,
 
)
inherited
PndGemTrackFinderIdeal::ClassDef ( PndGemTrackFinderIdeal  ,
 
)
private
Int_t PndGemTrackFinderIdeal::DoFind ( TClonesArray *  hitArray,
TClonesArray *  trackArray,
TClonesArray *  trackCandArray 
)
virtual

DoFind method

Parameters
hitArrayArray of Gem hits
trackArrayArray of PndGemTrack
Returns
Number of created tracks

Implements PndGemTrackFinder.

Definition at line 102 of file PndGemTrackFinderIdeal.cxx.

References PndTrackCand::AddHit(), fabs(), fMCPointArray, fMCTrackArray, fNofEvents, fPrimary, fVerbose, PndTrackCandHit::GetHitId(), PndMCTrack::GetMotherID(), PndMCTrack::GetNPoints(), PndMCTrack::GetPdgCode(), PndGemHit::GetPosition(), PndTrackCand::GetSortedHit(), PndMCTrack::GetStartVertex(), kGEM, mom, pos, PndTrack::SetRefIndex(), PndTrackCand::Sort(), CAMath::Sqrt(), and Z.

104  {
105 
106  // Count events
107  fNofEvents++;
108  if ( fVerbose ) {
109  cout << endl << endl<< endl << endl;
110  cout << "=======================================================" << endl;
111  cout << "-I- Event No: " << fNofEvents << endl;
112  cout << "=======================================================" << endl;
113 
114 
115  cout <<"-I- "<< GetName() <<"::DoFind "<< endl;
116  cout << "-------------------------------------------------------" << endl;
117  cout << " ### Start DoFind" << endl;
118  cout << "-------------------------------------------------------" << endl;
119  }
120 
121  // Check pointers
122  if( !fMCTrackArray ) {
123  cout << "-E- PndGemTrackFinderIdeal::DoFind: "
124  << "MCTrack array missing! " << endl;
125  return -1;
126  }
127 
128  if( !fMCPointArray ) {
129  cout << "-E- "<< GetName() <<"::DoFind: "
130  << "MCPoint array missing! " << endl;
131  return -1;
132  }
133 
134  if( !hitArray ) {
135  cout << "-E- "<< GetName() <<"::DoFind: "
136  << "Hit arrays missing! "<< endl;
137  return -1;
138  }
139 
140  // Initialise control counters
141  Int_t nNoMCTrack = 0;
142  Int_t nNoTrack = 0;
143  Int_t nNoGemPoint = 0;
144  Int_t nNoGemHit = 0;
145 
146  // Create pointers to GemHit and GemPoint
147  PndGemHit* gemHit = NULL;
148  FairMCPoint* mcPoint = NULL;
149  PndMCTrack* mcTrack = NULL;
150  PndTrack* gemTrack = NULL;
151  PndTrackCand* gemTrackCand = NULL;
152  PndTrackCandHit tcHit;
153 
154  // Declare variables outside the loop
155  Int_t ptIndex = 0; // MC point index
156  Int_t mcTrackIndex = 0; // MC track index
157  Int_t trackIndex = 0; // Gem track index
158  Int_t relDetID = -1;//3000; //
159 
160  // Create STL map from MCTrack index to number of hits
161  std::map<Int_t, Int_t> hitMap;
162  std::map<Int_t, Double_t> trackPMap;
163  std::map<Int_t, Int_t>::iterator itHitMap;
164 
165  if ( fVerbose ) {
166  // Size of fMCTrackArray
167  cout <<"# MC Tracks: "<< fMCTrackArray->GetEntriesFast() << endl;
168  // Size of fMCTrackArray
169  cout <<"# MC Points: "<< fMCPointArray->GetEntriesFast() << endl;
170  }
171 
172  // Number of Gem hits
173  Int_t nGemHits = hitArray->GetEntriesFast();
174  if(fVerbose > 2) cout <<"# GemHits: "<< nGemHits << endl;
175 
176  for(Int_t iHit = 0; iHit < nGemHits; iHit++){
177  // Get the pointer to Gem hit
178  gemHit = (PndGemHit*) hitArray->At(iHit);
179  if(gemHit->GetDetectorID() > relDetID) {
180  if(NULL == gemHit ) continue;
181 
182  // Get point index
183  ptIndex = gemHit->GetRefIndex();
184 
185  if ( ptIndex == -1 ) continue;
186 
187  // Get pointer to MC point
188  mcPoint = (FairMCPoint*) fMCPointArray->At(ptIndex);
189  if(NULL == mcPoint) continue;
190 
191  // Get MC track index
192  mcTrackIndex = mcPoint->GetTrackID();
193 
194  trackPMap[mcTrackIndex] = TMath::Sqrt(mcPoint->GetPx()*mcPoint->GetPx()+
195  mcPoint->GetPy()*mcPoint->GetPy()+
196  mcPoint->GetPz()*mcPoint->GetPz());
197 
198  // Increment the number of hits
199  hitMap[mcTrackIndex] += 1;
200  }
201  }
202 
203 
204  // Create STL map from MCTrack index to GemTrack index
205  map<Int_t, Int_t> trackMap;
206 
207  // Loop over reconstructable MCTracks and create corresponding GemTrack
208  Int_t nMCacc = 0; // Accepted MC tracks
209  Int_t nTracks = 0; // Reconstructable MC tracks
210  Int_t nMCTracks = fMCTrackArray->GetEntriesFast();
211 
212  if(fVerbose > 2) {
213  cout <<"# of MC Tracks (nMCTracks): " << nMCTracks << endl;
214  }
215 
216  for(Int_t iMCTrack = 0; iMCTrack < nMCTracks; iMCTrack++) {
217  mcTrack = (PndMCTrack*) fMCTrackArray->At(iMCTrack);
218  if( !mcTrack ) continue;
219 
220 
221  // Either Primary or All MC tracks are considered
222  if(fPrimary) {
223  if(mcTrack->GetMotherID() != -1 && fabs((mcTrack->GetStartVertex()).Z())>1.) continue;
224 
225  if(fVerbose > 2) {
226  cout <<"MC track #: "<< iMCTrack
227  << "\t MotherID: "<< mcTrack->GetMotherID()
228  << "\t StartVertex Z: "<< mcTrack->GetStartVertex().Z() << endl;
229  }
230  }
231  //----------------------------------------------------
232  nMCacc++;
233 
234  if(fVerbose > 2) {
235  cout << iMCTrack << ": #GemPoints in MCTrack: "<< mcTrack->GetNPoints(kGEM) << " -> " << hitMap[iMCTrack] << endl;
236  }
237  if ( !hitMap[iMCTrack] ) continue;
238 
239  gemTrackCand = new((*trackCandArray)[nTracks]) PndTrackCand();
240 
241  // Loop over hits. Get corresponding MCPoint and MCTrack index
242  for(Int_t iHit = 0; iHit < nGemHits; iHit++) {
243  gemHit = (PndGemHit*) hitArray->At(iHit);
244  if( !gemHit ) {
245  nNoGemHit++;
246  continue;
247  }
248 
249  ptIndex = gemHit->GetRefIndex();
250  if(ptIndex < 0) continue; // fake or background hit
251  mcPoint = (FairMCPoint*) fMCPointArray->At(ptIndex);
252 
253  if( !mcPoint ) {
254  nNoGemPoint++;
255  continue;
256  }
257 
258  mcTrackIndex = mcPoint->GetTrackID();
259 
260  if(mcTrackIndex < 0 || mcTrackIndex > nMCTracks) {
261  cout << "-E- "<< GetName() <<"::DoFind: "
262  << "MCTrack index out of range. " << mcTrackIndex << " "
263  << nMCTracks << endl;
264  nNoMCTrack++;
265  continue;
266  }
267  if ( mcTrackIndex != iMCTrack ) continue;
268 
269  gemTrackCand->AddHit(FairRootManager::Instance()->GetBranchId("GEMHit"),
270  iHit,gemHit->GetPosition().Mag());
271 
272  if(fVerbose > 3) {
273  cout << "GEM hit " << iHit << " from GEM point "
274  << ptIndex << " (" << mcTrackIndex << ") "
275  << "added to GEM track " << trackIndex << endl;
276  }
277  }
278 
279  gemTrackCand->Sort();
280 
281  // cout << "gemTrack " << nTracks << " has " << gemTrackCand->GetNHits() << " hits" << endl;
282  PndTrackCandHit tch = gemTrackCand->GetSortedHit(0);
283 
284  gemHit = (PndGemHit*) hitArray->At(tch.GetHitId());
285 
286  TVector3 pos;
287  TVector3 mom;
288 
289  ptIndex = gemHit->GetRefIndex();
290  mcPoint = (FairMCPoint*) fMCPointArray->At(ptIndex);
291 
292  gemHit->Position(pos);
293  mcPoint->Momentum(mom);
294 
295  mcTrack = (PndMCTrack*) fMCTrackArray->At(mcPoint->GetTrackID());
296 
297  int pdg = mcTrack->GetPdgCode();
298  double charge = 0.;
299  if(pdg<100000000) charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge()/3.;
300 
301 // gemTrackCand->setMcTrackId(iMCTrack);
302 
303  FairTrackParP firstPar(pos,mom,
304  TVector3(0.5, 0.5, 0.5),
305  0.1*mom,
306  (Int_t)charge,
307  pos,
308  TVector3(1.,0.,0.),
309  TVector3(0.,1.,0.));
310  FairTrackParP lastPar (pos,mom,
311  TVector3(0.5, 0.5, 0.5),
312  0.1*mom,
313  (Int_t)charge,
314  pos,
315  TVector3(1.,0.,0.),
316  TVector3(0.,1.,0.));
317 
318  gemTrack = new((*trackArray)[nTracks]) PndTrack(firstPar, lastPar, *gemTrackCand);
319 
320  gemTrack->SetRefIndex(iMCTrack);
321 
322  trackMap[iMCTrack] = nTracks;
323 
324  nTracks++;
325  }
326 
327  if(fVerbose) {
328  cout << endl;
329  cout << "-------------------------------------------------------" << endl;
330  cout << "-I- "<< GetName() <<": Event summary -I-" << endl;
331  cout << "-------------------------------------------------------" << endl;
332  cout << "Total Gem hits: " << nGemHits << endl;
333  cout << "MC tracks total: " << nMCTracks << ", accepted: "
334  << nMCacc << ", reconstructable: " << nTracks << endl;
335  if(nNoGemHit) cout << "GemHits not found : " << nNoGemHit << endl;
336  if(nNoGemPoint) cout << "GemPoints not found : " << nNoGemPoint << endl;
337  if(nNoMCTrack) cout << "MCTracks not found : " << nNoMCTrack << endl;
338  if(nNoTrack) cout << "GemTracks not found : " << nNoTrack << endl;
339  cout << "------------------------------------------------------" << endl;
340  cout << endl;
341  } else {
342 // cout << "All: " << nMCTracks
343 // << ", Accepted: " << nMCacc
344 // << ", Reconstructed: " << nTracks << endl;
345  }
346 
347  return nTracks;
348 }
TVector3 pos
void SetRefIndex(TString branch, Int_t i)
Definition: PndTrack.h:41
Int_t GetNPoints(DetectorId detId) const
Definition: PndMCTrack.cxx:120
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
Int_t GetPdgCode() const
Definition: PndMCTrack.h:73
PndTrackCandHit GetSortedHit(UInt_t i)
Definition: PndTrackCand.h:54
Double_t mom
Definition: plot_dirc.C:14
Int_t fNofEvents
event counter
void AddHit(UInt_t detId, UInt_t hitId, Double_t rho)
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
TVector3 GetPosition() const
Definition: PndGemHit.h:71
double Z
Definition: anaLmdDigi.C:68
TVector3 GetStartVertex() const
Definition: PndMCTrack.h:76
Int_t GetMotherID() const
Definition: PndMCTrack.h:74
Int_t GetHitId() const
virtual void PndGemTrackFinder::Finish ( )
inlinevirtualinherited

Reimplemented in PndGemTrackFinderOnHitsTB.

Definition at line 42 of file PndGemTrackFinder.h.

Referenced by PndGemFindTracks::Finish().

42 {};
void PndGemTrackFinderIdeal::Init ( )
virtual

Initialisation

Reimplemented from PndGemTrackFinder.

Definition at line 50 of file PndGemTrackFinderIdeal.cxx.

References fMCPointArray, fMCTrackArray, fVerbose, and rtdb.

50  {
51 
52  // Get and check FairRootManager
53  FairRootManager* ioman = FairRootManager::Instance();
54  if( !ioman ) {
55  cout << "-E- "<< GetName() <<"::Init: "
56  << "RootManager not instantised!" << endl;
57  return;
58  }
59 
60  // Get the pointer to the singleton FairRunAna object
61  FairRunAna* ana = FairRunAna::Instance();
62  if(NULL == ana) {
63  cout << "-E- "<< GetName() <<"::Init :"
64  <<" no FairRunAna object!" << endl;
65  return;
66  }
67  // Get the pointer to run-time data base
68  FairRuntimeDb* rtdb = ana->GetRuntimeDb();
69  if(NULL == rtdb) {
70  cout << "-E- "<< GetName() <<"::Init :"
71  <<" no runtime database!" << endl;
72  return;
73  }
74 
75  // Get MCTrack array
76  fMCTrackArray = (TClonesArray*) ioman->GetObject("MCTrack");
77  if( !fMCTrackArray ) {
78  cout << "-E- "<< GetName() <<"::Init: No MCTrack array!"
79  << endl;
80  return;
81  }
82 
83  // Get PndGemPoint (MCPoint) array
84  fMCPointArray = (TClonesArray*) ioman->GetObject("GEMPoint");
85  if( !fMCPointArray ) {
86  cout << "-E- "<< GetName() <<"::Init: No MCPoint array!"
87  << endl;
88  return;
89  }
90  if ( fVerbose )
91  cout <<"fMCPointArray #: "<< fMCPointArray->GetEntriesFast() << endl;
92 
93  // Geometry loading
94  //TFile *infile = ioman->GetInFile();
95  //TGeoManager *geoMan = (TGeoManager*) infile->Get("FAIRGeom");
96  //fGemStructure = PndGemStructure::Instance(geoMan);
97 
98  std::cout << "-I- "<< GetName() <<": Intialization successfull" << std::endl;
99 }
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
virtual void PndGemTrackFinder::SetParContainers ( )
inlinevirtualinherited

Virtual method SetParContainers. If needed, to be implemented in the concrete class.

Reimplemented in PndGemTrackFinderOnHitsTB, and PndGemTrackFinderOnHits.

Definition at line 47 of file PndGemTrackFinder.h.

47 { };
void PndGemTrackFinderIdeal::SetPrimary ( const Int_t &  primary)
inline

Definition at line 53 of file PndGemTrackFinderIdeal.h.

References fPrimary.

Referenced by gem_idealTracks(), locT_all(), and locT_theta().

53 { fPrimary = primary; };
void PndGemTrackFinderIdeal::SetVerbose ( const Int_t &  verbose)
inline

Public modifiers

Definition at line 52 of file PndGemTrackFinderIdeal.h.

References fVerbose, and verbose.

Referenced by gem_idealTracks(), locT_all(), and locT_theta().

52 { fVerbose = verbose; };
#define verbose

Member Data Documentation

TClonesArray* PndGemTrackFinderIdeal::fMCPointArray
private

Definition at line 60 of file PndGemTrackFinderIdeal.h.

Referenced by DoFind(), Init(), and PndGemTrackFinderIdeal().

TClonesArray* PndGemTrackFinderIdeal::fMCTrackArray
private

Arrays of MC information

Definition at line 53 of file PndGemTrackFinderIdeal.h.

Referenced by DoFind(), Init(), and PndGemTrackFinderIdeal().

Int_t PndGemTrackFinderIdeal::fNofEvents
private

event counter

Event counter

Definition at line 80 of file PndGemTrackFinderIdeal.h.

Referenced by DoFind(), and PndGemTrackFinderIdeal().

Int_t PndGemTrackFinderIdeal::fPrimary
private

Primaries level 0 - All MC tracks are considered 1 - Only primary MC tracks

Definition at line 77 of file PndGemTrackFinderIdeal.h.

Referenced by DoFind(), PndGemTrackFinderIdeal(), and SetPrimary().

Int_t PndGemTrackFinderIdeal::fVerbose
private

fGemStructure Verbosity level. 0 - quit 1 - event level 2 - track level 3 - debug (maximal output)

Definition at line 71 of file PndGemTrackFinderIdeal.h.

Referenced by DoFind(), Init(), PndGemTrackFinderIdeal(), and SetVerbose().


The documentation for this class was generated from the following files: