CbmRoot
CbmLitFindGlobalTracksIdeal.cxx
Go to the documentation of this file.
1 
7 #include "CbmGlobalTrack.h"
8 #include "CbmMCTrack.h"
9 #include "CbmMatch.h"
10 #include "CbmTofHit.h"
11 #include "CbmTofPoint.h"
12 #include "CbmTrackMatchNew.h"
13 #include "FairRootManager.h"
14 
15 #include "TClonesArray.h"
16 
17 #include <iostream>
18 
20  : fDet()
21  ,
22 
23  fMCTracks(NULL)
24  , fStsMatches(NULL)
25  , fMuchMatches(NULL)
26  , fTrdMatches(NULL)
27  , fTofMCPoints(NULL)
28  , fTofHits(NULL)
29  , fTofHitsMatches(NULL)
30  , fGlobalTracks(NULL)
31  ,
32 
33  fMcStsMap()
34  , fMcTrdMap()
35  , fMcMuchMap()
36  , fMcTofMap()
37  ,
38 
39  fEventNo(0) {}
40 
42 
45  std::cout << fDet.ToString();
46 
48 
49  return kSUCCESS;
50 }
51 
52 void CbmLitFindGlobalTracksIdeal::Exec(Option_t* opt) {
57  }
59 
61 
62  std::cout << "Event: " << fEventNo++ << std::endl;
63 }
64 
66 
68  FairRootManager* ioman = FairRootManager::Instance();
69  if (NULL == ioman) { Fatal("Init", "CbmRootManager is not instantiated"); }
70 
71  fMCTracks = (TClonesArray*) ioman->GetObject("MCTrack");
72  if (NULL == fMCTracks) { Fatal("Init", "No MCTrack array!"); }
73 
74  //STS data
76  fStsMatches = (TClonesArray*) ioman->GetObject("StsTrackMatch");
77  if (NULL == fStsMatches) { Fatal("Init", "No StsTrackMatch array!"); }
78  }
79 
80  //MUCH data
82  fMuchMatches = (TClonesArray*) ioman->GetObject("MuchTrackMatch");
83  if (NULL == fMuchMatches) { Fatal("Init", "No MuchTrackMatch array!"); }
84  }
85 
86  //TRD data
88  fTrdMatches = (TClonesArray*) ioman->GetObject("TrdTrackMatch");
89  if (NULL == fTrdMatches) { Fatal("Init", "No TrdTrackMatch array!"); }
90  }
91 
92  //TOF data
94  fTofMCPoints = (TClonesArray*) ioman->GetObject("TofPoint");
95  if (NULL == fTofMCPoints) { Fatal("Init", "No TofPoint array!"); }
96  fTofHits = (TClonesArray*) ioman->GetObject("TofHit");
97  if (NULL == fTofHits) { Fatal("Init", "No TofHit array!"); }
98  fTofHitsMatches = (TClonesArray*) ioman->GetObject("TofHitMatch");
99  if (NULL == fTofHitsMatches) { Fatal("Init", "No TofHitMatch array!"); }
100  }
101 
102  // Create and register CbmGlobalTrack array
103  fGlobalTracks = new TClonesArray("CbmGlobalTrack", 100);
104  ioman->Register("GlobalTrack",
105  "Global",
107  IsOutputBranchPersistent("GlobalTrack"));
108 }
109 
110 void CbmLitFindGlobalTracksIdeal::FillTrackMap(std::map<Int_t, Int_t>& mcMap,
111  const TClonesArray* matches) {
112  mcMap.clear();
113  Int_t nofTracks = matches->GetEntriesFast();
114  for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
115  CbmTrackMatchNew* trackMatch = (CbmTrackMatchNew*) matches->At(iTrack);
116  if (trackMatch == NULL) { continue; }
117  Int_t mcId = trackMatch->GetMatchedLink().GetIndex();
118  if (mcId == -1) { continue; }
119  mcMap.insert(std::pair<Int_t, Int_t>(mcId, iTrack));
120  }
121 }
122 
124  fMcTofMap.clear();
125  Int_t nofTofHits = fTofHits->GetEntriesFast();
126  for (Int_t iTofHit = 0; iTofHit < nofTofHits; iTofHit++) {
127  CbmTofHit* tofHit = (CbmTofHit*) fTofHits->At(iTofHit);
128  if (tofHit == NULL) { continue; }
129  CbmMatch* tofHitMatch = (CbmMatch*) fTofHitsMatches->At(iTofHit);
130  if (tofHitMatch == NULL) { continue; }
131  Int_t tofPointIndex = tofHitMatch->GetMatchedLink().GetIndex();
132  CbmTofPoint* tofPoint = (CbmTofPoint*) fTofMCPoints->At(tofPointIndex);
133  if (tofPoint == NULL) { continue; }
134  Int_t mcId = tofPoint->GetTrackID();
135  if (mcId == -1) { continue; }
136  fMcTofMap.insert(std::pair<Int_t, Int_t>(mcId, iTofHit));
137  }
138 }
139 
141  fGlobalTracks->Clear();
142  Int_t nGlobalTracks = 0;
143  Int_t nofMCTracks = fMCTracks->GetEntriesFast();
144  for (Int_t iMCTrack = 0; iMCTrack < nofMCTracks; iMCTrack++) {
145  CbmMCTrack* mcTrack = (CbmMCTrack*) fMCTracks->At(iMCTrack);
146  if (mcTrack == NULL) { continue; }
147  Int_t stsId = -1, trdId = -1, muchId = -1, tofId = -1;
149  && (fMcStsMap.find(iMCTrack) != fMcStsMap.end())) {
150  stsId = fMcStsMap[iMCTrack];
151  }
153  && (fMcTrdMap.find(iMCTrack) != fMcTrdMap.end())) {
154  trdId = fMcTrdMap[iMCTrack];
155  }
157  && (fMcMuchMap.find(iMCTrack) != fMcMuchMap.end())) {
158  muchId = fMcMuchMap[iMCTrack];
159  }
161  && (fMcTofMap.find(iMCTrack) != fMcTofMap.end())) {
162  tofId = fMcTofMap[iMCTrack];
163  }
164 
165  if (stsId == -1 && trdId == -1 && muchId == -1 && tofId == -1) { continue; }
166 
167  CbmGlobalTrack* globalTrack =
168  new ((*fGlobalTracks)[nGlobalTracks++]) CbmGlobalTrack();
169  globalTrack->SetStsTrackIndex(stsId);
170  globalTrack->SetTrdTrackIndex(trdId);
171  globalTrack->SetTofHitIndex(tofId);
172  globalTrack->SetMuchTrackIndex(muchId);
173  }
174 }
175 
CbmMatch::GetMatchedLink
const CbmLink & GetMatchedLink() const
Definition: CbmMatch.h:37
CbmLitFindGlobalTracksIdeal::fMcTrdMap
std::map< Int_t, Int_t > fMcTrdMap
Definition: CbmLitFindGlobalTracksIdeal.h:95
CbmLitFindGlobalTracksIdeal::fStsMatches
TClonesArray * fStsMatches
Definition: CbmLitFindGlobalTracksIdeal.h:84
CbmMatch
Definition: CbmMatch.h:22
CbmLitFindGlobalTracksIdeal::Finish
virtual void Finish()
Derived from FairTask.
Definition: CbmLitFindGlobalTracksIdeal.cxx:65
CbmLitFindGlobalTracksIdeal::fEventNo
Int_t fEventNo
Definition: CbmLitFindGlobalTracksIdeal.h:99
CbmLitFindGlobalTracksIdeal::~CbmLitFindGlobalTracksIdeal
virtual ~CbmLitFindGlobalTracksIdeal()
Definition: CbmLitFindGlobalTracksIdeal.cxx:41
CbmGlobalTrack::SetTrdTrackIndex
void SetTrdTrackIndex(Int_t iTrd)
Definition: CbmGlobalTrack.h:55
CbmLitFindGlobalTracksIdeal::Exec
virtual void Exec(Option_t *opt)
Derived from FairTask.
Definition: CbmLitFindGlobalTracksIdeal.cxx:52
CbmLitFindGlobalTracksIdeal::fGlobalTracks
TClonesArray * fGlobalTracks
Definition: CbmLitFindGlobalTracksIdeal.h:90
CbmLitFindGlobalTracksIdeal::fMcStsMap
std::map< Int_t, Int_t > fMcStsMap
Definition: CbmLitFindGlobalTracksIdeal.h:94
CbmGlobalTrack.h
CbmLitFindGlobalTracksIdeal::fTofMCPoints
TClonesArray * fTofMCPoints
Definition: CbmLitFindGlobalTracksIdeal.h:87
ECbmModuleId::kTof
@ kTof
Time-of-flight Detector.
CbmLitFindGlobalTracksIdeal.h
FairTask for ideal global track reconstruction.
CbmMatch.h
ClassImp
ClassImp(CbmLitFindGlobalTracksIdeal)
CbmLitFindGlobalTracksIdeal::Init
virtual InitStatus Init()
Derived from FairTask.
Definition: CbmLitFindGlobalTracksIdeal.cxx:43
CbmGlobalTrack::SetStsTrackIndex
void SetStsTrackIndex(Int_t iSts)
Definition: CbmGlobalTrack.h:54
CbmLitFindGlobalTracksIdeal::fTrdMatches
TClonesArray * fTrdMatches
Definition: CbmLitFindGlobalTracksIdeal.h:86
CbmLitFindGlobalTracksIdeal::fMuchMatches
TClonesArray * fMuchMatches
Definition: CbmLitFindGlobalTracksIdeal.h:85
CbmLitFindGlobalTracksIdeal::fTofHitsMatches
TClonesArray * fTofHitsMatches
Definition: CbmLitFindGlobalTracksIdeal.h:89
CbmLitFindGlobalTracksIdeal::fMCTracks
TClonesArray * fMCTracks
Definition: CbmLitFindGlobalTracksIdeal.h:83
CbmTrackMatchNew.h
CbmLitDetectorSetup::GetDet
bool GetDet(ECbmModuleId detId) const
Return detector presence in setup.
Definition: CbmLitDetectorSetup.cxx:27
CbmLitFindGlobalTracksIdeal::fMcTofMap
std::map< Int_t, Int_t > fMcTofMap
Definition: CbmLitFindGlobalTracksIdeal.h:97
CbmLitFindGlobalTracksIdeal::fTofHits
TClonesArray * fTofHits
Definition: CbmLitFindGlobalTracksIdeal.h:88
ECbmModuleId::kTrd
@ kTrd
Transition Radiation Detector.
CbmGlobalTrack
Definition: CbmGlobalTrack.h:26
CbmLitFindGlobalTracksIdeal::fDet
CbmLitDetectorSetup fDet
Definition: CbmLitFindGlobalTracksIdeal.h:80
CbmMCTrack.h
CbmLitFindGlobalTracksIdeal::CbmLitFindGlobalTracksIdeal
CbmLitFindGlobalTracksIdeal()
Definition: CbmLitFindGlobalTracksIdeal.cxx:19
CbmMCTrack
Definition: CbmMCTrack.h:34
CbmLitFindGlobalTracksIdeal::FillTrackMap
void FillTrackMap(std::map< Int_t, Int_t > &mcMap, const TClonesArray *matches)
Fill map from <MC track index> to <reconstructed track index>.
Definition: CbmLitFindGlobalTracksIdeal.cxx:110
CbmTofPoint.h
CbmLitFindGlobalTracksIdeal::FillMapTof
void FillMapTof()
Fill map from <MC track index> to <TOF hit index>.
Definition: CbmLitFindGlobalTracksIdeal.cxx:123
CbmGlobalTrack::SetMuchTrackIndex
void SetMuchTrackIndex(Int_t iMuch)
Definition: CbmGlobalTrack.h:56
CbmLitFindGlobalTracksIdeal
FairTask for ideal global track reconstruction.
Definition: CbmLitFindGlobalTracksIdeal.h:32
CbmLitFindGlobalTracksIdeal::ReadDataBranches
void ReadDataBranches()
Read necessary data branches from the input data files.
Definition: CbmLitFindGlobalTracksIdeal.cxx:67
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
CbmTrackMatchNew
Definition: CbmTrackMatchNew.h:19
CbmGlobalTrack::SetTofHitIndex
void SetTofHitIndex(Int_t iTofHit)
Definition: CbmGlobalTrack.h:58
CbmTofPoint
Geometric intersection of a MC track with a TOFb detector.
Definition: CbmTofPoint.h:40
CbmTofHit
Definition: core/data/tof/CbmTofHit.h:26
CbmLitFindGlobalTracksIdeal::fMcMuchMap
std::map< Int_t, Int_t > fMcMuchMap
Definition: CbmLitFindGlobalTracksIdeal.h:96
CbmLitFindGlobalTracksIdeal::CreateGlobalTracks
void CreateGlobalTracks()
Create output CbmGlobalTracks and write them to output array.
Definition: CbmLitFindGlobalTracksIdeal.cxx:140
CbmLitDetectorSetup::ToString
string ToString() const
Return string representation of class.
Definition: CbmLitDetectorSetup.cxx:99
ECbmModuleId::kSts
@ kSts
Silicon Tracking System.
CbmLitDetectorSetup::DetermineSetup
void DetermineSetup()
Determines detector presence using TGeoManager.
Definition: CbmLitDetectorSetup.cxx:79