Skip to content

Commit 66b81d8

Browse files
authored
fix: +1 for L1 latency and trigger class check improved (#13682)
* fix: +1 for L1 latency * fix: +1 for L1 latency * dev: decoder: checking only trigger class bits which belongs to run * clang * dev: ctp config added also to CTF decoder * clang * fix: getting ctpconfig * clang * fix: removing std:;cout * clang * removing macro's modification to have cleaner PR * dec: two latency vars, rew-decoder accessing ccdb * clang * TriggerParams old variable same name * clang * dev: reading of CCDB offset paraams in rawdatadecoder * clang * dev: config done only if run changed
1 parent 74c640e commit 66b81d8

File tree

8 files changed

+82
-15
lines changed

8 files changed

+82
-15
lines changed

DataFormats/Detectors/CTP/include/DataFormatsCTP/TriggerOffsetsParam.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ namespace ctp
2424
struct TriggerOffsetsParam : public o2::conf::ConfigurableParamHelper<TriggerOffsetsParam> {
2525
static constexpr int MaxNDet = 32; // take with margin to account for possible changes / upgrades
2626
int64_t LM_L0 = 15;
27-
int64_t L0_L1 = 280;
27+
int64_t L0_L1 = 281; // trigger input latency
2828
int64_t globalInputsShift = 0; // Global shift of inps; customOffset[CTP] is global shift of classes
2929
int64_t customOffset[MaxNDet] = {};
30+
int64_t L0_L1_classes = 280; // trigger input latency
3031
O2ParamDef(TriggerOffsetsParam, "TriggerOffsetsParam"); // boilerplate stuff + make principal key
3132
};
3233
} // namespace ctp

Detectors/CTP/reconstruction/include/CTPReconstruction/CTFCoder.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "DetectorsBase/CTFCoderBase.h"
2626
#include "CTPReconstruction/CTFHelper.h"
2727
#include "CTPReconstruction/RawDataDecoder.h"
28+
#include "DataFormatsCTP/Configuration.h"
2829

2930
class TTree;
3031

@@ -53,6 +54,9 @@ class CTFCoder : public o2::ctf::CTFCoderBase
5354

5455
void createCoders(const std::vector<char>& bufVec, o2::ctf::CTFCoderBase::OpType op) final;
5556
void setDecodeInps(bool decodeinps) { mDecodeInps = decodeinps; }
57+
void setCTPConfig(CTPConfiguration cfg) { mCTPConfig = std::move(cfg); }
58+
bool getDecodeInps() { return mDecodeInps; }
59+
CTPConfiguration& getCTPConfig() { return mCTPConfig; }
5660
bool canApplyBCShiftInputs(const o2::InteractionRecord& ir) const { return canApplyBCShift(ir, mBCShiftInputs); }
5761

5862
private:
@@ -62,6 +66,7 @@ class CTFCoder : public o2::ctf::CTFCoderBase
6266
void appendToTree(TTree& tree, CTF& ec);
6367
void readFromTree(TTree& tree, int entry, std::vector<CTPDigit>& data, LumiInfo& lumi);
6468
std::vector<CTPDigit> mDataFilt;
69+
CTPConfiguration mCTPConfig;
6570
int mBCShiftInputs = 0;
6671
bool mDecodeInps = false;
6772
};
@@ -215,8 +220,13 @@ o2::ctf::CTFIOSize CTFCoder::decode(const CTF::base& ec, VTRG& data, LumiInfo& l
215220
}
216221
}
217222
if (mDecodeInps) {
223+
uint64_t trgclassmask = 0xffffffffffffffff;
224+
if (mCTPConfig.getRunNumber() != 0) {
225+
trgclassmask = mCTPConfig.getTriggerClassMask();
226+
}
227+
// std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
218228
o2::pmr::vector<CTPDigit> digits;
219-
o2::ctp::RawDataDecoder::shiftInputs(digitsMap, digits, mFirstTFOrbit);
229+
o2::ctp::RawDataDecoder::shiftInputs(digitsMap, digits, mFirstTFOrbit, trgclassmask);
220230
for (auto const& dig : digits) {
221231
data.emplace_back(dig);
222232
}

Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "Framework/InputRecord.h"
2323
#include "DataFormatsCTP/Digits.h"
2424
#include "DataFormatsCTP/LumiInfo.h"
25+
#include "DataFormatsCTP/Configuration.h"
2526

2627
namespace o2
2728
{
@@ -43,14 +44,16 @@ class RawDataDecoder
4344
void setVerbose(bool v) { mVerbose = v; }
4445
void setMAXErrors(int m) { mErrorMax = m; }
4546
int setLumiInp(int lumiinp, std::string inp);
47+
void setCTPConfig(CTPConfiguration cfg) { mCTPConfig = std::move(cfg); };
4648
uint32_t getIRRejected() const { return mIRRejected; }
4749
uint32_t getTCRRejected() const { return mTCRRejected; }
4850
std::vector<uint32_t>& getTFOrbits() { return mTFOrbits; }
4951
int getErrorIR() { return mErrorIR; }
5052
int getErrorTCR() { return mErrorTCR; }
53+
CTPConfiguration& getCTPConfig() { return mCTPConfig; }
5154
int init();
5255
static int shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit, std::bitset<48>& inpmask, int64_t shift, int level, std::map<o2::InteractionRecord, CTPDigit>& digmap);
53-
static int shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit);
56+
static int shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit, uint64_t trgclassmask = 0xffffffffffffffff);
5457

