Skip to content

Commit

Permalink
ctpdev: special digi for emc (AliceO2Group#12192)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
lietava and mfasDa authored Nov 17, 2023
1 parent bfa09b7 commit b9b48a2
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 20 deletions.
5 changes: 4 additions & 1 deletion DataFormats/Detectors/CTP/src/Configuration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<CTPInput> CTPInputsConfiguration::CTPInputsDefault =
{
CTPInput("MT0A", "FT0", 1), CTPInput("MT0C", "FT0", 2), CTPInput("MTVX", "FT0", 3), CTPInput("MTSC", "FT0", 4), CTPInput("MTCE", "FT0", 5),
Expand All @@ -1057,7 +1060,7 @@ const std::vector<CTPInput> 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;
Expand Down
64 changes: 56 additions & 8 deletions Detectors/CTP/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ std::vector<CTPDigit> Digitizer::process(const gsl::span<o2::ctp::CTPInputDigit>
std::map<o2::detectors::DetID::ID, std::vector<CTPInput>> det2ctpinp = mCTPConfiguration->getDet2InputMap();
// To be taken from config database ?
std::map<std::string, uint64_t> 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<o2::InteractionRecord, std::vector<const CTPInputDigit*>> predigits;
Expand Down Expand Up @@ -69,12 +69,23 @@ std::vector<CTPDigit> Digitizer::process(const gsl::span<o2::ctp::CTPInputDigit>
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<CTP_NINPUTS>(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<CTP_NINPUTS> 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<CTP_NINPUTS>(ctpinp.inputMask);
}
}
}
LOG(info) << "EMC input mask:" << inpmaskcoll;
break;
}
case o2::detectors::DetID::PHS: {
Expand All @@ -100,13 +111,21 @@ std::vector<CTPDigit> Digitizer::process(const gsl::span<o2::ctp::CTPInputDigit>
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;
}
Expand All @@ -117,10 +136,39 @@ void Digitizer::calculateClassMask(const std::bitset<CTP_NINPUTS> 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()
{
Expand Down
40 changes: 29 additions & 11 deletions Steer/DigitizerWorkflow/src/CTPDigitizerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<o2::detectors::DetID>& detList) : o2::base::BaseDPLDigitizer(), mDigitizer(), mDetList(detList) {}
~CTPDPLDigitizerTask() override = default;
void initDigitizerTask(framework::InitContext& ic) override
{
Expand All @@ -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<o2::steer::DigitizationContext*>("collisioncontext");
//const bool withQED = context->isQEDProvided();
//auto& timesview = context->getEventRecords(withQED);
// auto context = pc.inputs().get<o2::steer::DigitizationContext*>("collisioncontext");
// const bool withQED = context->isQEDProvided();
// auto& timesview = context->getEventRecords(withQED);
// read ctp inputs from input
auto ft0inputs = pc.inputs().get<gsl::span<o2::ft0::DetTrigInput>>("ft0");
auto fv0inputs = pc.inputs().get<gsl::span<o2::fv0::DetTrigInput>>("fv0");

std::vector<o2::ctp::CTPInputDigit> 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<gsl::span<o2::ft0::DetTrigInput>>("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<gsl::span<o2::fv0::DetTrigInput>>("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<gsl::span<o2::ctp::CTPInputDigit>>("emc");
for (const auto& inp : emcinputs) {
finputs.emplace_back(inp);
}
}
gsl::span<CTPInputDigit> ginputs(finputs);
auto digits = mDigitizer.process(ginputs);
Expand All @@ -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<o2::detectors::DetID> mDetList;
};
o2::framework::DataProcessorSpec getCTPDigitizerSpec(int channel, std::vector<o2::detectors::DetID>& detList, bool mctruth)
{
std::vector<InputSpec> inputs;
std::vector<OutputSpec> 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<CTPDPLDigitizerTask>()},
AlgorithmSpec{adaptFromTask<CTPDPLDigitizerTask>(detList)},
Options{{"pileup", VariantType::Int, 1, {"whether to run in continuous time mode"}},
{"disable-qed", o2::framework::VariantType::Bool, false, {"disable QED handling"}}}};
}
Expand Down

0 comments on commit b9b48a2

Please sign in to comment.