Skip to content
Snippets Groups Projects
Commit 1e0d03a5 authored by Axel Puntke's avatar Axel Puntke Committed by Pierre-Alain Loizeau
Browse files

Add Timeshift per E-Link Functionality for TRD1D Unpacker

parent 682ff512
No related branches found
No related tags found
1 merge request!1751Add Timeshift per E-Link Functionality for TRD1D Unpacker
Pipeline #28767 passed
......@@ -74,6 +74,23 @@ public:
*/
void SetSpadicObject(std::shared_ptr<CbmTrdSpadic> value) { fSpadic = value; }
/**
* @brief Register a time offeset to be substracted from the digis which come from a specific CRI
*
* @param map
*/
void SetElinkTimeOffsetMap(std::map<std::uint32_t, std::vector<std::int32_t>> map) { fElinkTimeOffsetMap = map; }
/**
* @brief Get the time offeset to be substracted from the digis which come from a specific CRI
*
* @param criid
*/
std::int32_t GetElinkTimeOffset(std::uint32_t criid, std::uint8_t elinkid)
{
return (fElinkTimeOffsetMap.find(criid) == fElinkTimeOffsetMap.end() ? 0 : fElinkTimeOffsetMap[criid].at(elinkid));
}
protected:
/**
* @brief Handle the output created by the explicit algorithms. E.g. write to output vectors.
......@@ -207,7 +224,10 @@ protected:
/** @brief length of one ts_msb in [cc] */
size_t fTsMsbLengthCC = fTsMsbLength / CbmTrdSpadic::GetClockCycle();
private:
/** @brief Map to store time offsets for each CRI&Elink combination */
std::map<std::uint32_t, std::vector<std::int32_t>> fElinkTimeOffsetMap;
private:
ClassDef(CbmTrdUnpackAlgoBaseR, 2)
};
......
......@@ -306,6 +306,7 @@ void CbmTrdUnpackAlgoR::makeDigi(CbmTrdRawMessageSpadic raw)
ULong64_t time = raw.GetTime();
time -= fSystemTimeOffset;
time -= GetElinkTimeOffset(raw.GetCriId(), raw.GetElinkId());
auto digi = fRTDMethod->MakeDigi(raw.GetSamples(), padChNr, uniqueModuleId, time, triggerType, errClass);
......@@ -338,6 +339,7 @@ void CbmTrdUnpackAlgoR::makeDigi(Spadic::FexWord<0x10> fw, std::uint32_t criid)
auto energy = fSpadic->MaxAdcToEnergyCal(fw.maxAdc);
time -= fSystemTimeOffset;
time -= GetElinkTimeOffset(criid, fw.elink);
auto digi = std::unique_ptr<CbmTrdDigi>(new CbmTrdDigi(padChNr, uniqueModuleId, energy, time, triggerType, 0));
......
......@@ -46,6 +46,10 @@ void CbmTrdUnpackConfig::SetAlgo()
if (fDoLog) LOG(info) << fName << "::SetAlgo - SetSystemTimeOffset";
algo->SetSystemTimeOffset(fSystemTimeOffset);
// Set the global system time offset
if (fDoLog) LOG(info) << fName << "::SetAlgo - SetElinkTimeOffsetMap";
algo->SetElinkTimeOffsetMap(fElinkTimeOffsetMap);
// If we have a monitor in the config add it to the algo
if (fMonitor) algo->SetMonitor(fMonitor);
......@@ -87,5 +91,16 @@ std::shared_ptr<CbmTrdUnpackAlgoBaseR> CbmTrdUnpackConfig::chooseAlgo()
return nullptr;
}
void CbmTrdUnpackConfig::SetElinkTimeOffset(std::uint32_t criid, std::uint8_t elinkid, std::int32_t offsetNs)
{
// create vector for criid if not yet existing
if (fElinkTimeOffsetMap.find(criid) == fElinkTimeOffsetMap.end()) {
//vector has fixed size of 256 (max elinkid) and is initialized to 0
fElinkTimeOffsetMap.insert(std::make_pair(criid, std::vector<int32_t>(256, 0)));
}
fElinkTimeOffsetMap[criid][elinkid] = offsetNs;
}
ClassImp(CbmTrdUnpackConfig)
......@@ -91,7 +91,16 @@ public:
*/
void SetSpadicObject(std::shared_ptr<CbmTrdSpadic> value) { fSpadic = value; }
protected:
/**
* @brief Register a time offeset to be substracted from the digis which come from a specific CRI
*
* @param criid
* @param elinkid
* @param offsetNs
*/
void SetElinkTimeOffset(std::uint32_t criid, std::uint8_t elinkid, std::int32_t offsetNs);
protected:
/**
* @brief Choose the derived unpacker algorithm to be used for the DAQ output to Digi translation. If algo was already set manually by the user this algorithm is used.
*
......@@ -108,7 +117,10 @@ protected:
/** @brief pointer to the monitor object */
std::shared_ptr<CbmTrdUnpackMonitor> fMonitor = nullptr;
private:
/** @brief Map to store time offsets for each CRI&Elink combination */
std::map<std::uint32_t, std::vector<std::int32_t>> fElinkTimeOffsetMap;
private:
ClassDef(CbmTrdUnpackConfig, 3)
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment