128 {
129
131
132
133
134
136
137
138 bool tileThresh =
m_tileInfo->TileZeroSuppress();
139
140 double Rndm[16];
141
142 float ttL1Calib, ttL1NoiseSigma, ttL1Ped, ttL1Thresh;
143
146 << ", tileNoise=" << ((tileNoise) ? "true" : "false")
147 << ", tileThresh=" << ((tileThresh) ? "true" : "false") );
148
149
150
151
152
155
157
158
160 ATH_CHECK( ttl1Container.record(std::make_unique<TileTTL1Container>()) );
162
163
164
165
166 Identifier ttId[16];
167 float ttAmp[16];
168 bool ttRawChannel[16];
169 int nTT;
170 int nRawChannel;
171 int nIgnore;
172 int nTTTot = 0;
173 int nRawChannelTot = 0;
174 int nIgnoreTot = 0;
175 float ttAmpTot = 0;
176 float ttAmpTotIg = 0.;
177 int minieta, maxieta, posneg;
178
179
180 std::vector<float> ttL1samples(
m_nSamp);
181
182
183
184 for (const TileRawChannelCollection* rawChannelCollection : *rawChannelContainer) {
185
186 HWIdentifier drawer_id =
m_tileHWID->drawer_id(rawChannelCollection->identify());
190
191 switch (ros) {
193 posneg = +1;
194 minieta = 0;
195 maxieta = 8;
196 break;
198 posneg = -1;
199 minieta = 0;
200 maxieta = 8;
201 break;
203 posneg = +1;
204 minieta = 9;
205 maxieta = 14;
206 break;
208 posneg = -1;
209 minieta = 9;
210 maxieta = 14;
211 break;
212 default:
213 posneg = minieta = maxieta = 0;
214 }
215
216
217 memset(ttAmp, 0, sizeof(ttAmp));
218 memset(ttRawChannel, 0, sizeof(ttRawChannel));
219 nTT = nIgnore = nRawChannel = 0;
220
221
222
223 for (const TileRawChannel* rawChannel : *rawChannelCollection) {
224
225
226 HWIdentifier hwid = rawChannel->adc_HWID();
229
230
232 rawChannel->amplitude(),
233 rChUnit,
235
236
239
240 int ieta = 999;
241 int iphi = 999;
242
243 Identifier pmt_id = rawChannel->pmt_ID();
246
247
248 Identifier tt_id = rawChannel->tt_ID();
249
252 if (iphi != drawer)
254 << ", iphi=" << iphi
255 <<
"id=" <<
m_tileID->to_string(pmt_id) );
256
257 if (ttRawChannel[ieta]) {
259 } else {
260 ttId[ieta] = tt_id;
261 ttRawChannel[ieta] = true;
263 if (ieta >= minieta && ieta <= maxieta)
264 ++nTT;
265 }
266 ++nRawChannel;
267 if (ieta < minieta || ieta > maxieta)
268 ++nIgnore;
269
270 if (ieta >= minieta && ieta <= maxieta) {
272 } else {
274 }
275
276 if (
msgLvl(MSG::VERBOSE)) {
277
279 int tower =
m_tileID->tower(pmt_id);
283 msg(MSG::VERBOSE) <<
"New RawChannel:"
288 << ", tower=" << tower
292 << ", ie=" << ieta
293 << ", ip=" << iphi;
294
295 if (ieta >= minieta && ieta <= maxieta)
297 else
298 msg(MSG::VERBOSE) <<
" Outside limits" <<
endmsg;
299 }
300
301 } else {
303 }
304
305 }
306
307 nTTTot += nTT;
308 nRawChannelTot += nRawChannel;
309 nIgnoreTot += nIgnore;
310
312 << " ROS=" << ros
313 << ", drawer=" << drawer
314 << "; posneg=" << posneg
315 << ", minieta=" << minieta
316 << ", maxieta=" << maxieta
317 << "; nTT=" << nTT
318 << ", nRawChannel=" << nRawChannel
319 << ", nIgnore=" << nIgnore );
320
321
322
323
324
325 for (int ieta = minieta; ieta <= maxieta; ++ieta) {
327 bool Good = ttRawChannel[ieta];
328 if (tileNoise)
329 Good = true;
330 if (Good) {
331 if (!ttRawChannel[ieta])
332 ttId[ieta] =
m_TT_ID->tower_id(posneg, 1, 0, ieta, drawer);
333
334 ttL1NoiseSigma =
m_tileInfo->TTL1NoiseSigma(ttId[ieta]);
335 ttL1Thresh =
m_tileInfo->TTL1Thresh(ttId[ieta]);
337 ttL1Calib =
m_tileInfo->TTL1Calib(ttId[ieta]);
338 ttAmp[ieta] *= ttL1Calib;
340
341
342
344
346 }
347 if (tileNoise)
348 CLHEP::RandGauss::shootArray(
m_nSamp, Rndm);
349 for (
int jsamp = 0; jsamp <
m_nSamp; ++jsamp) {
350 ttL1samples[jsamp] = ttAmp[ieta] *
m_TTL1Shape[jsamp] + ttL1Ped;
351 if (tileNoise)
352 ttL1samples[jsamp] += ttL1NoiseSigma * Rndm[jsamp];
353 }
354 if (tileThresh) {
355 if (ttL1samples[
m_iTrig] - ttL1Ped < ttL1Thresh)
356 Good = false;
357 }
358 }
359
360 if (Good) {
362 << " ros=" << ros
363 << ", ieta=" << ieta
364 << ", iphi=" << iphi
365 << ", rawChannelTrue=" << ttRawChannel[ieta]
366 << ", Good=" << Good
367 << ", amp0=" << ttAmp[ieta]
368 <<
", digitIn=" << ttL1samples[
m_iTrig] );
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389 ttl1Container->push_back(std::make_unique<TileTTL1>(ttId[ieta], ttL1samples));
390 }
391 }
392 }
393
394
395 ATH_MSG_DEBUG(
"TileRawChannelToTTL1 execution completed." );
397 << " nRawChannelTot=" << nRawChannelTot
398 << " nIgnoreTot=" << nIgnoreTot
399 << " ttAmpTot=" << ttAmpTot
400 << " ttAmpTotIg=" << ttAmpTotIg
401 << " =>eneTot=" << ttAmpTot + ttAmpTotIg );
402
403 return StatusCode::SUCCESS;
404}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
bool msgLvl(const MSG::Level lvl) const
bool is_valid() const
Check if id is in a valid state.
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
std::vector< double > m_TTL1Shape
SG::WriteHandleKey< TileTTL1Container > m_ttl1ContainerKey
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey