17#include "FairRootManager.h"
19#include "FairRunOnline.h"
20#include "FairRuntimeDb.h"
27#include "TPaveStats.h"
43 fbEtofFeeIndexing(kTRUE)
44 , fvbMaskedComponents()
52 , fuNrOfChannelsPerGet4(0)
53 , fuNrOfChannelsPerFee(0)
55 , fuNrOfGet4PerGdpb(0)
56 , fuNrOfChannelsPerGdpb(0)
63 , fdTsStopTimeCore(-1.0)
66 , fuCurrentEquipmentId(0)
72 , fvulCurrentEpochCycle()
73 , fvulCurrentEpochFull()
80 , fuHistoryHistoSize(1800)
81 , fvvhFeePairPulserTimeDiff()
82 , fhPulserTimeDiffMean(nullptr)
83 , fhPulserTimeDiffRms(nullptr)
84 , fhPulserTimeDiffRmsZoom(nullptr)
85 , fhPulserRmsGdpbToRefEvo(nullptr)
86 , fhPulserRmsGbtxToRefEvo(nullptr)
98 LOG(info) <<
"Initializing mCBM Bmon 2019 monitor algo";
113 LOG(info) <<
"Init parameter containers for CbmStar2019MonitorPulserAlgo";
120 LOG(info) <<
"**********************************************";
121 LOG(info) <<
"ReInit parameter containers for CbmStar2019MonitorPulserAlgo";
168 LOG(info) <<
"GDPB Id of TOF " << i <<
" : " << std::hex <<
fUnpackPar->
GetGdpbId(i) << std::dec;
173 LOG(info) <<
"Timeslice parameters: each MS is " <<
fdMsSizeInNs <<
" ns";
179 LOG(fatal) <<
"Selected sector out of bounds relative to parameter file: " <<
fiSectorIndex <<
" VS "
183 <<
" for single sector analysis";
189 if (
fbEtofFeeIndexing) LOG(info) <<
"Using eTOF indexing with only 3 FEE per GBTx instead of 5";
197 for (UInt_t uGdpb = 0; uGdpb <
fuNrOfGdpbs; ++uGdpb) {
216 LOG(info) <<
"CbmStar2019MonitorPulserAlgo::AddMsComponentToList => Component " << component <<
" with detector ID 0x"
217 << std::hex << usDetectorId << std::dec <<
" added to list";
224 fdTsStartTime =
static_cast<Double_t
>(ts.descriptor(0, 0).idx);
236 <<
" Overlap MS, for a core duration of " <<
fdTsCoreSizeInNs <<
" ns and a full duration of "
242 LOG(info) <<
"In each TS " <<
fuNbMsLoop <<
" MS will be looped over";
270 auto msDescriptor = ts.descriptor(uMsCompIdx, uMsIdx);
272 const uint8_t* msContent =
reinterpret_cast<const uint8_t*
>(ts.content(uMsCompIdx, uMsIdx));
274 uint32_t uSize = msDescriptor.size;
278 <<
" has size: " << uSize;
291 LOG(info) <<
"---------------------------------------------------------------";
293 LOG(warning) <<
"Could not find the gDPB index for AFCK id 0x" << std::hex <<
fuCurrDpbId << std::dec
294 <<
" in timeslice " <<
fulCurrentTsIdx <<
" in microslice " << uMsIdx <<
" component " << uMsCompIdx
296 <<
"If valid this index has to be added in the TOF "
297 "parameter file in the DbpIdArray field";
313 LOG(error) <<
"The input microslice buffer does NOT "
314 <<
"contain only complete nDPB messages!";
320 Int_t messageType = -111;
321 const uint64_t* pInBuff =
reinterpret_cast<const uint64_t*
>(msContent);
322 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
324 uint64_t ulData =
static_cast<uint64_t
>(pInBuff[uIdx]);
341 <<
" set in parameters.";
343 switch (messageType) {
347 LOG(fatal) <<
"This monitor does not support 24b hit messages!!!.";
361 LOG(fatal) <<
"This event builder does not support unmerged epoch "
377 LOG(fatal) <<
"Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType)
378 <<
" not included in Get4 data format.";
393 LOG(warning) <<
"CbmStar2019MonitorPulserAlgo::ProcessEpochCycle => "
394 <<
" Missmatch in epoch cycles detected for Gdpb " <<
fuCurrDpbIdx
395 <<
", probably fake cycles due to epoch index corruption! "
400 LOG(info) <<
"CbmStar2019EventBuilderEtofAlgo::ProcessEpochCycle => "
430 if (0 == iBufferSize)
return;
432 LOG(debug) <<
"Now processing stored messages for for gDPB " <<
fuCurrDpbIdx <<
" with epoch number "
443 if (0 == ulCurEpochGdpbGet4)
return;
446 ulCurEpochGdpbGet4--;
448 Int_t messageType = -111;
449 for (Int_t iMsgIdx = 0; iMsgIdx < iBufferSize; iMsgIdx++) {
459 switch (messageType) {
474 LOG(error) <<
"Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType)
475 <<
" not included in Get4 unpacker.";
521 std::string sFolder =
"eTofMoni";
523 LOG(info) <<
"create Histos for eTOF monitoring ";
526 // Number of log bins =
527 // 9 for the sub-unit decade
528 // + 9 for each unit of each decade * 10 for the subdecade range
529 // + 1 for the closing bin top edge
530 const Int_t iNbDecadesLog = 4;
531 const Int_t iNbStepsDecade = 9;
532 const Int_t iNbSubStepsInStep = 1;
533 const Int_t iNbBinsLog = iNbStepsDecade
534 + iNbStepsDecade * iNbSubStepsInStep * iNbDecadesLog
536 Double_t dBinsLog[iNbBinsLog];
537 // First fill sub-unit decade
538 for( Int_t iSubU = 0; iSubU < iNbStepsDecade; iSubU ++ )
539 dBinsLog[ iSubU ] = 0.1 * ( 1 + iSubU );
540 std::cout << std::endl;
541 // Then fill the main decades
542 Double_t dSubstepSize = 1.0 / iNbSubStepsInStep;
543 for( Int_t iDecade = 0; iDecade < iNbDecadesLog; iDecade ++)
545 Double_t dBase = std::pow( 10, iDecade );
546 Int_t iDecadeIdx = iNbStepsDecade
547 + iDecade * iNbStepsDecade * iNbSubStepsInStep;
548 for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ )
550 Int_t iStepIdx = iDecadeIdx + iStep * iNbSubStepsInStep;
551 for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ )
553 dBinsLog[ iStepIdx + iSubStep ] = dBase * (1 + iStep)
554 + dBase * dSubstepSize * iSubStep;
555 } // for( Int_t iSubStep = 0; iSubStep < iNbSubStepsInStep; iSubStep++ )
556 } // for( Int_t iStep = 0; iStep < iNbStepsDecade; iStep++ )
557 } // for( Int_t iDecade = 0; iDecade < iNbDecadesLog; iDecade ++)
558 dBinsLog[ iNbBinsLog - 1 ] = std::pow( 10, iNbDecadesLog );
577 UInt_t uFeeIndexA = uFeeA;
579 uFeeIndexA = 3 * (uFeeA / 5) + (uFeeA % 5);
582 UInt_t uFeeIdA = uFeeIndexA - (3 * 6 * uGdpbA);
587 if (uFeeA < uFeeB && (!
fbEtofFeeIndexing || ((uFeeA % 5) < 3 && (uFeeB % 5) < 3))) {
589 UInt_t uFeeIndexB = uFeeB;
597 UInt_t uFeeIdB = uFeeIndexB - (3 * 6 * uGdpbB);
599 new TH1I(Form(
"hFeePairPulserTimeDiff_s%02u_f%1u_s%02u_f%1u", uSectorA, uFeeIdA, uSectorB, uFeeIdB),
600 Form(
"Time difference for pulser on sector %02u FEE %1u and "
601 "sector %02u FEE %1u; DeltaT [ps]; Counts",
602 uSectorA, uFeeIdA, uSectorB, uFeeIdB),
622 new TH2D(
"hPulserTimeDiffMean",
"Time difference Mean for each FEE pairs; FEE A; FEE B ; Mean [ps]",
623 uTotalNbFee - 1, -0.5, uTotalNbFee - 1.5, uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5);
626 new TH2D(
"hPulserTimeDiffRms",
"Time difference RMS for each FEE pairs; FEE A; FEE B ; RMS [ps]", uTotalNbFee - 1,
627 -0.5, uTotalNbFee - 1.5, uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5);
630 "Time difference RMS for each FEE pairs after zoom on peak; FEE "
631 "A; FEE B ; RMS [ps]",
632 uTotalNbFee - 1, -0.5, uTotalNbFee - 1.5, uTotalNbFee - 1, 0.5, uTotalNbFee - 0.5);
636 new TH2D(
"hPulserRmsGdpbToRefEvo",
637 "Evo. of Time difference RMS for selected FEE of each sector to "
638 "the 1st; Time in run [s] A; Sector ; RMS [ps]",
643 new TH2D(
"hPulserTimeDiffRmsZoom",
644 "Evo. of Time difference RMS for selected FEE pairs of each GBTx to the "
645 "1st in same sector; Time in run [s] A; FEE ; RMS [ps]",
650 new TH2D(
"hPulserRmsGdpbToRefEvo",
651 "Evo. of Time difference RMS for selected FEE of each gDPb to "
652 "the 1st; Time in run [s] A; gDPB ; RMS [ps]",
656 new TH2D(
"hPulserTimeDiffRmsZoom",
657 "Evo. of Time difference RMS for selected FEE pairs of each GBTx to the "
658 "1st in same gDPB; Time in run [s] A; FEE ; RMS [ps]",
671 fcSummary =
new TCanvas(
"cSummary",
"Pulser Monitoring Summary");
727 UInt_t uFeeIndexA = uFeeA;
728 UInt_t uFeeIndexB = uFeeB;
731 uFeeIndexA = 3 * (uFeeA / 5) + (uFeeA % 5);
732 uFeeIndexB = 3 * (uFeeB / 5) + (uFeeB % 5);
750 if ((dZoomCounts / dNbCounts) < 0.8) {
792 UInt_t uFeeIndexA = uFeeA;
793 UInt_t uFeeIndexB = uFeeB;
796 uFeeIndexA = 3 * (uFeeA / 5) + (uFeeA % 5);
797 uFeeIndexB = 3 * (uFeeB / 5) + (uFeeB % 5);
815 if ((dZoomCounts / dNbCounts) < 0.8) {
817 LOG(warning) <<
"CbmStar2019MonitorPulserAlgo::FillHistograms => Zoom too strong, "
818 <<
"more than 20% loss for FEE pair " << uFeeA <<
" and " << uFeeB <<
" !!! ";
828 LOG(info) <<
"Stats FEE A " << std::setw(3) << uFeeIndexA <<
" FEE B " << std::setw(3) << uFeeIndexB
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
void ProcessEpochCycle(uint64_t ulCycleData)
std::vector< std::vector< TH1 * > > fvvhFeePairPulserTimeDiff
Size in seconds of the evolution histograms.
UInt_t fuNrOfFeePerGdpb
gDPB ID to index map
TCanvas * fcSummary
Canvases.
Bool_t ProcessTs(const fles::Timeslice &ts)
void ProcessEpoch(gdpbv100::Message mess)
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
UInt_t fuGet4Nr
running number (0 to fuNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message
const Double_t kdMaxDtPulserPs
[ Sector ][ FEE ]
void ProcessHit(gdpbv100::FullMessage mess)
static const UInt_t kuBytesPerMessage
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
void ProcessEpSupprBuffer()
TH2 * fhPulserTimeDiffRmsZoom
const Double_t kdFitZoomWidthPs
std::vector< ULong64_t > fvulCurrentEpoch
Data format control: Current time references for each GDPB: merged epoch marker, epoch cycle,...
std::vector< ULong64_t > fvulCurrentEpochFull
Epoch cycle from the Ms Start message and Epoch counter flip.
std::vector< Bool_t > fvbMaskedComponents
std::vector< std::vector< Double_t > > fvvdFeeHits
[ Sector ][ FEE ]
TH2 * fhPulserRmsGbtxToRefEvo
Double_t fdStartTime
Starting time and time evolution book-keeping.
UInt_t fuHistoryHistoSize
Time of first MS.
TH2 * fhPulserTimeDiffMean
[ FEE A ][ FEE B ]
TH2 * fhPulserRmsGdpbToRefEvo
std::vector< ULong64_t > fvulCurrentEpochCycle
Current epoch index, per DPB.
UInt_t fuNrOfGet4PerGdpb
Total number of Get4 chips in the system.
Bool_t ReInitContainers()
ULong64_t fulCurrentMsIdx
CbmStar2019MonitorPulserAlgo()
std::vector< gdpbv100::Message > fvmEpSupprBuffer
Epoch + Epoch Cycle.
~CbmStar2019MonitorPulserAlgo()
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
ULong64_t fulCurrentTsIdx
UInt_t fuNrOfChannelsPerFee
Number of channels in each GET4.
TH2 * fhPulserTimeDiffRms
UInt_t fuCurrentEquipmentId
Bool_t CreateHistograms()
Double_t fdMsTime
End Time in ns of current TS Core from the index of the first MS first component.
Bool_t fbEtofFeeIndexing
Control flags.
std::vector< std::vector< Bool_t > > fvvbFeeHitFound
Storing the time of the last hit for each MS in each of the FEE.
UInt_t fuNrOfChannelsPerGet4
Number of GET4s per FEE.
Double_t fdTsStopTimeCore
Time in ns of current TS from the index of the first MS first component.
UInt_t fuGet4Id
Index of the DPB from which the MS currently unpacked is coming.
UInt_t fuNrOfGet4
Number of channels in each FEE.
UInt_t fuNrOfGet4PerFee
Number of FEBs per GDPB.
CbmStar2019TofPar * fUnpackPar
Settings from parameter file.
UInt_t fuNrOfChannelsPerGdpb
Number of GET4s per GDPB.
std::map< UInt_t, UInt_t > fGdpbIdIndexMap
Total number of GDPBs in the system.
Bool_t ProcessMs(const fles::Timeslice &ts, size_t uMsCompIdx, size_t uMsIdx)
UInt_t fuMsIndex
Start Time in ns of current MS from its index field in header.
UInt_t fuPulserMinTot
Number of channels per GDPB.
static constexpr UInt_t GetNrOfFeePerGdpb()
Int_t ElinkIdxToGet4Idx(UInt_t uElink)
static constexpr UInt_t GetGdpbToSectorOffset()
Int_t Get4ChanToPadiChan(UInt_t uChannelInFee)
static constexpr UInt_t GetNrOfChannelsPerGet4()
static constexpr UInt_t GetNrOfGet4PerFee()
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