67 {
69
70 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{
m_cablingKey};
71 const LArOnOffIdMapping*
cabling{*cablingHdl};
72 if(!cabling) {
74 return StatusCode::FAILURE;
75 }
76
77
78 const LArDigitContainer* digitContainer;
79
80
82 ATH_MSG_DEBUG (
"1) LArDigitContainer container size = " << digitContainer->
size() );
83
84 ATH_MSG_DEBUG (
"2) LArDigitContainer container size = " << digitContainer->
size() );
85 if( digitContainer->
size() < 1 ) {
87 return StatusCode::SUCCESS;
88 }
89
90
93 larRawChannelContainer->reserve(digitContainer->
size());
95
96
98
99 for (const LArDigit* digit : *digitContainer) {
100
101
102 const std::vector<short>& samples =
digit->samples();
103 unsigned int nSamples = samples.size();
104 const HWIdentifier chid =
digit->channelID();
106
107
108 std::vector<float> mySamples;
109 mySamples.resize(samples.size());
110
112
113
114 for (
unsigned int i=0;
i<samples.size();
i++ )
115 {
116 mySamples[
i] = ((
float)samples[
i]) - thePedestal;
117 }
118
119
120 float GainFactor;
122 GainFactor = 9.8*9.8;
124 GainFactor = 9.8;
126 GainFactor = 1.0;
127 } else {
128 GainFactor = 1.0;
129 ATH_MSG_ERROR (
"Channel " << chid <<
"unknown gain: " << gain );
130 }
131
132
133 float maxADCPeak = 0.;
134 unsigned int iPeakSamp = 0;
136 if ( maxADCPeak < mySamples[i] )
137 {
138 maxADCPeak = mySamples[
i];
140 }
141 }
142
143 bool CubicFailed = false;
144 float ADCPeak=0.;
146
147
149 {
150 ADCPeak = maxADCPeak;
151 time = ((
float)iPeakSamp+0.5) * 25.0 * nanosecond;
152 }
153
154
155 else if (
m_mode ==
"CUBIC" &&
157 {
158
159 unsigned int it0;
160 const float invT[4][4]
161 = { { 1, 0, 0, 0},
162 { -1.83333, 3, -1.5, 0.333333},
163 { 1, -2.5, 2, -0.5},
164 {-0.166666, 0.5, -0.5, 0.166666} };
165
166
167 if ( iPeakSamp <= 1 )
168 {
170 }
171
172 else if ( iPeakSamp >= nSamples - 2 )
173 {
175 }
176
177 else
178 {
179 it0 = ( mySamples[iPeakSamp-2] > mySamples[iPeakSamp+2] )
180 ? iPeakSamp - 2
181 : iPeakSamp - 1;
182 }
183
184
185 float A[4] = {0, 0, 0, 0};
186 float dtmax = 0.0;
187 float disc;
188
189 for (int ia = 0; ia < 4; ia++)
190 for (
int it = 0;
it < 4;
it++)
191 A[ia] += invT[ia][it] * mySamples[it0+it];
192
193
194 disc =
A[2]*
A[2] - 3*
A[1]*
A[3];
195 if ( ! ( CubicFailed = ( disc < 0 || A[3] == 0 ) ) )
196 {
197 dtmax = (-
A[2]-sqrt(disc))/(3*A[3]);
198 if ( ! ( CubicFailed = ( dtmax < 0 || dtmax > 3 ) ) )
199 {
200 time = (
float(it0) + dtmax) * 25.0 * nanosecond;
201 for(int ia = 0; ia < 4; ia++)
202 ADCPeak += A[ia] *
pow(dtmax, ia);
203 }
204 }
205 }
207 ( "Flag: "
208 << CubicFailed
209 << " Mode: "
211 << " Signal: "
212 << ADCPeak
213 << " Peak: "
214 << maxADCPeak
215 );
216
217
218 if(
m_mode ==
"FIXED" || CubicFailed )
219 {
222 }
223
224
225
226 float ADCtoMeV = 10.0;
227 const Identifier
id =
cabling->cnvToIdentifier(chid);
228 if (
m_emId->is_em_barrel(
id)) {
229
232 }
else if (
m_emId->is_em_endcap_inner(
id)) {
233 int samp =
m_emId->sampling(
id);
234 if (samp > 0) {
236 ATH_MSG_DEBUG (
" in EMEC inner s="<<
m_emId->sampling(
id)<<
", using ADCtoMeV = " << ADCtoMeV );
237 }
238 }
else if (
m_emId->is_em_endcap_outer(
id)) {
239 int samp =
m_emId->sampling(
id);
240 if (samp > 0) {
242 ATH_MSG_DEBUG (
" in EMEC outer s="<<
m_emId->sampling(
id)<<
", using ADCtoMeV = " << ADCtoMeV );
243 }
244 }
else if (
m_fcalId->is_lar_fcal(
id)) {
246 if (module > 0) {
249 }
250 }
else if (
m_hecId->is_lar_hec(
id)) {
251
254 }
255
256 float Energy = ADCPeak * ADCtoMeV * GainFactor;
259
260
261 LArRawChannel larRawChannel(chid,(
int)
Energy,(
int)time,quality, provenance, gain);
262 larRawChannelContainer->
add(larRawChannel);
263
264 }
265
267
268
269
270 ATH_MSG_DEBUG (
"sorted RawChannelContainer, now lock it " );
271
273
274 return StatusCode::SUCCESS;
275}
#define ATH_CHECK
Evaluate an expression and check for errors.
std::vector< double > Energy
Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Old LArRawChannelContainer
constexpr int pow(int base, int exp) noexcept
ServiceHandle< StoreGateSvc > & evtStore()
size_type size() const noexcept
Returns the number of elements in the collection.
void add(const LArRawChannel &rc)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
time(flags, cells_name, *args, **kw)
retrieve(aClass, aKey=None)