80 auto createH1 = [
this](
const std::string& name,
const std::string& title,
int nbins,
double xmin,
double xmax,
81 const std::string& xTitle =
"",
const std::string& yTitle =
"") -> TH1F* {
82 TString fullName = fTitle +
"_" + name;
83 auto* hist =
new TH1F(fullName, title.c_str(), nbins, xmin, xmax);
84 setupAxis(hist, xTitle, yTitle);
85 m_allHistograms.push_back(hist);
89 auto createH2 = [
this](
const std::string& name,
const std::string& title,
int nbinsx,
double xmin,
double xmax,
90 int nbinsy,
double ymin,
double ymax,
const std::string& xTitle =
"",
91 const std::string& yTitle =
"") -> TH2F* {
92 TString fullName = fTitle +
"_" + name;
93 auto* hist =
new TH2F(fullName, title.c_str(), nbinsx, xmin, xmax, nbinsy, ymin, ymax);
94 setupAxis(hist, xTitle, yTitle);
95 hist->GetZaxis()->SetNoExponent(kFALSE);
96 hist->SetOption(
"colz");
98 m_allHistograms.push_back(hist);
102 auto addCanvas = [
this](
const std::string& name,
int w,
int h,
int rows = 1,
int cols = 1) ->
CanvasInfo* {
103 TString fullName = fTitle + name;
104 auto* canvas =
new TCanvas(fullName, fullName, w, h);
105 if (rows > 1 || cols > 1)
106 canvas->Divide(rows, cols);
108 auto info = std::make_unique<CanvasInfo>(canvas);
110 m_canvases.push_back(std::move(info));
114 auto addPad = [](
CanvasInfo* cinfo, TH1* hist,
const std::string& opt,
const std::string& name =
"") {
120 pad->name = hist->GetName();
122 cinfo->
pads.push_back(pad);
127 createH1(
"h1_ECells",
"Hgnd signal in cells", kROWS * kCOLS, 0, kROWS * kCOLS,
"Cell id",
"Average Signal");
129 createH1(
"h1_ProfileSlice",
"Energy in detector slice", kLAYRS, 1, kLAYRS + 1,
"Layer id",
"Events");
133 createH2(
"h2_grid",
"Hgnd_Grid", kROWS + 2, 0, kROWS + 2, kCOLS + 2, 0, kCOLS + 2,
"X position",
"Y position");
134 h2_Layer_Cell = createH2(
"h2_Layer_Cell",
"h2_Layer_Cell", kLAYRS + 2, 0, kLAYRS + 2, kROWS * kCOLS + 2, 0,
135 kROWS * kCOLS + 2,
"Layer number",
"Cell number");
137 for (uint32_t layer = 1; layer <= kLAYRS; ++layer) {
138 TString ampName = fTitle + TString::Format(
"_hLayer%d_Amp", layer);
140 new TH2F(ampName, TString::Format(
"Layer %d Amplitudes", layer), kROWS, 0, kROWS, kCOLS, 0, kCOLS);
141 setupAxis(hLayerAmps[layer],
"Column",
"Row");
142 m_allHistograms.push_back(hLayerAmps[layer]);
146 for (uint32_t address : fAddresses) {
154 TString profName = fTitle + TString::Format(
"_hProfCell_%08X", address);
156 new TH1F(profName, TString::Format(
"D%d R%d C%d Profile", arm, row, col), kLAYRS, 1, kLAYRS + 1);
157 setupAxis(hProfCell[address],
"Layer id",
"Average Signal");
158 m_allHistograms.push_back(hProfCell[address]);
162 TString ampTimeName = fTitle + TString::Format(
"_hCellAmpTime_%08X", address);
163 hCellAmpTime[address] =
new TH2F(ampTimeName, TString::Format(
"D%d L%d R%d C%d Amplitude", arm, lay, row, col),
164 100, 0, 100, 100, -300, 300);
165 setupAxis(hCellAmpTime[address],
"Signal",
"");
166 m_allHistograms.push_back(hCellAmpTime[address]);
171 addPad(canAmpsInfo, h2_grid,
"colz",
"h2_grid");
172 addPad(canAmpsInfo, h1_ECells,
"hist",
"h1_ECells");
175 addPad(canvSliceInfo, h2_Layer_Cell,
"colz",
"h2_Layer_Cell");
176 addPad(canvSliceInfo, h1_ProfileSlice,
"hist",
"h1_ProfileSlice");
180 for (uint32_t address : fAddresses) {
185 addPad(canvProfInfo, hProfCell[address],
"hist", TString::Format(
"R%dC%d", row, col).Data());
191 for (uint32_t address : fAddresses) {
195 addPad(canvCellAmpInfo, hCellAmpTime[address],
"hist", TString::Format(
"L%d_R%dC%d", lay, row, col).Data());
256 TClonesArray* digits = fDigiArrays->
hgnd;
262 double scale = 1.0 / fEventCounter;
263 h1_ECells->Scale(scale);
264 h1_ProfileSlice->Scale(scale);
265 h2_grid->Scale(scale);
266 h2_Layer_Cell->Scale(scale);
269 for (
auto& [address, hist] : hProfCell) {
274 for (Int_t iDig = 0; iDig < digits->GetEntriesFast(); iDig++) {
275 auto* digi =
static_cast<BmnHgndDigi*
>(digits->At(iDig));
278 double signal = digi->GetSignal();
279 double time = digi->GetTime();
280 auto arm = digi->GetArmId();
281 auto row = digi->GetRowId();
282 auto col = digi->GetColumnId();
283 auto cell = (row - 1) * kCOLS + col;
284 auto lay = digi->GetLayerId();
287 if (fAddresses.find(address) == fAddresses.end()) {
288 LOG(debug) <<
"Unknown Hgnd address: " << address;
293 h1_ECells->Fill(cell, signal);
294 h1_ProfileSlice->Fill(lay, signal);
295 h2_grid->Fill(col, row, signal);
296 h2_Layer_Cell->Fill(lay, cell, signal);
299 if (hCellAmpTime.find(address) != hCellAmpTime.end()) {
300 hCellAmpTime[address]->Fill(signal, time);
305 if (hLayerAmps.find(lay) != hLayerAmps.end()) {
306 hLayerAmps[lay]->Fill(row, col, signal);