14 #include "FairLogger.h"
15 #include "FairRootManager.h"
17 #include "FairRunOnline.h"
18 #include "FairRuntimeDb.h"
39 , fbDebugMonitorMode(kFALSE)
40 , fvbMaskedComponents()
42 , fvuElinkIdxHodo(kuNbHodos, 0)
43 , fvbHodoSwapXY(kuNbHodos, kFALSE)
44 , fvbHodoInvertX(kuNbHodos, kFALSE)
45 , fvbHodoInvertY(kuNbHodos, kFALSE)
46 , fvuAdcGainHodo(kuNbHodos, 0)
47 , fvuAdcOffsHodo(kuNbHodos, 0)
70 , fdTsStopTimeCore(-1.0)
71 , fvdPrevMsTime(kiMaxNbFlibLinks, -1.0)
75 , fuCurrentEquipmentId(0)
77 , fiRunStartDateTimeSec(-1)
78 , fiBinSizeDatePlots(-1)
81 , fdStartTimeMsSz(-1.0)
82 , ftStartTimeUnix(std::chrono::steady_clock::now())
84 , fhHodoMessType(nullptr)
85 , fhHodoStatusMessType(nullptr)
86 , fhHodoMsStatusFieldType(nullptr)
87 , fhHodoMessTypePerElink(nullptr)
88 , fhHodoChanCntRaw(kuNbHodos, nullptr)
89 , fhHodoChanAdcRaw(kuNbHodos, nullptr)
90 , fhHodoChanAdcRawProf(kuNbHodos, nullptr)
91 , fhHodoChanAdcCal(kuNbHodos, nullptr)
92 , fhHodoChanAdcCalProf(kuNbHodos, nullptr)
93 , fhHodoChanRawTs(kuNbHodos, nullptr)
94 , fhHodoChanMissEvt(kuNbHodos, nullptr)
95 , fhHodoChanMissEvtEvo(kuNbHodos, nullptr)
96 , fhHodoChanHitRateEvo(kuNbHodos, nullptr)
97 , fhHodoChanHitRateProf(kuNbHodos, nullptr)
98 , fhHodoChanDistT(kuNbHodos, nullptr)
99 , fhHodoFiberCnt(kuNbHodos, std::vector<TH1*>(kuNbAxis, nullptr))
100 , fhHodoFiberAdc(kuNbHodos, std::vector<TH2*>(kuNbAxis, nullptr))
101 , fhHodoFiberAdcProf(kuNbHodos, std::vector<TProfile*>(kuNbAxis, nullptr))
102 , fhHodoFiberHitRateEvo(kuNbHodos, std::vector<TH2*>(kuNbAxis, nullptr))
103 , fhHodoFiberCoincMapXY(kuNbHodos, nullptr)
104 , fhHodoFiberCoincTimeXY(kuNbHodos, nullptr)
105 , fhHodoFiberCoincWalkXY_X(kuNbHodos, nullptr)
106 , fhHodoFiberCoincWalkXY_Y(kuNbHodos, nullptr)
107 , fhHodoFiberCoincMapSameAB(kuNbAxis, nullptr)
108 , fhHodoFiberCoincTimeSameAB(kuNbAxis, nullptr)
109 , fhHodoFiberCoincMapDiffAB(kuNbAxis, nullptr)
110 , fhHodoFiberCoincTimeDiffAB(kuNbAxis, nullptr)
111 , fhHodoFullCoincPosA(nullptr)
112 , fhHodoFullCoincPosB(nullptr)
113 , fhHodoFullCoincCompX(nullptr)
114 , fhHodoFullCoincCompY(nullptr)
115 , fhHodoFullCoincResidualXY(nullptr)
116 , fhHodoFullCoincTimeDiff(nullptr)
117 , fhHodoFullCoincTimeWalk(kuNbHodos, std::vector<TH2*>(kuNbAxis, nullptr))
118 , fhHodoFullCoincRateEvo(nullptr)
119 , fhHodoFullCoincPosEvo(kuNbHodos, std::vector<TH2*>(kuNbAxis, nullptr))
120 , fhPrevHitDtAllAsics(nullptr)
121 , fhPrevHitDtAsicA(nullptr)
122 , fhPrevHitDtAsicB(nullptr)
123 , fhPrevHitDtAsicsAB(nullptr)
124 , fiTimeIntervalRateUpdate(-1)
125 , fviTimeSecLastRateUpdate(kuNbHodos, 0)
126 , fvdChanCountsSinceLastRateUpdate(
128 std::vector<Double_t>(kuNbChanPerAsic, 0.0))
129 , fdHodoChanLastTimeForDist(kuNbHodos,
130 std::vector<Double_t>(kuNbChanPerAsic, 0.0))
131 , fuPreviousHitAsic(0)
132 , fvdPreviousHitTimePerAsic(2, 0.0)
134 , fcHodoSummaryRaw(kuNbHodos, nullptr)
135 , fcHodoSummaryFiber(kuNbHodos, nullptr)
136 , fcHodoFiberCoinc(nullptr)
137 , fcHodoFiberCoincAB(nullptr)
138 , fcHodoFullCoinc(nullptr)
139 , fcHodoFullCoincPos(nullptr)
140 , fcHodoPrevHitDt(nullptr) {}
148 LOG(info) <<
"Initializing mCBM HODO 2019 monitor algo";
161 LOG(info) <<
"Init parameter containers for CbmMcbm2018MonitorAlgoHodo";
167 LOG(info) <<
"**********************************************";
168 LOG(info) <<
"ReInit parameter containers for CbmMcbm2018MonitorAlgoHodo";
373 UShort_t usDetectorId) {
381 LOG(info) <<
"CbmMcbm2018MonitorAlgoHodo::AddMsComponentToList => Component "
382 << component <<
" with detector ID 0x" << std::hex << usDetectorId
383 << std::dec <<
" added to list";
389 fdTsStartTime =
static_cast<Double_t
>(ts.descriptor(0, 0).idx);
408 LOG(info) <<
"In each TS " <<
fuNbMsLoop <<
" MS will be looped over";
424 <<
fuMsIndex <<
" for component " << uMsComp;
446 LOG(error) <<
"Failed to fill histos in ts " <<
fulCurrentTsIdx <<
" MS "
465 auto msDescriptor = ts.descriptor(uMsCompIdx, uMsIdx);
467 const uint8_t* msContent =
468 reinterpret_cast<const uint8_t*
>(ts.content(uMsCompIdx, uMsIdx));
470 uint32_t uSize = msDescriptor.size;
474 LOG(debug) <<
"Microslice: " <<
fulCurrentMsIdx <<
" from EqId " << std::hex
486 <<
"---------------------------------------------------------------";
497 LOG(warning) <<
"Could not find the sDPB index for AFCK id 0x" << std::hex
500 <<
" component " << uMsCompIdx <<
"\n"
501 <<
"If valid this index has to be added in the STS "
502 "parameter file in the DbpIdArray field";
517 <
static_cast<Int_t
>(dMsTime)) {
519 for (UInt_t uHodoIdx = 0; uHodoIdx <
kuNbHodos; ++uHodoIdx) {
546 uint16_t uMsHeaderFlags = msDescriptor.flags;
547 for (UInt_t uBit = 0; uBit < 16; ++uBit)
551 UInt_t uTsMsbCycleHeader = std::floor(
561 <<
"TS MSB cycle from MS header does not match current cycle from data "
565 << uTsMsbCycleHeader;
571 LOG(error) <<
"The input microslice buffer does NOT "
572 <<
"contain only complete nDPB messages!";
575 uint32_t uNbMessages =
579 const uint32_t* pInBuff =
reinterpret_cast<const uint32_t*
>(msContent);
580 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
582 uint32_t ulData =
static_cast<uint32_t
>(pInBuff[uIdx]);
596 static_cast<uint16_t
>(typeMess));
600 Bool_t bBadElink = kTRUE;
601 for (uHodoIdx = 0; uHodoIdx <
kuNbHodos; ++uHodoIdx)
608 LOG(warning) <<
"CbmMcbm2018MonitorAlgoHodo::DoUnpack => "
609 <<
"Wrong elink Idx! Elink raw "
610 << Form(
"%2d", usElinkIdx);
630 LOG(info) <<
"CbmMcbm2018MonitorAlgoHodo::DoUnpack => "
631 <<
"EPOCH message at unexpected position in MS: message "
632 << uIdx <<
" VS message 0 expected!";
638 static_cast<uint16_t
>(typeMess));
652 LOG(fatal) <<
"CbmMcbm2018MonitorAlgoHodo::DoUnpack => "
653 <<
"Unknown message type, should never happen, stopping "
654 "here! Type found was: "
655 <<
static_cast<int>(typeMess);
665 const UInt_t& uHodoIdx,
696 Long64_t ulHitTime = usRawTs;
717 Double_t dTimeSinceStartSec = (dHitTimeNs -
fdStartTime) * 1e-9;
739 << uMsIdx <<
" Msg Idx " << std::setw(5) << uMessIdx
742 <<
" new TsMsb " << std::setw(5) << uVal;
749 LOG(info) <<
"TS MSb Jump in "
752 << uMsIdx <<
" Msg Idx " << std::setw(5) << uMessIdx
754 <<
" new TsMsb " << std::setw(5) << uVal;
801 new TH1I(
"hHodoMessType",
"Nb of message for each type; Type", 6, 0., 6.);
810 "hHodoStatusMessType",
811 "Nb of status message of each type for each DPB; ASIC; Status Type",
826 "hHodoMsStatusFieldType",
827 "For each flag in the MS header, ON/OFF counts; Flag bit []; ON/OFF; MS []",
842 new TH2I(
"hHodoMessTypePerElink",
843 "Nb of message of each type for each eLink; eLink; Type",
862 for (UInt_t uHodoIdx = 0; uHodoIdx <
kuNbHodos; ++uHodoIdx) {
866 Form(
"hHodoChanCntRaw_%u", uHodoIdx),
867 Form(
"Hits Count per channel, Hodo #%u; Channel; Hits []", uHodoIdx),
874 new TH2I(Form(
"hHodoChanAdcRaw_%u", uHodoIdx),
875 Form(
"Raw Adc distribution per channel, Hodo #%u; Channel []; "
887 Form(
"hHodoChanAdcRawProf_%u", uHodoIdx),
888 Form(
"Raw Adc prodile per channel, Hodo #%u; Channel []; Adc []",
907 new TH2I(Form(
"hHodoChanRawTs_%u", uHodoIdx),
908 Form(
"Raw Timestamp distribution per channel, FEB #%03u; "
909 "Channel []; Ts []; Hits []",
920 new TH2I(Form(
"hHodoChanMissEvt_%u", uHodoIdx),
921 Form(
"Missed Event flags per channel, Hodo #%u; Channel []; "
922 "Miss Evt []; Hits []",
933 new TH2I(Form(
"hHodoChanMissEvtEvo_%u", uHodoIdx),
934 Form(
"Missed Evt flags per second & channel in Hodo #%u; Time "
935 "[s]; Channel []; Missed Evt flags []",
946 Form(
"hHodoChanHitRateEvo_%u", uHodoIdx),
948 "Hits per second & channel in Hodo #%u; Time [s]; Channel []; Hits []",
959 Form(
"hHodoChanHitRateProf_%u", uHodoIdx),
961 "Hits per second for each channel in Hodo #%u; Channel []; Hits/s []",
969 new TH2I(Form(
"hHodoChanDistT_%u", uHodoIdx),
970 Form(
"Time distance between hits on same channel in Hodo #%u; "
971 "Time difference [ns]; Channel []; ",
981 for (UInt_t uAxis = 0; uAxis <
kuNbAxis; ++uAxis) {
982 Char_t cAxisName = (uAxis ?
'Y' :
'X');
985 new TH1I(Form(
"hHodoFiberCnt%c_%u", cAxisName, uHodoIdx),
986 Form(
"Hits Count per Fiber, Hodo #%u Axis %c; Fiber; Hits []",
995 new TH2I(Form(
"fhHodoFiberAdc%c_%u", cAxisName, uHodoIdx),
996 Form(
"Raw Adc distribution per Fiber, Hodo #%u Axis %c; "
997 "Channel []; Adc []; Hits []",
1009 Form(
"hHodoFiberAdcProf%c_%u", cAxisName, uHodoIdx),
1010 Form(
"Raw Adc prodile per Fiber, Hodo #%u Axis %c; Channel []; Adc []",
1019 new TH2I(Form(
"hHodoFiberHitRateEvo%c_%u", cAxisName, uHodoIdx),
1020 Form(
"Hits per second & Fiber in Hodo #%u Axis %c; Time [s]; "
1021 "Channel []; Hits []",
1043 new TH2I(Form(
"hHodoFiberCoincMapXY_%u", uHodoIdx),
1044 Form(
"Map of coincident (X, Y) pairs in Hodo #%u; X [Fiber]; Y "
1055 new TH1I(Form(
"hHodoFiberCoincTimeXY_%u", uHodoIdx),
1056 Form(
"Time difference of coincident (X, Y) pairs in Hodo #%u; "
1057 "t_Y - t_X [ns]; Hits []",
1064 new TH2I(Form(
"hHodoFiberCoincWalkXY_X_%u", uHodoIdx),
1065 Form(
"Walk X of coincident (X, Y) pairs in Hodo #%u; ADC X "
1066 "[bin]; t_Y - t_X [ns]; Hits []",
1075 new TH2I(Form(
"hHodoFiberCoincWalkXY_Y_%u", uHodoIdx),
1076 Form(
"Walk X of coincident (X, Y) pairs in Hodo #%u; ADC X "
1077 "[bin]; t_Y - t_X [ns]; Hits []",
1103 for (UInt_t uAxis = 0; uAxis <
kuNbAxis; ++uAxis) {
1104 Char_t cAxisName = (uAxis ?
'Y' :
'X');
1105 Char_t cOtherAxisName = (uAxis ?
'X' :
'Y');
1109 new TH2I(Form(
"hHodoFiberCoincMapSameAB_%c%c", cAxisName, cAxisName),
1110 Form(
"Map of coincident (%c, %c) pairs in Hodo A and B; %c_A "
1111 "[Fiber]; %c_B [Fiber]; Hits []",
1124 new TH1I(Form(
"hHodoFiberCoincTimeSameAB_%c%c", cAxisName, cAxisName),
1125 Form(
"Time difference of coincident (%c, %c) pairs in Hodo A "
1126 "and B; t_%c_B - t_%c_A [ns]; Hits []",
1137 new TH2I(Form(
"hHodoFiberCoincMapDiffAB_%c%c", cAxisName, cOtherAxisName),
1138 Form(
"Map of coincident (%c, %c) pairs in Hodo A and B; %c_A "
1139 "[Fiber]; %c_B [Fiber]; Hits []",
1152 Form(
"hHodoFiberCoincTimeDiffAB_%c%c", cAxisName, cOtherAxisName),
1153 Form(
"Time difference of coincident (%c, %c) pairs in Hodo A and B; "
1154 "t_%c_B - t_%c_A [ns]; Hits []",
1172 new TH2I(
"fhHodoFullCoincPosA",
1173 "Position on Hodo A for coincident pairs in Hodo A and B; X_A "
1174 "[Fiber]; Y_A [Fiber]; Hits []",
1183 new TH2I(
"fhHodoFullCoincPosB",
1184 "Position on Hodo B for coincident pairs in Hodo A and B; X_B "
1185 "[Fiber]; Y_B [Fiber]; Hits []",
1194 new TH2I(
"hHodoFullCoincCompX",
1195 "Comparison of X pos for coincident pairs in Hodo A and B; X_A "
1196 "[Fiber]; X_B [Fiber]; Hits []",
1205 new TH2I(
"hHodoFullCoincCompY",
1206 "Comparison of Y pos for coincident pairs in Hodo A and B; Y_A "
1207 "[Fiber]; Y_B [Fiber]; Hits []",
1217 new TH2I(
"hHodoFullCoincResidualXY",
1218 "X and Y residuals for coincident pairs in Hodo A and B; X_B - "
1219 "X_A [Fiber]; Y_B - Y_A [Fiber]; Hits []",
1228 new TH1I(
"hHodoFullCoincTimeDiff",
1229 "Time difference of coincident pairs in Hodo A and B; (t_X_B + "
1230 "t_Y_B)/2 - (t_X_A + t_Y_A)/2 [ns]; Hits []",
1236 "Evolution of the full coincidence rate; "
1237 "Time in run [s]; Full coincidences;",
1250 for (UInt_t uHodoIdx = 0; uHodoIdx <
kuNbHodos; ++uHodoIdx) {
1251 for (UInt_t uAxis = 0; uAxis <
kuNbAxis; ++uAxis) {
1252 Char_t cAxisName = (uAxis ?
'Y' :
'X');
1254 new TH2I(Form(
"hHodoFullCoincTimeWalk_%u%c", uHodoIdx, cAxisName),
1255 Form(
"Time walk of coincident (A, B) pairs in Hodo #%u Axis "
1256 "%c; ADC %u_%c [bin]; Time Diff <B> - <A> [ns]; Hits []",
1270 Form(
"hHodoFullCoincPosEvo_%u%c", uHodoIdx, cAxisName),
1271 Form(
"Time evolution of coincident (A, B) pairs position in Hodo #%u "
1272 "Axis %c; Time in run [s]; Position %u_%c [Fiber]; Hits []",
1289 new TH1I(
"hPrevHitDtAllAsics",
1290 "Time difference between current and previous hits in any ASIC; t "
1291 "- t_prev [ns]; Hit pairs []",
1296 "Time difference between current and previous "
1297 "hits in ASIC A; t - t_prev [ns]; Hit pairs []",
1302 "Time difference between current and previous "
1303 "hits in ASIC B; t - t_prev [ns]; Hit pairs []",
1308 new TH1I(
"hPrevHitDtAsicsAB",
1309 "Time difference between current in ASIC A and previous hit in "
1310 "ASIC B; t - t_prev [ns]; Hit pairs []",
1324 fcSummary =
new TCanvas(
"fcSummary",
"Summary for the Hodo sDPB", w,
h);
1354 for (UInt_t uHodoIdx = 0; uHodoIdx <
kuNbHodos; ++uHodoIdx) {
1357 new TCanvas(Form(
"cHodoSummaryRaw%u", uHodoIdx),
1358 Form(
"Raw Summary for Hodo %u", uHodoIdx),
1412 new TCanvas(Form(
"cHodoSummaryFiber%u", uHodoIdx),
1413 Form(
"Fiber Summary for Hodo %u", uHodoIdx),
1418 for (UInt_t uAxis = 0; uAxis <
kuNbAxis; ++uAxis) {
1448 new TCanvas(
"fcHodoFiberCoinc",
"X/Y coincidences in same hodoscope", w,
h);
1500 "fcHodoFiberCoincAB",
"X/Y coincidences between hodoscopes", w,
h);
1503 for (UInt_t uAxis = 0; uAxis <
kuNbAxis; ++uAxis) {
1530 "fcHodoFullCoinc",
"Full coincidences between hodoscopes", w,
h);
1583 new TCanvas(
"fcHodoFullCoincPos",
1584 "Hit Positions for Full coincidences between hodoscopes",
1602 new TCanvas(
"fcHodoFullCoincPosEvo",
1603 "Hit Positions Evo for Full coincidences between hodoscopes",
1633 new TCanvas(
"fcHodoPrevHitDt",
1634 "Time difference between current and previous hits",
1673 std::vector<std::vector<stsxyter::FinalHit>> lastHitHodoAxis;
1674 std::vector<std::vector<Bool_t>> bHitFoundHodoAxis;
1677 for (UInt_t uHodoIdx = 0; uHodoIdx <
kuNbHodos; ++uHodoIdx) {
1678 lastHitHodoAxis[uHodoIdx].resize(
kuNbAxis);
1679 bHitFoundHodoAxis[uHodoIdx].resize(
kuNbAxis, kFALSE);
1684 for (UInt_t uHit = 0; uHit < uTotalNbHits; ++uHit) {
1690 Double_t dCurrentHitTime =
1704 lastHitHodoAxis[uHodo][uAxis] =
fvmHitsInMs[uHit];
1705 bHitFoundHodoAxis[uHodo][uAxis] = kTRUE;
1708 if (bHitFoundHodoAxis[uHodo][0] && bHitFoundHodoAxis[uHodo][1]) {
1709 Double_t dTimeDiffAxis =
1716 lastHitHodoAxis[uHodo][1].GetChan());
1719 lastHitHodoAxis[uHodo][0].GetAdc(), dTimeDiffAxis);
1721 lastHitHodoAxis[uHodo][1].GetAdc(), dTimeDiffAxis);
1726 if (bHitFoundHodoAxis[0][uAxis] && bHitFoundHodoAxis[1][uAxis]) {
1727 Double_t dTimeDiffHodoSame =
1734 lastHitHodoAxis[0][uAxis].GetChan(),
1735 lastHitHodoAxis[1][uAxis].GetChan());
1740 UInt_t uAxisA = (uHodo ? !uAxis : uAxis);
1741 UInt_t uAxisB = (uHodo ? uAxis : !uAxis);
1742 if (bHitFoundHodoAxis[0][uAxisA] && bHitFoundHodoAxis[1][uAxisB]) {
1743 Double_t dTimeDiffHodoDiff =
1750 lastHitHodoAxis[0][uAxisA].GetChan(),
1751 lastHitHodoAxis[1][uAxisB].GetChan());
1757 if (bHitFoundHodoAxis[0][0] && bHitFoundHodoAxis[0][1]
1758 && bHitFoundHodoAxis[1][0] && bHitFoundHodoAxis[1][1]) {
1759 Double_t dTimeDiffHodoA =
1762 Double_t dTimeDiffHodoB =
1765 Double_t dTimeDiffHodoAB =
1772 Double_t dTimeHitHodoAB =
1785 UInt_t uPosXA =
fvbHodoSwapXY[0] ? lastHitHodoAxis[0][1].GetChan()
1786 : lastHitHodoAxis[0][0].GetChan();
1787 UInt_t uPosYA =
fvbHodoSwapXY[0] ? lastHitHodoAxis[0][0].GetChan()
1788 : lastHitHodoAxis[0][1].GetChan();
1789 UInt_t uPosXB =
fvbHodoSwapXY[1] ? lastHitHodoAxis[1][1].GetChan()
1790 : lastHitHodoAxis[1][0].GetChan();
1791 UInt_t uPosYB =
fvbHodoSwapXY[1] ? lastHitHodoAxis[1][0].GetChan()
1792 : lastHitHodoAxis[1][1].GetChan();
1799 Double_t dResX = uPosXB;
1800 Double_t dResY = uPosYB;
1822 Double_t dTimeSinceStart = (dTimeHitHodoAB -
fdStartTime) * 1e-9;
1862 for (UInt_t uHodoIdx = 0; uHodoIdx <
kuNbHodos; ++uHodoIdx) {
1863 for (UInt_t uAxis = 0; uAxis <
kuNbAxis; ++uAxis) {
1893 for (UInt_t uAxis = 0; uAxis <
kuNbAxis; ++uAxis) {