Skip to content

Commit

Permalink
Propagate digitizer interaction rate via DigitizationContext
Browse files Browse the repository at this point in the history
Some digitizer (EMCAL) aim to use the interaction rate for flow-control
in digitization. This is now possible from a new member in DigitizationContext
which will be filled in digitizer workflows.
  • Loading branch information
sawenzel committed Jul 12, 2024
1 parent d4b03d4 commit 7f32257
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class DigitizationContext

void setMuPerBC(float m) { mMuBC = m; }
float getMuPerBC() const { return mMuBC; }

/// returns the main (hadronic interaction rate) associated to this digitization context
float getCalculatedInteractionRate() const { return getMuPerBC() * getBunchFilling().getNBunches() * o2::constants::lhc::LHCRevFreq; }

void printCollisionSummary(bool withQED = false, int truncateOutputTo = -1) const;

Expand Down Expand Up @@ -150,6 +153,9 @@ class DigitizationContext
}
}

void setDigitizerInteractionRate(float intRate) { mDigitizerInteractionRate = intRate; }
float getDigitizerInteractionRate() const { return mDigitizerInteractionRate; }

std::vector<o2::ctp::CTPDigit> const* getCTPDigits() const { return mCTPTrigger; }
bool hasTriggerInput() const { return mHasTrigger; }

Expand Down Expand Up @@ -184,7 +190,13 @@ class DigitizationContext
mutable std::vector<o2::ctp::CTPDigit> const* mCTPTrigger = nullptr; // CTP trigger info associated to this digitization context
mutable bool mHasTrigger = false; //

ClassDefNV(DigitizationContext, 5);
// The global ALICE interaction hadronic interaction rate as applied in digitization.
// It should be consistent with mMuPerBC but it might be easier to handle.
// The value will be filled/inserted by the digitization workflow so that digiters can access it.
// There is no guarantee that the value is available elsewhere.
float mDigitizerInteractionRate{-1};

ClassDefNV(DigitizationContext, 6);
};

/// function reading the hits from a chain (previously initialized with initSimChains
Expand Down
3 changes: 3 additions & 0 deletions Detectors/EMCAL/workflow/src/EMCALDigitizerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ void DigitizerSpec::run(framework::ProcessingContext& ctx)

// read collision context from input
auto context = ctx.inputs().get<o2::steer::DigitizationContext*>("collisioncontext");

// get interaction rate ... so that it can be used in digitization
auto intRate = context->getDigitizerInteractionRate();
context->initSimChains(o2::detectors::DetID::EMC, mSimChains);
auto& timesview = context->getEventRecords();
LOG(debug) << "GOT " << timesview.size() << " COLLISSION TIMES";
Expand Down
19 changes: 11 additions & 8 deletions Steer/DigitizerWorkflow/src/SimReaderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace steer
{

std::vector<o2::ctp::CTPDigit>* ctptrigger = nullptr;
float gIntRate = -1.;

DataProcessorSpec getSimReaderSpec(SubspecRange range, const std::vector<std::string>& simprefixes, const std::vector<int>& tpcsectors, bool withTrigger)
{
Expand All @@ -55,7 +56,7 @@ DataProcessorSpec getSimReaderSpec(SubspecRange range, const std::vector<std::st

auto doit = [range, tpcsectors, activeSectors, withTrigger](ProcessingContext& pc) {
auto& mgr = steer::HitProcessingManager::instance();
const auto& context = mgr.getDigitizationContext();
auto& context = mgr.getDigitizationContext();
auto eventrecords = context.getEventRecords();

if (withTrigger) {
Expand All @@ -64,6 +65,9 @@ DataProcessorSpec getSimReaderSpec(SubspecRange range, const std::vector<std::st
context.setCTPDigits(ctptrigger);
}

// inject the global interaction rate information
context.setDigitizerInteractionRate(gIntRate);

for (auto const& sector : tpcsectors) {
// Note: the TPC sector header was serving the sector to lane mapping before
// now the only remaining purpose is to propagate the mask of valid sectors
Expand Down Expand Up @@ -128,6 +132,10 @@ DataProcessorSpec getSimReaderSpec(SubspecRange range, const std::vector<std::st
}
}

gIntRate = ctx.options().get<float>("interactionRate"); // is interaction rate requested?
if (gIntRate < 1.f) {
gIntRate = 1.f;
}
// do we start from an existing context
auto incontextstring = ctx.options().get<std::string>("incontext");
LOG(info) << "INCONTEXTSTRING " << incontextstring;
Expand All @@ -137,13 +145,8 @@ DataProcessorSpec getSimReaderSpec(SubspecRange range, const std::vector<std::st
LOG(fatal) << "Could not read collision context from " << incontextstring;
}
} else {

auto intRate = ctx.options().get<float>("interactionRate"); // is interaction rate requested?
if (intRate < 1.f) {
intRate = 1.f;
}
LOG(info) << "Imposing hadronic interaction rate " << intRate << "Hz";
mgr.getInteractionSampler().setInteractionRate(intRate);
LOG(info) << "Imposing hadronic interaction rate " << gIntRate << "Hz";
mgr.getInteractionSampler().setInteractionRate(gIntRate);
o2::raw::HBFUtils::Instance().print();
o2::raw::HBFUtils::Instance().checkConsistency();
mgr.getInteractionSampler().setFirstIR({0, o2::raw::HBFUtils::Instance().orbitFirstSampled});
Expand Down

0 comments on commit 7f32257

Please sign in to comment.