15#include <RtypesCore.h>
31std::vector<std::pair<std::string, std::shared_ptr<FairParGenericSet>>>*
35 std::string basepath = Form(
"%s/trd_%s", fParFilesBasePath.data(), geoTag.data());
36 std::string temppath =
"";
39 std::string runpath =
"";
41 runpath =
".run" + std::to_string(runId);
45 temppath = basepath + runpath +
".asic" +
".par";
46 fParContVec.emplace_back(std::make_pair(temppath, std::make_shared<CbmTrdParSetAsic>()));
50 temppath = basepath + runpath +
".digi" +
".par";
51 auto pair = std::make_pair(temppath, std::make_shared<CbmTrdParSetDigi>());
52 fParContVec.emplace_back(pair);
58 if (runId == 831 && geoTag ==
"mcbm_beam_2020_03") {
59 temppath = Form(
"%s/mcbm2020_special/CbmMcbm2020TrdTshiftPar_run%d.par", fParFilesBasePath.data(), runId);
60 fParContVec.emplace_back(std::make_pair(temppath, std::make_shared<CbmMcbm2020TrdTshiftPar>()));
69 std::uint32_t isample,
bool multihit)
75 LOG(error) << fName <<
"::ExtractSample] SOM MSG - Idx " << isample <<
" Wrong sample index!";
81 if (isample < 3 || isample > 31) {
82 LOG(error) << fName <<
"::ExtractSample] RDA MSG - Idx " << isample <<
" Wrong sample index!";
88 LOG(error) << fName <<
"::ExtractSample] Wrong Message Type!";
96 mask = mask << (9 * (6 - index));
97 size_t temp = word & mask;
98 temp = temp >> (6 - index) * 9;
99 if (
fSpadic->GetUseBaselineAvg() && (isample == 0) && !(multihit)) {
108 temp ^= (-0 ^ temp) & (1 << 7);
109 temp ^= (-1 ^ temp) & (1 << 8);
114 int16_t result = s.x = temp;
121 size_t mask = 0x3FFFFFFF;
123 return ((word & mask) >> 32);
136 size_t mask = 0x000FFFFF;
138 if (((msg & mask) >> 18) == 3)
142 if (((msg & mask) >> 17) == 2)
146 if (((msg & mask) >> 17) == 3)
150 if (((msg & mask) >> 17) == 4)
154 if (((msg & mask) >> 17) == 5)
159 LOG(error) << fName <<
"::GetInfoType] unknown type!";
168 if ((msg >> 61) == 1)
172 else if ((msg >> 63) == 1)
176 else if ((msg >> 62) == 1)
180 else if ((msg >> 60) == 1)
197 auto nwords = (nsamples + 3) / 7;
198 return nwords > 5 ? 5 : nwords;
206 uint8_t elinkId = 0, chId = 0, crobId = 0;
207 uint16_t criId = msDesc.eq_id;
209 uint8_t hitType = 0, nSamples = 0;
210 bool multihit =
false;
211 uint16_t timestamp = 0;
214 elinkId = (char) ((word & mask) >> 55);
218 chId = (char) ((word & mask) >> 51);
222 timestamp = (uint16_t)((word & mask) >> 35);
226 hitType = (uint8_t)((word & mask) >> 33);
230 multihit = (bool) ((word & mask) >> 32);
234 nSamples = (uint8_t)((word & mask) >> 27);
242 std::vector<std::int16_t> samples = {};
243 for (std::uint32_t isample = 0; isample < nSamples && isample < 3; isample++) {
245 samples.emplace_back(adcvalue);
249 CbmTrdRawMessageSpadic retval(chId, elinkId, crobId, criId, hitType, nSamples, multihit, fulltime, samples);
264 size_t spadicHwAddress(0);
267 Int_t asicAddress(0);
271 <<
"::makeDigi - No asic address "
272 "found for Spadic hardware address %lu"
276 asicAddress = mapIt->second;
279 Int_t uniqueModuleId = asicAddress / 1000;
287 auto padChNr = (
fAsicChannelMap.find(asicAddress))->second.at(asicChannelId);
293 ULong64_t time = raw.
GetTime();
298 time -= fSystemTimeOffset;
301 time -= fTsStartTime;
303 auto digi =
fRTDMethod->MakeDigi(raw.
GetSamples(), padChNr, uniqueModuleId, time, triggerType, errClass);
326 bool unpackOk =
true;
328 auto msdesc = ts->descriptor(icomp, imslice);
331 auto mssize = msdesc.size;
336 const auto mspointer = ts->content(icomp, imslice);
337 const auto mscontent =
reinterpret_cast<const size_t*
>(mspointer);
340 for (std::uint32_t iword = 0; iword < msNrWords; iword++) {
342 auto word =
static_cast<size_t>(mscontent[iword]);
353 std::uint32_t isample = 3;
357 word =
static_cast<size_t>(mscontent[iword]);
361 <<
"::unpack() Incomplete Spadic "
362 "Message! RDA Word missing, Microslice corrupted.";
366 for (std::uint32_t iwordsample = 0; isample < nsamples && iwordsample < 7; isample++, iwordsample++) {
382 <<
"::unpack() Unexpected RDA "
383 "Word. Microslice corrupted.";
391 fOptOutBVec->emplace_back(std::make_pair(fLastFulltime, word));
393 fNrCreatedInfoMsgs++;
403 if (iword != (msNrWords - 1))
406 <<
"::unpack() Null Word but "
407 "not at end of Microslice.";
413 <<
"::unpack() Unknown Word. "
414 "Microslice corrupted.";
ClassImp(CbmConverterManager)
Assign pad layout to TRD Modules.
Unpacker algorithms for the TrdR 2020 data.
Base class for storing raw information which comes from the Spadic v2.2 trough flib or from a tsa fil...
std::uint64_t GetFullTime() const
void SetTime(double setvalue)
const std::vector< std::int16_t > * GetSamples() const
std::uint8_t GetChannelId() const
void SetSample(std::int16_t value, std::uint8_t pos)
std::uint8_t GetNrSamples() const
std::uint8_t GetCrobId() const
std::uint8_t GetHitType() const
std::uint8_t GetElinkId() const
std::uint16_t GetCriId() const
static CbmTrdDigi::eTriggerType GetDigiTriggerType(Spadic::eTriggerType tt)
Get the Digi Trigger Type from the raw message triggertype.
static UInt_t GetNrChannels()
std::shared_ptr< CbmTrdRawToDigiBaseR > fRTDMethod
raw to digi extraction method, set in the task
std::map< Int_t, std::vector< Int_t > > fAsicChannelMap
Map to retrieve module channelId from asicAddress and asicChannel.
void digestOutput(std::unique_ptr< CbmTrdDigi > digi, CbmTrdRawMessageSpadic raw)
Handle the output created by the explicit algorithms. E.g. write to output vectors.
std::shared_ptr< CbmTrdUnpackMonitor > fMonitor
Potential (online) monitor for the unpacking process.
std::shared_ptr< CbmTrdSpadic > fSpadic
Spadic software reprensentation object.
size_t fNrWildRda
Number of rda frames outside of a SOM frame range.
size_t fNrUnknownWords
Number of unknown words.
Bool_t fIsFirstChannelsElinkEven
Define if the first 16 channels (00..15) are found on the even (set true) or odd (false) eLinkId....
std::map< size_t, Int_t > fSpadicAddressMap
Map to retrieve asic address from CriId/CrobId/ElinkId (see CbmTrdHardwareSetupR)
std::map< size_t, std::vector< Int_t > > fTimeshiftsMap
Map containing the timeshift parameters for the correction of the µSlice timeshifts....
std::uint8_t getNrOfRdaWords(std::uint8_t nsamples)
Get the Nr Of Rda Words required for the amount of ADC samples.
size_t fMsLengthCC
Microslice length [CC]. To be overwritten in the version specific unpackers.
Spadic::MsInfoType getInfoType(const size_t msg)
Identify the InfoType of a 64bit InfoMessage word inside a Microslice.
virtual bool unpack(const fles::Timeslice *ts, std::uint16_t icomp, UInt_t imslice)
Unpack a given microslice.
void makeDigi(CbmTrdRawMessageSpadic raw)
Create an actual digi from the raw message.
CbmTrdUnpackAlgoLegacy2020R()
Create the Cbm Trd Unpack AlgoBase object.
std::vector< std::int32_t > * fTimeshiftsParVec
Vector containing the timeshift parameters for the correction of the µSlice timeshifts for a given ts...
Spadic::MsMessageType getMessageType(const size_t msg)
Identify the message type of a 64bit word inside a Microslice.
size_t extractEpoch(const size_t word)
Extract the epoch time reference information from the epoch word.
static const std::uint8_t fBytesPerWord
Bytes per word stored in the microslices.
size_t fEpoch
Time of the current epoch marker.
std::int16_t extractSample(const size_t word, const Spadic::MsMessageType msgType, std::uint32_t isample, bool multihit=false)
Extract the given sample from the given rda word.
const std::vector< std::uint8_t > fExtractSampleIndicesVec
virtual CbmTrdRawMessageSpadic makeRaw(const size_t word, fles::MicrosliceDescriptor msDesc)
Create a CbmTrdRawMessageSpadic from the hit message input.
virtual std::vector< std::pair< std::string, std::shared_ptr< FairParGenericSet > > > * GetParContainerRequest(std::string geoTag, std::uint32_t runId)
Get the requested parameter containers. Return the required parameter containers together with the pa...
virtual bool setDerivedTsParameters(size_t itimeslice)
Set the Derived Ts Parameters.
virtual ~CbmTrdUnpackAlgoLegacy2020R()
Destroy the Cbm Trd Unpack Task object.
void finishDerived()
Additional explicit finish function of this algo implementation.
@ kUNU
Unused request. 100. .... .... .... cccc.
@ kBOM
Buffer overflow count. 11nn nnnn nnnn nnnn cccc.
@ kMIS
Missing request. 101. .... .... .... ....
@ kBUF
Buffer full. 011b b... .... .... cccc.
@ kMSB
Message build error. 010. .... .... .... cccc.
@ kEPO
Epoch Marker or TS_MSB depending on the hitmessage version.