17 #include "FairLogger.h"
18 #include "FairRootManager.h"
20 #include "FairRunOnline.h"
21 #include "FairRuntimeDb.h"
24 #include "TClonesArray.h"
26 #include "THttpServer.h"
55 , fvMsComponentsListSts()
56 , fvMsComponentsListTof()
59 , fbIgnoreOverlapMs(kFALSE)
60 , fUnpackParSts(nullptr)
62 , fmStsDpbIdIndexMap()
64 , fUnpackParTof(nullptr)
66 , fmTofDpbIdIndexMap()
69 , fdStsTofOffsetNs(0.0)
70 , fdMuchTofOffsetNs(0.0)
71 , fbUseBestPair(kFALSE)
72 , fbTsLevelAna(kFALSE)
73 , fsHistoFileFullname(
"data/mCBMsyncHistos.root")
74 , fbPrintMessages(kFALSE)
79 , fuCurrentEquipmentId(0)
82 , fiRunStartDateTimeSec(-1)
83 , fiBinSizeDatePlots(-1)
84 , fvulStsCurrentTsMsb()
85 , fvuStsCurrentTsMsbCycle()
86 , fvmStsSdpbHitsInMs()
87 , fvmStsSdpbHitsInTs()
88 , fulTofCurrentTsIndex(0)
95 , fvulTofCurrentEpoch()
96 , fvulTofCurrentEpochCycle()
97 , fvulTofCurrentEpochFull()
98 , fulTofCurrentEpochTime(0)
99 , fvmTofEpSupprBuffer()
100 , fvmTofGdpbHitsInMs()
101 , fvmTofGdpbHitsInTs()
102 , fhMcbmHitsNbPerMs()
103 , fvhMcbmTimeDiffToSelDpb()
104 , fvhMcbmTimeDiffToSelDpbWide()
105 , fvhMcbmTimeDiffToSelDpbTs()
106 , fvhMcbmTimeDiffToDiamondEvoDpb()
107 , fvhMcbmTimeDiffToDiamondWideEvoDpb()
108 , fvhMcbmTimeDiffToDiamondTsEvoDpb()
109 , fvhMcbmTimeDiffToTofEvoDpb()
110 , fvhMcbmTimeDiffToTofWideEvoDpb()
111 , fvhMcbmTimeDiffToTofTsEvoDpb() {}
116 LOG(info) <<
"Initializing flib StsXyter unpacker for STS";
118 FairRootManager* ioman = FairRootManager::Instance();
119 if (ioman ==
nullptr) { LOG(fatal) <<
"No FairRootManager instance"; }
125 LOG(info) <<
"Setting parameter containers for " << GetName();
128 "CbmMcbm2018StsPar"));
131 "CbmMcbm2018TofPar"));
136 LOG(info) <<
"Init parameter containers for " << GetName();
147 LOG(info) <<
"ReInit parameter containers for " << GetName();
156 LOG(info) <<
"Eq. ID for DPB #" << std::setw(2) << uDpb <<
" = 0x"
158 << std::dec <<
" => "
175 LOG(info) <<
"GDPB Id of TOF " <<
i <<
" : " << std::hex
192 UShort_t usDetectorId) {
193 switch (usDetectorId) {
205 LOG(warning) <<
"CbmMcbm2018MonitorStsSync::AddMsComponentToList => "
206 <<
"Ignore component " << component <<
" as detector id "
207 << usDetectorId <<
" is not supported by this unpacker.";
229 size_t uOverlapMsNb) {
238 TString sHistName {
""};
298 LOG(info) <<
"Done Creating STS Histograms";
304 TString sHistName {
""};
372 LOG(info) <<
"Done Creating TOF Histograms";
378 TString sHistName {
""};
379 TString sHistTitle {
""};
383 sHistName =
"hMcbmHitsNbPerMs";
384 sHistTitle =
"Nb of hits per DPB; Nb of hits []; DPB []";
395 sHistName = Form(
"hMcbmTimeDiffToDpb%02u", uDpb);
396 sHistTitle = Form(
"Time difference for STS and TOF hits, per DPB, against "
397 "any hits in DPB %02u; <tn - tRef> [ns]; DPB []",
408 sHistName = Form(
"hMcbmTimeDiffToDpb%02uWide", uDpb);
410 Form(
"Time difference for STS and TOF hits, per DPB, against any hits in "
411 "DPB %02u, wide range; <tn - tRef> [us]; DPB []",
421 sHistName = Form(
"hMcbmTimeDiffToDpb%02uTs", uDpb);
423 Form(
"Time difference for STS and TOF hits, per DPB, against any hits in "
424 "DPB %02u, TS range; <tn - tRef> [ms]; DPB []",
435 sHistName = Form(
"hMcbmTimeDiffToDiamondEvoDpb%02u", uDpb);
437 Form(
"Evolution of time difference for STS or TOF hits from DPB %02u "
438 "against any Diamond hit; TS []; <tn - tDia> [ns]",
450 sHistName = Form(
"hMcbmTimeDiffToDiamondWideEvoDpb%02u", uDpb);
452 Form(
"Evolution of time difference for STS or TOF hits from DPB %02u "
453 "against any Diamond hit, wide range; TS []; <tn - tDia> [us]",
456 sHistName, sHistTitle, 2000.0, 0., 200000., 4000.0, -200., 200.));
458 sHistName = Form(
"hMcbmTimeDiffToDiamondTsEvoDpb%02u", uDpb);
460 Form(
"Evolution of time difference for STS or TOF hits from DPB %02u "
461 "against any Diamond hit, TS range; TS []; <tn - tDia> [ms]",
464 new TH2D(sHistName, sHistTitle, 2000.0, 0., 200000., 200.0, -10., 10.));
466 sHistName = Form(
"hMcbmTimeDiffToTofEvoDpb%02u", uDpb);
467 sHistTitle = Form(
"Evolution of time difference for STS or TOF hits from "
468 "DPB %02u against any Tof hit; TS []; <tn - tTof> [ns]",
480 sHistName = Form(
"hMcbmTimeDiffToTofWideEvoDpb%02u", uDpb);
482 Form(
"Evolution of time difference for STS or TOF hits from DPB %02u "
483 "against any Tof hit, wide range; TS []; <tn - tTof> [us]",
486 sHistName, sHistTitle, 2000.0, 0., 200000., 4000.0, -200., 200.));
488 sHistName = Form(
"hMcbmTimeDiffToTofTsEvoDpb%02u", uDpb);
490 Form(
"Evolution of time difference for STS or TOF hits from DPB %02u "
491 "against any Tof hit, TS range; TS []; <tn - tTof> [ms]",
494 new TH2D(sHistName, sHistTitle, 2000.0, 0., 200000., 200.0, -10., 10.));
496 #ifdef USE_HTTP_SERVER
497 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
515 server->RegisterCommand(
"/Reset_All",
"bMcbm2018ResetPulser=kTRUE");
516 server->RegisterCommand(
"/Save_All",
"bMcbm2018WritePulser=kTRUE");
518 server->Restrict(
"/Reset_All",
"allow=admin");
519 server->Restrict(
"/Save_All",
"allow=admin");
527 TCanvas* cSyncMcbmDpb =
528 new TCanvas(Form(
"cSyncMcbmDpb%02u", uDpb),
529 Form(
"Time difference for STS and TOF hits, per DPB, against "
534 cSyncMcbmDpb->Divide(3);
556 LOG(info) <<
"Done Creating mCBM Histograms";
572 LOG(debug) <<
"Timeslice contains " << ts.num_microslices(component)
586 for (UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx++) {
592 if (kFALSE ==
ProcessStsMs(ts, uMsComp, uMsIdx))
return kFALSE;
600 if (kFALSE ==
ProcessTofMs(ts, uMsComp, uMsIdx))
return kFALSE;
620 for (UInt_t uRefSdpb = 0; uRefSdpb <
fuStsNrOfDpbs; ++uRefSdpb) {
622 for (UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++) {
632 Double_t dBestDt = 1e9;
634 UInt_t uNbIncrDt = 0;
636 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
637 if (uRefSdpb == uSdpb && uHitRef == uHit)
continue;
646 Double_t dDt = dHitTime - dRefTime;
650 if (TMath::Abs(dDt) < TMath::Abs(dBestDt)) {
654 else if (dBestDt < dDt)
658 if (5 == dBestDt)
break;
675 Double_t dBestDt = 1e9;
676 UInt_t uNbIncrDt = 0;
678 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
681 Double_t dDt = dHitTime - dRefTime;
685 if (TMath::Abs(dDt) < TMath::Abs(dBestDt))
687 else if (dBestDt < dDt)
691 if (5 == dBestDt)
break;
712 for (UInt_t uRefGdpb = 0; uRefGdpb <
fuTofNrOfDpbs; ++uRefGdpb) {
714 for (UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++) {
720 Double_t dBestDt = 1e9;
721 UInt_t uNbIncrDt = 0;
723 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
731 Double_t dDt = dHitTime - dRefTime;
735 if (TMath::Abs(dDt) < TMath::Abs(dBestDt))
737 else if (dBestDt < dDt)
741 if (5 == dBestDt)
break;
747 dDt / 1000.0, uSdpb);
768 dBestDt / 1000.0, uSdpb);
786 Double_t dBestDt = 1e9;
787 UInt_t uNbIncrDt = 0;
789 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
791 if (uRefGdpb == uGdpb && uHitRef == uHit)
continue;
795 Double_t dDt = dHitTime - dRefTime;
799 if (TMath::Abs(dDt) < TMath::Abs(dBestDt))
801 else if (dBestDt < dDt)
805 if (5 == dBestDt)
break;
879 for (UInt_t uRefSdpb = 0; uRefSdpb <
fuStsNrOfDpbs; ++uRefSdpb) {
881 for (UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++) {
895 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
896 if (uRefSdpb == uSdpb && uHitRef == uHit)
continue;
905 Double_t dDt = dHitTime - dRefTime;
908 if (300e3 < dDt)
break;
919 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
922 Double_t dDt = dHitTime - dRefTime;
925 if (300e3 < dDt)
break;
935 for (UInt_t uRefGdpb = 0; uRefGdpb <
fuTofNrOfDpbs; ++uRefGdpb) {
937 for (UInt_t uHitRef = 0; uHitRef < uNbRefHits; uHitRef++) {
942 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
946 Double_t dDt = dHitTime - dRefTime;
949 if (300e3 < dDt)
break;
965 for (UInt_t uHit = 0; uHit < uNbHits; ++uHit) {
966 if (uRefGdpb == uGdpb && uHitRef == uHit)
continue;
970 Double_t dDt = dHitTime - dRefTime;
973 if (300e3 < dDt)
break;
999 if (0 == ts.index() % 1000) {
1000 LOG(info) <<
"End of TS " << std::setw(7) << ts.index();
1010 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
1012 const uint8_t* msContent =
1013 reinterpret_cast<const uint8_t*
>(ts.content(uMsComp, uMsIdx));
1015 uint32_t uSize = msDescriptor.size;
1018 LOG(debug) <<
"Microslice: " <<
fulCurrentMsIdx <<
" from EqId " << std::hex
1025 UInt_t uTsMsbCycleHeader = std::floor(
1035 <<
"TS MSB cycle from MS header does not match current cycle from data "
1039 << uTsMsbCycleHeader;
1045 LOG(error) <<
"The input microslice buffer does NOT "
1046 <<
"contain only complete nDPB messages!";
1049 uint32_t uNbMessages =
1053 const uint32_t* pInBuff =
reinterpret_cast<const uint32_t*
>(msContent);
1055 for (uint32_t uIdx = 0; uIdx < uNbMessages; ++uIdx) {
1057 uint32_t ulData =
static_cast<uint32_t
>(pInBuff[uIdx]);
1082 LOG(info) <<
"CbmMcbm2018MonitorMcbmPulser::DoUnpack => "
1083 <<
"EPOCH message at unexpected position in MS: message "
1084 << uIdx <<
" VS message 0 expected!";
1094 <<
"CbmMcbm2018MonitorMcbmPulser::DoUnpack => "
1095 <<
"Unknown message type, should never happen, stopping here!";
1140 if (usRawAdc < 15)
return;
1155 if ((0 == uChanIdx % 2) && (543 < uChanIdx) && (uChanIdx < 633)) {
1162 Long64_t ulStsHitTime = usRawTs;
1192 <<
" new TsMsb " << std::setw(5) << uVal;
1198 LOG(info) <<
"TS MSb Jump in "
1201 << uMsIdx <<
" Msg Idx " << std::setw(5) << uMessIdx <<
" DPB "
1204 <<
" new TsMsb " << std::setw(5) << uVal;
1226 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
1229 const uint8_t* msContent =
1230 reinterpret_cast<const uint8_t*
>(ts.content(uMsComp, uMsIdx));
1232 uint32_t size = msDescriptor.size;
1235 LOG(debug) <<
"Microslice: " << msDescriptor.idx <<
" has size: " << size;
1237 Int_t messageType = -111;
1241 LOG(error) <<
"The input microslice buffer does NOT "
1242 <<
"contain only complete nDPB messages!";
1245 uint32_t uNbMessages =
1253 const uint64_t* pInBuff =
reinterpret_cast<const uint64_t*
>(msContent);
1254 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
1256 uint64_t ulData =
static_cast<uint64_t
>(pInBuff[uIdx]);
1265 if (gLogger->IsLogNeeded(fair::Severity::debug2)) {
1274 switch (messageType) {
1296 LOG(error) <<
"Message type " << std::hex << std::setw(2)
1297 <<
static_cast<uint16_t
>(messageType)
1298 <<
" not included in Get4 unpacker.";
1320 if (0 < ulCurEpochGdpbGet4)
1321 ulCurEpochGdpbGet4--;
1356 if (0 < iBufferSize) {
1357 LOG(debug) <<
"Now processing stored messages for for gDPB " <<
fuTofGdpbNr
1358 <<
" with epoch number "
1366 for (Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++) {
1393 LOG(info) <<
"-------------------------------------";
1401 TDirectory* oldDir =
nullptr;
1402 TFile* histoFile =
nullptr;
1403 if (
"" != sFileName) {
1405 oldDir = gDirectory;
1407 histoFile =
new TFile(sFileName,
"RECREATE");
1421 gDirectory->mkdir(
"mcbmDt");
1422 gDirectory->cd(
"mcbmDt");
1438 gDirectory->cd(
"..");
1441 if (
"" != sFileName) {