19 #include "FairLogger.h"
20 #include "FairRootManager.h"
21 #include "FairRunOnline.h"
23 #include "TClonesArray.h"
26 #include "THttpServer.h"
33 #include <type_traits>
35 using std::setprecision;
39 : FairTask(
"CbmMcbm2019CheckPulser") {}
60 FairRootManager* ioman = FairRootManager::Instance();
69 fT0DigiVector = ioman->InitObjectAs<std::vector<CbmTofDigi>
const*>(
"T0Digi");
71 LOG(info) <<
"No T0 digi vector found; trying TClonesArray";
72 if (std::is_convertible<TObject*, CbmTofDigi*>::value) {
73 fT0DigiArray =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"T0Digi"));
74 if (!
fT0DigiArray) LOG(info) <<
"No T0 digi input found.";
79 LOG(info) <<
"No STS digi input found.";
83 LOG(info) <<
"No MUCH digi input found.";
87 LOG(info) <<
"No TRD digi input found.";
92 LOG(info) <<
"No TOF digi input found.";
96 LOG(info) <<
"No RICH digi input found.";
100 LOG(info) <<
"No PSD digi input found.";
105 dynamic_cast<TClonesArray*
>(ioman->GetObject(
"TimesliceMetaData"));
115 if (offsetRange < 251) {
116 Double_t dClocks = offsetRange;
118 return (dClocks * 112 * 2);
119 }
else if (offsetRange < 501) {
121 }
else if (offsetRange < 1001) {
123 }
else if (offsetRange < 10001) {
125 }
else if (offsetRange < 100001) {
136 uint32_t iNbBinsLog = 0;
139 double* dBinsLog = dBinsLogVector.data();
145 "T0-Sts;time diff [ns];Counts",
151 "T0-Sts;TS; time diff [ns];Counts",
163 "T0-Much;time diff [ns];Counts",
169 "T0-Much;TS; time diff [ns];Counts",
181 "T0-Trd;time diff [ns];Counts",
187 "T0-Trd;TS; time diff [ns];Counts",
199 "T0-Tof;time diff [ns];Counts",
205 "T0-Tof;TS; time diff [ns];Counts",
217 "T0-Rich;time diff [ns];Counts",
223 "T0-Rich;TS; time diff [ns];Counts",
234 "T0-Psd;time diff [ns];Counts",
240 "T0-Psd;TS; time diff [ns];Counts",
249 "T0-Psd;time diff [ns]; Charge [a.u]; ;Counts",
260 "T0-Sts;TS; time diff [ns];Counts",
269 "T0-Much;TS; time diff [ns];Counts",
278 "T0-Trd;TS; time diff [ns];Counts",
287 "T0-Tof;TS; time diff [ns];Counts",
296 "T0-Rich;TS; time diff [ns];Counts",
306 "T0-Psd;TS; time diff [ns];Counts",
317 "T0-Sts; time in run [s]; Mean time diff [ns]",
323 "T0-Much; time in run [s]; Mean time diff [ns]",
329 "T0-Trd; time in run [s]; Mean time diff [ns]",
335 "T0-Tof; time in run [s]; Mean time diff [ns]",
341 "T0-Rich; time in run [s]; Mean time diff [ns]",
347 "T0-Psd; time in run [s]; Mean time diff [ns]",
356 "T0-Much;DPB; time diff [ns];Counts",
366 new TH2F(Form(
"fT0StsDpbDiffEvo%02u", uStsDpb),
367 Form(
"T0-STS DPB %02u;TS; time diff [ns];Counts", uStsDpb),
375 new TH1F(Form(
"fStsDpbCntsEvo%02u", uStsDpb),
376 Form(
"Time STS DPB %02u;TS; Hit Counts", uStsDpb),
384 "T0-Much;AFCK; time diff [ns];Counts",
394 "T0-Much;ASIC; time diff [ns];Counts",
404 new TH2F(Form(
"fT0MuchAsicDiffEvo%02u", uMuchAsic),
405 Form(
"T0-Much ASIC %02u;TS; time diff [ns];Counts", uMuchAsic),
415 "fT0T0Diff",
"T0-T0_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
418 "fStsStsDiff",
"Sts-Sts_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
421 "Much-Much_prev;time diff [ns];Counts",
426 "fTrdTrdDiff",
"Trd-Trd_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
429 "fTofTofDiff",
"Tof-Tof_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
432 "Rich-Rich_prev;time diff [ns];Counts",
437 "fPsdPsdDiff",
"Psd-Psd_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
441 "fT0StsNb",
"T0-STS;Nb T0; Nb STS;TS []", 100, 0, 100, 100, 0, 100);
443 "fT0MuchNb",
"T0-MUCH;Nb T0; Nb MUCH;TS []", 100, 0, 100, 100, 0, 100);
445 "fT0TrdNb",
"T0-TRD;Nb T0; Nb TRD;TS []", 100, 0, 100, 100, 0, 100);
447 "fT0TofNb",
"T0-TOF;Nb T0; Nb TOF;TS []", 100, 0, 100, 100, 0, 100);
449 "fT0RichNb",
"T0-RICH;Nb T0; Nb RICH;TS []", 100, 0, 100, 100, 0, 100);
451 "fT0PsdNb",
"T0-PSD;Nb T0; Nb PSD;TS []", 100, 0, 100, 100, 0, 100);
454 new TH1F(
"fT0Address",
"T0 address;address;Counts", 1000000, 0, 1000000.);
457 new TH1F(
"fT0Channel",
"T0 channel;channel nr;Counts", 100, -0.5, 99.5);
463 FairRunOnline* run = FairRunOnline::Instance();
465 THttpServer* server = run->GetHttpServer();
466 if (
nullptr != server) {
493 server->Register(
"/CheckTiming",
fT0T0Diff);
501 server->Register(
"/CheckTiming",
fT0StsNb);
502 server->Register(
"/CheckTiming",
fT0MuchNb);
503 server->Register(
"/CheckTiming",
fT0TrdNb);
504 server->Register(
"/CheckTiming",
fT0TofNb);
505 server->Register(
"/CheckTiming",
fT0RichNb);
506 server->Register(
"/CheckTiming",
fT0PsdNb);
558 LOG(debug) <<
"executing TS " <<
fNrTs;
561 LOG(info) << Form(
"Processing TS %6d",
fNrTs);
626 LOG(debug) <<
"Begin";
632 LOG(debug) <<
"T0Digis: " << nrT0Digis;
655 if (nrT0Digis < 1000000) {
667 LOG(fatal) << Form(
"No TS metadata found for TS %6u.",
fNrTs);
669 for (Int_t iT0 = 0; iT0 < nrT0Digis; ++iT0) {
671 if (iT0 % 1000 == 0) LOG(debug) <<
"Executing entry " << iT0;
681 if (fuMaxTotPulserT0 < T0Digi->GetCharge()
685 Double_t T0Time = T0Digi->
GetTime();
689 if (0x00005006 != T0Address && 0x04005006 != T0Address)
continue;
704 if (nrStsDigis > 0 && nrStsDigis < 1000000
707 FillSystemOffsetHistos<CbmStsDigi>(
fT0StsDiff,
716 if (nrMuchDigis > 0 && nrMuchDigis < 1000000
719 FillSystemOffsetHistos<CbmMuchBeamTimeDigi>(
fT0MuchDiff,
728 if (nrTrdDigis > 0 && nrTrdDigis < 1000000
731 FillSystemOffsetHistos<CbmTrdDigi>(
fT0TrdDiff,
740 if (nrTofDigis > 0 && nrTofDigis < 1000000
743 FillSystemOffsetHistos<CbmTofDigi>(
fT0TofDiff,
752 if (nrRichDigis > 0 && nrRichDigis < 1000000
764 if (nrPsdDigis > 0 && nrPsdDigis < 1000000
767 FillSystemOffsetHistos<CbmPsdDigi>(
fT0PsdDiff,
780 for (Int_t iDigi = 0; iDigi < nrStsDigis; ++iDigi) {
791 if (fuMaxAdcPulserSts < digi->GetCharge()
798 for (Int_t iDigi = 0; iDigi < nrMuchDigis; ++iDigi) {
802 UInt_t uAsic = digi->
GetNxId();
803 UInt_t uChan = digi->
GetNxCh();
810 if (fuMaxAdcPulserMuch < digi->GetCharge()
817 for (Int_t iDigi = 0; iDigi < nrTrdDigis; ++iDigi) {
824 if (fuMaxChargePulserTrd < digi->GetCharge()
831 for (Int_t iDigi = 0; iDigi < nrTofDigis; ++iDigi) {
834 if (fuMaxTotPulserTof < digi->GetCharge()
841 for (Int_t iDigi = 0; iDigi < nrRichDigis; ++iDigi) {
844 if (fuMaxTotPulserRich < digi->GetCharge()
851 for (Int_t iDigi = 0; iDigi < nrPsdDigis; ++iDigi) {
858 if (fuMaxAdcPulserPsd < digi->GetCharge()
928 TProfile* profMeanEvo,
930 const Double_t T0Time,
931 const Int_t offsetRange,
936 Int_t iFirstDigiInWin = iStartDigi;
938 for (Int_t
i = iStartDigi;
i < nrDigis; ++
i) {
947 stsDigi = boost::any_cast<const CbmStsDigi*>(digi);
949 LOG(fatal) <<
"Failed boost any_cast in "
950 "CbmMcbm2019CheckPulser::FillSystemOffsetHistos for a "
952 << Digi::GetClassName();
963 if (fuMaxAdcPulserSts < digi->GetCharge()
974 muchDigi = boost::any_cast<const CbmMuchBeamTimeDigi*>(digi);
976 LOG(fatal) <<
"Failed boost any_cast in "
977 "CbmMcbm2019CheckPulser::FillSystemOffsetHistos for a "
979 << Digi::GetClassName();
982 UInt_t uAsic = muchDigi->GetNxId();
983 UInt_t uChan = muchDigi->GetNxCh();
990 if (fuMaxAdcPulserMuch < digi->GetCharge()
1010 UInt_t uAddr = digi->GetAddress();
1015 if (fuMaxChargePulserTrd < digi->GetCharge()
1024 if (fuMaxTotPulserTof < digi->GetCharge()
1033 if (fuMaxTotPulserRich < digi->GetCharge()
1042 UInt_t uAddr = digi->GetAddress();
1047 if (fuMaxAdcPulserPsd < digi->GetCharge()
1050 if (digi->GetAddress() != (9 << 10) + 8)
continue;
1058 Double_t diffTime = T0Time - digi->GetTime();
1061 if (diffTime > offsetRange) {
1065 if (diffTime < -offsetRange)
break;
1067 histo->Fill(diffTime);
1068 histoEvo->Fill(
fNrTs, diffTime);
1069 histoEvoLong->Fill(
fNrTs, diffTime);
1072 profMeanEvo->Fill(T0Time * 1e-9 -
fdStartTime, diffTime);
1083 UInt_t uDPB = (0 < (digi->GetAddress() & 0x00000400));
1084 histoAFCK->Fill(uDPB, diffTime);
1092 muchDigi = boost::any_cast<const CbmMuchBeamTimeDigi*>(digi);
1095 <<
"Failed boost any_cast in CbmCheckTiming::FillSystemOffsetHistos "
1096 "for a digi of type "
1097 << Digi::GetClassName();
1100 UInt_t afck = muchDigi->GetRocId();
1101 UInt_t asic = muchDigi->GetNxId();
1102 histoAFCK->Fill(afck, diffTime);
1109 return iFirstDigiInWin;
1117 TFile* outfile = TFile::Open(
fOutFileName,
"RECREATE");