CbmRoot
Loading...
Searching...
No Matches
CbmRichReconstruction.cxx
Go to the documentation of this file.
1/* Copyright (C) 2012-2021 UGiessen/JINR-LIT, Giessen/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev [committer], Andrey Lebedev */
4
13
14#include "CbmRichProjectionProducerAnalytical.h"
16#include "CbmRichRing.h"
17//#include "prototype/CbmRichProtProjectionProducer.h"
18
28//#include "prototype/CbmRichProtRingFinderHough.h"
29
30#include "CbmEvent.h"
31#include "CbmGlobalTrack.h"
32#include "CbmRichConverter.h"
33#include "CbmRichGeoManager.h"
41#include "FairHit.h"
42#include "FairRootManager.h"
43#include "TClonesArray.h"
44#include "TStopwatch.h"
45
46#include <Logger.h>
47
48#include <iomanip>
49#include <iostream>
50
51using std::fixed;
52using std::right;
53using std::setprecision;
54using std::setw;
55
56CbmRichReconstruction::CbmRichReconstruction() : FairTask("CbmRichReconstruction") {}
57
59{
60 if (nullptr != fRingFinder) delete fRingFinder;
61 if (nullptr != fRingFitter) delete fRingFitter;
62 if (nullptr != fTrackExtrapolation) delete fTrackExtrapolation;
63 if (nullptr != fProjectionProducer) delete fProjectionProducer;
64 if (nullptr != fRingTrackAssign) delete fRingTrackAssign;
65}
66
68{
69 FairRootManager* manager = FairRootManager::Instance();
70 if (nullptr == manager) LOG(fatal) << "CbmRichReconstruction::Init(): FairRootManager is nullptr.";
71
72 fCbmEvents = dynamic_cast<TClonesArray*>(manager->GetObject("CbmEvent"));
73 if (fCbmEvents == nullptr) {
74 LOG(info) << GetName() << "::Init() CbmEvent NOT found \n";
75 }
76 else {
77 LOG(info) << GetName() << "::Init() CbmEvent found";
78 }
79
81 fRichTrackParamZ = new TClonesArray("FairTrackParam", 100);
82 manager->Register("RichTrackParamZ", "RICH", fRichTrackParamZ, IsOutputBranchPersistent("RichTrackParamZ"));
83
84 fGlobalTracks = static_cast<TClonesArray*>(manager->GetObject("GlobalTrack"));
85 if (fGlobalTracks == nullptr) LOG(fatal) << "CbmRichReconstruction::Init(): No GlobalTrack array.";
86 }
87
88 if (fRunProjection) {
89 if (!fRunExtrapolation) LOG(fatal) << "CbmRichReconstruction::Init(): fRunExtrapolation must be true.";
90 fRichProjections = new TClonesArray("FairTrackParam");
91 manager->Register("RichProjection", "RICH", fRichProjections, IsOutputBranchPersistent("RichProjection"));
92 }
93
94 fRichHits = static_cast<TClonesArray*>(manager->GetObject("RichHit"));
95 if (fRichHits == nullptr) LOG(fatal) << "CbmRichReconstruction::Init(): No RichHit array.";
96
97 fRichRings = new TClonesArray("CbmRichRing", 100);
98 manager->Register("RichRing", "RICH", fRichRings, IsOutputBranchPersistent("RichRing"));
99
100 // This was checked for v17a, v21a geometries. The offset was chosen that
101 // the value for v17a is 260 cm and the value for v21a is 220 cm
102 double offset = 205.7331;
104 LOG(info) << "CbmRichReconstruction::Init() fZTrackExtrapolation = " << fZTrackExtrapolation;
106 LOG(fatal) << "CbmRichReconstruction::Init() fZTrackExtrapolation = " << fZTrackExtrapolation
107 << " The value of fZTrackExtrapolation is not correct. It must be in the range [200, 300] cm."
108 << " Probably the RICH geometry is not correct or it is not supported.";
109 }
110
113 if (fRunFinder) InitFinder();
114 if (fRunFitter) InitFitter();
116
117 return kSUCCESS;
118}
119
120void CbmRichReconstruction::Exec(Option_t* /*opt*/)
121{
122 TStopwatch timer;
123 timer.Start();
124 Int_t nEvents{0};
125 Int_t nTrackProj{0};
126 Int_t nGlobalTracks{0};
127
128 if (fRichTrackParamZ != nullptr) fRichTrackParamZ->Delete();
129 if (fRichProjections != nullptr) fRichProjections->Delete();
130 if (fRichRings != nullptr) fRichRings->Delete();
131
132 if (fCbmEvents == nullptr) {
133 ProcessData(nullptr);
135 nGlobalTracks += (fGlobalTracks ? fGlobalTracks->GetEntriesFast() : 0);
136 }
137 else {
138 nEvents = fCbmEvents->GetEntriesFast();
139 fNofEvents += nEvents;
140 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
141 CbmEvent* event = static_cast<CbmEvent*>(fCbmEvents->At(iEvent));
142 ProcessData(event);
144 nGlobalTracks += (fGlobalTracks ? event->GetNofData(ECbmDataType::kGlobalTrack) : 0);
145 }
146 }
147
148 timer.Stop();
149 std::stringstream logOut;
150 logOut << setw(20) << left << GetName() << "[";
151 logOut << fixed << setw(8) << setprecision(1) << right << timer.RealTime() * 1000. << " ms] ";
152 logOut << "TS " << fNofTs;
153 if (fCbmEvents) logOut << ", events " << nEvents;
154 logOut << ", hits " << fRichHits->GetEntriesFast();
155 logOut << ", rings " << fRichRings->GetEntriesFast();
156 if (fRichProjections) logOut << ", trackProj " << nTrackProj << " / " << nGlobalTracks;
157 LOG(info) << logOut.str();
158
159 fNofTs++;
160 fCalcTime[0] += timer.RealTime();
161 fTotalNofHits += fRichHits->GetEntriesFast();
162 fTotalNofRings += fRichRings->GetEntriesFast();
163 fTotalNofTrackProj += nTrackProj;
164 fTotalNofGlobalTracks += nGlobalTracks;
165}
166
168{
169 TStopwatch timer;
170 if (fRunExtrapolation) {
171 timer.Start();
172 RunExtrapolation(event);
173 timer.Stop();
174 fCalcTime[1] += timer.RealTime();
175 }
176 if (fRunProjection) {
177 timer.Start();
178 RunProjection(event);
179 timer.Stop();
180 fCalcTime[2] += timer.RealTime();
181 }
182 if (fRunFinder) {
183 timer.Start();
184 RunFinder(event);
185 timer.Stop();
186 fCalcTime[3] += timer.RealTime();
187 }
188 if (fRunFitter) {
189 timer.Start();
190 RunFitter(event);
191 timer.Stop();
192 fCalcTime[4] += timer.RealTime();
193 }
194 if (fRunTrackAssign) {
195 timer.Start();
196 RunTrackAssign(event);
197 timer.Stop();
198 fCalcTime[5] += timer.RealTime();
199 }
200}
201
203{
204 if (fExtrapolationName == "ideal") {
206 }
207 else if (fExtrapolationName == "mirror_ideal") {
209 }
210 else if (fExtrapolationName == "kf" || fExtrapolationName == "KF") {
212 }
213 else if (fExtrapolationName == "lit" || fExtrapolationName == "littrack") {
215 }
216 else {
217 LOG(fatal) << fExtrapolationName << " is not correct name for extrapolation algorithm.";
218 }
220}
221
223{
224 if (fProjectionName == "analytical") {
226 }
227 else if (fProjectionName == "TGeo" || fProjectionName == "tgeo") {
229 }
230 else {
231 LOG(fatal) << fFinderName << " is not correct name for projection producer algorithm.";
232 }
234}
235
237{
238 if (fFinderName == "hough") {
240 static_cast<CbmRichRingFinderHough*>(fRingFinder)->SetUseAnnSelect(fUseHTAnnSelect);
241 static_cast<CbmRichRingFinderHough*>(fRingFinder)->SetUseSubdivide(fUseHTSubdivide);
242 }
243 else if (fFinderName == "ideal") {
245 }
246 else if (fFinderName == "enn") {
248 }
249 else if ((fFinderName == "enn_parallel")) {
251 }
252 /*
253 else if (fFinderName == "hough_prototype") {
254 fRingFinder = new CbmRichProtRingFinderHough();
255 }*/
256 else {
257 LOG(fatal) << fFinderName << " is not correct name for ring finder algorithm.";
258 }
259
260 fRingFinder->Init();
261}
262
264{
265 if (fFitterName == "circle_cop") {
267 }
268 else if (fFitterName == "circle_simple") {
270 }
271 else if (fFitterName == "circle_tau") {
273 }
274 else if (fFitterName == "circle_robust_cop") {
276 }
277 else if (fFitterName == "ellipse_tau") {
279 }
280 else if (fFitterName == "ellipse_minuit") {
282 }
283 else {
284 LOG(fatal) << fFitterName << " is not correct name for ring fitter algorithm.";
285 }
287}
288
290{
291 if (fTrackAssignName == "closest_distance") {
293 }
294 else {
295 LOG(fatal) << fTrackAssignName << " is not correct name for ring-track assignment algorithm.";
296 }
298}
299
301{
302 if (fRichTrackParamZ == nullptr) LOG(info) << "fRichTrackParamZ == nullptr";
304}
305
310
315
317{
318 const Int_t nofRings = event ? event->GetNofData(ECbmDataType::kRichRing) : fRichRings->GetEntriesFast();
319 if (nofRings <= 0) return;
320 for (Int_t iR0 = 0; iR0 < nofRings; iR0++) {
321 Int_t iR = event ? event->GetIndex(ECbmDataType::kRichRing, iR0) : iR0;
322 CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(iR));
323 if (nullptr == ring) continue;
324 CbmRichRingLight ringL;
325
327 fRingFitter->DoFit(&ringL);
329 }
330}
331
336
338{
339 std::cout << std::endl;
340 LOG(info) << "=====================================";
341 LOG(info) << GetName() << ": Run summary";
342 LOG(info) << "Time slices : " << fNofTs;
343 LOG(info) << "Hits / TS : " << fixed << setprecision(2) << fTotalNofHits / Double_t(fNofTs);
344 LOG(info) << "Rings / TS : " << fixed << setprecision(2) << fTotalNofRings / Double_t(fNofTs);
346 LOG(info) << "TrackProj / TS : " << fixed << setprecision(2) << fTotalNofTrackProj / Double_t(fNofTs);
347 LOG(info) << "Time / TS : " << fixed << setprecision(2) << 1000. * fCalcTime[0] / Double_t(fNofTs) << " ms";
348 if (fCbmEvents) {
349 LOG(info) << "Events : " << fNofEvents;
350 LOG(info) << "Events / TS : " << fixed << setprecision(2) << fNofEvents / Double_t(fNofTs);
351 if (fNofEvents > 0) {
352 LOG(info) << "Hits / ev : " << fixed << setprecision(2) << fTotalNofHits / Double_t(fNofEvents);
353 LOG(info) << "Rings / ev : " << fixed << setprecision(2) << fTotalNofRings / Double_t(fNofEvents);
355 LOG(info) << "TrackProj / ev : " << fixed << setprecision(2) << fTotalNofTrackProj / Double_t(fNofEvents);
356 LOG(info) << "Time / ev : " << fixed << setprecision(2) << 1000. * fCalcTime[0] / Double_t(fNofEvents)
357 << " ms";
358 }
359 }
361 LOG(info) << "TrackProj / GTr : " << fixed << setprecision(2)
363 TString eventOrTsStr = fCbmEvents && fNofEvents > 0 ? "ev: " : "TS: ";
364 Double_t eventOrTsValue = Double_t(fCbmEvents && fNofEvents > 0 ? fNofEvents : fNofTs);
365 if (fCalcTime[0] != 0.) {
366 LOG(info) << "===== Time by task (real time) ======";
368 LOG(info) << "TrackExtrapolation / " << eventOrTsStr << fixed << setprecision(2) << setw(9) << right
369 << 1000. * fCalcTime[1] / eventOrTsValue << " ms [" << setw(5) << right
370 << 100 * fCalcTime[1] / fCalcTime[0] << " %]";
372 LOG(info) << "TrackProjection / " << eventOrTsStr << fixed << setprecision(2) << setw(9) << right
373 << 1000. * fCalcTime[2] / eventOrTsValue << " ms [" << setw(5) << right
374 << 100 * fCalcTime[2] / fCalcTime[0] << " %]";
375 if (fRingFinder)
376 LOG(info) << "RingFinder / " << eventOrTsStr << fixed << setprecision(2) << setw(9) << right
377 << 1000. * fCalcTime[3] / eventOrTsValue << " ms [" << setw(5) << right
378 << 100 * fCalcTime[3] / fCalcTime[0] << " %]";
379 if (fRingFitter)
380 LOG(info) << "RingFitter / " << eventOrTsStr << fixed << setprecision(2) << setw(9) << right
381 << 1000. * fCalcTime[4] / eventOrTsValue << " ms [" << setw(5) << right
382 << 100 * fCalcTime[4] / fCalcTime[0] << " %]";
384 LOG(info) << "RingTrackAssign / " << eventOrTsStr << fixed << setprecision(2) << setw(9) << right
385 << 1000. * fCalcTime[5] / eventOrTsValue << " ms [" << setw(5) << right
386 << 100 * fCalcTime[5] / fCalcTime[0] << " %]";
387 }
388 LOG(info) << "=====================================\n";
389}
390
ClassImp(CbmConverterManager)
Convert internal data classes to cbmroot common data classes.
Project track by straight line from imaginary plane to the mirror and reflect it to the photodetector...
Main class for running event reconstruction in the RICH detector.
Main class for ring finder based on Hough Transform implementation.
Ideal ring finder in the RICH detector. It uses MC information to attach RICH hits to rings.
Here the ring is fitted with the COP algorithm from A. Ayriyan/G. Ososkov.
Implementation of a ring fitting algorithm with equation of a circle. Algorithm from F77 subroutine o...
This is the implementation of ellipse fitting using MINUIT.
Here the ring is fitted with Taubin algorithm from A. Ayriyan, G. Ososkov, N. Chernov.
Here the ring is fitted with the RobustCOP algorithm from A. Ayriyan/G. Ososkov.
Here the ring is fitted with the TAU algorithm from A. Ayriyan/ G. Ososkov.
Ring-Track Assignment according to the closest distance criterion.
This is interface for concrete extrapolation algorithms to RICH.
This is the implementation of the TrackExtrapolation from MC points. It reads the STS track array,...
"TrackExtrapolation" from STS tracks (Kalman Fitter) It reads the track array form STS and extrapolat...
"TrackExtrapolation" from STS tracks based on Littrack. It reads the track array form STS and extrapo...
This is the implementation of the TrackExtrapolation from MC points - operating on points in the RICH...
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
static void CopyParamsToRing(const CbmRichRingLight *ring1, CbmRichRing *ring2)
Copy parameters from CbmRichRingLight to CbmRichRing.
static void Init()
Initialize array of RICH hits.
static void CopyHitsToRingLight(const CbmRichRing *ring1, CbmRichRingLight *ring2)
Copy hits from CbmRichRing to CbmRichRingLight.
CbmRichRecGeoPar * fGP
static CbmRichGeoManager & GetInstance()
Project track by straight line from imaginary plane to the mirror and reflect it to the photodetector...
virtual void Init()
Initialization in case one needs to initialize some TCloneArrays.
virtual void DoProjection(TClonesArray *richProj)=0
Project track by straight line from imaginary plane to the mirror and reflect it to the photodetector...
Main class for running event reconstruction in the RICH detector.
std::array< Double_t, 6 > fCalcTime
virtual InitStatus Init()
Inherited from FairTask.
CbmRichRingTrackAssignBase * fRingTrackAssign
CbmRichTrackExtrapolationBase * fTrackExtrapolation
void ProcessData(CbmEvent *event)
virtual void Exec(Option_t *opt)
Inherited from FairTask.
virtual void Finish()
Inherited from FairTask.
CbmRichProjectionProducerBase * fProjectionProducer
Main class for ring finder based on Hough Transform implementation.
virtual Int_t DoFind(CbmEvent *event, TClonesArray *rHitArray, TClonesArray *rProjArray, TClonesArray *rRingArray)=0
virtual void Init()
virtual void DoFit(CbmRichRingLight *ring)=0
Abstract method DoFit. To be implemented in the concrete class. Perform a fit to the hits attached to...
Here the ring is fitted with the COP algorithm from A. Ayriyan/G. Ososkov.
Implementation of a ring fitting algorithm with equation of a circle. Algorithm from F77 subroutine o...
This is the implementation of ellipse fitting using MINUIT.
Here the ring is fitted with Taubin algorithm from A. Ayriyan, G. Ososkov, N. Chernov.
Here the ring is fitted with the RobustCOP algorithm from A. Ayriyan/G. Ososkov.
Here the ring is fitted with the TAU algorithm from A. Ayriyan/ G. Ososkov.
virtual void Init()
Initialization in case one needs to initialize some TCloneArrays.
virtual void DoAssign(CbmEvent *event, TClonesArray *rings, TClonesArray *richProj)=0
Ring-Track Assignment according to the closest distance criterion.
virtual void Init()
Initialization in case one needs to initialize some TClonearrays.
virtual void DoExtrapolation(CbmEvent *event, TClonesArray *globalTracks, TClonesArray *extrapolatedTrackParams, double z)=0
Read the global track array, extrapolate track to a given z-Plane in RICH detector and fill output ar...
"TrackExtrapolation" from MC points. It reads the PointArray with ImPlanePoints from MC and selects t...
"TrackExtrapolation" from STS tracks (Kalman Fitter) It reads the track array form STS and extrapolat...
"TrackExtrapolation" from STS tracks based on Littrack. It reads the track array form STS and extrapo...
This is the implementation of the TrackExtrapolation from MC points - operating on points in the RICH...