CbmRoot
CbmLitFindGlobalTracksParallel.cxx
Go to the documentation of this file.
1 
6 #include "FairLogger.h"
7 
8 #include "CbmGlobalTrack.h"
10 #include "CbmStsTrack.h"
11 #include "CbmTrack.h"
16 #include "parallel/LitScalTrack.h"
19 
20 #include "TClonesArray.h"
21 
22 #include <algorithm>
23 #include <iostream>
24 #include <set>
25 
26 #include <boost/assign/list_of.hpp>
27 
28 using boost::assign::list_of;
29 using std::cout;
30 using std::endl;
31 using std::for_each;
32 using std::set;
33 
35  : FairTask()
36  , fStsTracks(NULL)
37  , fTrdHits(NULL)
38  , fTrdTracks(NULL)
39  , fMuchPixelHits(NULL)
40  , fMuchTracks(NULL)
41  , fGlobalTracks(NULL)
42  , fTrackingType("nn")
43  , fMergerType("neares_hit")
44  , fFitterType("kalman")
45  , fTrackingWatch()
46  , fTrackingWithIOWatch() {}
47 
49 
52  cout << fDet.ToString();
53 
55 
56  fTrackingWatch.Reset();
57  fTrackingWithIOWatch.Reset();
58 
59  return kSUCCESS;
60 }
61 
63  if (fDet.GetDet(ECbmModuleId::kTrd)) { fTrdTracks->Delete(); }
64  if (fDet.GetDet(ECbmModuleId::kMuch)) { fMuchTracks->Delete(); }
65  fGlobalTracks->Delete();
66 
67  DoTracking();
68 
69  static Int_t eventNo = 0;
70  cout << "CbmLitFindGlobalTracksParallel::Exec eventNo: " << eventNo++ << endl;
71 }
72 
74 
76  FairRootManager* ioman = FairRootManager::Instance();
77  if (NULL == ioman)
78  LOG(fatal)
79  << "CbmLitFindGlobalTracksParallel: FairRootManager is not instantiated";
80 
81  // STS
82  fStsTracks = (TClonesArray*) ioman->GetObject("StsTrack");
83  if (NULL == fStsTracks)
84  LOG(fatal) << "CbmLitFindGlobalTracksParallel: No StsTrack array!";
85 
86  // TRD
88  fTrdHits = (TClonesArray*) ioman->GetObject("TrdHit");
89  if (NULL == fTrdHits)
90  if (NULL == fTrdHits)
91  LOG(fatal) << "CbmLitFindGlobalTracksParallel: No TRDHit array!";
92  }
93 
94  // MUCH
96  fMuchPixelHits = (TClonesArray*) ioman->GetObject("MuchPixelHit");
97  if (NULL == fMuchPixelHits)
98  if (NULL == fMuchPixelHits)
99  LOG(fatal) << "CbmLitFindGlobalTracksParallel: No MuchPixelHit array!";
100  }
101 
102  // Create and register track arrays
103  fGlobalTracks = new TClonesArray("CbmGlobalTrack", 100);
104  ioman->Register("GlobalTrack",
105  "Global",
107  IsOutputBranchPersistent("GlobalTrack"));
108 
110  fTrdTracks = new TClonesArray("CbmTrdTrack", 100);
111  ioman->Register(
112  "TrdTrack", "Trd", fTrdTracks, IsOutputBranchPersistent("TrdTrack"));
113  }
114 
116  fMuchTracks = new TClonesArray("CbmMuchTrack", 100);
117  ioman->Register(
118  "MuchTrack", "Much", fMuchTracks, IsOutputBranchPersistent("MuchTrack"));
119  }
120 }
121 
123  static Bool_t firstTime = true;
125  static lit::parallel::LitTrackFinderNN finder;
126  if (firstTime) {
129  finder.SetDetectorLayout(layout);
130  finder.SetNofIterations(1);
131  finder.SetMaxNofMissingHits(list_of(4));
132  finder.SetPDG(list_of(211));
133  finder.SetChiSqStripHitCut(list_of(9.));
134  finder.SetChiSqPixelHitCut(list_of(25.));
135  finder.SetSigmaCoef(list_of(5.));
136  firstTime = false;
137  }
140  finder.SetDetectorLayout(layout);
141  finder.SetNofIterations(1);
142  finder.SetMaxNofMissingHits(list_of(4));
143  finder.SetPDG(list_of(211));
144  finder.SetChiSqStripHitCut(list_of(9.));
145  finder.SetChiSqPixelHitCut(list_of(25.));
146  finder.SetSigmaCoef(list_of(5.));
147  firstTime = false;
148  }
149  }
150 
151  fTrackingWithIOWatch.Start(kFALSE);
152 
153  // Convert input data
154  vector<lit::parallel::LitScalTrack*> lseeds;
155  vector<lit::parallel::LitScalPixelHit*> lhits;
156  vector<lit::parallel::LitScalTrack*> ltracks;
159  lhits);
160  }
163  fMuchPixelHits, lhits);
164  }
165 
166  // Convert track seeds
167  Int_t nofSeeds = fStsTracks->GetEntriesFast();
168  for (Int_t iSeed = 0; iSeed < nofSeeds; iSeed++) {
169  CbmStsTrack* stsTrack = static_cast<CbmStsTrack*>(fStsTracks->At(iSeed));
173  stsTrack->GetParamLast(), &lpar);
174  lseed->SetParamFirst(lpar);
175  lseeds.push_back(lseed);
176  lseed->SetPreviousTrackId(iSeed);
177  }
178 
179  fTrackingWatch.Start(kFALSE);
180  finder.DoFind(lhits, lseeds, ltracks);
181  fTrackingWatch.Stop();
182 
183  // Convert to CBMROOT data and construct global tracks
186  fTrdTracks);
187  }
190  fMuchTracks);
191  }
193 
194  // Clear memory
195  for_each(lseeds.begin(), lseeds.end(), DeleteObject());
196  for_each(ltracks.begin(), ltracks.end(), DeleteObject());
197  for_each(lhits.begin(), lhits.end(), DeleteObject());
198  lseeds.clear();
199  ltracks.clear();
200  lhits.clear();
201 
202  fTrackingWithIOWatch.Stop();
203 }
204 
206  set<Int_t> stsTracksSet;
207  Int_t globalTrackNo = 0;
209  Int_t nofTrdTracks = fTrdTracks->GetEntriesFast();
210  for (Int_t iTrack = 0; iTrack < nofTrdTracks; iTrack++) {
211  const CbmTrack* trdTrack =
212  static_cast<const CbmTrack*>(fTrdTracks->At(iTrack));
213  CbmGlobalTrack* globalTrack =
214  new ((*fGlobalTracks)[globalTrackNo++]) CbmGlobalTrack();
215  globalTrack->SetStsTrackIndex(trdTrack->GetPreviousTrackId());
216  globalTrack->SetTrdTrackIndex(iTrack);
217  }
218  }
219 
221  Int_t nofMuchTracks = fMuchTracks->GetEntriesFast();
222  for (Int_t iTrack = 0; iTrack < nofMuchTracks; iTrack++) {
223  const CbmTrack* trdTrack =
224  static_cast<const CbmTrack*>(fMuchTracks->At(iTrack));
225  CbmGlobalTrack* globalTrack =
226  new ((*fGlobalTracks)[globalTrackNo++]) CbmGlobalTrack();
227  globalTrack->SetStsTrackIndex(trdTrack->GetPreviousTrackId());
228  globalTrack->SetMuchTrackIndex(iTrack);
229  }
230  }
231 
232  // Loop over STS tracks in order to create additional CbmGlobalTrack,
233  // consisting of only CbmStsTrack
234  for (Int_t iTrack = 0; iTrack < fStsTracks->GetEntriesFast(); iTrack++) {
235  // if CbmGlobalTrack for STS track was not created, than create one
236  if (stsTracksSet.find(iTrack) == stsTracksSet.end()) {
237  CbmGlobalTrack* globalTrack =
238  new ((*fGlobalTracks)[globalTrackNo++]) CbmGlobalTrack();
239  globalTrack->SetStsTrackIndex(iTrack);
240  }
241  }
242 }
243 
245  LOG(info) << "CbmLitFindGlobalTracksParallel::PrintStopwatchStatistics:\n "
246  << "tracking without IO: counts=" << fTrackingWatch.Counter()
247  << ", real=" << fTrackingWatch.RealTime() / fTrackingWatch.Counter()
248  << "/" << fTrackingWatch.RealTime()
249  << " s, cpu=" << fTrackingWatch.CpuTime() / fTrackingWatch.Counter()
250  << "/" << fTrackingWatch.CpuTime() << "\n"
251  << "tracking with IO: counts=" << fTrackingWithIOWatch.Counter()
252  << ", real="
253  << fTrackingWithIOWatch.RealTime() / fTrackingWithIOWatch.Counter()
254  << "/" << fTrackingWithIOWatch.RealTime() << " s, cpu="
255  << fTrackingWithIOWatch.CpuTime() / fTrackingWithIOWatch.Counter()
256  << "/" << fTrackingWithIOWatch.CpuTime();
257 }
258 
CbmTrack::GetParamLast
const FairTrackParam * GetParamLast() const
Definition: CbmTrack.h:62
CbmLitFindGlobalTracksParallel::DoTracking
void DoTracking()
Do the track reconstruction.
Definition: CbmLitFindGlobalTracksParallel.cxx:122
CbmLitMemoryManagment.h
lit::parallel::LitTrackFinderNN::SetNofIterations
void SetNofIterations(int nofIterations)
Definition: LitTrackFinderNN.h:52
CbmLitFindGlobalTracksParallel
Definition: CbmLitFindGlobalTracksParallel.h:22
CbmLitFindGlobalTracksParallel::Exec
virtual void Exec(Option_t *opt)
Inherited from FairTask.
Definition: CbmLitFindGlobalTracksParallel.cxx:62
lit::parallel::LitTrackFinderNN
Definition: LitTrackFinderNN.h:25
CbmGlobalTrack::SetTrdTrackIndex
void SetTrdTrackIndex(Int_t iTrd)
Definition: CbmGlobalTrack.h:55
CbmLitFindGlobalTracksParallel::Init
virtual InitStatus Init()
Inherited from FairTask.
Definition: CbmLitFindGlobalTracksParallel.cxx:50
CbmLitTrackingGeometryConstructor.h
Tracking geometry constructor.
CbmLitFindGlobalTracksParallel.h
CBM task for parallel global track reconstruction.
CbmLitFindGlobalTracksParallel::fTrackingWatch
TStopwatch fTrackingWatch
Definition: CbmLitFindGlobalTracksParallel.h:103
CbmGlobalTrack.h
lit::parallel::LitTrackFinderNN::SetChiSqStripHitCut
void SetChiSqStripHitCut(const vector< fscal > &chiSqStripHitCut)
Definition: LitTrackFinderNN.h:59
lit::parallel::LitTrackFinderNN::SetMaxNofMissingHits
void SetMaxNofMissingHits(const vector< int > &maxNofMissingHits)
Definition: LitTrackFinderNN.h:55
CbmLitFindGlobalTracksParallel::fTrdHits
TClonesArray * fTrdHits
Definition: CbmLitFindGlobalTracksParallel.h:82
lit::parallel::LitScalTrack
Scalar track data class.
Definition: LitScalTrack.h:33
DeleteObject
Definition: CbmLitMemoryManagment.h:5
lit::parallel::LitScalTrack::SetPreviousTrackId
void SetPreviousTrackId(unsigned short previousTrackId)
Sets previous trackId.
Definition: LitScalTrack.h:188
CbmLitFindGlobalTracksParallel::PrintStopwatchStatistics
void PrintStopwatchStatistics()
Print stopwatch statistics.
Definition: CbmLitFindGlobalTracksParallel.cxx:244
CbmLitTrackingGeometryConstructor::GetTrdLayoutScal
void GetTrdLayoutScal(lit::parallel::LitDetectorLayoutScal &layout)
Return TRD detector layout for TRD parallel tracking in scalar format.
Definition: CbmLitTrackingGeometryConstructor.cxx:158
lit::parallel::LitDetectorLayout< fscal >
lit::parallel::LitTrackParam< fscal >
CbmLitFindGlobalTracksParallel::~CbmLitFindGlobalTracksParallel
virtual ~CbmLitFindGlobalTracksParallel()
Destructor.
Definition: CbmLitFindGlobalTracksParallel.cxx:48
CbmTrack
Definition: CbmTrack.h:32
CbmStsTrack.h
Data class for STS tracks.
CbmGlobalTrack::SetStsTrackIndex
void SetStsTrackIndex(Int_t iSts)
Definition: CbmGlobalTrack.h:54
CbmLitConverterParallel::FairTrackParamToLitTrackParamScal
static void FairTrackParamToLitTrackParamScal(const FairTrackParam *par, lit::parallel::LitTrackParamScal *lpar)
Convert FairTrackParam to LitTrackParamScal.
Definition: CbmLitConverterParallel.cxx:27
lit::parallel::LitTrackFinderNN::SetPDG
void SetPDG(const vector< int > &pdg)
Definition: LitTrackFinderNN.h:58
CbmLitFindGlobalTracksParallel::fTrdTracks
TClonesArray * fTrdTracks
Definition: CbmLitFindGlobalTracksParallel.h:83
lit::parallel::LitScalTrack::SetParamFirst
void SetParamFirst(const LitTrackParamScal &param)
Sets first track parameter.
Definition: LitScalTrack.h:96
lit::parallel::LitTrackFinderNN::SetChiSqPixelHitCut
void SetChiSqPixelHitCut(const vector< fscal > &chiSqPixelHitCut)
Definition: LitTrackFinderNN.h:62
CbmTrack.h
CbmLitConverterParallel::LitScalTrackArrayToCbmMuchTrackArray
static void LitScalTrackArrayToCbmMuchTrackArray(const vector< lit::parallel::LitScalTrack * > &ltracks, TClonesArray *tracks)
Convert array of LitScalTrack to array of CbmTrack.
Definition: CbmLitConverterParallel.cxx:192
LitScalTrack.h
Scalar track data class.
CbmLitDetectorSetup::GetDet
bool GetDet(ECbmModuleId detId) const
Return detector presence in setup.
Definition: CbmLitDetectorSetup.cxx:27
CbmLitFindGlobalTracksParallel::fMuchTracks
TClonesArray * fMuchTracks
Definition: CbmLitFindGlobalTracksParallel.h:85
CbmLitConverterParallel::LitScalTrackArrayToCbmTrdTrackArray
static void LitScalTrackArrayToCbmTrdTrackArray(const vector< lit::parallel::LitScalTrack * > &ltracks, TClonesArray *tracks)
Convert array of LitScalTrack to array of CbmTrack.
Definition: CbmLitConverterParallel.cxx:181
LitScalPixelHit.h
Base class for scalar pixel hits.
CbmTrack::GetPreviousTrackId
Int_t GetPreviousTrackId() const
Definition: CbmTrack.h:60
ClassImp
ClassImp(CbmLitFindGlobalTracksParallel)
CbmLitFindGlobalTracksParallel::fMuchPixelHits
TClonesArray * fMuchPixelHits
Definition: CbmLitFindGlobalTracksParallel.h:84
CbmLitTrackingGeometryConstructor::GetMuchLayoutScal
void GetMuchLayoutScal(lit::parallel::LitDetectorLayoutScal &layout)
Return MUCH detector layout for parallel MUCH tracking in scalar format.
Definition: CbmLitTrackingGeometryConstructor.cxx:65
lit::parallel::LitTrackFinderNN::SetSigmaCoef
void SetSigmaCoef(const vector< fscal > &sigmaCoef)
Definition: LitTrackFinderNN.h:65
lit::parallel::LitTrackFinderNN::DoFind
void DoFind(const vector< lit::parallel::LitScalPixelHit * > &hits, const vector< lit::parallel::LitScalTrack * > &trackSeeds, vector< lit::parallel::LitScalTrack * > &tracks)
Main function for track reconstruction.
Definition: LitTrackFinderNN.cxx:42
CbmLitConverterParallel::CbmPixelHitArrayToLitScalPixelHitArray
static void CbmPixelHitArrayToLitScalPixelHitArray(const TClonesArray *hits, vector< lit::parallel::LitScalPixelHit * > &lhits)
Convert CbmPixelHit array to LitScalPixelHit arra.
Definition: CbmLitConverterParallel.cxx:106
LitTrackFinderNN.h
Parallel implementation of the nearest neighbor tracking algorithm.
CbmLitConverterParallel.h
Class for conversion between CBMROOT data classes and littrack parallel data classes.
CbmLitFindGlobalTracksParallel::fGlobalTracks
TClonesArray * fGlobalTracks
Definition: CbmLitFindGlobalTracksParallel.h:86
LitDetectorLayout.h
Detector layout class.
ECbmModuleId::kTrd
@ kTrd
Transition Radiation Detector.
CbmGlobalTrack
Definition: CbmGlobalTrack.h:26
CbmLitFindGlobalTracksParallel::CbmLitFindGlobalTracksParallel
CbmLitFindGlobalTracksParallel()
Constructor.
Definition: CbmLitFindGlobalTracksParallel.cxx:34
CbmLitFindGlobalTracksParallel::ReadAndCreateDataBranches
void ReadAndCreateDataBranches()
Reads necessary data branches from the input data files and creates branches for CbmGlobalTrack,...
Definition: CbmLitFindGlobalTracksParallel.cxx:75
CbmLitFindGlobalTracksParallel::Finish
virtual void Finish()
Inherited from FairTask.
Definition: CbmLitFindGlobalTracksParallel.cxx:73
lit::parallel::LitTrackFinderNN::SetDetectorLayout
void SetDetectorLayout(const LitDetectorLayoutScal &layout)
Definition: LitTrackFinderNN.h:49
CbmGlobalTrack::SetMuchTrackIndex
void SetMuchTrackIndex(Int_t iMuch)
Definition: CbmGlobalTrack.h:56
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
CbmLitFindGlobalTracksParallel::fStsTracks
TClonesArray * fStsTracks
Definition: CbmLitFindGlobalTracksParallel.h:81
CbmStsTrack
Definition: CbmStsTrack.h:37
CbmLitFindGlobalTracksParallel::ConstructGlobalTracks
void ConstructGlobalTracks()
Create and fill global tracks.
Definition: CbmLitFindGlobalTracksParallel.cxx:205
CbmLitDetectorSetup::ToString
string ToString() const
Return string representation of class.
Definition: CbmLitDetectorSetup.cxx:99
CbmLitFindGlobalTracksParallel::fTrackingWithIOWatch
TStopwatch fTrackingWithIOWatch
Definition: CbmLitFindGlobalTracksParallel.h:104
CbmLitTrackingGeometryConstructor::Instance
static CbmLitTrackingGeometryConstructor * Instance()
Return pointer to singleton object.
Definition: CbmLitTrackingGeometryConstructor.cxx:55
CbmLitFindGlobalTracksParallel::fDet
CbmLitDetectorSetup fDet
Definition: CbmLitFindGlobalTracksParallel.h:78
CbmLitDetectorSetup::DetermineSetup
void DetermineSetup()
Determines detector presence using TGeoManager.
Definition: CbmLitDetectorSetup.cxx:79