122 {
123
125
126 unsigned int nClusters = thisEflowCaloObject.
nClusters();
127 unsigned int nTrackMatches = thisEflowCaloObject.
nTracks();
128
129 ATH_MSG_DEBUG(
"Have got an eflowCaloObject with " << nClusters <<
" clusters and " << nTrackMatches <<
" track matches");
130
131 if (msgLevel(MSG::DEBUG)){
132 for (unsigned int iTrack = 0; iTrack < nTrackMatches; ++iTrack){
133 eflowRecTrack* thisTrack = thisEflowCaloObject.
efRecTrack(iTrack);
135 }
136 }
137
138
140
141
142 if (nTrackMatches < 1) return;
143
147
148
150 if (
isEOverPFail(expectedEnergy, expectedSigma, clusterEnergy))
return;
151 }
152
153 const std::vector<std::pair<eflowTrackClusterLink *, std::pair<float, float>>> &matchedTrackList = thisEflowCaloObject.
efRecLink();
154
155 ATH_MSG_DEBUG(
"Matched Track List has size " << matchedTrackList.size());
156
157 if (msgLevel(MSG::DEBUG))
158 {
159 for (unsigned int iTrack = 0; iTrack < nTrackMatches; ++iTrack)
160 {
162 ATH_MSG_DEBUG(
"eflowCaloObject has track match with E, pt and eta " << thisTrack->
e() <<
", " << thisTrack->
pt() <<
" and " << thisTrack->
eta());
163 }
164 }
165
166 ATH_MSG_DEBUG(
"About to perform subtraction for this eflowCaloObject");
167
168 bool wasAnnihilated = false;
169
170
172
173 if (
canAnnihilate(expectedEnergy, expectedSigma, clusterEnergy)){
174
175 wasAnnihilated = true;
176
177 std::vector<std::pair<xAOD::CaloCluster *, bool>> clusterList;
178 std::map<xAOD::CaloCluster *, double> clusterEnergyMap;
179 unsigned nCluster = thisEflowCaloObject.
nClusters();
180 for (unsigned iCluster = 0; iCluster < nCluster; ++iCluster){
182 }
183
184 ATH_MSG_DEBUG(
"We are going to annihilate. ExpectedEnergy, expectedSigma and clusterEnergy are " << expectedEnergy <<
", " << expectedSigma <<
" and " << clusterEnergy);
185 if (msgLevel(MSG::DEBUG))
186 for (auto thisPair : clusterList)
187 ATH_MSG_DEBUG(
"Annihilating cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
188
190
191
193
195
196 if (msgLevel(MSG::DEBUG))
197 for (auto thisPair : clusterList)
198 ATH_MSG_DEBUG(
"Have Annihilated cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
199
200
201 for (
unsigned iTrack = 0; iTrack < thisEflowCaloObject.
nTracks(); ++iTrack){
202 eflowRecTrack *thisEfRecTrack = (matchedTrackList[iTrack].first)->getTrack();
204 }
205
206 }
207 }
209
210 for (
unsigned iTrack = 0; iTrack < thisEflowCaloObject.
nTracks(); ++iTrack){
211
212 eflowRecTrack *thisEfRecTrack = thisEflowCaloObject.
efRecTrack(iTrack);
213
216
217 if (!thisEfRecTrack->
hasBin())
continue;
218
220
222
223 ATH_MSG_DEBUG(
"Am not in dense environment for this eflowCaloObject");
224
225
226 std::vector<eflowRecCluster *> matchedClusters;
228 matchedClusters.reserve(
links.size());
229 for (auto* thisEFlowTrackClusterLink : links)
230 matchedClusters.push_back(thisEFlowTrackClusterLink->getCluster());
233 matchedClusters.end(),
234 eflowRecCluster::SortDescendingPt());
235
236 if (msgLvl(MSG::DEBUG)) {
237 for (auto* thisClus : matchedClusters)
239 "Haved matched cluster "
240 << thisClus->getCluster()->index() << " with e,pt, eta and phi of "
241 << thisClus->getCluster()->e() << ", "
242 << thisClus->getCluster()->pt() << ", "
243 << thisClus->getCluster()->eta() << " and "
244 << thisClus->getCluster()->phi() << " will be subtracted");
245 }
246
247
248 std::vector<std::pair<xAOD::CaloCluster *, bool>> clusterSubtractionList;
249 clusterSubtractionList.reserve(matchedClusters.size());
250 std::map<xAOD::CaloCluster *, double> clusterEnergyMap;
251 for (auto *thisEFlowRecCluster : matchedClusters){
253 clusterSubtractionList.emplace_back(thisCluster, false);
254 clusterEnergyMap[thisCluster] = thisCluster->
e();
255 }
256
257 ATH_MSG_DEBUG(
"Have filled clusterSubtractionList for this eflowCaloObject");
258
259 unsigned int trackIndex = thisEfRecTrack->
getTrack()->index();
260
261
262 auto sumClusEnergy = [](double accumulator, std::pair<xAOD::CaloCluster *, bool> thisPair){ return accumulator += thisPair.first->e();};
263 double totalClusterEnergy = std::accumulate(clusterSubtractionList.begin(),clusterSubtractionList.end(),0.0,sumClusEnergy);
264
265
267
268 if (msgLevel(MSG::DEBUG))
269 for (auto thisPair : clusterSubtractionList)
270 ATH_MSG_DEBUG(
"Annihilating cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
271
272
274
276
277
278 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
280 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
281 }
282 else
283 {
284
285
287
288
289 totalClusterEnergy = std::accumulate(clusterSubtractionList.begin(),clusterSubtractionList.end(),0.0,sumClusEnergy);
290
291
293
294 if (msgLevel(MSG::DEBUG))
295 for (auto thisPair : clusterSubtractionList){
296 ATH_MSG_DEBUG(
"Annihilating remnant cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
297 }
299
300 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
302 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
303 }
304 else
305 {
306 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
308 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
309 }
310
311 }
312
313 ATH_MSG_DEBUG(
"Have subtracted charged shower for this eflowRecTrack");
314
315
317
318 }
319 }
320
321}
double getExpectedVariance() const
double getClusterEnergy() const
unsigned nClusters() const
const std::vector< std::pair< eflowTrackClusterLink *, std::pair< float, float > > > & efRecLink() const
double getExpectedEnergy() const
const eflowRecCluster * efRecCluster(int i) const
xAOD::CaloCluster * getCluster()
double getEExpect() const
const std::vector< eflowTrackClusterLink * > & getClusterMatches() const
bool isSubtracted() const
const xAOD::TrackParticle * getTrack() const
bool isInDenseEnvironment() const
double getVarEExpect() const
static void annihilateClusters(std::vector< std::pair< xAOD::CaloCluster *, bool > > &clusters)
virtual double e() const
The total energy of the particle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual double e() const override final
The total energy of the particle.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
TrackParticle_v1 TrackParticle
Reference the current persistent version: