17#include "FairRootManager.h"
19#include "FairRunOnline.h"
20#include "FairRuntimeDb.h"
27#include "TPaveStats.h"
51 , fuNrOfChannelsPerGet4(0)
52 , fuNrOfChannelsPerFee(0)
54 , fuNrOfGet4PerGdpb(0)
55 , fuNrOfChannelsPerGdpb(0)
62 , fdTsStopTimeCore(-1.0)
65 , fuCurrentEquipmentId(0)
71 , fvulCurrentEpochCycle()
72 , fvulCurrentEpochFull()
79 , fuHistoryHistoSize(1800)
80 , fvvhFeePairPulserTimeDiff()
81 , fhPulserTimeDiffMean(nullptr)
82 , fhPulserTimeDiffRms(nullptr)
83 , fhPulserTimeDiffRmsZoom(nullptr)
84 , fhPulserRmsGdpbToRefEvo(nullptr)
85 , fhPulserRmsGbtxToRefEvo(nullptr)
97 LOG(info) <<
"Initializing mCBM T0 2019 monitor algo";
112 LOG(info) <<
"Init parameter containers for CbmMcbm2018MonitorAlgoTofPulser";
119 LOG(info) <<
"**********************************************";
120 LOG(info) <<
"ReInit parameter containers for CbmMcbm2018MonitorAlgoTofPulser";
167 LOG(info) <<
"GDPB Id of TOF " << i <<
" : " << std::hex <<
fUnpackPar->
GetGdpbId(i) << std::dec;
172 LOG(info) <<
"Timeslice parameters: each MS is " <<
fdMsSizeInNs <<
" ns";
177 LOG(fatal) <<
"Selected gDPB out of bounds relative to parameter file: " <<
fiGdpbIndex <<
" VS " <<
fuNrOfGdpbs;
179 LOG(info) <<
"Selected gDPB " <<
fiGdpbIndex <<
" for single gDPB analysis";
191 for (UInt_t uGdpb = 0; uGdpb <
fuNrOfGdpbs; ++uGdpb) {
210 LOG(info) <<
"CbmMcbm2018MonitorAlgoTofPulser::AddMsComponentToList => Component " << component
211 <<
" with detector ID 0x" << std::hex << usDetectorId << std::dec <<
" added to list";
218 fdTsStartTime =
static_cast<Double_t
>(ts.descriptor(0, 0).idx);
230 <<
" Overlap MS, for a core duration of " <<
fdTsCoreSizeInNs <<
" ns and a full duration of "
236 LOG(info) <<
"In each TS " <<
fuNbMsLoop <<
" MS will be looped over";
264 auto msDescriptor = ts.descriptor(uMsCompIdx, uMsIdx);
266 const uint8_t* msContent =
reinterpret_cast<const uint8_t*
>(ts.content(uMsCompIdx, uMsIdx));
268 uint32_t uSize = msDescriptor.size;
273 <<
" has size: " << uSize;
286 LOG(info) <<
"---------------------------------------------------------------";
288 LOG(warning) <<
"Could not find the gDPB index for AFCK id 0x" << std::hex <<
fuCurrDpbId << std::dec
289 <<
" in timeslice " <<
fulCurrentTsIdx <<
" in microslice " << uMsIdx <<
" component " << uMsCompIdx
291 <<
"If valid this index has to be added in the TOF "
292 "parameter file in the DbpIdArray field";
308 LOG(error) <<
"The input microslice buffer does NOT "
309 <<
"contain only complete nDPB messages!";
315 Int_t messageType = -111;
316 const uint64_t* pInBuff =
reinterpret_cast<const uint64_t*
>(msContent);
317 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
319 uint64_t ulData =
static_cast<uint64_t
>(pInBuff[uIdx]);
338 <<
" set in parameters.";
340 switch (messageType) {
344 LOG(fatal) <<
"This monitor does not support 24b hit messages!!!.";
358 LOG(fatal) <<
"This event builder does not support unmerged epoch "
374 LOG(fatal) <<
"Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType)
375 <<
" not included in Get4 data format.";
390 LOG(warning) <<
"CbmMcbm2018MonitorAlgoTofPulser::ProcessEpochCycle => "
391 <<
" Missmatch in epoch cycles detected for Gdpb " <<
fuCurrDpbIdx
392 <<
", probably fake cycles due to epoch index corruption! "
397 LOG(info) <<
"CbmMcbm2018MonitorAlgoTofPulser::ProcessEpochCycle => "
427 if (0 == iBufferSize)
return;
429 LOG(debug) <<
"Now processing stored messages for for gDPB " <<
fuCurrDpbIdx <<
" with epoch number "
440 if (0 == ulCurEpochGdpbGet4)
return;
443 ulCurEpochGdpbGet4--;
445 Int_t messageType = -111;
446 for (Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++) {
458 switch (messageType) {
473 LOG(error) <<
"Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType)
474 <<
" not included in Get4 unpacker.";
513 if ((0 ==
fuGet4Id / 2) && (185 < uTot && uTot < 190)) {
527 std::string sFolder =
"mTofMoni";
529 LOG(info) <<
"create Histos for mTof monitoring ";
549 UInt_t uFeeIndexA = uFeeA;
551 UInt_t uFeeIdA = uFeeIndexA - (3 * 6 * uGdpbA);
558 UInt_t uFeeIndexB = uFeeB;
563 UInt_t uFeeIdB = uFeeIndexB - (3 * 6 * uGdpbB);
565 Form(
"hFeePairPulserTimeDiff_s%02u_f%1u_s%02u_f%1u", uGdpbA, uFeeIdA, uGdpbB, uFeeIdB),
566 Form(
"Time difference for pulser on gDPB %02u FEE %1u and gDPB %02u FEE %1u; DeltaT [ps]; Counts",
567 uGdpbA, uFeeIdA, uGdpbB, uFeeIdB ),
571 Form(
"TofDt/s%03u", uFeeIndexA));
583 "Time difference Mean for each FEE pairs; FEE A; FEE B ; Mean [ps]",
584 uTotalNbFee - 1, -0.5, uTotalNbFee - 1.5,
585 uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5 );
588 "Time difference RMS for each FEE pairs; FEE A; FEE B ; RMS [ps]",
589 uTotalNbFee - 1, -0.5, uTotalNbFee - 1.5,
590 uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5 );
593 "Time difference RMS for each FEE pairs after zoom on peak; FEE A; FEE B ; RMS [ps]",
594 uTotalNbFee - 1, -0.5, uTotalNbFee - 1.5,
595 uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5 );
599 "Evo. of Time difference RMS for selected FEE of each gDPb to the 1st; Time in run [s] A; gDPB ; RMS [ps]",
604 "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]",
606 uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5 );
619 fcSummary =
new TCanvas(
"cSummary",
"Pulser Monitoring Summary");
682 UInt_t uFeeIndexA = uFeeA;
683 UInt_t uFeeIndexB = uFeeB;
700 if ((dZoomCounts / dNbCounts) < 0.8) {
736 UInt_t uFeeIndexA = uFeeA;
737 UInt_t uFeeIndexB = uFeeB;
754 if ((dZoomCounts / dNbCounts) < 0.8) {
756 LOG(warning) <<
"CbmMcbm2018MonitorAlgoTofPulser::FillHistograms => "
758 <<
"more than 20% loss for FEE pair " << uFeeA <<
" and " << uFeeB <<
" !!! ";
768 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
static constexpr UInt_t GetNrOfFeePerGdpb()
Int_t GetNrOfGdpbs()
FIXME: replace with method returning the correspondign constants! see Star2019 parameter.
Int_t GetNrOfGet4PerFee()
Int_t Get4ChanToPadiChan(UInt_t uChannelInFee)
Int_t GetNrOfChannelsPerGet4()
Int_t ElinkIdxToGet4Idx(UInt_t uElink)
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