Project
Loading...
Searching...
No Matches
Digit.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
13#include <iostream>
14
15using namespace o2::emcal;
16
17Digit::Digit(Short_t tower, Double_t amplitudeGeV, Double_t time)
18 : DigitBase(time), mTower(tower), mAmplitudeGeV(amplitudeGeV)
19{
20}
21
22Digit::Digit(Short_t tower, uint16_t noiseLG, uint16_t noiseHG, Double_t time)
23 : DigitBase(time), mNoiseLG(noiseLG), mNoiseHG(noiseHG), mTower(tower)
24{
25}
26
28{
29 if (canAdd(other)) {
30 mAmplitudeGeV += other.mAmplitudeGeV;
31 mNoiseHG += other.mNoiseHG;
32 mNoiseLG += other.mNoiseLG;
33 }
34 return *this;
35}
36
37void Digit::setAmplitudeADC(Short_t amplitude, ChannelType_t ctype)
38{
39
40 // truncate energy in case dynamic range is saturated
41 if (amplitude >= constants::MAX_RANGE_ADC) {
42 amplitude = constants::MAX_RANGE_ADC;
43 }
44
45 switch (ctype) {
47 mAmplitudeGeV = amplitude * constants::EMCAL_ADCENERGY;
48 break;
49 };
51 mAmplitudeGeV = amplitude * (constants::EMCAL_ADCENERGY * constants::EMCAL_HGLGFACTOR);
52 break;
53 };
54 case ChannelType_t::TRU: {
55 mAmplitudeGeV = amplitude * constants::EMCAL_TRU_ADCENERGY;
56 break;
57 };
58
59 default:
60 // can only be LEDMon which is not simulated
61 mAmplitudeGeV = 0.;
62 break;
63 };
64}
65
67{
68
69 switch (ctype) {
71 int ampADC = std::floor(mAmplitudeGeV / constants::EMCAL_ADCENERGY);
72 // truncate energy in case dynamic range is saturated
73 if (ampADC >= constants::MAX_RANGE_ADC) {
74 return constants::MAX_RANGE_ADC;
75 }
76 return ampADC + mNoiseHG;
77 };
79 int ampADC = std::floor(mAmplitudeGeV / (constants::EMCAL_ADCENERGY * constants::EMCAL_HGLGFACTOR));
80 // truncate energy in case dynamic range is saturated
81 if (ampADC >= constants::MAX_RANGE_ADC) {
82 return constants::MAX_RANGE_ADC;
83 }
84 return ampADC + mNoiseLG;
85 };
86 case ChannelType_t::TRU: {
87 int ampADC = std::floor(mAmplitudeGeV / constants::EMCAL_TRU_ADCENERGY);
88 // truncate energy in case dynamic range is saturated
89 if (ampADC >= constants::MAX_RANGE_ADC) {
90 return constants::MAX_RANGE_ADC;
91 }
92 return ampADC;
93 };
94
95 default:
96 // can only be LEDMon which is not simulated
97 return 0;
98 };
99}
100
101Double_t Digit::getAmplitude() const
102{
103 double noise = 0;
104
105 switch (getType()) {
107 noise = mNoiseHG * constants::EMCAL_ADCENERGY;
108 return mAmplitudeGeV + noise;
109 };
111 noise = mNoiseLG * (constants::EMCAL_ADCENERGY * constants::EMCAL_HGLGFACTOR);
112 return mAmplitudeGeV + noise;
113 };
114 case ChannelType_t::TRU: {
115 noise = mNoiseHG * constants::EMCAL_TRU_ADCENERGY;
116 return mAmplitudeGeV + noise;
117 };
118
119 default:
120 // can only be LEDMon which is not simulated
121 return 0;
122 };
123}
124
126{
127
128 if (mIsTRU) {
129 return ChannelType_t::TRU;
130 }
131 constexpr double ENERGYHGLGTRANISITION = (constants::EMCAL_HGLGTRANSITION * constants::EMCAL_ADCENERGY);
132
133 if (mAmplitudeGeV < ENERGYHGLGTRANISITION) {
135 }
136
138}
139
140void Digit::PrintStream(std::ostream& stream) const
141{
142 stream << "EMCAL Digit: Tower " << mTower << ", Time " << getTimeStamp() << ", Amplitude " << getAmplitude() << " GeV, Type " << channelTypeToString(getType());
143}
144
145std::ostream& operator<<(std::ostream& stream, const Digit& digi)
146{
147 digi.PrintStream(stream);
148 return stream;
149}
int16_t time
Definition RawEventData.h:4
EMCAL digit implementation.
Definition Digit.h:34
Int_t getAmplitudeADC() const
Definition Digit.h:69
bool canAdd(const Digit other)
Definition Digit.h:46
Digit & operator+=(const Digit &other)
Definition Digit.cxx:27
Double_t getAmplitude() const
Definition Digit.cxx:101
ChannelType_t getType() const
Definition Digit.cxx:125
void PrintStream(std::ostream &stream) const
Definition Digit.cxx:140
void setAmplitudeADC(Short_t amplitude, ChannelType_t ctype=ChannelType_t::HIGH_GAIN)
Definition Digit.cxx:37
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
Definition Cell.cxx:355
std::string channelTypeToString(ChannelType_t chantype)
Create string representation of the channel type object.
Definition Constants.cxx:20
ChannelType_t
Type of a raw data channel.
Definition Constants.h:33
@ TRU
TRU channel.
Definition Constants.h:36
@ HIGH_GAIN
High gain channel.
Definition Constants.h:35
@ LOW_GAIN
Low gain channel.
Definition Constants.h:34
VectorOfTObjectPtrs other