12 #include "CaloDetDescr/CaloDetDescrElement.h"
39 m_calocell_id(nullptr)
42 declareInterface<IDataRetriever>(
this);
54 "Input collection to retrieve Tile digits, used when doTileDigit is True");
60 "Input collection to retrieve Tile raw channels, used when doTileCellDetails is True.");
87 return StatusCode::SUCCESS;
110 return StatusCode::SUCCESS;
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());
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());
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());
155 std::string adcCounts1Str =
"adcCounts1 multiple=\"0\"";
156 std::string adcCounts2Str =
"adcCounts2 multiple=\"0\"";
158 const TileID* tileID =
nullptr;
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;
185 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileID" );
190 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileHWID" );
194 ATH_MSG_ERROR(
"in getCaloTileData(), Could not retrieve TileInfo" );
212 RChUnit = RawChannelCnt->
get_unit();
224 for (
const auto rawChannel : *RawChannelCnt) {
226 for (
const auto cell : *rawChannel) {
229 if (
Index <= -1 )
continue;
231 cellInd = cellContainer->
findIndex(cell_hash);
232 if (cellInd < 0)
continue;
235 int adc = tileHWID->
adc(hwid);
238 int ros = tileHWID->
ros(hwid);
243 amplitude =
cell->amplitude();
255 pmt1ped[cellInd] =
cell->pedestal();
256 pmt1rawamp[cellInd] = amplitude;
257 pmt1rawtime[cellInd] =
cell->uncorrTime();
258 pmt1number[cellInd] = PMT;
259 pmt1status[cellInd] = tileAdcStatus;
263 pmt2ped[cellInd] =
cell->pedestal();
264 pmt2rawamp[cellInd] = amplitude;
265 pmt2rawtime[cellInd] =
cell->uncorrTime();
266 pmt2number[cellInd] = PMT;
267 pmt2status[cellInd] = tileAdcStatus;
283 for (
const auto digitChannel : *tileDigits) {
285 for (
const auto cell : *digitChannel) {
288 if (
Index <= -1 )
continue;
290 cellInd = cellContainer->
findIndex(cell_hash);
291 if (cellInd < 0)
continue;
294 nTileSamples =
cell->NtimeSamples();
295 std::vector<float> tileSamples =
cell->samples();
298 pmt1digit.insert(std::make_pair( cellInd, tileSamples ) );
301 pmt2digit.insert(std::make_pair( cellInd, tileSamples ) );
314 double energyAllTile = 0.;
318 if ((*it1)->badcell()) BadCell.push_back(1);
320 else BadCell.push_back(-1);
324 cellInd = cellContainer->
findIndex(cell_hash);
325 if (cellInd < 0)
continue;
328 energyGeV = (*it1)->energy()*(1./
GeV);
330 energyAllTile += energyGeV;
333 phi.push_back(
DataType((*it1)->phi()));
334 eta.push_back(
DataType((*it1)->eta()));
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])));
345 for (
int i=0;
i<nTileSamples;
i++) {
346 adcCounts1Str=
"adcCounts1 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
347 adcCounts1Vec.push_back(
DataType(0));
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])));
359 for (
int i=0;
i<nTileSamples;
i++) {
360 adcCounts2Str=
"adcCounts2 multiple=\""+
DataType(nTileSamples).toString()+
"\"";
361 adcCounts2Vec.push_back(
DataType(0));
369 if (not theTileCell) {
371 throw std::runtime_error(
"Could not cast pointer to TileCell in CaloTileRetriever::getCaloTileData");
373 int gain1 = theTileCell->gain1();
374 int qual1 = theTileCell->qual1();
375 bool badch1 = theTileCell->badch1();
376 bool noch1 = (gain1<0 || gain1>1);
378 int qual2 = theTileCell->qual2();
379 int gain2 = theTileCell->gain2();
380 bool badch2 = theTileCell->badch2();
381 bool noch2 = (gain2<0 || gain2>1);
383 if (badch1 != badch2 && qual1 != qual2 && qual1 < 255 && qual2 < 255) {
387 if (badch1) qual1 = -qual1;
388 if (badch2) qual2 = -qual2;
390 pmt1Energy.push_back(
DataType(theTileCell->ene1()*(1./
GeV)));
391 pmt1Time.push_back(
DataType(theTileCell->time1()));
392 pmt1Chi2.push_back(
DataType(qual1));
395 pmt2Energy.push_back(
DataType(theTileCell->ene2()*(1./
GeV)));
396 pmt2Time.push_back(
DataType(theTileCell->time2()));
397 pmt2Chi2.push_back(
DataType(qual2));
400 if (offlineRch && RawChannelCnt.
isValid()
401 && (noch1 || pmt1number[cellInd]!=0) && (noch2 || pmt2number[cellInd]!=0)) {
403 uint32_t tileAdcStatus = pmt1status[cellInd];
404 if (badch1) tileAdcStatus += 10;
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));
412 tileAdcStatus = pmt2status[cellInd];
413 if (badch2) tileAdcStatus += 10;
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));
426 pmt1RawAmplitude.push_back(
DataType(0));
428 pmt1ADCStatus.push_back(
DataType(0));
430 pmt1Pedestal.push_back(
DataType(0));
434 int adc = tileHWID->
adc(hwid);
437 int ros = tileHWID->
ros(hwid);
442 float amp = theTileCell->ene1() /
scale;
443 float time = theTileCell->time1();
446 if ((qual1 != 0 || qbit != 0 || amp != 0.0) && (fabs(time) < maxTime && time != 0.0)) {
451 if (badch1) tileAdcStatus += 10;
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));
461 pmt2RawAmplitude.push_back(
DataType(0));
463 pmt2ADCStatus.push_back(
DataType(0));
465 pmt2Pedestal.push_back(
DataType(0));
469 int adc = tileHWID->
adc(hwid);
472 int ros = tileHWID->
ros(hwid);
477 float amp = theTileCell->ene2() /
scale;
478 float time = theTileCell->time2();
481 if ((qual2 != 0 || qbit != 0 || amp != 0.0) && (fabs(time) < maxTime && time != 0.0)) {
486 if (badch2) tileAdcStatus += 10;
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));
498 ATH_MSG_DEBUG(
" Total energy in Tile in GeV : " << energyAllTile );
500 if ( !pmt1digit.empty() ) pmt1digit.clear();
501 if ( !pmt2digit.empty() ) pmt2digit.clear();
505 DataMap[
"phi"] = std::move(phi);
506 DataMap[
"eta"] = std::move(eta);
508 DataMap[
"id"] = std::move(idVec);
509 DataMap[
"energy"] = std::move(energyVec);
514 DataMap[
"BadCell"]= std::move(BadCell);
518 DataMap[
"pmt1Energy"] = std::move(pmt1Energy);
519 DataMap[
"pmt1Time"] = std::move(pmt1Time);
520 DataMap[
"pmt1Chi2"] = std::move(pmt1Chi2);
521 DataMap[
"pmt1Gain"] = std::move(pmt1Gain);
523 DataMap[
"pmt2Energy"] = std::move(pmt2Energy);
524 DataMap[
"pmt2Time"] = std::move(pmt2Time);
525 DataMap[
"pmt2Chi2"] = std::move(pmt2Chi2);
526 DataMap[
"pmt2Gain"] = std::move(pmt2Gain);
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);
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);
541 DataMap[adcCounts1Str] = std::move( adcCounts1Vec);
542 DataMap[adcCounts2Str] = std::move(adcCounts2Vec);