CbmRoot
CbmRichRingTrackAssignClosestD.cxx
Go to the documentation of this file.
1 
9 
10 #include "CbmRichRing.h"
11 
12 #include "CbmGlobalTrack.h"
13 #include "CbmMCTrack.h"
14 #include "CbmTrdTrack.h"
15 #include "FairRootManager.h"
16 #include "FairTrackParam.h"
17 
18 #include "TClonesArray.h"
19 
20 #include <algorithm>
21 #include <iostream>
22 #include <vector>
23 
24 using std::cout;
25 using std::endl;
26 using std::vector;
27 
29  : fGlobalTracks(NULL)
30  , fTrdTracks(NULL)
31  , fTrdAnnCut(-0.5)
32  , fUseTrd(false)
33  , fAlgorithmType(RingTrack) {}
34 
36 
38  FairRootManager* ioman = FairRootManager::Instance();
39  if (NULL == ioman) {
40  Fatal("CbmRichRingTrackAssignClosestD::Init",
41  "RootManager not instantised!");
42  }
43 
44  fGlobalTracks = (TClonesArray*) ioman->GetObject("GlobalTrack");
45  if (NULL == fGlobalTracks) {
46  Fatal("CbmRichRingTrackAssignClosestD::Init", "No GlobalTrack array!");
47  }
48 
49  fTrdTracks = (TClonesArray*) ioman->GetObject("TrdTrack");
50  //if (NULL == fTrdTracks) {Fatal("CbmRichRingTrackAssignClosestD::Init", "No TrdTrack array!");}
51 }
52 
54  TClonesArray* richProj) {
55  if (fAlgorithmType == RingTrack) {
57  } // RingTrack algorithm
58 
59  else if (fAlgorithmType == TrackRing) {
61  } // TrackRing
62 
63  else if (fAlgorithmType == Combined) {
66  } // Combined
67 }
68 
70  TClonesArray* richProj) {
71  Int_t nofTracks = richProj->GetEntriesFast();
72  Int_t nofRings = rings->GetEntriesFast();
73  vector<Int_t> trackIndex;
74  vector<Double_t> trackDist;
75  trackIndex.resize(nofRings);
76  trackDist.resize(nofRings);
77  for (UInt_t i = 0; i < trackIndex.size(); i++) {
78  trackIndex[i] = -1;
79  trackDist[i] = 999.;
80  }
81 
82  for (Int_t iIter = 0; iIter < 4; iIter++) {
83  for (Int_t iRing = 0; iRing < nofRings; iRing++) {
84  if (trackIndex[iRing] != -1) continue;
85  CbmRichRing* pRing = (CbmRichRing*) rings->At(iRing);
86  if (NULL == pRing) continue;
87  if (pRing->GetNofHits() < fMinNofHitsInRing) continue;
88 
89  Double_t xRing = pRing->GetCenterX();
90  Double_t yRing = pRing->GetCenterY();
91  Double_t rMin = 999.;
92  Int_t iTrackMin = -1;
93 
94  for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
95  vector<Int_t>::iterator it =
96  find(trackIndex.begin(), trackIndex.end(), iTrack);
97  if (it != trackIndex.end()) continue;
98 
99  FairTrackParam* pTrack = (FairTrackParam*) richProj->At(iTrack);
100  Double_t xTrack = pTrack->GetX();
101  Double_t yTrack = pTrack->GetY();
102  // no projection onto the photodetector plane
103  if (xTrack == 0 && yTrack == 0) continue;
104 
105  if (fUseTrd && fTrdTracks != NULL && !IsTrdElectron(iTrack)) continue;
106 
107  Double_t dist = TMath::Sqrt((xRing - xTrack) * (xRing - xTrack)
108  + (yRing - yTrack) * (yRing - yTrack));
109 
110  if (dist < rMin) {
111  rMin = dist;
112  iTrackMin = iTrack;
113  }
114  } // loop tracks
115  trackIndex[iRing] = iTrackMin;
116  trackDist[iRing] = rMin;
117  } //loop rings
118 
119  for (UInt_t i1 = 0; i1 < trackIndex.size(); i1++) {
120  for (UInt_t i2 = 0; i2 < trackIndex.size(); i2++) {
121  if (i1 == i2) continue;
122  if (trackIndex[i1] == trackIndex[i2] && trackIndex[i1] != -1) {
123  if (trackDist[i1] >= trackDist[i2]) {
124  trackDist[i1] = 999.;
125  trackIndex[i1] = -1;
126  } else {
127  trackDist[i2] = 999.;
128  trackIndex[i2] = -1;
129  }
130  }
131  }
132  }
133  } //iIter
134 
135  // fill global tracks
136  for (UInt_t i = 0; i < trackIndex.size(); i++) {
137  // CbmRichRing* pRing = (CbmRichRing*)rings->At(i);
138  // cout << "trackIndex[i]:" << trackIndex[i] << " trackDist[i]:" << trackDist[i] << " r:" << pRing->GetRadius() << " x:" << pRing->GetCenterX() << " y:" << pRing->GetCenterY()<< endl;
139  if (trackIndex[i] == -1) continue;
140  CbmGlobalTrack* gTrack = (CbmGlobalTrack*) fGlobalTracks->At(trackIndex[i]);
141  gTrack->SetRichRingIndex(i);
142  }
143 }
144 
146  TClonesArray* richProj) {
147  Int_t nofTracks = richProj->GetEntriesFast();
148  Int_t nofRings = rings->GetEntriesFast();
149 
150  for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
151  CbmGlobalTrack* gTrack = (CbmGlobalTrack*) fGlobalTracks->At(iTrack);
152  // track already has rich segment
153  if (gTrack == NULL || gTrack->GetRichRingIndex() >= 0) continue;
154 
155  FairTrackParam* pTrack = (FairTrackParam*) richProj->At(iTrack);
156  Double_t xTrack = pTrack->GetX();
157  Double_t yTrack = pTrack->GetY();
158  if (xTrack == 0 && yTrack == 0) continue;
159  if (fUseTrd && fTrdTracks != NULL && !IsTrdElectron(iTrack)) continue;
160  Double_t rMin = 999.;
161  Int_t iRingMin = -1;
162  for (Int_t iRing = 0; iRing < nofRings; iRing++) {
163  CbmRichRing* pRing = (CbmRichRing*) rings->At(iRing);
164  if (NULL == pRing) continue;
165  if (pRing->GetNofHits() < fMinNofHitsInRing) continue;
166 
167  Double_t xRing = pRing->GetCenterX();
168  Double_t yRing = pRing->GetCenterY();
169  Double_t dist = TMath::Sqrt((xRing - xTrack) * (xRing - xTrack)
170  + (yRing - yTrack) * (yRing - yTrack));
171  if (dist < rMin) {
172  rMin = dist;
173  iRingMin = iRing;
174  }
175  } // loop rings
176  if (iRingMin < 0) continue;
177  // CbmRichRing* pRing = (CbmRichRing*)rings->At(iRingMin);
178  gTrack->SetRichRingIndex(iRingMin);
179  } //loop tracks
180 }
181 
183  CbmGlobalTrack* gTrack = (CbmGlobalTrack*) fGlobalTracks->At(iTrack);
184  Int_t trdIndex = gTrack->GetTrdTrackIndex();
185  if (trdIndex == -1) return false;
186  CbmTrdTrack* trdTrack = (CbmTrdTrack*) fTrdTracks->At(trdIndex);
187  if (NULL == trdTrack) return false;
188 
189  if (trdTrack->GetPidANN() > fTrdAnnCut) { return true; }
190 
191  return false;
192 }
TrackRing
@ TrackRing
Definition: CbmRichRingTrackAssignClosestD.h:18
CbmGlobalTrack::GetRichRingIndex
Int_t GetRichRingIndex() const
Definition: CbmGlobalTrack.h:41
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmRichRingTrackAssignClosestD::IsTrdElectron
bool IsTrdElectron(int iTrack)
Check if global track was identified as electron in the TRD detector.
Definition: CbmRichRingTrackAssignClosestD.cxx:182
CbmGlobalTrack.h
CbmRichRing::GetNofHits
Int_t GetNofHits() const
Definition: CbmRichRing.h:40
CbmRichRing
Definition: CbmRichRing.h:17
CbmRichRingTrackAssignClosestD::fTrdTracks
TClonesArray * fTrdTracks
Definition: CbmRichRingTrackAssignClosestD.h:65
CbmRichRingTrackAssignClosestD::CbmRichRingTrackAssignClosestD
CbmRichRingTrackAssignClosestD()
Default constructor.
Definition: CbmRichRingTrackAssignClosestD.cxx:28
CbmRichRing.h
CbmRichRingTrackAssignClosestD::fTrdAnnCut
double fTrdAnnCut
Definition: CbmRichRingTrackAssignClosestD.h:67
RingTrack
@ RingTrack
Definition: CbmRichRingTrackAssignClosestD.h:19
CbmRichRingTrackAssignClosestD::~CbmRichRingTrackAssignClosestD
virtual ~CbmRichRingTrackAssignClosestD()
Destructor.
Definition: CbmRichRingTrackAssignClosestD.cxx:35
CbmRichRingTrackAssignClosestD.h
Ring-Track Assignment according to the closest distance criterion.
CbmRichRingTrackAssignClosestD::DoAssignTrackRing
void DoAssignTrackRing(TClonesArray *rings, TClonesArray *richProj)
Implementation of the track-ring version of the algorithm.
Definition: CbmRichRingTrackAssignClosestD.cxx:145
CbmTrdTrack::GetPidANN
Double_t GetPidANN() const
Definition: CbmTrdTrack.h:32
CbmRichRingTrackAssignClosestD::fAlgorithmType
CbmRichRingTrackAssignClosestDAlgorithmEnum fAlgorithmType
Definition: CbmRichRingTrackAssignClosestD.h:69
CbmRichRingTrackAssignClosestD::fUseTrd
bool fUseTrd
Definition: CbmRichRingTrackAssignClosestD.h:68
CbmGlobalTrack::GetTrdTrackIndex
Int_t GetTrdTrackIndex() const
Definition: CbmGlobalTrack.h:39
CbmRichRingTrackAssignClosestD::DoAssignRingTrack
void DoAssignRingTrack(TClonesArray *rings, TClonesArray *richProj)
Implementation of the ring-track version of the algorithm.
Definition: CbmRichRingTrackAssignClosestD.cxx:69
CbmRichRingTrackAssignClosestD::DoAssign
void DoAssign(TClonesArray *rings, TClonesArray *richProj)
Inherited from CbmRichRingTrackAssignBase.
Definition: CbmRichRingTrackAssignClosestD.cxx:53
CbmTrdTrack
Definition: CbmTrdTrack.h:22
CbmGlobalTrack
Definition: CbmGlobalTrack.h:26
richProj
TClonesArray * richProj
Definition: Compute_distance.h:18
CbmMCTrack.h
CbmRichRingTrackAssignClosestD::Init
void Init()
Inherited from CbmRichRingTrackAssignBase.
Definition: CbmRichRingTrackAssignClosestD.cxx:37
CbmRichRing::GetCenterY
Float_t GetCenterY() const
Definition: CbmRichRing.h:81
CbmRichRingTrackAssignClosestD::fGlobalTracks
TClonesArray * fGlobalTracks
Definition: CbmRichRingTrackAssignClosestD.h:64
CbmRichRingTrackAssignBase::fMinNofHitsInRing
int fMinNofHitsInRing
Definition: CbmRichRingTrackAssignBase.h:51
CbmTrdTrack.h
CbmGlobalTrack::SetRichRingIndex
void SetRichRingIndex(Int_t iRing)
Definition: CbmGlobalTrack.h:57
CbmRichRing::GetCenterX
Float_t GetCenterX() const
Definition: CbmRichRing.h:80
Combined
@ Combined
Definition: CbmRichRingTrackAssignClosestD.h:20
rings
TClonesArray * rings
Definition: Analyze_matching.h:21