-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathDigit.cxx
More file actions
149 lines (128 loc) · 4.13 KB
/
Digit.cxx
File metadata and controls
149 lines (128 loc) · 4.13 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// 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.
#include "DataFormatsEMCAL/Digit.h"
#include <iostream>
using namespace o2::emcal;
Digit::Digit(Short_t tower, Double_t amplitudeGeV, Double_t time)
: DigitBase(time), mTower(tower), mAmplitudeGeV(amplitudeGeV)
{
}
Digit::Digit(Short_t tower, uint16_t noiseLG, uint16_t noiseHG, Double_t time)
: DigitBase(time), mNoiseLG(noiseLG), mNoiseHG(noiseHG), mTower(tower)
{
}
Digit& Digit::operator+=(const Digit& other)
{
if (canAdd(other)) {
mAmplitudeGeV += other.mAmplitudeGeV;
mNoiseHG += other.mNoiseHG;
mNoiseLG += other.mNoiseLG;
}
return *this;
}
void Digit::setAmplitudeADC(Short_t amplitude, ChannelType_t ctype)
{
// truncate energy in case dynamic range is saturated
if (amplitude >= constants::MAX_RANGE_ADC) {
amplitude = constants::MAX_RANGE_ADC;
}
switch (ctype) {
case ChannelType_t::HIGH_GAIN: {
mAmplitudeGeV = amplitude * constants::EMCAL_ADCENERGY;
break;
};
case ChannelType_t::LOW_GAIN: {
mAmplitudeGeV = amplitude * (constants::EMCAL_ADCENERGY * constants::EMCAL_HGLGFACTOR);
break;
};
case ChannelType_t::TRU: {
mAmplitudeGeV = amplitude * constants::EMCAL_TRU_ADCENERGY;
break;
};
default:
// can only be LEDMon which is not simulated
mAmplitudeGeV = 0.;
break;
};
}
Int_t Digit::getAmplitudeADC(ChannelType_t ctype) const
{
switch (ctype) {
case ChannelType_t::HIGH_GAIN: {
int ampADC = std::floor(mAmplitudeGeV / constants::EMCAL_ADCENERGY);
// truncate energy in case dynamic range is saturated
if (ampADC >= constants::MAX_RANGE_ADC) {
return constants::MAX_RANGE_ADC;
}
return ampADC + mNoiseHG;
};
case ChannelType_t::LOW_GAIN: {
int ampADC = std::floor(mAmplitudeGeV / (constants::EMCAL_ADCENERGY * constants::EMCAL_HGLGFACTOR));
// truncate energy in case dynamic range is saturated
if (ampADC >= constants::MAX_RANGE_ADC) {
return constants::MAX_RANGE_ADC;
}
return ampADC + mNoiseLG;
};
case ChannelType_t::TRU: {
int ampADC = std::floor(mAmplitudeGeV / constants::EMCAL_TRU_ADCENERGY);
// truncate energy in case dynamic range is saturated
if (ampADC >= constants::MAX_RANGE_ADC) {
return constants::MAX_RANGE_ADC;
}
return ampADC;
};
default:
// can only be LEDMon which is not simulated
return 0;
};
}
Double_t Digit::getAmplitude() const
{
double noise = 0;
switch (getType()) {
case ChannelType_t::HIGH_GAIN: {
noise = mNoiseHG * constants::EMCAL_ADCENERGY;
return mAmplitudeGeV + noise;
};
case ChannelType_t::LOW_GAIN: {
noise = mNoiseLG * (constants::EMCAL_ADCENERGY * constants::EMCAL_HGLGFACTOR);
return mAmplitudeGeV + noise;
};
case ChannelType_t::TRU: {
noise = mNoiseHG * constants::EMCAL_TRU_ADCENERGY;
return mAmplitudeGeV + noise;
};
default:
// can only be LEDMon which is not simulated
return 0;
};
}
ChannelType_t Digit::getType() const
{
if (mIsTRU) {
return ChannelType_t::TRU;
}
constexpr double ENERGYHGLGTRANISITION = (constants::EMCAL_HGLGTRANSITION * constants::EMCAL_ADCENERGY);
if (mAmplitudeGeV < ENERGYHGLGTRANISITION) {
return ChannelType_t::HIGH_GAIN;
}
return ChannelType_t::LOW_GAIN;
}
void Digit::PrintStream(std::ostream& stream) const
{
stream << "EMCAL Digit: Tower " << mTower << ", Time " << getTimeStamp() << ", Amplitude " << getAmplitude() << " GeV, Type " << channelTypeToString(getType());
}
std::ostream& operator<<(std::ostream& stream, const Digit& digi)
{
digi.PrintStream(stream);
return stream;
}