86 {
87
89 char rndStr[30];
91
95 DataVect energyVec; energyVec.reserve(cellContainer->
size());
96 DataVect adcCounts1Vec; adcCounts1Vec.reserve(cellContainer->
size() * 10);
97 DataVect adcCounts2Vec; adcCounts2Vec.reserve(cellContainer->
size() * 10);
98 DataVect BadCell; BadCell.reserve(cellContainer->
size());
99
100 DataVect pmt1Energy; pmt1Energy.reserve(cellContainer->
size());
101 DataVect pmt1Time; pmt1Time.reserve(cellContainer->
size());
102 DataVect pmt1Chi2; pmt1Chi2.reserve(cellContainer->
size());
103 DataVect pmt1Gain; pmt1Gain.reserve(cellContainer->
size());
104 DataVect pmt2Energy; pmt2Energy.reserve(cellContainer->
size());
105 DataVect pmt2Time; pmt2Time.reserve(cellContainer->
size());
106 DataVect pmt2Chi2; pmt2Chi2.reserve(cellContainer->
size());
107 DataVect pmt2Gain; pmt2Gain.reserve(cellContainer->
size());
108
109 DataVect pmt1RawAmplitude; pmt1RawAmplitude.reserve(cellContainer->
size());
110 DataVect pmt1RawTime; pmt1RawTime.reserve(cellContainer->
size());
111 DataVect pmt1Pedestal; pmt1Pedestal.reserve(cellContainer->
size());
112 DataVect pmt1Number; pmt1Number.reserve(cellContainer->
size());
113 DataVect pmt1ADCStatus; pmt1ADCStatus.reserve(cellContainer->
size());
114 DataVect pmt2RawAmplitude; pmt2RawAmplitude.reserve(cellContainer->
size());
115 DataVect pmt2RawTime; pmt2RawTime.reserve(cellContainer->
size());
116 DataVect pmt2Pedestal; pmt2Pedestal.reserve(cellContainer->
size());
117 DataVect pmt2Number; pmt2Number.reserve(cellContainer->
size());
118 DataVect pmt2ADCStatus; pmt2ADCStatus.reserve(cellContainer->
size());
119
120
122
123 std::string adcCounts1Str = "adcCounts1 multiple=\"0\"";
124 std::string adcCounts2Str = "adcCounts2 multiple=\"0\"";
125
126 const TileID* tileID = nullptr;
128 const TileInfo* tileInfo = nullptr;
129 const TileCablingService*
cabling=
nullptr;
132 double energyGeV;
133 double amplitude = 0.;
134 const int vsize = cellContainer->
size();
135 int Index,pmtInd, cellInd, nTileSamples=0;
136 std::vector<double> pmt1ped(vsize,0.0);
137 std::vector<double> pmt2ped(vsize,0.0);
138 std::vector<double> pmt1rawamp(vsize,0.0);
139 std::vector<double> pmt2rawamp(vsize,0.0);
140 std::vector<double> pmt1rawtime(vsize,0.0);
141 std::vector<double> pmt2rawtime(vsize,0.0);
142 std::vector<int> pmt1number(vsize,0);
143 std::vector<int> pmt2number(vsize,0);
144 std::vector<unsigned long int> pmt1status(vsize,0);
145 std::vector<unsigned long int> pmt2status(vsize,0);
146 std::map<int,std::vector<float> > pmt1digit;
147 std::map<int,std::vector<float> > pmt2digit;
148 bool offlineRch = false;
149
150
151
152 if (detStore()->
retrieve(tileID).isFailure()) {
153 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileID" );
154
155 }
156
157 if (detStore()->
retrieve(tileHWID).isFailure()) {
158 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileHWID" );
159 }
160
161 if (detStore()->
retrieve(tileInfo,
"TileInfo").isFailure()) {
162 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileInfo" );
163 }
164
165 SG::ReadHandle<TileDigitsContainer> tileDigits;
170 }
171 }
172
173 SG::ReadHandle<TileRawChannelContainer> RawChannelCnt;
178 }
179 else {
180 RChUnit = RawChannelCnt->get_unit();
183 }
184 }
185
186
187
188
190 if (offlineRch) {
191
192 for (const auto rawChannel : *RawChannelCnt) {
193
194 for (const auto cell : *rawChannel) {
195
197 if (
Index <= -1 )
continue;
199 cellInd = cellContainer->
findIndex(cell_hash);
200 if (cellInd < 0) continue;
201
202 HWIdentifier hwid=
cell->adc_HWID();
203 int adc = tileHWID->
adc(hwid);
206 int ros = tileHWID->
ros(hwid);
207 int PMT = abs(
cabling->channel2hole(ros,channel) );
210
211 amplitude =
cell->amplitude();
212
216
217
218 std::abort();
219 }
220
221 if ( pmtInd == 0 ) {
222
223 pmt1ped[cellInd] =
cell->pedestal();
224 pmt1rawamp[cellInd] = amplitude;
225 pmt1rawtime[cellInd] =
cell->uncorrTime();
226 pmt1number[cellInd] = PMT;
227 pmt1status[cellInd] = tileAdcStatus;
228 }
229 else {
230
231 pmt2ped[cellInd] =
cell->pedestal();
232 pmt2rawamp[cellInd] = amplitude;
233 pmt2rawtime[cellInd] =
cell->uncorrTime();
234 pmt2number[cellInd] = PMT;
235 pmt2status[cellInd] = tileAdcStatus;
236
237 }
238 }
239 }
240 }
241 }
242
243
244
245
247
248
249
250
251 for (const auto digitChannel : *tileDigits) {
252
253 for (const auto cell : *digitChannel) {
254
256 if (
Index <= -1 )
continue;
258 cellInd = cellContainer->
findIndex(cell_hash);
259 if (cellInd < 0) continue;
261
262 nTileSamples =
cell->NtimeSamples();
263 std::vector<float> tileSamples =
cell->samples();
264
265 if (pmtInd == 0 ) {
266 pmt1digit.insert(std::make_pair( cellInd, tileSamples ) );
267 }
268 else {
269 pmt2digit.insert(std::make_pair( cellInd, tileSamples ) );
270 }
271
272 }
273 }
274 }
275
276
277
278
281
282 double energyAllTile = 0.;
283
284 for (;it1!=it2;++it1) {
285
286 if ((*it1)->badcell()) BadCell.push_back(1);
288 else BadCell.push_back(-1);
289
290 Identifier cellid = (*it1)->ID();
291 IdentifierHash cell_hash =
m_calocell_id->calo_cell_hash( cellid );
292 cellInd = cellContainer->
findIndex(cell_hash);
293 if (cellInd < 0) continue;
295
296 energyGeV = (*it1)->energy()*(1./
GeV);
298 energyAllTile += energyGeV;
299
300 idVec.push_back(
DataType( (Identifier::value_type)(*it1)->ID().get_compact() ));
303
305
306 if ( !pmt1digit[cellInd].
empty()) {
307 for (
int i=0;
i<nTileSamples;
i++) {
308 adcCounts1Str=
"adcCounts1 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
309 adcCounts1Vec.push_back(
DataType(
int(pmt1digit[cellInd][i])));
310 }
311 }
312 else {
313 for (
int i=0;
i<nTileSamples;
i++) {
314 adcCounts1Str=
"adcCounts1 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
315 adcCounts1Vec.push_back(
DataType(0));
316 }
317 }
318
319
320 if ( !pmt2digit[cellInd].
empty()) {
321 for (
int i=0;
i<nTileSamples;
i++) {
322 adcCounts2Str=
"adcCounts2 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
323 adcCounts2Vec.push_back(
DataType(
int(pmt2digit[cellInd][i])));
324 }
325 }
326 else {
327 for (
int i=0;
i<nTileSamples;
i++) {
328 adcCounts2Str=
"adcCounts2 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
329 adcCounts2Vec.push_back(
DataType(0));
330 }
331 }
332 }
333
335
336 const TileCell* theTileCell = dynamic_cast<const TileCell *>(*it1);
337 if (not theTileCell) {
338
339 throw std::runtime_error("Could not cast pointer to TileCell in CaloTileRetriever::getCaloTileData");
340 }
341 int gain1 = theTileCell->gain1();
342 int qual1 = theTileCell->qual1();
343 bool badch1 = theTileCell->badch1();
344 bool noch1 = (gain1<0 || gain1>1);
345
346 int qual2 = theTileCell->qual2();
347 int gain2 = theTileCell->gain2();
348 bool badch2 = theTileCell->badch2();
349 bool noch2 = (gain2<0 || gain2>1);
350
351 if (badch1 != badch2 && qual1 != qual2 && qual1 < 255 && qual2 < 255) {
354 }
355 if (badch1) qual1 = -qual1;
356 if (badch2) qual2 = -qual2;
357
358 pmt1Energy.push_back(
DataType(theTileCell->ene1()*(1./
GeV)));
359 pmt1Time.push_back(
DataType(theTileCell->time1()));
360 pmt1Chi2.push_back(
DataType(qual1));
361 pmt1Gain.push_back(
DataType(gain1));
362
363 pmt2Energy.push_back(
DataType(theTileCell->ene2()*(1./
GeV)));
364 pmt2Time.push_back(
DataType(theTileCell->time2()));
365 pmt2Chi2.push_back(
DataType(qual2));
366 pmt2Gain.push_back(
DataType(gain2));
367
368 if (offlineRch && RawChannelCnt.isValid()
369 && (noch1 || pmt1number[cellInd]!=0) && (noch2 || pmt2number[cellInd]!=0)) {
370
371 uint32_t tileAdcStatus = pmt1status[cellInd];
372 if (badch1) tileAdcStatus += 10;
373
374 pmt1RawAmplitude.push_back(
DataType(pmt1rawamp[cellInd]));
375 pmt1RawTime.push_back(
DataType(pmt1rawtime[cellInd]));
376 pmt1Pedestal.push_back(
DataType(pmt1ped[cellInd]));
377 pmt1Number.push_back(
DataType(pmt1number[cellInd]));
378 pmt1ADCStatus.push_back(
DataType(tileAdcStatus));
379
380 tileAdcStatus = pmt2status[cellInd];
381 if (badch2) tileAdcStatus += 10;
382
383 pmt2RawAmplitude.push_back(
DataType(pmt2rawamp[cellInd]));
384 pmt2RawTime.push_back(
DataType(pmt2rawtime[cellInd]));
385 pmt2Pedestal.push_back(
DataType(pmt2ped[cellInd]));
386 pmt2Number.push_back(
DataType(pmt2number[cellInd]));
387 pmt2ADCStatus.push_back(
DataType(tileAdcStatus));
388 }
389 else {
390
392
393 if (noch1 ) {
394 pmt1RawAmplitude.push_back(
DataType(0));
396 pmt1ADCStatus.push_back(
DataType(0));
398 pmt1Pedestal.push_back(
DataType(0));
399 } else {
400 HWIdentifier hwid =
cabling->s2h_adc_id(tileID->
adc_id(cellid,0,gain1));
401
402 int adc = tileHWID->
adc(hwid);
405 int ros = tileHWID->
ros(hwid);
406 int PMT = abs(
cabling->channel2hole(ros,channel) );
410 float amp = theTileCell->ene1() /
scale;
411 float time = theTileCell->time1();
412
414 if ((qual1 != 0 || qbit != 0 || amp != 0.0) && (fabs(time) < maxTime && time != 0.0)) {
416 }
417
419 if (badch1) tileAdcStatus += 10;
420
421 pmt1RawAmplitude.push_back(
DataType(amp));
422 pmt1RawTime.push_back(
DataType(time));
423 pmt1Number.push_back(
DataType(PMT));
424 pmt1ADCStatus.push_back(
DataType( tileAdcStatus ));
425 pmt1Pedestal.push_back(
DataType(0));
426 }
427
428 if (noch2 ) {
429 pmt2RawAmplitude.push_back(
DataType(0));
431 pmt2ADCStatus.push_back(
DataType(0));
433 pmt2Pedestal.push_back(
DataType(0));
434 } else {
435 HWIdentifier hwid =
cabling->s2h_adc_id(tileID->
adc_id(cellid,1,gain2));
436
437 int adc = tileHWID->
adc(hwid);
440 int ros = tileHWID->
ros(hwid);
441 int PMT = abs(
cabling->channel2hole(ros,channel) );
445 float amp = theTileCell->ene2() /
scale;
446 float time = theTileCell->time2();
447
449 if ((qual2 != 0 || qbit != 0 || amp != 0.0) && (fabs(time) < maxTime && time != 0.0)) {
451 }
452
454 if (badch2) tileAdcStatus += 10;
455
456 pmt2RawAmplitude.push_back(
DataType(amp));
457 pmt2RawTime.push_back(
DataType(time));
458 pmt2ADCStatus.push_back(
DataType( tileAdcStatus ));
459 pmt2Number.push_back(
DataType(PMT));
460 pmt2Pedestal.push_back(
DataType(0));
461 }
462 }
463 }
464 }
465
466 ATH_MSG_DEBUG(
" Total energy in Tile in GeV : " << energyAllTile );
467
468 if ( !pmt1digit.empty() ) pmt1digit.clear();
469 if ( !pmt2digit.empty() ) pmt2digit.clear();
470
471
476 DataMap[
"id"] = std::move(idVec);
477 DataMap[
"energy"] = std::move(energyVec);
478
479
480
482 DataMap[
"BadCell"]= std::move(BadCell);
483 }
484
486 DataMap[
"pmt1Energy"] = std::move(pmt1Energy);
487 DataMap[
"pmt1Time"] = std::move(pmt1Time);
488 DataMap[
"pmt1Chi2"] = std::move(pmt1Chi2);
489 DataMap[
"pmt1Gain"] = std::move(pmt1Gain);
490
491 DataMap[
"pmt2Energy"] = std::move(pmt2Energy);
492 DataMap[
"pmt2Time"] = std::move(pmt2Time);
493 DataMap[
"pmt2Chi2"] = std::move(pmt2Chi2);
494 DataMap[
"pmt2Gain"] = std::move(pmt2Gain);
495
496 DataMap[
"pmt1RawAmplitude"] = std::move(pmt1RawAmplitude);
497 DataMap[
"pmt1RawTime"] = std::move(pmt1RawTime);
498 DataMap[
"pmt1ADCStatus"] = std::move(pmt1ADCStatus);
499 DataMap[
"pmt1Number"] = std::move(pmt1Number);
500 DataMap[
"pmt1Pedestal"] = std::move(pmt1Pedestal);
501
502 DataMap[
"pmt2RawAmplitude"] = std::move(pmt2RawAmplitude);
503 DataMap[
"pmt2RawTime"] = std::move(pmt2RawTime);
504 DataMap[
"pmt2ADCStatus"] = std::move(pmt2ADCStatus);
505 DataMap[
"pmt2Number"] = std::move(pmt2Number);
506 DataMap[
"pmt2Pedestal"] = std::move(pmt2Pedestal);
507 }
508
509 DataMap[adcCounts1Str] = std::move( adcCounts1Vec);
510 DataMap[adcCounts2Str] = std::move(adcCounts2Vec);
511
512
514
515
517
518 }
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_WARNING(x)
IndexedConstituentUserInfo::Index Index
static const Attributes_t empty
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 &)
SG::ReadHandleKey< TileDigitsContainer > m_sgKeyTileDigits
Gaudi::Property< bool > m_doTileCellDetails
ToolHandle< TileCondToolTiming > m_tileToolTiming
Gaudi::Property< double > m_cellThreshold
ToolHandle< ITileBadChanTool > m_tileBadChanTool
SG::ReadHandleKey< TileRawChannelContainer > m_sgKeyTileRawChannel
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
virtual std::string dataTypeName() const override
Return the name of the data type.
Gaudi::Property< bool > m_doBadTile
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool) override
Retrieve all the data.
Gaudi::Property< int > m_cellEnergyPrec
Gaudi::Property< bool > m_doTileDigit
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())