13 #include "FairLogger.h"
14 #include "FairRootManager.h"
16 #include "FairRunOnline.h"
17 #include "FairRuntimeDb.h"
21 #include "TClonesArray.h"
26 #include "THttpServer.h"
28 #include "TPaveStats.h"
30 #include "TProfile2D.h"
46 , fvMsComponentsList()
49 , fbIgnoreOverlapMs(kFALSE)
50 , fsHistoFileFullname(
"data/TofPulserHistos.root")
51 , fuMsAcceptsPercent(100)
56 , fdTsCoreSizeInNs(0.0)
63 , fuNrOfChannelsPerGet4(0)
64 , fuNrOfChannelsPerFee(0)
66 , fuNrOfGet4PerGdpb(0)
67 , fuNrOfChannelsPerGdpb(0)
68 , fulCurrentTsIndex(0)
77 , fviMsgCounter(11, 0)
79 fhGdpbAsicSpiCounts(nullptr)
88 LOG(info) <<
"Initializing Get4 monitor";
90 FairRootManager* ioman = FairRootManager::Instance();
92 LOG(fatal) <<
"No FairRootManager instance";
99 LOG(info) <<
"Setting parameter containers for " << GetName();
102 "CbmStar2019TofPar"));
106 LOG(info) <<
"Init parameter containers for " << GetName();
115 LOG(info) <<
"ReInit parameter containers for " << GetName();
146 LOG(info) <<
"GDPB Id of TOF " <<
i <<
" : " << std::hex
156 LOG(info) <<
"Timeslice parameters: " <<
fuTotalMsNb
175 UInt_t uGet4topadi[32] = {4, 3, 2, 1,
176 8, 7, 6, 5, 12, 11, 10, 9, 16, 15,
177 14, 13, 20, 19, 18, 17, 24, 23, 22, 21,
178 28, 27, 26, 25, 32, 31, 30, 29};
180 UInt_t uPaditoget4[32] = {4, 3, 2, 1,
181 12, 11, 10, 9, 20, 19, 18, 17, 28, 27,
182 26, 25, 32, 31, 30, 29, 8, 7, 6, 5,
183 16, 15, 14, 13, 24, 23, 22, 21};
195 27, 2, 7, 3, 31, 26, 30, 1, 33, 37, 32, 13, 9, 14,
196 10, 15, 17, 21, 16, 35, 34, 38, 25, 24, 0, 6, 20, 23,
197 18, 22, 28, 4, 29, 5, 19, 36, 39, 8, 12, 11};
199 24, 7, 1, 3, 31, 33, 25, 2, 37, 12, 14, 39, 38, 11,
200 13, 15, 18, 16, 28, 34, 26, 17, 29, 27, 23, 22, 5, 0,
201 30, 32, 6, 4, 10, 8, 20, 19, 35, 9, 21, 36};
213 UShort_t usDetectorId) {
229 LOG(info) <<
"create Histos for " <<
fuNrOfGdpbs <<
" gDPBs ";
231 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
234 "hGdpbAsicSpiCounts",
235 "SPI messages count per GDPB and ASIC; ASIC Idx []; GDPB []; SPI msg[]",
245 server->RegisterCommand(
"/Reset_All_eTOF",
246 "bStar2019TofFeeThrResetHistos=kTRUE");
247 server->RegisterCommand(
"/Save_All_eTof",
248 "bStar2019TofFeeThrSaveHistos=kTRUE");
250 server->Restrict(
"/Reset_All_eTof",
"allow=admin");
251 server->Restrict(
"/Save_All_eTof",
"allow=admin");
254 LOG(info) <<
"Leaving CreateHistograms";
260 LOG(info) <<
"Reset eTOF STAR histos ";
265 LOG(info) <<
"Start saving eTOF STAR histos ";
271 LOG(debug1) <<
"Timeslice contains " << ts.num_microslices(component)
278 Int_t messageType = -111;
279 Double_t dTsStartTime = -1;
282 for (UInt_t uMsIdx = 0; uMsIdx < uNbMsLoop; uMsIdx++) {
291 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
293 <<
"hi hv eqid flag si sv idx/start crc size offset";
295 "%02x %02x %04x %04x %02x %02x %016lx %08x %08x %016lx",
296 static_cast<unsigned int>(msDescriptor.hdr_id),
297 static_cast<unsigned int>(msDescriptor.hdr_ver),
300 static_cast<unsigned int>(msDescriptor.sys_id),
301 static_cast<unsigned int>(msDescriptor.sys_ver),
305 msDescriptor.offset);
312 constexpr uint32_t kuBytesPerMessage = 8;
315 auto msDescriptor = ts.descriptor(uMsComp, uMsIdx);
317 fdMsIndex =
static_cast<double>(msDescriptor.idx);
319 const uint8_t* msContent =
320 reinterpret_cast<const uint8_t*
>(ts.content(uMsComp, uMsIdx));
322 uint32_t size = msDescriptor.size;
325 LOG(debug) <<
"Microslice: " << msDescriptor.idx
326 <<
" has size: " << size;
329 if (0 != (size % kuBytesPerMessage))
330 LOG(error) <<
"The input microslice buffer does NOT "
331 <<
"contain only complete nDPB messages!";
334 uint32_t uNbMessages =
335 (size - (size % kuBytesPerMessage)) / kuBytesPerMessage;
344 <<
"---------------------------------------------------------------";
346 <<
"hi hv eqid flag si sv idx/start crc size offset";
348 "%02x %02x %04x %04x %02x %02x %016lx %08x %08x %016lx",
349 static_cast<unsigned int>(msDescriptor.hdr_id),
350 static_cast<unsigned int>(msDescriptor.hdr_ver),
353 static_cast<unsigned int>(msDescriptor.sys_id),
354 static_cast<unsigned int>(msDescriptor.sys_ver),
358 msDescriptor.offset);
359 LOG(warning) <<
"Could not find the gDPB index for AFCK id 0x"
360 << std::hex <<
fuGdpbId << std::dec <<
" in timeslice "
362 <<
" component " << uMsCompIdx <<
"\n"
363 <<
"If valid this index has to be added in the TOF "
364 "parameter file in the RocIdArray field";
371 const uint64_t* pInBuff =
reinterpret_cast<const uint64_t*
>(msContent);
372 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
374 uint64_t ulData =
static_cast<uint64_t
>(pInBuff[uIdx]);
377 if (0 == uIdx) {
continue; }
394 LOG(warning) <<
"Message with Get4 ID too high: " <<
fuGet4Id
397 switch (messageType) {
410 LOG(error) <<
"Message type " << std::hex << std::setw(2)
411 <<
static_cast<uint16_t
>(messageType)
412 <<
" not included in Get4 unpacker.";
440 LOG(info) <<
"GET4 Slow Control message, time "
441 << Form(
"%3.3f", dMessTime) <<
" s "
442 << Form(
" for board %02u (ID %04x, sector %2u)",
447 <<
" +++++++ > Chip = " << std::setw(3) <<
fuGet4Id
448 <<
", Chan = " << std::setw(1) << uChan
449 <<
", Edge = " << std::setw(1) << uEdge
451 << Form(
"channel %1u,", (uData >> 10) & 0xF)
452 << Form(
"value 0x%03x ", uData & 0x3FF)
453 << Form(
"(Data = 0x%06x)", uData);
462 TString message_type;
465 case 0: message_type =
"NOP";
break;
466 case 1: message_type =
"HIT";
break;
467 case 2: message_type =
"EPOCH";
break;
468 case 3: message_type =
"SYNC";
break;
469 case 4: message_type =
"AUX";
break;
470 case 5: message_type =
"EPOCH2";
break;
471 case 6: message_type =
"GET4";
break;
472 case 7: message_type =
"SYS";
break;
473 case 8: message_type =
"GET4_SLC";
break;
474 case 9: message_type =
"GET4_32B";
break;
475 case 10: message_type =
"GET4_SYS";
break;
476 default: message_type =
"UNKNOWN";
break;
486 TDirectory* oldDir = NULL;
487 TFile* histoFile = NULL;
488 if (
"" != sFileName) {
492 histoFile =
new TFile(sFileName,
"RECREATE");
496 if (
"" != sFileName) {
504 LOG(info) <<
"Reseting all TOF histograms.";