CbmRoot
Loading...
Searching...
No Matches
CbmTofUnpackMonitorPulser.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: Pierre-Alain Loizeau [committer] */
4
6
8#include "CriGet4Mess001.h"
9#include "MicrosliceDescriptor.hpp"
10
11#include <FairRunOnline.h>
12#include <Logger.h>
13
14#include <RtypesCore.h>
15#include <TCanvas.h>
16#include <TF1.h>
17#include <TFile.h>
18#include <TH1.h>
19#include <TH2.h>
20#include <THttpServer.h>
21#include <TMath.h>
22#include <TPaveStats.h>
23#include <TProfile.h>
24#include <TROOT.h>
25
35
37
40{
41 // Get Infos from the parset
42 fUnpackPar = digiParSet;
43
44 fuNbOfComps = fUnpackPar->GetNrOfGdpbs();
46 // FIXME: Start using again the parameter class accessors once a new CRI oriented class is brought into use
52
56
58 TFile* oldFile = gFile;
59 TDirectory* oldDir = gDirectory;
60 gROOT->cd();
61
65
67 gFile = oldFile;
68 gDirectory = oldDir;
69
71 std::vector<std::pair<TNamed*, std::string>> vHistos = GetHistoVector();
72
74 std::vector<std::pair<TCanvas*, std::string>> vCanvases = GetCanvasVector();
75
77 std::string sSystem = "tof";
79 //
80 sSystem = "bmon";
81 }
82
83 if (fbInternalHttp) {
84 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
85 if (nullptr != server) {
86 for (UInt_t uCanvas = 0; uCanvas < vCanvases.size(); ++uCanvas) {
87 server->Register(Form("/%s/%s", sSystem.data(), vCanvases[uCanvas].second.data()), vCanvases[uCanvas].first);
88 }
89 for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
90 server->Register(Form("/%s/%s", sSystem.data(), vHistos[uHisto].second.data()), vHistos[uHisto].first);
91 }
92 /*
93 server->RegisterCommand(Form("/Reset_%s_Hist", sSystem.data()), "bMcbm2018UnpackerTaskStsResetHistos=kTRUE");
94 server->Restrict("/Reset_UnpSts_Hist", "allow=admin");
95 */
96 }
97 }
98
99 return kTRUE;
100}
101
103{
105 std::string sSystem = "tof";
106
107 // Full Fee time difference test
108 UInt_t uNbBinsDt = kuNbBinsDt + 1; // To account for extra bin due to shift by 1/2 bin of both ranges
109
113
114 /*******************************************************************/
116 // clang-format off
117 fhGet4MessType = new TH2I(Form("%sGet4MessType", sSystem.data()),
118 "Nb of message for each type per GET4; GET4 chip # ; Type",
120 4, 0., 4.);
121 fhGet4MessType->GetYaxis()->SetBinLabel(1, "DATA 32b");
122 fhGet4MessType->GetYaxis()->SetBinLabel(2, "EPOCH");
123 fhGet4MessType->GetYaxis()->SetBinLabel(3, "S.C.M");
124 fhGet4MessType->GetYaxis()->SetBinLabel(4, "ERROR");
125
128 for (UInt_t uFeeA = 0; uFeeA < fuNbOfFeePerComp * fuNbOfComps; uFeeA++) {
130 for (UInt_t uFeeB = 0; uFeeB < fuNbOfFeePerComp * fuNbOfComps; uFeeB++) {
131 if (uFeeA < uFeeB) {
132 UInt_t uCompA = uFeeA / (fuNbOfFeePerComp);
133 UInt_t uFeeIdA = uFeeA - (fuNbOfFeePerComp * uCompA);
134 UInt_t uCompB = uFeeB / (fuNbOfFeePerComp);
135 UInt_t uFeeIdB = uFeeB - (fuNbOfFeePerComp * uCompB);
136 fvhTimeDiffPulser[uFeeA][uFeeB] =
137 new TH1I(Form("hTimeDiffPulser_g%02u_f%1u_g%02u_f%1u", uCompA, uFeeIdA, uCompB, uFeeIdB),
138 Form("Time difference for pulser on gDPB %02u FEE %1u and gDPB %02u FEE %1u; DeltaT [ps]; Counts",
139 uCompA, uFeeIdA, uCompB, uFeeIdB),
140 uNbBinsDt, dMinDt, dMaxDt);
141 } // if( uFeeA < uFeeB )
142 else
143 fvhTimeDiffPulser[uFeeA][uFeeB] = nullptr;
144 } // for( UInt_t uFeeB = uFeeA; uFeeB < fuNbOfFeePerComp * fuNbOfComps - 1; uFeeB++)
145 } // for( UInt_t uFeeA = 0; uFeeA < kuNbChanTest - 1; uFeeA++)
146
147 fhTimeMeanPulser = new TH2D("hTimeMeanPulser",
148 "Time difference Mean for each FEE pairs; FEE A; FEE B ; Mean [ps]",
151
152 fhTimeRmsPulser = new TH2D("hTimeRmsPulser",
153 "Time difference RMS for each FEE pairs; FEE A; FEE B ; RMS [ps]",
156
157 fhTimeRmsZoomFitPuls = new TH2D("hTimeRmsZoomFitPuls",
158 "Time difference RMS after zoom for each FEE pairs; FEE A; FEE B ; RMS [ps]",
161
162 fhTimeResFitPuls = new TH2D("hTimeResFitPuls",
163 "Time difference Res from fit for each FEE pairs; FEE A; FEE B ; Sigma [ps]",
166
167 /*
168 FIXME: only one GBTx per comp in CRI design!
169 fvhPulserTimeDiffEvoGbtxGbtx.resize(fuNbOfComps * (kuNbGbtxPerComp - 1));
170 */
172 for (UInt_t uComp = 0; uComp < fuNbOfComps; ++uComp) {
173 fvhPulserCountEvoPerFeeComp.push_back(new TH2D(Form("hPulserCountEvoPerFeeComp%02u", uComp),
174 Form("Pulser count per FEE in gDPB %02u; time in run [s]; dt [ps]",
175 uComp),
178
179 /*
180 FIXME: only one GBTx per comp in CRI design!
181 for (UInt_t uGbtx = 0; uGbtx < kuNbGbtxPerComp - 1; ++uGbtx) {
182 fvhPulserTimeDiffEvoGbtxGbtx[uComp * (kuNbGbtxPerComp - 1) + uGbtx] =
183 new TProfile(Form("hPulserTimeDiffEvoComp%02uGbtx00Gbtx%02u", uComp, uGbtx + 1),
184 Form("Time difference of the 1st FEE in the 1st GBTx of gDPB %02u vs GBTx %02u; time in run [s];"
185 " dt [ps]", uComp, uGbtx + 1),
186 fuHistoryHistoSize, 0, fuHistoryHistoSize);
187 } // for( UInt_t uGbtx = 0; uGbtx < kuNbGbtxPerComp; ++uGbtx )
188 */
189
190 fvvhPulserTimeDiffEvoCompComp[uComp].resize(fuNbOfComps, nullptr);
191 for (UInt_t uCompB = uComp + 1; uCompB < fuNbOfComps; ++uCompB) {
192 fvvhPulserTimeDiffEvoCompComp[uComp][uCompB] =
193 new TProfile(Form("hPulserTimeDiffEvoComp%02uComp%02u", uComp, uCompB),
194 Form("Time difference of the 1st FEE in the 1st GBTx of gDPB %02u vs %02u; time in run [s];"
195 " dt [ps]", uComp, uCompB),
197 } // for( UInt_t uCompB = uComp + 1; uCompB < fuNbOfComps; ++uCompB )
198 } // for( UInt_t uComp = 0; uComp < fuNbOfComps; ++uComp )
199
201 for (UInt_t uFeeRef = 0; uFeeRef < kuNbRefFeeEvo; ++uFeeRef) {
202 UInt_t uCompRef = kuRefFeeEvoIdx[uFeeRef] / (fuNbOfFeePerComp);
203 UInt_t uFeeIdRef = kuRefFeeEvoIdx[uFeeRef] - (fuNbOfFeePerComp * uCompRef);
204
206 for (UInt_t uFee = 0; uFee < fuNbOfFeePerComp * fuNbOfComps; uFee++) {
207 UInt_t uComp = uFee / (fuNbOfFeePerComp);
208 UInt_t uFeeId = uFee - (fuNbOfFeePerComp * uComp);
209
210 fvvhPulserTimeDiffEvoFeeFee[uFeeRef][uFee] =
211 new TProfile(Form("hTimeDiffEvoFeeFee_g%02u_f%02u_g%02u_f%02u", uCompRef, uFeeIdRef, uComp, uFeeId),
212 Form("Time difference for pulser on gDPB %02u FEE %1u and gDPB %02u FEE %02u; time in run [s]"
213 "; DeltaT [ps]", uCompRef, uFeeIdRef, uComp, uFeeId),
215 } // for( UInt_t uFee = 0; uFee < fuNbOfFeePerComp * fuNbOfComps; uFee++)
216 } // for( UInt_t uFeeRef = 0; uFeeRef < kuNbRefFeeEvo; ++uFeeRef )
217
221 for( UInt_t uFee = 0; uFee < fuNbOfFeePerComp * fuNbOfComps; uFee++)
222 {
223 UInt_t uComp = uFee / ( fuNbOfFeePerComp );
224 UInt_t uFeeId = uFee - ( fuNbOfFeePerComp * uComp );
225 fhFeeFtDistribPerCh[ uFee ] = new TH2D(
226 Form( "hFeeFtDistribPerCh_g%02u_f%02u", uComp, uFeeId ),
227 Form( "FT distribution per channel for gDPB %02u FEE %02u", uComp, uFeeId ),
230 fhFeeFtNormDnl[ uFee ] = new TH2D(
231 Form( "hFeeFtNormDnl_g%02u_f%02u", uComp, uFeeId ),
232 Form( "Normalized DNL per channel for gDPB %02u FEE %02u", uComp, uFeeId ),
235 fhFeeFtNormInl[ uFee ] = new TH2D(
236 Form( "hFeeFtNormInl_g%02u_f%02u", uComp, uFeeId ),
237 Form( "Normalized INL per channel for gDPB %02u FEE %02u", uComp, uFeeId ),
240 } // for( UInt_t uFee = 0; uFee < fuNbOfFeePerComp * fuNbOfComps; uFee++)
241
243 // clang-format on
244
246 std::string sFolder = "TofDt";
248
249 for (UInt_t uFeeA = 0; uFeeA < fuNbOfFeePerComp * fuNbOfComps; uFeeA++) {
250 for (UInt_t uFeeB = 0; uFeeB < fuNbOfFeePerComp * fuNbOfComps; uFeeB++) {
251 if (nullptr != fvhTimeDiffPulser[uFeeA][uFeeB]) {
252 AddHistoToVector(fvhTimeDiffPulser[uFeeA][uFeeB], sFolder);
253 }
254 }
255 }
256
257 sFolder = "TofRaw";
262
263 sFolder = "TofDtEvo";
264 for (UInt_t uComp = 0; uComp < fuNbOfComps; ++uComp) {
266
267 /*
268 FIXME: only one GBTx per comp in CRI design!
269 for (UInt_t uGbtx = 0; uGbtx < kuNbGbtxPerComp - 1; ++uGbtx) {
270 if (nullptr != fvhPulserTimeDiffEvoGbtxGbtx[uComp * (kuNbGbtxPerComp - 1) + uGbtx]) {
271 AddHistoToVector(fvhPulserTimeDiffEvoGbtxGbtx[uComp * (kuNbGbtxPerComp - 1) + uGbtx], sFolder);
272 }
273 }
274 */
275
276 for (UInt_t uCompB = uComp + 1; uCompB < fuNbOfComps; ++uCompB) {
277 if (nullptr != fvvhPulserTimeDiffEvoCompComp[uComp][uCompB]) {
278 AddHistoToVector(fvvhPulserTimeDiffEvoCompComp[uComp][uCompB], sFolder);
279 }
280 }
281 } // for( UInt_t uComp = 0; uComp < fuNbOfComps; ++uComp )
282
283 sFolder = "DnlInl";
284 for (UInt_t uFee = 0; uFee < fuNbOfFeePerComp * fuNbOfComps; uFee++) {
286 AddHistoToVector(fhFeeFtNormDnl[uFee], sFolder);
287 AddHistoToVector(fhFeeFtNormInl[uFee], sFolder);
288 } // for( UInt_t uFee = 0; uFee < fuNbOfFeePerComp * fuNbOfComps; uFee++)
289
290 return kTRUE;
291}
292
294{
296 std::string sSystem = "tof";
297
300 new TCanvas(Form("c%sSummaryGet4s", sSystem.data()), Form("GET4s message stats, %s", sSystem.data()));
301 fcSummaryGet4s->Divide(3, 2);
302
303 fcSummaryGet4s->cd(1);
304 gPad->SetGridx();
305 gPad->SetGridy();
306 gPad->SetLogz();
307 fhGet4MessType->Draw("colz");
308
309 std::string sFolder = "canvases";
311
312 /*****************************/
314 fcPulser = new TCanvas("cPulser", "Time difference RMS for pulser channels when FEE pulser mode is ON");
315 fcPulser->Divide(2, 2);
316
317 fcPulser->cd(1);
318 gPad->SetGridx();
319 gPad->SetGridy();
320 fhTimeRmsPulser->Draw("colz");
321
322 fcPulser->cd(2);
323 gPad->SetGridx();
324 gPad->SetGridy();
325 fhTimeMeanPulser->Draw("colz");
326
327 fcPulser->cd(3);
328 gPad->SetGridx();
329 gPad->SetGridy();
330 fhTimeRmsZoomFitPuls->Draw("colz");
331
332 fcPulser->cd(4);
333 gPad->SetGridx();
334 gPad->SetGridy();
335 fhTimeResFitPuls->Draw("colz");
336
337 AddCanvasToVector(fcPulser, sFolder);
338 /*****************************/
339
341 fcPulserEvo = new TCanvas("cPulserEvo", "Time difference evolution between 1st FEE of 1st GBTx of Comp pairs");
342 fcPulserEvo->Divide(1, fuNbOfComps - 1);
343 for (UInt_t uComp = 0; uComp < fuNbOfComps - 1; uComp++) {
344 fcPulserEvo->cd(1 + uComp);
345 gPad->SetGridx();
346 gPad->SetGridy();
347 if (nullptr != fvvhPulserTimeDiffEvoCompComp[uComp][uComp + 1]) {
348 fvvhPulserTimeDiffEvoCompComp[uComp][uComp + 1]->Draw();
349 }
350 } // for( UInt_t uComp = 0; uComp < fuNbOfComps - 1; uComp ++)
351
353 /*****************************/
354
356 /*
357 FIXME: only one GBTx per comp in CRI design!
358 for (UInt_t uComp = 0; uComp < fuNbOfComps; uComp++) {
359 fcPulserEvoGbtx.push_back(
360 new TCanvas(Form("cPulserEvoGbtx%02u", uComp),
361 Form("Time difference evolution between 1st FEE of GBTx pairs in Comp %02u", uComp)));
362 fcPulserEvoGbtx[uComp]->Divide(1, kuNbGbtxPerComp - 1);
363
364 for (UInt_t uGbtx = 0; uGbtx < kuNbGbtxPerComp - 1; ++uGbtx) {
365 fcPulserEvoGbtx[uComp]->cd(1 + uGbtx);
366 gPad->SetGridx();
367 gPad->SetGridy();
368
369 if (nullptr != fvhPulserTimeDiffEvoGbtxGbtx[uComp * (kuNbGbtxPerComp - 1) + uGbtx]) {
370 fvhPulserTimeDiffEvoGbtxGbtx[uComp * (kuNbGbtxPerComp - 1) + uGbtx]->Draw();
371 }
372 } // for( UInt_t uGbtx = 0; uGbtx < kuNbGbtxPerComp - 1; ++uGbtx )
373 AddCanvasToVector(fcPulserEvoGbtx[uComp], sFolder);
374 } // for( UInt_t uComp = 0; uComp < fuNbOfComps; uComp ++)
375 */
376 /*****************************/
377}
378
380{
381 fhGet4MessType->Reset();
382
383 return kTRUE;
384}
385
398
400void CbmTofUnpackMonitorPulser::FillHitMonitoringHistos(const double_t& dMsTime, const uint32_t& uCurrCompIdx,
401 const uint32_t& uGet4Id, const uint32_t& uRawCh,
402 const uint32_t& /*uRemapCh*/, const uint32_t& uTot,
403 const double_t& dHitTime, const uint32_t& uFts, bool bDiamond)
404{
405 if (-1 == fdStartTime) {
407 fdStartTime = dMsTime;
408 }
410 uint32_t uGet4InSys = uGet4Id + uCurrCompIdx * fuNbOfGet4PerComp;
411 fhGet4MessType->Fill(uGet4InSys, 0);
412
413 //UInt_t uChannelNrInFee = (uGet4Id % fuNbOfGet4PerFee) * fuNbOfChannelsPerGet4 + uRawCh;
414 UInt_t uChannelNrInFee = uRawCh % (fuNbOfGet4PerFee * fuNbOfChannelsPerGet4);
415 UInt_t uFeeNr = (uGet4Id / fuNbOfGet4PerFee);
416 UInt_t uFeeNrInSys = uCurrCompIdx * fuNbOfFeePerComp + uFeeNr;
417
419 fhFeeFtDistribPerCh[uFeeNrInSys]->Fill(uFts, uChannelNrInFee);
420
424 if (fuMinTotPulser < uTot && uTot < fuMaxTotPulser) {
425 /*
426 LOG(info) << "CbmTofUnpackMonitorPulser::FillHitMonitoringHistos => Pulser hit "
427 << Form( "%3u %2u %3u %3u %1u", uTot, uCurrCompIdx, uGet4Id, uRawCh, bDiamond);
428 LOG(info) << " => "
429 << Form( "%3u %3u", uFeeNrInSys, uChannelNrInFee);
430 */
431 if (bDiamond) {
433 if (critof001::kuFeePulserChannelDiam == uChannelNrInFee) {
434 fdTsLastPulserHit[uFeeNrInSys] = dHitTime;
435 fvuFeeNbHitsLastMs[uFeeNrInSys]++;
436 fvhPulserCountEvoPerFeeComp[uCurrCompIdx]->Fill(dHitTime * 1e-9, uFeeNr);
437 } // if (critof001::kuFeePulserChannel == uChannelNrInFee) {
438 } // if (bDiamond) {
439 else {
441 if (critof001::kuFeePulserChannel == uChannelNrInFee) {
442 fdTsLastPulserHit[uFeeNrInSys] = dHitTime;
443 fvuFeeNbHitsLastMs[uFeeNrInSys]++;
444 fvhPulserCountEvoPerFeeComp[uCurrCompIdx]->Fill(dHitTime * 1e-9, uFeeNr);
445 } // if (critof001::kuFeePulserChannel == uChannelNrInFee) {
446 } // else of if (bDiamond) {
447 } // if( fuMinTotPulser < uTot && uTot < fuMaxTotPulser )
448}
449
452{
455 for (UInt_t uFeeA = 0; uFeeA < fuNbOfFeePerComp * fuNbOfComps; ++uFeeA) {
456 if (1 != fvuFeeNbHitsLastMs[uFeeA]) {
458 fvuFeeNbHitsLastMs[uFeeA] = 0;
459 continue;
460 } // if( 1 != fvuFeeNbHitsLastMs[ uFeeA ] )
461
462 UInt_t uCompNr = uFeeA / fuNbOfFeePerComp;
463 UInt_t uGbtxNr = (uFeeA % fuNbOfFeePerComp) / kuNbFeePerGbtx;
464
465 UInt_t uFeeRefIndexA = kuNbRefFeeEvo;
466 for (UInt_t uFeeRef = 0; uFeeRef < kuNbRefFeeEvo; ++uFeeRef)
467 if (kuRefFeeEvoIdx[uFeeRef] == uFeeA) uFeeRefIndexA = uFeeRef;
468
470 for (UInt_t uFeeB = uFeeA + 1; uFeeB < fuNbOfFeePerComp * fuNbOfComps; ++uFeeB) {
471 if (1 != fvuFeeNbHitsLastMs[uFeeB]) continue;
472
473 if (nullptr != fvhTimeDiffPulser[uFeeA][uFeeB]) {
474 UInt_t uFeeRefIndexB = kuNbRefFeeEvo;
475 for (UInt_t uFeeRef = 0; uFeeRef < kuNbRefFeeEvo; ++uFeeRef)
476 if (kuRefFeeEvoIdx[uFeeRef] == uFeeB) uFeeRefIndexB = uFeeRef;
477
478 Double_t dTimeDiff = 1e3 * (fdTsLastPulserHit[uFeeB] - fdTsLastPulserHit[uFeeA]);
479 if (TMath::Abs(dTimeDiff) < kdMaxDtPulserPs) {
480 fvhTimeDiffPulser[uFeeA][uFeeB]->Fill(dTimeDiff);
481
482 if (uFeeRefIndexA < kuNbRefFeeEvo)
483 fvvhPulserTimeDiffEvoFeeFee[uFeeRefIndexA][uFeeB]->Fill(1e-9 * (fdTsLastPulserHit[uFeeA] - fdStartTime),
484 dTimeDiff);
485
486 if (uFeeRefIndexB < kuNbRefFeeEvo)
487 fvvhPulserTimeDiffEvoFeeFee[uFeeRefIndexB][uFeeA]->Fill(1e-9 * (fdTsLastPulserHit[uFeeB] - fdStartTime),
488 -1.0 * dTimeDiff);
489
491 if (0 == uFeeA % kuNbFeePerGbtx && 0 == uFeeB % kuNbFeePerGbtx) {
492 UInt_t uCompNrB = uFeeB / fuNbOfFeePerComp;
493 UInt_t uGbtxNrB = (uFeeB % fuNbOfFeePerComp) / kuNbFeePerGbtx;
494
496 if (uCompNr == uCompNrB) {
497 /*
498 FIXME: only one GBTx per comp in CRI design!
499 if (0 == uGbtxNr) {
500 UInt_t uPlotIdx = uCompNr * (kuNbGbtxPerComp - 1) + uGbtxNrB - 1;
501 fvhPulserTimeDiffEvoGbtxGbtx[uPlotIdx]->Fill(1e-9 * (fdTsLastPulserHit[uFeeA] - fdStartTime),
502 dTimeDiff);
503 } // if( 0 == uGbtxNr )
504 */
505 } // if( uCompNr == uFeeB / fuNbOfFeePerComp )
506 else // if (uCompNr == uCompNrB)
507 {
509 if (0 == uGbtxNr && 0 == uGbtxNrB)
510 fvvhPulserTimeDiffEvoCompComp[uCompNr][uFeeB / fuNbOfFeePerComp]->Fill(
511 1e-9 * (fdTsLastPulserHit[uFeeA] - fdStartTime), dTimeDiff);
512 } // else of if( uCompNr == uFeeB / fuNbOfFeePerComp )
513 } // if( 0 == uFeeA % kuNbFeePerGbtx && 0 == uFeeB % kuNbFeePerGbtx )
514 } // if( TMath::Abs( dTimeDiff ) < kdMaxDtPulserPs )
515 } // if( nullptr != fvhTimeDiffPulser[uFeeA][uFeeB] )
516 } // for( UInt_t uFeeB = uFeeA + 1; uFeeB < fuNbOfFeePerComp * fuNbOfComps; ++uFeeB)
517
519 fvuFeeNbHitsLastMs[uFeeA] = 0;
520 } // for( UInt_t uFeeA = 0; uFeeA < fuNbOfFeePerComp * fuNbOfComps; ++uFeeA)
521}
522
525{
526 // Update RMS plots only every 10s in data
527 if (10.0 < dTsStartTime * 1e-9 - fdLastRmsUpdateTime) {
528 LOG(info) << "CbmTofUnpackMonitorPulser::FinalizeTsHistos => Update pulser statistics ";
529 // Reset summary histograms for safety
530 fhTimeMeanPulser->Reset();
531 fhTimeRmsPulser->Reset();
532
533 for (UInt_t uFeeA = 0; uFeeA < fuNbOfFeePerComp * fuNbOfComps; uFeeA++)
534 for (UInt_t uFeeB = 0; uFeeB < fuNbOfFeePerComp * fuNbOfComps; uFeeB++)
535 if (nullptr != fvhTimeDiffPulser[uFeeA][uFeeB]) {
536 fhTimeMeanPulser->Fill(uFeeA, uFeeB, fvhTimeDiffPulser[uFeeA][uFeeB]->GetMean());
537 fhTimeRmsPulser->Fill(uFeeA, uFeeB, fvhTimeDiffPulser[uFeeA][uFeeB]->GetRMS());
538 } // for( UInt_t uChan = 0; uChan < kuNbChanTest - 1; uChan++)
541
542 // Update zoomed plots only every 60s as no http UI commands in this version of monitor
543 if (6 == fuNbRmsUpdates) { //
548
549 fuNbRmsUpdates = 0;
550 } // if (6 == fuNbRmsUpdates)
551 } // if( 10.0 < dTsStartTime - fdLastRmsUpdateTime )
552}
553
555{
556 // Only do something is the user defined the width he want for the zoom
557 if (0.0 < fdFitZoomWidthPs) {
558 // Reset summary histograms for safety
559 fhTimeRmsZoomFitPuls->Reset();
560 fhTimeResFitPuls->Reset();
561
562 Double_t dRes = 0;
564
565 for (UInt_t uFeeA = 0; uFeeA < fuNbOfFeePerComp * fuNbOfComps; uFeeA++)
566 for (UInt_t uFeeB = 0; uFeeB < fuNbOfFeePerComp * fuNbOfComps; uFeeB++)
567 if (nullptr != fvhTimeDiffPulser[uFeeA][uFeeB]) {
568 // Check that we have at least 1 entry
569 if (0 == fvhTimeDiffPulser[uFeeA][uFeeB]->GetEntries()) {
570 fhTimeRmsZoomFitPuls->Fill(uFeeA, uFeeB, 0.0);
571 fhTimeResFitPuls->Fill(uFeeA, uFeeB, 0.0);
572 LOG(debug) << "CbmTofUnpackMonitorPulser::UpdateZoomedFit => Empty input "
573 << "for FEE pair " << uFeeA << " and " << uFeeB << " !!! ";
574 continue;
575 } // if( 0 == fvhTimeDiffPulser[uFeeA][uFeeB]->GetEntries() )
576
577 // Read the peak position (bin with max counts) + total nb of entries
578 Int_t iBinWithMax = fvhTimeDiffPulser[uFeeA][uFeeB]->GetMaximumBin();
579 Double_t dNbCounts = fvhTimeDiffPulser[uFeeA][uFeeB]->Integral();
580
581 // Zoom the X axis to +/- ZoomWidth around the peak position
582 Double_t dPeakPos = fvhTimeDiffPulser[uFeeA][uFeeB]->GetXaxis()->GetBinCenter(iBinWithMax);
583 fvhTimeDiffPulser[uFeeA][uFeeB]->GetXaxis()->SetRangeUser(dPeakPos - fdFitZoomWidthPs,
584 dPeakPos + fdFitZoomWidthPs);
585
586 // Read integral and check how much we lost due to the zoom (% loss allowed)
587 Double_t dZoomCounts = fvhTimeDiffPulser[uFeeA][uFeeB]->Integral();
588 if ((dZoomCounts / dNbCounts) < 0.99) {
589 fhTimeRmsZoomFitPuls->Fill(uFeeA, uFeeB, 0.0);
590 fhTimeResFitPuls->Fill(uFeeA, uFeeB, 0.0);
591 LOG(warning) << "CbmTofUnpackMonitorPulser::UpdateZoomedFit => Zoom too strong, "
592 << "more than 1% loss for FEE pair " << uFeeA << " and " << uFeeB << " !!! ";
593 continue;
594 } // if( ( dZoomCounts / dNbCounts ) < 0.99 )
595
596 // Fill new RMS after zoom into summary histo
597 fhTimeRmsZoomFitPuls->Fill(uFeeA, uFeeB, fvhTimeDiffPulser[uFeeA][uFeeB]->GetRMS());
598
599
600 // Fit using zoomed boundaries + starting gaussian width, store into summary histo
601 dRes = 0;
602 fitFuncPairs[uFeeA][uFeeB] = new TF1(Form("fPair_%02d_%02d", uFeeA, uFeeB), "gaus",
603 dPeakPos - fdFitZoomWidthPs, dPeakPos + fdFitZoomWidthPs);
604 // Fix the Mean fit value around the Histogram Mean
605 fitFuncPairs[uFeeA][uFeeB]->SetParameter(0, dZoomCounts);
606 fitFuncPairs[uFeeA][uFeeB]->SetParameter(1, dPeakPos);
607 fitFuncPairs[uFeeA][uFeeB]->SetParameter(2, 200.0); // Hardcode start with ~4*BinWidth, do better later
608 // Using integral instead of bin center seems to lead to unrealistic values => no "I"
609 fvhTimeDiffPulser[uFeeA][uFeeB]->Fit(Form("fPair_%02d_%02d", uFeeA, uFeeB), "QRM0");
610 // Get Sigma
611 dRes = fitFuncPairs[uFeeA][uFeeB]->GetParameter(2);
612 // Cleanup memory
613 delete fitFuncPairs[uFeeA][uFeeB];
614 // Fill summary
615 fhTimeResFitPuls->Fill(uFeeA, uFeeB, dRes / TMath::Sqrt2());
616
617
618 LOG(info) << "CbmTofUnpackMonitorPulser::UpdateZoomedFit => "
619 << "For FEE pair " << uFeeA << " and " << uFeeB
620 << " we have zoomed RMS = " << fvhTimeDiffPulser[uFeeA][uFeeB]->GetRMS() << " and a resolution of "
621 << dRes / TMath::Sqrt2();
622
623 // Restore original axis state?
624 fvhTimeDiffPulser[uFeeA][uFeeB]->GetXaxis()->UnZoom();
625 } // loop on uFeeA and uFeeB + check if corresponding fvhTimeDiffPulser exists
626 } // if( 0.0 < fdFitZoomWidthPs )
627 else {
628 LOG(error) << "CbmTofUnpackMonitorPulser::UpdateZoomedFit => Zoom width not defined, "
629 << "please use SetFitZoomWidthPs, e.g. in macro, before trying this update !!!";
630 } // else of if( 0.0 < fdFitZoomWidthPs )
631}
632
634{
635 TDirectory* oldDir = gDirectory;
636
637 gROOT->cd();
638 TF1* constantVal = new TF1("constant", "1", 0, critof001::kdFtBinsNb);
639 for (UInt_t uFeeNrInSys = 0; uFeeNrInSys < fuNbOfFeePerComp * fuNbOfComps; uFeeNrInSys++) {
640 fhFeeFtNormDnl[uFeeNrInSys]->Reset();
641 fhFeeFtNormInl[uFeeNrInSys]->Reset();
642
643 for (UInt_t uChannel = 0; uChannel < fuNbOfChannelsPerFee; uChannel++) {
644 // Rising edge
645 TH1* pFtSelChSlice =
646 fhFeeFtDistribPerCh[uFeeNrInSys]->ProjectionX("temp_pFtSelChSlice", 1 + uChannel, 1 + uChannel);
647 if (0 < pFtSelChSlice->GetEntries()) {
648 Double_t dNormFactRise = pFtSelChSlice->GetEntries() / critof001::kdFtBinsNb;
649 pFtSelChSlice->Scale(1.0 / dNormFactRise);
650 pFtSelChSlice->Add(constantVal, -1.);
651 } // if( 0 < pFtSelChSliceRise->GetEntries() )
652
653 // INLs + storage
654 Double_t dDnl = 0.0;
655 Double_t dInl = 0.0;
656 for (UInt_t uFtBin = 0; uFtBin < critof001::kdFtBinsNb; uFtBin++) {
657 dDnl = pFtSelChSlice->GetBinContent(1 + uFtBin);
658 dInl += dDnl;
659 fhFeeFtNormDnl[uFeeNrInSys]->Fill(uFtBin, uChannel, dDnl);
660 fhFeeFtNormInl[uFeeNrInSys]->Fill(uFtBin, uChannel, dInl);
661 } // for( UInt_t uFtBin = 0; uFtBin < critof001::kuFineCounterSize; uFtBin++)
662
663 delete pFtSelChSlice;
664 } // for( UInt_t uChannel = 0; uChannel < fuNbOfChannelsPerFee; uChannel++ )
665 } // for( UInt_t uFeeNrInSys = 0; uFeeNrInSys < fuNbOfFeePerComp * fuNbOfComps; uFeeNrInSys++ )
666 delete constantVal;
667
668 oldDir->cd();
669}
670
671/**********************************************************************************************************************/
674{
675 LOG(fatal) << "SetBmonMode mode not available in CbmTofUnpackMonitorPulser (forced off)";
676}
677
679{
680 LOG(fatal) << "SetBmonMicroSpillMode mode not available in CbmTofUnpackMonitorPulser (forced off)";
681}
682
684{
685 LOG(fatal) << "SetBmonScvdMode mode not available in CbmTofUnpackMonitorPulser (forced off)";
686}
687
689{
690 LOG(fatal) << "SetBmonQFactorMode mode not available in CbmTofUnpackMonitorPulser (forced off)";
691}
692
694{
695 LOG(fatal) << "SetTofQFactorMode mode not available in CbmTofUnpackMonitorPulser (forced off)";
696}
697/**********************************************************************************************************************/
698
ClassImp(CbmConverterManager)
static double dTsStartTime
int Int_t
bool Bool_t
std::vector< std::vector< TH1 * > > fvhTimeDiffPulser
[ fuNrOfComps ][ fuNrOfChannelsPerComp ]
const double_t kdMaxDtPulserPs
Constants.
const UInt_t kuRefFeeEvoIdx[kuNbRefFeeEvo]
std::vector< double_t > fdTsLastPulserHit
[ fuFeeNr ]
std::vector< uint32_t > fvuFeeNbHitsLastMs
Number of channels in each FEE.
virtual void Finish()
Write all histograms and canvases to file.
uint32_t fuNbOfChannelsPerFee
Max number of Get4 per FEE (has to match nb FEE and GET4 per comp)
std::vector< TH2 * > fvhPulserCountEvoPerFeeComp
virtual void FillHitMonitoringHistos(const double_t &dMsTime, const uint32_t &uCurrCompIdx, const uint32_t &uGet4Id, const uint32_t &uRawCh, const uint32_t &uRemapCh, const uint32_t &uTot, const double_t &dHitTime, const uint32_t &uFts, bool bDiamond=false)
Fill pulser histograms.
uint32_t fuNbOfFeePerComp
FIXME: recheck if OK and if not conflicting with fuNrOfFeePerComp!
virtual void FinalizeTsHistos(double_t dTsStartTime)
Finalize pulser histograms.
uint32_t fuNbOfGet4PerFee
Max number of FEE per component.
double_t fdFitZoomWidthPs
Settings and tracers.
virtual Bool_t Init(CbmMcbm2018TofPar *digiParSet)
Init all required parameter informations and histograms.
std::vector< std::vector< TProfile * > > fvvhPulserTimeDiffEvoCompComp
std::vector< std::vector< TProfile * > > fvvhPulserTimeDiffEvoFeeFee
virtual void FinalizeMsHistos()
Finalize pulser histograms.
void SetBmonMicroSpillMode(bool value)
Activate the BMon mode.
CbmMcbm2018TofPar * fUnpackPar
Settings from parameter file.
void AddHistoToVector(TNamed *pointer, std::string sFolder="")
std::vector< std::pair< TCanvas *, std::string > > GetCanvasVector()
void AddCanvasToVector(TCanvas *pointer, std::string sFolder="")
void SetBmonMode(bool value)
Activate the BMon mode.
std::vector< std::pair< TNamed *, std::string > > GetHistoVector()
Double_t fdStartTime
Total/maximum number of Get4 in system.
void SetBmonQFactorMode(bool value)
Activate the Bmon QFactor mode.
UInt_t fuNbOfComps
Readout chain dimensions and mapping.
UInt_t fuNbOfGet4PerComp
Total number of Components in the system.
bool fBmonMode
Flag if debug mode is active or not.
UInt_t fuMinTotPulser
---> User settings: Data correction parameters
UInt_t fuNbOfChannelsPerComp
Number of channels per Get4, constant.
void SetBmonScvdMode(bool value)
Activate the BMon sCVD mode.
void SetTofQFactorMode(bool value)
Activate the Tof QFactor mode.
UInt_t fuNbOfChannelsPerGet4
Max number of Get4 per component.
void Finish()
Write all histograms and canvases to file.
UInt_t fuNbOfGet4InSyst
Number of channels per Component, recalculated.
const double kdFtBinsNb
const uint32_t kuFeePulserChannelDiam
const double kdBinSize
const uint32_t kuFeePulserChannel