CbmRoot
Loading...
Searching...
No Matches
CbmRichRingFinderIdeal.cxx
Go to the documentation of this file.
1/* Copyright (C) 2006-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev, Andrey Lebedev, Florian Uhlig, Claudia Höhne [committer] */
4
16
17#include "CbmDigiManager.h"
18#include "CbmMCDataArray.h"
19#include "CbmMCDataManager.h"
20#include "CbmMCEventList.h"
21#include "CbmMCTrack.h"
22#include "CbmMatch.h"
23#include "CbmMatchRecoToMC.h"
24#include "CbmRichDigi.h"
25#include "CbmRichHit.h"
26#include "CbmRichPoint.h"
27#include "CbmRichRing.h"
28#include "FairRootManager.h"
29#include "TClonesArray.h"
30
31#include <Logger.h>
32
33#include <iostream>
34#include <map>
35#include <vector>
36
37using namespace std;
38
39
41
43
45{
46 LOG(fatal) << "CbmRichRingFinderIdeal::Init(): Ideal ringfinder is currently disabled. Will be reimplemented soon, "
47 "supporting time-based mode and mutiple MC input files. Also hits from the same mother particle in 2 "
48 "different cameras will be taken care of.";
49
50 FairRootManager* manager = FairRootManager::Instance();
51 if (nullptr == manager) LOG(fatal) << "CbmRichRingFinderIdeal::Init(): FairRootManager is nullptr.";
52
53 CbmMCDataManager* mcManager = (CbmMCDataManager*) manager->GetObject("MCDataManager");
54 if (mcManager == nullptr) LOG(fatal) << "CbmRichRingFinderIdeal::Init(): MCDataManager is nullptr.";
55
57 fDigiMan->Init();
58 if (!fDigiMan->IsPresent(ECbmModuleId::kRich)) LOG(fatal) << "CbmRichRingFinderIdeal::Init(): No RichDigi.";
59
60 if (!fDigiMan->IsMatchPresent(ECbmModuleId::kRich)) LOG(fatal) << "CbmRichRingFinderIdeal::Init(): No RichMatchDigi.";
61
62 fMcTracks = mcManager->InitBranch("MCTrack");
63 if (fMcTracks == nullptr) LOG(fatal) << "CbmRichRingFinderIdeal::Init(): No MCTrack.";
64
65 fRichPoints = mcManager->InitBranch("RichPoint");
66 if (fRichPoints == nullptr) LOG(fatal) << "CbmRichRingFinderIdeal::Init(): No RichPoint!";
67
68 fEventList = (CbmMCEventList*) manager->GetObject("MCEventList.");
69 if (fEventList == nullptr) LOG(fatal) << "CbmRichRingFinderIdeal::Init(): No MCEventList.";
70}
71
72Int_t CbmRichRingFinderIdeal::DoFind(CbmEvent* /* event */, TClonesArray* /* hitArray */, TClonesArray* /*projArray*/,
73 TClonesArray* /* ringArray */)
74{
75 return 0; // FIXME: Ideal Rich Ring Finder needs to be reimplemented
76 // This will be done soon. Supporting time-based mode and mutiple MC input files.
77 // Also hits from the same mother particle in 2 different cameras will be taken care of.
78
79 // if (event != nullptr) {
80 // LOG(fatal) << "CbmRichRingFinderIdeal::DoFind(): CbmEvent is not nullptr. "
81 // "This class does not support time-based mode. Please switch to event-by-event mode.";
82 // }
83
84 // if (hitArray == nullptr) {
85 // LOG(error) << "CbmRichRingFinderIdeal::DoFind(), hitArray is nullptr.";
86 // return -1;
87 // }
88
89 // if (ringArray == nullptr) {
90 // LOG(error) << "CbmRichRingFinderIdeal::DoFind(): ringArray is nullptr.";
91 // return -1;
92 // }
93
94 // // Create STL map from MCtrack index to number of valid RichHits
95 // map<pair<Int_t, Int_t>, Int_t> hitMap;
96 // Int_t nofRichHits = hitArray->GetEntriesFast();
97 // for (Int_t iHit = 0; iHit < nofRichHits; iHit++) {
98 // const CbmRichHit* richHit = static_cast<CbmRichHit*>(hitArray->At(iHit));
99 // if (richHit == nullptr) continue;
100 // Int_t eventId = GetEventIdForRichHit(richHit);
101 // vector<pair<Int_t, Int_t>> motherIds =
102 // CbmMatchRecoToMC::GetMcTrackMotherIdsForRichHit(fDigiMan, richHit, fRichPoints, fMcTracks, eventId);
103 // for (UInt_t i = 0; i < motherIds.size(); i++) {
104 // hitMap[motherIds[i]]++;
105 // }
106 // }
107
108 // // Create STL map from MCTrack index to RichRing index
109 // map<pair<Int_t, Int_t>, Int_t> ringMap;
110 // Int_t nofRings = 0;
111 // Int_t nofEvents = fEventList->GetNofEvents();
112 // for (Int_t iE = 0; iE < nofEvents; iE++) {
113 // Int_t fileId = fEventList->GetFileIdByIndex(iE);
114 // Int_t eventId = fEventList->GetEventIdByIndex(iE);
115
116 // // Create RichRings for McTracks
117 // Int_t nofMcTracks = fMcTracks->Size(fileId, eventId);
118 // for (Int_t iT = 0; iT < nofMcTracks; iT++) {
119 // const CbmMCTrack* mcTrack = static_cast<CbmMCTrack*>(fMcTracks->Get(fileId, eventId, iT));
120 // if (mcTrack == nullptr) continue;
121 // pair<Int_t, Int_t> val = std::make_pair(eventId, iT);
122 // if (hitMap[val] <= 0) continue;
123 // new ((*ringArray)[nofRings]) CbmRichRing();
124 // ringMap[val] = nofRings++;
125 // }
126 // }
127
128 // // Loop over RichHits. Get corresponding MCPoint and MCTrack index
129 // for (Int_t iHit = 0; iHit < nofRichHits; iHit++) {
130 // const CbmRichHit* richHit = static_cast<CbmRichHit*>(hitArray->At(iHit));
131 // if (richHit == nullptr) continue;
132 // Int_t eventId = GetEventIdForRichHit(richHit);
133
134 // vector<pair<Int_t, Int_t>> motherIds =
135 // CbmMatchRecoToMC::GetMcTrackMotherIdsForRichHit(fDigiMan, richHit, fRichPoints, fMcTracks, eventId);
136
137 // for (UInt_t i = 0; i < motherIds.size(); i++) {
138 // if (ringMap.find(motherIds[i]) == ringMap.end()) continue;
139 // Int_t ringIndex = ringMap[motherIds[i]];
140 // CbmRichRing* ring = (CbmRichRing*) ringArray->At(ringIndex);
141 // if (ring == nullptr) continue;
142
143 // ring->AddHit(iHit); // attach the hit to the ring
144 // }
145 // }
146
147 // return nofRings;
148}
149
150
152{
153 if (richHit == nullptr) return -1;
154 Int_t digiIndex = richHit->GetRefId();
155 if (digiIndex < 0) return -1;
156 const CbmMatch* digiMatch = fDigiMan->GetMatch(ECbmModuleId::kRich, digiIndex);
157 if (NULL == digiMatch) return -1;
158 return digiMatch->GetMatchedLink().GetEntry();
159}
@ kRich
Ring-Imaging Cherenkov Detector.
FairTask for matching RECO data to MC.
Ideal ring finder in the RICH detector. It uses MC information to attach RICH hits to rings.
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
static Bool_t IsMatchPresent(ECbmModuleId systemId)
Presence of a digi match branch.
InitStatus Init()
Initialisation.
static CbmDigiManager * Instance()
Static instance.
const CbmMatch * GetMatch(ECbmModuleId systemId, UInt_t index) const
Get a match object.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
int32_t GetRefId() const
Definition CbmHit.h:73
Task class creating and managing CbmMCDataArray objects.
CbmMCDataObject * GetObject(const char *name)
CbmMCDataArray * InitBranch(const char *name)
Container class for MC events with number, file and start time.
const CbmLink & GetMatchedLink() const
Definition CbmMatch.h:41
Int_t GetEventIdForRichHit(const CbmRichHit *richHit)
virtual void Init()
Inherited from CbmRichRingFinder.
virtual int DoFind(CbmEvent *event, TClonesArray *hitArray, TClonesArray *projArray, TClonesArray *ringArray)
CbmRichRingFinderIdeal()
Default constructor.
virtual ~CbmRichRingFinderIdeal()
Destructor.
Hash for CbmL1LinkKey.