10#include <FairParGenericSet.h>
15#include <RtypesCore.h>
25std::vector<std::pair<std::string, std::shared_ptr<FairParGenericSet>>>*
29 std::string basepath = Form(
"%s", fParFilesBasePath.data());
30 std::string temppath =
"";
34 LOG(info) << fName <<
"::GetParContainerRequest - Trying to open file " << temppath;
37 LOG(info) << fName <<
"::GetParContainerRequest - Requesting CbmMcbm2018BmonPar instead of CbmMcbm2018TofPar";
38 fParContVec.emplace_back(std::make_pair(temppath, std::make_shared<CbmMcbm2018BmonPar>()));
41 fParContVec.emplace_back(std::make_pair(temppath, std::make_shared<CbmMcbm2018TofPar>()));
50 LOG(info) << fName << std::endl
61 LOG(info) << fName <<
"::initParSet - for container " << parset->ClassName();
62 if (parset->IsA() == CbmMcbm2018BmonPar::Class()) {
67 else if (parset->IsA() == CbmMcbm2018TofPar::Class()) {
73 << fName <<
"::initParSet - for container " << parset->ClassName()
74 <<
" failed, since CbmTofUnpackAlgo::initParSet() does not know the derived ParSet and what to do with it!";
83 LOG(debug) <<
"InitParameters from " << parset;
112 LOG(debug) <<
"GDPB Id of TOF " << i <<
" : " << std::hex << parset->
GetGdpbId(i) << std::dec;
119 LOG(debug) <<
"Nr. of possible Tof channels: " << uNrOfChannels;
124 TString sPrintout =
"";
125 for (UInt_t uCh = 0; uCh < uNrOfChannels; ++uCh) {
126 if (0 == uCh % 8) sPrintout +=
"\n";
129 sPrintout += Form(
"\n Gdpb %u (0x%x), index %u \n", uGdpbIdx, parset->
GetGdpbId(uGdpbIdx), uCh);
132 sPrintout +=
" ----------";
138 LOG(debug) << sPrintout;
140 LOG(info) << fName <<
"::initParSetTofMcbm2018 - Successfully initialized TOF settings";
144 LOG(info) << fName <<
"::initParSetTofMcbm2018 - Successfully initialized TOF monitor";
153 auto msDescriptor = ts->descriptor(icomp, imslice);
155 const uint8_t* msContent =
reinterpret_cast<const uint8_t*
>(ts->content(icomp, imslice));
158 uint32_t uSize = msDescriptor.size;
163 <<
" has size: " << uSize;
174 LOG(debug) <<
"---------------------------------------------------------------";
176 LOG(warning) << fName <<
"::unpack => "
177 <<
"Could not find the gDPB index for FLIM id 0x" << std::hex <<
fuCurrDpbId << std::dec
178 <<
" in timeslice " <<
fulCurrentTsIdx <<
" in microslice " << imslice <<
" component " << icomp
180 <<
"If valid this index has to be added in the TOF parameter file in the DbpIdArray field";
201 LOG(error) << fName <<
"::unpack => "
202 <<
"The input microslice buffer does NOT contain only complete gDPB messages!";
208 Int_t messageType = -111;
217 const uint64_t* pInBuff =
reinterpret_cast<const uint64_t*
>(msContent);
220 for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
222 if (0 < uIdx && pMess[uIdx] == pMess[uIdx - 1]) {
230 if (uNbMessages - 1 == uIdx) {
231 if (pMess[uIdx].isEndOfMs()) {
235 LOG(warning) << fName <<
"::unpack => "
236 <<
"In timeslice " <<
fulCurrentTsIdx <<
" in microslice " << imslice <<
" component " << icomp
237 <<
" last message is not an EndOfMs: type " << messageType
238 << Form(
" dump: 0x%16llX",
static_cast<unsigned long long int>(pMess[uIdx].getData()));
257 LOG(warning) << fName <<
"::unpack => "
263 LOG(warning) << fName <<
"::unpack => "
264 <<
"In timeslice " <<
fulCurrentTsIdx <<
" in microslice " << imslice <<
" component " << icomp
265 <<
" first message is not an epoch: type " << messageType
266 << Form(
" dump: 0x%16llX",
static_cast<unsigned long long int>(pMess[uIdx].getData()));
267 LOG(warning) << fName <<
"::unpack => "
268 <<
"Ignoring this microslice.";
272 switch (messageType) {
289 LOG(debug2) << fName <<
"::unpack => "
290 <<
"This unpacker does not support unmerged epoch messages!!!.";
300 pMess[uIdx].getGdpbSlcEdge(), pMess[uIdx].getGdpbSlcType());
311 pMess[uIdx].getGdpbSysErrData());
316 == pMess[uIdx].getGdpbSysErrData());
323 LOG(error) << fName <<
"::unpack => "
324 <<
"Message type " << std::hex << std::setw(2) << static_cast<uint16_t>(messageType) << std::dec
325 <<
" not included in Get4 unpacker.";
358 uint64_t ulMsStartInEpoch =
364 if (ulMsStartInEpoch < 4) {
368 ulMsStartInEpoch -= 4;
372 if (ulEpochNr != ulMsStartInEpoch) {
375 << fName <<
"::ProcessEpoch => Error first global epoch, "
376 << Form(
"from MS index 0x%06llx, current 0x%06llx, diff %lld, raw 0x%016llx, NoErr %d, current 0x%06lx %f",
377 static_cast<unsigned long long int>(ulMsStartInEpoch), ulEpochNr, ulEpochNr - ulMsStartInEpoch,
381 LOG(fatal) << fName <<
"::ProcessEpoch => Stopping there, system is not synchronized and send corrupt data";
384 ulEpochNr = ulMsStartInEpoch;
395 LOG(error) << fName <<
"::ProcessEpoch => Error global epoch, DPB 0x" << std::setw(4) << std::hex <<
fuCurrDpbId
397 << Form(
" last 0x%06llx, current 0x%06llx, diff %lld, raw 0x%016lx, NoErr %d",
fulCurrentEpoch,
400 LOG(error) << fName <<
"::ProcessEpoch => Ignoring data until next valid epoch";
421 LOG(debug) << fName <<
"::ProcessEpoch => "
422 << Form(
"Raw Epoch: 0x%06llx, Epoch offset 0x%06llx, Epoch in Ts: 0x%07lx, time %f ns (%f * %lu)",
449 uRemappedChannelNr = uChannelNr;
454 Double_t dHitTot = uTot;
465 LOG(debug) << fName <<
"::unpack => "
466 <<
"T0 data item at " << std::setw(4) << uRemappedChannelNrInSys <<
", from FLIM " <<
fuCurrDpbIdx
467 <<
", Get4 " << std::setw(2) <<
fuGet4Id <<
", Ch " << uChannel <<
", ChNr " << std::setw(2)
468 << uChannelNr <<
", ChNrIF " << std::setw(2) << uChannelNrInFee <<
", FiS " << std::setw(2)
472 : Form(
" 0x%08x",
fviRpcChUId[uRemappedChannelNrInSys]))
473 <<
" TOT " << std::setw(3) << uTot <<
" time " << dHitTime;
477 if (
fviRpcChUId.size() < uRemappedChannelNrInSys) {
478 LOG(fatal) << fName <<
"::unpack => "
479 <<
"Invalid mapping index " << uRemappedChannelNrInSys <<
" VS " <<
fviRpcChUId.size() <<
", from FLIM "
480 <<
fuCurrDpbIdx <<
", Get4 " <<
fuGet4Id <<
", Ch " << uChannel <<
", ChNr " << uChannelNr <<
", ChNrIF "
481 << uChannelNrInFee <<
", FiS " << uFeeNrInSys;
485 UInt_t uChanUId =
fviRpcChUId[uRemappedChannelNrInSys];
489 LOG(debug) << fName <<
"::unpack => "
490 <<
"Unused data item at " << uRemappedChannelNrInSys <<
", from FLIM " <<
fuCurrDpbIdx <<
", Get4 "
491 <<
fuGet4Id <<
", Ch " << uChannel <<
", ChNr " << uChannelNr <<
", ChNrIF " << uChannelNrInFee
492 <<
", FiS " << uFeeNrInSys;
496 dHitTime -= fSystemTimeOffset;
504 LOG(debug) << Form(
"Insert 0x%08x digi with time ", uChanUId) << dHitTime << Form(
", Tot %4.0f", dHitTot)
508 fMonitor->FillHitBmonMicroSpillHistos(dHitTime);
512 std::unique_ptr<CbmTofDigi> digi(
new CbmTofDigi(uChanUId, dHitTime, dHitTot));
513 if (digi) fOutputVec.emplace_back(*std::move(digi));
ClassImp(CbmConverterManager)
Baseclass for the TrdR unpacker algorithms.
std::vector< Int_t > GetRpcChUidMap()
Int_t GetNrOfGdpbs()
FIXME: replace with method returning the correspondign constants! see Star2019 parameter.
Int_t GetNrOfGet4PerFee()
Int_t GetNrOfFeesPerGdpb()
Int_t Get4ChanToPadiChan(UInt_t uChannelInFee)
bool CheckInnerComp(uint32_t uCompId)
Int_t GetNrOfChannelsPerGet4()
Int_t ElinkIdxToGet4Idx(UInt_t uElink)
Int_t ElinkIdxToGet4IdxA(UInt_t uElink)
Data class for expanded digital TOF information.
CbmMcbm2018TofPar * fUnpackPar
size_t fuCurrentMsSysId
Time of the current MS in s.
ULong64_t fulCurrentEpoch
Data format control: Current time references for each GDPB: merged epoch marker, epoch cycle,...
UInt_t fuCurrDpbIdx
Temp holder until Current equipment ID is properly filled in MS.
UInt_t fuNrOfGdpbs
For static/inline mapping functions.
UInt_t fuCurrDpbId
Current equipment ID, tells from which DPB the current MS is originating.
void ExtractTsStartEpoch(const uint64_t &ulTsStart)
Message processing methods.
bool fbEpochCountHack2021
Current epoch index.
UInt_t fuNrOfChannelsPerFee
Number of channels in each GET4.
Bool_t initParSet(FairParGenericSet *parset)
Handles the distribution of the hidden derived classes to their explicit functions.
UInt_t fuGet4Nr
running number (0 to fuNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message
void ProcessEpoch(const critof001::Message &mess, uint32_t uMesgIdx)
UInt_t fuNrOfChannelsPerGet4
Number of GET4s per FEE.
virtual ~CbmTofUnpackAlgo()
Destroy the Cbm Trd Unpack Task object.
ULong64_t fulCurrentMsIdx
Idx of the current TS.
ULong64_t fulCurrentTsIdx
CbmTofUnpackAlgo()
Create the Cbm Trd Unpack AlgoBase object.
UInt_t fuNrOfGet4PerFee
Number of FEBs per GDPB.
UInt_t fuMapWarnToPrint
Running indices.
void finishDerived()
Function that allows special calls during Finish in the derived algos.
void ProcessHit(const critof001::Message &mess)
uint64_t fulTsStartInEpoch
std::vector< bool > fvbMaskedComponents
std::string fParFileName
Settings from parameter file.
UInt_t fuCurrentEquipmentId
SysId of the current MS in TS (0 to fuTotalMsNb)
UInt_t fuNrOfGet4
Number of channels in each FEE.
uint64_t fulEpochIndexInTs
double fdCurrentMsTime
Idx of the current MS in TS (0 to fuTotalMsNb)
uint32_t fuProcEpochUntilError
Book-keeping members.
std::vector< Int_t > fviRpcChUId
std::map< UInt_t, UInt_t > fGdpbIdIndexMap
Total number of GDPBs in the system.
UInt_t fuNrOfGet4PerGdpb
Total number of Get4 chips in the system.
UInt_t fuNrOfFeePerGdpb
gDPB ID to index map
UInt_t fuGet4Id
Index of the DPB from which the MS currently unpacked is coming.
std::shared_ptr< CbmTofUnpackMonitor > fMonitor
Potential (online) monitor for the unpacking process.
UInt_t fuNrOfChannelsPerGdpb
Number of GET4s per GDPB.
Bool_t init()
Initialisation at begin of run. Special inits of the derived algos.
UInt_t fuNrOfGbtx
Number of channels per GDPB.
virtual std::vector< std::pair< std::string, std::shared_ptr< FairParGenericSet > > > * GetParContainerRequest(std::string geoTag, std::uint32_t runId)
Get the requested parameter containers. To be defined in the derived classes! Return the required par...
uint64_t fulBadEpochHitNb
bool unpack(const fles::Timeslice *ts, std::uint16_t icomp, UInt_t imslice)
Unpack a given microslice. To be implemented in the derived unpacker algos.
uint16_t getGdpbHit32Tot() const
uint16_t getGet4Idx() const
bool getGdpbEpEpochLoss() const
uint8_t getMessageType() const
Returns the message type. Valid for all message types. 2 bit.
uint16_t getGdpbHitChanId() const
bool getGdpbEpSync() const
bool getGdpbEpDataLoss() const
uint32_t getGdpbEpEpochNb() const
double getMsgFullTimeD(uint64_t epoch) const
Returns expanded and adjusted time of message in double (in ns)
bool getGdpbEpMissmatch() const
const uint64_t kulEpochCycleEp
const uint32_t kuChipIdMergedEpoch