88 {
89
91 char rndStr[30];
93
97 DataVect energyVec; energyVec.reserve(cellContainer->
size());
98 DataVect adcCounts1Vec; adcCounts1Vec.reserve(cellContainer->
size() * 10);
99 DataVect adcCounts2Vec; adcCounts2Vec.reserve(cellContainer->
size() * 10);
100 DataVect BadCell; BadCell.reserve(cellContainer->
size());
101
102 DataVect pmt1Energy; pmt1Energy.reserve(cellContainer->
size());
103 DataVect pmt1Time; pmt1Time.reserve(cellContainer->
size());
104 DataVect pmt1Chi2; pmt1Chi2.reserve(cellContainer->
size());
105 DataVect pmt1Gain; pmt1Gain.reserve(cellContainer->
size());
106 DataVect pmt2Energy; pmt2Energy.reserve(cellContainer->
size());
107 DataVect pmt2Time; pmt2Time.reserve(cellContainer->
size());
108 DataVect pmt2Chi2; pmt2Chi2.reserve(cellContainer->
size());
109 DataVect pmt2Gain; pmt2Gain.reserve(cellContainer->
size());
110
111 DataVect pmt1RawAmplitude; pmt1RawAmplitude.reserve(cellContainer->
size());
112 DataVect pmt1RawTime; pmt1RawTime.reserve(cellContainer->
size());
113 DataVect pmt1Pedestal; pmt1Pedestal.reserve(cellContainer->
size());
114 DataVect pmt1Number; pmt1Number.reserve(cellContainer->
size());
115 DataVect pmt1ADCStatus; pmt1ADCStatus.reserve(cellContainer->
size());
116 DataVect pmt2RawAmplitude; pmt2RawAmplitude.reserve(cellContainer->
size());
117 DataVect pmt2RawTime; pmt2RawTime.reserve(cellContainer->
size());
118 DataVect pmt2Pedestal; pmt2Pedestal.reserve(cellContainer->
size());
119 DataVect pmt2Number; pmt2Number.reserve(cellContainer->
size());
120 DataVect pmt2ADCStatus; pmt2ADCStatus.reserve(cellContainer->
size());
121
122
124
125 std::string adcCounts1Str = "adcCounts1 multiple=\"0\"";
126 std::string adcCounts2Str = "adcCounts2 multiple=\"0\"";
127
128 const TileID* tileID = nullptr;
130 const TileInfo* tileInfo = nullptr;
131 const TileCablingService*
cabling=
nullptr;
134 double energyGeV;
135 double amplitude = 0.;
136 const int vsize = cellContainer->
size();
137 int Index,pmtInd, cellInd, nTileSamples=0;
138 std::vector<double> pmt1ped(vsize,0.0);
139 std::vector<double> pmt2ped(vsize,0.0);
140 std::vector<double> pmt1rawamp(vsize,0.0);
141 std::vector<double> pmt2rawamp(vsize,0.0);
142 std::vector<double> pmt1rawtime(vsize,0.0);
143 std::vector<double> pmt2rawtime(vsize,0.0);
144 std::vector<int> pmt1number(vsize,0);
145 std::vector<int> pmt2number(vsize,0);
146 std::vector<unsigned long int> pmt1status(vsize,0);
147 std::vector<unsigned long int> pmt2status(vsize,0);
148 std::map<int,std::vector<float> > pmt1digit;
149 std::map<int,std::vector<float> > pmt2digit;
150 bool offlineRch = false;
151
152
153
154 if (detStore()->
retrieve(tileID).isFailure()) {
155 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileID" );
156
157 }
158
159 if (detStore()->
retrieve(tileHWID).isFailure()) {
160 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileHWID" );
161 }
162
163 if (detStore()->
retrieve(tileInfo,
"TileInfo").isFailure()) {
164 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileInfo" );
165 }
166
167 SG::ReadHandle<TileDigitsContainer> tileDigits;
172 }
173 }
174
175 SG::ReadHandle<TileRawChannelContainer> RawChannelCnt;
180 }
181 else {
182 RChUnit = RawChannelCnt->get_unit();
185 }
186 }
187
188
189
190
192 if (offlineRch) {
193
194 for (const auto rawChannel : *RawChannelCnt) {
195
196 for (const auto cell : *rawChannel) {
197
199 if (
Index <= -1 )
continue;
201 cellInd = cellContainer->
findIndex(cell_hash);
202 if (cellInd < 0) continue;
203
204 HWIdentifier hwid=
cell->adc_HWID();
205 int adc = tileHWID->
adc(hwid);
208 int ros = tileHWID->
ros(hwid);
209 int PMT = abs(
cabling->channel2hole(ros,channel) );
212
213 amplitude =
cell->amplitude();
214
218
219
220 std::abort();
221 }
222
223 if ( pmtInd == 0 ) {
224
225 pmt1ped[cellInd] =
cell->pedestal();
226 pmt1rawamp[cellInd] = amplitude;
227 pmt1rawtime[cellInd] =
cell->uncorrTime();
228 pmt1number[cellInd] = PMT;
229 pmt1status[cellInd] = tileAdcStatus;
230 }
231 else {
232
233 pmt2ped[cellInd] =
cell->pedestal();
234 pmt2rawamp[cellInd] = amplitude;
235 pmt2rawtime[cellInd] =
cell->uncorrTime();
236 pmt2number[cellInd] = PMT;
237 pmt2status[cellInd] = tileAdcStatus;
238
239 }
240 }
241 }
242 }
243 }
244
245
246
247
249
250
251
252
253 for (const auto digitChannel : *tileDigits) {
254
255 for (const auto cell : *digitChannel) {
256
258 if (
Index <= -1 )
continue;
260 cellInd = cellContainer->
findIndex(cell_hash);
261 if (cellInd < 0) continue;
263
264 nTileSamples =
cell->NtimeSamples();
265 std::vector<float> tileSamples =
cell->samples();
266
267 if (pmtInd == 0 ) {
268 pmt1digit.insert(std::make_pair( cellInd, tileSamples ) );
269 }
270 else {
271 pmt2digit.insert(std::make_pair( cellInd, tileSamples ) );
272 }
273
274 }
275 }
276 }
277
278
279
280
283
284 double energyAllTile = 0.;
285
286 for (;it1!=it2;++it1) {
287
288 if ((*it1)->badcell()) BadCell.push_back(1);
290 else BadCell.push_back(-1);
291
292 Identifier cellid = (*it1)->ID();
293 IdentifierHash cell_hash =
m_calocell_id->calo_cell_hash( cellid );
294 cellInd = cellContainer->
findIndex(cell_hash);
295 if (cellInd < 0) continue;
297
298 energyGeV = (*it1)->energy()*(1./
GeV);
300 energyAllTile += energyGeV;
301
302 idVec.push_back(
DataType( (Identifier::value_type)(*it1)->ID().get_compact() ));
305
307
308 if ( !pmt1digit[cellInd].
empty()) {
309 for (
int i=0;
i<nTileSamples;
i++) {
310 adcCounts1Str=
"adcCounts1 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
311 adcCounts1Vec.push_back(
DataType(
int(pmt1digit[cellInd][i])));
312 }
313 }
314 else {
315 for (
int i=0;
i<nTileSamples;
i++) {
316 adcCounts1Str=
"adcCounts1 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
317 adcCounts1Vec.push_back(
DataType(0));
318 }
319 }
320
321
322 if ( !pmt2digit[cellInd].
empty()) {
323 for (
int i=0;
i<nTileSamples;
i++) {
324 adcCounts2Str=
"adcCounts2 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
325 adcCounts2Vec.push_back(
DataType(
int(pmt2digit[cellInd][i])));
326 }
327 }
328 else {
329 for (
int i=0;
i<nTileSamples;
i++) {
330 adcCounts2Str=
"adcCounts2 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
331 adcCounts2Vec.push_back(
DataType(0));
332 }
333 }
334 }
335
337
338 const TileCell* theTileCell = dynamic_cast<const TileCell *>(*it1);
339 if (not theTileCell) {
340
341 throw std::runtime_error("Could not cast pointer to TileCell in CaloTileRetriever::getCaloTileData");
342 }
343 int gain1 = theTileCell->gain1();
344 int qual1 = theTileCell->qual1();
345 bool badch1 = theTileCell->badch1();
346 bool noch1 = (gain1<0 || gain1>1);
347
348 int qual2 = theTileCell->qual2();
349 int gain2 = theTileCell->gain2();
350 bool badch2 = theTileCell->badch2();
351 bool noch2 = (gain2<0 || gain2>1);
352
353 if (badch1 != badch2 && qual1 != qual2 && qual1 < 255 && qual2 < 255) {
356 }
357 if (badch1) qual1 = -qual1;
358 if (badch2) qual2 = -qual2;
359
360 pmt1Energy.push_back(
DataType(theTileCell->ene1()*(1./
GeV)));
361 pmt1Time.push_back(
DataType(theTileCell->time1()));
362 pmt1Chi2.push_back(
DataType(qual1));
363 pmt1Gain.push_back(
DataType(gain1));
364
365 pmt2Energy.push_back(
DataType(theTileCell->ene2()*(1./
GeV)));
366 pmt2Time.push_back(
DataType(theTileCell->time2()));
367 pmt2Chi2.push_back(
DataType(qual2));
368 pmt2Gain.push_back(
DataType(gain2));
369
370 if (offlineRch && RawChannelCnt.isValid()
371 && (noch1 || pmt1number[cellInd]!=0) && (noch2 || pmt2number[cellInd]!=0)) {
372
373 uint32_t tileAdcStatus = pmt1status[cellInd];
374 if (badch1) tileAdcStatus += 10;
375
376 pmt1RawAmplitude.push_back(
DataType(pmt1rawamp[cellInd]));
377 pmt1RawTime.push_back(
DataType(pmt1rawtime[cellInd]));
378 pmt1Pedestal.push_back(
DataType(pmt1ped[cellInd]));
379 pmt1Number.push_back(
DataType(pmt1number[cellInd]));
380 pmt1ADCStatus.push_back(
DataType(tileAdcStatus));
381
382 tileAdcStatus = pmt2status[cellInd];
383 if (badch2) tileAdcStatus += 10;
384
385 pmt2RawAmplitude.push_back(
DataType(pmt2rawamp[cellInd]));
386 pmt2RawTime.push_back(
DataType(pmt2rawtime[cellInd]));
387 pmt2Pedestal.push_back(
DataType(pmt2ped[cellInd]));
388 pmt2Number.push_back(
DataType(pmt2number[cellInd]));
389 pmt2ADCStatus.push_back(
DataType(tileAdcStatus));
390 }
391 else {
392
394
395 if (noch1 ) {
396 pmt1RawAmplitude.push_back(
DataType(0));
398 pmt1ADCStatus.push_back(
DataType(0));
400 pmt1Pedestal.push_back(
DataType(0));
401 } else {
402 HWIdentifier hwid =
cabling->s2h_adc_id(tileID->
adc_id(cellid,0,gain1));
403
404 int adc = tileHWID->
adc(hwid);
407 int ros = tileHWID->
ros(hwid);
408 int PMT = abs(
cabling->channel2hole(ros,channel) );
412 float amp = theTileCell->ene1() /
scale;
413 float time = theTileCell->time1();
414
416 if ((qual1 != 0 || qbit != 0 || amp != 0.0) && (fabs(time) < maxTime && time != 0.0)) {
418 }
419
421 if (badch1) tileAdcStatus += 10;
422
423 pmt1RawAmplitude.push_back(
DataType(amp));
424 pmt1RawTime.push_back(
DataType(time));
425 pmt1Number.push_back(
DataType(PMT));
426 pmt1ADCStatus.push_back(
DataType( tileAdcStatus ));
427 pmt1Pedestal.push_back(
DataType(0));
428 }
429
430 if (noch2 ) {
431 pmt2RawAmplitude.push_back(
DataType(0));
433 pmt2ADCStatus.push_back(
DataType(0));
435 pmt2Pedestal.push_back(
DataType(0));
436 } else {
437 HWIdentifier hwid =
cabling->s2h_adc_id(tileID->
adc_id(cellid,1,gain2));
438
439 int adc = tileHWID->
adc(hwid);
442 int ros = tileHWID->
ros(hwid);
443 int PMT = abs(
cabling->channel2hole(ros,channel) );
447 float amp = theTileCell->ene2() /
scale;
448 float time = theTileCell->time2();
449
451 if ((qual2 != 0 || qbit != 0 || amp != 0.0) && (fabs(time) < maxTime && time != 0.0)) {
453 }
454
456 if (badch2) tileAdcStatus += 10;
457
458 pmt2RawAmplitude.push_back(
DataType(amp));
459 pmt2RawTime.push_back(
DataType(time));
460 pmt2ADCStatus.push_back(
DataType( tileAdcStatus ));
461 pmt2Number.push_back(
DataType(PMT));
462 pmt2Pedestal.push_back(
DataType(0));
463 }
464 }
465 }
466 }
467
468 ATH_MSG_DEBUG(
" Total energy in Tile in GeV : " << energyAllTile );
469
470 if ( !pmt1digit.empty() ) pmt1digit.clear();
471 if ( !pmt2digit.empty() ) pmt2digit.clear();
472
473
478 DataMap[
"id"] = std::move(idVec);
479 DataMap[
"energy"] = std::move(energyVec);
480
481
482
484 DataMap[
"BadCell"]= std::move(BadCell);
485 }
486
488 DataMap[
"pmt1Energy"] = std::move(pmt1Energy);
489 DataMap[
"pmt1Time"] = std::move(pmt1Time);
490 DataMap[
"pmt1Chi2"] = std::move(pmt1Chi2);
491 DataMap[
"pmt1Gain"] = std::move(pmt1Gain);
492
493 DataMap[
"pmt2Energy"] = std::move(pmt2Energy);
494 DataMap[
"pmt2Time"] = std::move(pmt2Time);
495 DataMap[
"pmt2Chi2"] = std::move(pmt2Chi2);
496 DataMap[
"pmt2Gain"] = std::move(pmt2Gain);
497
498 DataMap[
"pmt1RawAmplitude"] = std::move(pmt1RawAmplitude);
499 DataMap[
"pmt1RawTime"] = std::move(pmt1RawTime);
500 DataMap[
"pmt1ADCStatus"] = std::move(pmt1ADCStatus);
501 DataMap[
"pmt1Number"] = std::move(pmt1Number);
502 DataMap[
"pmt1Pedestal"] = std::move(pmt1Pedestal);
503
504 DataMap[
"pmt2RawAmplitude"] = std::move(pmt2RawAmplitude);
505 DataMap[
"pmt2RawTime"] = std::move(pmt2RawTime);
506 DataMap[
"pmt2ADCStatus"] = std::move(pmt2ADCStatus);
507 DataMap[
"pmt2Number"] = std::move(pmt2Number);
508 DataMap[
"pmt2Pedestal"] = std::move(pmt2Pedestal);
509 }
510
511 DataMap[adcCounts1Str] = std::move( adcCounts1Vec);
512 DataMap[adcCounts2Str] = std::move(adcCounts2Vec);
513
514
516
517
519
520 }
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())