CbmRoot
Loading...
Searching...
No Matches
CbmRichDigiQa.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023-2023 UGiessen, Giessen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Martin Beyer [committer] */
4
5#include "CbmRichDigiQa.h"
6
7#include "CbmDigiManager.h"
8#include "CbmHistManager.h"
10#include "CbmRichDigi.h"
12
13#include <FairRootManager.h>
14#include <Logger.h>
15
16#include <TDirectory.h>
17#include <TFile.h>
18
20{
22
24 fDigiMan->Init();
25 if (!fDigiMan->IsPresent(ECbmModuleId::kRich)) LOG(fatal) << "CbmRichDigiQa::Init: No RichDigi array!";
26
28
29 return kSUCCESS;
30}
31
33{
34 fHM = new CbmHistManager();
35
36 fHM->Create1<TH1D>("fhDigiDt", "same address consecutive digis time diff;dt [ns];entries", 1001, -0.5, 10000.5);
37
38 fHM->Create1<TH1D>("fhDigiDtEdge", "same address consecutive digis time diff;dt [ns];entries", 101, -0.5, 100.5);
39
40 fHM->Create1<TH1D>("fhDigiDistH", "horizontal distance of digis same pmt;DIndX [in pixels];entries", 11, -0.5, 10.5);
41
42 fHM->Create1<TH1D>("fhDigiDistV", "vertical distance of digis same pmt;DIndY [in pixels];entries", 11, -0.5, 10.5);
43
44 fHM->Create2<TH2D>("fhDigiNeighbours", "digi neighbours same pmt;DIndX [in pixels];DIndY [in pixels];entries", 5,
45 -2.5, 2.5, 5, -2.5, 2.5);
46}
47
48void CbmRichDigiQa::Exec(Option_t* /*option*/)
49{
50 LOG(debug) << GetName() << " Event " << fEventNum;
51 fEventNum++;
52
53 Int_t nofDigis = fDigiMan->GetNofDigis(ECbmModuleId::kRich);
54 for (Int_t i = 0; i < nofDigis; i++) {
55 const CbmRichDigi* digi = fDigiMan->Get<CbmRichDigi>(i);
56 if (!digi) continue;
58 if (fToTLimitLow > 0. && fToTLimitHigh > 0.) {
59 if (digi->GetToT() < fToTLimitHigh && digi->GetToT() > fToTLimitLow) {
60 fFiredTimes[digi->GetAddress()].push_back(digi->GetTime());
61 fPmtDigisTimeAddress[pmtId].push_back(std::make_pair(digi->GetTime(), digi->GetAddress()));
62 }
63 }
64 else {
65 fFiredTimes[digi->GetAddress()].push_back(digi->GetTime());
66 fPmtDigisTimeAddress[pmtId].push_back(std::make_pair(digi->GetTime(), digi->GetAddress()));
67 }
68 }
69
70 // Fill deadtimes
71 for (auto& [address, times] : fFiredTimes) {
72 std::sort(times.begin(), times.end());
73 for (auto it = times.begin(); it != times.end(); ++it) {
74 if (*it < 0.)
75 LOG(warn) << "Digi time < 0.: "
76 << "address: " << address << " time: " << *it << " ns";
77
78 if (it != times.begin()) {
79 Double_t dt = *it - *std::prev(it);
80 fHM->H1("fhDigiDt")->Fill(dt);
81 if (dt < 100.5) {
82 fHM->H1("fhDigiDtEdge")->Fill(dt);
83 }
84 }
85 }
86 }
87
88 // Fill neighbour digis
89 for (auto& [pmt, digis] : fPmtDigisTimeAddress) {
90 std::sort(digis.begin(), digis.end());
91 for (auto it0 = digis.begin(); it0 != digis.end(); ++it0) {
94 for (auto it1 = it0 + 1; it1 != digis.end(); ++it1) {
95 if (abs(it0->first - it1->first) < fNeighbourTimeLimit) {
98 if (indX0 == indX1 && indY0 == indY1) continue;
99 if (indY0 == indY1) fHM->H1("fhDigiDistH")->Fill(indX1 - indX0);
100 if (indX0 == indX1) fHM->H1("fhDigiDistV")->Fill(indY1 - indY0);
101 if (abs(indX0 - indX1) > 1 || abs(indY0 - indY1) > 1) continue;
102 fHM->H2("fhDigiNeighbours")->Fill(indX1 - indX0, indY0 - indY1);
103 }
104 else if (it1->first - it0->first > fNeighbourTimeLimit) {
105 break;
106 }
107 }
108 }
109 }
110
111 fFiredTimes.clear();
112 fPmtDigisTimeAddress.clear();
113}
114
116{
117 TDirectory* oldir = gDirectory;
118 TFile* outFile = FairRootManager::Instance()->GetOutFile();
119 if (outFile != nullptr) {
120 outFile->mkdir(GetName());
121 outFile->cd(GetName());
122 fHM->WriteToFile();
123 }
124 gDirectory->cd(oldir->GetPath());
125}
@ kRich
Ring-Imaging Cherenkov Detector.
Histogram manager.
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
Histogram manager.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
void Create2(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
Helper function for creation of 2-dimensional histograms and profiles. Template argument is a real ob...
void WriteToFile()
Write all objects to current opened file.
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
static CbmRichDigiMapManager & GetInstance()
Return Instance of CbmRichGeoManager.
CbmRichPixelData * GetPixelDataByAddress(Int_t address)
Return CbmRichDataPixel by digi address.
Double_t fToTLimitLow
Double_t fToTLimitHigh
std::map< Int_t, std::vector< std::pair< Double_t, Int_t > > > fPmtDigisTimeAddress
CbmDigiManager * fDigiMan
void Exec(Option_t *option)
std::map< Int_t, std::vector< Double_t > > fFiredTimes
Double_t fNeighbourTimeLimit
CbmHistManager * fHM
InitStatus Init()
int32_t GetAddress() const
Definition CbmRichDigi.h:43
double GetToT() const
Definition CbmRichDigi.h:78
double GetTime() const
Definition CbmRichDigi.h:72