CbmRoot
Loading...
Searching...
No Matches
CbmLitTrackingQa.cxx
Go to the documentation of this file.
1/* Copyright (C) 2007-2021 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer], Florian Uhlig */
4
11#include "CbmLitTrackingQa.h"
12
13#include "CbmGlobalTrack.h"
14#include "CbmHistManager.h"
15#include "CbmHit.h"
18#include "CbmMCDataArray.h"
19#include "CbmMCDataManager.h"
20#include "CbmMCTrack.h"
21#include "CbmMatch.h"
22#include "CbmRichRing.h"
23#include "CbmRichUtil.h"
24#include "CbmStsSetup.h"
25#include "CbmStsTrack.h"
26#include "CbmTrackMatchNew.h"
27#include "CbmUtils.h"
28#include "FairMCPoint.h"
29#include "TClonesArray.h"
30#include "TH1.h"
31#include "TH2F.h"
35
36#include <TFile.h>
37
38#include <boost/assign/list_of.hpp>
39
40#include <fstream>
41#include <iostream>
42
43using boost::assign::list_of;
45using Cbm::Split;
46using std::cout;
47using std::list;
48using std::make_pair;
49using std::pair;
50
52 : FairTask("LitTrackingQA", 1)
53 , fHM(NULL)
54 , fOutputDir("")
55 , fDet()
56 , fMCTrackCreator(NULL)
57 , fMinNofPointsSts(4)
58 , fMinNofPointsTrd(2)
59 , // SIS100
60 fMinNofPointsMuch(10)
61 , fMinNofPointsTof(1)
62 , fQuota(0.7)
63 , fUseConsecutivePointsInSts(true)
64 , fMinNofHitsRich(7)
65 , fQuotaRich(0.6)
66 , fMinNofHitsTrd(2)
67 , // SIS100
68 fMinNofHitsMuch(10)
69 , fPRangeMin(0.)
70 , fPRangeMax(10.)
71 , fPRangeBins(20.)
72 , fPtRangeMin(0.)
73 , fPtRangeMax(3.)
74 , fPtRangeBins(12.)
75 , fYRangeMin(0.)
76 , fYRangeMax(4.)
77 , fYRangeBins(16)
78 , fAngleRangeMin(0.)
79 , fAngleRangeMax(25.)
80 , fAngleRangeBins(10)
81 , fMCTracks(NULL)
82 , fGlobalTracks(NULL)
83 , fMvdPoints(NULL)
84 , fMvdHitMatches(NULL)
85 , fStsTracks(NULL)
86 , fStsMatches(NULL)
87 , fRichRings(NULL)
88 , fRichProjections(NULL)
89 , fRichRingMatches(NULL)
90 , fMuchMatches(NULL)
91 , fTrdMatches(NULL)
92 , fTofPoints(NULL)
93 , fTofMatches(NULL)
94 , fRichAnnCut(0.0) // values loose | strict: -0.4 | 0.0
95 , fTrdAnnCut(0.8) // at the moment, TrdAnn is likelihood value // values loose | strict: 0.2 | 0.8
96{
97}
98
100{
101 if (fHM) delete fHM;
102}
103
105{
106 // Create histogram manager which is used throughout the program
107 fHM = new CbmHistManager();
108
112
117
119
121
122 // --- Get STS setup
124
125 if (!stsSetup->IsInit()) stsSetup->Init();
126
128
129 fMcToRecoMap.clear();
130 vector<string> trackVariants = GlobalTrackVariants();
131 for (UInt_t i = 0; i < trackVariants.size(); i++) {
132 fMcToRecoMap.insert(make_pair(trackVariants[i], multimap<pair<Int_t, Int_t>, Int_t>()));
133 }
134
137
138 return kSUCCESS;
139}
140
141void CbmLitTrackingQa::Exec(Option_t* /*opt*/)
142{
143 // Increase event counter
144 fHM->H1("hen_EventNo_TrackingQa")->Fill(0.5);
145 Int_t eventNum = fHM->H1("hen_EventNo_TrackingQa")->GetEntries() - 1;
146 std::cout << "CbmLitTrackingQa::Exec: event=" << eventNum << std::endl;
147
148 fMCTrackCreator->Create(eventNum);
149
151 ProcessMcTracks(eventNum);
154}
155
157{
158
159 TDirectory* oldir = gDirectory;
160 TFile* outFile = FairRootManager::Instance()->GetOutFile();
161 if (outFile != NULL) {
162 outFile->cd();
163 fHM->WriteToFile();
164 }
165 gDirectory->cd(oldir->GetPath());
166
167 if (fOutputDir != "") {
169 report->Create(fHM, fOutputDir);
170 delete report;
171 }
172}
173
175{
176 FairRootManager* ioman = FairRootManager::Instance();
177 if (NULL == ioman) {
178 Fatal("Init", "CbmRootManager is not instantiated");
179 }
180
181 CbmMCDataManager* mcManager = (CbmMCDataManager*) ioman->GetObject("MCDataManager");
182 fMCTracks = mcManager->InitBranch("MCTrack");
183 if (NULL == fMCTracks) {
184 Fatal("Init", "No MCTrack array!");
185 }
186
187 fGlobalTracks = (TClonesArray*) ioman->GetObject("GlobalTrack");
188 if (NULL == fGlobalTracks) {
189 Fatal("Init", "No GlobalTrack array!");
190 }
191
193 fMvdPoints = mcManager->InitBranch("MvdPoint");
194 if (NULL == fMvdPoints) {
195 Fatal("Init", ": No MvdPoint array!");
196 }
197 fMvdHitMatches = (TClonesArray*) ioman->GetObject("MvdHitMatch");
198 if (NULL == fMvdHitMatches) {
199 Fatal("Init", ": No MvdHitMatch array!");
200 }
201 }
202
204 fStsTracks = (TClonesArray*) ioman->GetObject("StsTrack");
205 if (NULL == fStsTracks) {
206 Fatal("Init", ": No StsTrack array!");
207 }
208 fStsMatches = (TClonesArray*) ioman->GetObject("StsTrackMatch");
209 if (NULL == fStsMatches) {
210 Fatal("Init", ": No StsTrackMatch array!");
211 }
212 }
213
215 fRichRings = (TClonesArray*) ioman->GetObject("RichRing");
216 if (NULL == fRichRings) {
217 Fatal("Init", "No RichRing array!");
218 }
219 fRichProjections = (TClonesArray*) ioman->GetObject("RichProjection");
220 if (NULL == fRichProjections) {
221 Fatal("Init", "No RichProjection array!");
222 }
223 fRichRingMatches = (TClonesArray*) ioman->GetObject("RichRingMatch");
224 if (NULL == fRichRingMatches) {
225 Fatal("Init", "No RichRingMatch array!");
226 }
227 }
228
230 fMuchMatches = (TClonesArray*) ioman->GetObject("MuchTrackMatch");
231 if (NULL == fMuchMatches) {
232 Fatal("Init", "No MuchTrackMatch array!");
233 }
234 }
235
237 fTrdMatches = (TClonesArray*) ioman->GetObject("TrdTrackMatch");
238 if (NULL == fTrdMatches) {
239 Fatal("Init", "No TrdTrackMatch array!");
240 }
241 }
242
244 fTofPoints = mcManager->InitBranch("TofPoint");
245 if (NULL == fTofPoints) {
246 Fatal("Init", "No TofPoint array!");
247 }
248 fTofMatches = (TClonesArray*) ioman->GetObject("TofHitMatch");
249 if (NULL == fTofMatches) {
250 Fatal("Init", "No TofHitMatch array!");
251 }
252 }
253}
254
256{
257 string elMu = fDet.GetElectronSetup() ? "Electron" : "Muon";
258 vector<string> tmp{"All", "Primary", "Secondary", "Reference", elMu,
259 "Proton", "PionPlus", "PionMinus", "KaonPlus", "KaonMinus"};
260 fTrackCategories = tmp;
261}
262
264{
265 vector<string> tmp{"All", "AllReference", "Electron", "ElectronReference", "Pion", "PionReference"};
266 fRingCategories = tmp;
267}
268
270{
271 if (fDet.GetElectronSetup()) {
272 vector<string> tmp = list_of("Electron");
274 }
275}
276
278{
279 if (fDet.GetElectronSetup()) {
280 vector<string> tmp = list_of("Electron");
281 fRingCategoriesPID = tmp;
282 }
283}
284
286{
287 if (fDet.GetElectronSetup()) {
288 vector<string> tmp = list_of("All")("TrueMatch")("WrongMatch");
289 fPiSuppCategories = tmp;
290 }
291}
292
294{
295 // List of all supported track categories
309
310 // List of all supported ring categories
314 fRingAcceptanceFunctions["ElectronReference"] =
318
319 // list of pion suppression categories
323}
324
325void CbmLitTrackingQa::CreateH1Efficiency(const string& name, const string& parameter, const string& xTitle,
326 Int_t nofBins, Double_t minBin, Double_t maxBin, const string& opt)
327{
328 assert(opt == "track" || opt == "ring" || opt == "track_pid" || opt == "ring_pid");
329 vector<string> types = list_of("Acc")("Rec")("Eff");
330 vector<string> cat = (opt == "track") ? fTrackCategories
331 : (opt == "ring") ? fRingCategories
332 : (opt == "track_pid") ? fTrackCategoriesPID
334
335 for (UInt_t iCat = 0; iCat < cat.size(); iCat++) {
336 for (Int_t iType = 0; iType < 3; iType++) {
337 string yTitle = (types[iType] == "Eff") ? "Efficiency [%]" : "Counter";
338 string histName = name + "_" + cat[iCat] + "_" + types[iType] + "_" + parameter;
339 string histTitle = histName + ";" + xTitle + ";" + yTitle;
340 fHM->Add(histName, new TH1F(histName.c_str(), histTitle.c_str(), nofBins, minBin, maxBin));
341 }
342 }
343}
344
345void CbmLitTrackingQa::CreateH2Efficiency(const string& name, const string& parameter, const string& xTitle,
346 const string& yTitle, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX,
347 Int_t nofBinsY, Double_t minBinY, Double_t maxBinY, const string& opt)
348{
349 assert(opt == "track" || opt == "ring" || opt == "track_pid" || opt == "ring_pid");
350 vector<string> types = list_of("Acc")("Rec")("Eff");
351 vector<string> cat = (opt == "track") ? fTrackCategories
352 : (opt == "ring") ? fRingCategories
353 : (opt == "track_pid") ? fTrackCategoriesPID
355
356 for (UInt_t iCat = 0; iCat < cat.size(); iCat++) {
357 for (Int_t iType = 0; iType < 3; iType++) {
358 string zTitle = (types[iType] == "Eff") ? "Efficiency [%]" : "Counter";
359 string histName = name + "_" + cat[iCat] + "_" + types[iType] + "_" + parameter;
360 string histTitle = histName + ";" + xTitle + ";" + yTitle + ";" + zTitle;
361 fHM->Add(histName,
362 new TH2F(histName.c_str(), histTitle.c_str(), nofBinsX, minBinX, maxBinX, nofBinsY, minBinY, maxBinY));
363 }
364 }
365}
366
367void CbmLitTrackingQa::CreateH1PionSuppression(const string& name, const string& parameter, const string& xTitle,
368 Int_t nofBins, Double_t minBin, Double_t maxBin)
369{
370 vector<string> types = list_of("RecPions")("Rec")("PionSup");
371 for (UInt_t iCat = 0; iCat < fPiSuppCategories.size(); iCat++) {
372 for (Int_t iType = 0; iType < 3; iType++) {
373 string yTitle = (types[iType] == "PionSup") ? "Pion suppression" : "Counter";
374 string histName = name + "_" + fPiSuppCategories[iCat] + "_" + types[iType] + "_" + parameter;
375 string histTitle = histName + ";" + xTitle + ";" + yTitle;
376 fHM->Add(histName, new TH1F(histName.c_str(), histTitle.c_str(), nofBins, minBin, maxBin));
377 }
378 }
379}
380
381void CbmLitTrackingQa::CreateH1(const string& name, const string& xTitle, const string& yTitle, Int_t nofBins,
382 Double_t minBin, Double_t maxBin)
383{
384 TH1F* h = new TH1F(name.c_str(), string(name + ";" + xTitle + ";" + yTitle).c_str(), nofBins, minBin, maxBin);
385 fHM->Add(name, h);
386}
387
388void CbmLitTrackingQa::CreateH2(const string& name, const string& xTitle, const string& yTitle, const string& zTitle,
389 Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY,
390 Double_t maxBinY)
391{
392 TH2F* h = new TH2F(name.c_str(), (name + ";" + xTitle + ";" + yTitle + ";" + zTitle).c_str(), nofBinsX, minBinX,
393 maxBinX, nofBinsY, minBinY, maxBinY);
394 fHM->Add(name, h);
395}
396
398{
399 string type[] = {"All", "True", "Fake", "TrueOverAll", "FakeOverAll"};
400 Double_t min[] = {-0.5, -0.5, -0.5, -0.1, -0.1};
401 Double_t max[] = {99.5, 99.5, 99.5, 1.1, 1.1};
402 Int_t bins[] = {100, 100, 100, 12, 12};
403 for (Int_t i = 0; i < 5; i++) {
404 string xTitle = (i == 3 || i == 4) ? "Ratio" : "Number of hits";
405 string histName = "hth_" + detName + "_TrackHits_" + type[i];
406 CreateH1(histName.c_str(), xTitle, "Yeild", bins[i], min[i], max[i]);
407 }
408}
409
410vector<string> CbmLitTrackingQa::CreateGlobalTrackingHistogramNames(const vector<string>& detectors)
411{
412 vector<string> histos;
413 Int_t nofDetectors = detectors.size();
414 for (Int_t iDet = 0; iDet < nofDetectors; iDet++) {
415 string histEff;
416 for (Int_t i = 0; i <= iDet; i++) {
417 histEff += detectors[i];
418 }
419 string histNorm = histEff;
420 histos.push_back("hte_" + histEff + "_" + histNorm);
421 for (Int_t i = iDet + 1; i < nofDetectors; i++) {
422 histNorm += detectors[i];
423 histos.push_back("hte_" + histEff + "_" + histNorm);
424 }
425 }
426 return histos;
427}
428
430{
431 // Histograms w/o RICH detector
432 vector<string> detectors;
433 if (fDet.GetDet(ECbmModuleId::kSts)) detectors.push_back("Sts");
434 if (fDet.GetDet(ECbmModuleId::kMuch)) detectors.push_back("Much");
435 if (fDet.GetDet(ECbmModuleId::kTrd)) detectors.push_back("Trd");
436 if (fDet.GetDet(ECbmModuleId::kTof)) detectors.push_back("Tof");
437 vector<string> names1 = CreateGlobalTrackingHistogramNames(detectors);
438
439 // Histograms with RICH detector
440 vector<string> names2;
442 detectors.clear();
443 if (fDet.GetDet(ECbmModuleId::kSts)) detectors.push_back("Sts");
444 if (fDet.GetDet(ECbmModuleId::kRich)) detectors.push_back("Rich");
445 if (fDet.GetDet(ECbmModuleId::kTrd)) detectors.push_back("Trd");
446 if (fDet.GetDet(ECbmModuleId::kTof)) detectors.push_back("Tof");
447 names2 = CreateGlobalTrackingHistogramNames(detectors);
448 }
449
450 set<string> names;
451 names.insert(names1.begin(), names1.end());
452 names.insert(names2.begin(), names2.end());
453 vector<string> nameVector(names.begin(), names.end());
454 return nameVector;
455}
456
458{
459 set<string> trackVariants;
460 // Histograms w/o RICH detector
461 vector<string> detectors;
462 if (fDet.GetDet(ECbmModuleId::kSts)) detectors.push_back("Sts");
463 if (fDet.GetDet(ECbmModuleId::kMuch)) detectors.push_back("Much");
464 if (fDet.GetDet(ECbmModuleId::kTrd)) detectors.push_back("Trd");
465 if (fDet.GetDet(ECbmModuleId::kTof)) detectors.push_back("Tof");
466 string name("");
467 for (UInt_t i = 0; i < detectors.size(); i++) {
468 name += detectors[i];
469 trackVariants.insert(name);
470 }
471
472 // Histograms with RICH detector
474 detectors.clear();
475 if (fDet.GetDet(ECbmModuleId::kSts)) detectors.push_back("Sts");
476 if (fDet.GetDet(ECbmModuleId::kRich)) detectors.push_back("Rich");
477 if (fDet.GetDet(ECbmModuleId::kTrd)) detectors.push_back("Trd");
478 if (fDet.GetDet(ECbmModuleId::kTof)) detectors.push_back("Tof");
479 name = "";
480 for (UInt_t i = 0; i < detectors.size(); i++) {
481 name += detectors[i];
482 trackVariants.insert(name);
483 }
484 }
485 vector<string> trackVariantsVector(trackVariants.begin(), trackVariants.end());
486
487 trackVariantsVector.push_back("Rich");
488
489 return trackVariantsVector;
490}
491
493{
494 set<string> variants;
495 // Histograms w/o RICH detector
496 vector<string> detectors;
497 if (fDet.GetDet(ECbmModuleId::kTrd)) detectors.push_back("Trd");
498 if (fDet.GetDet(ECbmModuleId::kTof)) detectors.push_back("Tof");
499 string name("");
500 for (UInt_t i = 0; i < detectors.size(); i++) {
501 name += detectors[i];
502 variants.insert(name);
503 }
504
505 // Histograms with RICH detector
507 detectors.clear();
508 if (fDet.GetDet(ECbmModuleId::kRich)) detectors.push_back("Rich");
509 if (fDet.GetDet(ECbmModuleId::kTrd)) detectors.push_back("Trd");
510 if (fDet.GetDet(ECbmModuleId::kTof)) detectors.push_back("Tof");
511 name = "";
512 for (UInt_t i = 0; i < detectors.size(); i++) {
513 name += detectors[i];
514 variants.insert(name);
515 }
516 }
517 vector<string> variantsVector(variants.begin(), variants.end());
518 return variantsVector;
519}
520
522{
523 set<string> trackVariants;
524 // Histograms w/o RICH detector
525 vector<string> detectors;
526 if (fDet.GetDet(ECbmModuleId::kSts)) detectors.push_back("Sts");
527 if (fDet.GetDet(ECbmModuleId::kMuch)) detectors.push_back("Much");
528 if (fDet.GetDet(ECbmModuleId::kTrd)) detectors.push_back("Trd");
529 if (fDet.GetDet(ECbmModuleId::kTof)) detectors.push_back("Tof");
530 string name("");
531 for (UInt_t i = 0; i < detectors.size(); i++) {
532 name += detectors[i];
533 if (detectors[i] == detName) break;
534 }
535 return name;
536}
537
539{
541
542 // Number of points distributions
543 Double_t minNofPoints = 0.;
544 Double_t maxNofPoints = 100.;
545 Int_t nofBinsPoints = 100;
546
547 // Reconstruction efficiency histograms
548 // Local efficiency histograms
549 // STS
550 // CreateEffHist3D("hSts3D", "track");
551 CreateH1Efficiency("hte_Sts_Sts", "Np", "Number of points", nofBinsPoints, minNofPoints, maxNofPoints, "track");
552 CreateH1Efficiency("hte_Sts_Sts", "Angle", "Polar angle [deg]", fAngleRangeBins, fAngleRangeMin, fAngleRangeMax,
553 "track");
554 // MUCH
556 string norm = LocalEfficiencyNormalization("Much");
557 string histName = "hte_Much_" + norm;
558 CreateH1Efficiency(histName, "p", "P [GeV/c]", fPRangeBins, fPRangeMin, fPRangeMax, "track");
559 CreateH1Efficiency(histName, "y", "Rapidity", fYRangeBins, fYRangeMin, fYRangeMax, "track");
560 CreateH1Efficiency(histName, "pt", "P_{t} [GeV/c]", fPtRangeBins, fPtRangeMin, fPtRangeMax, "track");
561 CreateH1Efficiency(histName, "Np", "Number of points", nofBinsPoints, minNofPoints, maxNofPoints, "track");
562 CreateH1Efficiency(histName, "Angle", "Polar angle [deg]", fAngleRangeBins, fAngleRangeMin, fAngleRangeMax,
563 "track");
564 CreateH2Efficiency(histName, "YPt", "Rapidity", "P_{t} [GeV/c]", fYRangeBins, fYRangeMin, fYRangeMax, fPtRangeBins,
565 fPtRangeMin, fPtRangeMax, "track");
566 }
567 // TRD
569 string norm = LocalEfficiencyNormalization("Trd");
570 string histName = "hte_Trd_" + norm;
571 CreateH1Efficiency(histName, "p", "P [GeV/c]", fPRangeBins, fPRangeMin, fPRangeMax, "track");
572 CreateH1Efficiency(histName, "y", "Rapidity", fYRangeBins, fYRangeMin, fYRangeMax, "track");
573 CreateH1Efficiency(histName, "pt", "P_{t} [GeV/c]", fPtRangeBins, fPtRangeMin, fPtRangeMax, "track");
574 CreateH1Efficiency(histName, "Np", "Number of points", nofBinsPoints, minNofPoints, maxNofPoints, "track");
575 CreateH1Efficiency(histName, "Angle", "Polar angle [deg]", fAngleRangeBins, fAngleRangeMin, fAngleRangeMax,
576 "track");
577 CreateH2Efficiency(histName, "YPt", "Rapidity", "P_{t} [GeV/c]", fYRangeBins, fYRangeMin, fYRangeMax, fPtRangeBins,
578 fPtRangeMin, fPtRangeMax, "track");
579 }
580 // TOF
582 string norm = LocalEfficiencyNormalization("Tof");
583 string histName = "hte_Tof_" + norm;
584 CreateH1Efficiency(histName, "p", "P [GeV/c]", fPRangeBins, fPRangeMin, fPRangeMax, "track");
585 CreateH1Efficiency(histName, "y", "Rapidity", fYRangeBins, fYRangeMin, fYRangeMax, "track");
586 CreateH1Efficiency(histName, "pt", "P_{t} [GeV/c]", fPtRangeBins, fPtRangeMin, fPtRangeMax, "track");
587 // CreateEfficiencyHistogram(histName, "Np", "Number of points", nofBinsPoints, minNofPoints, maxNofPoints, "track");
588 CreateH1Efficiency(histName, "Angle", "Polar angle [deg]", fAngleRangeBins, fAngleRangeMin, fAngleRangeMax,
589 "track");
590 CreateH2Efficiency(histName, "YPt", "Rapidity", "P_{t} [GeV/c]", fYRangeBins, fYRangeMin, fYRangeMax, fPtRangeBins,
591 fPtRangeMin, fPtRangeMax, "track");
592 }
593
594 // RICH
596 CreateH1Efficiency("hte_Rich_Rich", "p", "P [GeV/c]", fPRangeBins, fPRangeMin, fPRangeMax, "ring");
597 CreateH1Efficiency("hte_Rich_Rich", "y", "Rapidity", fYRangeBins, fYRangeMin, fYRangeMax, "ring");
598 CreateH1Efficiency("hte_Rich_Rich", "pt", "P_{t} [GeV/c]", fPtRangeBins, fPtRangeMin, fPtRangeMax, "ring");
599 CreateH1Efficiency("hte_Rich_Rich", "RingNh", "Number of hits", nofBinsPoints, minNofPoints, maxNofPoints, "ring");
600 CreateH1Efficiency("hte_Rich_Rich", "BoA", "B/A", 50, 0.0, 1.0, "ring");
601 CreateH1Efficiency("hte_Rich_Rich", "RingXc", "X [cm]", 60, -120, 120, "ring");
602 CreateH1Efficiency("hte_Rich_Rich", "RingYc", "|Y| [cm]", 25, 100, 200, "ring");
603 // CreateH1Efficiency("hte_Rich_Rich", "RadPos", "Radial position [cm]", 50, 0., 150., "ring");
604 CreateH2Efficiency("hte_Rich_Rich", "RingXcYc", "X [cm]", "Y [cm]", 14, -110., 110, 60, -300, 300, "ring");
605 CreateH2Efficiency("hte_Rich_Rich", "YPt", "Rapidity", "P_{t} [GeV/c]", fYRangeBins, fYRangeMin, fYRangeMax,
607 }
608
609 // Global efficiency histograms
610 vector<string> histoNames = CreateGlobalTrackingHistogramNames();
611 for (UInt_t iHist = 0; iHist < histoNames.size(); iHist++) {
612 string name = histoNames[iHist];
613 string opt = (name.find("Rich") == string::npos) ? "track" : "ring";
614 // Tracking efficiency
615 CreateH1Efficiency(name, "p", "P [GeV/c]", fPRangeBins, fPRangeMin, fPRangeMax, opt);
616 CreateH1Efficiency(name, "y", "Rapidity", fYRangeBins, fYRangeMin, fYRangeMax, opt);
617 CreateH1Efficiency(name, "pt", "P_{t} [GeV/c]", fPtRangeBins, fPtRangeMin, fPtRangeMax, opt);
618 CreateH2Efficiency(name, "YPt", "Rapidity", "P_{t} [GeV/c]", fYRangeBins, fYRangeMin, fYRangeMax, fPtRangeBins,
620
621 //Global efficiency vs. RingXc or RingYc
622 if (name.find("Rich") != string::npos) {
623 CreateH1Efficiency(name, "RingXc", "Ring Xc [cm]", 60, -120, 120, opt);
624 CreateH1Efficiency(name, "RingYc", "|Ring Yc| [cm]", 25, 100, 200, opt);
625 }
626 // PID
627 opt += "_pid";
628 CreateH1Efficiency(FindAndReplace(name, "hte_", "hpe_"), "p", "P [GeV/c]", fPRangeBins, fPRangeMin, fPRangeMax,
629 opt);
630 // CreateH1Efficiency(name, "y", "Rapidity", fYRangeBins, fYRangeMin, fYRangeMax, opt);
631 // CreateH1Efficiency(name, "pt", "P_{t} [GeV/c]", fPtRangeBins, fPtRangeMin, fPtRangeMax, opt);
632 // CreateH2Efficiency(name, "YPt", "Rapidity", "P_{t} [GeV/c]", fYRangeBins, fYRangeMin, fYRangeMax, fPtRangeBins, fPtRangeMin, fPtRangeMax, opt);
633 }
634
635
636 // Create histograms for pion suppression calculation
637 vector<string> psVariants = PionSuppressionVariants();
638 for (UInt_t iHist = 0; iHist < psVariants.size(); iHist++) {
639 string name = "hps_" + psVariants[iHist];
640 CreateH1PionSuppression(name, "p", "P [GeV/c]", fPRangeBins, fPRangeMin, fPRangeMax);
641 CreateH1PionSuppression(name, "p", "P [GeV/c]", fPRangeBins, fPRangeMin, fPRangeMax);
642 CreateH1PionSuppression(name, "p", "P [GeV/c]", fPRangeBins, fPRangeMin, fPRangeMax);
643 }
644
645 // // Create efficiency histograms with normalization to INPUT
646 // vector<TH1*> effHistos = fHM->H1Vector("hte_+*_Eff_+*");
647 // Int_t nofEffHistos = effHistos.size();
648 // set<string> effNamesSet;
649 // vector<string> effNormNames;
650 // for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
651 // TH1* hist = effHistos[iHist];
652 // vector<string> split = Split(hist->GetName(), '_');
653 // string effName = split[1];
654 // string normName = split[2];
655 // if (effNamesSet.find(effName) == effNamesSet.end()) {
656 // effNamesSet.insert(effName);
657 // effNormNames.push_back(effName + "_" + normName);
658 // }
659 // }
660 // for (Int_t i = 0; i < effNormNames.size(); i++) {
661 // std::cout << i << " " << effNormNames[i] << std::endl;
662 // }
663 // Int_t nofEffNormNames = effNormNames.size();
664 // for (Int_t iHist = 0; iHist < effNormNames.size(); iHist++) {
665 //
666 // }
667 // //vector<string> effNormNames(effNormNamesSet.begin(), effNormNames.end());
668 // //
669
670 // Create histograms for ghost tracks
672 CreateH1("hng_NofGhosts_Sts_Nh", "Number of hits", "Yield", nofBinsPoints, minNofPoints, maxNofPoints);
674 CreateH1("hng_NofGhosts_Trd_Nh", "Number of hits", "Yield", nofBinsPoints, minNofPoints, maxNofPoints);
676 CreateH1("hng_NofGhosts_Much_Nh", "Number of hits", "Yield", nofBinsPoints, minNofPoints, maxNofPoints);
678 CreateH1("hng_NofGhosts_Rich_Nh", "Number of hits", "Yield", nofBinsPoints, minNofPoints, maxNofPoints);
679 CreateH2("hng_NofGhosts_Rich_RingXcYc", "X [cm]", "Y [cm]", "Ghosts per event", 28, -110., 110, 40, -200, 200);
680 CreateH1("hng_NofGhosts_RichStsMatching_Nh", "Number of hits", "Yield", nofBinsPoints, minNofPoints, maxNofPoints);
681 CreateH1("hng_NofGhosts_RichElId_Nh", "Number of hits", "Yield", nofBinsPoints, minNofPoints, maxNofPoints);
682 CreateH1("hng_NofGhosts_StsRichMatching_Nh", "Number of hits", "Yield", nofBinsPoints, minNofPoints, maxNofPoints);
683 }
684
685 // Create track hits histograms
691
692
693 // Create number of object histograms
694 Int_t nofBinsC = 100000;
695 Double_t maxXC = 100000.;
696 CreateH1("hno_NofObjects_GlobalTracks", "Tracks per event", "Yield", nofBinsC, 1., maxXC);
698 CreateH1("hno_NofObjects_StsTracks", "Tracks per event", "Yield", nofBinsC, 1., maxXC);
700 CreateH1("hno_NofObjects_TrdTracks", "Tracks per event", "Yield", nofBinsC, 1., maxXC);
702 CreateH1("hno_NofObjects_MuchTracks", "Tracks per event", "Yield", nofBinsC, 1., maxXC);
704 CreateH1("hno_NofObjects_RichRings", "Rings per event", "Yield", nofBinsC, 1., maxXC);
705 CreateH1("hno_NofObjects_RichProjections", "Projections per event", "Yield", nofBinsC, 1., maxXC);
706 }
707
708 // Histogram stores number of events
709 CreateH1("hen_EventNo_TrackingQa", "", "", 1, 0, 1.);
710
711 cout << fHM->ToString();
712}
713
714
716{
717 // Clear all maps for MC to reco matching
718 for (auto it = fMcToRecoMap.begin(); it != fMcToRecoMap.end(); it++) {
719 multimap<pair<Int_t, Int_t>, Int_t>& mcRecoMap = (*it).second;
720 mcRecoMap.clear();
721 //(*it).second.clear();
722 }
723
725
726 if (fGlobalTracks == nullptr) return;
727
728 Int_t nofGlobalTracks = fGlobalTracks->GetEntriesFast();
729 for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) {
730 const CbmGlobalTrack* globalTrack = static_cast<const CbmGlobalTrack*>(fGlobalTracks->At(iTrack));
731
732 // get track segments indices
733 Int_t stsId = globalTrack->GetStsTrackIndex();
734 Int_t trdId = globalTrack->GetTrdTrackIndex();
735 Int_t muchId = globalTrack->GetMuchTrackIndex();
736 Int_t tofId = globalTrack->GetTofHitIndex();
737 Int_t richId = globalTrack->GetRichRingIndex();
738
739 // check track segments
740 Bool_t isStsOk = stsId > -1 && fDet.GetDet(ECbmModuleId::kSts);
741 Bool_t isTrdOk = trdId > -1 && fDet.GetDet(ECbmModuleId::kTrd);
742 Bool_t isMuchOk = muchId > -1 && fDet.GetDet(ECbmModuleId::kMuch);
743 Bool_t isTofOk = tofId > -1 && fDet.GetDet(ECbmModuleId::kTof);
744 Bool_t isRichOk = richId > -1 && fDet.GetDet(ECbmModuleId::kRich);
745
746 Double_t rtDistance = 10;
747
748 if (isRichOk) rtDistance = CbmRichUtil::GetRingTrackDistance(iTrack);
749
750 // check the quality of track segments
751 const CbmTrackMatchNew* stsTrackMatch = nullptr;
752 if (isStsOk) {
753 stsTrackMatch = static_cast<const CbmTrackMatchNew*>(fStsMatches->At(stsId));
754 isStsOk = stsTrackMatch->GetTrueOverAllHitsRatio() >= fQuota;
756 if (!isStsOk) { // ghost track
757 Int_t nofHits = stsTrackMatch->GetNofHits();
758 fHM->H1("hng_NofGhosts_Sts_Nh")->Fill(nofHits);
759
760 // calculate number of ghost after RICH matching
761 if (isRichOk) {
762 const CbmRichRing* ring = static_cast<const CbmRichRing*>(fRichRings->At(richId));
763 if (NULL != ring) {
764 if (CbmRichUtil::GetRingTrackDistance(iTrack) < 1.)
765 fHM->H1("hng_NofGhosts_StsRichMatching_Nh")->Fill(nofHits);
766 }
767 }
768 }
769 else {
770 ProcessMvd(stsId);
771 }
772 }
773 const CbmTrackMatchNew* trdTrackMatch = nullptr;
774 if (isTrdOk) {
775 trdTrackMatch = static_cast<const CbmTrackMatchNew*>(fTrdMatches->At(trdId));
776 Int_t nofHits = trdTrackMatch->GetNofHits();
777 if (nofHits >= fMinNofHitsTrd) {
778 isTrdOk = trdTrackMatch->GetTrueOverAllHitsRatio() >= fQuota;
780 if (!isTrdOk) { // ghost track
781 fHM->H1("hng_NofGhosts_Trd_Nh")->Fill(nofHits);
782 }
783 }
784 else {
785 isTrdOk = false;
786 }
787 }
788 const CbmTrackMatchNew* muchTrackMatch;
789 if (isMuchOk) {
790 muchTrackMatch = static_cast<const CbmTrackMatchNew*>(fMuchMatches->At(muchId));
791 Int_t nofHits = muchTrackMatch->GetNofHits();
792 if (nofHits >= fMinNofHitsMuch) {
793 isMuchOk = muchTrackMatch->GetTrueOverAllHitsRatio() >= fQuota;
795 if (!isMuchOk) { // ghost track
796 fHM->H1("hng_NofGhosts_Much_Nh")->Fill(nofHits);
797 }
798 }
799 else {
800 isMuchOk = false;
801 }
802 }
803 const CbmTrackMatchNew* richRingMatch = nullptr;
804 if (isRichOk) {
805 richRingMatch = static_cast<const CbmTrackMatchNew*>(fRichRingMatches->At(richId));
806 Int_t nofHits = richRingMatch->GetNofHits();
807 isRichOk = richRingMatch->GetTrueOverAllHitsRatio() >= fQuotaRich;
809 if (!isRichOk) { // ghost ring
810 fHM->H1("hng_NofGhosts_Rich_Nh")->Fill(nofHits);
811
812 const CbmRichRing* ring = static_cast<const CbmRichRing*>(fRichRings->At(richId));
813 if (NULL != ring) {
814 // ghost ring distribution vs position on photodetector plane
815 fHM->H1("hng_NofGhosts_Rich_RingXcYc")->Fill(ring->GetCenterX(), ring->GetCenterY());
816
817 // calculate number of ghost after STS matching and electron identification
818 if (rtDistance < 1.) fHM->H1("hng_NofGhosts_RichStsMatching_Nh")->Fill(nofHits);
819
820 Double_t momentumMc = 0.;
821 if (stsTrackMatch != NULL) {
822 const CbmMCTrack* mcTrack = static_cast<const CbmMCTrack*>(fMCTracks->Get(stsTrackMatch->GetMatchedLink()));
823 if (mcTrack != NULL) momentumMc = mcTrack->GetP();
824 }
825 if (rtDistance < 1. && CbmLitGlobalElectronId::GetInstance().IsRichElectron(iTrack, momentumMc)) {
826 fHM->H1("hng_NofGhosts_RichElId_Nh")->Fill(nofHits);
827 }
828 }
829 }
830 }
831
832 // Get MC indices of track segments
833 pair<Int_t, Int_t> stsMCId = {-1, -1}, trdMCId = {-1, -1}, muchMCId = {-1, -1}, richMCId = {-1, -1};
834 list<pair<Int_t, Int_t>> tofMCIds;
835 if (isStsOk) {
836 stsMCId = {stsTrackMatch->GetMatchedLink().GetEntry(), stsTrackMatch->GetMatchedLink().GetIndex()};
837 }
838 if (isTrdOk) {
839 trdMCId = {trdTrackMatch->GetMatchedLink().GetEntry(), trdTrackMatch->GetMatchedLink().GetIndex()};
840 }
841 if (isMuchOk) {
842 muchMCId = {muchTrackMatch->GetMatchedLink().GetEntry(), muchTrackMatch->GetMatchedLink().GetIndex()};
843 }
844 if (isTofOk) {
845 const CbmMatch* tofMatch = static_cast<const CbmMatch*>(fTofMatches->At(tofId));
846 const vector<CbmLink>& tofMCLinks = tofMatch->GetLinks();
847
848 for (vector<CbmLink>::const_iterator tofMCIt = tofMCLinks.begin(); tofMCIt != tofMCLinks.end(); ++tofMCIt) {
849 const FairMCPoint* tofPoint = static_cast<const FairMCPoint*>(fTofPoints->Get(*tofMCIt));
850
851 if (tofPoint != NULL) tofMCIds.push_back(pair<Int_t, Int_t>(tofMCIt->GetEntry(), tofPoint->GetTrackID()));
852 }
853 }
854 if (isRichOk) {
855 richMCId = {richRingMatch->GetMatchedLink().GetEntry(), richRingMatch->GetMatchedLink().GetIndex()};
856 }
857
858 for (auto it = fMcToRecoMap.begin(); it != fMcToRecoMap.end(); it++) {
859 string name = (*it).first;
860 multimap<pair<Int_t, Int_t>, Int_t>& mcRecoMap = (*it).second;
861 Bool_t sts = (name.find("Sts") != string::npos) ? isStsOk && stsMCId.second != -1 : true;
862 Bool_t trd = (name.find("Trd") != string::npos) ? isTrdOk && stsMCId == trdMCId : true;
863 Bool_t much = (name.find("Much") != string::npos) ? isMuchOk && stsMCId == muchMCId : true;
864 Bool_t tof = (name.find("Tof") != string::npos)
865 ? isTofOk && find(tofMCIds.begin(), tofMCIds.end(), stsMCId) != tofMCIds.end()
866 : true;
867 Bool_t rich = (name.find("Rich") != string::npos) ? isRichOk && stsMCId == richMCId : true;
868
869 if (sts && trd && much && tof && rich) {
870 pair<pair<Int_t, Int_t>, Int_t> tmp = make_pair(stsMCId, iTrack);
871 mcRecoMap.insert(tmp);
872 }
873 }
874 }
875}
876
878{
879 if (!fDet.GetDet(ECbmModuleId::kRich)) return;
880 Int_t nofRings = fRichRings->GetEntriesFast();
881 for (Int_t iRing = 0; iRing < nofRings; iRing++) {
882 const CbmTrackMatchNew* richRingMatch = static_cast<const CbmTrackMatchNew*>(fRichRingMatches->At(iRing));
883 Bool_t isRichOk = richRingMatch->GetTrueOverAllHitsRatio() >= fQuotaRich;
884 pair<Int_t, Int_t> richMCId = {isRichOk ? richRingMatch->GetMatchedLink().GetEntry() : -1,
885 isRichOk ? richRingMatch->GetMatchedLink().GetIndex() : -1}; //GetMCTrackId() : -1;
886 if (isRichOk && -1 != richMCId.second) {
887 pair<pair<Int_t, Int_t>, Int_t> tmp = make_pair(richMCId, iRing);
888 fMcToRecoMap["Rich"].insert(tmp);
889 }
890 }
891}
892
894{
895 if (!fDet.GetDet(ECbmModuleId::kMvd)) return;
896 const CbmStsTrack* track = static_cast<const CbmStsTrack*>(fStsTracks->At(stsId));
897 Int_t nofHits = track->GetNofMvdHits();
898 fHM->H1("hth_Mvd_TrackHits_All")->Fill(nofHits);
899
900 const CbmTrackMatchNew* stsTrackMatch = static_cast<const CbmTrackMatchNew*>(fStsMatches->At(stsId));
901 Int_t stsMcTrackId = stsTrackMatch->GetMatchedLink().GetIndex();
902
903 Int_t nofTrueHits = 0, nofFakeHits = 0;
904 for (Int_t iHit = 0; iHit < nofHits; iHit++) {
905 Int_t hitId = track->GetMvdHitIndex(iHit);
906 const CbmMatch* hitMatch = static_cast<const CbmMatch*>(fMvdHitMatches->At(hitId));
907 if (NULL == hitMatch) continue;
908 Int_t pointId = hitMatch->GetMatchedLink().GetIndex();
909 Int_t eventId = hitMatch->GetMatchedLink().GetEntry();
910 const FairMCPoint* point = static_cast<const FairMCPoint*>(fMvdPoints->Get(0, eventId, pointId));
911 if (NULL == point) continue;
912 Int_t mcTrackId = point->GetTrackID();
913 if (mcTrackId == stsMcTrackId) { // true hit
914 nofTrueHits++;
915 }
916 else { // fake hit
917 nofFakeHits++;
918 }
919 }
920 fHM->H1("hth_Mvd_TrackHits_True")->Fill(nofTrueHits);
921 fHM->H1("hth_Mvd_TrackHits_Fake")->Fill(nofFakeHits);
922 if (nofHits != 0) {
923 fHM->H1("hth_Mvd_TrackHits_TrueOverAll")->Fill(Double_t(nofTrueHits) / Double_t(nofHits));
924 fHM->H1("hth_Mvd_TrackHits_FakeOverAll")->Fill(Double_t(nofFakeHits) / Double_t(nofHits));
925 }
926}
927
929{
930 string detName = (detId == ECbmModuleId::kSts) ? "Sts"
931 : (detId == ECbmModuleId::kTrd) ? "Trd"
932 : (detId == ECbmModuleId::kMuch) ? "Much"
933 : (detId == ECbmModuleId::kRich) ? "Rich"
934 : "";
935 assert(detName != "");
936 string histName = "hth_" + detName + "_TrackHits";
937 fHM->H1(histName + "_All")->Fill(trackMatch->GetNofHits());
938 fHM->H1(histName + "_True")->Fill(trackMatch->GetNofTrueHits());
939 fHM->H1(histName + "_Fake")->Fill(trackMatch->GetNofWrongHits());
940 fHM->H1(histName + "_TrueOverAll")->Fill(trackMatch->GetTrueOverAllHitsRatio());
941 fHM->H1(histName + "_FakeOverAll")->Fill(trackMatch->GetWrongOverAllHitsRatio());
942}
943
945{
946 vector<TH1*> effHistos = fHM->H1Vector("(hte|hpe)_.*_Eff_.*");
947 Int_t nofEffHistos = effHistos.size();
948
949 Int_t nofMcTracks = fMCTracks->Size(0, iEvent);
950 //Int_t nofExistsMcTracks = 0;
951 for (Int_t iMCTrack = 0; iMCTrack < nofMcTracks; ++iMCTrack) {
952 const CbmMCTrack* mcTrack = static_cast<const CbmMCTrack*>(fMCTracks->Get(0, iEvent, iMCTrack));
953
954 // Check accepted tracks cutting on minimal number of MC points
955 if (!fMCTrackCreator->TrackExists(iEvent, iMCTrack)) {
956 continue;
957 }
958
959 const CbmLitMCTrack& litMCTrack = fMCTrackCreator->GetTrack(iEvent, iMCTrack);
960 Int_t nofPointsSts = litMCTrack.GetNofPointsInDifferentStations(ECbmModuleId::kSts);
961 Int_t nofPointsTrd = litMCTrack.GetNofPointsInDifferentStations(ECbmModuleId::kTrd);
962 Int_t nofPointsMuch = litMCTrack.GetNofPointsInDifferentStations(ECbmModuleId::kMuch);
963 Int_t nofPointsTof = litMCTrack.GetNofPoints(ECbmModuleId::kTof);
964 Int_t nofHitsRich = litMCTrack.GetNofRichHits();
965 Double_t boa = litMCTrack.GetRingBaxis() / litMCTrack.GetRingAaxis();
966 if (litMCTrack.GetRingBaxis() == -1. || litMCTrack.GetRingAaxis() == -1) boa = -1.;
967 Double_t ringX = litMCTrack.GetRingCenterX();
968 Double_t ringY = litMCTrack.GetRingCenterY();
969
970
971 // Check local tracks
972 Bool_t stsConsecutive =
974 Bool_t isStsOk = nofPointsSts >= fMinNofPointsSts && fDet.GetDet(ECbmModuleId::kSts) && stsConsecutive;
975 Bool_t isTrdOk = nofPointsTrd >= fMinNofPointsTrd && fDet.GetDet(ECbmModuleId::kTrd);
976 Bool_t isMuchOk = nofPointsMuch >= fMinNofPointsMuch && fDet.GetDet(ECbmModuleId::kMuch);
977 Bool_t isTofOk = nofPointsTof >= fMinNofPointsTof && fDet.GetDet(ECbmModuleId::kTof);
978 Bool_t isRichOk = nofHitsRich >= fMinNofHitsRich && fDet.GetDet(ECbmModuleId::kRich);
979
980 // calculate polar angle
981 TVector3 mom;
982 mcTrack->GetMomentum(mom);
983 Double_t angle = std::abs(mom.Theta() * 180 / TMath::Pi());
984 Double_t mcP = mcTrack->GetP();
985 Double_t mcY = mcTrack->GetRapidity();
986 Double_t mcPt = mcTrack->GetPt();
987
988 // Fill parameter name to value map
989 map<string, vector<Double_t>> parMap;
990
991 vector<Double_t> tmp = list_of(mcP);
992 parMap["p"] = tmp;
993
994 vector<Double_t> tmp1 = list_of(mcY);
995 parMap["y"] = tmp1;
996
997 vector<Double_t> tmp2 = list_of(mcPt);
998 parMap["pt"] = tmp2;
999
1000 vector<Double_t> tmp3 = list_of(angle);
1001 parMap["Angle"] = tmp3;
1002
1003 vector<Double_t> tmp4 = list_of(0);
1004 parMap["Np"] = tmp4; // FIXME : correct to number of points in concrete detector!
1005 // Currently as a temporary solution it is reassigned later
1006
1007 vector<Double_t> tmp5 = list_of(boa);
1008 parMap["BoA"] = tmp5;
1009
1010 vector<Double_t> tmp5X = list_of(ringX);
1011 parMap["RingXc"] = tmp5X;
1012
1013 vector<Double_t> tmp5Y = list_of(std::abs(ringY));
1014 parMap["RingYc"] = tmp5Y;
1015
1016 vector<Double_t> tmp6 = list_of(ringX)(ringY);
1017 parMap["RingXcYc"] = tmp6;
1018
1019 vector<Double_t> tmp7 = list_of(nofHitsRich);
1020 parMap["RingNh"] = tmp7;
1021
1022 vector<Double_t> tmp8 = list_of(mcY)(mcPt);
1023 //parMap["RadPos"] = list_of(1);
1024 parMap["YPt"] = tmp8;
1025
1026 for (Int_t iHist = 0; iHist < nofEffHistos; iHist++) {
1027 TH1* hist = effHistos[iHist];
1028 string histName = hist->GetName();
1029 vector<string> split = Split(histName, '_');
1030 string effName = split[1];
1031 string normName = split[2];
1032 string catName = split[3];
1033 string histTypeName = split[0];
1034 string parName = split[5];
1035 assert(parMap.count(parName) != 0);
1036
1037 vector<Double_t> par = list_of(0);
1038 if (parName == "Np") {
1039 vector<Double_t> tmp9 = list_of((effName == "Sts") ? nofPointsSts
1040 : (effName == "Trd") ? nofPointsTrd
1041 : (effName == "Much") ? nofPointsMuch
1042 : (effName == "Tof") ? nofPointsTof
1043 : 0);
1044 par = tmp9;
1045 }
1046 else {
1047 par = parMap[parName];
1048 }
1049
1050 Bool_t sts = (normName.find("Sts") != string::npos) ? isStsOk : true;
1051 Bool_t trd = (normName.find("Trd") != string::npos) ? isTrdOk : true;
1052 Bool_t much = (normName.find("Much") != string::npos) ? isMuchOk : true;
1053 Bool_t tof = (normName.find("Tof") != string::npos) ? isTofOk : true;
1054 Bool_t rich = (normName.find("Rich") != string::npos) ? isRichOk : true;
1055
1056 if (effName == "Trd" || effName == "Much" || effName == "Tof") {
1057 string prevRecName = FindAndReplace(normName, effName, "");
1058 Bool_t isPrevRec =
1059 fMcToRecoMap[prevRecName].find(make_pair(iEvent, iMCTrack)) != fMcToRecoMap[prevRecName].end();
1060 Bool_t accOk = isPrevRec && sts && trd && much && tof && rich;
1061 if (accOk) {
1062 FillGlobalReconstructionHistos(iEvent, iMCTrack, fMcToRecoMap[normName], histName, histTypeName, effName,
1063 catName, par);
1064 }
1065 }
1066 else {
1067 Bool_t accOk = sts && trd && much && tof && rich;
1068 if (accOk) {
1069 if (histName.find("Rich") == string::npos) {
1070 FillGlobalReconstructionHistos(iEvent, iMCTrack, fMcToRecoMap[effName], histName, histTypeName, effName,
1071 catName, par);
1072 }
1073 else {
1074 FillGlobalReconstructionHistosRich(iEvent, iMCTrack, fMcToRecoMap[effName], histName, histTypeName, effName,
1075 catName, par);
1076 }
1077 }
1078 }
1079 } // Loop over efficiency histograms
1080 } // Loop over MCTracks
1081}
1082
1084 const multimap<pair<Int_t, Int_t>, Int_t>& mcMap,
1085 const string& histName, const string& histTypeName,
1086 const string& effName, const string& catName,
1087 const vector<Double_t>& par)
1088{
1089 string accHistName = FindAndReplace(histName, "_Eff_", "_Acc_");
1090 string recHistName = FindAndReplace(histName, "_Eff_", "_Rec_");
1091 LitTrackAcceptanceFunction function = fTrackAcceptanceFunctions.find(catName)->second;
1092 Bool_t accOk = function(fMCTracks, mcEventId, mcId);
1093 Bool_t recOk = (histTypeName == "hte") ? (mcMap.find(pair<Int_t, Int_t>(mcEventId, mcId)) != mcMap.end() && accOk)
1094 : (ElectronId(mcEventId, mcId, mcMap, effName) && accOk);
1095 Int_t nofParams = par.size();
1096 assert(nofParams < 3 && nofParams > 0);
1097 if (nofParams == 1) {
1098 if (accOk) {
1099 fHM->H1(accHistName)->Fill(par[0]);
1100 }
1101 if (recOk) {
1102 fHM->H1(recHistName)->Fill(par[0]);
1103 }
1104 }
1105 else if (nofParams == 2) {
1106 if (accOk) {
1107 fHM->H1(accHistName)->Fill(par[0], par[1]);
1108 }
1109 if (recOk) {
1110 fHM->H1(recHistName)->Fill(par[0], par[1]);
1111 }
1112 }
1113}
1114
1116 const multimap<pair<Int_t, Int_t>, Int_t>& mcMap,
1117 const string& histName, const string& histTypeName,
1118 const string& effName, const string& catName,
1119 const vector<Double_t>& par)
1120{
1121 Int_t nofHitsInRing = fMCTrackCreator->GetTrack(mcEventId, mcId).GetNofRichHits();
1122 string accHistName = FindAndReplace(histName, "_Eff_", "_Acc_");
1123 string recHistName = FindAndReplace(histName, "_Eff_", "_Rec_");
1124 LitRingAcceptanceFunction function = fRingAcceptanceFunctions.find(catName)->second;
1125 Bool_t accOk = function(fMCTracks, mcEventId, mcId, nofHitsInRing);
1126 Bool_t recOk = (histTypeName == "hte") ? (mcMap.find(make_pair(mcEventId, mcId)) != mcMap.end() && accOk)
1127 : (ElectronId(mcEventId, mcId, mcMap, effName) && accOk);
1128 Int_t nofParams = par.size();
1129 assert(nofParams < 3 && nofParams > 0);
1130 if (nofParams == 1) {
1131 if (accOk) {
1132 fHM->H1(accHistName)->Fill(par[0]);
1133 }
1134 if (recOk) {
1135 fHM->H1(recHistName)->Fill(par[0]);
1136 }
1137 }
1138 else if (nofParams == 2) {
1139 if (accOk) {
1140 fHM->H1(accHistName)->Fill(par[0], par[1]);
1141 }
1142 if (recOk) {
1143 fHM->H1(recHistName)->Fill(par[0], par[1]);
1144 }
1145 }
1146}
1147
1148Bool_t CbmLitTrackingQa::ElectronId(Int_t mcEventId, Int_t mcId, const multimap<pair<Int_t, Int_t>, Int_t>& mcMap,
1149 const string& effName)
1150{
1151 multimap<pair<Int_t, Int_t>, Int_t>::const_iterator it = mcMap.find(pair<Int_t, Int_t>(mcEventId, mcId));
1152 if (it == mcMap.end()) return false;
1153 Int_t globalTrackIndex = (*it).second;
1154 const CbmMCTrack* mcTrack = static_cast<const CbmMCTrack*>(fMCTracks->Get(0, mcEventId, mcId));
1155 TVector3 mom;
1156 mcTrack->GetMomentum(mom);
1157 Bool_t isRichElectron = (fDet.GetDet(ECbmModuleId::kRich) && (effName.find("Rich") != string::npos))
1158 ? CbmLitGlobalElectronId::GetInstance().IsRichElectron(globalTrackIndex, mom.Mag())
1159 : true;
1160 Bool_t isTrdElectron = (fDet.GetDet(ECbmModuleId::kTrd) && (effName.find("Trd") != string::npos))
1161 ? CbmLitGlobalElectronId::GetInstance().IsTrdElectron(globalTrackIndex, mom.Mag())
1162 : true;
1163 Bool_t isTofElectron = (fDet.GetDet(ECbmModuleId::kTof) && (effName.find("Tof") != string::npos))
1164 ? CbmLitGlobalElectronId::GetInstance().IsTofElectron(globalTrackIndex, mom.Mag())
1165 : true;
1166 return isRichElectron && isTrdElectron && isTofElectron;
1167}
1168
1170{
1171 if (!(fGlobalTracks && fStsMatches && fRichProjections && fMCTracks)) return;
1172 vector<TH1*> histos = fHM->H1Vector("hps_.*_RecPions_.*");
1173 Int_t nofHistos = histos.size();
1174
1175 Int_t nofGlobalTracks = fGlobalTracks->GetEntriesFast();
1176 for (Int_t iGT = 0; iGT < nofGlobalTracks; iGT++) {
1177 const CbmGlobalTrack* globalTrack = static_cast<const CbmGlobalTrack*>(fGlobalTracks->At(iGT));
1178 Int_t stsIndex = globalTrack->GetStsTrackIndex();
1179 if (stsIndex < 0) continue;
1180 const CbmTrackMatchNew* trackMatch = static_cast<const CbmTrackMatchNew*>(fStsMatches->At(stsIndex));
1181 const FairTrackParam* richProjection = static_cast<const FairTrackParam*>(fRichProjections->At(iGT));
1182 if (richProjection == NULL || richProjection->GetX() == 0 || richProjection->GetY() == 0) continue;
1183 Int_t trdIndex = globalTrack->GetTrdTrackIndex();
1184 if (fDet.GetDet(ECbmModuleId::kTrd) && trdIndex < 0) continue;
1185 Int_t tofIndex = globalTrack->GetTofHitIndex();
1186 if (fDet.GetDet(ECbmModuleId::kTof) && tofIndex < 0) continue;
1187
1188 if (trackMatch->GetNofLinks() <= 0) continue;
1189 Int_t mcIdSts = trackMatch->GetMatchedLink().GetIndex();
1190 Int_t mcIdStsEvent = trackMatch->GetMatchedLink().GetEntry();
1191 if (mcIdSts < 0) continue;
1192 const CbmMCTrack* mcTrack = static_cast<const CbmMCTrack*>(fMCTracks->Get(0, mcIdStsEvent, mcIdSts));
1193 TVector3 mom;
1194 mcTrack->GetMomentum(mom);
1195 Double_t p = mom.Mag();
1196 Int_t pdgSts = mcTrack->GetPdgCode();
1197 if (std::abs(pdgSts) == 211) {
1198 Bool_t isRichElectron =
1200 Bool_t isTrdElectron =
1202 Bool_t isTofElectron =
1204
1205 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
1206 histos[iHist]->Fill(p); // Fill RecPions histogramm
1207 string name = histos[iHist]->GetName();
1208 vector<string> split = Split(name, '_');
1209 string effName = split[1];
1210 string category = split[2];
1211 //cout << category << endl;
1212 Bool_t isElectron = ((effName.find("Rich") != string::npos) ? isRichElectron : true)
1213 && ((effName.find("Trd") != string::npos) ? isTrdElectron : true)
1214 && ((effName.find("Tof") != string::npos) ? isTofElectron : true);
1215 if (isElectron) {
1216
1217 LitPiSuppAcceptanceFunction function = fPiSuppAcceptanceFunctions.find(category)->second;
1218 Bool_t ok = function(fGlobalTracks, fStsMatches, fRichRingMatches, iGT);
1219
1220 if (ok) fHM->H1(FindAndReplace(name, "RecPions", "Rec"))->Fill(p);
1221 }
1222 }
1223 }
1224 }
1225}
1226
1228{
1229 if (fGlobalTracks != nullptr) fHM->H1("hno_NofObjects_GlobalTracks")->Fill(fGlobalTracks->GetEntriesFast());
1231 fHM->H1("hno_NofObjects_StsTracks")->Fill(fStsTracks->GetEntriesFast());
1232 }
1234 fHM->H1("hno_NofObjects_RichRings")->Fill(fRichRings->GetEntriesFast());
1235 Int_t projCount = 0;
1236 Int_t nProj = fRichProjections->GetEntriesFast();
1237 for (Int_t iProj = 0; iProj < nProj; iProj++) {
1238 FairTrackParam* proj = (FairTrackParam*) fRichProjections->At(iProj);
1239 if (NULL == proj || proj->GetX() == 0. || proj->GetY() == 0) continue;
1240 projCount++;
1241 }
1242 fHM->H1("hno_NofObjects_RichProjections")->Fill(projCount);
1243 }
1245 fHM->H1("hno_NofObjects_TrdTracks")->Fill(fTrdMatches->GetEntriesFast());
1246 }
1248 fHM->H1("hno_NofObjects_MuchTracks")->Fill(fMuchMatches->GetEntriesFast());
1249 }
1250}
1251
ECbmModuleId
Definition CbmDefs.h:39
@ kMvd
Micro-Vertex Detector.
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
@ kRich
Ring-Imaging Cherenkov Detector.
Histogram manager.
Global function to define the track acceptance. Used in QA.
Creates CbmLitMCTrack objects.
Create report for tracking QA.
Creates study report for tracking QA.
ClassImp(CbmLitTrackingQa)
FairTask for tracking performance calculation.
Data class for STS tracks.
int32_t GetStsTrackIndex() const
int32_t GetRichRingIndex() const
int32_t GetTofHitIndex() const
int32_t GetMuchTrackIndex() const
int32_t GetTrdTrackIndex() const
Histogram manager.
std::vector< TH1 * > H1Vector(const std::vector< std::string > &names) const
Return vector of pointers to TH1 histogram.
void WriteToFile()
Write all objects to current opened file.
void Add(const std::string &name, TNamed *object)
Add new named object to manager.
std::string ToString() const
Return string representation of class.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
static Bool_t KaonTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t KaonMinusTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t PionRingAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index, Int_t)
static Bool_t PionMinusTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t AllTrackAcceptanceFunction(CbmMCDataArray *, Int_t, Int_t)
static Bool_t PionTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t TrueMatchPiSuppAcceptanceFunction(const TClonesArray *globalTracks, const TClonesArray *stsMatches, const TClonesArray *richMatches, Int_t index)
static Bool_t PionPlusTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t SecondaryTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t AllPiSuppAcceptanceFunction(const TClonesArray *, const TClonesArray *, const TClonesArray *, Int_t)
static Bool_t KaonPlusTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t ProtonTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t PrimaryElectronRingAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index, Int_t)
static Bool_t PrimaryElectronTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t AllRingAcceptanceFunction(CbmMCDataArray *, Int_t, Int_t, Int_t)
static Bool_t PrimaryMuonTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t WrongMatchPiSuppAcceptanceFunction(const TClonesArray *globalTracks, const TClonesArray *stsMatches, const TClonesArray *richMatches, Int_t index)
static Bool_t PionReferenceRingAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index, Int_t nofHitsInRing)
static Bool_t ReferenceTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t AllReferenceRingAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index, Int_t nofHitsInRing)
static Bool_t PrimaryTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
static Bool_t PrimaryElectronReferenceRingAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index, Int_t nofHitsInRing)
void DetermineSetup()
Determines detector presence using TGeoManager.
bool GetElectronSetup() const
Return true if electron setup is detected.
bool GetDet(ECbmModuleId detId) const
Return detector presence in setup.
Bool_t IsTrdElectron(Int_t globalTrackindex, Double_t momentum)
Identify electron in RICH detector.
Bool_t IsTofElectron(Int_t globalTrackIndex, Double_t momentum, Double_t eventTime=1000.)
Identify electron in RICH detector.
Bool_t IsRichElectron(Int_t globalTrackIndex, Double_t momentum)
Identify electron in RICH detector.
void SetRichAnnCut(Double_t par)
Set cut on RICH ANN output value.
static CbmLitGlobalElectronId & GetInstance()
void SetTrdAnnCut(Double_t par)
Set cut on TRD ANN output value.
bool TrackExists(int mcEventId, int mcId) const
Check whether a track exists in the array.
void Create(Int_t eventNum)
Creates array of CbmLitMCTracks for current event.
static CbmLitMCTrackCreator * Instance()
Singleton instance.
const CbmLitMCTrack & GetTrack(int mcEventId, int mcId) const
Return CbmLitMCTrack by its index.
Monte-Carlo track.
Double_t GetRingCenterY() const
Return Y coordinate of the ellipse center.
Double_t GetRingAaxis() const
Return major semi-axis of the ellipse.
UInt_t GetNofPointsInDifferentStations(ECbmModuleId detId) const
Return number of MC points in different stations for specified detector id.
Double_t GetRingCenterX() const
Return X coordinate of the ellipse center.
Int_t GetNofConsecutivePoints(ECbmModuleId detId) const
Return number of consecutive MC points for specified detector id. Currently works only for STS.
UInt_t GetNofPoints(ECbmModuleId detId) const
Return number of MC points for specified detector id.
Int_t GetNofRichHits() const
Return number of RICH hits in ring.
Double_t GetRingBaxis() const
Return minor semi-axis of the ellipse.
Create report for tracking QA.
Bool_t(*) LitTrackAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index)
CbmMCDataArray * fMvdPoints
vector< string > PionSuppressionVariants()
vector< string > CreateGlobalTrackingHistogramNames()
CbmLitTrackingQa()
Constructor.
TClonesArray * fGlobalTracks
Bool_t ElectronId(Int_t mcEventId, Int_t mcId, const multimap< pair< Int_t, Int_t >, Int_t > &mcMap, const string &effName)
void CreateTrackHitsHistogram(const string &detName)
vector< string > fTrackCategories
void FillDefaultTrackCategories()
Fill array of track categories with default values.
Bool_t(*) LitRingAcceptanceFunction(CbmMCDataArray *mcTracks, Int_t eventNo, Int_t index, Int_t nofHitsInRing)
void CreateH1PionSuppression(const string &name, const string &parameter, const string &xTitle, Int_t nofBins, Double_t minBin, Double_t maxBin)
CbmMCDataArray * fTofPoints
map< string, multimap< pair< Int_t, Int_t >, Int_t > > fMcToRecoMap
TClonesArray * fMuchMatches
TClonesArray * fStsMatches
TClonesArray * fRichProjections
TClonesArray * fTofMatches
virtual void Finish()
Derived from FairTask.
void ProcessGlobalTracks()
Loop over the reconstructed global tracks. Check if track is correct and fill multimap <MC track inde...
void CreateH1Efficiency(const string &name, const string &parameter, const string &xTitle, Int_t nofBins, Double_t minBin, Double_t maxBin, const string &opt)
Bool_t(*) LitPiSuppAcceptanceFunction(const TClonesArray *globalTracks, const TClonesArray *stsMatches, const TClonesArray *richMatches, Int_t index)
virtual ~CbmLitTrackingQa()
Destructor.
void CreateH2Efficiency(const string &name, const string &parameter, const string &xTitle, const string &yTitle, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY, const string &opt)
void FillGlobalReconstructionHistos(Int_t mcEventId, Int_t mcId, const multimap< pair< Int_t, Int_t >, Int_t > &mcMap, const string &histName, const string &histTypeName, const string &effName, const string &catName, const vector< Double_t > &par)
Calculate efficiency histograms.
CbmLitDetectorSetup fDet
void ProcessMvd(Int_t stsId)
Check correctness attached MVD hits.
string LocalEfficiencyNormalization(const string &detName)
void FillTrackQualityHistograms(const CbmTrackMatchNew *trackMatch, ECbmModuleId detId)
TClonesArray * fRichRings
TClonesArray * fTrdMatches
void ProcessMcTracks(Int_t iEvent)
Loop over the MC tracks. Check track acceptance for different cases. Fill histograms of accepted and ...
virtual InitStatus Init()
Derived from FairTask.
map< string, LitRingAcceptanceFunction > fRingAcceptanceFunctions
CbmHistManager * fHM
map< string, LitPiSuppAcceptanceFunction > fPiSuppAcceptanceFunctions
vector< string > GlobalTrackVariants()
void CreateH2(const string &name, const string &xTitle, const string &yTitle, const string &zTitle, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
TClonesArray * fStsTracks
TClonesArray * fMvdHitMatches
void ReadDataBranches()
Read data branches from input data files.
void FillTrackAndRingAcceptanceFunctions()
Bool_t fUseConsecutivePointsInSts
void IncreaseCounters()
Increase number of objects counters.
void CreateH1(const string &name, const string &xTitle, const string &yTitle, Int_t nofBins, Double_t minBin, Double_t maxBin)
void FillGlobalReconstructionHistosRich(Int_t mcEventId, Int_t mcId, const multimap< pair< Int_t, Int_t >, Int_t > &mcMap, const string &histName, const string &histTypeName, const string &effName, const string &catName, const vector< Double_t > &par)
Fill histograms of accepted and reconstructed rings tracks.
map< string, LitTrackAcceptanceFunction > fTrackAcceptanceFunctions
vector< string > fTrackCategoriesPID
vector< string > fRingCategories
CbmLitMCTrackCreator * fMCTrackCreator
virtual void Exec(Option_t *opt)
Derived from FairTask.
TClonesArray * fRichRingMatches
CbmMCDataArray * fMCTracks
void ProcessRichRings()
Loop over the reconstructed RICH rings. Check if ring is correct and fill multimap <MC track index,...
vector< string > fPiSuppCategories
vector< string > fRingCategoriesPID
TObject * Get(const CbmLink *lnk)
Int_t Size(Int_t fileNumber, Int_t eventNumber)
Task class creating and managing CbmMCDataArray objects.
CbmMCDataObject * GetObject(const char *name)
CbmMCDataArray * InitBranch(const char *name)
double GetPt() const
Definition CbmMCTrack.h:97
double GetP() const
Definition CbmMCTrack.h:98
void GetMomentum(TVector3 &momentum) const
Definition CbmMCTrack.h:170
int32_t GetPdgCode() const
Definition CbmMCTrack.h:68
double GetRapidity() const
int32_t GetNofLinks() const
Definition CbmMatch.h:42
const CbmLink & GetMatchedLink() const
Definition CbmMatch.h:41
const std::vector< CbmLink > & GetLinks() const
Definition CbmMatch.h:40
float GetCenterX() const
Definition CbmRichRing.h:77
float GetCenterY() const
Definition CbmRichRing.h:78
static double GetRingTrackDistance(int globalTrackId)
Base class for simulation reports.
void Create(CbmHistManager *histManager, const std::string &outputDir)
Main function which creates report data.
Class representing the top level of the STS setup.
Definition CbmStsSetup.h:43
Bool_t Init(const char *geometryFile=nullptr)
Initialise the setup.
static CbmStsSetup * Instance()
Bool_t IsInit() const
Initialisation status for sensor parameters.
Data class with information on a STS local track.
int32_t GetNofMvdHits() const
Definition CbmStsTrack.h:87
int32_t GetMvdHitIndex(int32_t iHit) const
Definition CbmStsTrack.h:75
double GetTrueOverAllHitsRatio() const
int32_t GetNofWrongHits() const
double GetWrongOverAllHitsRatio() const
int32_t GetNofHits() const
int32_t GetNofTrueHits() const
string FindAndReplace(const string &name, const string &oldSubstr, const string &newSubstr)
Definition CbmUtils.cxx:59
vector< string > Split(const string &name, char delimiter)
Definition CbmUtils.cxx:67