5558
private:
5659
static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800;
@@ -79,6 +82,7 @@ class RawDataDecoder
7982
int mErrorTCR = 0;
8083
int mErrorMax = 3;
8184
bool mStickyError = false;
85+
CTPConfiguration mCTPConfig;
8286
};
8387
} // namespace ctp
8488
} // namespace o2

Detectors/CTP/reconstruction/src/RawDataDecoder.cxx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& d
8989
}
9090
} else if (linkCRU == o2::ctp::GBTLinkIDClassRec) {
9191
int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP];
92-
int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1 - 1;
92+
int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1_classes - 1;
9393
LOG(debug) << "tcr ir ori:" << ir;
9494
if ((ir.orbit <= mTFOrbit) && ((int32_t)ir.bc < offset)) {
9595
// LOG(warning) << "Loosing tclass:" << ir;
@@ -293,7 +293,12 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector<o2
293293
// std::cout << "last lumi:" << nhb << std::endl;
294294
}
295295
if (mDoDigits & mDecodeInps) {
296-
shiftInputs(digitsMap, digits, mTFOrbit);
296+
uint64_t trgclassmask = 0xffffffffffffffff;
297+
if (mCTPConfig.getRunNumber() != 0) {
298+
trgclassmask = mCTPConfig.getTriggerClassMask();
299+
}
300+
// std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
301+
shiftInputs(digitsMap, digits, mTFOrbit, trgclassmask);
297302
}
298303
if (mDoDigits && !mDecodeInps) {
299304
for (auto const& dig : digitsMap) {
@@ -519,14 +524,15 @@ int RawDataDecoder::shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit
519524
}
520525
//
521526

522-
int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit)
527+
int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit, uint64_t trgclassmask)
523528
{
524529
// int nClasswoInp = 0; // counting classes without input which should never happen
525530
int nLM = 0;
526531
int nL0 = 0;
527532
int nL1 = 0;
528533
int nTwI = 0;
529534
int nTwoI = 0;
535+
int nTwoIlost = 0;
530536
std::map<o2::InteractionRecord, CTPDigit> digitsMapShifted;
531537
auto L0shift = o2::ctp::TriggerOffsetsParam::Instance().LM_L0;
532538
auto L1shift = L0shift + o2::ctp::TriggerOffsetsParam::Instance().L0_L1;
@@ -594,18 +600,27 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
594600
if ((d.CTPInputMask & L1MASKInputs).count()) {
595601
nL1++;
596602
}
597-
if (d.CTPClassMask.count()) {
603+
if ((d.CTPClassMask).to_ulong() & trgclassmask) {
598604
if (d.CTPInputMask.count()) {
599605
nTwI++;
600606
} else {
601-
nTwoI++;
607+
if (d.intRecord.bc == (o2::constants::lhc::LHCMaxBunches - L1shift)) { // input can be lost because latency class-l1input = 1
608+
nTwoIlost++;
609+
} else {
610+
// LOG(error) << d.intRecord << " " << d.CTPClassMask << " " << d.CTPInputMask;
611+
// std::cout << "ERROR:" << std::hex << d.CTPClassMask << " " << d.CTPInputMask << std::dec << std::endl;
612+
nTwoI++;
613+
}
602614
}
603615
}
604616
digits.push_back(dig.second);
605617
}
606618
if (nTwoI) { // Trigger class wo Input
607619
LOG(error) << "LM:" << nLM << " L0:" << nL0 << " L1:" << nL1 << " TwI:" << nTwI << " Trigger classes wo input:" << nTwoI;
608620
}
621+
if (nTwoIlost) {
622+
LOG(warn) << " Trigger classes wo input from diff latency 1:" << nTwoIlost;
623+
}
609624
return 0;
610625
}
611626
//

Detectors/CTP/workflow/include/CTPWorkflow/EntropyDecoderSpec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class EntropyDecoderSpec : public o2::framework::Task
3434
void init(o2::framework::InitContext& ic) final;
3535
void endOfStream(o2::framework::EndOfStreamContext& ec) final;
3636
void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final;
37+
void updateTimeDependentParams(framework::ProcessingContext& pc);
3738

