Skip to content

Commit

Permalink
[EMCAL-539,EMCAL-696,EMCAL-697] Enum for EMCAL triggers, introduced s…
Browse files Browse the repository at this point in the history
…witch trigger sim
  • Loading branch information
siragoni committed Mar 14, 2024
1 parent 98903c5 commit 3b0dff4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 50 deletions.
4 changes: 1 addition & 3 deletions Detectors/EMCAL/simulation/src/DigitsWriteoutBufferTRU.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@ void DigitsWriteoutBufferTRU::fillOutputContainer(bool isEndOfTimeFrame, Interac
}
}
reserve(15);


LOG(info) << "DIG TRU fillOutputContainer in DigitsWriteoutBufferTRU: HIGH IR";

LOG(info) << "DIG TRU fillOutputContainer in DigitsWriteoutBufferTRU: HIGH IR";
}
}
//________________________________________________________
Expand Down
7 changes: 1 addition & 6 deletions Detectors/EMCAL/simulation/src/LZEROElectronics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ void LZEROElectronics::fill(const std::deque<o2::emcal::DigitTimebinTRU>& digitl
int sizemDigitMap = -999;
TriggerMappingV2 mTriggerMap(mGeometry);




for (auto& digitsTimeBin : digitlist) {
// Inside the DigitTimebinTRU
// Fill the LZEROElectronics with the new ADC value
Expand Down Expand Up @@ -152,7 +149,6 @@ void LZEROElectronics::fill(const std::deque<o2::emcal::DigitTimebinTRU>& digitl

auto [whichTRU, whichFastOrTRU] = mTriggerMap.getTRUFromAbsFastORIndex(fastor);


auto whichFastOr = std::get<1>(mTriggerMap.convertFastORIndexTRUtoSTU(whichTRU, whichFastOrTRU));
auto& patchTRU = patchesFromAllTRUs[whichTRU];
auto& fastOrPatchTRU = patchTRU.mFastOrs[whichFastOr];
Expand All @@ -174,7 +170,7 @@ void LZEROElectronics::fill(const std::deque<o2::emcal::DigitTimebinTRU>& digitl
// It accounts for the difference in times between L0a, L0b, and then there will be a L1 and L1b delay
// There is 1BC uncertainty on the trigger readout due to steps in the interaction between CTP and detector simulations
bool foundPeak = false;
int counterWhichTRU = 0;
int counterWhichTRU = 0;
int triggeredTRU = -1;
std::vector<int> triggeredPatches;
for (auto& patches : patchesFromAllTRUs) {
Expand All @@ -191,7 +187,6 @@ void LZEROElectronics::fill(const std::deque<o2::emcal::DigitTimebinTRU>& digitl
counterWhichTRU += 1;
}


if (foundPeak == true) {
LOG(debug) << "DIG TRU fill in LZEROElectronics: foundPeak = " << foundPeak;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <DetectorsBase/BaseDPLDigitizer.h>
#include "EMCALSimulation/DigitizerTRU.h"


class TChain;

namespace o2
Expand Down Expand Up @@ -87,9 +86,9 @@ class DigitizerSpec final : public o2::base::BaseDPLDigitizer, public o2::framew
std::vector<TChain*> mSimChains;
o2::ctp::CTPConfiguration* mCTPConfig; ///< CTP configuration

DigitizerTRU mDigitizerTRU; ///< Digitizer object TRU
o2::emcal::SDigitizer mSumDigitizerTRU; ///< Summed digitizer TRU

DigitizerTRU mDigitizerTRU; ///< Digitizer object TRU
o2::emcal::SDigitizer mSumDigitizerTRU; ///< Summed digitizer TRU
bool mRunDigitizerTRU = true; ///< Run Digitizer TRU?
};

/// \brief Create new digitizer spec
Expand Down
66 changes: 29 additions & 37 deletions Detectors/EMCAL/workflow/src/EMCALDigitizerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ void DigitizerSpec::initDigitizerTask(framework::InitContext& ctx)
mDigitizerTRU.setDebugStreaming(true);
}
// mDigitizer.init();
if (ctx.options().get<bool>("no-dig-tru")) {
mRunDigitizerTRU = false;
}

mFinished = false;
}
Expand Down Expand Up @@ -98,14 +101,8 @@ void DigitizerSpec::run(framework::ProcessingContext& ctx)
TStopwatch timer;
timer.Start();






auto& eventParts = context->getEventParts();


// ------------------------------
// TRIGGER Simulation
// ------------------------------
Expand All @@ -118,6 +115,10 @@ void DigitizerSpec::run(framework::ProcessingContext& ctx)
int collisionN = 0;
for (int collID = 0; collID < timesview.size(); ++collID) {

if (mRunDigitizerTRU == false) {
break;
}

LOG(info) << "DIG TRU in SPEC: before mDigitizerTRU.setEventTime collN = " << collisionN;
collisionN++;

Expand Down Expand Up @@ -155,10 +156,6 @@ void DigitizerSpec::run(framework::ProcessingContext& ctx)
}
}





// call actual digitization procedure
mDigitizerTRU.process(summedDigits);
}
Expand All @@ -168,11 +165,6 @@ void DigitizerSpec::run(framework::ProcessingContext& ctx)
// -> Set of BCs with triggering patches
auto emcalTriggers = mDigitizerTRU.getTriggerInputs();






// Load FIT triggers if not running in self-triggered mode
std::vector<o2::InteractionRecord> mbtriggers;
if (mRequireCTPInput) {
Expand Down Expand Up @@ -249,6 +241,10 @@ void DigitizerSpec::run(framework::ProcessingContext& ctx)

// auto& eventParts = context->getEventParts();
std::vector<std::tuple<o2::InteractionRecord, std::bitset<5>>> acceptedTriggers;
enum EMCALTriggerBits { kMB,
kEMC,
kDMC }; // EMCAL trigger bits enum for CTP inputs
TRandom3 mRandomGenerator(std::chrono::high_resolution_clock::now().time_since_epoch().count());

// loop over all composite collisions given from context
// (aka loop over all the interaction records)
Expand All @@ -269,9 +265,8 @@ void DigitizerSpec::run(framework::ProcessingContext& ctx)
// . - Old logics kept, no downscaling, pure busy
// ----------------------------------------------------
// PRNG for downscaling check
TRandom3 mRandomGenerator(std::chrono::high_resolution_clock::now().time_since_epoch().count());
auto mbtrigger = std::find(mbtriggers.begin(), mbtriggers.end(), timesview[collID]);
if( mbtrigger != mbtriggers.end() ) {
if (mbtrigger != mbtriggers.end()) {

// ============================
// retrieve downscaling from
Expand All @@ -285,26 +280,26 @@ void DigitizerSpec::run(framework::ProcessingContext& ctx)
}
if (mRandomGenerator.Uniform(0., 1) < downscaling) {
// accept as minimum bias
trigger.set(0, true);
} else {
// check for LO triggers in 12 BCs
for (auto emcalTrigger : emcalTriggers) {
auto bcTimingOfEmcalTrigger = emcalTrigger.mInterRecord.bc;
auto bcTimingOfMBTrigger = (*mbtrigger).bc;
if (abs(bcTimingOfEmcalTrigger - bcTimingOfMBTrigger) < 12) {
if (emcalTrigger.mTriggeredTRU < 32) {
trigger.set(1, true);
} else {
trigger.set(2, true);
}
}
}
}
trigger.set(EMCALTriggerBits::kMB, true);
}
// check for LO triggers in 12 BCs
for (auto emcalTrigger : emcalTriggers) {
auto bcTimingOfEmcalTrigger = emcalTrigger.mInterRecord.bc;
auto bcTimingOfMBTrigger = (*mbtrigger).bc;
if (std::abs(bcTimingOfEmcalTrigger - bcTimingOfMBTrigger) < 12) {
if (emcalTrigger.mTriggeredTRU < 32) {
trigger.set(EMCALTriggerBits::kEMC, true);
} else {
trigger.set(EMCALTriggerBits::kDMC, true);
}
}
}

} else {
// No trigger active
// Set busy
trigger.set(0, false);
}
trigger.set(EMCALTriggerBits::kMB, false);
}
}
// Bitset
// Trigger sim: Select event
Expand All @@ -314,9 +309,6 @@ void DigitizerSpec::run(framework::ProcessingContext& ctx)
// Trigger sim: Prepare CTP input digit
acceptedTriggers.push_back(std::make_tuple(timesview[collID], trigger));




mDigitizer.setEventTime(timesview[collID], trigger.any());

if (!mDigitizer.isLive()) {
Expand Down

0 comments on commit 3b0dff4

Please sign in to comment.