Project
Loading...
Searching...
No Matches
DigitsVectorStream.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include <unordered_map>
13#include <vector>
14#include <list>
15#include <deque>
16#include <iostream>
17#include <gsl/span>
18#include <fairlogger/Logger.h>
23
24using namespace o2::emcal;
25
27{
28 mSimParam = &(o2::emcal::SimParam::Instance());
29 auto randomSeed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
30 if (o2::conf::DigiParams::Instance().seed != 0) {
32 }
33 mRandomGenerator = new TRandom3(randomSeed);
34
35 mRemoveDigitsBelowThreshold = mSimParam->doRemoveDigitsBelowThreshold();
36 mSimulateNoiseDigits = mSimParam->doSimulateNoiseDigits();
37}
38
39//_______________________________________________________________________
41{
42 double amplitude = d1.getAmplitude();
43 double sigmaHG = mSimParam->getPinNoise();
44 double sigmaLG = mSimParam->getPinNoiseLG();
45
46 uint16_t noiseHG = std::floor(std::abs(mRandomGenerator->Gaus(0, sigmaHG) / constants::EMCAL_ADCENERGY)); // ADC
47 uint16_t noiseLG = std::floor(std::abs(mRandomGenerator->Gaus(0, sigmaLG) / (constants::EMCAL_ADCENERGY * constants::EMCAL_HGLGFACTOR))); // ADC
48
49 MCLabel label(true, 1.0);
50 LabeledDigit d(d1.getTower(), noiseLG, noiseHG, d1.getTimeStamp(), label);
51
52 d1 += d;
53}
54//_______________________________________________________________________
55void DigitsVectorStream::fill(std::deque<o2::emcal::DigitTimebin>& digitlist, o2::InteractionRecord record)
56{
57 std::map<unsigned int, std::list<LabeledDigit>> outputList;
58
59 for (auto& digitsTimeBin : digitlist) {
60
61 for (auto& [tower, digitsList] : *digitsTimeBin.mDigitMap) {
62
63 if (digitsList.size() == 0) {
64 continue;
65 }
66 digitsList.sort();
67
68 int digIndex = 0;
69 for (auto& ld : digitsList) {
70
71 // Loop over all digits in the time sample and sum the digits that belongs to the same tower and falls in one time bin
72 int digIndex1 = 0;
73 for (auto ld1 = digitsList.begin(); ld1 != digitsList.end(); ++ld1) {
74
75 if (digIndex == digIndex1) {
76 digIndex1++;
77 continue;
78 }
79
80 if (ld.canAdd(*ld1)) {
81 ld += *ld1;
82 digitsList.erase(ld1--);
83 }
84 digIndex1++;
85 }
86
87 if (mSimulateNoiseDigits) {
89 }
90
91 if (mRemoveDigitsBelowThreshold && (ld.getAmplitude() < (mSimParam->getDigitThreshold() * constants::EMCAL_ADCENERGY))) {
92 continue;
93 }
94 if (ld.getAmplitude() < 0) {
95 continue;
96 }
97 if ((ld.getTimeStamp() >= mSimParam->getLiveTime()) || (ld.getTimeStamp() < 0)) {
98 continue;
99 }
100
101 outputList[tower].push_back(ld);
102 digIndex++;
103 }
104 }
105 }
106
107 unsigned int numberOfNewDigits = 0;
108 for (const auto& [tower, outdiglist] : outputList) {
109 for (const auto& d : outdiglist) {
110 // outdiglist.sort();
111
112 Digit digit = d.getDigit();
113 std::vector<MCLabel> labels = d.getLabels();
114 mDigits.push_back(digit);
115 numberOfNewDigits++;
116
117 Int_t LabelIndex = mLabels.getIndexedSize();
118 for (const auto& label : labels) {
119 mLabels.addElementRandomAccess(LabelIndex, label);
120 }
121 }
122 }
123
124 mTriggerRecords.emplace_back(record, o2::trigger::PhT, mStartIndex, numberOfNewDigits);
125 mStartIndex = mDigits.size();
126
127 LOG(info) << "Trigger Orbit " << record.orbit << ", BC " << record.bc << ": have " << numberOfNewDigits << " digits (" << mStartIndex << " total)";
128}
129
130//_______________________________________________________________________
132{
133 mDigits.clear();
134 mLabels.clear();
135 mTriggerRecords.clear();
136 mStartIndex = 0;
137}
Definition of the 32 Central Trigger System (CTS) Trigger Types defined in https://twiki....
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
std::vector< o2::MCCompLabel > labels
void addElementRandomAccess(uint32_t dataindex, TruthElement const &element)
EMCAL digit implementation.
Definition Digit.h:34
void init()
Initialize the streamer.
void clear()
clear the container
void addNoiseDigits(LabeledDigit &d1)
Add noise to this digit.
void fill(std::deque< o2::emcal::DigitTimebin > &digitlist, o2::InteractionRecord record)
Fill all the containers, digits, labels, and trigger records.
EMCAL labeled digit implementation.
Monte-Carlo label for EMCAL clusters / digits.
Definition MCLabel.h:26
Bool_t doRemoveDigitsBelowThreshold() const
Definition SimParam.h:69
Bool_t doSimulateNoiseDigits() const
Definition SimParam.h:70
Float_t getLiveTime() const
Definition SimParam.h:63
Float_t getPinNoise() const
Definition SimParam.h:34
Float_t getPinNoiseLG() const
Definition SimParam.h:35
Int_t getDigitThreshold() const
Definition SimParam.h:33
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
constexpr uint32_t PhT
Definition Triggers.h:30
uint32_t orbit
LHC orbit.
uint16_t bc
bunch crossing ID of interaction
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"