11 #include "CbmTofHit.h"
13 #include "FairRootManager.h"
15 #include "TClonesArray.h"
62 FairRootManager*
rootMgr = FairRootManager::Instance();
64 cout <<
"-E- CbmL1TofMerger::Init(): "
65 <<
"ROOT manager is not instantiated!" << endl;
69 L1_DYNAMIC_CAST<TClonesArray*>(
rootMgr->GetObject(
"TrdTrack"));
71 cout <<
"-W- CbmL1TofMerger::Init: "
72 <<
"no TRD track array" << endl;
84 map<Int_t, Bool_t> mapTofHitUsed;
85 mapTofHitUsed.clear();
87 map<Int_t, Double_t> mapTofHitChi2;
88 mapTofHitChi2.clear();
90 map<Int_t, Int_t> mapTofHitTrack;
91 mapTofHitTrack.clear();
93 map<Int_t, Bool_t> mapTrack;
95 for (Int_t iTrack = 0; iTrack < glbTracks->GetEntriesFast(); iTrack++) {
96 mapTrack[iTrack] = kTRUE;
99 map<pair<Int_t, Int_t>, Bool_t> mapForbidden;
100 mapForbidden.clear();
113 Int_t indexOfClosest;
116 while (mapTrack.size() > 0) {
119 for (Int_t iTrack = 0; iTrack < glbTracks->GetEntriesFast(); iTrack++) {
122 if (mapTrack.find(iTrack) == mapTrack.end())
continue;
125 track = L1_DYNAMIC_CAST<CbmGlobalTrack*>(glbTracks->At(iTrack));
127 mapTrack.erase(iTrack);
133 mapTrack.erase(iTrack);
141 if (NULL == trdTrack) {
142 mapTrack.erase(iTrack);
148 *(
const_cast<FairTrackParam*
>(trdTrack->
GetParamLast())));
153 for (Int_t iTof = 0; iTof < tofHits->GetEntriesFast(); iTof++) {
155 if (mapForbidden[make_pair(iTrack, iTof)])
continue;
157 tofHit = L1_DYNAMIC_CAST<CbmTofHit*>(tofHits->At(iTof));
158 if (NULL == tofHit)
continue;
160 zposTof = tofHit->
GetZ();
164 if (kFALSE ==
Overlap(kfTrack, tofHit))
continue;
168 if (chi2 < chi2min) {
170 indexOfClosest = iTof;
175 if (-1 != indexOfClosest) {
177 if (mapTofHitUsed[indexOfClosest]) {
179 if (chi2min < mapTofHitChi2[indexOfClosest]) {
181 oldTrackIndex = mapTofHitTrack[indexOfClosest];
183 L1_DYNAMIC_CAST<CbmGlobalTrack*>(glbTracks->At(oldTrackIndex));
185 mapTrack[oldTrackIndex] = kTRUE;
188 mapForbidden[make_pair(oldTrackIndex, indexOfClosest)] = kTRUE;
191 mapTofHitChi2[indexOfClosest] = chi2min;
192 mapTofHitTrack[indexOfClosest] = iTrack;
193 mapTrack.erase(iTrack);
197 mapForbidden[make_pair(iTrack, indexOfClosest)] = kTRUE;
201 mapTofHitUsed[indexOfClosest] = kTRUE;
202 mapTofHitChi2[indexOfClosest] = chi2min;
203 mapTofHitTrack[indexOfClosest] = iTrack;
204 mapTrack.erase(iTrack);
208 mapTrack.erase(iTrack);
225 Double_t x2 = tofHit->
GetX();
226 Double_t dx2 = tofHit->
GetDx();
227 Bool_t overlap_x = TMath::Abs(x1 - x2) <= (5 + 3 * dx2);
229 Double_t y2 = tofHit->
GetY();
230 Double_t dy2 = tofHit->
GetDy();
231 Bool_t overlap_y = TMath::Abs(y1 - y2) <= (5 + 3 * dy2);
232 return (overlap_x && overlap_y);
247 Double_t chi2 = TMath::Sqrt(dx * dx + dy * dy);