forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDigitizer.h
More file actions
133 lines (108 loc) · 6.06 KB
/
Digitizer.h
File metadata and controls
133 lines (108 loc) · 6.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef ALICEO2_EMCAL_FEEDIGITIZER_H
#define ALICEO2_EMCAL_FEEDIGITIZER_H
#include <array>
#include <memory>
#include <unordered_map>
#include <vector>
#include <list>
#include "Rtypes.h" // for Digitizer::Class, Double_t, ClassDef, etc
#include "TObject.h" // for TObject
#include "TRandom3.h"
#include "DataFormatsEMCAL/Constants.h"
#include "DataFormatsEMCAL/Digit.h"
#include "EMCALBase/Hit.h"
#include "EMCALSimulation/SimParam.h"
#include "EMCALSimulation/LabeledDigit.h"
#include "EMCALSimulation/DigitsWriteoutBuffer.h"
#include "SimulationDataFormat/MCTruthContainer.h"
#include "DataFormatsEMCAL/TriggerRecord.h"
#include "CommonUtils/TreeStreamRedirector.h"
namespace o2
{
namespace utils
{
class TreeStreamRedirector;
}
namespace emcal
{
/// \class Digitizer
/// \brief EMCAL FEE digitizer
/// \ingroup EMCALsimulation
/// \author Anders Knospe, University of Houston
/// \author Hadi Hassan, ORNL
/// @TODO adapt it to digitize TRU digits
class Digitizer : public TObject
{
public:
Digitizer() = default;
~Digitizer() override = default;
Digitizer(const Digitizer&) = delete;
Digitizer& operator=(const Digitizer&) = delete;
void init();
void clear();
/// clear DigitsVectorStream
void flush() { mDigits.flush(); }
/// This is for the readout window that was interrupted by the end of the run
void finish() { mDigits.finish(); }
/// Steer conversion of hits to digits
void process(const std::vector<LabeledDigit>& labeledDigit);
void setEventTime(o2::InteractionTimeRecord record, bool trigger);
double getTriggerTime() const { return mDigits.getTriggerTime(); }
double getEventTime() const { return mDigits.getEventTime(); }
bool isLive(double t) const { return mDigits.isLive(t); }
bool isLive() const { return mDigits.isLive(); }
bool isCurrentEventTriggered() const { return mDigits.isCurrentEventTriggered(); }
void setDebugStreaming(bool doStreaming) { mEnableDebugStreaming = doStreaming; }
// function returns true if the collision occurs 600ns before the readout window is open
bool preTriggerCollision() const { return mDigits.preTriggerCollision(); }
void fillOutputContainer(std::vector<Digit>& digits, o2::dataformats::MCTruthContainer<o2::emcal::MCLabel>& labels);
bool doSmearEnergy() const { return mSmearEnergy; }
double smearEnergy(double energy);
double smearTime(double time, double energy);
bool doSimulateTimeResponse() const { return mSimulateTimeResponse; }
void sampleSDigit(const Digit& sdigit);
/// raw pointers used here to allow interface with TF1
static double rawResponseFunction(double* x, double* par);
const std::vector<o2::emcal::Digit>& getDigits() const { return mDigits.getDigits(); }
const std::vector<o2::emcal::TriggerRecord>& getTriggerRecords() const { return mDigits.getTriggerRecords(); }
const o2::dataformats::MCTruthContainer<o2::emcal::MCLabel>& getMCLabels() const { return mDigits.getMCLabels(); }
static constexpr int getTOFSamplingBins() { return EMC_TOF_BINS; }
private:
using TimeSampleContainer = std::array<double, constants::EMCAL_MAXTIMEBINS>;
static constexpr int EMC_PHASES = 4; ///< Number of phases
static constexpr int EMC_TOF_BINS = 1500; ///< Number of bins in TOF sampling of the time response
static constexpr double EMC_TOF_MIN = 0; ///< Min TOF
static constexpr double EMC_TOF_MAX = 1500.; ///< Max TOF
static constexpr double EMC_TOF_BINWITH = (EMC_TOF_MAX - EMC_TOF_MIN) / EMC_TOF_BINS; ///< Number time samples simulated
short mEventTimeOffset = 0; ///< event time difference from trigger time (in number of bins)
short mPhase = 0; ///< event phase
UInt_t mROFrameMin = 0; ///< lowest RO frame of current digits
UInt_t mROFrameMax = 0; ///< highest RO frame of current digits
bool mSmearEnergy = true; ///< do time and energy smearing
bool mSimulateTimeResponse = true; ///< simulate time response
const SimParam* mSimParam = nullptr; ///< SimParam object
bool mIsBeforeFirstRO = false; ///< check if the signal comes before the ROF
o2::InteractionRecord mIRFirstSampledTF; ///< IR of the 1st sampled IR, noise-only ROFs will be inserted till this IR only
double mTimeBCns; ///< time difference between bc and start of ROF in ns
std::vector<Digit> mTempDigitVector; ///< temporary digit storage
o2::emcal::DigitsWriteoutBuffer mDigits; ///< used to sort digits and labels by tower
TRandom3* mRandomGenerator = nullptr; ///< random number generator
std::array<std::array<TimeSampleContainer, EMC_TOF_BINS>, EMC_PHASES>
mAmplitudeInTimeBins; ///< template of the sampled time response function: amplitude of signal for each time bin (per phase)
std::unique_ptr<o2::utils::TreeStreamRedirector> mDebugStream = nullptr;
bool mEnableDebugStreaming = false;
ClassDefOverride(Digitizer, 1);
};
} // namespace emcal
} // namespace o2
#endif /* ALICEO2_EMCAL_FEEDIGITIZER_H */