16#include "FairRootManager.h"
18#include "FairRunOnline.h"
19#include "FairRuntimeDb.h"
24#include "TPaveStats.h"
95 LOG(info) <<
"Initializing mCBM T0 2019 monitor algo";
110 LOG(info) <<
"Init parameter containers for CbmMcbm2018MonitorAlgoTofPulser";
117 LOG(info) <<
"**********************************************";
118 LOG(info) <<
"ReInit parameter containers for CbmMcbm2018MonitorAlgoTofPulser";
165 LOG(info) <<
"GDPB Id of TOF " << i <<
" : " << std::hex <<
fUnpackPar->GetGdpbId(i) << std::dec;
170 LOG(info) <<
"Timeslice parameters: each MS is " <<
fdMsSizeInNs <<
" ns";
175 LOG(fatal) <<
"Selected gDPB out of bounds relative to parameter file: " <<
fiGdpbIndex <<
" VS " <<
fuNrOfGdpbs;
177 LOG(info) <<
"Selected gDPB " <<
fiGdpbIndex <<
" for single gDPB analysis";
189 for (UInt_t uGdpb = 0; uGdpb <
fuNrOfGdpbs; ++uGdpb) {
208 LOG(info) <<
"CbmMcbm2018MonitorAlgoTofPulser::AddMsComponentToList => Component " << component
209 <<
" with detector ID 0x" << std::hex << usDetectorId << std::dec <<
" added to list";
216 fdTsStartTime =
static_cast<Double_t
>(ts.descriptor(0, 0).idx);
228 <<
" Overlap MS, for a core duration of " <<
fdTsCoreSizeInNs <<
" ns and a full duration of "
234 LOG(info) <<
"In each TS " <<
fuNbMsLoop <<
" MS will be looped over";
262 auto msDescriptor = ts.descriptor(uMsCompIdx, uMsIdx);
264 const uint8_t* msContent =
reinterpret_cast<const uint8_t*
>(ts.content(uMsCompIdx, uMsIdx));
266 uint32_t uSize = msDescriptor.size;
271 <<
" has size: " << uSize;
284 LOG(info) <<
"---------------------------------------------------------------";
286 LOG(warning) <<
"Could not find the gDPB index for AFCK id 0x" << std::hex <<
fuCurrDpbId << std::dec
287 <<
" in timeslice " <<
fulCurrentTsIdx <<
" in microslice " << uMsIdx <<
" component " << uMsCompIdx
289 <<
"If valid this index has to be added in the TOF "
290 "parameter file in the DbpIdArray field";
306 LOG(error) <<
"The input microslice buffer does NOT "
307 <<
"contain only complete nDPB messages!";
313 Int_t messageType = -111;
314 const uint64_t* pInBuff =
reinterpret_cast<const uint64_t*
>(msContent);
315 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
317 uint64_t ulData =
static_cast<uint64_t
>(pInBuff[uIdx]);
336 <<
" set in parameters.";
338 switch (messageType) {
342 LOG(fatal) <<
"This monitor does not support 24b hit messages!!!.";
356 LOG(fatal) <<
"This event builder does not support unmerged epoch "
372 LOG(fatal) <<
"Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType)
373 <<
" not included in Get4 data format.";
388 LOG(warning) <<
"CbmMcbm2018MonitorAlgoTofPulser::ProcessEpochCycle => "
389 <<
" Missmatch in epoch cycles detected for Gdpb " <<
fuCurrDpbIdx
390 <<
", probably fake cycles due to epoch index corruption! "
395 LOG(info) <<
"CbmMcbm2018MonitorAlgoTofPulser::ProcessEpochCycle => "
425 if (0 == iBufferSize)
return;
427 LOG(debug) <<
"Now processing stored messages for for gDPB " <<
fuCurrDpbIdx <<
" with epoch number "
438 if (0 == ulCurEpochGdpbGet4)
return;
441 ulCurEpochGdpbGet4--;
443 Int_t messageType = -111;
444 for (
Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++) {
456 switch (messageType) {
471 LOG(error) <<
"Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType)
472 <<
" not included in Get4 unpacker.";
495 UInt_t uRemappedChanNrInFee =
fUnpackPar->Get4ChanToPadiChan(uChannelNrInFee);
511 if ((0 ==
fuGet4Id / 2) && (185 < uTot && uTot < 190)) {
525 std::string sFolder =
"mTofMoni";
527 LOG(info) <<
"create Histos for mTof monitoring ";
547 UInt_t uFeeIndexA = uFeeA;
549 UInt_t uFeeIdA = uFeeIndexA - (3 * 6 * uGdpbA);
556 UInt_t uFeeIndexB = uFeeB;
561 UInt_t uFeeIdB = uFeeIndexB - (3 * 6 * uGdpbB);
563 Form(
"hFeePairPulserTimeDiff_s%02u_f%1u_s%02u_f%1u", uGdpbA, uFeeIdA, uGdpbB, uFeeIdB),
564 Form(
"Time difference for pulser on gDPB %02u FEE %1u and gDPB %02u FEE %1u; DeltaT [ps]; Counts",
565 uGdpbA, uFeeIdA, uGdpbB, uFeeIdB ),
569 Form(
"TofDt/s%03u", uFeeIndexA));
581 "Time difference Mean for each FEE pairs; FEE A; FEE B ; Mean [ps]",
582 uTotalNbFee - 1, -0.5, uTotalNbFee - 1.5,
583 uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5 );
586 "Time difference RMS for each FEE pairs; FEE A; FEE B ; RMS [ps]",
587 uTotalNbFee - 1, -0.5, uTotalNbFee - 1.5,
588 uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5 );
591 "Time difference RMS for each FEE pairs after zoom on peak; FEE A; FEE B ; RMS [ps]",
592 uTotalNbFee - 1, -0.5, uTotalNbFee - 1.5,
593 uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5 );
597 "Evo. of Time difference RMS for selected FEE of each gDPb to the 1st; Time in run [s] A; gDPB ; RMS [ps]",
602 "Evo. of Time difference RMS for selected FEE pairs of each GBTx to the 1st in same gDPB; Time in run [s] A; FEE ; RMS [ps]",
604 uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5 );
617 fcSummary =
new TCanvas(
"cSummary",
"Pulser Monitoring Summary");
680 UInt_t uFeeIndexA = uFeeA;
681 UInt_t uFeeIndexB = uFeeB;
698 if ((dZoomCounts / dNbCounts) < 0.8) {
734 UInt_t uFeeIndexA = uFeeA;
735 UInt_t uFeeIndexB = uFeeB;
752 if ((dZoomCounts / dNbCounts) < 0.8) {
754 LOG(warning) <<
"CbmMcbm2018MonitorAlgoTofPulser::FillHistograms => "
756 <<
"more than 20% loss for FEE pair " << uFeeA <<
" and " << uFeeB <<
" !!! ";
766 LOG(info) <<
"Stats FEE A " << std::setw(3) << uFeeIndexA <<
" FEE B " << std::setw(3) << uFeeIndexB
std::vector< std::vector< Double_t > > fvvdFeeHits
[ gDPB ][ FEE ]
UInt_t fuGet4Nr
running number (0 to fuNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message
UInt_t fuNrOfFeePerGdpb
gDPB ID to index map
std::vector< Bool_t > fvbMaskedComponents
Control flags.
const Double_t kdFitZoomWidthPs
void ProcessEpochCycle(uint64_t ulCycleData)
ULong64_t fulCurrentTsIdx
UInt_t fuGet4Id
Index of the DPB from which the MS currently unpacked is coming.
UInt_t fuNrOfChannelsPerFee
Number of channels in each GET4.
std::vector< std::vector< TH1 * > > fvvhFeePairPulserTimeDiff
Size in seconds of the evolution histograms.
CbmMcbm2018TofPar * fUnpackPar
Settings from parameter file.
TH2 * fhPulserRmsGdpbToRefEvo
Bool_t ReInitContainers()
std::map< UInt_t, UInt_t > fGdpbIdIndexMap
Total number of GDPBs in the system.
std::vector< gdpbv100::Message > fvmEpSupprBuffer
Epoch + Epoch Cycle.
UInt_t fuNrOfChannelsPerGet4
Number of GET4s per FEE.
std::vector< ULong64_t > fvulCurrentEpochFull
Epoch cycle from the Ms Start message and Epoch counter flip.
UInt_t fuNrOfGet4PerFee
Number of FEBs per GDPB.
void ProcessHit(gdpbv100::FullMessage mess)
TCanvas * fcSummary
Canvases.
Bool_t ProcessMs(const fles::Timeslice &ts, size_t uMsCompIdx, size_t uMsIdx)
CbmMcbm2018MonitorAlgoTofPulser()
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
UInt_t fuPulserMinTot
Number of channels per GDPB.
std::vector< ULong64_t > fvulCurrentEpoch
Data format control: Current time references for each GDPB: merged epoch marker, epoch cycle,...
TH2 * fhPulserRmsGbtxToRefEvo
Bool_t ProcessTs(const fles::Timeslice &ts)
Bool_t CreateHistograms()
UInt_t fuHistoryHistoSize
Time of first MS.
static const UInt_t kuBytesPerMessage
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
TH2 * fhPulserTimeDiffMean
[ FEE A ][ FEE B ]
Double_t fdTsStopTimeCore
Time in ns of current TS from the index of the first MS first component.
std::vector< ULong64_t > fvulCurrentEpochCycle
Current epoch index, per DPB.
void ProcessEpoch(gdpbv100::Message mess)
Double_t fdStartTime
Starting time and time evolution book-keeping.
TH2 * fhPulserTimeDiffRmsZoom
UInt_t fuNrOfGet4PerGdpb
Total number of Get4 chips in the system.
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
void ProcessEpSupprBuffer()
Double_t fdTsStartTime
SysId of the current MS in TS (0 to fuTotalMsNb)
UInt_t fuNrOfGet4
Number of channels in each FEE.
UInt_t fuMsIndex
Start Time in ns of current MS from its index field in header.
UInt_t fuCurrentEquipmentId
Double_t fdMsTime
End Time in ns of current TS Core from the index of the first MS first component.
uint32_t fuCurrentMsSysId
~CbmMcbm2018MonitorAlgoTofPulser()
UInt_t fuNrOfChannelsPerGdpb
Number of GET4s per GDPB.
const Double_t kdMaxDtPulserPs
[ gDPB ][ FEE ]
std::vector< std::vector< Bool_t > > fvvbFeeHitFound
Storing the time of the last hit for each MS in each of the FEE.
TH2 * fhPulserTimeDiffRms
ULong64_t fulCurrentMsIdx
Double_t fdTsCoreSizeInNs
void AddHistoToVector(TNamed *pointer, std::string sFolder="")
std::vector< size_t > fvMsComponentsList
void AddCanvasToVector(TCanvas *pointer, std::string sFolder="")
Double_t fdTsFullSizeInNs
double GetFullTimeNs() const
uint16_t getGdpbHitIs24b() const
uint32_t getGdpbEpEpochNb() const
uint16_t getGdpbHit32Tot() const
bool isStarTrigger() const
Returns true is message type is MSG_STAR_TRI_A, _B, _C, _D (STAR Trigger message)
uint16_t getGdpbGenChipId() const
uint8_t getMessageType() const
Returns the message type. Valid for all message types. 4 bit.
uint16_t getGdpbHitChanId() const
const uint32_t kuChipIdMergedEpoch
const uint32_t kuEpochCounterSz
const uint64_t kulEpochCycleFieldSz
const uint32_t kuEpochInBins