Skip to content

Commit ee9e90b

Browse files
shahor02davidrohr
authored andcommitted
Suppress HBFUtils.bcFirst (1st BC always 0), add orbitFirstSampled for MC, set default nHBFPerTF=128
1 parent 98d3d38 commit ee9e90b

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

Detectors/MUON/MCH/Raw/test/testClosureCoDec.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ std::vector<std::byte> createBuffer(gsl::span<std::string> data,
112112

113113
const o2::raw::HBFUtils& hbfutils = o2::raw::HBFUtils::Instance();
114114
o2::conf::ConfigurableParam::setValue<uint32_t>("HBFUtils", "orbitFirst", orbit);
115-
o2::conf::ConfigurableParam::setValue<uint16_t>("HBFUtils", "bcFirst", bc);
116115
std::vector<std::byte> out = o2::mch::raw::paginate(buffer,
117116
isUserLogicFormat<FORMAT>::value,
118117
isChargeSumMode<CHARGESUM>::value,

Detectors/MUON/MID/Raw/src/Encoder.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void Encoder::finalize(bool closeFile)
102102
{
103103
/// Writes remaining data and closes the file
104104
if (mLastIR.isDummy()) {
105-
mLastIR.bc = mRawWriter.getHBFUtils().bcFirst;
105+
mLastIR.bc = 0;
106106
mLastIR.orbit = mRawWriter.getHBFUtils().orbitFirst;
107107
}
108108
auto ir = getOrbitIR(mLastIR.orbit);

Detectors/Raw/include/DetectorsRaw/HBFUtils.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace raw
2727
{
2828
/*
2929
In the MC->Raw conversion we have to make sure that
30-
1) The HB and TF starts are in sync for all detectors regardless on time (bc/orbir)
30+
1) The HB and TF starts are in sync for all detectors regardless on time (0/orbit)
3131
distribution of its signal.
3232
2) All HBF and TF (RAWDataHeaders with corresponding HB and TF trigger flags) are present
3333
in the emulated raw data, even if some of them had no data in particular detector.
@@ -42,8 +42,7 @@ namespace raw
4242
struct HBFUtils : public o2::conf::ConfigurableParamHelper<HBFUtils> {
4343
using IR = o2::InteractionRecord;
4444

45-
46-
IR getFirstIR() const { return {bcFirst, orbitFirst}; }
45+
IR getFirstIR() const { return {0, orbitFirst}; }
4746

4847
int getNOrbitsPerTF() const { return nHBFPerTF; }
4948

@@ -69,6 +68,9 @@ struct HBFUtils : public o2::conf::ConfigurableParamHelper<HBFUtils> {
6968
///< get 1st IR of the TF corresponding to provided interaction record
7069
IR getFirstIRofTF(const IR& rec) const { return getIRTF(getTF(rec)); }
7170

71+
///< get 1st IR of TF corresponding to the 1st sampled orbit (in MC)
72+
IR getFirstSampledTFIR() const { return getFirstIRofTF({0, orbitFirstSampled}); }
73+
7274
///< get TF and HB (abs) for this IR
7375
std::pair<int, int> getTFandHB(const IR& rec) const
7476
{
@@ -123,10 +125,12 @@ struct HBFUtils : public o2::conf::ConfigurableParamHelper<HBFUtils> {
123125

124126
void print() const { printKeyValues(true); }
125127

126-
int nHBFPerTF = 1 + 0xff; // number of orbits per BC
127-
uint16_t bcFirst = 0; ///< BC of 1st TF
128-
uint32_t orbitFirst = 0; ///< orbit of 1st TF
129-
uint32_t maxNOrbits = 0xffffffff; // max number of orbits to accept, used in digit->raw conversion
128+
int nHBFPerTF = 128; ///< number of orbits per BC
129+
uint32_t orbitFirst = 0; ///< orbit of 1st TF of the run
130+
131+
// used for MC
132+
uint32_t orbitFirstSampled = 0; ///< 1st orbit sampled in the MC
133+
uint32_t maxNOrbits = 0xffffffff; ///< max number of orbits to accept, used in digit->raw conversion
130134

131135
O2ParamDef(HBFUtils, "HBFUtils");
132136
};
@@ -140,10 +144,10 @@ void HBFUtils::updateRDH(H& rdh, const IR& rec, bool setHBTF) const
140144

141145
if (setHBTF) { // need to set the HBF IR and HB / TF trigger flags
142146
auto tfhb = getTFandHBinTF(rec);
143-
RDHUtils::setHeartBeatBC(rdh, bcFirst);
147+
RDHUtils::setHeartBeatBC(rdh, 0);
144148
RDHUtils::setHeartBeatOrbit(rdh, rec.orbit);
145149

146-
if (rec.bc == bcFirst) { // if we are starting new HB, set the HB trigger flag
150+
if (rec.bc == 0) { // if we are starting new HB, set the HB trigger flag
147151
auto trg = RDHUtils::getTriggerType(rdh) | (o2::trigger::ORBIT | o2::trigger::HB);
148152
if (tfhb.second == 0) { // if we are starting new TF, set the TF trigger flag
149153
trg |= o2::trigger::TF;

Detectors/Raw/include/DetectorsRaw/RawFileReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class RawFileReader
267267
o2::header::DataDescription getDefaultDataSpecification() const { return mDefDataDescription; }
268268
ReadoutCardType getDefaultReadoutCardType() const { return mDefCardType; }
269269

270-
void imposeFirstTF(uint32_t orbit, uint16_t bc);
270+
void imposeFirstTF(uint32_t orbit);
271271
void setTFAutodetect(FirstTFDetection v) { mFirstTFAutodetect = v; }
272272
void setPreferCalculatedTFStart(bool v) { mPreferCalculatedTFStart = v; }
273273
FirstTFDetection getTFAutodetect() const { return mFirstTFAutodetect; }

Detectors/Raw/src/HBFUtils.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ uint32_t HBFUtils::getHBF(const IR& rec) const
2626
auto diff = rec.differenceInBC(getFirstIR());
2727
if (diff < 0) {
2828
LOG(ERROR) << "IR " << rec.bc << '/' << rec.orbit << " is ahead of the reference IR "
29-
<< bcFirst << '/' << orbitFirst;
29+
<< "0/" << orbitFirst;
3030
throw std::runtime_error("Requested IR is ahead of the reference IR");
3131
}
3232
return diff / o2::constants::lhc::LHCMaxBunches;
@@ -39,7 +39,7 @@ int HBFUtils::fillHBIRvector(std::vector<IR>& dst, const IR& fromIR, const IR& t
3939
// BCs between interaction records "fromIR" and "toIR" (inclusive).
4040
dst.clear();
4141
int hb0 = getHBF(fromIR), hb1 = getHBF(toIR);
42-
if (fromIR.bc != bcFirst) { // unless we are just starting the HBF of fromIR, it was already counted
42+
if (fromIR.bc != 0) { // unless we are just starting the HBF of fromIR, it was already counted
4343
hb0++;
4444
}
4545
for (int ihb = hb0; ihb <= hb1; ihb++) {

Detectors/Raw/src/RawFileReader.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ bool RawFileReader::LinkData::preprocessCRUPage(const RDHAny& rdh, bool newSPage
374374
}
375375
}
376376
if (!irOfSOX.isDummy() && reader->getTFAutodetect() == FirstTFDetection::Pending) {
377-
reader->imposeFirstTF(irOfSOX.orbit, irOfSOX.bc);
377+
reader->imposeFirstTF(irOfSOX.orbit);
378378
}
379379
}
380380
auto newTFCalc = blocks.empty() || HBU.getTF(blocks.back().ir) < HBU.getTF(ir);
@@ -482,7 +482,7 @@ bool RawFileReader::LinkData::preprocessCRUPage(const RDHAny& rdh, bool newSPage
482482
if (newTF) {
483483
if (reader->getTFAutodetect() == FirstTFDetection::Pending) { // impose first TF
484484
if (cruDetector) {
485-
reader->imposeFirstTF(hbIR.orbit, hbIR.bc);
485+
reader->imposeFirstTF(hbIR.orbit);
486486
bl.tfID = HBU.getTF(hbIR); // update
487487
} else {
488488
throw std::runtime_error("HBFUtil first orbit/bc autodetection cannot be done with first link from CRORC detector");
@@ -901,14 +901,13 @@ RawFileReader::InputsMap RawFileReader::parseInput(const std::string& confUri)
901901
return entries;
902902
}
903903

904-
void RawFileReader::imposeFirstTF(uint32_t orbit, uint16_t bc)
904+
void RawFileReader::imposeFirstTF(uint32_t orbit)
905905
{
906906
if (mFirstTFAutodetect != FirstTFDetection::Pending) {
907907
throw std::runtime_error("reader was not expecting imposing first TF");
908908
}
909909
auto& hbu = o2::raw::HBFUtils::Instance();
910910
o2::raw::HBFUtils::setValue("HBFUtils", "orbitFirst", orbit);
911-
o2::raw::HBFUtils::setValue("HBFUtils", "bcFirst", bc);
912911
LOG(INFO) << "Imposed data-driven TF start";
913912
mFirstTFAutodetect = FirstTFDetection::Done;
914913
hbu.printKeyValues();

0 commit comments

Comments
 (0)