CbmRoot
Loading...
Searching...
No Matches
CbmCaMCModule.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#include "CbmCaMCModule.h"
11
12#include "CbmEvent.h"
13#include "CbmL1Constants.h"
14#include "CbmL1DetectorID.h"
15#include "CbmL1Hit.h"
16#include "CbmMCDataManager.h"
17#include "CbmMCDataObject.h"
18#include "CbmMCEventList.h"
19#include "CbmMCTrack.h"
20#include "CbmStsHit.h"
21#include "CbmTimeSlice.h"
22#include "CbmTofPoint.h"
23#include "FairEventHeader.h"
24#include "FairMCEventHeader.h"
25#include "FairRootManager.h"
26#include "FairRunAna.h"
27#include "Logger.h"
28#include "TDatabasePDG.h"
29#include "TLorentzVector.h"
30#include "TVector3.h"
31
32#include <boost/filesystem.hpp>
33
34#include <algorithm>
35#include <cassert>
36#include <fstream> // TODO: SZh 07.12.2022: For debug, should be removed!
37#include <limits>
38#include <map>
39#include <stdexcept> // for std::logic_error
40#include <utility>
41
42// *********************************
43// ** Action definition functions **
44// *********************************
45
46using cbm::algo::ca::constants::clrs::CL; // clear log
47using cbm::algo::ca::constants::clrs::RDb; // red bold log
50
51// ---------------------------------------------------------------------------------------------------------------------
52//
54try {
55
56 if (fVerbose > 0) {
57 LOG(info) << "CA MC Module: initializing CA tracking Monte-Carlo module... ";
58 }
59
60 // Detector interfaces
61 if (fvbUseDet[ca::EDetectorID::kMvd]) {
62 fvpDetInterface[ca::EDetectorID::kMvd] = CbmMvdTrackingInterface::Instance();
63 }
64 if (fvbUseDet[ca::EDetectorID::kSts]) {
65 fvpDetInterface[ca::EDetectorID::kSts] = CbmStsTrackingInterface::Instance();
66 }
67 if (fvbUseDet[ca::EDetectorID::kMuch]) {
68 fvpDetInterface[ca::EDetectorID::kMuch] = CbmMuchTrackingInterface::Instance();
69 }
70 if (fvbUseDet[ca::EDetectorID::kTrd]) {
71 fvpDetInterface[ca::EDetectorID::kTrd] = CbmTrdTrackingInterface::Instance();
72 }
73 if (fvbUseDet[ca::EDetectorID::kTof]) {
74 fvpDetInterface[ca::EDetectorID::kTof] = CbmTofTrackingInterface::Instance();
75 }
76
77 auto fairManager = FairRootManager::Instance();
78 assert(fairManager);
79
80 auto mcManager = dynamic_cast<CbmMCDataManager*>(fairManager->GetObject("MCDataManager"));
81 assert(mcManager);
82
83 fpTimeSlice = dynamic_cast<CbmTimeSlice*>(fairManager->GetObject("TimeSlice."));
84 fpMCEventList = dynamic_cast<CbmMCEventList*>(fairManager->GetObject("MCEventList."));
85 fpMCEventHeader = mcManager->GetObject("MCEventHeader.");
86 fpMCTracks = mcManager->InitBranch("MCTrack");
87
88 fvpBrPoints.fill(nullptr);
89 fvpBrHitMatches.fill(nullptr);
90
91 fFileEventIDs.clear();
92
93 auto InitPointBranch = [&](const char* brName, ca::EDetectorID detID) {
94 if (fvbUseDet[detID]) {
95 fvpBrPoints[detID] = mcManager->InitBranch(brName);
96 }
97 };
98
99 auto InitMatchesBranch = [&](const char* brName, ca::EDetectorID detID) {
100 if (fvbUseDet[detID]) {
101 fvpBrHitMatches[detID] = dynamic_cast<TClonesArray*>(fairManager->GetObject(brName));
102 }
103 };
104
105 InitPointBranch("MvdPoint", ca::EDetectorID::kMvd);
106 InitPointBranch("StsPoint", ca::EDetectorID::kSts);
107 InitPointBranch("MuchPoint", ca::EDetectorID::kMuch);
108 InitPointBranch("TrdPoint", ca::EDetectorID::kTrd);
109 InitPointBranch("TofPoint", ca::EDetectorID::kTof);
110
111 InitMatchesBranch("MvdHitMatch", ca::EDetectorID::kMvd);
112 InitMatchesBranch("StsHitMatch", ca::EDetectorID::kSts);
113 InitMatchesBranch("MuchPixelHitMatch", ca::EDetectorID::kMuch);
114 InitMatchesBranch("TrdHitMatch", ca::EDetectorID::kTrd);
115 InitMatchesBranch("TofHitMatch", ca::EDetectorID::kTof);
116
117
118 // Check initialization
119 this->CheckInit();
120
121 // Init monitor
132
133
134 if (fVerbose > 0) {
135 LOG(info) << "CA MC Module: initializing CA tracking Monte-Carlo module... \033[1;32mDone!\033[0m";
136 }
137 return true;
138}
139catch (const std::logic_error& error) {
140 LOG(error) << "CA MC Module: initializing CA tracking Monte-Carlo module... \033[1;31mFailed\033[0m\nReason: "
141 << error.what();
142 return false;
143}
144
145// ---------------------------------------------------------------------------------------------------------------------
146//
148{
149 // Fill a set of file and event indexes
150 fFileEventIDs.clear();
151 fBestMcFile = -1;
152 fBestMcEvent = -1;
153 if (pEvent) {
154 CbmMatch* pEvtMatch = pEvent->GetMatch();
155 assert(pEvtMatch);
156 int nLinks = pEvtMatch->GetNofLinks();
157 LOG(info) << "DEBUG: nof linked mc events " << nLinks << " of total " << fpMCEventList->GetNofEvents();
158 for (int iLink = 0; iLink < nLinks; ++iLink) {
159 const auto& link = pEvtMatch->GetLink(iLink);
160 fFileEventIDs.emplace(link.GetFile(), link.GetEntry());
161 }
162 if (nLinks > 1) {
163 const auto& bestLink = pEvtMatch->GetMatchedLink();
164 fBestMcFile = bestLink.GetFile();
165 fBestMcEvent = bestLink.GetEntry();
166 }
167 }
168 else {
169 int nEvents = fpMCEventList->GetNofEvents();
170 for (int iE = 0; iE < nEvents; ++iE) {
171 int iFile = fpMCEventList->GetFileIdByIndex(iE);
172 int iEvent = fpMCEventList->GetEventIdByIndex(iE);
173 fFileEventIDs.emplace(iFile, iEvent);
174 }
175 }
176
177 // Read data
178 fpMCData->Clear();
179 this->ReadMCTracks();
180 this->ReadMCPoints();
183
184 // Prepare tracks: set point indexes and redefine indexes from external to internal containers
185 for (auto& aTrk : fpMCData->GetTrackContainer()) {
186 aTrk.SortPointIndexes(
187 [&](const int& iPl, const int& iPr) { return fpMCData->GetPoint(iPl).GetZ() < fpMCData->GetPoint(iPr).GetZ(); });
188 }
189
191}
192
193// ---------------------------------------------------------------------------------------------------------------------
194//
196
197// ---------------------------------------------------------------------------------------------------------------------
198//
200{
201 // FIXME: Reconstructable criteria initialization should be verified!
202 // ----- Initialize stations arrangement and hit indexes
204
205 // ----- Define reconstructable and additional flags
206 for (auto& aTrk : fpMCData->GetTrackContainer()) {
207 bool isRec = true; // the track can be reconstructed
208
209 // Cut on momentum
210 isRec &= aTrk.GetP() > CbmL1Constants::MinRecoMom;
211
212 // Cut on max number of points on station
213 isRec &= aTrk.GetMaxNofPointsOnStation() <= 3;
214
215 // Suppress MC tracks from complementary MC events
216 if (fBestMcFile >= 0 && (aTrk.GetFileId() != fBestMcFile || aTrk.GetEventId() != fBestMcEvent)) {
217 isRec = false;
218 }
219
220 bool isAdd = isRec; // is track additional
221
222 // Cut on number of stations
223 switch (fPerformanceMode) {
224 case 1: isRec &= aTrk.GetNofConsStationsWithHit() >= CbmL1Constants::MinNStations; break;
225 case 2: isRec &= aTrk.GetTotNofStationsWithHit() >= CbmL1Constants::MinNStations; break;
226 case 3: isRec &= aTrk.GetNofConsStationsWithPoint() >= CbmL1Constants::MinNStations; break;
227 default: LOG(fatal) << "CA MC Module: invalid performance mode " << fPerformanceMode;
228 }
229
230 if (aTrk.GetNofPoints() > 0) {
231 isAdd &= aTrk.GetNofConsStationsWithHit() == aTrk.GetTotNofStationsWithHit();
232 isAdd &= aTrk.GetNofConsStationsWithPoint() == aTrk.GetTotNofStationsWithHit();
233 isAdd &= aTrk.GetTotNofStationsWithHit() == aTrk.GetTotNofStationsWithPoint();
234 isAdd &= aTrk.GetNofConsStationsWithHit() >= 3;
235 isAdd &= fpMCData->GetPoint(aTrk.GetPointIndexes()[0]).GetStationId() == 0;
236 isAdd &= !isRec;
237 }
238 else {
239 isAdd = false;
240 }
241 aTrk.SetFlagReconstructable(isRec);
242 aTrk.SetFlagAdditional(isAdd);
243 }
244}
245
246// ---------------------------------------------------------------------------------------------------------------------
247//
248void MCModule::Finish() { LOG(info) << '\n' << fMonitor.ToString(); }
249
250
251// **********************************
252// ** Reco and MC matching **
253// **********************************
254
255
256// ---------------------------------------------------------------------------------------------------------------------
257//
266
267// ---------------------------------------------------------------------------------------------------------------------
268//
270{
271 this->MatchRecoAndMCTracks();
272 this->InitTrackInfo();
273 for (const auto& trkMC : fpMCData->GetTrackContainer()) {
274 if (trkMC.IsReconstructable()) {
276 }
277 }
278}
279
280
281// ---------------------------------------------------------------------------------------------------------------------
282//
284{
285 for (int iTre = 0; iTre < int(fpvRecoTracks->size()); ++iTre) {
286 auto& trkRe = (*fpvRecoTracks)[iTre];
287
288 // ----- Count number of hits from each MC track belonging to this reconstructed track
289 auto& mNofHitsVsMCTrkID = trkRe.hitMap;
290 mNofHitsVsMCTrkID.clear();
291 for (int iH : trkRe.Hits) {
292 auto& vP = (*fpvQaHits)[iH].GetMcPointIds();
293 for (int iP : vP) {
294 if (iP < 0) {
295 continue;
296 }
297 int iTmc = fpMCData->GetPoint(iP).GetTrackId();
298 mNofHitsVsMCTrkID[iTmc]++;
299 }
300 } // loop over hit ids stored for a reconstructed track: end
301
302
303 // ----- Calculate track max purity
304 // NOTE: Maximal purity is a maximum fraction of hits from a single MC track. A reconstructed track can be matched
305 // to several MC tracks, because it uses hits from different particle. Purity shows, how fully the true track
306 // was reconstructed.
307 int nHitsTrkRe = trkRe.Hits.size(); // number of hits in a given reconstructed track
308 double maxPurity = 0.; // [0, 1]
309 for (auto& item : mNofHitsVsMCTrkID) {
310 int iTmc = item.first;
311 int nHitsTrkMc = item.second;
312
313 if (iTmc < 0) {
314 continue;
315 }
316
317 if (double(nHitsTrkMc) > double(nHitsTrkRe) * maxPurity) {
318 maxPurity = double(nHitsTrkMc) / double(nHitsTrkRe);
319 }
320
321 auto& trkMc = fpMCData->GetTrack(iTmc);
322
323 // Match reconstructed and MC tracks, if purity with this MC track passes the threshold
324 if (double(nHitsTrkMc) >= CbmL1Constants::MinPurity * double(nHitsTrkRe)) {
325 trkMc.AddRecoTrackIndex(iTre);
326 trkRe.AddMCTrackIndex(iTmc);
327 }
328 // If purity is low, but some hits of a given MC track are presented in the reconstructed track
329 else {
330 trkMc.AddTouchTrackIndex(iTre);
331 }
332
333 // Update max purity of the reconstructed track
334 trkRe.SetMaxPurity(maxPurity);
335 } // loop over hit map: end
336 } // loop over reconstructed tracks: end
337}
338
339// *******************************
340// ** Utility functions **
341// *******************************
342
343// ---------------------------------------------------------------------------------------------------------------------
344//
346{
347 // Check parameters
348 if (!fpParameters.get()) {
349 throw std::logic_error("Tracking parameters object was not defined");
350 }
351
352 // Check output data containers
353 if (!fpMCData) {
354 throw std::logic_error("MC data object was not registered");
355 }
356 if (!fpvRecoTracks) {
357 throw std::logic_error("Reconstructed track container was not registered");
358 }
359 if (!fpvHitIds) {
360 throw std::logic_error("Hit index container was not registered");
361 }
362 if (!fpvQaHits) {
363 throw std::logic_error("QA hit container was not registered");
364 }
365 if (!fpvFstHitId) {
366 throw std::logic_error("Array of first hit indexes in each detector was not registered");
367 }
368
369 // Check event list
370 if (!fpMCEventList) {
371 throw std::logic_error("MC event list was not found");
372 }
373 if (!fpTimeSlice) {
374 throw std::logic_error("Time slice was not found");
375 }
376
377 // Tracks branch
378 if (!fpMCTracks) {
379 throw std::logic_error("MC tracks branch is unavailable");
380 }
381
382 // Event header
383 if (!fpMCEventHeader) {
384 throw std::logic_error("MC event header is unavailable");
385 }
386
387 // Check detectors initialization
388 for (int iD = 0; iD < static_cast<int>(ca::EDetectorID::END); ++iD) {
389 if (fvbUseDet[iD]) {
390 if (!fvpBrPoints[iD]) {
391 throw std::logic_error(Form("MC points are unavailable for %s", kDetName[iD]));
392 }
393 if (!fvpBrHitMatches[iD]) {
394 throw std::logic_error(Form("Hit matches are unavailable for %s", kDetName[iD]));
395 }
396 }
397 }
398}
399
400// ---------------------------------------------------------------------------------------------------------------------
401//
402template<>
403void MCModule::ReadMCPointsForDetector<ca::EDetectorID::kTof>()
404{
405 if (!fvbUseDet[ca::EDetectorID::kTof]) {
406 return;
407 }
408
409 auto* pBrHitMatches = fvpBrHitMatches[ca::EDetectorID::kTof];
410 auto* pBrPoints = fvpBrPoints[ca::EDetectorID::kTof];
411
412 // FIXME: Use mask from CbmTofAddress (but test before!!)
413 constexpr int kNofBitsRpcAddress = 11;
414
415 for (const auto& [iFile, iEvent] : fFileEventIDs) {
416 // Fill map of flags: the external index of the matched point vs. iTrExt and the RPC address
417 int nPoints = pBrPoints->Size(iFile, iEvent);
418 std::map<std::pair<int, int>, int> mMatchedPointId; // map (iTr, addr) -> is matched
419 for (int iH = 0; iH < pBrHitMatches->GetEntriesFast(); ++iH) {
420 auto* pHitMatch = dynamic_cast<CbmMatch*>(pBrHitMatches->At(iH));
421 LOG_IF(fatal, !pHitMatch) << "CA MC Module: hit match was not found for TOF hit " << iH;
422 double bestWeight = 0;
423 for (int iLink = 0; iLink < pHitMatch->GetNofLinks(); ++iLink) {
424 const auto& link = pHitMatch->GetLink(iLink);
425 if (link.GetFile() != iFile || link.GetEntry() != iEvent) {
426 continue;
427 }
428 int iPext = link.GetIndex();
429 if (iPext < 0) {
430 continue;
431 }
432 auto* pExtPoint = dynamic_cast<CbmTofPoint*>(pBrPoints->Get(link));
433 if (!pExtPoint) {
434 LOG(error) << "ca::MCModule: MC Point with link=" << link.ToString() << " does not exist in branch";
435 continue;
436 }
437
438 int trkId = pExtPoint->GetTrackID();
439 int rpcAddr = pExtPoint->GetDetectorID() << kNofBitsRpcAddress; // FIXME:
440 auto key = std::make_pair(trkId, rpcAddr);
441 auto prev = mMatchedPointId.find(key);
442 if (prev == mMatchedPointId.end()) {
443 bestWeight = link.GetWeight();
444 mMatchedPointId[key] = iPext;
445 }
446 else { // If we find two links for the same interaction, we select the one with the largest weight
447 if (bestWeight < link.GetWeight()) {
448 mMatchedPointId[key] = iPext;
449 }
450 }
451 }
452 } // iH
453
454 // Select one point for the given track ID and RPC address. If at least one of the points for (trackID, RPC address)
455 // produced a hit, the point from the best link is selected. Otherwise the closest point to the RPC z-center is selected
456 {
457 int iPointSelected = -1;
458 int iTmcCurr = -1;
459 int rpcAddrCurr = -1;
460 bool bTrkHasHits = false;
461 double zDist = std::numeric_limits<double>::max();
462 double zCell = std::numeric_limits<double>::signaling_NaN();
463 for (int iP = 0; iP < nPoints; ++iP) {
464 auto* pExtPoint = dynamic_cast<CbmTofPoint*>(pBrPoints->Get(iFile, iEvent, iP));
465 LOG_IF(fatal, !pExtPoint) << "NO POINT: TOF: file, event, index = " << iFile << ' ' << iEvent << ' ' << iP;
466
467 int iTmc = pExtPoint->GetTrackID();
468 int rpcAddr = pExtPoint->GetDetectorID() << kNofBitsRpcAddress;
469 // New point
470 if (rpcAddrCurr != rpcAddr || iTmcCurr != iTmc) { // The new interaction of the MC track with the TOF RPC
471 if (iPointSelected != -1) {
472 auto oPoint = FillMCPoint<ca::EDetectorID::kTof>(iPointSelected, iEvent, iFile);
473 if (oPoint) {
474 fpMCData->AddPoint(*oPoint);
475 }
476 }
477 iTmcCurr = iTmc;
478 rpcAddrCurr = rpcAddr;
479 auto key = std::make_pair(iTmc, rpcAddr);
480 auto found = mMatchedPointId.find(key);
481 bTrkHasHits = found != mMatchedPointId.end();
482 if (bTrkHasHits) {
483 iPointSelected = found->second;
484 }
485 else {
486 // First iteration
487 zCell = fvpDetInterface[ca::EDetectorID::kTof]->GetZrefModule(pExtPoint->GetDetectorID());
488 zDist = std::fabs(zCell - pExtPoint->GetZ());
489 iPointSelected = iP;
490 }
491 }
492 else {
493 if (!bTrkHasHits) {
494 auto newDist = std::fabs(pExtPoint->GetZ() - zCell);
495 if (newDist < zDist) {
496 zDist = newDist;
497 iPointSelected = iP;
498 }
499 }
500 }
501 }
502 // Add the last point
503 if (iPointSelected != -1) {
504 auto oPoint = FillMCPoint<ca::EDetectorID::kTof>(iPointSelected, iEvent, iFile);
505 if (oPoint) {
506 fpMCData->AddPoint(*oPoint);
507 }
508 }
509 }
510 } // [iFile, iEvent]
511}
512
513// ---------------------------------------------------------------------------------------------------------------------
514//
516{
517 int nPointsEstimated = 5 * fpMCData->GetNofTracks() * fpParameters->GetNstationsActive();
518 fpMCData->ReserveNofPoints(nPointsEstimated);
519
520 DetIdArr_t<int> vNofPointsDet = {{0}};
521 for (const auto& [iFile, iEvent] : fFileEventIDs) {
522 for (int iD = 0; iD < static_cast<int>(vNofPointsDet.size()); ++iD) {
523 if (fvbUseDet[iD]) {
524 vNofPointsDet[iD] = fvpBrPoints[iD]->Size(iFile, iEvent);
525 }
526 fpMCData->SetNofPointsOrig(static_cast<ca::EDetectorID>(iD), vNofPointsDet[iD]);
527 }
528 }
529
530 // ----- Read MC points in MVD, STS, MuCh, TRD and TOF
536}
537
538// ---------------------------------------------------------------------------------------------------------------------
539//
541{
542 // ----- Total number of tracks
543 int nTracksTot = 0;
544 for (const auto& [iFile, iEvent] : fFileEventIDs) {
545 if (iFile < 0 || iEvent < 0) {
546 continue;
547 }
548 nTracksTot += fpMCTracks->Size(iFile, iEvent);
549 }
550 fpMCData->ReserveNofTracks(nTracksTot);
551
552 // ----- Loop over MC events
553 for (const auto& [iFile, iEvent] : fFileEventIDs) {
554 if (iFile < 0 || iEvent < 0) {
555 continue;
556 }
557 auto pEvtHeader = dynamic_cast<FairMCEventHeader*>(fpMCEventHeader->Get(iFile, iEvent));
558 if (!pEvtHeader) {
559 LOG(fatal) << "cbm::ca::MCModule: event header is not found for file " << iFile << " and event " << iEvent;
560 }
561 double eventTime = fpMCEventList->GetEventTime(iEvent, iFile);
562
563 // ----- Loop over MC tracks
564 int nTracks = fpMCTracks->Size(iFile, iEvent);
565 for (int iTrkExt = 0; iTrkExt < nTracks; ++iTrkExt) {
566 CbmMCTrack* pExtMCTrk = dynamic_cast<CbmMCTrack*>(fpMCTracks->Get(iFile, iEvent, iTrkExt));
567 if (!pExtMCTrk) {
568 LOG(warn) << "cbm::ca::MCModule: track with (iF, iE, iT) = " << iFile << ' ' << iEvent << ' ' << iTrkExt
569 << " not found";
570 }
571 // Create a CbmL1MCTrack
572 auto aTrk = MCTrack{};
573
574 aTrk.SetId(fpMCData->GetNofTracks()); // assign current number of tracks read so far as an ID of a new track
575 aTrk.SetExternalId(iTrkExt); // external index of track is its index from CbmMCTrack objects container
576 aTrk.SetEventId(iEvent);
577 aTrk.SetFileId(iFile);
578
579 aTrk.SetStartT(pExtMCTrk->GetStartT() + eventTime);
580 aTrk.SetStartX(pExtMCTrk->GetStartX());
581 aTrk.SetStartY(pExtMCTrk->GetStartY());
582 aTrk.SetStartZ(pExtMCTrk->GetStartZ());
583
584 aTrk.SetPx(pExtMCTrk->GetPx());
585 aTrk.SetPy(pExtMCTrk->GetPy());
586 aTrk.SetPz(pExtMCTrk->GetPz());
587
588 aTrk.SetFlagSignal(aTrk.IsPrimary() && (aTrk.GetStartZ() > (pEvtHeader->GetZ() + 1.e-10)));
589
590 // In CbmMCTrack mass is defined from ROOT PDG data base. If track is left from ion, and its pdg is not registered
591 // in the data base, its mass is calculated as A times proton mass.
592 aTrk.SetMass(pExtMCTrk->GetMass());
593
594 // The charge in CbmMCTrack is given in the units of e
595 aTrk.SetCharge(pExtMCTrk->GetCharge());
596
597 // Set index of mother track. We assume, that mother track was recorded into the internal array before
598 int extMotherId = pExtMCTrk->GetMotherId();
599 int extChainId = iTrkExt;
600 int extChainParent = extMotherId;
601 while (extChainParent >= 0) {
602 extChainId = extChainParent;
603 const auto* pExtParentTrk = dynamic_cast<CbmMCTrack*>(fpMCTracks->Get(iFile, iEvent, extChainParent));
604 extChainParent = pExtParentTrk->GetMotherId();
605 }
606
607 if (extMotherId < 0) {
608 // This is a primary track, and it's mother ID equals -1 or -2. This value is taken also as an internal mother
609 // ID. The same rules here and below are applied to the chainId
610 aTrk.SetMotherId(extMotherId);
611 aTrk.SetChainId(extChainId);
612 }
613 else {
614 // This is a secondary track, mother ID should be recalculated for the internal track array.
615 int motherId = fpMCData->FindInternalTrackIndex(extMotherId, iEvent, iFile);
616 int chainId = fpMCData->FindInternalTrackIndex(extChainId, iEvent, iFile);
617 if (motherId == -1) {
618 motherId = -3;
619 } // Mother is neutral particle, which is rejected
620 aTrk.SetMotherId(motherId);
621 aTrk.SetChainId(chainId);
622 }
623
624 aTrk.SetProcessId(pExtMCTrk->GetGeantProcessId());
625 aTrk.SetPdgCode(pExtMCTrk->GetPdgCode());
626
627 fpMCData->AddTrack(aTrk);
628 } // Loop over MC tracks: end
629 } // Loop over MC events: end
630}
void MCModule::ReadMCPointsForDetector< ca::EDetectorID::kTof >()
CA Tracking performance interface for CBM (header)
Implementation of L1DetectorID enum class for CBM.
Data class for a reconstructed hit in the STS.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
CbmMatch * GetMatch() const
Definition CbmEvent.h:98
TObject * Get(const CbmLink *lnk)
Int_t Size(Int_t fileNumber, Int_t eventNumber)
Task class creating and managing CbmMCDataArray objects.
TObject * Get(const CbmLink *lnk)
Container class for MC events with number, file and start time.
int32_t GetFileIdByIndex(uint32_t index)
File number by index @value File number for event at given index in list.
int32_t GetEventIdByIndex(uint32_t index)
Event number by index @value Event number for event at given index in list.
std::size_t GetNofEvents() const
Number of events in the list @value Number of events.
double GetEventTime(uint32_t event, uint32_t file)
Event start time.
double GetPz() const
Definition CbmMCTrack.h:72
double GetStartT() const
Definition CbmMCTrack.h:76
double GetCharge() const
Charge of the associated particle.
double GetPx() const
Definition CbmMCTrack.h:70
uint32_t GetGeantProcessId() const
Definition CbmMCTrack.h:67
double GetStartZ() const
Definition CbmMCTrack.h:75
int32_t GetMotherId() const
Definition CbmMCTrack.h:69
double GetMass() const
Mass of the associated particle.
double GetStartX() const
Definition CbmMCTrack.h:73
int32_t GetPdgCode() const
Definition CbmMCTrack.h:68
double GetStartY() const
Definition CbmMCTrack.h:74
double GetPy() const
Definition CbmMCTrack.h:71
const CbmLink & GetLink(int32_t i) const
Definition CbmMatch.h:39
int32_t GetNofLinks() const
Definition CbmMatch.h:42
const CbmLink & GetMatchedLink() const
Definition CbmMatch.h:41
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.
Bookkeeping of time-slice content.
Geometric intersection of a MC track with a TOFb detector.
Definition CbmTofPoint.h:44
static CbmTofTrackingInterface * Instance()
Gets pointer to the instance of the CbmTofTrackingInterface.
static CbmTrdTrackingInterface * Instance()
Gets pointer to the instance of the CbmTrdTrackingInterface.
std::string ToString() const
Prints counters summary to string.
Definition CaMonitor.h:167
void IncrementCounter(ECounterKey key)
Increments key counter by 1.
Definition CaMonitor.h:99
void SetCounterName(ECounterKey key, std::string_view name)
Sets name of counter.
Definition CaMonitor.h:115
void SetRatioKeys(const std::vector< ECounterKey > &vKeys)
Sets keys of counters, which are used as denominators for ratios.
Definition CaMonitor.h:111
Class CbmCaPerformance is an interface to communicate between.
DetIdArr_t< CbmTrackingDetectorInterfaceBase * > fvpDetInterface
Tracking detector interface.
void ReadMCTracks()
Reads MC tracks from external trees and saves them to MCDataObject.
void InitEvent(CbmEvent *pEvent)
Defines performance action in the beginning of each event or time slice.
void Finish()
Defines performance action in the end of the run.
void CheckInit() const
Check class initialization.
CbmMCEventList * fpMCEventList
MC event list.
int fBestMcFile
Index of bestly matched MC file.
void ProcessEvent(CbmEvent *pEvent)
Processes event.
ca::Vector< CbmL1HitId > * fpvHitIds
Pointer to hit index container.
void ReadMCPoints()
Reads MC points from external trees and saves them to MCDataObject.
ca::Monitor< EMonitorKey > fMonitor
Monitor.
DetIdArr_t< bool > fvbUseDet
Flag: is detector subsystem used.
const std::array< int, constants::size::MaxNdetectors+1 > * fpvFstHitId
Pointer to array of first hit indexes in the detector subsystem.
int fVerbose
Verbosity level.
tools::MCData * fpMCData
MC information (hits and tracks) instance.
DetIdArr_t< CbmMCDataArray * > fvpBrPoints
Array of points vs. detector.
void MatchRecoAndMCTracks()
Matches reconstructed tracks with MC tracks.
CbmMCDataObject * fpMCEventHeader
MC event header.
void ReadMCPointsForDetector()
Reads MC points in particular detector.
@ kMissedMatchesMvd
Number of missed matches in MVD.
@ kMissedMatchesTof
Number of missed TOF matches.
@ kMissedMatchesTrd
Number of missed matches in TRD.
@ kMcPoint
Number of MC points.
@ kMissedMatchesMuch
Number of missed matches in MuCh.
@ kRecoNevents
Number of events.
@ kMissedMatchesSts
Number of missed matches in STS.
@ kMcTrack
Number of MC tracks.
@ kMcTrackReconstructable
Number of reconstructable MC tracks.
void MatchPointsAndHits()
Match sets of MC points and reconstructed hits for a given detector.
ca::Vector< CbmL1HitDebugInfo > * fpvQaHits
Pointer to QA hit container.
std::set< std::pair< int, int > > fFileEventIDs
Set of file and event indexes: first - iFile, second - iEvent.
bool InitRun()
Defines action on the module in the beginning of the run.
int fBestMcEvent
Index of bestly matched MC event.
ca::Vector< CbmL1Track > * fpvRecoTracks
Pointer to reconstructed track container.
DetIdArr_t< TClonesArray * > fvpBrHitMatches
Array of hit match branches vs. detector.
CbmMCDataArray * fpMCTracks
MC tracks input.
void MatchHits()
Match reconstructed hits and MC points.
const CbmTimeSlice * fpTimeSlice
Current time slice.
void MatchTracks()
Match reconstructed and MC data.
int fPerformanceMode
Mode of performance.
void InitTrackInfo()
Initializes MC track.
std::shared_ptr< ca::Parameters< float > > fpParameters
Pointer to tracking parameters object.
int GetNofPoints() const
Gets number of points in this event/TS.
void InitTrackInfo(const ca::Vector< CbmL1HitDebugInfo > &vHits)
Initialize information about points and hits association with MC track.
const auto & GetTrack(int idx) const
Gets a reference to MC track by its internal index.
void ReserveNofPoints(int nPoints)
Reserves memory for points to avoid extra allocations.
int GetNofTracks() const
Gets number of tracks in this event/TS.
int FindInternalTrackIndex(int index, int event, int file) const
Finds an index of MC track in internal track container.
void AddTrack(const MCTrack &track)
void ReserveNofTracks(int nTracks)
Reserves memory for tracks to avoid extra allocations.
const auto & GetTrackContainer() const
Gets a reference to the vector of tracks.
const auto & GetPoint(int idx) const
Gets a reference to MC point by its index.
void SetNofPointsOrig(ca::EDetectorID detID, int nPoints)
Sets original number of MC points in different detectors.
void Clear()
Clears contents.
void SetId(int id)
Sets index of track in the CA internal data structure (within event/TS)
const double MinRecoMom
Performance constants.
const double MinPurity
const int MinNStations
constexpr char RDb[]
bold red
Definition CaDefs.h:154
constexpr char CL[]
clear
Definition CaDefs.h:132
EDetectorID
Enumeration for the tracking detector subsystems in CBM-CA.
Definition CbmDefs.h:176
constexpr DetIdArr_t< const char * > kDetName
Names of detector subsystems.