Skip to content

Commit 94de37b

Browse files
authored
ctpdev: raw decoder output size protection (#12830)
* dev: output size protection in ctp reco * clang
1 parent 492b260 commit 94de37b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class RawDecoderSpec : public framework::Task
5656
// for digits
5757
bool mDoDigits = true;
5858
o2::pmr::vector<CTPDigit> mOutputDigits;
59+
int mMaxOutputSize = 0;
5960
// for lumi
6061
bool mDoLumi = true;
6162
//

Detectors/CTP/workflow/src/RawDecoderSpec.cxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ void RawDecoderSpec::init(framework::InitContext& ctx)
4040
int inp2 = mDecoder.setLumiInp(2, lumiinp2);
4141
mOutputLumiInfo.inp1 = inp1;
4242
mOutputLumiInfo.inp2 = inp2;
43-
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;
43+
mMaxOutputSize = ctx.options().get<int>("max-output-size");
44+
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 output size:" << mMaxOutputSize;
4445
// mOutputLumiInfo.printInputs();
4546
}
4647
void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec)
@@ -117,6 +118,10 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
117118
}
118119
if (mDoDigits) {
119120
LOG(info) << "[CTPRawToDigitConverter - run] Writing " << mOutputDigits.size() << " digits. IR rejected:" << mDecoder.getIRRejected() << " TCR rejected:" << mDecoder.getTCRRejected();
121+
if ((mMaxOutputSize > 0) && (mOutputDigits.size() > mMaxOutputSize)) {
122+
LOG(error) << "CTP raw output size: " << mOutputDigits.size();
123+
mOutputDigits.clear();
124+
}
120125
ctx.outputs().snapshot(o2::framework::Output{"CTP", "DIGITS", 0}, mOutputDigits);
121126
}
122127
if (mDoLumi) {
@@ -189,5 +194,6 @@ o2::framework::DataProcessorSpec o2::ctp::reco_workflow::getRawDecoderSpec(bool
189194
{"lumi-inp1", o2::framework::VariantType::String, "TVX", {"The first input used for online lumi. Name in capital."}},
190195
{"lumi-inp2", o2::framework::VariantType::String, "VBA", {"The second input used for online lumi. Name in capital."}},
191196
{"use-verbose-mode", o2::framework::VariantType::Bool, false, {"Verbose logging"}},
197+
{"max-output-size", o2::framework::VariantType::Int, 0, {"Do not send output if bigger than max size, 0 - do not check"}},
192198
{"ctpinputs-decoding", o2::framework::VariantType::Bool, false, {"Inputs alignment: true - raw decoder - has to be compatible with CTF decoder: allowed options: 10,01,00"}}}};
193199
}

0 commit comments

Comments
 (0)