118 {
119
121 char rndStr[30];
123
127 DataVect energyVec; energyVec.reserve(cellContainer->
size());
128 DataVect adcCounts1Vec; adcCounts1Vec.reserve(cellContainer->
size() * 10);
129 DataVect adcCounts2Vec; adcCounts2Vec.reserve(cellContainer->
size() * 10);
130 DataVect BadCell; BadCell.reserve(cellContainer->
size());
131
132 DataVect pmt1Energy; pmt1Energy.reserve(cellContainer->
size());
133 DataVect pmt1Time; pmt1Time.reserve(cellContainer->
size());
134 DataVect pmt1Chi2; pmt1Chi2.reserve(cellContainer->
size());
135 DataVect pmt1Gain; pmt1Gain.reserve(cellContainer->
size());
136 DataVect pmt2Energy; pmt2Energy.reserve(cellContainer->
size());
137 DataVect pmt2Time; pmt2Time.reserve(cellContainer->
size());
138 DataVect pmt2Chi2; pmt2Chi2.reserve(cellContainer->
size());
139 DataVect pmt2Gain; pmt2Gain.reserve(cellContainer->
size());
140
141 DataVect pmt1RawAmplitude; pmt1RawAmplitude.reserve(cellContainer->
size());
142 DataVect pmt1RawTime; pmt1RawTime.reserve(cellContainer->
size());
143 DataVect pmt1Pedestal; pmt1Pedestal.reserve(cellContainer->
size());
144 DataVect pmt1Number; pmt1Number.reserve(cellContainer->
size());
145 DataVect pmt1ADCStatus; pmt1ADCStatus.reserve(cellContainer->
size());
146 DataVect pmt2RawAmplitude; pmt2RawAmplitude.reserve(cellContainer->
size());
147 DataVect pmt2RawTime; pmt2RawTime.reserve(cellContainer->
size());
148 DataVect pmt2Pedestal; pmt2Pedestal.reserve(cellContainer->
size());
149 DataVect pmt2Number; pmt2Number.reserve(cellContainer->
size());
150 DataVect pmt2ADCStatus; pmt2ADCStatus.reserve(cellContainer->
size());
151
152
154
155 std::string adcCounts1Str = "adcCounts1 multiple=\"0\"";
156 std::string adcCounts2Str = "adcCounts2 multiple=\"0\"";
157
158 const TileID* tileID = nullptr;
160 const TileInfo* tileInfo = nullptr;
161 const TileCablingService*
cabling=
nullptr;
164 double energyGeV;
165 double amplitude = 0.;
166 const int vsize = cellContainer->
size();
167 int Index,pmtInd, cellInd, nTileSamples=0;
168 std::vector<double> pmt1ped(vsize,0.0);
169 std::vector<double> pmt2ped(vsize,0.0);
170 std::vector<double> pmt1rawamp(vsize,0.0);
171 std::vector<double> pmt2rawamp(vsize,0.0);
172 std::vector<double> pmt1rawtime(vsize,0.0);
173 std::vector<double> pmt2rawtime(vsize,0.0);
174 std::vector<int> pmt1number(vsize,0);
175 std::vector<int> pmt2number(vsize,0);
176 std::vector<unsigned long int> pmt1status(vsize,0);
177 std::vector<unsigned long int> pmt2status(vsize,0);
178 std::map<int,std::vector<float> > pmt1digit;
179 std::map<int,std::vector<float> > pmt2digit;
180 bool offlineRch = false;
181
182
183
185 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileID" );
186
187 }
188
190 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileHWID" );
191 }
192
194 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileInfo" );
195 }
196
197 SG::ReadHandle<TileDigitsContainer> tileDigits;
202 }
203 }
204
205 SG::ReadHandle<TileRawChannelContainer> RawChannelCnt;
210 }
211 else {
212 RChUnit = RawChannelCnt->get_unit();
215 }
216 }
217
218
219
220
222 if (offlineRch) {
223
224 for (const auto rawChannel : *RawChannelCnt) {
225
226 for (const auto cell : *rawChannel) {
227
229 if (
Index <= -1 )
continue;
231 cellInd = cellContainer->
findIndex(cell_hash);
232 if (cellInd < 0) continue;
233
234 HWIdentifier hwid=
cell->adc_HWID();
235 int adc = tileHWID->
adc(hwid);
238 int ros = tileHWID->
ros(hwid);
239 int PMT = abs(
cabling->channel2hole(ros,channel) );
242
243 amplitude =
cell->amplitude();
244
248
249
250 std::abort();
251 }
252
253 if ( pmtInd == 0 ) {
254
255 pmt1ped[cellInd] =
cell->pedestal();
256 pmt1rawamp[cellInd] = amplitude;
257 pmt1rawtime[cellInd] =
cell->uncorrTime();
258 pmt1number[cellInd] = PMT;
259 pmt1status[cellInd] = tileAdcStatus;
260 }
261 else {
262
263 pmt2ped[cellInd] =
cell->pedestal();
264 pmt2rawamp[cellInd] = amplitude;
265 pmt2rawtime[cellInd] =
cell->uncorrTime();
266 pmt2number[cellInd] = PMT;
267 pmt2status[cellInd] = tileAdcStatus;
268
269 }
270 }
271 }
272 }
273 }
274
275
276
277
279
280
281
282
283 for (const auto digitChannel : *tileDigits) {
284
285 for (const auto cell : *digitChannel) {
286
288 if (
Index <= -1 )
continue;
290 cellInd = cellContainer->
findIndex(cell_hash);
291 if (cellInd < 0) continue;
293
294 nTileSamples =
cell->NtimeSamples();
295 std::vector<float> tileSamples =
cell->samples();
296
297 if (pmtInd == 0 ) {
298 pmt1digit.insert(std::make_pair( cellInd, tileSamples ) );
299 }
300 else {
301 pmt2digit.insert(std::make_pair( cellInd, tileSamples ) );
302 }
303
304 }
305 }
306 }
307
308
309
310
313
314 double energyAllTile = 0.;
315
316 for (;it1!=it2;++it1) {
317
318 if ((*it1)->badcell()) BadCell.push_back(1);
320 else BadCell.push_back(-1);
321
322 Identifier cellid = (*it1)->ID();
323 IdentifierHash cell_hash =
m_calocell_id->calo_cell_hash( cellid );
324 cellInd = cellContainer->
findIndex(cell_hash);
325 if (cellInd < 0) continue;
327
328 energyGeV = (*it1)->energy()*(1./
GeV);
330 energyAllTile += energyGeV;
331
332 idVec.push_back(
DataType( (Identifier::value_type)(*it1)->ID().get_compact() ));
335
337
338 if ( !pmt1digit[cellInd].
empty()) {
339 for (
int i=0;
i<nTileSamples;
i++) {
340 adcCounts1Str=
"adcCounts1 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
341 adcCounts1Vec.push_back(
DataType(
int(pmt1digit[cellInd][i])));
342 }
343 }
344 else {
345 for (
int i=0;
i<nTileSamples;
i++) {
346 adcCounts1Str=
"adcCounts1 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
347 adcCounts1Vec.push_back(
DataType(0));
348 }
349 }
350
351
352 if ( !pmt2digit[cellInd].
empty()) {
353 for (
int i=0;
i<nTileSamples;
i++) {
354 adcCounts2Str=
"adcCounts2 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
355 adcCounts2Vec.push_back(
DataType(
int(pmt2digit[cellInd][i])));
356 }
357 }
358 else {
359 for (
int i=0;
i<nTileSamples;
i++) {
360 adcCounts2Str=
"adcCounts2 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
361 adcCounts2Vec.push_back(
DataType(0));
362 }
363 }
364 }
365
367
368 const TileCell* theTileCell = dynamic_cast<const TileCell *>(*it1);
369 if (not theTileCell) {
370
371 throw std::runtime_error("Could not cast pointer to TileCell in CaloTileRetriever::getCaloTileData");
372 }
373 int gain1 = theTileCell->gain1();
374 int qual1 = theTileCell->qual1();
375 bool badch1 = theTileCell->badch1();
376 bool noch1 = (gain1<0 || gain1>1);
377
378 int qual2 = theTileCell->qual2();
379 int gain2 = theTileCell->gain2();
380 bool badch2 = theTileCell->badch2();
381 bool noch2 = (gain2<0 || gain2>1);
382
383 if (badch1 != badch2 && qual1 != qual2 && qual1 < 255 && qual2 < 255) {
386 }
387 if (badch1) qual1 = -qual1;
388 if (badch2) qual2 = -qual2;
389
390 pmt1Energy.push_back(
DataType(theTileCell->ene1()*(1./
GeV)));
391 pmt1Time.push_back(
DataType(theTileCell->time1()));
392 pmt1Chi2.push_back(
DataType(qual1));
393 pmt1Gain.push_back(
DataType(gain1));
394
395 pmt2Energy.push_back(
DataType(theTileCell->ene2()*(1./
GeV)));
396 pmt2Time.push_back(
DataType(theTileCell->time2()));
397 pmt2Chi2.push_back(
DataType(qual2));
398 pmt2Gain.push_back(
DataType(gain2));
399
400 if (offlineRch && RawChannelCnt.isValid()
401 && (noch1 || pmt1number[cellInd]!=0) && (noch2 || pmt2number[cellInd]!=0)) {
402
403 uint32_t tileAdcStatus = pmt1status[cellInd];
404 if (badch1) tileAdcStatus += 10;
405
406 pmt1RawAmplitude.push_back(
DataType(pmt1rawamp[cellInd]));
407 pmt1RawTime.push_back(
DataType(pmt1rawtime[cellInd]));
408 pmt1Pedestal.push_back(
DataType(pmt1ped[cellInd]));
409 pmt1Number.push_back(
DataType(pmt1number[cellInd]));
410 pmt1ADCStatus.push_back(
DataType(tileAdcStatus));
411
412 tileAdcStatus = pmt2status[cellInd];
413 if (badch2) tileAdcStatus += 10;
414
415 pmt2RawAmplitude.push_back(
DataType(pmt2rawamp[cellInd]));
416 pmt2RawTime.push_back(
DataType(pmt2rawtime[cellInd]));
417 pmt2Pedestal.push_back(
DataType(pmt2ped[cellInd]));
418 pmt2Number.push_back(
DataType(pmt2number[cellInd]));
419 pmt2ADCStatus.push_back(
DataType(tileAdcStatus));
420 }
421 else {
422
424
425 if (noch1 ) {
426 pmt1RawAmplitude.push_back(
DataType(0));
428 pmt1ADCStatus.push_back(
DataType(0));
430 pmt1Pedestal.push_back(
DataType(0));
431 } else {
432 HWIdentifier hwid =
cabling->s2h_adc_id(tileID->
adc_id(cellid,0,gain1));
433
434 int adc = tileHWID->
adc(hwid);
437 int ros = tileHWID->
ros(hwid);
438 int PMT = abs(
cabling->channel2hole(ros,channel) );
442 float amp = theTileCell->ene1() /
scale;
443 float time = theTileCell->time1();
444
446 if ((qual1 != 0 || qbit != 0 || amp != 0.0) && (fabs(time) < maxTime && time != 0.0)) {
448 }
449
451 if (badch1) tileAdcStatus += 10;
452
453 pmt1RawAmplitude.push_back(
DataType(amp));
454 pmt1RawTime.push_back(
DataType(time));
455 pmt1Number.push_back(
DataType(PMT));
456 pmt1ADCStatus.push_back(
DataType( tileAdcStatus ));
457 pmt1Pedestal.push_back(
DataType(0));
458 }
459
460 if (noch2 ) {
461 pmt2RawAmplitude.push_back(
DataType(0));
463 pmt2ADCStatus.push_back(
DataType(0));
465 pmt2Pedestal.push_back(
DataType(0));
466 } else {
467 HWIdentifier hwid =
cabling->s2h_adc_id(tileID->
adc_id(cellid,1,gain2));
468
469 int adc = tileHWID->
adc(hwid);
472 int ros = tileHWID->
ros(hwid);
473 int PMT = abs(
cabling->channel2hole(ros,channel) );
477 float amp = theTileCell->ene2() /
scale;
478 float time = theTileCell->time2();
479
481 if ((qual2 != 0 || qbit != 0 || amp != 0.0) && (fabs(time) < maxTime && time != 0.0)) {
483 }
484
486 if (badch2) tileAdcStatus += 10;
487
488 pmt2RawAmplitude.push_back(
DataType(amp));
489 pmt2RawTime.push_back(
DataType(time));
490 pmt2ADCStatus.push_back(
DataType( tileAdcStatus ));
491 pmt2Number.push_back(
DataType(PMT));
492 pmt2Pedestal.push_back(
DataType(0));
493 }
494 }
495 }
496 }
497
498 ATH_MSG_DEBUG(
" Total energy in Tile in GeV : " << energyAllTile );
499
500 if ( !pmt1digit.empty() ) pmt1digit.clear();
501 if ( !pmt2digit.empty() ) pmt2digit.clear();
502
503
508 DataMap[
"id"] = std::move(idVec);
509 DataMap[
"energy"] = std::move(energyVec);
510
511
512
514 DataMap[
"BadCell"]= std::move(BadCell);
515 }
516
518 DataMap[
"pmt1Energy"] = std::move(pmt1Energy);
519 DataMap[
"pmt1Time"] = std::move(pmt1Time);
520 DataMap[
"pmt1Chi2"] = std::move(pmt1Chi2);
521 DataMap[
"pmt1Gain"] = std::move(pmt1Gain);
522
523 DataMap[
"pmt2Energy"] = std::move(pmt2Energy);
524 DataMap[
"pmt2Time"] = std::move(pmt2Time);
525 DataMap[
"pmt2Chi2"] = std::move(pmt2Chi2);
526 DataMap[
"pmt2Gain"] = std::move(pmt2Gain);
527
528 DataMap[
"pmt1RawAmplitude"] = std::move(pmt1RawAmplitude);
529 DataMap[
"pmt1RawTime"] = std::move(pmt1RawTime);
530 DataMap[
"pmt1ADCStatus"] = std::move(pmt1ADCStatus);
531 DataMap[
"pmt1Number"] = std::move(pmt1Number);
532 DataMap[
"pmt1Pedestal"] = std::move(pmt1Pedestal);
533
534 DataMap[
"pmt2RawAmplitude"] = std::move(pmt2RawAmplitude);
535 DataMap[
"pmt2RawTime"] = std::move(pmt2RawTime);
536 DataMap[
"pmt2ADCStatus"] = std::move(pmt2ADCStatus);
537 DataMap[
"pmt2Number"] = std::move(pmt2Number);
538 DataMap[
"pmt2Pedestal"] = std::move(pmt2Pedestal);
539 }
540
541 DataMap[adcCounts1Str] = std::move( adcCounts1Vec);
542 DataMap[adcCounts2Str] = std::move(adcCounts2Vec);
543
544
546
547
549
550 }
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_WARNING(x)
IndexedConstituentUserInfo::Index Index
static const Attributes_t empty
const ServiceHandle< StoreGateSvc > & detStore() const
CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const iterators on cell of just one calo
CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
DataModel_detail::const_iterator< DataVector > const_iterator
size_type size() const noexcept
Returns the number of elements in the collection.
void calcTILELayerSub(Identifier &)
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
virtual std::string dataTypeName() const
Return the name of the data type.
ToolHandle< TileCondToolTiming > m_tileToolTiming
ToolHandle< ITileBadChanTool > m_tileBadChanTool
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
virtual bool isValid() override final
Can the handle be successfully dereferenced?
static const TileCablingService * getInstance()
get pointer to service instance
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
int NdigitSamples() const
Returns the number of sammples (digits) per event.
Identifier adc_id(const Identifier &cell_id, int pmt, int adc) const
time(flags, cells_name, *args, **kw)
std::map< std::string, DataVect > DataMap
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())