CbmRoot
Loading...
Searching...
No Matches
CbmL1GlobalTrackFinder.cxx
Go to the documentation of this file.
1/* Copyright (C) 2019-2020 IKF-UFra, GSI
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Valentina Akishina [committer] */
4
5/*
6 *====================================================================
7 *
8 * CBM Level 1 Reconstruction
9 *
10 * Authors: V. Akishina
11 *
12 * e-mail : v.akishina@gsi.de
13 *
14 *====================================================================
15 *
16 * CbmL1GlobalTrackFinder source file
17 *
18 *====================================================================
19 */
21
22#include "CbmEvent.h"
23#include "CbmGlobalTrack.h"
24#include "CbmKfUtil.h"
25#include "CbmMuchTrack.h"
26#include "CbmStsHit.h"
27#include "CbmStsTrack.h"
28#include "CbmTofTrack.h"
29#include "CbmTrack.h"
30#include "CbmTrdTrack.h"
31#include "FairHit.h"
32#include "FairMCPoint.h"
33#include "FairRootManager.h"
34#include "TClonesArray.h"
35#include "TDatabasePDG.h"
36
37#include <vector>
38
39using std::vector;
40
42
43 // ----- Default constructor -------------------------------------------
45 : fGlobalTracks(nullptr)
46 , fStsTracks(nullptr)
47 , fMuchTracks(nullptr)
48 , fTrdTracks(nullptr)
49 , fTofTracks(nullptr)
50{
51 fName = "Global Track Finder L1";
52}
53// -------------------------------------------------------------------------
54
55
56// ----- Destructor ----------------------------------------------------
58// -------------------------------------------------------------------------
59
60// ----- Public method Init --------------------------------------------
62// -------------------------------------------------------------------------
63
64
65// ----- Copy tracks to output array -----------------------------------
67{
68 CbmL1* L1 = CbmL1::Instance();
69 if (!L1) return 0;
70 Int_t globalTrackIndex = fGlobalTracks->GetEntriesFast();
71 Int_t globalTrackIndexStart = globalTrackIndex;
72
73 Int_t stsTrackIndex = fStsTracks->GetEntriesFast();
74 Int_t muchTrackIndex = fMuchTracks->GetEntriesFast();
75 Int_t trdTrackIndex = fTrdTracks->GetEntriesFast();
76 Int_t tofTrackIndex = fTofTracks->GetEntriesFast();
77
78 LOG(debug) << "Copy L1 tracks : " << L1->fvRecoTracks.size() << " tracks in L1";
79
80 for (vector<CbmL1Track>::iterator it = L1->fvRecoTracks.begin(); it != L1->fvRecoTracks.end(); ++it) {
81 CbmL1Track& T = *it;
82 //BEGIN add global track
83 new ((*fGlobalTracks)[globalTrackIndex]) CbmGlobalTrack();
84 if (event) event->AddData(ECbmDataType::kGlobalTrack, globalTrackIndex);
85 CbmGlobalTrack* t = dynamic_cast<CbmGlobalTrack*>(fGlobalTracks->At(globalTrackIndex++));
86 t->SetFlag(0);
89 t->SetChi2(T.GetChiSq());
90 // t->SetLength(T.length);
91 t->SetNDF(T.GetNdf());
92 t->SetChiSqTime(T.GetChiSqTime());
93 t->SetNdfTime(T.GetNdfTime());
94 t->SetPidHypo(T.GetQp() >= 0 ? 211 : -211);
95 // t->SetTime(T.Tpv[6]);
96 // t->SetTimeError(T.Cpv[20]);
97 //END add global track
98 //BEGIN create detector tracks if needed
99 bool hasStsHits = false;
100 bool hasMuchHits = false;
101 bool hasTrdHits = false;
102 bool hasTofHits = false;
103 for (vector<int>::iterator ih = it->Hits.begin(); ih != it->Hits.end(); ++ih) {
104 const CbmL1HitId& h = L1->fvExternalHits[*ih];
105
106 if (h.detId <= 1 && hasStsHits == false) {
107 hasStsHits = true;
108 CbmStsTrack* track = new ((*fStsTracks)[stsTrackIndex]) CbmStsTrack();
109 t->SetStsTrackIndex(stsTrackIndex);
110 if (event) event->AddData(ECbmDataType::kStsTrack, stsTrackIndex);
111 CbmL1TrackToCbmStsTrack(T, track);
112 stsTrackIndex++;
113 }
114 if (h.detId == 2 && hasMuchHits == false) {
115 hasMuchHits = true;
116
117 CbmMuchTrack* track = new ((*fMuchTracks)[muchTrackIndex]) CbmMuchTrack();
118 t->SetMuchTrackIndex(muchTrackIndex);
119 if (event) event->AddData(ECbmDataType::kMuchTrack, muchTrackIndex);
120 CbmL1TrackToCbmMuchTrack(T, track, h.detId);
121 muchTrackIndex++;
122 }
123 if (h.detId == 3 && hasTrdHits == false) {
124 hasTrdHits = true;
125 CbmTrdTrack* track = new ((*fTrdTracks)[trdTrackIndex]) CbmTrdTrack();
126 t->SetTrdTrackIndex(trdTrackIndex);
127 if (event) event->AddData(ECbmDataType::kTrdTrack, trdTrackIndex);
128 CbmL1TrackToCbmTrdTrack(T, track, h.detId);
129 trdTrackIndex++;
130 }
131 if (h.detId == 4 && hasTofHits == false) {
132 hasTofHits = true;
133 CbmTofTrack* track = new ((*fTofTracks)[tofTrackIndex]) CbmTofTrack();
134
135 t->SetTofTrackIndex(tofTrackIndex);
136
137 if (event) event->AddData(ECbmDataType::kTofTrack, tofTrackIndex);
138 CbmL1TrackToCbmTofTrack(T, track, h.detId);
139 tofTrackIndex++;
140
141 // if (event) event->AddData(ECbmDataType::kTofHit, h.hitId);
142 }
143 }
144 //END create detector tracks if needed
145 }
146 return globalTrackIndex - globalTrackIndexStart;
147}
148// -------------------------------------------------------------------------
149
150
151// ----- Public method CbmL1TrackToCbmTrack ------------------------------------------
153{
154 track->SetChiSq(l1track.GetChiSq());
155 track->SetNDF(l1track.GetNdf());
156 //track->SetPreviousTrackId(l1track.GetPreviousTrackId());//???
157 //track->SetFlag(l1track.GetQuality());//???
158
161}
162// -------------------------------------------------------------------------
163
164// ----- Public method CbmL1TrackToCbmStsTrack ------------------------------------------
166{
167 CbmL1Track& T = l1track;
168 CbmL1* L1 = CbmL1::Instance();
169
170 for (vector<int>::iterator ih = T.Hits.begin(); ih != T.Hits.end(); ++ih) {
171 CbmL1HitId& h = L1->fvExternalHits[*ih];
172 if (h.detId == 0) {
173 track->AddMvdHit(h.hitId);
174 }
175 else if (h.detId == 1) {
176 track->AddStsHit(h.hitId);
177 }
178 }
179
180 track->SetFlag(0);
181 track->SetChiSq(T.GetChiSq());
182 track->SetNDF(T.GetNdf());
183 track->SetPidHypo(T.GetQp() >= 0. ? 211 : -211);
184 track->SetStartTime(T.Tpv.GetTime());
185 track->SetStartTimeError(T.Tpv.GetTimeError());
186 track->SetFirstHitTime(T.GetTime());
187 track->SetFirstHitTimeError(T.GetTimeError());
188 track->SetLastHitTime(T.TLast.GetTime());
189 track->SetLastHitTimeError(T.TLast.GetTimeError());
190
193}
194// -------------------------------------------------------------------------
195
196// ----- Public method CbmL1TrackToCbmMuchTrack ------------------------------------------
198{
199
200 CbmL1Track& T = l1track;
201
202 CbmL1* L1 = CbmL1::Instance();
203
204 for (vector<int>::iterator ih = T.Hits.begin(); ih != T.Hits.end(); ++ih) {
205 CbmL1HitId& h = L1->fvExternalHits[*ih];
206 if (h.detId != systemIdT) continue;
207 track->AddHit(h.hitId, kMUCHPIXELHIT);
208 }
209 track->SetChiSq(T.GetChiSq());
210 track->SetNDF(T.GetNdf());
211 //track->SetPreviousTrackId(T->GetPreviousTrackId());//???
212 //track->SetFlag(T->GetQuality());//???
213
216}
217// -------------------------------------------------------------------------
218
219// ----- Public method CbmL1TrackToCbmTrdTrack ------------------------------------------
221{
222 CbmL1Track& T = l1track;
223
224 CbmL1* L1 = CbmL1::Instance();
225
226 for (vector<int>::iterator ih = T.Hits.begin(); ih != T.Hits.end(); ++ih) {
227 CbmL1HitId& h = L1->fvExternalHits[*ih];
228 if (h.detId != systemIdT) continue;
229 track->AddHit(h.hitId, kTRDHIT);
230 }
231
232 track->SetChiSq(T.GetChiSq());
233 track->SetNDF(T.GetNdf());
234 //track->SetPreviousTrackId(T->GetPreviousTrackId());//???
235 //track->SetFlag(T->GetQuality());//???
236
239}
240// -------------------------------------------------------------------------
241
242// ----- Public method CbmL1TrackToCbmTofTrack ------------------------------------------
244{
245 CbmL1Track& T = l1track;
246
247 CbmL1* L1 = CbmL1::Instance();
248
249 for (vector<int>::iterator ih = T.Hits.begin(); ih != T.Hits.end(); ++ih) {
250 CbmL1HitId& h = L1->fvExternalHits[*ih];
251 if (h.detId != systemIdT) continue;
252 track->AddHit(h.hitId, kTOFHIT);
253 }
254 track->SetChiSq(T.GetChiSq());
255 track->SetNDF(T.GetNdf());
256 //track->SetPreviousTrackId(T->GetPreviousTrackId());//???
257 //track->SetFlag(T->GetQuality());//???
258
261}
262// -------------------------------------------------------------------------
263
264// ----- Public method DoFind ------------------------------------------
266{
267
268 if (!fTracks) {
269 LOG(error) << "-E- CbmL1GlobalTrackFinder::DoFind: "
270 << "Track array missing! ";
271 return -1;
272 }
273
274 CbmL1* L1 = CbmL1::Instance();
275 if (!L1) return 0;
276
277 L1->Reconstruct();
278 int ntracks = CopyL1Tracks();
279
280 return ntracks;
281}
282// -------------------------------------------------------------------------
283
284
285// ----- Track finding in one event ------------------------------------
287{
288
289 CbmL1* l1 = CbmL1::Instance();
290 if (!l1) return 0;
291
292 l1->Reconstruct(event);
293 int nTracks = CopyL1Tracks(event);
294
295 return nTracks;
296}
297// -------------------------------------------------------------------------
298
299
300// -------------------------------------------------------------------------
302{
305 CbmL1* l1 = CbmL1::Instance();
306 if (!l1 || !l1->fpAlgo) {
307 LOG(fatal) << "L1 instance doesn't exist or is not initialised";
308 return;
309 }
310 auto* p = TDatabasePDG::Instance()->GetParticle(pdg);
311 if (!p) {
312 LOG(fatal) << "Particle with pdg " << pdg << " doesn't exist";
313 return;
314 }
315 l1->fpAlgo->SetDefaultParticleMass(p->Mass());
316}
TClonesArray * fTofTracks
@ kTOFHIT
Definition CbmHit.h:31
@ kTRDHIT
Definition CbmHit.h:30
@ kMUCHPIXELHIT
Definition CbmHit.h:28
ClassImp(CbmL1GlobalTrackFinder) CbmL1GlobalTrackFinder
Data class for a reconstructed hit in the STS.
Data class for STS tracks.
Generates beam ions for transport simulation.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
void SetChiSqTime(double chi2)
void SetParamLast(const FairTrackParam *parLast)
void SetMuchTrackIndex(int32_t iMuch)
void SetPidHypo(int32_t iPid)
void SetTofTrackIndex(int32_t iTofTrack)
void SetChi2(double chi2)
void SetTrdTrackIndex(int32_t iTrd)
void SetParamFirst(const FairTrackParam *parFirst)
void SetNDF(int32_t ndf)
void SetFlag(int32_t iFlag)
void SetNdfTime(int32_t ndf)
void SetStsTrackIndex(int32_t iSts)
void CbmL1TrackToCbmTrack(CbmL1Track T, CbmTrack *track, int systemIdT)
void CbmL1TrackToCbmStsTrack(CbmL1Track T, CbmStsTrack *track)
Int_t CopyL1Tracks(CbmEvent *event=nullptr)
void CbmL1TrackToCbmTrdTrack(CbmL1Track T, CbmTrdTrack *track, int systemIdT)
void CbmL1TrackToCbmMuchTrack(CbmL1Track T, CbmMuchTrack *track, int systemIdT)
void CbmL1TrackToCbmTofTrack(CbmL1Track T, CbmTofTrack *track, int systemIdT)
virtual Int_t FindTracks(CbmEvent *event)
cbm::algo::kf::TrackParamD TLast
Track parameters in the end of the track.
Definition CbmL1Track.h:102
Definition CbmL1.h:109
static CbmL1 * Instance()
Pointer to CbmL1 instance.
Definition CbmL1.h:171
void Reconstruct(CbmEvent *event=nullptr)
Definition CbmL1.cxx:581
ca::Vector< CbmL1HitId > fvExternalHits
Array of hits.
Definition CbmL1.h:484
ca::Framework * fpAlgo
Pointer to the L1 track finder algorithm.
Definition CbmL1.h:425
ca::Vector< CbmL1Track > fvRecoTracks
Reconstructed tracks container.
Definition CbmL1.h:429
TClonesArray * fTracks
void AddMvdHit(int32_t hitIndex)
Definition CbmStsTrack.h:55
void AddStsHit(int32_t hitIndex)
Definition CbmStsTrack.h:61
void SetLastHitTimeError(double error)
Definition CbmTrack.h:96
void SetStartTimeError(double error)
Definition CbmTrack.h:92
void SetLastHitTime(double time)
Definition CbmTrack.h:95
void AddHit(int32_t index, HitType type)
Definition CbmTrack.cxx:97
void SetFirstHitTime(double time)
Definition CbmTrack.h:93
void SetFirstHitTimeError(double error)
Definition CbmTrack.h:94
void SetPidHypo(int32_t pid)
Definition CbmTrack.h:79
void SetFlag(int32_t flag)
Definition CbmTrack.h:80
void SetParamFirst(const FairTrackParam *par)
Definition CbmTrack.h:86
void SetChiSq(double chiSq)
Definition CbmTrack.h:81
void SetStartTime(double time)
Definition CbmTrack.h:91
void SetNDF(int32_t ndf)
Definition CbmTrack.h:82
void SetParamLast(const FairTrackParam *par)
Definition CbmTrack.h:87
void SetDefaultParticleMass(fscal mass)
Sets a default particle mass for the track fit.
T GetNdf() const
Gets NDF of track fit model.
T GetChiSq() const
Gets Chi-square of track fit model.
cbm::algo::kf::TrackParamD ConvertTrackParam(const FairTrackParam &par)
copy fair track param to Ca track param
Definition CbmKfUtil.cxx:12