CbmRoot
Loading...
Searching...
No Matches
CbmMcbm2019CheckPulser.cxx
Go to the documentation of this file.
1/* Copyright (C) 2019-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
6
7#include "CbmDigiManager.h"
10#include "CbmPsdDigi.h"
11#include "CbmRichDigi.h"
12#include "CbmStsDigi.h"
13#include "CbmTofDigi.h"
14#include "CbmTrdDigi.h"
15
16#include "FairRootManager.h"
17#include "FairRunOnline.h"
18#include <Logger.h>
19
20#include "TClonesArray.h"
21#include "TH1.h"
22#include "TH2.h"
23#include "THttpServer.h"
24#include "TProfile.h"
25#include <TDirectory.h>
26#include <TFile.h>
27#include <type_traits>
28
29#include <iomanip>
30#include <iostream>
31using std::fixed;
32using std::setprecision;
33
34// ---- Default constructor -------------------------------------------
35CbmMcbm2019CheckPulser::CbmMcbm2019CheckPulser() : FairTask("CbmMcbm2019CheckPulser") {}
36
37// ---- Destructor ----------------------------------------------------
39
40// ---- Initialisation ----------------------------------------------
42{
43 // Load all necessary parameter containers from the runtime data base
44 /*
45 FairRunAna* ana = FairRunAna::Instance();
46 FairRuntimeDb* rtdb=ana->GetRuntimeDb();
47
48 <CbmMcbm2019CheckPulserDataMember> = (<ClassPointer>*)
49 (rtdb->getContainer("<ContainerName>"));
50 */
51}
52
53// ---- Init ----------------------------------------------------------
55{
56
57 // Get a handle from the IO manager
58 FairRootManager* ioman = FairRootManager::Instance();
59
60 // Digi manager
63 fDigiMan->Init();
64
65 // Bmon is not included in DigiManager; have to take care here
66 // Try to find a vector branch for the digi
67 fBmonDigiVector = ioman->InitObjectAs<std::vector<CbmTofDigi> const*>("BmonDigi");
68 if (!fBmonDigiVector) {
69 LOG(info) << "No Bmon digi vector found; trying TClonesArray";
70 if (std::is_convertible<TObject*, CbmTofDigi*>::value) {
71 fBmonDigiArray = dynamic_cast<TClonesArray*>(ioman->GetObject("BmonDigi"));
72 if (!fBmonDigiArray) LOG(info) << "No Bmon digi input found.";
73 } //? CbmTofDigi derives from TObject
74 } //? No vector for Bmon digis
75
76 if (!fDigiMan->IsPresent(ECbmModuleId::kSts)) { LOG(info) << "No STS digi input found."; }
77
78 if (!fDigiMan->IsPresent(ECbmModuleId::kMuch)) { LOG(info) << "No MUCH digi input found."; }
79
81 LOG(info) << "No TRD digi input found.";
82 } // if ( ! fDigiMan->IsPresent(ECbmModuleId::kTrd) )
83 else {
84 } // else of if ( ! fDigiMan->IsPresent(ECbmModuleId::kTrd) )
85
86 if (!fDigiMan->IsPresent(ECbmModuleId::kTof)) { LOG(info) << "No TOF digi input found."; }
87
88 if (!fDigiMan->IsPresent(ECbmModuleId::kRich)) { LOG(info) << "No RICH digi input found."; }
89
90 if (!fDigiMan->IsPresent(ECbmModuleId::kPsd)) { LOG(info) << "No PSD digi input found."; }
91
93 fTimeSliceMetaDataArray = dynamic_cast<TClonesArray*>(ioman->GetObject("TimesliceMetaData"));
94 if (!fTimeSliceMetaDataArray) LOG(fatal) << "No TS metadata input found";
95
97
98 return kSUCCESS;
99}
100
102{
103
104 if (offsetRange < 251) {
105 Double_t dClocks = offsetRange;
106 dClocks /= 6.25;
107 return (dClocks * 112 * 2);
108 }
109 else if (offsetRange < 501) {
110 fBinWidth = 1;
111 }
112 else if (offsetRange < 1001) {
113 fBinWidth = 5;
114 }
115 else if (offsetRange < 10001) {
116 fBinWidth = 10;
117 }
118 else if (offsetRange < 100001) {
119 fBinWidth = 100;
120 }
121 else {
122 fBinWidth = 100;
123 }
124
125 return (offsetRange / fBinWidth * 2);
126}
127
129{
131 uint32_t iNbBinsLog = 0;
133 std::vector<double> dBinsLogVector = GenerateLogBinArray(9, 9, 1, iNbBinsLog);
134 double* dBinsLog = dBinsLogVector.data();
135 // double * dBinsLog = GenerateLogBinArray( 9, 9, 1, iNbBinsLog );
136
137 Int_t nrOfBinsSts = CalcNrBins(fStsOffsetRange);
138 // Bmon vs. Sts
140 new TH1F("fBmonStsDiff", "Bmon-Sts;time diff [ns];Counts", nrOfBinsSts, -fStsOffsetRange, fStsOffsetRange);
141
142 fBmonStsDiffEvo = new TH2F("fBmonStsDiffEvo", "Bmon-Sts;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsSts,
144
145
146 Int_t nrOfBinsMuch = CalcNrBins(fMuchOffsetRange);
147 // Bmon vs. Much
149 new TH1F("fBmonMuchDiff", "Bmon-Much;time diff [ns];Counts", nrOfBinsMuch, -fMuchOffsetRange, fMuchOffsetRange);
150
151 fBmonMuchDiffEvo = new TH2F("fBmonMuchDiffEvo", "Bmon-Much;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsMuch,
153
154
155 Int_t nrOfBinsTrd = CalcNrBins(fTrdOffsetRange);
156 // To vs. Trd
158 new TH1F("fBmonTrdDiff", "Bmon-Trd;time diff [ns];Counts", nrOfBinsTrd, -fTrdOffsetRange, fTrdOffsetRange);
159
160 fBmonTrdDiffEvo = new TH2F("fBmonTrdDiffEvo", "Bmon-Trd;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsTrd,
162
163
164 Int_t nrOfBinsTof = CalcNrBins(fTofOffsetRange);
165 // To vs. Tof
167 new TH1F("fBmonTofDiff", "Bmon-Tof;time diff [ns];Counts", nrOfBinsTof, -fTofOffsetRange, fTofOffsetRange);
168
169 fBmonTofDiffEvo = new TH2F("fBmonTofDiffEvo", "Bmon-Tof;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsTof,
171
172
173 Int_t nrOfBinsRich = CalcNrBins(fRichOffsetRange);
174 // To vs. Rich
176 new TH1F("fBmonRichDiff", "Bmon-Rich;time diff [ns];Counts", nrOfBinsRich, -fRichOffsetRange, fRichOffsetRange);
177
178 fBmonRichDiffEvo = new TH2F("fBmonRichDiffEvo", "Bmon-Rich;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsRich,
180
181 Int_t nrOfBinsPsd = CalcNrBins(fPsdOffsetRange);
182 // To vs. Psd
184 new TH1F("fBmonPsdDiff", "Bmon-Psd;time diff [ns];Counts", nrOfBinsPsd, -fPsdOffsetRange, fPsdOffsetRange);
185
186 fBmonPsdDiffEvo = new TH2F("fBmonPsdDiffEvo", "Bmon-Psd;TS; time diff [ns];Counts", 1000, 0, 10000, nrOfBinsPsd,
188
189 fBmonPsdDiffCharge = new TH2F("fBmonPsdDiffCharge", "Bmon-Psd;time diff [ns]; Charge [a.u]; ;Counts", nrOfBinsPsd,
190 -fPsdOffsetRange, fPsdOffsetRange, 7000, 0, 70000);
191
192
193 // Bmon vs. Sts
194 fBmonStsDiffEvoLong = new TH2F("fBmonStsDiffEvoLong", "Bmon-Sts;TS; time diff [ns];Counts", 1800, 0, 180000,
195 nrOfBinsSts, -fStsOffsetRange, fStsOffsetRange);
196 // Bmon vs. Much
197 fBmonMuchDiffEvoLong = new TH2F("fBmonMuchDiffEvoLong", "Bmon-Much;TS; time diff [ns];Counts", 1800, 0, 180000,
198 nrOfBinsMuch, -fMuchOffsetRange, fMuchOffsetRange);
199 // To vs. Trd
200 fBmonTrdDiffEvoLong = new TH2F("fBmonTrdDiffEvoLong", "Bmon-Trd;TS; time diff [ns];Counts", 1800, 0, 180000,
201 nrOfBinsTrd, -fTrdOffsetRange, fTrdOffsetRange);
202 // To vs. Tof
203 fBmonTofDiffEvoLong = new TH2F("fBmonTofDiffEvoLong", "Bmon-Tof;TS; time diff [ns];Counts", 1800, 0, 180000,
204 nrOfBinsTof, -fTofOffsetRange, fTofOffsetRange);
205 // To vs. Rich
206 fBmonRichDiffEvoLong = new TH2F("fBmonRichDiffEvoLong", "Bmon-Rich;TS; time diff [ns];Counts", 1800, 0, 180000,
207 nrOfBinsRich, -fRichOffsetRange, fRichOffsetRange);
208
209 // To vs. Psd
210 fBmonPsdDiffEvoLong = new TH2F("fBmonPsdDiffEvoLong", "Bmon-Psd;TS; time diff [ns];Counts", 1800, 0, 180000,
211 nrOfBinsPsd, -fPsdOffsetRange, fPsdOffsetRange);
212
213
214 // Bmon vs. Sts
215 fBmonStsMeanEvo = new TProfile("fBmonStsMeanEvo", "Bmon-Sts; time in run [s]; Mean time diff [ns]", 4320, 0, 4320);
216 // Bmon vs. Much
217 fBmonMuchMeanEvo = new TProfile("fBmonMuchMeanEvo", "Bmon-Much; time in run [s]; Mean time diff [ns]", 4320, 0, 4320);
218 // To vs. Tof
219 fBmonTrdMeanEvo = new TProfile("fBmonTrdMeanEvo", "Bmon-Trd; time in run [s]; Mean time diff [ns]", 4320, 0, 4320);
220 // To vs. Tof
221 fBmonTofMeanEvo = new TProfile("fBmonTofMeanEvo", "Bmon-Tof; time in run [s]; Mean time diff [ns]", 4320, 0, 4320);
222 // To vs. Rich
223 fBmonRichMeanEvo = new TProfile("fBmonRichMeanEvo", "Bmon-Rich; time in run [s]; Mean time diff [ns]", 4320, 0, 4320);
224 // To vs. Psd
225 fBmonPsdMeanEvo = new TProfile("fBmonPsdMeanEvo", "Bmon-Psd; time in run [s]; Mean time diff [ns]", 4320, 0, 4320);
226 // 4320, 0, 259200);
227
228
229 // Bmon vs. STS for the different DPBs
230 fBmonStsDpbDiff = new TH2F("fBmonStsDpbDiff", "Bmon-Much;DPB; time diff [ns];Counts", 2, -0.5, 1.5, nrOfBinsSts,
232
233 for (UInt_t uStsDpb = 0; uStsDpb < kuMaxNbStsDpbs; ++uStsDpb) {
234 fBmonStsDpbDiffEvo[uStsDpb] =
235 new TH2F(Form("fBmonStsDpbDiffEvo%02u", uStsDpb), Form("Bmon-STS DPB %02u;TS; time diff [ns];Counts", uStsDpb),
236 1800, 0, 180000, nrOfBinsSts, -fStsOffsetRange, fStsOffsetRange);
237 fStsDpbCntsEvo[uStsDpb] =
238 new TH1F(Form("fStsDpbCntsEvo%02u", uStsDpb), Form("Time STS DPB %02u;TS; Hit Counts", uStsDpb), 1800, 0, 180000);
239 } // for( UInt_t uStsDpb = 0; uStsDpb < kuMaxNbStsDpbs; ++uStsDpb )
240
241 // Bmon vs. Much for the different DPBs/AFCK
242 fBmonMuchRocDiff = new TH2F("fBmonMuchRocDiff", "Bmon-Much;AFCK; time diff [ns];Counts", kuMaxNbMuchDpbs, -0.5,
243 kuMaxNbMuchDpbs - 0.5, nrOfBinsMuch, -fMuchOffsetRange, fMuchOffsetRange);
244
245 // Bmon vs. Much for the different ASICs
246 fBmonMuchAsicDiff = new TH2F("fBmonMuchAsicDiff", "Bmon-Much;ASIC; time diff [ns];Counts", kuMaxNbMuchAsics, -0.5,
247 kuMaxNbMuchAsics - 0.5, nrOfBinsMuch, -fMuchOffsetRange, fMuchOffsetRange);
248
249 for (UInt_t uMuchAsic = 0; uMuchAsic < kuMaxNbMuchAsics; ++uMuchAsic)
250 fBmonMuchAsicDiffEvo[uMuchAsic] = new TH2F(Form("fBmonMuchAsicDiffEvo%02u", uMuchAsic),
251 Form("Bmon-Much ASIC %02u;TS; time diff [ns];Counts", uMuchAsic), 1800,
252 0, 180000, nrOfBinsMuch, -fMuchOffsetRange, fMuchOffsetRange);
253
254 // Bmon vs. Bmon
255 fBmonBmonDiff = new TH1F("fBmonBmonDiff", "Bmon-Bmon_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
256 // sts vs. Sts
257 fStsStsDiff = new TH1F("fStsStsDiff", "Sts-Sts_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
258 // Much vs. Much
259 fMuchMuchDiff = new TH1F("fMuchMuchDiff", "Much-Much_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
260 // Trd vs. Trd
261 fTrdTrdDiff = new TH1F("fTrdTrdDiff", "Trd-Trd_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
262 // Tof vs. Tof
263 fTofTofDiff = new TH1F("fTofTofDiff", "Tof-Tof_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
264 // Rich vs. Rich
265 fRichRichDiff = new TH1F("fRichRichDiff", "Rich-Rich_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
266 // Psd vs. Psd
267 fPsdPsdDiff = new TH1F("fPsdPsdDiff", "Psd-Psd_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
268
269
270 fBmonStsNb = new TH2F("fBmonStsNb", "Bmon-STS;Nb Bmon; Nb STS;TS []", 100, 0, 100, 100, 0, 100);
271 fBmonMuchNb = new TH2F("fBmonMuchNb", "Bmon-MUCH;Nb Bmon; Nb MUCH;TS []", 100, 0, 100, 100, 0, 100);
272 fBmonTrdNb = new TH2F("fBmonTrdNb", "Bmon-TRD;Nb Bmon; Nb TRD;TS []", 100, 0, 100, 100, 0, 100);
273 fBmonTofNb = new TH2F("fBmonTofNb", "Bmon-TOF;Nb Bmon; Nb TOF;TS []", 100, 0, 100, 100, 0, 100);
274 fBmonRichNb = new TH2F("fBmonRichNb", "Bmon-RICH;Nb Bmon; Nb RICH;TS []", 100, 0, 100, 100, 0, 100);
275 fBmonPsdNb = new TH2F("fBmonPsdNb", "Bmon-PSD;Nb Bmon; Nb PSD;TS []", 100, 0, 100, 100, 0, 100);
276
277 fBmonAddress = new TH1F("fBmonAddress", "Bmon address;address;Counts", 1000000, 0, 1000000.);
278
279 fBmonChannel = new TH1F("fBmonChannel", "Bmon channel;channel nr;Counts", 100, -0.5, 99.5);
280
282 // delete dBinsLog;
283
285 FairRunOnline* run = FairRunOnline::Instance();
286 if (run) {
287 THttpServer* server = run->GetHttpServer();
288 if (nullptr != server) {
289 server->Register("/CheckTiming", fBmonStsDiff);
290 server->Register("/CheckTiming", fBmonMuchDiff);
291 server->Register("/CheckTiming", fBmonTrdDiff);
292 server->Register("/CheckTiming", fBmonTofDiff);
293 server->Register("/CheckTiming", fBmonRichDiff);
294 server->Register("/CheckTiming", fBmonPsdDiff);
295 server->Register("/CheckTiming", fBmonStsDiffEvo);
296 server->Register("/CheckTiming", fBmonMuchDiffEvo);
297 server->Register("/CheckTiming", fBmonTrdDiffEvo);
298 server->Register("/CheckTiming", fBmonTofDiffEvo);
299 server->Register("/CheckTiming", fBmonRichDiffEvo);
300 server->Register("/CheckTiming", fBmonPsdDiffEvo);
301 server->Register("/CheckTiming", fBmonStsDiffEvoLong);
302 server->Register("/CheckTiming", fBmonMuchDiffEvoLong);
303 server->Register("/CheckTiming", fBmonTrdDiffEvoLong);
304 server->Register("/CheckTiming", fBmonTofDiffEvoLong);
305 server->Register("/CheckTiming", fBmonRichDiffEvoLong);
306 server->Register("/CheckTiming", fBmonPsdDiffEvoLong);
307
308 server->Register("/CheckTiming", fBmonStsMeanEvo);
309 server->Register("/CheckTiming", fBmonMuchMeanEvo);
310 server->Register("/CheckTiming", fBmonTrdMeanEvo);
311 server->Register("/CheckTiming", fBmonTofMeanEvo);
312 server->Register("/CheckTiming", fBmonRichMeanEvo);
313 server->Register("/CheckTiming", fBmonPsdMeanEvo);
314
315 server->Register("/CheckTiming", fBmonBmonDiff);
316 server->Register("/CheckTiming", fStsStsDiff);
317 server->Register("/CheckTiming", fMuchMuchDiff);
318 server->Register("/CheckTiming", fTrdTrdDiff);
319 server->Register("/CheckTiming", fTofTofDiff);
320 server->Register("/CheckTiming", fRichRichDiff);
321 server->Register("/CheckTiming", fPsdPsdDiff);
322
323 server->Register("/CheckTiming", fBmonStsNb);
324 server->Register("/CheckTiming", fBmonMuchNb);
325 server->Register("/CheckTiming", fBmonTrdNb);
326 server->Register("/CheckTiming", fBmonTofNb);
327 server->Register("/CheckTiming", fBmonRichNb);
328 server->Register("/CheckTiming", fBmonPsdNb);
329
330 server->Register("/CheckTiming", fBmonStsDpbDiff);
331 for (UInt_t uStsDpb = 0; uStsDpb < kuMaxNbStsDpbs; ++uStsDpb)
332 server->Register("/CheckTiming/STS", fBmonStsDpbDiffEvo[uStsDpb]);
333
334 server->Register("/CheckTiming", fBmonMuchRocDiff);
335 server->Register("/CheckTiming", fBmonMuchAsicDiff);
336 for (UInt_t uMuchAsic = 0; uMuchAsic < kuMaxNbMuchAsics; ++uMuchAsic)
337 server->Register("/CheckTiming/MUCH", fBmonMuchAsicDiffEvo[uMuchAsic]);
338 }
339 }
340 /*
341 fDigisPerAsicEvo = new TH2F( "fDigisPerAsicEvo",
342 "Digis per Asic evo; Time [ ns ]; ASIC []",
343 5 * 10240, 0, 5 * 10240000.,
344 kuMaxNbMuchAsics, 0, kuMaxNbMuchAsics);
345 for( UInt_t uAsic = 0; uAsic < kuMaxNbMuchAsics; ++uAsic )
346 for( UInt_t uChan = 0; uChan < kuNbChanSMX; ++uChan )
347 {
348 fdLastMuchDigi[ uAsic ][ uChan ] = 0.0;
349 fdLastMuchDigiPulser[ uAsic ][ uChan ] = 0.0;
350 } // loop on channel and asic
351
352 fSameChanDigisDistEvo = new TH2F( "fSameChanDigisDistEvo",
353 "Time dist of digis in same chan evo; Time [ ns ]; Same chan dist [ ns ]",
354 5000, 0, 500000.,
355 1000, 0., 10000. );
356
357 fDigiTimeEvoBmon = new TH2F( "fDigiTimeEvoBmon",
358 "Time of digi in Bmon vs ts index; TS [ ]; Digi time [ ns ]",
359 10000, 0., 30000.,
360 10000, 0., 300.e9 );
361 fDigiTimeEvoSts = new TH2F( "fDigiTimeEvoSts",
362 "Time of digi in Sts vs ts index; TS [ ]; Digi time [ ns ]",
363 10000, 0., 30000.,
364 10000, 0., 300.e9 );
365 fDigiTimeEvoMuch = new TH2F( "fDigiTimeEvoMuch",
366 "Time of digi in Much vs ts index; TS [ ]; Digi time [ ns ]",
367 10000, 0., 30000.,
368 10000, 0., 300.e9 );
369 fDigiTimeEvoTof = new TH2F( "fDigiTimeEvoTof",
370 "Time of digi in Tof vs ts index; TS [ ]; Digi time [ ns ]",
371 10000, 0., 30000.,
372 10000, 0., 300.e9 );
373*/
374}
375// ---- ReInit -------------------------------------------------------
376InitStatus CbmMcbm2019CheckPulser::ReInit() { return kSUCCESS; }
377
378// ---- Exec ----------------------------------------------------------
379void CbmMcbm2019CheckPulser::Exec(Option_t* /*option*/)
380{
381 LOG(debug) << "executing TS " << fNrTs;
382
383 if (0 < fNrTs && 0 == fNrTs % 1000) LOG(info) << Form("Processing TS %6d", fNrTs);
384
385 /*
387 if( fNrTs < 17600 || 17650 < fNrTs )
388// if( fNrTs < 17634 || 17637 < fNrTs )
389 return;
390*/
391
393 /*
394 Int_t nrBmonDigis=fBmonDigis->GetEntriesFast();
395 for (Int_t iBmon = 0; iBmon < nrBmonDigis; ++iBmon)
396 {
397 CbmDigi* BmonDigi = static_cast<CbmDigi*>(fBmonDigis->At(iBmon));
398
399 Double_t T0Time = BmonDigi->GetTime();
400 fDigiTimeEvoBmon->Fill( fNrTs, T0Time );
401 }
402
403 Int_t nrStsDigis{0};
404 if (fStsDigis) {
405 nrStsDigis=fStsDigis->GetEntriesFast();
406 LOG(debug) << "StsDigis: " << nrStsDigis;
407 for (Int_t iMuch = 0; iMuch < nrStsDigis; ++iMuch) {
408
409 CbmDigi* Digi = static_cast<CbmDigi*>(fStsDigis->At(iMuch));
410
411 Double_t dTime = Digi->GetTime();
412 fDigiTimeEvoSts->Fill( fNrTs, dTime );
413 }
414 }
415
416 Int_t nrMuchDigis{0};
417 if (fMuchDigis) {
418 nrMuchDigis=fMuchDigis->GetEntriesFast();
419 LOG(debug) << "MuchDigis: " << nrMuchDigis;
420 for (Int_t iMuch = 0; iMuch < nrMuchDigis; ++iMuch) {
421
422 CbmDigi* Digi = static_cast<CbmDigi*>(fMuchDigis->At(iMuch));
423
424 Double_t dTime = Digi->GetTime();
425 fDigiTimeEvoMuch->Fill( fNrTs, dTime );
426 }
427 }
428
429 Int_t nrTofDigis{0};
430 if (fTofDigis) {
431 nrTofDigis=fTofDigis->GetEntriesFast();
432 LOG(debug) << "TofDigis: " << nrTofDigis;
433 for (Int_t iMuch = 0; iMuch < nrTofDigis; ++iMuch) {
434
435 CbmDigi* Digi = static_cast<CbmDigi*>(fTofDigis->At(iMuch));
436
437 Double_t dTime = Digi->GetTime();
438 fDigiTimeEvoTof->Fill( fNrTs, dTime );
439 }
440 }
441*/
442 fNrTs++;
443
444 if (0 < fNrTs && 0 == fNrTs % 90000) WriteHistos();
445}
446
448{
449 LOG(debug) << "Begin";
450 Int_t nrBmonDigis = 0;
451 if (fBmonDigiVector) nrBmonDigis = fBmonDigiVector->size();
452 else if (fBmonDigiArray)
453 nrBmonDigis = fBmonDigiArray->GetEntriesFast();
454 LOG(debug) << "BmonDigis: " << nrBmonDigis;
455
456 Int_t nrStsDigis = fDigiMan->GetNofDigis(ECbmModuleId::kSts);
457 Int_t nrMuchDigis = fDigiMan->GetNofDigis(ECbmModuleId::kMuch);
458 Int_t nrTrdDigis = fDigiMan->GetNofDigis(ECbmModuleId::kTrd);
459 Int_t nrTofDigis = fDigiMan->GetNofDigis(ECbmModuleId::kTof);
460 Int_t nrRichDigis = fDigiMan->GetNofDigis(ECbmModuleId::kRich);
461 Int_t nrPsdDigis = fDigiMan->GetNofDigis(ECbmModuleId::kPsd);
462
463 /*
464 if( 0 < nrBmonDigis )
465 {
466 LOG(info) << "TS: " << fNrTs;
467 LOG(info) << "Bmon: " << nrBmonDigis;
468 LOG(info) << "STS: " << nrStsDigis;
469 LOG(info) << "MUCH: " << nrMuchDigis;
470 LOG(info) << "TRD: " << nrTrdDigis;
471 LOG(info) << "TOF: " << nrTofDigis;
472 LOG(info) << "RICH: " << nrRichDigis;
473 LOG(info) << "PSD: " << nrPsdDigis;
474 }
475*/
476 // if (nrBmonDigis < 100000) {
477 if (nrBmonDigis < 1000000) {
485
487 if (nullptr == pTsMetaData) LOG(fatal) << Form("No TS metadata found for TS %6u.", fNrTs);
488
489 for (Int_t iBmon = 0; iBmon < nrBmonDigis; ++iBmon) {
490
491 if (iBmon % 1000 == 0) LOG(debug) << "Executing entry " << iBmon;
492
493 const CbmTofDigi* BmonDigi = nullptr;
494 if (fBmonDigiVector) BmonDigi = &(fBmonDigiVector->at(iBmon));
495 else if (fBmonDigiArray)
496 BmonDigi = dynamic_cast<CbmTofDigi*>(fBmonDigiArray->At(iBmon));
497 assert(BmonDigi);
498
500 if (fuMaxTotPulserBmon < BmonDigi->GetCharge() || BmonDigi->GetCharge() < fuMinTotPulserBmon) continue;
501
502 Double_t T0Time = BmonDigi->GetTime();
503 Int_t BmonAddress = BmonDigi->GetAddress();
504
506 if (0x00005006 != BmonAddress && 0x04005006 != BmonAddress) continue;
507
508 fiBmonNb++;
509
510 fBmonAddress->Fill(BmonAddress);
511 /*
512 std::cout << Form( "Bmon pulser in TS %5d: address 0x%08X Bmon time %12.0f dt %12.0f",
513 fNrTs, BmonAddress, T0Time, T0Time - fdLastBmonDigiPulser )
514 << std::endl;
515*/
516 fBmonBmonDiff->Fill(T0Time - fdLastBmonDigiPulser);
517 fdLastBmonDigiPulser = T0Time;
518
519 fBmonChannel->Fill(BmonDigi->GetChannel());
520
521 if (nrStsDigis > 0 && nrStsDigis < 1000000 && fuMinAdcPulserSts < fuMaxAdcPulserSts)
525 if (nrMuchDigis > 0 && nrMuchDigis < 1000000 && fuMinAdcPulserMuch < fuMaxAdcPulserMuch)
529 if (nrTrdDigis > 0 && nrTrdDigis < 1000000 && fuMinChargePulserTrd < fuMaxChargePulserTrd)
531 fBmonTrdMeanEvo, nullptr, T0Time, fTrdOffsetRange,
533 if (nrTofDigis > 0 && nrTofDigis < 1000000 && fuMinTotPulserTof < fuMaxTotPulserTof)
535 fBmonTofMeanEvo, nullptr, T0Time, fTofOffsetRange,
537 if (nrRichDigis > 0 && nrRichDigis < 1000000 && fuMinTotPulserRich < fuMaxTotPulserRich)
541 if (nrPsdDigis > 0 && nrPsdDigis < 1000000 && fuMinAdcPulserPsd < fuMaxAdcPulserPsd)
543 fBmonPsdMeanEvo, nullptr, T0Time, fPsdOffsetRange,
545 }
546
549 for (Int_t iDigi = 0; iDigi < nrStsDigis; ++iDigi) {
550 const CbmStsDigi* digi = fDigiMan->Get<CbmStsDigi>(iDigi);
551
552 UInt_t uAddr = digi->GetAddress();
553 UInt_t uChan = digi->GetChannel();
554
555 if ((kuDefaultAddress != fuStsAddress && uAddr != fuStsAddress)
558 continue;
559
560 if (fuMaxAdcPulserSts < digi->GetCharge() || digi->GetCharge() < fuMinAdcPulserSts) continue;
561
562 fiStsNb++;
563 } // for( Int_t iDigi = 0; iDigi < nrStsDigis; ++iDigi )
565 for (Int_t iDigi = 0; iDigi < nrMuchDigis; ++iDigi) {
567
568 UInt_t uAsic = digi->GetNxId();
569 UInt_t uChan = digi->GetNxCh();
570
571 if ((kuMaxNbMuchAsics != fuMuchAsic && uAsic != fuMuchAsic)
572 || (kuNbChanSMX != fuMuchFirstCha && uChan < fuMuchFirstCha)
573 || (kuNbChanSMX != fuMuchLastChan && fuMuchLastChan < uChan))
574 continue;
575
576 if (fuMaxAdcPulserMuch < digi->GetCharge() || digi->GetCharge() < fuMinAdcPulserMuch) continue;
577
578 fiMuchNb++;
579 } // for( Int_t iDigi = 0; iDigi < nrMuchDigis; ++iDigi )
581 for (Int_t iDigi = 0; iDigi < nrTrdDigis; ++iDigi) {
582 const CbmTrdDigi* digi = fDigiMan->Get<CbmTrdDigi>(iDigi);
583
584 UInt_t uAddr = digi->GetAddress();
585
586 if ((kuDefaultAddress != fuTrdAddress && uAddr != fuTrdAddress)) continue;
587
588 if (fuMaxChargePulserTrd < digi->GetCharge() || digi->GetCharge() < fuMinChargePulserTrd) continue;
589
590 fiTrdNb++;
591 } // for( Int_t iDigi = 0; iDigi < nrTrdDigis; ++iDigi )
593 for (Int_t iDigi = 0; iDigi < nrTofDigis; ++iDigi) {
594 const CbmTofDigi* digi = fDigiMan->Get<CbmTofDigi>(iDigi);
595
596 if (fuMaxTotPulserTof < digi->GetCharge() || digi->GetCharge() < fuMinTotPulserTof) continue;
597
598 fiTofNb++;
599 } // for( Int_t iDigi = 0; iDigi < nrTofDigis; ++iDigi )
601 for (Int_t iDigi = 0; iDigi < nrRichDigis; ++iDigi) {
602 const CbmRichDigi* digi = fDigiMan->Get<CbmRichDigi>(iDigi);
603
604 if (fuMaxTotPulserRich < digi->GetCharge() || digi->GetCharge() < fuMinTotPulserRich) continue;
605
606 fiRichNb++;
607 } // for( Int_t iDigi = 0; iDigi < nrRichDigis; ++iDigi )
609 for (Int_t iDigi = 0; iDigi < nrPsdDigis; ++iDigi) {
610 const CbmPsdDigi* digi = fDigiMan->Get<CbmPsdDigi>(iDigi);
611
612 UInt_t uAddr = digi->GetAddress();
613
614 if ((kuDefaultAddress != fuPsdAddress && uAddr != fuPsdAddress)) continue;
615
616 if (fuMaxAdcPulserPsd < digi->GetCharge() || digi->GetCharge() < fuMinAdcPulserPsd) continue;
617
618 fiPsdNb++;
619 } // for( Int_t iDigi = 0; iDigi < nrPsdDigis; ++iDigi )
620
627
628 fiBmonNb = 0;
629 fiStsNb = 0;
630 fiMuchNb = 0;
631 fiTrdNb = 0;
632 fiTofNb = 0;
633 fiRichNb = 0;
634 fiPsdNb = 0;
635 } // if (nrBmonDigis < 1000000)
636
637 /*
638 for (Int_t iMuch = 0; iMuch < nrMuchDigis; ++iMuch) {
639
640 CbmMuchBeamTimeDigi* Digi = static_cast<CbmMuchBeamTimeDigi*>(fMuchDigis->At(iMuch));
641
642 Double_t dTime = Digi->GetTime();
643 Double_t dAdc = Digi->GetCharge();
644 UInt_t uAsic = Digi->GetNxId();
645 UInt_t uChan = Digi->GetNxCh();
646
647 Double_t dStartJump = (17633. + 1969.) * 10240000.;
648 Double_t dTimeSinceStart = dTime - dStartJump;
649 fDigisPerAsicEvo->Fill( dTimeSinceStart, uAsic );
650
651 if( 19132000. < dTimeSinceStart && dTimeSinceStart < 19600000 )
652 {
653// std::cout << Form( "Much hit in TS %5d: asic %2u chan %3u Bmon time %12.0f ADC %2.0f",
654// fNrTs, uAsic, uChan, (dTimeSinceStart - 19132000), dAdc )
655// << std::endl;
656 Double_t dTimeDistLastDigi = dTimeSinceStart - fdLastMuchDigi[ uAsic ][ uChan ];
657 fSameChanDigisDistEvo->Fill( dTimeSinceStart - 19132000,
658 dTimeDistLastDigi < 10000 ? dTimeDistLastDigi : 9999 );
659 }
660 fdLastMuchDigi[ uAsic ][ uChan ] = dTimeSinceStart;
661
662 if( ( kuMaxNbMuchAsics == fuMuchAsic && uAsic == fuMuchAsic ) &&
663 ( kuNbChanSMX == fuMuchFirstCha || uChan >= fuMuchFirstCha ) &&
664 ( kuNbChanSMX == fuMuchLastChan || fuMuchLastChan <= uChan )
665 )
666 continue;
667 if( fuMaxAdcPulserMuch < Digi->GetCharge() || Digi->GetCharge() < fuMinAdcPulserMuch )
668 continue;
669
670 if( 32 != uChan )
671 continue;
672 std::cout << Form( "Much pulser in TS %5d: chan %3u Bmon time %12.0f ADC %2.0f dt %12.0f",
673 fNrTs, uChan, dTime, dAdc, dTime - fdLastMuchDigiPulser[ uAsic ][ uChan ] )
674 << std::endl;
675 fdLastMuchDigiPulser[ uAsic ][ uChan ] = dTime;
676 }
677*/
678}
679
680template<class Digi>
681Int_t CbmMcbm2019CheckPulser::FillSystemOffsetHistos(TH1* histo, TH2* histoEvo, TH2* histoEvoLong,
682 TProfile* profMeanEvo, TH2* histoAFCK, const Double_t T0Time,
683 const Int_t offsetRange, Int_t iStartDigi, ECbmModuleId iDetId)
684{
685
686 Int_t nrDigis = fDigiMan->GetNofDigis(iDetId);
687 Int_t iFirstDigiInWin = iStartDigi;
688
689 for (Int_t i = iStartDigi; i < nrDigis; ++i) {
690
691 const Digi* digi = fDigiMan->Get<Digi>(i);
692
693 switch (iDetId) {
694 case ECbmModuleId::kSts:
695 {
696 const CbmStsDigi* stsDigi = nullptr;
697 try {
698 stsDigi = boost::any_cast<const CbmStsDigi*>(digi);
699 }
700 catch (...) {
701 LOG(fatal) << "Failed boost any_cast in "
702 "CbmMcbm2019CheckPulser::FillSystemOffsetHistos for a "
703 "digi of type "
704 << Digi::GetClassName();
705 } // try/catch
706 assert(stsDigi);
707 UInt_t uAddr = stsDigi->GetAddress();
708 UInt_t uChan = stsDigi->GetChannel();
709
710 if ((kuDefaultAddress != fuStsAddress && uAddr != fuStsAddress)
713 continue;
714
715 if (fuMaxAdcPulserSts < digi->GetCharge() || digi->GetCharge() < fuMinAdcPulserSts) continue;
716
717 fiStsNb++;
718 break;
719 } // case ECbmModuleId::kSts:
721 {
722 const CbmMuchBeamTimeDigi* muchDigi {nullptr};
723 try {
724 muchDigi = boost::any_cast<const CbmMuchBeamTimeDigi*>(digi);
725 }
726 catch (...) {
727 LOG(fatal) << "Failed boost any_cast in "
728 "CbmMcbm2019CheckPulser::FillSystemOffsetHistos for a "
729 "digi of type "
730 << Digi::GetClassName();
731 } // try/catch
732 assert(muchDigi);
733 UInt_t uAsic = muchDigi->GetNxId();
734 UInt_t uChan = muchDigi->GetNxCh();
735
736 if ((kuMaxNbMuchAsics != fuMuchAsic && uAsic != fuMuchAsic)
737 || (kuNbChanSMX != fuMuchFirstCha && uChan < fuMuchFirstCha)
738 || (kuNbChanSMX != fuMuchLastChan && fuMuchLastChan < uChan))
739 continue;
740
741 if (fuMaxAdcPulserMuch < digi->GetCharge() || digi->GetCharge() < fuMinAdcPulserMuch) continue;
742
743 fiMuchNb++;
744 break;
745 } // case ECbmModuleId::kMuch:
746 case ECbmModuleId::kTrd:
747 {
748 /*
749 const CbmTrdDigi* trdDigi;
750 try {
751 trdDigi =
752 boost::any_cast<const CbmTrdDigi*>( digi );
753 } catch( ... ) {
754 LOG( fatal ) << "Failed boost any_cast in CbmMcbm2019CheckPulser::FillSystemOffsetHistos for a digi of type "
755 << Digi::GetClassName();
756 } // try/catch
757 assert(trdDigi);
758*/
759 UInt_t uAddr = digi->GetAddress();
760
761 if ((kuDefaultAddress != fuTrdAddress && uAddr != fuTrdAddress)) continue;
762
763 if (fuMaxChargePulserTrd < digi->GetCharge() || digi->GetCharge() < fuMinChargePulserTrd) continue;
764
765 fiTrdNb++;
766 break;
767 } // case ECbmModuleId::kTrd:
768 case ECbmModuleId::kTof:
769 {
770 if (fuMaxTotPulserTof < digi->GetCharge() || digi->GetCharge() < fuMinTotPulserTof) continue;
771
772 fiTofNb++;
773 break;
774 } // case ECbmModuleId::kTof:
776 {
777 if (fuMaxTotPulserRich < digi->GetCharge() || digi->GetCharge() < fuMinTotPulserRich) continue;
778
779 fiRichNb++;
780 break;
781 } // case ECbmModuleId::kRich:
782 case ECbmModuleId::kPsd:
783 {
784 UInt_t uAddr = digi->GetAddress();
785
786 if ((kuDefaultAddress != fuPsdAddress && uAddr != fuPsdAddress)) continue;
787
788 if (fuMaxAdcPulserPsd < digi->GetCharge() || digi->GetCharge() < fuMinAdcPulserPsd) continue;
789 if (digi->GetAddress() != (9 << 10) + 8) continue;
790
791 fiPsdNb++;
792 break;
793 } // case ECbmModuleId::kPsd:
794 default: return 0;
795 } // switch( iDetId )
796
797 Double_t diffTime = T0Time - digi->GetTime();
798 // profMeanEvo->Fill( T0Time * 1e-9 - fdStartTime, diffTime );
799
800 if (diffTime > offsetRange) {
801 ++iFirstDigiInWin; // Update Index of first digi in Win to next digi
802 continue; // not yet in interesting range
803 } // if (diffTime > offsetRange)
804 if (diffTime < -offsetRange) break; // already past interesting range
805
806 histo->Fill(diffTime);
807 histoEvo->Fill(fNrTs, diffTime);
808 histoEvoLong->Fill(fNrTs, diffTime);
809
810 if (-1 == fdStartTime) fdStartTime = T0Time * 1e-9;
811 profMeanEvo->Fill(T0Time * 1e-9 - fdStartTime, diffTime);
812 /*
813 if (ECbmModuleId::kMuch == iDetId )
814 std::cout << Form( "MUCH coinc in TS %5d: %7.2f Bmon time %12.0f", fNrTs, diffTime, T0Time )
815 << std::endl;
816*/
817 if (ECbmModuleId::kPsd == iDetId) fBmonPsdDiffCharge->Fill(diffTime, digi->GetCharge());
818
820 if (ECbmModuleId::kSts == iDetId && histoAFCK) {
821 UInt_t uDPB = (0 < (digi->GetAddress() & 0x00000400));
822 histoAFCK->Fill(uDPB, diffTime);
823 if (uDPB < kuMaxNbStsDpbs) fBmonStsDpbDiffEvo[uDPB]->Fill(fNrTs, diffTime);
824 } // if (ECbmModuleId::kSts == iDetId && histoAFCK)
825
827 if (ECbmModuleId::kMuch == iDetId && histoAFCK) {
828 const CbmMuchBeamTimeDigi* muchDigi {nullptr};
829 try {
830 muchDigi = boost::any_cast<const CbmMuchBeamTimeDigi*>(digi);
831 }
832 catch (...) {
833 LOG(fatal) << "Failed boost any_cast in CbmCheckTiming::FillSystemOffsetHistos "
834 "for a digi of type "
835 << Digi::GetClassName();
836 } // try/catch
837 assert(muchDigi);
838 UInt_t afck = muchDigi->GetRocId();
839 UInt_t asic = muchDigi->GetNxId();
840 histoAFCK->Fill(afck, diffTime);
841 fBmonMuchAsicDiff->Fill(asic, diffTime);
842 if (asic < kuMaxNbMuchAsics) fBmonMuchAsicDiffEvo[asic]->Fill(fNrTs, diffTime);
843 } // if (ECbmModuleId::kMuch == iDetId && histoAFCK)
844 }
845
846 return iFirstDigiInWin;
847}
848
849// ---- Finish --------------------------------------------------------
851
853{
854 TFile* oldFile = gFile;
855 TDirectory* oldDir = gDirectory;
856
857 TFile* outfile = TFile::Open(fOutFileName, "RECREATE");
858
859 fBmonStsDiff->Write();
860 fBmonMuchDiff->Write();
861 fBmonTrdDiff->Write();
862 fBmonTofDiff->Write();
863 fBmonRichDiff->Write();
864 fBmonPsdDiff->Write();
865 fBmonPsdDiffCharge->Write();
866
867 fBmonStsDiffEvo->Write();
868 fBmonMuchDiffEvo->Write();
869 fBmonTrdDiffEvo->Write();
870 fBmonTofDiffEvo->Write();
871 fBmonRichDiffEvo->Write();
872 fBmonPsdDiffEvo->Write();
873
874 fBmonStsDiffEvoLong->Write();
875 fBmonMuchDiffEvoLong->Write();
876 fBmonTrdDiffEvoLong->Write();
877 fBmonTofDiffEvoLong->Write();
878 fBmonRichDiffEvoLong->Write();
879 fBmonPsdDiffEvoLong->Write();
880
881 fBmonStsMeanEvo->Write();
882 fBmonMuchMeanEvo->Write();
883 fBmonTrdMeanEvo->Write();
884 fBmonTofMeanEvo->Write();
885 fBmonRichMeanEvo->Write();
886 fBmonPsdMeanEvo->Write();
887
888 fBmonBmonDiff->Write();
889 fStsStsDiff->Write();
890 fMuchMuchDiff->Write();
891 fTrdTrdDiff->Write();
892 fTofTofDiff->Write();
893 fRichRichDiff->Write();
894 fPsdPsdDiff->Write();
895
896 fBmonStsNb->Write();
897 fBmonMuchNb->Write();
898 fBmonTrdNb->Write();
899 fBmonTofNb->Write();
900 fBmonRichNb->Write();
901 fBmonPsdNb->Write();
902
903 fBmonAddress->Write();
904 fBmonChannel->Write();
905
906 fBmonStsDpbDiff->Write();
907 /*
908 for( UInt_t uStsDpb = 0; uStsDpb < kuMaxNbStsDpbs; ++uStsDpb )
909 {
910 fBmonStsDpbDiffEvo[uStsDpb]->Write();
911 fStsDpbCntsEvo[uStsDpb]->Write();
912 }
913*/
914 fBmonMuchRocDiff->Write();
915 fBmonMuchAsicDiff->Write();
916 /*
917 for( UInt_t uMuchAsic = 0; uMuchAsic < kuMaxNbMuchAsics; ++uMuchAsic )
918 fBmonMuchAsicDiffEvo[uMuchAsic]->Write();
919*/
920 /*
921 fDigisPerAsicEvo->Write();
922 fSameChanDigisDistEvo->Write();
923
924 fDigiTimeEvoBmon ->Write();
925 fDigiTimeEvoSts ->Write();
926 fDigiTimeEvoMuch->Write();
927 fDigiTimeEvoTof->Write();
928*/
929 outfile->Close();
930 delete outfile;
931
932 gFile = oldFile;
933 gDirectory = oldDir;
934}
935
ClassImp(CbmConverterManager)
ECbmModuleId
Definition CbmDefs.h:39
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kPsd
Projectile spectator detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
@ kRich
Ring-Imaging Cherenkov Detector.
std::vector< double > GenerateLogBinArray(uint32_t uNbDecadesLog, uint32_t uNbStepsDecade, uint32_t uNbSubStepsInStep, uint32_t &uNbBinsLog, int32_t iStartExp, bool bAddZeroStart)
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
void UseMuchBeamTimeDigi(Bool_t)
Use CbmMuchBeamTimeDigi instead of CbmMuchDigi for MUCH.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
static const UInt_t kuNbChanSMX
Constants.
const std::vector< CbmTofDigi > * fBmonDigiVector
const TimesliceMetaData * pTsMetaData
static const UInt_t kuMaxNbMuchDpbs
static const UInt_t kuMaxNbMuchAsics
static const UInt_t kuMaxChannelSts
TH1 * fStsDpbCntsEvo[kuMaxNbStsDpbs]
TH2 * fBmonStsDpbDiffEvo[kuMaxNbStsDpbs]
Int_t FillSystemOffsetHistos(TH1 *histo, TH2 *histoEvo, TH2 *histoEvoLong, TProfile *profMeanEvo, TH2 *histoAFCK, const Double_t T0Time, const Int_t offsetRange, Int_t iStartDigi, ECbmModuleId iDetId=ECbmModuleId::kLastModule)
static const UInt_t kuMaxNbStsDpbs
UInt_t fuStsAddress
Channel selection.
TH2 * fBmonMuchAsicDiffEvo[kuMaxNbMuchAsics]
static const UInt_t kuDefaultAddress
virtual void Exec(Option_t *)
double GetCharge() const
Charge.
Definition CbmMuchDigi.h:69
Data class for PSD digital information.
Definition CbmPsdDigi.h:36
uint32_t GetAddress() const
Address.
Definition CbmPsdDigi.h:93
double GetCharge() const
Charge.
Definition CbmPsdDigi.h:113
double GetCharge() const
Charge.
Definition CbmRichDigi.h:56
Data class for a single-channel message in the STS.
Definition CbmStsDigi.h:40
XPU_D uint16_t GetChannel() const
Channel number in module @value Channel number.
Definition CbmStsDigi.h:93
XPU_D int32_t GetAddress() const
Definition CbmStsDigi.h:74
Data class for expanded digital TOF information.
Definition CbmTofDigi.h:47
double GetChannel() const
Channel .
Definition CbmTofDigi.h:156
int32_t GetAddress() const
Inherited from CbmDigi.
Definition CbmTofDigi.h:112
double GetTime() const
Inherited from CbmDigi.
Definition CbmTofDigi.h:131
double GetCharge() const
Inherited from CbmDigi.
Definition CbmTofDigi.h:136
int32_t GetAddress() const
Address getter for module in the format defined by CbmTrdDigi (format of CbmTrdAddress can be accesse...
Definition CbmTrdDigi.h:112
double GetCharge() const
Common purpose charge getter.