19 #include "FairLogger.h"
20 #include "FairRootManager.h"
21 #include "FairRunOnline.h"
23 #include "TClonesArray.h"
26 #include "THttpServer.h"
32 using std::setprecision;
56 FairRootManager* ioman = FairRootManager::Instance();
62 fT0DigiVec = ioman->InitObjectAs<std::vector<CbmTofDigi>
const*>(
"T0Digi");
64 fT0DigiArr =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"T0Digi"));
65 if (!
fT0DigiArr) { LOG(fatal) <<
"No TClonesArray with T0 digis found."; }
69 LOG(info) <<
"No STS digis found.";
73 LOG(info) <<
"No MUCH digis found.";
77 LOG(info) <<
"No TRD digis found.";
81 LOG(info) <<
"No TOF digis found.";
85 LOG(info) <<
"No RICH digis found.";
89 LOG(info) <<
"No PSD digis found.";
99 if (offsetRange < 1001) {
101 }
else if (offsetRange < 10001) {
103 }
else if (offsetRange < 100001) {
109 if ((
static_cast<Double_t
>(offsetRange) / 6.25) == (offsetRange / 6.25))
110 return (offsetRange / 6.25 * 2);
117 uint32_t iNbBinsLog = 0;
120 double* dBinsLog = dBinsLogVector.data();
126 "Sts-T0;time diff [ns];Counts",
132 "Sts-T0;time diff [ns]; Charge [a.u]; Counts",
141 "Sts-T0;TS; time diff [ns];Counts",
153 "Much-T0;time diff [ns];Counts",
159 "Much-T0;time diff [ns]; Charge [a.u]; ;Counts",
168 "Much-T0;TS; time diff [ns];Counts",
179 "Trd-T0;time diff [ns];Counts",
185 "Trd-T0;time diff [ns]; Charge [a.u]; ;Counts",
194 "Trd-T0;TS; time diff [ns];Counts",
205 "Tof-T0;time diff [ns];Counts",
211 "Tof-T0;time diff [ns]; Charge [a.u]; ;Counts",
220 "Tof-T0;TS; time diff [ns];Counts",
232 "Rich-T0;time diff [ns];Counts",
238 "Rich-T0;time diff [ns]; Charge [a.u]; ;Counts",
247 "Rich-T0;TS; time diff [ns];Counts",
258 "Psd-T0;time diff [ns];Counts",
264 "Psd-T0;time diff [ns]; Charge [a.u]; ;Counts",
273 "Psd-T0;TS; time diff [ns];Counts",
283 "Sts-T0;TS; time diff [ns];Counts",
292 "Much-T0;TS; time diff [ns];Counts",
301 "Trd-T0;TS; time diff [ns];Counts",
310 "Tof-T0;TS; time diff [ns];Counts",
319 "Rich-T0;TS; time diff [ns];Counts",
329 "Psd-T0;TS; time diff [ns];Counts",
339 "Much-T0;DPB; time diff [ns];Counts",
349 new TH2F(Form(
"fT0StsDpbDiffEvo%02u", uStsDpb),
350 Form(
"Sts-T0 DPB %02u;TS; time diff [ns];Counts", uStsDpb),
358 new TH1F(Form(
"fStsDpbCntsEvo%02u", uStsDpb),
359 Form(
"Time STS DPB %02u;TS; Hit Counts", uStsDpb),
367 "Much-T0;AFCK; time diff [ns];Counts",
377 "Much-T0;ASIC; time diff [ns];Counts",
387 new TH2F(Form(
"fT0MuchAsicDiffEvo%02u", uMuchAsic),
388 Form(
"Much-T0 ASIC %02u;TS; time diff [ns];Counts", uMuchAsic),
398 "fT0T0Diff",
"T0-T0_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
401 "fStsStsDiff",
"Sts-Sts_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
404 "Much-Much_prev;time diff [ns];Counts",
409 "fTrdTrdDiff",
"Trd-Trd_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
412 "fTofTofDiff",
"Tof-Tof_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
415 "Rich-Rich_prev;time diff [ns];Counts",
420 "fPsdPsdDiff",
"Psd-Psd_prev;time diff [ns];Counts", iNbBinsLog, dBinsLog);
423 new TH1F(
"fT0Address",
"T0 address;address;Counts", 1000000, 0, 1000000.);
426 new TH1F(
"fT0Channel",
"T0 channel;channel nr;Counts", 100, -0.5, 99.5);
429 new TH1F(
"fSelT0StsDiff",
430 "Sts-T0 if T0 in coinc with TOF;time diff [ns];Counts",
435 new TH1F(
"fSelT0MuchDiff",
436 "Much-T0 if T0 in coinc with TOF;time diff [ns];Counts",
441 new TH1F(
"fSelT0TrdDiff",
442 "Trd-T0 if T0 in coinc with TOF;time diff [ns];Counts",
447 new TH1F(
"fSelT0TofDiff",
448 "Tof-T0 if T0 in coinc with TOF;time diff [ns];Counts",
453 new TH1F(
"fSelT0RichDiff",
454 "Rich-T0 if T0 in coinc with TOF;time diff [ns];Counts",
459 new TH1F(
"fSelT0PsdDiff",
460 "Psd-T0 if T0 in coinc with TOF;time diff [ns];Counts",
469 FairRunOnline* run = FairRunOnline::Instance();
471 THttpServer* server = run->GetHttpServer();
472 if (
nullptr != server) {
497 server->Register(
"/CheckTiming",
fT0T0Diff);
528 LOG(debug) <<
"executing TS " <<
fNrTs;
539 LOG(debug) <<
"Begin";
545 LOG(debug) <<
"T0Digis: " << nrT0Digis;
547 Int_t nrStsDigis {0};
550 LOG(debug) <<
"StsDigis: " << nrStsDigis;
553 Int_t nrMuchDigis {0};
556 LOG(debug) <<
"MuchDigis: " << nrMuchDigis;
559 Int_t nrTrdDigis {0};
562 LOG(debug) <<
"TrdDigis: " << nrTrdDigis;
565 Int_t nrTofDigis {0};
568 LOG(debug) <<
"TofDigis: " << nrTofDigis;
571 Int_t nrRichDigis {0};
574 LOG(debug) <<
"RichDigis: " << nrRichDigis;
577 Int_t nrPsdDigis {0};
580 LOG(debug) <<
"PsdDigis: " << nrPsdDigis;
584 if (nrT0Digis < 1000000) {
595 for (Int_t iT0 = 0; iT0 < nrT0Digis; ++iT0) {
597 if (iT0 % 1000 == 0) LOG(debug) <<
"Executing entry " << iT0;
607 if (fuMinTotPulserT0 < T0Digi->GetCharge()
611 Double_t T0Time = T0Digi->
GetTime();
617 if (nrStsDigis > 0 && nrStsDigis < 1000000)
619 FillSystemOffsetHistos<CbmStsDigi>(
fT0StsDiff,
633 if (nrMuchDigis > 0 && nrMuchDigis < 1000000)
635 FillSystemOffsetHistos<CbmMuchBeamTimeDigi>(
fT0MuchDiff,
647 if (nrTrdDigis > 0 && nrTrdDigis < 1000000)
649 FillSystemOffsetHistos<CbmTrdDigi>(
fT0TrdDiff,
662 if (nrTofDigis > 0 && nrTofDigis < 1000000)
664 FillSystemOffsetHistos<CbmTofDigi>(
fT0TofDiff,
676 if (nrRichDigis > 0 && nrRichDigis < 1000000)
690 if (nrPsdDigis > 0 && nrPsdDigis < 1000000)
692 FillSystemOffsetHistos<CbmPsdDigi>(
fT0PsdDiff,
718 if (nrStsDigis > 0 && nrStsDigis < 1000000)
730 if (nrMuchDigis > 0 && nrMuchDigis < 1000000)
740 if (nrTrdDigis > 0 && nrTrdDigis < 1000000)
750 if (nrTofDigis > 0 && nrTofDigis < 1000000)
760 if (nrRichDigis > 0 && nrRichDigis < 1000000)
770 if (nrPsdDigis > 0 && nrPsdDigis < 1000000)
790 const Double_t T0Time,
791 const Int_t offsetRange,
798 Int_t iFirstDigiInWin = iStartDigi;
800 for (Int_t
i = iStartDigi;
i < nrDigis; ++
i) {
806 if (fuMinTotPulserTof < digi->GetCharge()
828 Double_t diffTime = digi->GetTime() - T0Time;
830 if (diffTime < -offsetRange) {
834 if (diffTime > offsetRange)
break;
835 histo->Fill(diffTime);
836 histoCharge->Fill(diffTime, digi->GetCharge());
837 histoEvo->Fill(
fNrTs, diffTime);
838 histoEvoLong->Fill(
fNrTs, diffTime);
841 if (bSts && histoAFCK) {
842 UInt_t uDPB = (0 < (digi->GetAddress() & 0x00000400));
843 histoAFCK->Fill(uDPB, diffTime);
848 if (bMuch && histoAFCK) {
851 muchDigi = boost::any_cast<const CbmMuchBeamTimeDigi*>(digi);
854 <<
"Failed boost any_cast in CbmCheckTiming::FillSystemOffsetHistos "
855 "for a digi of type "
856 << Digi::GetClassName();
860 UInt_t asic = muchDigi->
GetNxId();
861 histoAFCK->Fill(afck, diffTime);
871 return iFirstDigiInWin;
876 const Double_t T0Time,
877 const Int_t offsetRange,
884 Int_t iFirstDigiInWin = iStartDigi;
886 for (Int_t
i = iStartDigi;
i < nrDigis; ++
i) {
892 if (fuMinTotPulserTof < digi->GetCharge()
914 Double_t diffTime = digi->GetTime() - T0Time;
916 if (diffTime < -offsetRange) {
920 if (diffTime > offsetRange)
break;
921 histo->Fill(diffTime);
924 return iFirstDigiInWin;
943 for (Int_t
i = 0;
i < nrStsDigis; ++
i) {
945 UInt_t uDPB = (0 < (Digi->
GetAddress() & 0x00000400));
985 Int_t nrOfErrors = 0;
988 for (Int_t
i = 0;
i < nrDigis; ++
i) {
992 Double_t diffTime = digi->GetTime() - prevTime;
993 histo->Fill(diffTime);
996 LOG(info) << fixed << setprecision(15) << diffTime <<
"ns";
997 LOG(info) <<
"Previous " << detector <<
" digi (" << fixed
998 << setprecision(15) << prevTime * 1.e-9
999 <<
") has a larger time than the current one ("
1000 << digi->GetTime() * 1.e-9 <<
") for digi " <<
i <<
" of ts "
1005 prevTime = digi->GetTime();
1016 Int_t nrOfErrors = 0;
1024 for (Int_t
i = 0;
i < nrDigis; ++
i) {
1036 Double_t diffTime = digi->
GetTime() - prevTime;
1037 histo->Fill(diffTime);
1039 if (diffTime < 0.) {
1040 LOG(info) << fixed << setprecision(15) << diffTime <<
"ns";
1041 LOG(info) <<
"Previous " << detector <<
" digi (" << fixed
1042 << setprecision(15) << prevTime * 1.e-9
1043 <<
") has a larger time than the current one ("
1044 << digi->
GetTime() * 1.e-9 <<
") for digi " <<
i <<
" of ts "
1059 LOG(info) <<
"Total number of T0 out of order digis: " <<
fNrOfT0Errors;
1060 LOG(info) <<
"Total number of T0 digis: " <<
fNrOfT0Digis;
1061 LOG(info) <<
"Total number of Sts out of order digis: " <<
fNrOfStsErrors;
1062 LOG(info) <<
"Total number of Sts digis: " <<
fNrOfStsDigis;
1063 LOG(info) <<
"Total number of Much out of order digis: " <<
fNrOfMuchErrors;
1065 LOG(info) <<
"Total number of Trd out of order digis: " <<
fNrOfTrdErrors;
1066 LOG(info) <<
"Total number of Trd digis: " <<
fNrOfTrdDigis;
1067 LOG(info) <<
"Total number of Tof out of order digis: " <<
fNrOfTofErrors;
1068 LOG(info) <<
"Total number of Tof digis: " <<
fNrOfTofDigis;
1069 LOG(info) <<
"Total number of Rich out of order digis: " <<
fNrOfRichErrors;
1071 LOG(info) <<
"Total number of Psd out of order digis: " <<
fNrOfPsdErrors;
1072 LOG(info) <<
"Total number of Psd digis: " <<
fNrOfPsdDigis;
1076 LOG(info) << Form(
"Checked %6d Timeslices",
fNrTs);
1081 TFile* outfile = TFile::Open(
fOutFileName,
"RECREATE");