Skip to content

Commit

Permalink
dev: ctp config added also to CTF decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
lietava committed Nov 16, 2024
1 parent 5b3513d commit ba4bea3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
1 change: 1 addition & 0 deletions Detectors/CTP/macro/TestConfig.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <CCDB/BasicCCDBManager.h>
#include <DataFormatsCTP/Configuration.h>
#include "CTPWorkflowScalers/ctpCCDBManager.h"
#include "Framework/Logger.h"
#endif
using namespace o2::ctp;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "DetectorsBase/CTFCoderBase.h"
#include "CTPReconstruction/CTFHelper.h"
#include "CTPReconstruction/RawDataDecoder.h"
#include "DataFormatsCTP/Configuration.h"

class TTree;

Expand Down Expand Up @@ -53,6 +54,8 @@ class CTFCoder : public o2::ctf::CTFCoderBase

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

private:
Expand All @@ -62,6 +65,7 @@ class CTFCoder : public o2::ctf::CTFCoderBase
void appendToTree(TTree& tree, CTF& ec);
void readFromTree(TTree& tree, int entry, std::vector<CTPDigit>& data, LumiInfo& lumi);
std::vector<CTPDigit> mDataFilt;
CTPConfiguration mCTPConfig;
int mBCShiftInputs = 0;
bool mDecodeInps = false;
};
Expand Down Expand Up @@ -215,8 +219,13 @@ o2::ctf::CTFIOSize CTFCoder::decode(const CTF::base& ec, VTRG& data, LumiInfo& l
}
}
if (mDecodeInps) {
uint64_t trgclassmask = 0xffffffffffffffff;
if(mCTPConfig.getRunNumber() != 0) {
trgclassmask = mCTPConfig.getTriggerClassMask();
}
std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
o2::pmr::vector<CTPDigit> digits;
o2::ctp::RawDataDecoder::shiftInputs(digitsMap, digits, mFirstTFOrbit);
o2::ctp::RawDataDecoder::shiftInputs(digitsMap, digits, mFirstTFOrbit, trgclassmask);
for (auto const& dig : digits) {
data.emplace_back(dig);
}
Expand Down
17 changes: 14 additions & 3 deletions Detectors/CTP/reconstruction/src/RawDataDecoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,10 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector<o2
// std::cout << "last lumi:" << nhb << std::endl;
}
if (mDoDigits & mDecodeInps) {
uint64_t trgclassmask = mCTPConfig.getTriggerClassMask();
uint64_t trgclassmask = 0xffffffffffffffff;
if(mCTPConfig.getRunNumber() != 0) {
trgclassmask = mCTPConfig.getTriggerClassMask();
}
std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
shiftInputs(digitsMap, digits, mTFOrbit, trgclassmask);
}
Expand Down Expand Up @@ -529,6 +532,7 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
int nL1 = 0;
int nTwI = 0;
int nTwoI = 0;
int nTwoIlost = 0;
std::map<o2::InteractionRecord, CTPDigit> digitsMapShifted;
auto L0shift = o2::ctp::TriggerOffsetsParam::Instance().LM_L0;
auto L1shift = L0shift + o2::ctp::TriggerOffsetsParam::Instance().L0_L1 + 1;
Expand Down Expand Up @@ -600,13 +604,20 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
if (d.CTPInputMask.count()) {
nTwI++;
} else {
nTwoI++;
if(d.intRecord.bc == (o2::constants::lhc::LHCMaxBunches - L1shift)) { // input can be lost because latency class-l1input = 1
nTwoIlost++;
} else {
LOG(error) << d.intRecord << " " << d.CTPClassMask << " " << d.CTPInputMask;
//std::cout << std::hex << d.CTPClassMask << " " << d.CTPInputMask << std::dec << std::endl;
nTwoI++;
}
}
}
digits.push_back(dig.second);
}
if (nTwoI) { // Trigger class wo Input
if (nTwoI || nTwoIlost) { // Trigger class wo Input
LOG(error) << "LM:" << nLM << " L0:" << nL0 << " L1:" << nL1 << " TwI:" << nTwI << " Trigger classes wo input:" << nTwoI;
LOG(warn) << " Trigger classes wo input from diff latency 1:" << nTwoIlost;
}
return 0;
}
Expand Down
9 changes: 8 additions & 1 deletion Detectors/CTP/workflow/src/EntropyDecoderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,20 @@ void EntropyDecoderSpec::run(ProcessingContext& pc)

mCTFCoder.updateTimeDependentParams(pc, true);
auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_CTP");


const auto ctpcfg = pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
auto& digits = pc.outputs().make<std::vector<CTPDigit>>(OutputRef{"digits"});
auto& lumi = pc.outputs().make<LumiInfo>(OutputRef{"CTPLumi"});

// since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
if (buff.size()) {
const auto ctfImage = o2::ctp::CTF::getImage(buff.data());
if(mCTFCoder.getDecodeInps()){
const auto ctpcfg = pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
if(ctpcfg != nullptr) {
mCTFCoder.setCTPConfig(*ctpcfg);
}
}
iosize = mCTFCoder.decode(ctfImage, digits, lumi);
}
pc.outputs().snapshot({"ctfrep", 0}, iosize);
Expand Down
5 changes: 3 additions & 2 deletions Detectors/CTP/workflow/src/RawDecoderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
} else {
if (mDecodeinputs) {
const auto ctpcfg = inputs.get<o2::ctp::CTPConfiguration*>("ctpconfig");
// ctpcfg->printStream(std::cout);
mDecoder.setCTPConfig(*ctpcfg);
if(ctpcfg != nullptr) {
mDecoder.setCTPConfig(*ctpcfg);
}
}
ret = mDecoder.decodeRaw(inputs, filter, mOutputDigits, lumiPointsHBF1);
}
Expand Down

0 comments on commit ba4bea3

Please sign in to comment.