9#include "FairRootManager.h"
11#include "FairRunOnline.h"
12#include "FairRuntimeDb.h"
16#include <THttpServer.h>
21 , fbMonitorMode(kFALSE)
22 , fbDebugMonitorMode(kFALSE)
23 , fbWriteOutput(kTRUE)
24 , fbDebugWriteOutput(kFALSE)
25 , fbBaselineAvg(kFALSE)
26 , fSystemIdentifier((
std::uint8_t)
fles::Subsystem::TRD)
27 , fdMsSizeInNs(1.28e6)
28 , fMonitorHistoFileName(
"")
30 , fTrdDigiVector(nullptr)
31 , fTrdRawMessageVector(nullptr)
32 , fSpadicInfoMsgVector(nullptr)
33 , fUnpackerAlgo(nullptr)
43 LOG(info) <<
"Initializing CbmMcbm2018UnpackerTaskTrdR...";
46 FairRootManager* ioman =
nullptr;
47 ioman = FairRootManager::Instance();
48 if (ioman ==
nullptr) { LOG(fatal) <<
"No FairRootManager instance"; }
57 LOG(fatal) <<
"fTrdDigiVector could not be registered at FairRootManager.";
70 LOG(fatal) <<
"[CbmMcbm2018UnpackerTaskTrdR::Init] Raw output could not "
71 "be registered at FairRootManager.";
80 LOG(info) <<
"Initialization of CbmMcbm2018UnpackerTaskTrdR and "
81 "CbmMcbm2018UnpackerAlgoTrdR successfull!";
84 LOG(fatal) <<
"Init of CbmMcbm2018UnpackerAlgoTrdR failed!";
94 LOG(error) <<
"CbmMcbm2018UnpackerTaskTrdR: Failed processing TS " << ts.index() <<
" in unpacker algorithm class.";
115 LOG(info) <<
"Finish of CbmMcbm2018UnpackerTaskTrdR";
123 TFile* oldFile = gFile;
124 TDirectory* oldDir = gDirectory;
127 TFile* histoFile =
nullptr;
131 histoFile =
new TFile(histoFileName.Data(),
"RECREATE");
134 for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
136 TString sFolder = vHistos[uHisto].second.data();
137 if (
nullptr == gDirectory->Get(sFolder)) gDirectory->mkdir(sFolder);
138 gDirectory->cd(sFolder);
140 vHistos[uHisto].first->Write();
154 LOG(info) <<
"Setting parameter containers for " << GetName();
159 for (
auto parSetIt : *fParContList) {
161 fParContList->Remove(tempObj);
162 std::string sParamName {tempObj->GetName()};
165 updatedParSet =
dynamic_cast<CbmTrdParSet*
>(FairRun::Instance()->GetRuntimeDb()->getContainer(sParamName.data()));
167 if (!updatedParSet) {
168 LOG(error) <<
"Failed to obtain parameter container " << sParamName <<
", for parameter index " << iParCont;
171 fParContList->AddAt(updatedParSet, iParCont);
176 FairRun::Instance()->GetRuntimeDb()->getContainer(
"CbmMcbm2020TrdTshiftPar"));
182 LOG(error) <<
"CbmMcbm2018UnpackerTaskTrdR::InitContainers failed! No "
186 LOG(info) <<
"Init containers for CbmMcbm2018UnpackerTaskTrdR";
203 LOG(info) <<
"CbmMcbm2018UnpackerTaskTrdR::SetParContainers() - Parsing "
204 "timeshift correction map to unpacker algo";
217 THttpServer* server = FairRunOnline::Instance()->GetHttpServer();
218 if (
nullptr != server) {
219 for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
220 server->Register(Form(
"/%s", vHistos[uHisto].second.data()), vHistos[uHisto].first);
230 LOG(warning) <<
"The histograms from CbmMcbm2018UnpackerTaskTrdR will "
231 "not be available online as no server present";
242 LOG(info) <<
"ReInit parameter containers for CbmMcbm2018UnpackerTaskTrdR";
251 LOG(error) <<
"CbmMcbm2018UnpackerTaskTrdR::AddMsComponentToList : Wrong "
ClassImp(CbmConverterManager)
Timeslice unpacker algorithm for Spadic v.2.2 .
void SetActiveHistograms(std::vector< bool > isActiveHistoVec)
Bool_t ProcessTs(const fles::Timeslice &ts)
void SetDebugSortOutput(Bool_t bFlagIn=kTRUE)
void SetTimeOffsetNs(Double_t dOffsetIn=0.0)
Bool_t CreateHistograms()
Goes through fIsActiveHistoVec and creates the activated histograms.
void SetFirstChannelsElinkEven(bool isEven)
void AddMsComponentToList(size_t component, UShort_t usDetectorId)
void SetMonitorMode(Bool_t bFlagIn=kTRUE)
void SetMsSizeInNs(Double_t msSizeInNs)
void SetTimeshiftsMap(std::map< size_t, std::vector< Int_t > > *setvalue)
In the mCbm 2020 beamtime timeshifts changing during the run of the correlation time to the Bmon have...
Bool_t SetDigiOutputPointer(std::vector< CbmTrdDigi > *const pVector)
Set fTrdDigiVector to the address of pVector.
Bool_t ReInitContainers()
void SetBaselineAvg(Bool_t bFlagIn=kTRUE)
Call this when Spadic Average-Baseline feature is enabled.
void SetWriteOutput(Bool_t bFlagIn=kTRUE)
void SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb)
Bool_t SetRawOutputPointer(std::vector< CbmTrdRawMessageSpadic > *const pVector, std::vector< std::pair< size_t, size_t > > *const qVector=nullptr)
Set fTrdRawMessageVector to the address of pVector.
void SetDebugMonitorMode(Bool_t bFlagIn=kTRUE)
void SetDebugWriteOutput(Bool_t bFlagIn=kTRUE)
Timeslice unpacker FairTask for Spadic v.2.2 .
Bool_t fbDebugSortOutput
If ON the output vector of raw messages is sorted in time.
void SetMonitorMode(Bool_t bFlagIn=kTRUE)
void SetTimeOffsetNs(Double_t dOffsetIn=0.0)
Bool_t fbWriteOutput
If ON the output Vector of digis is written to disk.
virtual Bool_t ReInitContainers()
std::vector< std::pair< size_t, size_t > > * fSpadicInfoMsgVector
vector< pair< fulltime, word > >
Bool_t fbDebugMonitorMode
Switch ON the filling of a additional set of histograms.
virtual ~CbmMcbm2018UnpackerTaskTrdR()
virtual Bool_t DoUnpack(const fles::Timeslice &ts, size_t component)
virtual Bool_t Init()
Registers output-data containers at the FairRootManager.
Double_t fdMsSizeInNs
microslice size in ns to be passed to the unpacker // TODO handle this with asic parameter files
Bool_t fbBaselineAvg
Set to true if Baseline Averaging is activated in Spadic.
virtual void SetNbMsInTs(size_t uCoreMsNb, size_t uOverlapMsNb)
Sets numbers of Core Microslices and overlap Microslices per Timeslice.
std::uint8_t fSystemIdentifier
by default set to: fles::Subsystem::TRD, changable via setter
Bool_t fbDebugWriteOutput
If ON the output vector of raw messages is filled and written to disk.
virtual Bool_t InitContainers()
CbmMcbm2020TrdTshiftPar * fTimeshiftPar
mCbm2020 timeshift correction parameters
virtual void SetParContainers()
std::vector< CbmTrdRawMessageSpadic > * fTrdRawMessageVector
Output Spadic raw messages for debugging.
std::vector< CbmTrdDigi > * fTrdDigiVector
Output Digi vector.
TString fMonitorHistoFileName
Bool_t fbMonitorMode
< Set wether channels 00..15 are on the even (true) or the odd (false and default) elink
virtual void AddMsComponentToList(size_t component, UShort_t usDetectorId)
Adds an input component to the list of active components for this unpacker.
void SetIgnoreOverlapMs(Bool_t bFlagIn=kTRUE)
CbmMcbm2018UnpackerAlgoTrdR * fUnpackerAlgo
Processing algo.
void SetHistoFileName(TString filename)
bool fIsFirstChannelsElinkEven
define if the first 16 channels (00..15) are found on the even (set true) or odd (false) eLinkId,...
std::vector< bool > fIsActiveHistoVec
CbmMcbm2018UnpackerTaskTrdR()
std::map< size_t, std::vector< Int_t > > * GetTimeshiftsMap()
Return the timeshift map.
std::vector< std::pair< TNamed *, std::string > > GetHistoVector()
void SetIgnoreOverlapMs(Bool_t bFlagIn=kTRUE)
Control flags.