288 {
289
291
292 unsigned int nClusters = thisEflowCaloObject.
nClusters();
293 unsigned int nTrackMatches = thisEflowCaloObject.
nTracks();
294
295 ATH_MSG_DEBUG(
"Have got an eflowCaloObject with " << nClusters <<
" clusters and " << nTrackMatches <<
" track matches");
296
297 if (msgLevel(MSG::DEBUG)){
298 for (unsigned int iTrack = 0; iTrack < nTrackMatches; ++iTrack){
299 eflowRecTrack* thisTrack = thisEflowCaloObject.
efRecTrack(iTrack);
301 }
302 }
303
304
306
307
308 if (nTrackMatches < 1) return;
309
313
314
316 if (
isEOverPFail(expectedEnergy, expectedSigma, clusterEnergy))
return;
317 }
318
319 const std::vector<std::pair<eflowTrackClusterLink *, std::pair<float, float>>> &matchedTrackList = thisEflowCaloObject.
efRecLink();
320
321 ATH_MSG_DEBUG(
"Matched Track List has size " << matchedTrackList.size());
322
323 if (msgLevel(MSG::DEBUG))
324 {
325 for (unsigned int iTrack = 0; iTrack < nTrackMatches; ++iTrack)
326 {
328 ATH_MSG_DEBUG(
"eflowCaloObject has track match with E, pt and eta " << thisTrack->
e() <<
", " << thisTrack->
pt() <<
" and " << thisTrack->
eta());
329 }
330 }
331
332 ATH_MSG_DEBUG(
"About to perform subtraction for this eflowCaloObject");
333
334 bool wasAnnihilated = false;
335
336
338
339 if (
canAnnihilate(expectedEnergy, expectedSigma, clusterEnergy)){
340
341 wasAnnihilated = true;
342
343 std::vector<std::pair<xAOD::CaloCluster *, bool>> clusterList;
344 std::map<xAOD::CaloCluster *, double> clusterEnergyMap;
345 unsigned nCluster = thisEflowCaloObject.
nClusters();
346 for (unsigned iCluster = 0; iCluster < nCluster; ++iCluster){
348 }
349
350 ATH_MSG_DEBUG(
"We are going to annihilate. ExpectedEnergy, expectedSigma and clusterEnergy are " << expectedEnergy <<
", " << expectedSigma <<
" and " << clusterEnergy);
351 if (msgLevel(MSG::DEBUG))
352 for (auto thisPair : clusterList)
353 ATH_MSG_DEBUG(
"Annihilating cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
354
356
357
359
361
362 if (msgLevel(MSG::DEBUG))
363 for (auto thisPair : clusterList)
364 ATH_MSG_DEBUG(
"Have Annihilated cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
365
366
367 for (
unsigned iTrack = 0; iTrack < thisEflowCaloObject.
nTracks(); ++iTrack){
368 eflowRecTrack *thisEfRecTrack = (matchedTrackList[iTrack].first)->getTrack();
370 }
371
372 }
373 }
375
376 for (
unsigned iTrack = 0; iTrack < thisEflowCaloObject.
nTracks(); ++iTrack){
377
378 eflowRecTrack *thisEfRecTrack = thisEflowCaloObject.
efRecTrack(iTrack);
379
382
383 if (!thisEfRecTrack->
hasBin())
continue;
384
386
388
389 ATH_MSG_DEBUG(
"Am not in dense environment for this eflowCaloObject");
390
391
392 std::vector<eflowRecCluster *> matchedClusters;
394 matchedClusters.reserve(
links.size());
395 for (auto* thisEFlowTrackClusterLink : links)
396 matchedClusters.push_back(thisEFlowTrackClusterLink->getCluster());
399 matchedClusters.end(),
400 eflowRecCluster::SortDescendingPt());
401
402 if (msgLvl(MSG::DEBUG)) {
403 for (auto* thisClus : matchedClusters)
405 "Haved matched cluster "
406 << thisClus->getCluster()->index() << " with e,pt, eta and phi of "
407 << thisClus->getCluster()->e() << ", "
408 << thisClus->getCluster()->pt() << ", "
409 << thisClus->getCluster()->eta() << " and "
410 << thisClus->getCluster()->phi() << " will be subtracted");
411 }
412
413
414 std::vector<std::pair<xAOD::CaloCluster *, bool>> clusterSubtractionList;
415 clusterSubtractionList.reserve(matchedClusters.size());
416 std::map<xAOD::CaloCluster *, double> clusterEnergyMap;
417 for (auto *thisEFlowRecCluster : matchedClusters){
419 clusterSubtractionList.emplace_back(thisCluster, false);
420 clusterEnergyMap[thisCluster] = thisCluster->
e();
421 }
422
423 ATH_MSG_DEBUG(
"Have filled clusterSubtractionList for this eflowCaloObject");
424
425 unsigned int trackIndex = thisEfRecTrack->
getTrack()->
index();
426
427
428 auto sumClusEnergy = [](double accumulator, std::pair<xAOD::CaloCluster *, bool> thisPair){ return accumulator += thisPair.first->e();};
429 double totalClusterEnergy = std::accumulate(clusterSubtractionList.begin(),clusterSubtractionList.end(),0.0,sumClusEnergy);
430
431
433
434 if (msgLevel(MSG::DEBUG))
435 for (auto thisPair : clusterSubtractionList)
436 ATH_MSG_DEBUG(
"Annihilating cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
437
438
440
442
443
444 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
446 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
447 }
448 else
449 {
450
451
453
454
455 totalClusterEnergy = std::accumulate(clusterSubtractionList.begin(),clusterSubtractionList.end(),0.0,sumClusEnergy);
456
457
459
460 if (msgLevel(MSG::DEBUG))
461 for (auto thisPair : clusterSubtractionList){
462 ATH_MSG_DEBUG(
"Annihilating remnant cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
463 }
465
466 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
468 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
469 }
470 else
471 {
472 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
474 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
475 }
476
477 }
478
479 ATH_MSG_DEBUG(
"Have subtracted charged shower for this eflowRecTrack");
480
481
483
484 }
485 }
486
487}
size_t index() const
Return the index of this element within its container.
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)