1515#define ALICEO2_HBFSAMPLER_H
1616
1717#include < Rtypes.h>
18+ #include " CommonUtils/ConfigurableParam.h"
19+ #include " CommonUtils/ConfigurableParamHelper.h"
1820#include " CommonDataFormat/InteractionRecord.h"
1921#include " Headers/RAWDataHeader.h"
2022#include " CommonConstants/Triggers.h"
@@ -39,46 +41,41 @@ namespace raw
3941using LinkSubSpec_t = uint32_t ;
4042
4143// _____________________________________________________________________
42- class HBFUtils
43- {
44+ struct HBFUtils : public o2 ::conf::ConfigurableParamHelper<HBFUtils> {
4445 using IR = o2::InteractionRecord;
4546
46- public:
4747 static constexpr int GBTWord = 16 ; // length of GBT word
4848 static constexpr int MAXCRUPage = 512 * GBTWord;
4949
50- HBFUtils () = default ;
51- HBFUtils (const IR& ir0) : mFirstIR (ir0) {}
52- const IR& getFirstIR () const { return mFirstIR ; }
53- IR& getFirstIR () { return mFirstIR ; }
50+ IR getFirstIR () const { return {bcFirst, orbitFirst}; }
5451
55- void setNOrbitsPerTF (int n) { mNHBFPerTF = n > 0 ? n : 1 ; }
56- int getNOrbitsPerTF () const { return mNHBFPerTF ; }
52+ void setNOrbitsPerTF (int n) { nHBFPerTF = n > 0 ? n : 1 ; }
53+ int getNOrbitsPerTF () const { return nHBFPerTF ; }
5754
5855 // /< get IR corresponding to start of the HBF
59- IR getIRHBF (uint32_t hbf) const { return mFirstIR + int64_t (hbf) * o2::constants::lhc::LHCMaxBunches; }
56+ IR getIRHBF (uint32_t hbf) const { return getFirstIR () + int64_t (hbf) * o2::constants::lhc::LHCMaxBunches; }
6057
6158 // /< get IR corresponding to start of the TF
62- IR getIRTF (uint32_t tf) const { return getIRHBF (tf * mNHBFPerTF ); }
59+ IR getIRTF (uint32_t tf) const { return getIRHBF (tf * nHBFPerTF ); }
6360
6461 // /< get HBF ID corresponding to this IR
65- int getHBF (const IR& rec) const ;
62+ int64_t getHBF (const IR& rec) const ;
6663
6764 // /< get TF ID corresponding to this IR
68- int getTF (const IR& rec) const { return getHBF (rec) / mNHBFPerTF ; }
65+ int64_t getTF (const IR& rec) const { return getHBF (rec) / nHBFPerTF ; }
6966
7067 // /< get TF and HB (within TF) for this IR
7168 std::pair<int , int > getTFandHBinTF (const IR& rec) const
7269 {
7370 auto hbf = getHBF (rec);
74- return std::pair<int , int >(hbf / mNHBFPerTF , hbf % mNHBFPerTF );
71+ return std::pair<int , int >(hbf / nHBFPerTF , hbf % nHBFPerTF );
7572 }
7673
7774 // /< get TF and HB (abs) for this IR
7875 std::pair<int , int > getTFandHB (const IR& rec) const
7976 {
8077 auto hbf = getHBF (rec);
81- return std::pair<int , int >(hbf / mNHBFPerTF , hbf);
78+ return std::pair<int , int >(hbf / nHBFPerTF , hbf);
8279 }
8380
8481 // /< create RDH for given IR
@@ -126,7 +123,7 @@ class HBFUtils
126123 //-------------------------------------------------------------------------------------*/
127124 int fillHBIRvector (std::vector<IR>& dst, const IR& fromIR, const IR& toIR) const ;
128125
129- void print () const ;
126+ void print () const { printKeyValues ( true ); }
130127
131128 // some fields of the same meaning have different names in the RDH of different versions
132129 static uint32_t getHBOrbit (const void * rdhP);
@@ -159,22 +156,22 @@ class HBFUtils
159156 static LinkSubSpec_t getSubSpec (const o2::header::RAWDataHeaderV4& rdh) { return getSubSpec (rdh.cruID , rdh.linkID , rdh.endPointID ); }
160157 static LinkSubSpec_t getSubSpec (const o2::header::RAWDataHeaderV5& rdh) { return getSubSpec (rdh.cruID , rdh.linkID , rdh.endPointID ); }
161158
162- protected:
163- int mNHBFPerTF = 1 + 0xff ; // number of orbits per BC
164- IR mFirstIR = { 0 , 0 } ; // 1st record of the 1st TF
159+ int nHBFPerTF = 1 + 0xff ; // number of orbits per BC
160+ uint16_t bcFirst = 0 ; // /< BC of 1st TF
161+ uint32_t orbitFirst = 0 ; // /< orbit of 1st TF
165162
166- ClassDefNV (HBFUtils, 1 );
163+ O2ParamDef (HBFUtils, " HBFUtils " );
167164};
168165
169166// _________________________________________________
170167template <>
171168inline void HBFUtils::updateRDH<o2::header::RAWDataHeaderV5>(o2::header::RAWDataHeaderV5& rdh, const o2::InteractionRecord& rec) const
172169{
173170 auto tfhb = getTFandHBinTF (rec);
174- rdh.bunchCrossing = mFirstIR . bc ;
171+ rdh.bunchCrossing = bcFirst ;
175172 rdh.orbit = rec.orbit ;
176173 //
177- if (rec.bc == mFirstIR . bc ) { // if we are starting new HB, set the HB trigger flag
174+ if (rec.bc == bcFirst ) { // if we are starting new HB, set the HB trigger flag
178175 rdh.triggerType |= o2::trigger::ORBIT | o2::trigger::HB;
179176 if (tfhb.second == 0 ) { // if we are starting new TF, set the TF trigger flag
180177 rdh.triggerType |= o2::trigger::TF;
@@ -190,10 +187,10 @@ inline void HBFUtils::updateRDH<o2::header::RAWDataHeaderV4>(o2::header::RAWData
190187 rdh.triggerBC = rec.bc ;
191188 rdh.triggerOrbit = rec.orbit ;
192189
193- rdh.heartbeatBC = mFirstIR . bc ;
190+ rdh.heartbeatBC = bcFirst ;
194191 rdh.heartbeatOrbit = rec.orbit ;
195192 //
196- if (rec.bc == mFirstIR . bc ) { // if we are starting new HB, set the HB trigger flag
193+ if (rec.bc == bcFirst ) { // if we are starting new HB, set the HB trigger flag
197194 rdh.triggerType |= o2::trigger::ORBIT | o2::trigger::HB;
198195 if (tfhb.second == 0 ) { // if we are starting new TF, set the TF trigger flag
199196 rdh.triggerType |= o2::trigger::TF;
0 commit comments