23#include "FairRootManager.h"
24#include "TClonesArray.h"
45using std::setprecision;
47using std::stringstream;
50 : FairTask(
"LitFindGlobalTracks")
57 , fMuchPixelHits(NULL)
72 , fLitOutputTofTracks()
81 fTrackingType(
"branch")
82 , fMergerType(
"nearest_hit")
83 , fFitterType(
"lit_kalman")
98 std::cout << std::endl;
99 LOG(info) <<
"=========================================";
100 LOG(info) << GetName() <<
": Initializing ";
112 LOG(info) <<
"=========================================";
113 std::cout << std::endl;
121 UInt_t nStsTracks = 0;
122 UInt_t nMuchHits = 0;
125 UInt_t nGlbTracks = 0;
141 nEvents =
fEvents->GetEntriesFast();
142 LOG(debug) << GetName() <<
": reading time slice with " << nEvents <<
" events ";
144 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
152 LOG(debug) <<
"CbmLitFindGlobalTracks::Exec event: " <<
event->GetNumber();
162 LOG(debug) <<
"CbmLitFindGlobalTracks::Exec timeslice: " <<
fEventNo++;
170 logOut << setw(20) << left << GetName() <<
" [";
171 logOut << fixed << setw(8) << setprecision(1) << right << timer.RealTime() * 1000. <<
" ms] ";
172 logOut <<
"TS " <<
fNofTs;
173 if (
fEvents) logOut <<
", events " << nEvents;
174 logOut <<
", STS tracks " << nStsTracks <<
", Hits MUCH " << nMuchHits <<
" TRD " << nTrdHits;
175 logOut <<
" TOF " <<
nTofHits <<
", global tracks " << nGlbTracks;
176 LOG(info) << logOut.str();
184 fTime += timer.RealTime();
193 std::cout << std::endl;
194 LOG(info) <<
"=====================================";
195 LOG(info) << GetName() <<
": Run summary";
196 LOG(info) <<
"Time slices : " <<
fNofTs;
197 LOG(info) <<
"STS tracks / TS : " << fixed << setprecision(2) << Double_t(
fNofStsTracks) / Double_t(
fNofTs);
198 LOG(info) <<
"MUCH hits / TS : " << fixed << setprecision(2) << Double_t(
fNofMuchHits) / Double_t(
fNofTs);
199 LOG(info) <<
"TRD hits / TS : " << fixed << setprecision(2) << Double_t(
fNofTrdHits) / Double_t(
fNofTs);
200 LOG(info) <<
"TOF hits / TS : " << fixed << setprecision(2) << Double_t(
fNofTofHits) / Double_t(
fNofTs);
201 LOG(info) <<
"Global tracks / TS : " << fixed << setprecision(2) << Double_t(
fNofGlbTracks) / Double_t(
fNofTs);
203 LOG(info) <<
"Time per TS : " << 1000. *
fTime / Double_t(
fNofTs) <<
" ms ";
205 LOG(info) <<
"Events processed : " <<
fNofEvents;
209 LOG(info) <<
"=====================================";
215 FairRootManager* ioman = FairRootManager::Instance();
220 fMvdHits =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"MvdHit"));
222 LOG(warn) << GetName() <<
": No MvdHit branch!";
226 LOG(info) << GetName() <<
": Found MvdHit branch";
230 fStsHits =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"StsHit"));
232 LOG(fatal) << GetName() <<
": No StsHit branch!";
236 LOG(info) << GetName() <<
": Found StsHit branch";
239 fStsTracks =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"StsTrack"));
241 LOG(fatal) << GetName() <<
": No StsTrack branch!";
245 LOG(info) << GetName() <<
": Found StsTrack branch";
249 fMuchPixelHits =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"MuchPixelHit"));
251 LOG(warning) << GetName() <<
"No MuchPixelHit branch!";
255 if (
fMuchPixelHits) LOG(info) << GetName() <<
": Found MuchPixelHit branch";
261 fTrdHits =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"TrdHit"));
263 LOG(warning) << GetName() <<
": No TrdHit branch!";
266 LOG(info) << GetName() <<
": Found TrdHit branch";
271 fTofHits =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"TofHit"));
273 LOG(warning) << GetName() <<
": No TofHit branch!";
277 LOG(info) << GetName() <<
": Found TofHit branch";
281 fEvents =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"CbmEvent"));
283 LOG(info) << GetName() <<
": Found Event branch";
285 LOG(info) << GetName() <<
": No Event branch; run in time-based mode";
293 LOG(warning) << GetName() <<
": No PrimaryVertex branch!";
295 LOG(info) << GetName() <<
": Found PrimaryVertex branch";
300 FairRootManager* ioman = FairRootManager::Instance();
305 fMuchTracks =
new TClonesArray(
"CbmMuchTrack", 100);
306 ioman->Register(
"MuchTrack",
"Much",
fMuchTracks, IsOutputBranchPersistent(
"MuchTrack"));
307 LOG(info) << GetName() <<
": Register MuchTrack branch";
312 fTrdTracks =
new TClonesArray(
"CbmTrdTrack", 100);
313 ioman->Register(
"TrdTrack",
"Trd",
fTrdTracks, IsOutputBranchPersistent(
"TrdTrack"));
314 LOG(info) << GetName() <<
": Register TrdTrack branch";
319 fTofTracks =
new TClonesArray(
"CbmTofTrack", 100);
320 ioman->Register(
"TofTrack",
"Tof",
fTofTracks, IsOutputBranchPersistent(
"TofTrack"));
321 LOG(info) << GetName() <<
": Register TofTrack branch";
326 ioman->Register(
"GlobalTrack",
"Global",
fGlobalTracks, IsOutputBranchPersistent(
"GlobalTrack"));
327 LOG(info) << GetName() <<
": Register GlobalTrack branch";
334 std::string st(
"e_");
339 LOG(fatal) << GetName() <<
"::InitTrackReconstruction: Tracking type not found";
344 std::string st(
"mu_");
349 LOG(fatal) << GetName() <<
"::InitTrackReconstruction: Tracking type not found";
358 LOG(fatal) << GetName() <<
"::InitTrackReconstruction: Merger type not found";
366 LOG(fatal) << GetName() <<
"::InitTrackReconstruction: Fitter type not found";
375 LOG(debug2) <<
"-I- CbmLitFindGlobalTracks: Number of STS tracks: " <<
fLitStsTracks.size();
385 for (Int_t i = 0; i <
fLitHits.size(); i++) {
393 LOG(debug2) <<
"-I- CbmLitFindGlobalTracks: Number of hits: " <<
fLitHits.size();
397 LOG(debug2) <<
"-I- CbmLitFindGlobalTracks: Number of TOF hits: " <<
fLitTofHits.size();
418 for (Int_t i = 0; i < nofTofTracks; ++i) {
422 if (globalTrack == NULL) {
426 std::vector<Double_t> X, Y, Z;
427 if (primVertex == NULL) {
433 X.push_back(primVertex->
GetX());
434 Y.push_back(primVertex->
GetY());
435 Z.push_back(primVertex->
GetZ());
447 for (Int_t ih = 0; ih < nofStsHits; ih++) {
449 X.push_back(hit->
GetX());
450 Y.push_back(hit->
GetY());
451 Z.push_back(hit->
GetZ());
458 for (Int_t ih = 0; ih < nofMuchHits; ih++) {
462 X.push_back(hit->
GetX());
463 Y.push_back(hit->
GetY());
464 Z.push_back(hit->
GetZ());
472 for (Int_t ih = 0; ih < nofTrdHits; ih++) {
474 X.push_back(hit->
GetX());
475 Y.push_back(hit->
GetY());
476 Z.push_back(hit->
GetZ());
482 X.push_back(hit->
GetX());
483 Y.push_back(hit->
GetY());
484 Z.push_back(hit->
GetZ());
488 Double_t length = 0.;
489 for (Int_t j = 0; j < X.size() - 1; ++j) {
490 Double_t dX = X[j] - X[j + 1];
491 Double_t dY = Y[j] - Y[j + 1];
492 Double_t dZ = Z[j] - Z[j + 1];
493 length += std::sqrt(dX * dX + dY * dY + dZ * dZ);
548 if (0 == primVertex)
return;
552 for (Int_t i0 = 0; i0 < nofGlobalTracks; ++i0) {
557 FairTrackParam vtxTrackParam;
558 float chiSqPrimary = 0.f;
636 std::cout <<
"Stopwatch: " << std::endl;
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
@ kMvd
Micro-Vertex Detector.
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
TClonesArray * fTofTracks
ClassImp(CbmLitFindGlobalTracks)
CBM task for global track reconstruction.
Base data class for hits.
Base data class for pixel hits.
Base data class for strip hits.
Base data class for track.
Tracking geometry constructor.
Data class for a reconstructed hit in the STS.
Data class for STS tracks.
std::vector< CbmTofTrack * >::iterator TrackPtrIterator
Class characterising one event by a collection of links (indices) to data objects,...
void SetParamPrimaryVertex(const FairTrackParam *parPV)
int32_t GetStsTrackIndex() const
int32_t GetTofHitIndex() const
int32_t GetMuchTrackIndex() const
void SetLength(double length)
int32_t GetTrdTrackIndex() const
static void ExtrapolateTrackToPV(const CbmStsTrack *track, CbmVertex *pv, FairTrackParam *paramAtPV, float &chiPrim)
static void LitTrackVectorToGlobalTrackArray(CbmEvent *event, const TrackPtrVector &litTracks, const TofTrackPtrVector &litTofTracks, TClonesArray *globalTracks, TClonesArray *stsTracks, TClonesArray *trdTracks, TClonesArray *muchTracks, TClonesArray *tofTracks)
static void HitArrayToHitVector(CbmEvent *event, ECbmDataType hitDataType, const TClonesArray *hits, HitPtrVector &litHits)
static void StsTrackArrayToTrackVector(CbmEvent *event, const TClonesArray *tracks, TrackPtrVector &litTracks)
void SetDet(ECbmModuleId detId, bool isDet)
Set detector presence manually.
void DetermineSetup()
Determines detector presence using TGeoManager.
bool GetElectronSetup() const
Return true if electron setup is detected.
string ToString() const
Return string representation of class.
bool GetDet(ECbmModuleId detId) const
Return detector presence in setup.
virtual void Finish()
Inherited from FairTask.
TrackPropagatorPtr fPropagator
CbmLitFindGlobalTracks()
Constructor.
void ConvertOutputData(CbmEvent *event)
Convert output data LIT data classes to CBMROOT data classes.
TrackPtrVector fLitOutputTracks
TofTrackPtrVector fLitOutputTofTracks
void ConvertInputData(CbmEvent *event)
Convert input data from CBMROOT data classes to LIT data classes.
void RegisterOutputBranches()
Register output data branches (tracks) to the tree.
virtual ~CbmLitFindGlobalTracks()
Destructor.
void ClearArrays()
Clear arrays and frees the memory.
void PrintStopwatchStatistics()
Print output stopwatch statistics for track-finder and hit-to-track merger.
HitToTrackMergerPtr fMerger
void CalculateLength(CbmEvent *event)
TClonesArray * fTofTracks
void InitTrackReconstruction()
Create and initialize track finder and track merger objects.
TClonesArray * fStsTracks
void RunTrackReconstruction()
Run the track reconstruction.
TClonesArray * fTrdTracks
TrackPtrVector fLitStsTracks
void SelectTracksForTofMerging()
Select tracks for further merging with TOF.
virtual void SetParContainers()
Inherited from FairTask.
virtual void Exec(Option_t *opt)
Inherited from FairTask.
void ReadInputBranches()
Accesses input data branches (hits, tracks, events) from the tree.
TClonesArray * fMuchTracks
TClonesArray * fGlobalTracks
virtual InitStatus Init()
Inherited from FairTask.
void CalculatePrimaryVertexParameters(CbmEvent *event)
TClonesArray * fMuchPixelHits
TStopwatch fTrackingWatch
Base data class for hits.
LitSystemId GetSystem() const
void SetDetectorId(LitSystemId sysId, Int_t station)
Base data class for track.
LitTrackQa GetQuality() const
void SetQuality(LitTrackQa quality)
static CbmLitTrackingGeometryConstructor * Instance()
Return pointer to singleton object.
Int_t GetNofMuchStations()
Return number of stations in MUCH.
data class for a reconstructed 3-d hit in the STS
int32_t GetStsHitIndex(int32_t iHit) const
int32_t GetNofStsHits() const
int32_t GetTofHitIndex() const
void SetTrackLength(double trackLength)
int32_t GetTrackIndex() const
virtual int32_t GetNofHits() const
int32_t GetHitIndex(int32_t iHit) const
HitType GetHitType(int32_t iHit) const