CbmRoot
Loading...
Searching...
No Matches
CbmCaTimeSliceReader.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
11
12#include "CaDefs.h"
13#include "CaInputData.h"
14#include "CaParameters.h"
15#include "CbmGlobalTrack.h"
16#include "CbmKfUtil.h" // for CopyTrackParam2TC
17#include "CbmL1.h"
18#include "CbmMuchTrack.h"
19#include "CbmStsTrack.h"
20#include "CbmTofTrack.h"
21#include "CbmTrdTrack.h"
22#include "FairRootManager.h"
23#include "Logger.h"
24
25#include <algorithm>
26#include <numeric>
27
29
30using namespace cbm::algo::ca::constants;
31using namespace cbm::algo;
32
34
35// ---------------------------------------------------------------------------------------------------------------------
36//
38{
39 // Detector used
40 fvbUseDet.fill(false);
41
42 // Input branches
43 // fpBrTimeSlice = nullptr;
44 fpParameters = nullptr;
45
46 fvpBrHits.fill(nullptr);
47
48 fpBrRecoTracks = nullptr;
49 fpBrStsTracks = nullptr;
50 fpBrMuchTracks = nullptr;
51 fpBrTrdTracks = nullptr;
52 fpBrTofTracks = nullptr;
53
54 // Pointers to output containers
55 fpvHitIds = nullptr;
56 fpvQaHits = nullptr;
57 fpIODataManager = nullptr;
58 fpvTracks = nullptr;
59
60 fNofHits = 0;
61 fNofHitKeys = 0;
62 fFirstHitKey = 0;
63
64 std::fill(fvHitFirstIndexDet.begin(), fvHitFirstIndexDet.end(), 0);
65}
66
67// ---------------------------------------------------------------------------------------------------------------------
68//
70{
71 // Check parameters
72 if (!fpParameters.get()) {
73 throw std::logic_error("Tracking parameters object was not defined");
74 }
75 if (!fpvHitIds) {
76 throw std::logic_error("Hit index container was not defined");
77 }
78
79 //if (!fpBrTimeSlice) {
80 //throw std::logic_error("Time slice branch is unavailable");
81 //}
82
83 for (int iDet = 0; iDet < static_cast<int>(ca::EDetectorID::END); ++iDet) {
84 if (fvbUseDet[iDet] && !fvpBrHits[iDet]) {
85 throw std::logic_error(std::string(kDetName[iDet]) + " hits branch is not found");
86 }
87 }
88
89 if (fpvTracks) {
91 if (!fpBrRecoTracks) {
92 throw std::logic_error("StsTrack branch is unavailable");
93 }
94 }
96 if (!fpBrRecoTracks) {
97 throw std::logic_error("GlobalTrack branch is unavailable");
98 }
99 if (fvbUseDet[ca::EDetectorID::kSts] && !fpBrStsTracks) {
100 throw std::logic_error("StsTrack branch is not found");
101 }
102 if (fvbUseDet[ca::EDetectorID::kMuch] && !fpBrMuchTracks) {
103 throw std::logic_error("MuchTrack branch is not found");
104 }
105 if (fvbUseDet[ca::EDetectorID::kTrd] && !fpBrTrdTracks) {
106 throw std::logic_error("TrdTrack branch is not found");
107 }
108 if (fvbUseDet[ca::EDetectorID::kTof] && !fpBrTofTracks) {
109 throw std::logic_error("TofTrack branch is not found");
110 }
111 }
112 }
113}
114
115// ---------------------------------------------------------------------------------------------------------------------
116//
118try {
119 LOG(info) << "TimeSliceReader: initializing run ... ";
120
121 // Init tracking detector interfaces
122 fvpDetInterface[ca::EDetectorID::kMvd] = CbmMvdTrackingInterface::Instance();
123 fvpDetInterface[ca::EDetectorID::kSts] = CbmStsTrackingInterface::Instance();
124 fvpDetInterface[ca::EDetectorID::kMuch] = CbmMuchTrackingInterface::Instance();
125 fvpDetInterface[ca::EDetectorID::kTrd] = CbmTrdTrackingInterface::Instance();
126 fvpDetInterface[ca::EDetectorID::kTof] = CbmTofTrackingInterface::Instance();
127
128 // ** Init data branches **
129
130 auto* pFairManager = FairRootManager::Instance();
131 LOG_IF(fatal, !pFairManager) << "TimeSliceReader: FairRootManager was not defined";
132
133 // fpBrTimeSlice = dynamic_cast<CbmTimeSlice*>(pFairManager->GetObject("TimeSlice."));
134
135 // Init branches
136 auto InitHitBranch = [&](ca::EDetectorID detID, const char* branchName) -> bool {
137 if (fvbUseDet[detID]) {
138 fvpBrHits[detID] = dynamic_cast<TClonesArray*>(pFairManager->GetObject(branchName));
139 }
140 return static_cast<bool>(fvpBrHits[detID]);
141 };
142
143 InitHitBranch(ca::EDetectorID::kMvd, "MvdHit");
144 InitHitBranch(ca::EDetectorID::kSts, "StsHit");
145 InitHitBranch(ca::EDetectorID::kMuch, "MuchPixelHit");
146 InitHitBranch(ca::EDetectorID::kTrd, "TrdHit");
147 if (!InitHitBranch(ca::EDetectorID::kTof, "TofCalHit")) {
148 LOG(warn) << "TimeSliceReader: TofCalHit branch not found, trying to get TofHit branch of uncalibrated hits";
149 InitHitBranch(ca::EDetectorID::kTof, "TofHit");
150 }
151
152 // Init track branches
153
154 if (fpvTracks) {
155 switch (fTrackingMode) {
157 fpBrRecoTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("StsTrack"));
158 break;
160 fpBrRecoTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("GlobalTrack"));
161 if (fvbUseDet[ca::EDetectorID::kSts]) {
162 fpBrStsTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("StsTrack"));
163 }
164 if (fvbUseDet[ca::EDetectorID::kMuch]) {
165 fpBrMuchTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("MuchTrack"));
166 }
167 if (fvbUseDet[ca::EDetectorID::kTrd]) {
168 fpBrTrdTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("TrdTrack"));
169 }
170 if (fvbUseDet[ca::EDetectorID::kTof]) {
171 fpBrTofTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("TofTrack"));
172 }
173 break;
174 }
175 }
176
177 // Check initialization
178 this->CheckInit();
179
180 //clrs::CL - clear log
181 //clrs::GNb - green bold log
182 //clrs::RDb - red bold log
183
184 LOG(info) << "TimeSliceReader: initializing run ... " << clrs::GNb << "done" << clrs::CL;
185 return true;
186}
187catch (const std::logic_error& error) {
188 LOG(info) << "TimeSliceReader: initializing run ... " << clrs::RDb << "failed" << clrs::CL
189 << "\nReason: " << error.what();
190 return false;
191}
192
193// ---------------------------------------------------------------------------------------------------------------------
194//
196{
197 fpEvent = pEvent;
198 this->ReadHits();
199 if (fpvTracks) {
200 this->ReadRecoTracks();
201 }
202}
203
204
205// ---------------------------------------------------------------------------------------------------------------------
206//
208{
209 assert(fpBrRecoTracks);
210 int nTracks = 0;
211 switch (fTrackingMode) {
213 nTracks = fpEvent ? fpEvent->GetNofData(ECbmDataType::kStsTrack) : fpBrRecoTracks->GetEntriesFast();
214 fpvTracks->reset(nTracks);
215 // Fill tracks from StsTrack branch
216 for (int iT = 0; iT < nTracks; ++iT) {
217 int iText = fpEvent ? fpEvent->GetIndex(ECbmDataType::kStsTrack, iT) : iT;
218 auto* pInputTrack = static_cast<CbmStsTrack*>(fpBrRecoTracks->At(iText));
219 auto& track = (*fpvTracks)[iT];
220
221 track.Set(cbm::kf::ConvertTrackParam(*pInputTrack->GetParamFirst()));
222 track.TLast = cbm::kf::ConvertTrackParam(*pInputTrack->GetParamLast());
223 track.ChiSq() = pInputTrack->GetChiSq();
224 track.Ndf() = pInputTrack->GetNDF();
225 track.Tpv.Time() = pInputTrack->GetStartTime();
226 track.Tpv.C55() = pInputTrack->GetStartTimeError();
227 track.Time() = pInputTrack->GetFirstHitTime();
228 track.C55() = pInputTrack->GetFirstHitTimeError();
229 track.TLast.Time() = pInputTrack->GetLastHitTime();
230 track.TLast.C55() = pInputTrack->GetLastHitTimeError();
231 track.Hits.clear();
232 track.Hits.reserve(pInputTrack->GetTotalNofHits());
233 for (int iH = 0; iH < pInputTrack->GetNofMvdHits(); ++iH) {
234 int iHext = pInputTrack->GetMvdHitIndex(iH);
235 int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kMvd][iHext];
236 track.Hits.push_back(iHint);
237 } // iH
238 for (int iH = 0; iH < pInputTrack->GetNofStsHits(); ++iH) {
239 int iHext = pInputTrack->GetStsHitIndex(iH);
240 int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kSts][iHext];
241 track.Hits.push_back(iHint);
242 } // iH
243 } // iT
244 break;
245
247 // Fill tracks from GlobalTrack branch
248 nTracks = fpEvent ? fpEvent->GetNofData(ECbmDataType::kGlobalTrack) : fpBrRecoTracks->GetEntriesFast();
249 fpvTracks->reset(nTracks);
250 for (int iT = 0; iT < nTracks; ++iT) {
251 int iText = fpEvent ? fpEvent->GetIndex(ECbmDataType::kGlobalTrack, iT) : iT;
252 auto* pInputTrack = static_cast<CbmGlobalTrack*>(fpBrRecoTracks->At(iText));
253 auto& track = (*fpvTracks)[iT];
254 track.Set(cbm::kf::ConvertTrackParam(*pInputTrack->GetParamFirst()));
255 track.TLast = cbm::kf::ConvertTrackParam(*pInputTrack->GetParamLast());
256 track.ChiSq() = pInputTrack->GetChi2();
257 track.Ndf() = pInputTrack->GetNDF();
258
259 // ** Fill information from local tracks **
260 // STS tracks (+ MVD)
261 if (fvbUseDet[ca::EDetectorID::kSts]) {
262 int iStsTrkId = pInputTrack->GetStsTrackIndex();
263 if (iStsTrkId > -1) {
264 auto* pStsTrack = static_cast<CbmStsTrack*>(fpBrStsTracks->At(iStsTrkId));
265 if (fvbUseDet[ca::EDetectorID::kMvd]) {
266 for (int iH = 0; iH < pStsTrack->GetNofMvdHits(); ++iH) {
267 int iHext = pStsTrack->GetMvdHitIndex(iH);
268 int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kMvd][iHext];
269 track.Hits.push_back(iHint);
270 }
271 }
272 for (int iH = 0; iH < pStsTrack->GetNofStsHits(); ++iH) {
273 int iHext = pStsTrack->GetStsHitIndex(iH);
274 int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kSts][iHext];
275 track.Hits.push_back(iHint);
276 }
277 }
278 }
279
280 // MUCH tracks
281 if (fvbUseDet[ca::EDetectorID::kMuch]) {
282 int iMuchTrkId = pInputTrack->GetMuchTrackIndex();
283 if (iMuchTrkId > -1) {
284 auto* pMuchTrack = static_cast<CbmMuchTrack*>(fpBrMuchTracks->At(iMuchTrkId));
285 for (int iH = 0; iH < pMuchTrack->GetNofHits(); ++iH) {
286 int iHext = pMuchTrack->GetHitIndex(iH);
287 int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kMuch][iHext];
288 track.Hits.push_back(iHint);
289 }
290 }
291 }
292
293 // TRD tracks
294 if (fvbUseDet[ca::EDetectorID::kTrd]) {
295 int iTrdTrkId = pInputTrack->GetTrdTrackIndex();
296 if (iTrdTrkId > -1) {
297 const auto* pTrdTrack = static_cast<const CbmTrdTrack*>(fpBrTrdTracks->At(iTrdTrkId));
298 for (int iH = 0; iH < pTrdTrack->GetNofHits(); ++iH) {
299 int iHext = pTrdTrack->GetHitIndex(iH);
300 int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kTrd][iHext];
301 track.Hits.push_back(iHint);
302 } // iH
303 }
304 }
305
306 // TOF tracks
307 if (fvbUseDet[ca::EDetectorID::kTof]) {
308 int iTofTrkId = pInputTrack->GetTofTrackIndex();
309 if (iTofTrkId > -1) {
310 const auto* pTofTrack = static_cast<const CbmTofTrack*>(fpBrTofTracks->At(iTofTrkId));
311 for (int iH = 0; iH < pTofTrack->GetNofHits(); ++iH) {
312 int iHext = pTofTrack->GetHitIndex(iH);
313 int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kTof][iHext];
314 track.Hits.push_back(iHint);
315 } // iH
316 } // if iTofTrkId > -1
317 } // if fvbUseDet[ca::EDetectorID::kTof]
318 } // iT
319 break;
320 }
321}
322
323// ---------------------------------------------------------------------------------------------------------------------
324//
325void TimeSliceReader::RegisterIODataManager(std::shared_ptr<ca::DataManager>& pIODataManager)
326{
327 LOG_IF(fatal, !pIODataManager.get()) << "TimeSliceReader: passed null pointer as a ca::DataManager instance";
328 fpIODataManager = pIODataManager;
329}
330
331// ---------------------------------------------------------------------------------------------------------------------
332//
334{
335 int nStationsActive = fpParameters->GetNstationsActive();
336 ca::Vector<CbmL1HitDebugInfo> vNewHits{"TimeSliceReader::SortQaHits(): vNewHits", fpvQaHits->size()};
337 std::vector<int> vHitFstIndexes(nStationsActive + 1, 0);
338 std::vector<int> vNofHitsStored(nStationsActive, 0);
339
340 // Count number of hits in each station (NOTE: we could use here boarders from the IO data manager, but we would keep
341 // these two procedures independent)
342 std::for_each(fpvQaHits->begin(), fpvQaHits->end(), [&](const auto& h) { ++vHitFstIndexes[h.GetStationId() + 1]; });
343 for (int iSt = 0; iSt < nStationsActive; ++iSt) {
344 vHitFstIndexes[iSt + 1] += vHitFstIndexes[iSt];
345 }
346 for (const auto& hit : (*fpvQaHits)) {
347 int iSt = hit.GetStationId();
348 vNewHits[vHitFstIndexes[iSt] + (vNofHitsStored[iSt]++)] = hit;
349 }
350
351 auto name = fpvQaHits->GetName();
352 std::swap(vNewHits, (*fpvQaHits));
353 fpvQaHits->SetName(name);
354}
355
356
357// ---------------------------------------------------------------------------------------------------------------------
358//
359template<ca::EDetectorID DetID>
361{
362 using Hit_t = HitTypes_t::at<DetID>;
363
364 if (!fvbUseDet[DetID]) {
365 return 0;
366 } // Detector is entirelly not used
367
368 const auto* pDetInterface = fvpDetInterface[DetID];
369 int nHitsTot = fpEvent ? fpEvent->GetNofData(kCbmHitType[DetID]) : fvpBrHits[DetID]->GetEntriesFast();
370 int nHitsStored = 0; // number of hits used in tracking
371
372 fFirstHitKey = fNofHitKeys;
373
374 for (int iH = 0; iH < nHitsTot; ++iH) {
375 int iHext = fpEvent ? fpEvent->GetIndex(kCbmHitType[DetID], iH) : iH;
376 if (iHext < 0) {
377 LOG(warn) << "TimeSliceReader: hit index stored in the event is negative: " << iHext;
378 continue;
379 }
380 tools::HitRecord hitRecord;
381
382 auto* pHit = static_cast<Hit_t*>(fvpBrHits[DetID]->At(iHext));
383 int iStGeom = pDetInterface->GetTrackingStationIndex(pHit);
384 if (iStGeom < 0) {
385 continue; // NOTE: sensors with iStGeom = -1 are ignored in tracking
386 }
387
388 // Fill out detector specific data
389 if constexpr (ca::EDetectorID::kSts == DetID) {
390 hitRecord.fStripF = fFirstHitKey + pHit->GetFrontClusterId();
391 hitRecord.fStripB = fFirstHitKey + pHit->GetBackClusterId();
392 }
393 else if constexpr (ca::EDetectorID::kTof == DetID) {
394 // *** Additional cuts for TOF ***
395 // Skip Bmon hits
396 if (5 == CbmTofAddress::GetSmType(pHit->GetAddress())) {
397 continue;
398 }
399 }
400
401 int iStActive = fpParameters->GetStationIndexActive(iStGeom, DetID);
402 if (iStActive < 0) {
403 continue;
404 } // Cut off inactive stations
405
406 // Fill out data common for all the detectors
407 hitRecord.fStaId = iStActive;
408 hitRecord.fX = pHit->GetX();
409 hitRecord.fY = pHit->GetY();
410 hitRecord.fZ = pHit->GetZ();
411 hitRecord.fDx2 = pHit->GetDx() * pHit->GetDx();
412 hitRecord.fDy2 = pHit->GetDy() * pHit->GetDy();
413 hitRecord.fDxy = pHit->GetDxy();
414 hitRecord.fT = pHit->GetTime();
415 hitRecord.fDt2 = pHit->GetTimeError() * pHit->GetTimeError();
416
417 // Apply hit error smearing according to misalignment
418 hitRecord.fDx2 += fpParameters->GetMisalignmentXsq(DetID);
419 hitRecord.fDy2 += fpParameters->GetMisalignmentYsq(DetID);
420 hitRecord.fDt2 += fpParameters->GetMisalignmentTsq(DetID);
421
422 std::tie(hitRecord.fRangeX, hitRecord.fRangeY, hitRecord.fRangeT) = pDetInterface->GetHitRanges(*pHit);
423
424 hitRecord.fDet = static_cast<int>(DetID);
425 hitRecord.fDataStream = (static_cast<int64_t>(hitRecord.fDet) << 60) | pHit->GetAddress();
426 hitRecord.fExtId = iHext;
427
428 // Check if hit values are reasonable
429 {
430 const ca::Station<fvec>& station = fpParameters->GetStation(iStActive);
431 if (pHit->GetX() < station.GetXmin<fscal>() * 1.2 || pHit->GetX() > station.GetXmax<fscal>() * 1.2
432 || pHit->GetY() < station.GetYmin<fscal>() * 1.2 || pHit->GetY() > station.GetYmax<fscal>() * 1.2
433 || fabs(pHit->GetZ() - station.GetZ<fscal>()) > 150) {
434 LOG(error) << "Ca:TimeSliceReader: " << CbmL1::GetDetectorName(DetID)
435 << " hit is outside of the station boundaries: " << hitRecord.ToString() << "; station X "
436 << station.GetXmin<fscal>() << ".." << station.GetXmax<fscal>() << " Y " << station.GetYmin<fscal>()
437 << ".." << station.GetYmax<fscal>() << " Z " << station.GetZ<fscal>();
438 continue;
439 }
440 }
441
442 // Update number of hit keys
443 if constexpr (ca::EDetectorID::kSts == DetID) {
444 if (fNofHitKeys <= hitRecord.fStripF) {
445 fNofHitKeys = hitRecord.fStripF + 1;
446 }
447 if (fNofHitKeys <= hitRecord.fStripB) {
448 fNofHitKeys = hitRecord.fStripB + 1;
449 }
450 }
451 else {
452 hitRecord.fStripF = fFirstHitKey + iHext;
453 hitRecord.fStripB = hitRecord.fStripF;
454 if (fNofHitKeys <= hitRecord.fStripF) {
455 fNofHitKeys = hitRecord.fStripF + 1;
456 }
457 }
458
459 // Save hit to data structures
460 if (hitRecord.Accept()) {
461 this->StoreHitRecord(hitRecord);
462 ++nHitsStored;
463 }
464 } // iH
465
466 return nHitsStored;
467}
468
469// ---------------------------------------------------------------------------------------------------------------------
470//
472{
473 fNofHits = 0;
474 fNofHitKeys = 0;
475 fFirstHitKey = 0;
476
477 // TODO: Address case with CbmEvent != nullptr
478 for (int iDet = 0; iDet < static_cast<int>(ca::EDetectorID::END); ++iDet) {
479 if (fvbUseDet[iDet]) {
480 fvNofHitsTotal[iDet] = fpEvent ? fpEvent->GetNofData(kCbmHitType[iDet]) : fvpBrHits[iDet]->GetEntriesFast();
481 }
482 }
483
484 int nHitsTot = std::accumulate(fvNofHitsTotal.begin(), fvNofHitsTotal.end(), 0);
485
486 // Resize the containers
487 if (fpvHitIds) {
488 fpvHitIds->clear();
489 fpvHitIds->reserve(nHitsTot);
490 }
491 if (fpvQaHits) {
492 fpvQaHits->clear();
493 fpvQaHits->reserve(nHitsTot);
494 }
495 if (fpIODataManager) {
496 fpIODataManager->ResetInputData(nHitsTot);
497 }
498
499 std::fill(fvHitFirstIndexDet.begin(), fvHitFirstIndexDet.end(), 0);
500
501 // Read hits for different detectors
507
508 // Save first hit index for different detector subsystems
509 for (uint32_t iDet = 0; iDet < fvNofHitsUsed.size(); ++iDet) {
510 fvHitFirstIndexDet[iDet + 1] = fvHitFirstIndexDet[iDet] + fvNofHitsUsed[iDet];
511 }
512
513 fNofHits = std::accumulate(fvNofHitsUsed.cbegin(), fvNofHitsUsed.cend(), 0);
514
515 LOG(debug) << "CA: N hits used/tot = " << fNofHits << "/" << nHitsTot;
516
517 // Update number of hit keys in input data object
518 if (fpIODataManager) {
519 fpIODataManager->SetNhitKeys(fNofHitKeys);
520 }
521
522 // Sort debug hits
523 if (fpvQaHits && fbSortQaHits) {
524 this->SortQaHits();
525 }
526
527 // Update maps of ext->int hit indexes
528 // NOTE: fvpHitIds must be initialized, if we want to read tracks from the file
529 if (fpvHitIds) {
530 auto ResetIndexMap = [&](auto& m) mutable { m.clear(); };
531 std::for_each(fvmHitExtToIntIndexMap.begin(), fvmHitExtToIntIndexMap.end(), ResetIndexMap);
532 for (int iH = 0; iH < fNofHits; ++iH) {
533 const auto& hit = (*fpvQaHits)[iH];
534 fvmHitExtToIntIndexMap[hit.Det][hit.ExtIndex] = iH;
535 }
536 }
537}
538
539// ---------------------------------------------------------------------------------------------------------------------
540//
542{
543 // Save the algo hit
544 if (fpIODataManager.get()) {
545 ca::Hit aHit;
546 aHit.SetFrontKey(hitRecord.fStripF);
547 aHit.SetBackKey(hitRecord.fStripB);
548 aHit.SetX(hitRecord.fX);
549 aHit.SetY(hitRecord.fY);
550 aHit.SetZ(hitRecord.fZ);
551 aHit.SetT(hitRecord.fT);
552 aHit.SetDx2(hitRecord.fDx2);
553 aHit.SetDy2(hitRecord.fDy2);
554 aHit.SetDxy(hitRecord.fDxy);
555 aHit.SetDt2(hitRecord.fDt2);
556 aHit.SetRangeX(hitRecord.fRangeX);
557 aHit.SetRangeY(hitRecord.fRangeY);
558 aHit.SetRangeT(hitRecord.fRangeT);
559 aHit.SetId(static_cast<int>(fpIODataManager->GetNofHits()));
560 aHit.SetStation(hitRecord.fStaId);
561
562 fpIODataManager->PushBackHit(aHit, hitRecord.fDataStream);
563 }
564
565 // Save hit ID information
566 if (fpvHitIds) {
567 fpvHitIds->emplace_back(hitRecord.fDet, hitRecord.fExtId);
568 }
569
570 // Save debug information
571 if (fpvQaHits) {
572 CbmL1HitDebugInfo aHitQa;
573 aHitQa.Det = hitRecord.fDet;
574 aHitQa.ExtIndex = hitRecord.fExtId;
575 aHitQa.IntIndex = static_cast<int>(fpvQaHits->size());
576 aHitQa.iStation = hitRecord.fStaId;
577 aHitQa.x = hitRecord.fX;
578 aHitQa.y = hitRecord.fY;
579 aHitQa.z = hitRecord.fZ;
580 aHitQa.dx = sqrt(hitRecord.fDx2);
581 aHitQa.dy = sqrt(hitRecord.fDy2);
582 aHitQa.dxy = hitRecord.fDxy;
583 aHitQa.time = hitRecord.fT;
584 aHitQa.dt = sqrt(hitRecord.fDt2);
585 fpvQaHits->push_back(aHitQa);
586 }
587}
Compile-time constants definition for the CA tracking algorithm.
Structure for input data to the L1 tracking algorithm (declaration)
Time-slice/event reader for CA tracker in CBM (header)
@ kMCBM
Global tracking in mCBM (STS, MuCh, TRD, TOF), results stored to GlobalTrack branch.
@ kSTS
Local tracking in CBM (STS + MVD), results stored to the StsTrack branch.
Data class for STS tracks.
friend fvec sqrt(const fvec &a)
Generates beam ions for transport simulation.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
size_t GetNofData() const
Definition CbmEvent.cxx:58
uint32_t GetIndex(ECbmDataType type, uint32_t iData) const
Definition CbmEvent.cxx:42
int ExtIndex
index of hit in the external branch
Definition CbmL1Hit.h:142
int Det
detector subsystem ID
Definition CbmL1Hit.h:145
double dy
y coordinate error [cm]
Definition CbmL1Hit.h:151
double y
y coordinate of position [cm]
Definition CbmL1Hit.h:147
int IntIndex
index of hit in the internal array
Definition CbmL1Hit.h:143
int iStation
index of station in active stations array
Definition CbmL1Hit.h:144
double time
hit time [ns]
Definition CbmL1Hit.h:149
double dx
x coordinate error [cm]
Definition CbmL1Hit.h:150
double dxy
covariance between x and y [cm2]
Definition CbmL1Hit.h:153
double z
z coordinate of position [cm]
Definition CbmL1Hit.h:148
double x
x coordinate of position [cm]
Definition CbmL1Hit.h:146
double dt
time error [ns]
Definition CbmL1Hit.h:152
static constexpr const char * GetDetectorName(ca::EDetectorID detectorID)
Utility to map the L1DetectorID items into detector names.
Definition CbmL1.h:245
static CbmMuchTrackingInterface * Instance()
Gets pointer to the instance of the CbmMuchTrackingInterface.
static CbmMvdTrackingInterface * Instance()
Gets pointer to the instance of the CbmMvdTrackingInterface.
static CbmStsTrackingInterface * Instance()
Gets pointer to the instance of the CbmStsTrackingInterface class.
static int32_t GetSmType(uint32_t address)
static CbmTofTrackingInterface * Instance()
Gets pointer to the instance of the CbmTofTrackingInterface.
static CbmTrdTrackingInterface * Instance()
Gets pointer to the instance of the CbmTrdTrackingInterface.
ca::Hit class describes a generic hit for the CA tracker
Definition CaHit.h:32
void SetX(fscal x)
Set the X coordinate.
Definition CaHit.h:54
void SetRangeT(fscal rangeT)
Set the +/- range of uncertainty of time.
Definition CaHit.h:84
void SetDt2(fscal dt2)
Set the uncertainty of time.
Definition CaHit.h:75
void SetDy2(fscal dy2)
Set the uncertainty of Y coordinate.
Definition CaHit.h:69
void SetRangeY(fscal rangeY)
Set the +/- range of uncertainty of Y coordinate.
Definition CaHit.h:81
void SetStation(int station)
Set the station index.
Definition CaHit.h:90
void SetDx2(fscal dx2)
Set the uncertainty of X coordinate.
Definition CaHit.h:66
void SetRangeX(fscal rangeX)
Set the +/- range of uncertainty of X coordinate.
Definition CaHit.h:78
void SetZ(fscal z)
Set the Z coordinate.
Definition CaHit.h:60
void SetBackKey(HitKeyIndex_t key)
Set the back key index.
Definition CaHit.h:51
void SetFrontKey(HitKeyIndex_t key)
Set the front key index.
Definition CaHit.h:48
void SetId(HitIndex_t id)
Set the hit id.
Definition CaHit.h:87
void SetT(fscal t)
Set the time.
Definition CaHit.h:63
void SetDxy(fscal dxy)
Set the X/Y covariance.
Definition CaHit.h:72
void SetY(fscal y)
Set the Y coordinate.
Definition CaHit.h:57
DataOut GetXmax() const
Gets limit of the station size in x-axis direction.
Definition CaStation.h:94
DataOut GetYmax() const
Gets limit of the station size in y-axis direction.
Definition CaStation.h:108
DataOut GetXmin() const
Gets limit of the station size in x-axis direction.
Definition CaStation.h:101
DataOut GetYmin() const
Gets limit of the station size in y-axis direction.
Definition CaStation.h:115
DataOut GetZ() const
Gets z-position of the station.
Definition CaStation.h:87
void SetName(const std::string &s)
Sets the name of the vector.
Definition CaVector.h:98
void push_back(Tinput value)
Pushes back a value to the vector.
Definition CaVector.h:176
std::string GetName() const
Gets name of the vector.
Definition CaVector.h:110
void reserve(std::size_t count)
Reserves a new size for the vector.
Definition CaVector.h:162
void reset(std::size_t count, Tinput... value)
Clears vector and resizes it to the selected size with selected values.
Definition CaVector.h:121
void emplace_back(Tinput &&... value)
Creates a parameter in the end of the vector.
Definition CaVector.h:196
A reader of time slice for CA tracker.
TClonesArray * fpBrTrdTracks
Input branch for reconstructed TRD tracks ("TrdTrack")
ca::Vector< CbmL1Track > * fpvTracks
Pointer to array of reconstructed tracks.
int fFirstHitKey
First index of hit key for the detector subsystem.
void ReadRecoTracks()
Reads reconstructed tracks.
std::shared_ptr< ca::DataManager > fpIODataManager
Pointer to input data manager.
void StoreHitRecord(const tools::HitRecord &hitRecord)
Saves hit to data structures.
TClonesArray * fpBrRecoTracks
Input branch for reconstructed tracks ("GlobalTrack", "StsTrack")
TClonesArray * fpBrTofTracks
Input branch for reconstructed TOF tracks ("TofTrack")
TClonesArray * fpBrStsTracks
Input branch for reconstructed STS tracks ("StsTrack")
int fNofHitKeys
Recorded number of hit keys.
DetIdArr_t< bool > fvbUseDet
Flag: is detector subsystem used.
DetIdArr_t< TClonesArray * > fvpBrHits
Input branch for hits.
void ReadEvent(CbmEvent *pEvent=nullptr)
Reads time slice.
void SortQaHits()
Sorts QA hit objects by stations.
ECbmCaTrackingMode fTrackingMode
Tracking mode.
std::array< int, constants::size::MaxNdetectors+1 > fvHitFirstIndexDet
First hit index in detector.
DetIdArr_t< int > fvNofHitsUsed
Number of used hits in detector.
CbmEvent * fpEvent
Pointer to the event object.
TClonesArray * fpBrMuchTracks
Input branch for reconstructed MuCh tracks ("MuchTrack")
std::shared_ptr< ca::Parameters< float > > fpParameters
Pointer to tracking parameters object.
ca::Vector< CbmL1HitDebugInfo > * fpvQaHits
Pointer to array of debug hits.
DetIdArr_t< const CbmTrackingDetectorInterfaceBase * > fvpDetInterface
Pointers to the tracking detector interfaces for each subsystem.
int ReadHitsForDetector()
Reads hits for a given detector subsystem.
int fNofHits
Stored number of hits.
void RegisterIODataManager(std::shared_ptr< ca::DataManager > &ioDataManager)
Registers the CA IO data manager instance.
DetIdArr_t< std::unordered_map< int, int > > fvmHitExtToIntIndexMap
Hit index map ext -> int.
bool InitRun()
Run initializer function.
ca::Vector< CbmL1HitId > * fpvHitIds
Pointer to array of hit index objects.
bool fbSortQaHits
Flag, if the QA hits must be sorted after reading.
void CheckInit() const
Check class initialization.
DetIdArr_t< int > fvNofHitsTotal
Total hit number in detector.
void Clear()
Clears class content.
constexpr char RDb[]
bold red
Definition CaDefs.h:154
constexpr char GNb[]
bold green
Definition CaDefs.h:155
constexpr char CL[]
clear
Definition CaDefs.h:132
kf::fscal fscal
Definition CaSimd.h:14
EDetectorID
Enumeration for the tracking detector subsystems in CBM-CA.
Definition CbmDefs.h:176
constexpr DetIdArr_t< ECbmDataType > kCbmHitType
Data type of hits (for CbmEvent)
constexpr DetIdArr_t< const char * > kDetName
Names of detector subsystems.
cbm::algo::kf::TrackParamD ConvertTrackParam(const FairTrackParam &par)
copy fair track param to Ca track param
Definition CbmKfUtil.cxx:12
std::tuple_element_t< static_cast< std::size_t >(DetID), std::tuple< Types... > > at
A helper structure to store hits information from different detectors in a uniform manner.
double fZ
z component of hit position [cm]
int fStaId
index of active tracking station
int64_t fDataStream
Global index of detector module.
double fRangeY
range of y [cm]
double fRangeX
range of x [cm]
double fDt2
time error of hit [ns]
int fStripF
index of front strip
double fDxy
correlation between x and y components [cm]
double fT
time of hit [ns]
std::string ToString() const
Converts hit record to a string.
int fStripB
index of back strip
int fExtId
external index of hit
double fDy2
error of y component of hit position [cm]
double fX
x component of hit position [cm]
double fY
y component of hit position [cm]
double fRangeT
range of t [ns]
double fDx2
error of x component of hit position [cm]