CbmRoot
Loading...
Searching...
No Matches
CbmBmonUnpackAlgo.h
Go to the documentation of this file.
1/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
5#ifndef CbmBmonUnpackAlgo_H
6#define CbmBmonUnpackAlgo_H
7
8#include "CbmBmonDigi.h"
9#include "CbmErrorMessage.h"
10#include "CbmMcbm2018TofPar.h"
11#include "CbmRecoUnpackAlgo.tmpl"
12#include "CbmTofDigi.h"
13#include "CbmTofUnpackAlgo.h"
14#include "CbmTofUnpackMonitor.h"
15#include "Timeslice.hpp" // timeslice
16
17#include <Logger.h>
18
19#include <Rtypes.h> // for types
20#include <RtypesCore.h>
21
22#include <cstddef>
23#include <cstdint>
24#include <memory>
25#include <utility>
26
27class CbmBmonUnpackAlgo : public CbmRecoUnpackAlgo<CbmBmonDigi, CbmErrorMessage> {
28 public:
31
33 virtual ~CbmBmonUnpackAlgo();
34
37
40
46 Bool_t Init()
47 {
48 LOG(info) << fName << "::Init()";
49
50 return fTofAlgo.Init();
51 }
52
63 std::vector<CbmBmonDigi> Unpack(const fles::Timeslice* ts, std::uint16_t icomp)
64 {
65
66 bool unpackOk = true;
67
68 // Clear the default return vector
69 fOutputVec.clear();
70 fTofAlgo.GetOutputVec().clear();
71
73 if (fIsFirstTs) getTimesliceParams(ts);
74
75 // Get the index of the current timeslice
76 fTsIndex = ts->index();
77
78 // Get the number of the current timeslice (the index increases currently via nthTimeslice* fNrCoreMsPerTs)
79 size_t itimeslice = fTsIndex / fNrCoreMsPerTs;
80
81 // Set further parameters required by the explicit algorithm
82 setDerivedTsParameters(itimeslice);
83
84 auto nrMsToLoop = fDoIgnoreOverlappMs ? fNrCoreMsPerTs : fNrMsPerTs;
85 LOG(debug) << fName << "::Unpack: nb MS used is " << nrMsToLoop;
86
88 for (UInt_t imslice = 0; imslice < nrMsToLoop; imslice++) {
89 unpackOk &= fTofAlgo.unpack(ts, icomp, imslice);
90 if (!unpackOk) {
92 continue;
93 }
94 }
95
98
99 auto ndigis = fOutputVec.size();
100 fNrCreatedDigis += ndigis;
101
102 // Get the input(output) data sizes
103 fSumInDataSize += ts->size_component(icomp) / 1.0e6;
104 fSumOutDataSize += ndigis * GetOutputObjSize() / 1.0e6;
105
106 ++fNrProcessedTs;
107 return fOutputVec;
108 }
109
110 // Getters
121 virtual std::vector<std::pair<std::string, std::shared_ptr<FairParGenericSet>>>*
122 GetParContainerRequest(std::string geoTag, std::uint32_t runId)
123 {
124 return fTofAlgo.GetParContainerRequest(geoTag, runId);
125 };
126
133 std::vector<CbmErrorMessage>* GetOptOutAVec() { return fTofAlgo.GetOptOutAVec(); }
134
141 std::vector<std::nullptr_t>* GetOptOutBVec() { return fTofAlgo.GetOptOutBVec(); }
142
148 static size_t GetOutputObjSize() { return sizeof(CbmBmonDigi); }
149
155 int32_t GetSystemTimeOffset() { return fTofAlgo.GetSystemTimeOffset(); }
156
157 // Setters
163 void SetDoIgnoreOverlappMs(bool value = false)
164 {
165 fDoIgnoreOverlappMs = value;
166 fTofAlgo.SetDoIgnoreOverlappMs(value);
167 }
168
170 void SetOptOutAVec(std::vector<CbmErrorMessage>* vec) { fTofAlgo.SetOptOutAVec(vec); }
171
173 void SetOptOutBVec(std::vector<std::nullptr_t>* vec) { fTofAlgo.SetOptOutBVec(vec); }
174
180 void SetParFilesBasePath(std::string value) { fTofAlgo.SetParFilesBasePath(value); }
181
183 void SetSystemTimeOffset(int32_t value) { fTofAlgo.SetSystemTimeOffset(value); }
184
186 void SetTsStartTime(size_t value) { fTofAlgo.SetTsStartTime(value); }
187
194 void SetFlagEpochCountHack2021(bool bFlagin = true) { fTofAlgo.SetFlagEpochCountHack2021(bFlagin); }
195
202 void SetFlagBmonParMode(bool bFlagin = true) { fTofAlgo.SetFlagBmonParMode(bFlagin); }
203
210 void SetParFileName(std::string sNewName) { fTofAlgo.SetParFileName(sNewName); }
211
215 void SetMonitor(std::shared_ptr<CbmTofUnpackMonitor> monitor) { fTofAlgo.SetMonitor(monitor); }
216
217 protected:
219 void finish() { fTofAlgo.finish(); }
220
225
231 Bool_t init() { return fTofAlgo.init(); }
232
240 Bool_t initParSet(FairParGenericSet* parset) { return fTofAlgo.initParSet(parset); }
241
249 Bool_t initParSet(CbmMcbm2018TofPar* parset) { return fTofAlgo.initParSet(parset); }
250
251
261 bool setDerivedTsParameters(size_t /*itimeslice*/) { return true; }
262
266 virtual void FinalizeComponent()
267 {
268 fOutputVec.reserve(fTofAlgo.GetOutputVec().size());
269 for (CbmTofDigi internalDigi : fTofAlgo.GetOutputVec()) {
270 fOutputVec.push_back(CbmBmonDigi(internalDigi));
271 }
272 return;
273 }
274
287 virtual bool unpack(const fles::Timeslice* /*ts*/, std::uint16_t /*icomp*/, UInt_t /*imslice*/) { return true; }
288
289 private:
292
293 ClassDef(CbmBmonUnpackAlgo, 1)
294};
295
296#endif // CbmBmonUnpackAlgo_H
Baseclass for the TrdR unpacker algorithms.
Data class for a signal in the t-zero detector.
Definition CbmBmonDigi.h:30
std::vector< CbmErrorMessage > * GetOptOutAVec()
Get a given output vector connected to the tree, if called after calling InitUnpacker()....
bool setDerivedTsParameters(size_t)
Set the Derived Ts Parameters.
Bool_t init()
Initialisation at begin of run. Forwards to TOF unpacker algo instance.
int32_t GetSystemTimeOffset()
Get the global system time offset Forwards to TOF unpacker algo instance.
void SetTsStartTime(size_t value)
Set the start time of the current TS.
std::vector< CbmBmonDigi > Unpack(const fles::Timeslice *ts, std::uint16_t icomp)
Unpack a given timeslice component. Overload to forward inner calls to TOF unpacker algo instance.
void SetParFileName(std::string sNewName)
Sets the name of the parameter file to be used. Forwards to TOF unpacker algo instance.
CbmBmonUnpackAlgo()
Create the Cbm Trd Unpack AlgoBase object.
void SetDoIgnoreOverlappMs(bool value=false)
Set the Do Ignore Overlapp µslices flag.
Bool_t initParSet(CbmMcbm2018TofPar *parset)
Handles the distribution of the hidden derived classes to their explicit functions....
CbmBmonUnpackAlgo(const CbmBmonUnpackAlgo &)=delete
Copy constructor - not implemented.
CbmBmonUnpackAlgo & operator=(const CbmBmonUnpackAlgo &)=delete
Assignment operator - not implemented.
void finishDerived()
Function that allows special calls during Finish in the derived algos. Forwards to TOF unpacker algo ...
Bool_t Init()
Initialisation at begin of run. Forwards to TOF unpacker algo instance.
virtual bool unpack(const fles::Timeslice *, std::uint16_t, UInt_t)
Unpack a given microslice. To be implemented in the derived unpacker algos. Unused as "Unpack(timesli...
void SetFlagBmonParMode(bool bFlagin=true)
Sets the flag switching to a request of CbmMcbm2018BmonPar. Default is enable. Forwards to TOF unpack...
void SetSystemTimeOffset(int32_t value)
Set the global system time offset.
static size_t GetOutputObjSize()
Get the Output Obj Size.
void finish()
Finish function for this algorithm base clase. Forwards to TOF unpacker algo instance.
void SetOptOutAVec(std::vector< CbmErrorMessage > *vec)
Set the optional output A vector.
CbmTofUnpackAlgo fTofAlgo
Actual unpacker algo.
void SetOptOutBVec(std::vector< std::nullptr_t > *vec)
Set the optional output B vector.
virtual ~CbmBmonUnpackAlgo()
Destroy the Cbm Trd Unpack Task object.
std::vector< std::nullptr_t > * GetOptOutBVec()
Get a given output vector connected to the tree, if called after calling InitUnpacker()....
void SetMonitor(std::shared_ptr< CbmTofUnpackMonitor > monitor)
Set a predefined monitor.
Bool_t initParSet(FairParGenericSet *parset)
Handles the distribution of the hidden derived classes to their explicit functions....
virtual void FinalizeComponent()
Copy the buffer from the internal (TOF) algo to the new Digi Type storage.
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...
void SetParFilesBasePath(std::string value)
Set the base path to the parameter containers.
void SetFlagEpochCountHack2021(bool bFlagin=true)
Sets the flag enabling the epoch offset hack for the July 2021 data. Default is enable....
Data class for expanded digital TOF information.
Definition CbmTofDigi.h:47
void SetMonitor(std::shared_ptr< CbmTofUnpackMonitor > monitor)
Set a predefined monitor.
void SetFlagEpochCountHack2021(bool bFlagin=true)
Sets the flag enabling the epoch offset hack for the July 2021 data. Default is enable.
Bool_t initParSet(FairParGenericSet *parset)
Handles the distribution of the hidden derived classes to their explicit functions.
std::vector< CbmTofDigi > & GetOutputVec()
Get a reference to the output vector. Used by BMON encapsulating algo to access output.
void SetParFileName(std::string sNewName)
Sets the name of the parameter file to be used.
void finishDerived()
Function that allows special calls during Finish in the derived algos.
void SetFlagBmonParMode(bool bFlagin=true)
Sets the flag switching to a request of CbmMcbm2018BmonPar. Default is enable.
void finish()
Raise permissions for access to these protected methods to allow access in encapsulating BMON algo.
Bool_t init()
Initialisation at begin of run. Special inits of the derived algos.
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...
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.