3839
private:
3940
o2::ctp::CTFCoder mCTFCoder;

Detectors/CTP/workflow/include/CTPWorkflow/RawDecoderSpec.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <deque>
1717
#include "Framework/DataProcessorSpec.h"
1818
#include "Framework/Task.h"
19+
#include "Framework/WorkflowSpec.h"
1920
#include "DataFormatsCTP/Digits.h"
2021
#include "DataFormatsCTP/LumiInfo.h"
2122
#include "CTPReconstruction/RawDataDecoder.h"
@@ -50,6 +51,7 @@ class RawDecoderSpec : public framework::Task
5051
/// Input RawData: {"ROUT", "RAWDATA", 0, Lifetime::Timeframe}
5152
/// Output HW errors: {"CTP", "RAWHWERRORS", 0, Lifetime::Timeframe} -later
5253
void run(framework::ProcessingContext& ctx) final;
54+
void updateTimeDependentParams(framework::ProcessingContext& pc);
5355

5456
protected:
5557
private:
@@ -68,6 +70,7 @@ class RawDecoderSpec : public framework::Task
6870
uint32_t mNTFToIntegrate = 1;
6971
uint32_t mNHBIntegratedT = 0;
7072
uint32_t mNHBIntegratedV = 0;
73+
bool mDecodeinputs = 0;
7174
std::deque<size_t> mHistoryT;
7275
std::deque<size_t> mHistoryV;
7376
RawDataDecoder mDecoder;

Detectors/CTP/workflow/src/EntropyDecoderSpec.cxx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ void EntropyDecoderSpec::run(ProcessingContext& pc)
5555
mTimer.Start(false);
5656
o2::ctf::CTFIOSize iosize;
5757

58-
mCTFCoder.updateTimeDependentParams(pc, true);
58+
updateTimeDependentParams(pc);
5959
auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_CTP");
60-
6160
auto& digits = pc.outputs().make<std::vector<CTPDigit>>(OutputRef{"digits"});
6261
auto& lumi = pc.outputs().make<LumiInfo>(OutputRef{"CTPLumi"});
6362

@@ -76,6 +75,20 @@ void EntropyDecoderSpec::endOfStream(EndOfStreamContext& ec)
7675
LOGF(info, "CTP Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
7776
mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
7877
}
78+
void EntropyDecoderSpec::updateTimeDependentParams(framework::ProcessingContext& pc)
79+
{
80+
mCTFCoder.updateTimeDependentParams(pc, true);
81+
if (pc.services().get<o2::framework::TimingInfo>().globalRunNumberChanged) {
82+
const auto ctpcfg = pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
83+
if (mCTFCoder.getDecodeInps()) {
84+
const auto ctpcfg = pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
85+
if (ctpcfg != nullptr) {
86+
mCTFCoder.setCTPConfig(*ctpcfg);
87+
LOG(info) << "ctpconfig for run done:" << mCTFCoder.getCTPConfig().getRunNumber();
88+
}
89+
}
90+
}
91+
}
7992

