Execute on an entire collection of clusters.
77{
79 std::vector<std::pair<unsigned int, double> > >
80 caloClusterWriteDecorHandleNLeadingTruthParticlesDM(
82
83 bool foundAllContainers(true);
84 std::vector<const CaloCalibrationHitContainer*> v_cchc;
85 std::vector<const CaloCalibrationHitContainer*> v_dmcchc;
86
87 for (const SG::ReadHandleKey<CaloCalibrationHitContainer>& key :
89 SG::ReadHandle<CaloCalibrationHitContainer> cchc(key, ctx);
90 if (!cchc.isValid()) {
92 ATH_MSG_ERROR(
"SG does not contain calibration hit container " <<
key.key());
93 }
94 foundAllContainers = false;
95 }
96 else {
97 v_cchc.push_back(cchc.cptr());
98 }
99 }
100
101 for (const SG::ReadHandleKey<CaloCalibrationHitContainer>& key :
103 SG::ReadHandle<CaloCalibrationHitContainer> dmcchc(key, ctx);
104 if (!dmcchc.isValid()) {
106 ATH_MSG_ERROR(
"SG does not contain DM calibration hit container " <<
key.key());
107 }
108 foundAllContainers = false;
109 }
110 else {
111 v_dmcchc.push_back(dmcchc.cptr());
112 }
113 }
114
117 }
118
119 if (!foundAllContainers) {
120 return StatusCode::SUCCESS;
121 }
122
124
127
128 unsigned int nHitsTotal = 0;
129 unsigned int nHitsWithoutParticleUID = 0;
131 v_cchc,
132 cellInfo,
134 clusInfoVec,
135 nHitsTotal,
136 nHitsWithoutParticleUID,
138 [this]() {
139 ATH_MSG_ERROR(
"Invalid uniqueID detected - this sample cannot be properly analysed.");
140 });
141
144 ATH_MSG_INFO(
"Calibration hits do not have ParticleUID, ids of particle-caused hits are always 0. Continuing without ParticleID machinery.");
145 useParticleID = false;
146 }
147
148 std::array<ClusList, 3> clusLists;
149 const std::array<bool, 3> doClusterLists{{
153
154 for (unsigned int ii = 0; ii < 3; ++ii) {
155 if (doClusterLists[ii]) {
157 }
158 }
159
160 std::array<ClusList*, 3> clusListPtrs{{&clusLists[0], &clusLists[1], &clusLists[2]}};
162 *theClusColl,
163 clusInfoVec,
169 doClusterLists,
170 clusListPtrs);
171
172 const ClusList* pClusList =
nullptr;
174 pClusList = &clusLists[0];
175 }
177 pClusList = &clusLists[1];
178 }
180 pClusList = &clusLists[2];
181 }
182
183 std::vector<std::unordered_map<unsigned int, double> > engCalibDeadByTruth(theClusColl->size());
184
185 if (pClusList != nullptr) {
187 v_dmcchc,
188 *theClusColl,
189 clusInfoVec,
190 *pClusList,
191 useParticleID,
192 [&engCalibDeadByTruth](int iClus, unsigned int uniqueID, int , double energy) {
194 });
195 }
196
197
198
199 for (std::size_t iClus = 0; iClus < clusInfoVec.size(); ++iClus) {
200 const auto& particleMap = clusInfoVec[iClus].engCalibParticle;
201 for (const auto& [uniqueID, calibEnergy] : particleMap) {
202 const double inClusterDeadEnergy =
203 calibEnergy.engSmp[CaloSampling::PreSamplerB]
204 + calibEnergy.engSmp[CaloSampling::PreSamplerE]
205 + calibEnergy.engSmp[CaloSampling::TileGap3];
206 if (inClusterDeadEnergy != 0.0) {
207 engCalibDeadByTruth[iClus][
uniqueID] += inClusterDeadEnergy;
208 }
209 }
210 }
211
212 int clusIdx = -1;
214 ++clusIdx;
215 const std::unordered_map<unsigned int, double>& truthMap = engCalibDeadByTruth[clusIdx];
216 if (!truthMap.empty()) {
217 caloClusterWriteDecorHandleNLeadingTruthParticlesDM(*thisCaloCluster) =
219 }
220 }
221
222 return StatusCode::SUCCESS;
223}
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
static void accumulateClusterCalibHits(const std::vector< const CaloCalibrationHitContainer * > &v_cchc, const CellInfoSet_t &cellInfo, const CaloCell_ID &calo_id, ClusInfo_t &clusInfoVec, unsigned int &nHitsTotal, unsigned int &nHitsWithoutParticleUID, bool useParticleID, InvalidUniqueIdHandler &&invalidUniqueIdHandler)
Accumulate calibration-hit energy inside clusters.
static void buildOutOfClusterClusterLists(const xAOD::CaloClusterContainer &theClusColl, const ClusInfo_t &clusInfoVec, int n_phi_out, int n_eta_out, double out_phi_max, double out_eta_max, const std::array< std::vector< std::vector< CalibHitIPhiIEtaRange > >, 3 > &i_phi_eta, const std::array< bool, 3 > &doOutOfCluster, const std::array< ClusList *, 3 > &clusLists)
Build lookup lists of clusters for out-of-cluster energy sharing.
static void buildCellInfoMap(const xAOD::CaloClusterContainer &theClusColl, CellInfoSet_t &cellInfo)
Build a map of calorimeter cells contributing to clusters.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.