12#include <unordered_map>
24#include <fairlogger/Logger.h>
35 auto& CurrentPatchTimeSum = p.mTimesum[patchID];
36 auto& TimeSums = std::get<1>(CurrentPatchTimeSum);
37 bool trendOfDigitsInTower =
false;
38 if (TimeSums.size() < 4) {
41 }
else if (TimeSums[3] < TimeSums[2] && TimeSums[2] < TimeSums[1] && TimeSums[1] >= TimeSums[0]) {
42 trendOfDigitsInTower =
true;
43 }
else if (TimeSums[0] > 0. || TimeSums[1] > 0. || TimeSums[2] > 0. || TimeSums[3] > 0.) {
45 double integralOfADCvalues = 0;
46 for (
auto it = TimeSums.begin(); it != TimeSums.end(); it++) {
47 integralOfADCvalues += *it;
49 bool peakOverThreshold =
false;
50 if (integralOfADCvalues > mThreshold && trendOfDigitsInTower) {
51 peakOverThreshold =
true;
53 return peakOverThreshold;
60 bool isFoundGlobal =
false;
61 p.mFiredPatches.clear();
62 for (
auto& patches : p.mIndexMapPatch) {
63 auto PatchID = std::get<0>(patches);
66 p.mFiredPatches.push_back(PatchID);
76 mSimulateNoiseDigits = mSimParam->doSimulateNoiseDigits();
93 double amplitude = d1.getAmplitude();
94 double sigma = mSimParam->getPinNoiseTRU();
96 TRandom3 mRandomGenerator(std::chrono::high_resolution_clock::now().time_since_epoch().
count());
97 uint16_t noise = std::floor(std::abs(mRandomGenerator.Gaus(0, sigma) / constants::EMCAL_TRU_ADCENERGY));
99 Digit d(d1.getTower(), 0., noise, d1.getTimeStamp());
106 int counterDigitTimeBin = 0;
107 int sizemDigitMap = -999;
110 for (
auto& digitsTimeBin : digitlist) {
116 counterDigitTimeBin++;
118 for (
auto& [fastor, digitsList] : *digitsTimeBin.mDigitMap) {
121 if (digitsList.size() == 0) {
129 for (
auto& ld : digitsList) {
140 Digit digitToSum(summedDigit.
getTower(), ld.getAmplitude(), summedDigit.getTimeStamp());
141 summedDigit += digitToSum;
145 sizemDigitMap = (*digitsTimeBin.mDigitMap).
size();
146 if (mSimulateNoiseDigits) {
153 auto& patchTRU = patchesFromAllTRUs[whichTRU];
154 auto& fastOrPatchTRU = patchTRU.mFastOrs[whichFastOr];
156 if (std::find(mMaskedFastOrs.begin(), mMaskedFastOrs.end(), fastor) != mMaskedFastOrs.end()) {
175 bool foundPeak =
false;
176 int counterWhichTRU = 0;
177 int triggeredTRU = -1;
178 std::vector<int> triggeredPatches;
179 for (
auto& patches : patchesFromAllTRUs) {
183 if (foundPeakCurrentTRU ==
true && foundPeak ==
false) {
184 triggeredTRU = counterWhichTRU;
185 triggeredPatches = firedPatches;
187 if (foundPeakCurrentTRU) {
190 counterWhichTRU += 1;
193 if (foundPeak ==
true) {
194 LOG(
debug) <<
"DIG TRU fill in LZEROElectronics: foundPeak = " << foundPeak;
202 for (
auto& patches : patchesFromAllTRUs) {
204 for (
auto& fastor : patches.mFastOrs) {
237 mTriggers.push_back(TriggerInputsForL1);
245 LOG(info) <<
"===============================";
246 LOG(info) <<
"== PRINT MASK SAVED IN LZERO ==";
248 for (
auto fastOr : mMaskedFastOrs) {
249 LOG(info) <<
"fastOr masked (number, ID) = (" <<
counter <<
", " << fastOr;
EMCAL DigitTimebin for the DigitsWriteoutBuffer and DigitsWriteoutBufferTRU.
unsigned short int uint16_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
static const SimParam & Instance()
EMCAL digit implementation.
Int_t getAmplitudeADC(ChannelType_t ctype) const
void fill(const std::deque< o2::emcal::DigitTimebinTRU > &digitlist, const o2::InteractionRecord record, std::vector< TRUElectronics > &patchesFromAllTRUs)
bool peakFinderOnPatch(TRUElectronics &p, unsigned int patchID)
const std::vector< int > & getFiredPatches(TRUElectronics const &p) const
void addNoiseDigits(Digit &d1)
Add noise to this digit.
bool peakFinderOnAllPatches(TRUElectronics &p)
void printMaskedFastOrs()
void init()
Initialize the L0 electronics.
void updatePatchesADC(TRUElectronics &p)
void clear()
clear the L0 electronics
void setThreshold(double threshold)
Trigger mapping starting from Run2.
IndexTRU convertTRUIndexTRUtoSTU(IndexTRU truIndexTRU) const
std::tuple< IndexTRU, IndexFastOR > convertFastORIndexTRUtoSTU(IndexTRU truIndexTRU, IndexFastOR fastorIndexTRU) const
Convert TRU and FastOR index in TRU from TRU number scheme to STU number scheme.
std::tuple< IndexTRU, IndexFastOR > convertFastORIndexSTUtoTRU(IndexTRU truIndexSTU, IndexFastOR fastOrIndexSTU, DetType_t detector) const
Convert TRU and FastOR index in TRU from STU number scheme to TRU number scheme.
std::tuple< IndexTRU, IndexFastOR > getTRUFromAbsFastORIndex(IndexFastOR fastOrAbsID) const
Get the TRU index and FastOR index in TRU from the absolute FastOR ID.
TRUElectronics creator, based on the TRUElectronics.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"