From b9b48a205754ee0d225450b1cbdefd8d6094fb9c Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Fri, 17 Nov 2023 14:14:20 +0100 Subject: [PATCH] ctpdev: special digi for emc (#12192) * dev: special digtization for emc * clang * typo * dev: Markus' modifications, mEMCsim not used * clang * improvements fixes: not finished * improvements fixes 2: not finished * improvements fixes 3: not finished * dev: bug fixes * clang * dev: emc reco mising with dataRequest * clang * dev: minor reshuffling * dev:DataRequest not needed : trigger input availability done in simpler way * debug commented * Fix masking of EMCAL inputs for busy-reject triggers --------- Co-authored-by: mfasel --- .../Detectors/CTP/src/Configuration.cxx | 5 +- Detectors/CTP/simulation/src/Digitizer.cxx | 64 ++++++++++++++++--- .../src/CTPDigitizerSpec.cxx | 40 ++++++++---- 3 files changed, 89 insertions(+), 20 deletions(-) diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 960dc542c6f55..9afb422e34984 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -1049,6 +1049,9 @@ void CTPInputsConfiguration::printStream(std::ostream& stream) const input.printStream(stream); } } +// +// EMBA - software generated input for EMC - Min Bias Accepted +// const std::vector CTPInputsConfiguration::CTPInputsDefault = { CTPInput("MT0A", "FT0", 1), CTPInput("MT0C", "FT0", 2), CTPInput("MTVX", "FT0", 3), CTPInput("MTSC", "FT0", 4), CTPInput("MTCE", "FT0", 5), @@ -1057,7 +1060,7 @@ const std::vector CTPInputsConfiguration::CTPInputsDefault = CTPInput("0DMC", "EMC", 14), CTPInput("0DJ1", "EMC", 41), CTPInput("0DG1", "EMC", 42), CTPInput("0DJ2", "EMC", 43), CTPInput("0DG2", "EMC", 44), CTPInput("0EMC", "EMC", 21), CTPInput("0EJ1", "EMC", 37), CTPInput("0EG1", "EMC", 38), CTPInput("0EJ2", "EMC", 39), CTPInput("0EG2", "EMC", 40), CTPInput("0PH0", "PHS", 22), CTPInput("1PHL", "PHS", 27), CTPInput("1PHH", "PHS", 28), CTPInput("1PHL", "PHM", 29), - CTPInput("1ZED", "ZDC", 25), CTPInput("1ZNC", "ZDC", 26)}; + CTPInput("1ZED", "ZDC", 25), CTPInput("1ZNC", "ZDC", 26), CTPInput("EMBA", "EMC", 48)}; void CTPInputsConfiguration::initDefaultInputConfig() { defaultInputConfig.CTPInputs = CTPInputsConfiguration::CTPInputsDefault; diff --git a/Detectors/CTP/simulation/src/Digitizer.cxx b/Detectors/CTP/simulation/src/Digitizer.cxx index 2e865f1f19e58..ffd37f1c16a50 100644 --- a/Detectors/CTP/simulation/src/Digitizer.cxx +++ b/Detectors/CTP/simulation/src/Digitizer.cxx @@ -27,7 +27,7 @@ std::vector Digitizer::process(const gsl::span std::map> det2ctpinp = mCTPConfiguration->getDet2InputMap(); // To be taken from config database ? std::map detInputName2Mask = - {{"MVBA", 1}, {"MVOR", 2}, {"MVNC", 4}, {"MVCH", 8}, {"MVIR", 0x10}, {"MT0A", 1}, {"MT0C", 2}, {"MTSC", 4}, {"MTCE", 8}, {"MTVX", 0x10}, {"0U0A", 1}, {"0U0C", 2}, {"0USC", 4}, {"0UCE", 8}, {"0UVX", 0x10}}; + {{"MVBA", 1}, {"MVOR", 2}, {"MVNC", 4}, {"MVCH", 8}, {"MVIR", 0x10}, {"MT0A", 1}, {"MT0C", 2}, {"MTSC", 4}, {"MTCE", 8}, {"MTVX", 0x10}, {"0U0A", 1}, {"0U0C", 2}, {"0USC", 4}, {"0UCE", 8}, {"0UVX", 0x10}, {"EMBA", 0x1}, {"0EMC", 0x2}, {"0DMC", 0x4}}; // pre-sorting detector inputs per interaction record std::map> predigits; @@ -69,12 +69,23 @@ std::vector Digitizer::process(const gsl::span break; } case o2::detectors::DetID::EMC: { - for (auto const& ctpinp : det2ctpinp[o2::detectors::DetID::EMC]) { - uint64_t mask = (inp->inputsMask).to_ullong() & detInputName2Mask[ctpinp.name]; - if (mask) { - inpmaskcoll |= std::bitset(ctpinp.inputMask); + // uint64_t inpmaskdebug = 1; + uint64_t inpmaskdebug = (inp->inputsMask).to_ullong(); + if (inpmaskdebug & detInputName2Mask["EMBA"]) { + // MB-accept must be treated separately, as it is not a CTP input + std::bitset emcMBaccept; + emcMBaccept.set(CTP_NINPUTS - 1, 1); + inpmaskcoll |= emcMBaccept; + } else { + for (auto const& ctpinp : det2ctpinp[o2::detectors::DetID::EMC]) { + uint64_t mask = inpmaskdebug & detInputName2Mask[ctpinp.name]; + // uint64_t mask = (inp->inputsMask).to_ullong() & detInputName2Mask[ctpinp.name]; + if (mask) { + inpmaskcoll |= std::bitset(ctpinp.inputMask); + } } } + LOG(info) << "EMC input mask:" << inpmaskcoll; break; } case o2::detectors::DetID::PHS: { @@ -100,13 +111,21 @@ std::vector Digitizer::process(const gsl::span LOG(error) << "CTP Digitizer: unknown detector:" << inp->detector; break; } + // inpmaskcoll.reset(); // debug + // inpmaskcoll[47] = 1; // debug } // end loop over trigger input for this interaction if (inpmaskcoll.to_ullong()) { // we put the trigger only when non-trivial + std::bitset<64> classmask; + calculateClassMask(inpmaskcoll, classmask); + if (classmask.to_ulong() == 0) { + // No class accepted + continue; + } CTPDigit data; data.intRecord = hits.first; data.CTPInputMask = inpmaskcoll; - calculateClassMask(inpmaskcoll, data.CTPClassMask); + data.CTPClassMask = classmask; digits.emplace_back(data); LOG(info) << "Trigger-Event " << data.intRecord.bc << " " << data.intRecord.orbit << " Input mask:" << inpmaskcoll; } @@ -117,10 +136,39 @@ void Digitizer::calculateClassMask(const std::bitset ctpinpmask, st { classmask = 0; for (auto const& tcl : mCTPConfiguration->getCTPClasses()) { - if (tcl.descriptor->getInputsMask() & ctpinpmask.to_ullong()) { - classmask |= (1 << tcl.classMask); + if (tcl.cluster->name == "emc") { + // check if Min Bias EMC class + bool tvxMBemc = tcl.name.find("C0TVX-B-NOPF-EMC") != std::string::npos; // 2023 + tvxMBemc |= tcl.name.find("C0TVX-A-NOPF-EMC") != std::string::npos; + tvxMBemc |= tcl.name.find("C0TVX-C-NOPF-EMC") != std::string::npos; + tvxMBemc |= tcl.name.find("C0TVX-E-NOPF-EMC") != std::string::npos; + if (tcl.cluster->name == "emc") { + tvxMBemc |= tcl.name.find("minbias_TVX_L0") != std::string::npos; // 2022 + } + if (tcl.descriptor->getInputsMask() & ctpinpmask.to_ullong()) { + // require real physics input in any case + if (tvxMBemc) { + // if the class is a min. bias class accept it only if the MB-accept bit is set in addition + // (fake trigger input) + if (ctpinpmask[CTP_NINPUTS - 1]) { + classmask |= tcl.classMask; + LOG(info) << "adding MBA:" << tcl.name; + } + } else { + // EMCAL rare triggers - physical trigger input + // class identification can be handled like in the case of the other + // classes as EMCAL trigger input is required + classmask |= tcl.classMask; + } + } + } else { + if (tcl.descriptor->getInputsMask() & ctpinpmask.to_ullong()) { + classmask |= tcl.classMask; + } } } + LOG(info) << "input mask:" << ctpinpmask; + LOG(info) << "class mask:" << classmask; } void Digitizer::init() { diff --git a/Steer/DigitizerWorkflow/src/CTPDigitizerSpec.cxx b/Steer/DigitizerWorkflow/src/CTPDigitizerSpec.cxx index bf9ce02c989dc..412e6d6129a76 100644 --- a/Steer/DigitizerWorkflow/src/CTPDigitizerSpec.cxx +++ b/Steer/DigitizerWorkflow/src/CTPDigitizerSpec.cxx @@ -35,7 +35,7 @@ class CTPDPLDigitizerTask : public o2::base::BaseDPLDigitizer using GRP = o2::parameters::GRPObject; public: - CTPDPLDigitizerTask() : o2::base::BaseDPLDigitizer(), mDigitizer() {} + CTPDPLDigitizerTask(const std::vector& detList) : o2::base::BaseDPLDigitizer(), mDigitizer(), mDetList(detList) {} ~CTPDPLDigitizerTask() override = default; void initDigitizerTask(framework::InitContext& ic) override { @@ -44,23 +44,36 @@ class CTPDPLDigitizerTask : public o2::base::BaseDPLDigitizer void run(framework::ProcessingContext& pc) { // read collision context from input - //auto context = pc.inputs().get("collisioncontext"); - //const bool withQED = context->isQEDProvided(); - //auto& timesview = context->getEventRecords(withQED); + // auto context = pc.inputs().get("collisioncontext"); + // const bool withQED = context->isQEDProvided(); + // auto& timesview = context->getEventRecords(withQED); // read ctp inputs from input - auto ft0inputs = pc.inputs().get>("ft0"); - auto fv0inputs = pc.inputs().get>("fv0"); std::vector finputs; TStopwatch timer; timer.Start(); LOG(info) << "CALLING CTP DIGITIZATION"; // Input order: T0, V0, ... but O need also position of inputs DETInputs - for (const auto& inp : ft0inputs) { - finputs.emplace_back(CTPInputDigit{inp.mIntRecord, inp.mInputs, o2::detectors::DetID::FT0}); + // fv0 + if (std::find(mDetList.begin(), mDetList.end(), o2::detectors::DetID::FT0) != mDetList.end()) { + auto ft0inputs = pc.inputs().get>("ft0"); + for (const auto& inp : ft0inputs) { + finputs.emplace_back(CTPInputDigit{inp.mIntRecord, inp.mInputs, o2::detectors::DetID::FT0}); + } } - for (const auto& inp : fv0inputs) { - finputs.emplace_back(CTPInputDigit{inp.mIntRecord, inp.mInputs, o2::detectors::DetID::FV0}); + // fv0 + if (std::find(mDetList.begin(), mDetList.end(), o2::detectors::DetID::FV0) != mDetList.end()) { + auto fv0inputs = pc.inputs().get>("fv0"); + for (const auto& inp : fv0inputs) { + finputs.emplace_back(CTPInputDigit{inp.mIntRecord, inp.mInputs, o2::detectors::DetID::FV0}); + } + } + // emc + if (std::find(mDetList.begin(), mDetList.end(), o2::detectors::DetID::EMC) != mDetList.end()) { + auto emcinputs = pc.inputs().get>("emc"); + for (const auto& inp : emcinputs) { + finputs.emplace_back(inp); + } } gsl::span ginputs(finputs); auto digits = mDigitizer.process(ginputs); @@ -76,24 +89,29 @@ class CTPDPLDigitizerTask : public o2::base::BaseDPLDigitizer protected: o2::parameters::GRPObject::ROMode mROMode = o2::parameters::GRPObject::PRESENT; o2::ctp::Digitizer mDigitizer; ///< Digitizer + std::vector mDetList; }; o2::framework::DataProcessorSpec getCTPDigitizerSpec(int channel, std::vector& detList, bool mctruth) { std::vector inputs; std::vector output; + if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::FT0) != detList.end()) { inputs.emplace_back("ft0", "FT0", "TRIGGERINPUT", 0, Lifetime::Timeframe); } if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::FV0) != detList.end()) { inputs.emplace_back("fv0", "FV0", "TRIGGERINPUT", 0, Lifetime::Timeframe); } + if (std::find(detList.begin(), detList.end(), o2::detectors::DetID::EMC) != detList.end()) { + inputs.emplace_back("emc", "EMC", "TRIGGERINPUT", 0, Lifetime::Timeframe); + } output.emplace_back("CTP", "DIGITS", 0, Lifetime::Timeframe); output.emplace_back("CTP", "ROMode", 0, Lifetime::Timeframe); return DataProcessorSpec{ "CTPDigitizer", inputs, output, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(detList)}, Options{{"pileup", VariantType::Int, 1, {"whether to run in continuous time mode"}}, {"disable-qed", o2::framework::VariantType::Bool, false, {"disable QED handling"}}}}; }