18 "Test mode activated with additional debug output. Makes only sense if we try to patch a FEB that is actually there, so we have a reference");
21 return StatusCode::SUCCESS;
27 if (!cellCollection) {
28 ATH_MSG_ERROR(
"Cell Correction tool receives invalid cell Collection");
29 return StatusCode::FAILURE;
36 return StatusCode::SUCCESS;
41 if (scToDead.empty()) {
42 return StatusCode::SUCCESS;
52 return StatusCode::SUCCESS;
55 const unsigned int bcid = ctx.eventID().bunch_crossing_id();
59 for (
const auto*
sc : *scells) {
63 auto itr = scToDead.find(scHwid);
64 if (itr == scToDead.end())
67 const std::vector<unsigned short>& bcids =
sc->bcids();
68 const std::vector<int>& energies =
sc->energies();
69 const std::vector<bool>& satur =
sc->satur();
73 const size_t nBCIDs = bcids.size();
75 for (i = 0; i < nBCIDs && bcids[i] != bcid; i++)
81 ATH_MSG_VERBOSE(
"SuperCell value " << scEne <<
" below threshold, ignoring");
85 float patchEneSum = 0;
86 for (
const auto& [
h, convFactor] : itr->second) {
89 const float patchEne = scEne * convFactor;
91 cellESum += cell->energy();
92 patchEneSum += patchEne;
94 ATH_MSG_DEBUG(
"Cell id 0x" << std::hex << cell->ID().get_identifier32().get_compact() <<
" Replacing energy " << cell->energy() <<
" " << patchEne
95 <<
", SCene=" << scEne);
96 cell->setEnergy(patchEne);
101 const float ratio = patchEneSum != 0 ? cellESum / patchEneSum : 0;
102 ATH_MSG_DEBUG(
"ESums=" << cellESum <<
"/" << patchEneSum <<
"=" << ratio);
103 std::scoped_lock l(
m_mtx);
104 auto& entry = m_testMap[scEne];
105 entry.first += ratio;
110 return StatusCode::SUCCESS;
117 std::vector<std::pair<float, float> > avgList;
118 for (
auto& [scEne, entry] : m_testMap) {
119 avgList.emplace_back(scEne, entry.first / entry.second);
121 auto ordering = [](
const std::pair<float, float>&
a, std::pair<float, float>& b) {
return (
a.first < b.first); };
122 std::sort(avgList.begin(), avgList.end(), ordering);
123 for (
auto& p : avgList) {
124 ATH_MSG_INFO(
"SCEne=" << p.first <<
"Avg patching ratio=" << p.second);
127 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Header file for AthHistogramAlgorithm.
Container class for CaloCell.
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
bool hasCalo(const CaloCell_ID::SUBCALO caloNum) const
tell wether it has been filled with cells (maybe none) of a given calo
Data object for each calorimeter readout cell.
std::map< HWIdentifier, std::vector< std::pair< IdentifierHash, float > > > payload_t
Container class for LArRawSC.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.