8093
DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec)
8194
{
@@ -88,7 +101,7 @@ DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec)
88101
inputs.emplace_back("ctf_CTP", "CTP", "CTFDATA", sspec, Lifetime::Timeframe);
89102
inputs.emplace_back("ctfdict_CTP", "CTP", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/CTFDictionaryTree"));
90103
inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
91-
104+
inputs.emplace_back("ctpconfig", "CTP", "CTPCONFIG", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/Config", 1));
92105
return DataProcessorSpec{
93106
"ctp-entropy-decoder",
94107
inputs,

Detectors/CTP/workflow/src/RawDecoderSpec.cxx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@
1313
#include <fairlogger/Logger.h>
1414
#include "Framework/InputRecordWalker.h"
1515
#include "Framework/DataRefUtils.h"
16-
#include "Framework/WorkflowSpec.h"
1716
#include "Framework/ConfigParamRegistry.h"
1817
#include "DetectorsRaw/RDHUtils.h"
1918
#include "CTPWorkflow/RawDecoderSpec.h"
2019
#include "CommonUtils/VerbosityConfig.h"
2120
#include "Framework/InputRecord.h"
2221
#include "DataFormatsCTP/TriggerOffsetsParam.h"
22+
#include "Framework/CCDBParamSpec.h"
23+
#include "DataFormatsCTP/Configuration.h"
2324

2425
using namespace o2::ctp::reco_workflow;
2526

2627
void RawDecoderSpec::init(framework::InitContext& ctx)
2728
{
28-
bool decodeinps = ctx.options().get<bool>("ctpinputs-decoding");
29-
mDecoder.setDecodeInps(decodeinps);
29+
mDecodeinputs = ctx.options().get<bool>("ctpinputs-decoding");
30+
mDecoder.setDecodeInps(mDecodeinputs);
3031
mNTFToIntegrate = ctx.options().get<int>("ntf-to-average");
3132
mVerbose = ctx.options().get<bool>("use-verbose-mode");
3233
int maxerrors = ctx.options().get<int>("print-errors-num");
@@ -42,7 +43,7 @@ void RawDecoderSpec::init(framework::InitContext& ctx)
4243
mOutputLumiInfo.inp2 = inp2;
4344
mMaxInputSize = ctx.options().get<int>("max-input-size");
4445
mMaxInputSizeFatal = ctx.options().get<bool>("max-input-size-fatal");
45-
LOG(info) << "CTP reco init done. Inputs decoding here:" << decodeinps << " DoLumi:" << mDoLumi << " DoDigits:" << mDoDigits << " NTF:" << mNTFToIntegrate << " Lumi inputs:" << lumiinp1 << ":" << inp1 << " " << lumiinp2 << ":" << inp2 << " Max errors:" << maxerrors << " Max input size:" << mMaxInputSize << " MaxInputSizeFatal:" << mMaxInputSizeFatal;
46+
LOG(info) << "CTP reco init done. Inputs decoding here:" << mDecodeinputs << " DoLumi:" << mDoLumi << " DoDigits:" << mDoDigits << " NTF:" << mNTFToIntegrate << " Lumi inputs:" << lumiinp1 << ":" << inp1 << " " << lumiinp2 << ":" << inp2 << " Max errors:" << maxerrors << " Max input size:" << mMaxInputSize << " MaxInputSizeFatal:" << mMaxInputSizeFatal;
4647
// mOutputLumiInfo.printInputs();
4748
}
4849
void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec)
@@ -73,6 +74,7 @@ void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec)
7374
}
7475
void RawDecoderSpec::run(framework::ProcessingContext& ctx)
7576
{
77+
updateTimeDependentParams(ctx);
7678
mOutputDigits.clear();
7779
std::map<o2::InteractionRecord, CTPDigit> digits;
7880
using InputSpec = o2::framework::InputSpec;
@@ -176,6 +178,7 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
176178
mOutputLumiInfo.orbit = lumiPointsHBF1[0].orbit;
177179
}
178180
mOutputLumiInfo.counts = mCountsT;
181+
179182
mOutputLumiInfo.countsFV0 = mCountsV;
180183
mOutputLumiInfo.nHBFCounted = mNHBIntegratedT;
181184
mOutputLumiInfo.nHBFCountedFV0 = mNHBIntegratedV;
@@ -199,6 +202,8 @@ o2::framework::DataProcessorSpec o2::ctp::reco_workflow::getRawDecoderSpec(bool
199202

200203
std::vector<o2::framework::OutputSpec> outputs;
201204
if (digits) {
205+
inputs.emplace_back("ctpconfig", "CTP", "CTPCONFIG", 0, o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec("CTP/Config/Config", 1));
206+
inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec("CTP/Config/TriggerOffsets"));
202207
outputs.emplace_back("CTP", "DIGITS", 0, o2::framework::Lifetime::Timeframe);
203208
}
204209
if (lumi) {
@@ -219,3 +224,18 @@ o2::framework::DataProcessorSpec o2::ctp::reco_workflow::getRawDecoderSpec(bool
219224
{"max-input-size-fatal", o2::framework::VariantType::Bool, false, {"If true issue fatal error otherwise error on;y"}},
220225
{"ctpinputs-decoding", o2::framework::VariantType::Bool, false, {"Inputs alignment: true - raw decoder - has to be compatible with CTF decoder: allowed options: 10,01,00"}}}};
221226
}
227+
void RawDecoderSpec::updateTimeDependentParams(framework::ProcessingContext& pc)
228+
{
229+
if (pc.services().get<o2::framework::TimingInfo>().globalRunNumberChanged) {
230+
pc.inputs().get<o2::ctp::TriggerOffsetsParam*>("trigoffset");
231+
const auto& trigOffsParam = o2::ctp::TriggerOffsetsParam::Instance();
232+
LOG(info) << "updateing TroggerOffsetsParam: inputs L0_L1:" << trigOffsParam.L0_L1 << " classes L0_L1:" << trigOffsParam.L0_L1_classes;
233+
if (mDecodeinputs) {
234+
const auto ctpcfg = pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
235+
if (ctpcfg != nullptr) {
236+
mDecoder.setCTPConfig(*ctpcfg);
237+
LOG(info) << "ctpconfig for run done:" << mDecoder.getCTPConfig().getRunNumber();
238+
}
239+
}
240+
}
241+
}

0 commit comments

Comments
 (0)