15 #include "FairLogger.h"
16 #include "FairRootManager.h"
18 #include "FairRunOnline.h"
19 #include "FairRuntimeDb.h"
23 #include "TClonesArray.h"
28 #include "THttpServer.h"
30 #include "TPaveStats.h"
32 #include "TProfile2D.h"
49 , fvMsComponentsList()
52 , fbIgnoreOverlapMs(kFALSE)
53 , fsHistoFileFullname(
"data/TofPulserHistos.root")
54 , fuMsAcceptsPercent(100)
59 , fdTsCoreSizeInNs(0.0)
66 , fuNrOfChannelsPerGet4(0)
67 , fuNrOfChannelsPerFee(0)
69 , fuNrOfGet4PerGdpb(0)
70 , fuNrOfChannelsPerGdpb(0)
71 , fulCurrentTsIndex(0)
80 , fviMsgCounter(11, 0)
86 , fvdPadiThrCodeToValue() {}
91 LOG(info) <<
"Initializing Get4 monitor";
93 FairRootManager* ioman = FairRootManager::Instance();
95 LOG(fatal) <<
"No FairRootManager instance";
102 LOG(info) <<
"Setting parameter containers for " << GetName();
105 "CbmMcbm2018TofPar"));
109 LOG(info) <<
"Init parameter containers for " << GetName();
118 LOG(info) <<
"ReInit parameter containers for " << GetName();
148 LOG(info) <<
"GDPB Id of TOF " <<
i <<
" : " << std::hex
160 LOG(info) <<
"Timeslice parameters: " <<
fuTotalMsNb
179 UInt_t uGet4topadi[32] = {4, 3, 2, 1,
180 8, 7, 6, 5, 12, 11, 10, 9, 16, 15,
181 14, 13, 20, 19, 18, 17, 24, 23, 22, 21,
182 28, 27, 26, 25, 32, 31, 30, 29};
184 UInt_t uPaditoget4[32] = {4, 3, 2, 1,
185 12, 11, 10, 9, 20, 19, 18, 17, 28, 27,
186 26, 25, 32, 31, 30, 29, 8, 7, 6, 5,
187 16, 15, 14, 13, 24, 23, 22, 21};
199 27, 2, 7, 3, 31, 26, 30, 1, 33, 37, 32, 13, 9, 14,
200 10, 15, 17, 21, 16, 35, 34, 38, 25, 24, 0, 6, 20, 23,
201 18, 22, 28, 4, 29, 5, 19, 36, 39, 8, 12, 11};
203 24, 7, 1, 3, 31, 33, 25, 2, 37, 12, 14, 39, 38, 11,
204 13, 15, 18, 16, 28, 34, 26, 17, 29, 27, 23, 22, 5, 0,
205 30, 32, 6, 4, 10, 8, 20, 19, 35, 9, 21, 36};
213 const UInt_t kuNbThrMeasPoints = 65;
214 UInt_t kuThrMeasCode[kuNbThrMeasPoints] = {
215 0x000, 0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070, 0x080, 0x090, 0x0A0,
216 0x0B0, 0x0C0, 0x0D0, 0x0E0, 0x0F0, 0x100, 0x110, 0x120, 0x130, 0x140, 0x150,
217 0x160, 0x170, 0x180, 0x190, 0x1A0, 0x1B0, 0x1C0, 0x1D0, 0x1E0, 0x1F0, 0x200,
218 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0x270, 0x280, 0x290, 0x2A0, 0x2B0,
219 0x2C0, 0x2D0, 0x2E0, 0x2F0, 0x300, 0x310, 0x320, 0x330, 0x340, 0x350, 0x360,
220 0x370, 0x380, 0x390, 0x3A0, 0x3B0, 0x3C0, 0x3D0, 0x3E0, 0x3F0, 0x3FF};
221 Double_t kdThrMeasVal[kuNbThrMeasPoints] = {
222 -652.6, -631.2, -611.4, -590.6, -570.9, -550.0, -529.9, -509.4, -490.6,
223 -469.5, -449.3, -428.5, -408.5, -388.2, -367.8, -347.2, -329.2, -308.2,
224 -287.5, -266.8, -246.9, -226.0, -205.6, -185.0, -165.7, -144.9, -124.4,
225 -103.8, -83.4, -62.9, -42.4, -21.2, -5.3, 15.5, 36.2, 56.8,
226 77.3, 97.8, 118.4, 139.1, 158.7, 179.2, 199.7, 220.2, 240.8,
227 261.1, 281.7, 302.2, 321.3, 341.4, 362.0, 382.2, 402.9, 422.8,
228 443.4, 463.7, 483.7, 503.7, 524.1, 544.3, 565.0, 585.0, 605.5,
232 for (UInt_t uPadiPoint = 0; uPadiPoint < kuNbThrMeasPoints; ++uPadiPoint) {
236 if (uPadiPoint + 1 < kuNbThrMeasPoints) {
238 kuThrMeasCode[uPadiPoint + 1] - kuThrMeasCode[uPadiPoint];
240 (kdThrMeasVal[uPadiPoint + 1] - kdThrMeasVal[uPadiPoint]) / uNbSteps;
241 UInt_t uCode = kuThrMeasCode[uPadiPoint];
242 for (UInt_t uStep = 1; uStep < uNbSteps; ++uStep) {
245 kdThrMeasVal[uPadiPoint] + dValStep * uStep;
272 LOG(info) <<
"create Histos for " <<
fuNrOfGdpbs <<
" gDPBs ";
274 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
277 "hGdpbAsicSpiCounts",
278 "SPI messages count per GDPB and ASIC; ASIC Idx []; GDPB []; SPI msg[]",
288 server->RegisterCommand(
"/Reset_All_eTOF",
289 "bMcbm2018TofFeeThrResetHistos=kTRUE");
290 server->RegisterCommand(
"/Save_All_eTof",
291 "bMcbm2018TofFeeThrSaveHistos=kTRUE");
293 server->Restrict(
"/Reset_All_eTof",
"allow=admin");
294 server->Restrict(
"/Save_All_eTof",
"allow=admin");
297 LOG(info) <<
"Leaving CreateHistograms";
303 LOG(info) <<
"Reset eTOF STAR histos ";
308 LOG(info) <<
"Start saving eTOF STAR histos ";
314 LOG(debug1) <<
"Timeslice contains " << ts.num_microslices(component)
321 Int_t messageType = -111;
325 for (UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx++) {
334 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
351 constexpr uint32_t kuBytesPerMessage = 8;
354 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
356 fdMsIndex =
static_cast<double>(msDescriptor.idx);
358 const uint8_t* msContent =
359 reinterpret_cast<const uint8_t*
>(ts.content(uMsComp, uMsIdx));
361 uint32_t size = msDescriptor.size;
364 LOG(debug) <<
"Microslice: " << msDescriptor.idx
365 <<
" has size: " << size;
368 if (0 != (size % kuBytesPerMessage))
369 LOG(error) <<
"The input microslice buffer does NOT "
370 <<
"contain only complete nDPB messages!";
373 uint32_t uNbMessages =
374 (size - (size % kuBytesPerMessage)) / kuBytesPerMessage;
383 <<
"---------------------------------------------------------------";
394 LOG(warning) <<
"Could not find the gDPB index for AFCK id 0x"
395 << std::hex <<
fuGdpbId << std::dec <<
" in timeslice "
397 <<
" component " << uMsCompIdx <<
"\n"
398 <<
"If valid this index has to be added in the TOF "
399 "parameter file in the RocIdArray field";
406 const uint64_t* pInBuff =
reinterpret_cast<const uint64_t*
>(msContent);
407 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
409 uint64_t ulData =
static_cast<uint64_t
>(pInBuff[uIdx]);
412 if (0 == uIdx) {
continue; }
429 LOG(warning) <<
"Message with Get4 ID too high: " <<
fuGet4Id
432 switch (messageType) {
445 LOG(error) <<
"Message type " << std::hex << std::setw(2)
446 <<
static_cast<uint16_t
>(messageType)
447 <<
" not included in Get4 unpacker.";
473 LOG(info) <<
"GET4 Slow Control message, time "
474 << Form(
"%3.3f", dMessTime) <<
" s "
475 <<
" for board ID " << std::hex << std::setw(4) <<
fuGdpbId
477 <<
" +++++++ > Chip = " << std::setw(3) <<
fuGet4Id
478 <<
", Chan = " << std::setw(1) << uChan
479 <<
", Edge = " << std::setw(1) << uEdge
481 << Form(
"channel %1u,", (uData >> 10) & 0xF)
482 << Form(
"value 0x%03x ", uData & 0x3FF)
484 << Form(
"(Data = 0x%06x) ", uData);
493 TString message_type;
496 case 0: message_type =
"NOP";
break;
497 case 1: message_type =
"HIT";
break;
498 case 2: message_type =
"EPOCH";
break;
499 case 3: message_type =
"SYNC";
break;
500 case 4: message_type =
"AUX";
break;
501 case 5: message_type =
"EPOCH2";
break;
502 case 6: message_type =
"GET4";
break;
503 case 7: message_type =
"SYS";
break;
504 case 8: message_type =
"GET4_SLC";
break;
505 case 9: message_type =
"GET4_32B";
break;
506 case 10: message_type =
"GET4_SYS";
break;
507 default: message_type =
"UNKNOWN";
break;
517 TDirectory* oldDir = NULL;
518 TFile* histoFile = NULL;
519 if (
"" != sFileName) {
523 histoFile =
new TFile(sFileName,
"RECREATE");
527 if (
"" != sFileName) {
535 LOG(info) <<
"Reseting all TOF histograms.";