19 #include "FairLogger.h"
20 #include "FairRootManager.h"
22 #include "FairRunOnline.h"
23 #include "FairRuntimeDb.h"
26 #include "TClonesArray.h"
28 #include "THttpServer.h"
58 , fvMsComponentsListSts()
59 , fvMsComponentsListTof()
62 , fbIgnoreOverlapMs(kFALSE)
63 , fUnpackParSts(nullptr)
65 , fmStsDpbIdIndexMap()
67 , fUnpackParTof(nullptr)
69 , fmTofDpbIdIndexMap()
72 , fdStsTofOffsetNs(0.0)
73 , fdMuchTofOffsetNs(0.0)
74 , fsHistoFileFullname(
"data/mCBMsyncHistos.root")
75 , fbPrintMessages(kFALSE)
80 , fuCurrentEquipmentId(0)
83 , fiRunStartDateTimeSec(-1)
84 , fiBinSizeDatePlots(-1)
85 , fvulStsCurrentTsMsb()
86 , fvuStsCurrentTsMsbCycle()
87 , fvmStsSdpbHitsInMs()
88 , fvmStsSdpbHitsInTs()
89 , fulTofCurrentTsIndex(0)
96 , fvulTofCurrentEpoch()
97 , fvulTofCurrentEpochCycle()
98 , fvulTofCurrentEpochFull()
99 , fulTofCurrentEpochTime(0)
100 , fvmTofEpSupprBuffer()
101 , fvmTofGdpbHitsInMs()
102 , fvmTofGdpbHitsInTs()
103 , fvuHitsNbInTimeBinSts(kuNbTimeBins, 0)
104 , fvuHitsNbInTimeBinMuch(kuNbTimeBins, 0)
105 , fvuHitsNbInTimeBinTof(kuNbTimeBins, 0)
106 , fvuHitsNbInTimeBinDiam(kuNbTimeBins, 0)
107 , fhMcbmHitsNbPerTsEvo()
108 , fhMcbmHitsNbFineEvo()
109 , fhMcbmHitsRateEvo()
110 , fhDiamondHitsRateMapEvo()
111 , fhDiamondHitsRateDerivative()
112 , fhMuchVsStsHitsNbPerTimeBin()
113 , fhTofVsStsHitsNbPerTimeBin()
114 , fhDiamVsStsHitsNbPerTimeBin()
115 , fhStsVsMuchHitsNbPerTimeBin()
116 , fhTofVsMuchHitsNbPerTimeBin()
117 , fhDiamVsMuchHitsNbPerTimeBin()
118 , fhStsVsTofHitsNbPerTimeBin()
119 , fhMuchVsTofHitsNbPerTimeBin()
120 , fhDiamVsTofHitsNbPerTimeBin()
121 , fhStsVsDiamHitsNbPerTimeBin()
122 , fhTofVsDiamHitsNbPerTimeBin()
123 , fhMuchVsDiamHitsNbPerTimeBin() {}
128 LOG(info) <<
"Initializing flib StsXyter unpacker for STS";
130 FairRootManager* ioman = FairRootManager::Instance();
131 if (ioman ==
nullptr) { LOG(fatal) <<
"No FairRootManager instance"; }
137 LOG(info) <<
"Setting parameter containers for " << GetName();
140 "CbmMcbm2018StsPar"));
143 "CbmMcbm2018TofPar"));
148 LOG(info) <<
"Init parameter containers for " << GetName();
159 LOG(info) <<
"ReInit parameter containers for " << GetName();
168 LOG(info) <<
"Eq. ID for DPB #" << std::setw(2) << uDpb <<
" = 0x"
170 << std::dec <<
" => "
187 LOG(info) <<
"GDPB Id of TOF " <<
i <<
" : " << std::hex
204 UShort_t usDetectorId) {
205 switch (usDetectorId) {
217 LOG(warning) <<
"CbmMcbm2018MonitorStsSync::AddMsComponentToList => "
218 <<
"Ignore component " << component <<
" as detector id "
219 << usDetectorId <<
" is not supported by this unpacker.";
241 size_t uOverlapMsNb) {
250 TString sHistName {
""};
308 LOG(info) <<
"Done Creating STS Histograms";
314 TString sHistName {
""};
380 LOG(info) <<
"Done Creating TOF Histograms";
386 TString sHistName {
""};
387 TString sHistTitle {
""};
391 sHistName =
"hMcbmHitsNbPerTsEvo";
393 "Nb STS or TOF hits, per DPB and per TS; TS index []; DPB []; Nb Hits []";
403 sHistName =
"hMcbmHitsNbFineEvo";
405 "Nb STS or TOF hits, per DPB and per 100 ms; t [s]; DPB []; Hit rate [1/s]";
415 sHistName =
"hMcbmHitsRateEvo";
416 sHistTitle =
"STS or TOF hits rate per DPB as function of time in run; t "
417 "[s]; DPB []; Hit rate [1/s]";
427 sHistName =
"hDiamondHitsRateMapEvo";
428 sHistTitle =
"Counts per diamond strip and 100 ms as function of time in "
429 "run; t [s]; strip []; Counts []";
431 new TH2D(sHistName, sHistTitle, 40001, -0.05, 4000.05, 8, 0., 8.);
433 sHistName =
"hDiamondHitsRateDerivative";
434 sHistTitle =
"Variation of the diamond counts per s in 100 ms bins as "
435 "function of time in run; t [s]; Delta(Counts/s) []";
437 new TH1D(sHistName, sHistTitle, 40000, 0., 4000.);
439 sHistName =
"hMuchVsStsHitsNbPerTimeBin";
440 sHistTitle = Form(
"Nb Hits in MUCH vs Sts in time bins of %5u ns; Nb Hits "
441 "STS []; Nb Hits TOF []; Time bins []",
444 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
445 sHistName =
"hTofVsStsHitsNbPerTimeBin";
446 sHistTitle = Form(
"Nb Hits in TOF vs Sts in time bins of %5u ns; Nb Hits STS "
447 "[]; Nb Hits MUCH []; Time bins []",
450 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
451 sHistName =
"hDiamVsStsHitsNbPerTimeBin";
452 sHistTitle = Form(
"Nb Hits in Diam vs Sts in time bins of %5u ns; Nb Hits "
453 "STS []; Nb Hits Diam []; Time bins []",
456 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
458 sHistName =
"hStsVsMuchHitsNbPerTimeBin";
459 sHistTitle = Form(
"Nb Hits in STS vs MUCH in time bins of %5u ns; Nb Hits "
460 "MUCH []; Nb Hits STS []; Time bins []",
463 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
464 sHistName =
"hTofVsMuchHitsNbPerTimeBin";
465 sHistTitle = Form(
"Nb Hits in TOF vs MUCH in time bins of %5u ns; Nb Hits "
466 "MUCH []; Nb Hits TOF []; Time bins []",
469 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
470 sHistName =
"hDiamVsMuchHitsNbPerTimeBin";
471 sHistTitle = Form(
"Nb Hits in Diam vs MUCH in time bins of %5u ns; Nb Hits "
472 "MUCH []; Nb Hits Diam []; Time bins []",
475 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
477 sHistName =
"hStsVsTofHitsNbPerTimeBin";
478 sHistTitle = Form(
"Nb Hits in STS vs TOF in time bins of %5u ns; Nb Hits TOF "
479 "[]; Nb Hits STS []; Time bins []",
482 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
483 sHistName =
"hMuchVsTofHitsNbPerTimeBin";
484 sHistTitle = Form(
"Nb Hits in MUCH vs TOF in time bins of %5u ns; Nb Hits "
485 "TOF []; Nb Hits MUCH []; Time bins []",
488 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
489 sHistName =
"hDiamVsTofHitsNbPerTimeBin";
490 sHistTitle = Form(
"Nb Hits in Diam vs TOF in time bins of %5u ns; Nb Hits "
491 "TOF []; Nb Hits Diam []; Time bins []",
494 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
496 sHistName =
"hStsVsDiamHitsNbPerTimeBin";
497 sHistTitle = Form(
"Nb Hits in STS vs Diam in time bins of %5u ns; Nb Hits "
498 "Diam []; Nb Hits STS []; Time bins []",
501 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
502 sHistName =
"hTofVsDiamHitsNbPerTimeBin";
503 sHistTitle = Form(
"Nb Hits in TOF vs Diam in time bins of %5u ns; Nb Hits "
504 "Diam []; Nb Hits TOF []; Time bins []",
507 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
508 sHistName =
"hMuchVsDiamHitsNbPerTimeBin";
509 sHistTitle = Form(
"Nb Hits in MUCH vs Diam in time bins of %5u ns; Nb Hits "
510 "Diam []; Nb Hits MUCH []; Time bins []",
513 new TH2D(sHistName, sHistTitle, 2000, 0., 2000., 2000, 0., 2000.);
515 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
549 LOG(info) <<
"Done Creating mCBM Histograms";
569 LOG(debug) <<
"Timeslice contains " << ts.num_microslices(component)
584 for (UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx++) {
590 if (kFALSE ==
ProcessStsMs(ts, uMsComp, uMsIdx))
return kFALSE;
598 if (kFALSE ==
ProcessTofMs(ts, uMsComp, uMsIdx))
return kFALSE;
616 for (UInt_t uHitDia = 0; uHitDia < uNbDiaHits; uHitDia++) {
621 case 0: uChan = 0;
break;
622 case 32: uChan = 1;
break;
623 case 64: uChan = 2;
break;
624 case 96: uChan = 3;
break;
625 case 160: uChan = 4;
break;
626 case 192: uChan = 5;
break;
627 case 224: uChan = 6;
break;
628 case 256: uChan = 7;
break;
649 for (UInt_t uHit = 0; uHit < uNbHitsInMs; ++uHit) {
650 Double_t dHitTimeInTs =
661 if (iTimeBin < 0 ||
kuNbTimeBins <=
static_cast<UInt_t
>(iTimeBin)) {
662 LOG(debug) <<
"sDPB hits with time out of the TS!! " << dHitTimeInTs
703 for (UInt_t uHit = 0; uHit < uNbHitsInMs; ++uHit) {
708 if (iTimeBin < 0 ||
kuNbTimeBins <=
static_cast<UInt_t
>(iTimeBin)) {
709 LOG(debug) <<
"gDPB hits with time out of the TS!! "
783 for (UInt_t uTimeBin = 0; uTimeBin <
kuNbTimeBins; ++uTimeBin) {
839 if (0 == ts.index() % 1000) {
840 LOG(info) <<
"End of TS " << std::setw(7) << ts.index();
850 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
852 const uint8_t* msContent =
853 reinterpret_cast<const uint8_t*
>(ts.content(uMsComp, uMsIdx));
855 uint32_t uSize = msDescriptor.size;
858 LOG(debug) <<
"Microslice: " <<
fulCurrentMsIdx <<
" from EqId " << std::hex
868 <<
"---------------------------------------------------------------";
879 LOG(warning) <<
"Could not find the sDPB index for AFCK id 0x" << std::hex
882 <<
" component " << uMsComp <<
"\n"
883 <<
"If valid this index has to be added in the STS/MUCH "
884 "parameter file in the RocIdArray field";
891 UInt_t uTsMsbCycleHeader = std::floor(
901 <<
"TS MSB cycle from MS header does not match current cycle from data "
905 << uTsMsbCycleHeader;
911 LOG(error) <<
"The input microslice buffer does NOT "
912 <<
"contain only complete nDPB messages!";
915 uint32_t uNbMessages =
919 const uint32_t* pInBuff =
reinterpret_cast<const uint32_t*
>(msContent);
921 for (uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx) {
923 uint32_t ulData =
static_cast<uint32_t
>(pInBuff[uIdx]);
948 LOG(info) <<
"CbmMcbm2018MonitorMcbmRate::DoUnpack => "
949 <<
"EPOCH message at unexpected position in MS: message "
950 << uIdx <<
" VS message 0 expected!";
960 <<
"CbmMcbm2018MonitorMcbmRate::DoUnpack => "
961 <<
"Unknown message type, should never happen, stopping here!";
1018 if ((0 == uChanIdx % 2) && (543 < uChanIdx) && (uChanIdx < 633)) {
1025 Long64_t ulStsHitTime = usRawTs;
1054 <<
" new TsMsb " << std::setw(5) << uVal;
1060 LOG(info) <<
"TS MSb Jump in "
1063 << uMsIdx <<
" Msg Idx " << std::setw(5) << uMessIdx <<
" DPB "
1066 <<
" new TsMsb " << std::setw(5) << uVal;
1087 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
1090 const uint8_t* msContent =
1091 reinterpret_cast<const uint8_t*
>(ts.content(uMsComp, uMsIdx));
1093 uint32_t size = msDescriptor.size;
1096 LOG(debug) <<
"Microslice: " << msDescriptor.idx <<
" has size: " << size;
1098 Int_t messageType = -111;
1102 LOG(error) <<
"The input microslice buffer does NOT "
1103 <<
"contain only complete nDPB messages!";
1106 uint32_t uNbMessages =
1117 <<
"---------------------------------------------------------------";
1128 LOG(warning) <<
"Could not find the gDPB index for AFCK id 0x" << std::hex
1131 <<
" component " << uMsComp <<
"\n"
1132 <<
"If valid this index has to be added in the TOF parameter "
1133 "file in the RocIdArray field";
1140 const uint64_t* pInBuff =
reinterpret_cast<const uint64_t*
>(msContent);
1141 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
1143 uint64_t ulData =
static_cast<uint64_t
>(pInBuff[uIdx]);
1152 if (gLogger->IsLogNeeded(fair::Severity::debug2)) {
1161 switch (messageType) {
1183 LOG(error) <<
"Message type " << std::hex << std::setw(2)
1184 <<
static_cast<uint16_t
>(messageType)
1185 <<
" not included in Get4 unpacker.";
1207 if (0 < ulCurEpochGdpbGet4)
1208 ulCurEpochGdpbGet4--;
1243 if (0 < iBufferSize) {
1244 LOG(debug) <<
"Now processing stored messages for for gDPB " <<
fuTofGdpbNr
1245 <<
" with epoch number "
1253 for (Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++) {
1280 LOG(info) <<
"-------------------------------------";
1288 TDirectory* oldDir =
nullptr;
1289 TFile* histoFile =
nullptr;
1290 if (
"" != sFileName) {
1292 oldDir = gDirectory;
1294 histoFile =
new TFile(sFileName,
"RECREATE");
1305 gDirectory->mkdir(
"mCbmRate");
1306 gDirectory->cd(
"mCbmRate");
1312 gDirectory->cd(
"..");
1314 gDirectory->mkdir(
"mCbmCounts");
1315 gDirectory->cd(
"mCbmCounts");
1328 gDirectory->cd(
"..");
1331 if (
"" != sFileName) {