CbmRoot
Loading...
Searching...
No Matches
BmonHitfindQa.cxx
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
11
12#include "CbmBmonDigi.h"
13#include "CbmTofAddress.h"
14#include "bmon/Hit.h"
15#include "qa/Histogram.h"
16
17#include <fmt/format.h>
18
20
21// ---------------------------------------------------------------------------------------------------------------------
22//
24try {
25 using fmt::format;
26 if (!IsActive()) {
27 return;
28 }
29
30 size_t nDiamonds = fParameters.diamonds.size();
31 if (nDiamonds < 1) {
32 throw std::runtime_error("parameters were not initialized. Please, provide the configuration using the function "
33 "HitfindQa::InitParameters(calSetup, hitSetup)");
34 }
35
36 fvphDigiOccupVsChan.resize(nDiamonds, nullptr);
37 fvphDigiChargeVsChan.resize(nDiamonds, nullptr);
38 fvphHitNofChan.resize(nDiamonds, nullptr);
39 fvphHitTimeDiff.resize(nDiamonds, nullptr);
40
41 for (size_t iD = 0; iD < nDiamonds; ++iD) {
42 const auto& diamondPar = fParameters.diamonds[iD];
43 int nCh = diamondPar.nChannels;
44 auto sDN = format("_diamond_{:#08x}", diamondPar.address); // diamond suffix
45
46 // Histograms initialisation
47 /* clang-format off */
49 format("bmon_digi_occup_channel{}", sDN),
50 format("BMON-{} digi occupancy vs. channel;channel;counts", iD),
51 nCh, -0.5, nCh - 0.5);
53 format("bmon_digi_charge_channel{}", sDN),
54 format("BMON-{} digi charge vs. channel;channel;charge;counts", iD),
55 nCh, -0.5, nCh - 0.5, kChrgB, kChrgL, kChrgU);
57 format("bmon_hit_nChannels{}", sDN),
58 format("BMON-{} hit number of channels;N_{{chan}};counts", iD),
59 2, 0.5, 2.5);
61 format("bmon_hit_time_diff{}", sDN),
62 format("BMON-{} digi time difference in a hit formed from two digis;#Delta t_{{digi}} [ns];counts", iD),
64 /* clang-format on */
65
66 // Canvas initialization
67 auto cName = format("{}/bmon{}", GetTaskName(), sDN);
68 auto cTitl = format("BMON-{}", iD);
69 auto canv = qa::CanvasConfig(cName, cTitl, 2, 2);
70 canv.AddPadConfig(qa::PadConfig(fvphDigiOccupVsChan[iD], "hist")); // (0,0)
71 canv.AddPadConfig(qa::PadConfig(fvphDigiChargeVsChan[iD], "colz")); // (1,0)
72 canv.AddPadConfig(qa::PadConfig(fvphHitNofChan[iD], "hist")); // (0,1)
73 canv.AddPadConfig(qa::PadConfig(fvphHitTimeDiff[iD], "hist")); // (1,1)
74 AddCanvasConfig(canv);
75 }
76}
77catch (const std::exception& err) {
78 L_(fatal) << "bmon::HitfindQa: initialization failed. Reason: " << err.what();
79 throw std::runtime_error("bmon::HitfindQa initialization failure");
80}
81
82// ---------------------------------------------------------------------------------------------------------------------
83//
85{
86 if (!IsActive()) {
87 return;
88 }
89
90 // Fill digi distributions
91 for (const auto& digi : *fpDigis) {
92 size_t iDiamond = fParameters.GetDiamondIndex(digi.GetAddress());
93 int32_t chan = digi.GetChannel();
94 fvphDigiOccupVsChan[iDiamond]->Fill(chan);
95 fvphDigiChargeVsChan[iDiamond]->Fill(chan, digi.GetCharge());
96 }
97
98 // Fill hit distributions
99 const auto& hits = fpHits->Data();
100 for (size_t iH = 0; iH < hits.size(); ++iH) {
101 const auto& hit = hits[iH];
102 size_t iDiamond = fParameters.GetDiamondIndex(hit.GetAddress());
103 int nChannels = hit.GetNofChannels();
104 fvphHitNofChan[iDiamond]->Fill(nChannels);
105 if (nChannels == 2) {
106 int32_t iDigi = (*fpDigiIndices)[iH];
107 const auto& digiF = (*fpDigis)[iDigi];
108 const auto& digiS = (*fpDigis)[iDigi + 1];
109 fvphHitTimeDiff[iDiamond]->Fill(digiS.GetTime() - digiF.GetTime());
110 }
111 }
112}
#define L_(level)
A BMON hitfinder QA.
static vector< vector< QAHit > > hits
ROOT-free implementation of a histogram.
A QA module for the BMON hit-finder.
std::vector< qa::H1D * > fvphHitNofChan
Hit number of channels [diamond].
const std::vector< CbmBmonDigi > * fpDigis
Pointer to BMON digi sample.
static constexpr double kDtimeU
digi time difference: upper bound [ns]
std::vector< qa::H1D * > fvphHitTimeDiff
Time difference of two digis in a hit [diamond].
std::vector< qa::H1D * > fvphDigiOccupVsChan
Digi occupancy vs. channel [diamond].
void Exec()
Executes the task, fills the histograms.
static constexpr double kChrgU
charge scale: upper bound
static constexpr int kChrgB
charge scale: number of bins
const PartitionedVector< bmon::Hit > * fpHits
Pointer to BMON hit sample.
std::vector< qa::H2D * > fvphDigiChargeVsChan
Digi charge vs channel [diamond].
static constexpr double kChrgL
charge scale: lower bound
static constexpr double kDtimeL
digi time difference: lower bound [ns]
static constexpr int kDtimeB
digi time difference: number of bins
HitfindQaParameters fParameters
Parameters of the hit finder QA.
void Init()
Initialized the task.
A canvas configuration for the histogram server.
A pad configuration for the histogram server.
Definition PadConfig.h:26
const std::string & GetTaskName()
Gets name of the task.
void AddCanvasConfig(const CanvasConfig &canvas)
Adds a canvas configuration.
bool IsActive() const
Checks, if the task is active.
Obj * MakeObj(Args... args)
Creates a QA-object and returns the pointer to it.
size_t GetDiamondIndex(uint32_t address) const
Returns an index of the diamond by the address.