21#include <forward_list>
25#include <fairlogger/Logger.h>
43 auto randomSeed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
47 mRandomGenerator =
new TRandom3(randomSeed);
65 if (mSimulateTimeResponse) {
68 RawResponse.SetParameters(1., 0., tau, N, 0.);
74 for (
int itofbin = 0; itofbin < EMC_TOF_BINS; itofbin++) {
75 double tofbincenter = itofbin * EMC_TOF_BINWITH + 0.5 * EMC_TOF_BINWITH;
76 RawResponse.SetParameter(1, 0.25 *
phase + (tofbincenter + mSimParam->
getSignalDelay()) / constants::EMCAL_TIMESAMPLE);
77 for (
int sample = 0; sample < constants::EMCAL_MAXTIMEBINS; sample++) {
78 mAmplitudeInTimeBins[
phase][itofbin][sample] = RawResponse.Eval(sample);
87 if (mEnableDebugStreaming) {
88 mDebugStream = std::make_unique<o2::utils::TreeStreamRedirector>(
"emcaldigitsDebug.root",
"RECREATE");
99 double xx = (
x[0] - par[1] + tau) / tau;
106 signal = ped + par[0] * std::pow(xx,
n) * std::exp(
n * (1 - xx));
122 for (
auto labeleddigit : labeledSDigits) {
124 int tower = labeleddigit.getTower();
128 if (mTempDigitVector.size() == 0) {
132 std::vector<LabeledDigit> listofLabeledDigit;
134 for (
auto& digit : mTempDigitVector) {
135 Int_t
id = digit.getTower();
137 auto labels = labeleddigit.getLabels();
141 if (digit.getAmplitude() < __DBL_EPSILON__) {
142 label.setAmplitudeFraction(0);
151 listofLabeledDigit.push_back(
d);
153 mDigits.
addDigits(tower, listofLabeledDigit);
160 mTempDigitVector.clear();
168 if (energy < __DBL_EPSILON__) {
173 LOG(
debug) <<
"mIsBeforeFirstRO " << mIsBeforeFirstRO <<
" sDigit.getTimeStamp() " << sDigit.getTimeStamp() <<
" mSimParam->getSignalDelay() " << mSimParam->
getSignalDelay() <<
" mPhase " << mPhase <<
" total: " << sDigit.getTimeStamp() + mSimParam->
getSignalDelay() + mPhase * 25 <<
" EMC_TOF_MAX " << EMC_TOF_MAX <<
" mTimeBCns " << mTimeBCns;
174 if (mIsBeforeFirstRO && sDigit.getTimeStamp() + mTimeBCns < 0) {
175 LOG(
debug) <<
"disregard this hit because it comes from an event before readout starts and it does not effect this RO";
179 Double_t energies[15];
180 if (mSimulateTimeResponse) {
181 if (sDigit.getTimeStamp() + mSimParam->
getSignalDelay() + mPhase * 25 > EMC_TOF_MAX) {
186 int tofbin =
static_cast<int>(sDigit.getTimeStamp() / EMC_TOF_BINWITH);
187 if (tofbin >= EMC_TOF_BINS) {
188 tofbin = EMC_TOF_BINS - 1;
190 for (
int sample = 0; sample < mAmplitudeInTimeBins[mPhase][tofbin].size(); sample++) {
192 double val = energy * (mAmplitudeInTimeBins[mPhase][tofbin][sample]);
193 energies[sample] =
val;
194 double digitTime = mEventTimeOffset * constants::EMCAL_TIMESAMPLE;
196 mTempDigitVector.push_back(digit);
199 if (sDigit.getTimeStamp() > EMC_TOF_MAX) {
204 Digit digit(tower, energy,
smearTime(sDigit.getTimeStamp(), energy));
205 mTempDigitVector.push_back(digit);
208 if (mEnableDebugStreaming) {
209 double timeStamp = sDigit.getTimeStamp();
210 (*mDebugStream).GetFile()->cd();
211 (*mDebugStream) <<
"DigitsTimeSamples"
213 <<
"Time=" << timeStamp
214 <<
"DigitEnergy=" << energy
215 <<
"Sample0=" << energies[0]
216 <<
"Sample1=" << energies[1]
217 <<
"Sample2=" << energies[2]
218 <<
"Sample3=" << energies[3]
219 <<
"Sample4=" << energies[4]
220 <<
"Sample5=" << energies[5]
221 <<
"Sample6=" << energies[6]
222 <<
"Sample7=" << energies[7]
223 <<
"Sample8=" << energies[8]
224 <<
"Sample9=" << energies[9]
225 <<
"Sample10=" << energies[10]
226 <<
"Sample11=" << energies[11]
227 <<
"Sample12=" << energies[12]
228 <<
"Sample13=" << energies[13]
229 <<
"Sample14=" << energies[14]
238 energy *= mRandomGenerator->Poisson(fluct) / fluct;
255 mEventTimeOffset = 0;
265 mTimeBCns += nbc * o2::constants::lhc::LHCBunchSpacingNS;
269 mIsBeforeFirstRO =
true;
271 mIsBeforeFirstRO =
false;
ClassImp(o2::emcal::Digitizer)
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
static const SimParam & Instance()
EMCAL digit implementation.
Double_t getAmplitude() const
static double rawResponseFunction(double *x, double *par)
raw pointers used here to allow interface with TF1
void setEventTime(o2::InteractionTimeRecord record, bool trigger)
void process(const std::vector< LabeledDigit > &labeledDigit)
Steer conversion of hits to digits.
double smearTime(double time, double energy)
void sampleSDigit(const Digit &sdigit)
double smearEnergy(double energy)
unsigned int getPhase() const
void clear()
clear the container
void reserve()
Reserve space for the future container.
void forwardMarker(o2::InteractionTimeRecord record, bool trigger)
forward the marker for every 100 ns
void addDigits(unsigned int towerID, std::vector< LabeledDigit > &digList)
EMCAL simulation hit information.
EMCAL labeled digit implementation.
Float_t getSignalDelay() const
Float_t getTimeResponseTau() const
Bool_t doSimulateL1Phase() const
Double_t getTimeResolution(Double_t energy) const
Float_t getGainFluctuations() const
Bool_t doSmearEnergy() const
Float_t getTimeResponsePower() const
Bool_t doSimulateTimeResponse() const
Int_t getMeanPhotonElectron() const
GLuint GLsizei const GLchar * label
int64_t differenceInBC(const InteractionRecord &other) const
double getTimeOffsetWrtBC() const
IR getFirstSampledTFIR() const
get TF and HB (abs) for this IR
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"