CbmRoot
Loading...
Searching...
No Matches
StsDigiQa.cxx
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#include "StsDigiQa.h"
11
12#include "CbmStsAddress.h"
13
14#include <fmt/format.h>
15
17using fmt::format;
18
19// ---------------------------------------------------------------------------------------------------------------------
20//
22{
30
31 if (!fpSender.get()) {
32 return;
33 }
34
35 int nModules = fpReadoutSetup->modules.size();
36
37 auto GetAddressName = [&](int32_t address) -> std::string {
38 uint32_t u = CbmStsAddress::GetElementId(address, kStsUnit);
39 uint32_t l = CbmStsAddress::GetElementId(address, kStsLadder);
40 uint32_t m = CbmStsAddress::GetElementId(address, kStsModule);
41 return format("u{}_l{}_m{}", u, l, m);
42 };
43
44 auto GetAddressTitle = [&](int32_t address) -> std::string {
45 uint32_t u = CbmStsAddress::GetElementId(address, kStsUnit);
46 uint32_t l = CbmStsAddress::GetElementId(address, kStsLadder);
47 uint32_t m = CbmStsAddress::GetElementId(address, kStsModule);
48 return format("U{} L{} M{}", u, l, m);
49 };
50
51 // Histograms per address
52 {
53 fvphAddressChannel.resize(nModules);
54 fvphAddressCharge.resize(nModules);
55 fvphAddressChannelCharge.resize(nModules);
56 if (fbAux) {
57 fvphAddressChannelElink.resize(nModules);
58 fvppAddressChannelMissedEvt.resize(nModules);
59 fvppAddressTimeMissedEvt.resize(nModules);
60 }
61 for (int iM = 0; iM < nModules; ++iM) {
62 int32_t address = fpReadoutSetup->modules.at(iM).address;
63 fmAddressMap[address] = iM;
64 auto aName = GetAddressName(address);
65 auto aTitl = GetAddressTitle(address);
66 auto cName = format("sts_digi/sts_digi_vs_channel_charge_{}", aName);
67 auto cTitl = format("STS digis per channel and charge for module {}", aTitl);
68 auto canv = CanvasConfig(cName, cTitl, 3, fbAux ? 2 : 1);
69 {
70 auto pad = PadConfig();
71 auto name = format("sts_digi_{}_channel", aName);
72 auto titl = format("Number of digis per channel for module {};channel;N_{{digis}}", aTitl);
73 fvphAddressChannel[iM] = fQaData.MakeObj<H1D>(name, titl, 2048, -0.5, 2047.5);
74 if (fbAux) {
75 fvphAddressChannel[iM]->SetFlag(EHistFlag::StoreVsTsId);
76 }
77 pad.RegisterHistogram(fvphAddressChannel[iM], "hist");
78 canv.AddPadConfig(pad);
79 }
80 {
81 auto pad = PadConfig();
82 auto name = format("sts_digi_{}_charge", aName);
83 auto titl = format("STS digi charge for mudule {};charge [ADS units];N_{{digis}}", aTitl);
84 fvphAddressCharge[iM] = fQaData.MakeObj<H1D>(name, titl, 32, -0.5, 31.5);
85 pad.RegisterHistogram(fvphAddressCharge[iM], "hist");
86 canv.AddPadConfig(pad);
87 }
88 {
89 auto pad = PadConfig();
90 auto name = format("sts_digi_{}_channel_charge", aName);
91 auto titl = format("STS digi charge for module {};charge [ADS units];channel", aTitl);
92 fvphAddressChannelCharge[iM] = fQaData.MakeObj<H2D>(name, titl, 32, -0.5, 31.5, 2048, -0.5, 2047.5);
93 pad.RegisterHistogram(fvphAddressChannelCharge[iM], "colz");
94 canv.AddPadConfig(pad);
95 }
96 if (fbAux) {
97 {
98 auto pad = PadConfig();
99 auto name = format("sts_digi_{}_channel_elink", aName);
100 auto titl = format("STS digi charge for module {};E-link;channel", aTitl);
101 fvphAddressChannelElink[iM] = fQaData.MakeObj<H2D>(name, titl, 40, -0.5, 39.5, 2048, -0.5, 2047.5);
102 pad.RegisterHistogram(fvphAddressChannelElink[iM], "colz");
103 canv.AddPadConfig(pad);
104 }
105 {
106 auto pad = PadConfig();
107 auto name = format("sts_digi_{}_channel_missed_evt", aName);
108 auto titl =
109 format("STS digi missed event ratio for module {};channel; N_{{w/ missed events}} / N_{{tot.}}", aTitl);
110 fvppAddressChannelMissedEvt[iM] = fQaData.MakeObj<Prof1D>(name, titl, 2048, -0.5, 2047.5, 0., 1.);
111 pad.RegisterHistogram(fvppAddressChannelMissedEvt[iM], "");
112 canv.AddPadConfig(pad);
113 }
114 {
115 auto pad = PadConfig();
116 auto name = format("sts_digi_{}_time_missed_evt", aName);
117 auto titl =
118 format("STS digi missed event ratio for module {};time [ms]; N_{{w/ missed events}} / N_{{tot.}}", aTitl);
119 constexpr double timeMin = 0.; // [ms]
120 constexpr double timeMax = 150.; // [ms]
121 int timeBins = std::ceil(timeMax - timeMin);
122 fvppAddressTimeMissedEvt[iM] = fQaData.MakeObj<Prof1D>(name, titl, timeBins, timeMin, timeMax, 0., 1.);
123 fvppAddressTimeMissedEvt[iM]->SetFlag(EHistFlag::StoreVsTsId);
124 fvppAddressTimeMissedEvt[iM]->SetFlag(EHistFlag::OmitIntegrated);
125 pad.RegisterHistogram(fvppAddressTimeMissedEvt[iM], "");
126 canv.AddPadConfig(pad);
127 }
128 }
129
131 }
132 }
133
135}
136
137// ---------------------------------------------------------------------------------------------------------------------
138//
140{
141 if (!fpSender.get()) {
142 return;
143 }
144
145 // --- Loop over STS digis and fill histograms
146 for (const auto& digi : (*fpvDigis)) {
147 int32_t address = digi.GetAddress();
148 double channel = digi.GetChannel();
149 double charge = digi.GetCharge();
150
151 // Ensure, that the address is defined
152 auto itHistID = fmAddressMap.find(address);
153 if (itHistID == fmAddressMap.end()) {
154 L_(error) << format("sts::DigiQa: found address {:x}, which is not defined in the ReadoutSetup config", address);
155 continue;
156 }
157
158 int iM = itHistID->second;
159 fvphAddressChannel[iM]->Fill(channel);
160 fvphAddressCharge[iM]->Fill(charge);
161 fvphAddressChannelCharge[iM]->Fill(charge, channel);
162 }
163
164 // --- Loop over aux QA digis
165 if (fbAux) {
166 for (const auto& ms : fpAuxDigis->msAux) {
167 for (const auto& auxDigi : ms.fQaDigis) {
168 int32_t address = auxDigi.address;
169 auto itHistID = fmAddressMap.find(address);
170 if (itHistID == fmAddressMap.end()) {
171 L_(error) << format("sts::DigiQa: found address {:x}, which is not defined in the ReadoutSetup config",
172 address);
173 continue;
174 }
175 int iM = itHistID->second;
176 fvphAddressChannelElink[iM]->Fill(static_cast<double>(auxDigi.elink), static_cast<double>(auxDigi.channel));
177 fvppAddressChannelMissedEvt[iM]->Fill(static_cast<double>(auxDigi.channel),
178 static_cast<double>(auxDigi.missedEvent));
179 fvppAddressTimeMissedEvt[iM]->Fill(auxDigi.time * 1.e-6, static_cast<double>(auxDigi.missedEvent));
180 }
181 }
182 }
183
185}
#define L_(level)
@ kStsModule
@ kStsLadder
@ kStsUnit
QA module for STS raw digis (source)
A canvas configuration for the histogram server.
Class to handle QA-objects in the online reconstruction.
Definition QaData.h:28
void AddCanvasConfig(const CanvasConfig &canvas)
Adds a canvas to the canvas config list.
Definition QaData.h:51
void Send(std::shared_ptr< HistogramSender > histoSender)
Sends QA data to the HistogramSender.
Definition QaData.cxx:72
void Init(std::shared_ptr< HistogramSender > histoSender)
Sends QA initialization information to the HistogramSender.
Definition QaData.cxx:18
Obj * MakeObj(Args... args)
Creates a QA-object and returns the pointer to it.
Definition QaData.h:85
1D-histogram
2D-histogram
A pad configuration for the histogram server.
Definition PadConfig.h:26
QA module for STS raw digis.
std::vector< qa::H1D * > fvphAddressChannel
hist: digi channel in different sensors
Definition StsDigiQa.h:56
std::vector< qa::Prof1D * > fvppAddressChannelMissedEvt
prof: missed event ratio vs. channel (AUX)
Definition StsDigiQa.h:61
std::vector< qa::Prof1D * > fvppAddressTimeMissedEvt
prof: missed event ratio vs. time (AUX)
Definition StsDigiQa.h:62
std::vector< qa::H2D * > fvphAddressChannelCharge
hist: digi channel vs. charge in different sensors
Definition StsDigiQa.h:58
void Init()
Initializes QA (initialization of histograms and canvases)
Definition StsDigiQa.cxx:21
void Exec()
Executes QA (filling histograms)
std::unordered_map< int32_t, int > fmAddressMap
Map of address to histogram index.
Definition StsDigiQa.h:53
std::vector< qa::H2D * > fvphAddressChannelElink
hist: digi channel (vs. eling (AUX)
Definition StsDigiQa.h:59
std::vector< qa::H1D * > fvphAddressCharge
hist: digi charge in different sensors
Definition StsDigiQa.h:57
std::shared_ptr< ReadoutSetup > fpReadoutSetup
Readout config instance.
Definition QaBase.h:79
std::shared_ptr< HistogramSender > fpSender
Histogram sender.
Definition QaBase.h:78
const AuxData * fpAuxDigis
Aux information on digis.
Definition QaBase.h:81
qa::Data fQaData
QA data.
Definition QaBase.h:77
const PODVector< Digi > * fpvDigis
Digis input.
Definition QaBase.h:80
bool fbAux
Extra distributions (if the auxiliary data should be used)
Definition QaBase.h:82
uint32_t GetElementId(int32_t address, int32_t level)
Get the index of an element.
EHistFlag
Histogram control flags (bit masks)
Definition Histogram.h:56