ATLAS Offline Software
Loading...
Searching...
No Matches
PFSubtractionStatusSetter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include "GaudiKernel/Bootstrap.h"
11
12#include <numeric>
13
15
16void
18 const std::vector<std::pair<xAOD::CaloCluster*, bool>>& clusterList,
19 std::vector<std::pair<float, float>>& clusterSubtractedEnergyRatios,
20 eflowCaloObject& thisEflowCaloObject,
21 unsigned int trackIndex) const
22{
23 // An eflowCaloObject may have one cluster and N tracks, and then one would
24 // have N eflowTrackClusterLink* for each track-cluster pair Hence there can
25 // be more entries in the track cluster link list due to duplication
26
27 ATH_MSG_DEBUG("Executing markSubtractionStatus and have clusterList of size " << clusterList.size() << ", clusterSubtractedEnergyRatios of size " << clusterSubtractedEnergyRatios.size() << " and trackIndex of " << trackIndex);
28
29 const std::vector<std::pair<eflowTrackClusterLink*, std::pair<float,float> > >& matchedTrackList = thisEflowCaloObject.efRecLink();
30
31 unsigned int clusCounter = 0;
32 for (auto thisClusterPair : clusterList){
33 xAOD::CaloCluster* thisCluster = thisClusterPair.first;
34 ATH_MSG_DEBUG("Cluster with e and eta " << thisCluster->e() << " and " << thisCluster->eta());
35 unsigned int counter = 0;
36 for (const auto & thisTrackClusterLinkPair : matchedTrackList){
37
38 if (trackIndex != thisTrackClusterLinkPair.first->getTrack()->getTrack()->index()){
39 counter++;
40 continue;
41 }
42
43 ATH_MSG_DEBUG("Track with e and eta " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->e() << " and " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->eta());
44
45 //if the subtraction status is already true, then no need to update it
46 if (!std::isnan(thisTrackClusterLinkPair.second.first)) {
47 counter++;
48 continue;
49 }
50
51 ATH_MSG_DEBUG("Not already subtracted");
52
53 //eflowTrackCluster link returns an eflowRecCluster pointer, which in turn returns an xAOD:;CaloCluster* pointer
54 xAOD::CaloCluster* thisMatchedTrackCluster = (thisTrackClusterLinkPair.first)->getCluster()->getCluster();
55 //Now we can do a pointer comparison of the two clusters to see if we have a match
56 ATH_MSG_DEBUG("Comparing clusters with energies " << thisCluster->e() << " and " << thisMatchedTrackCluster->e());
57 if (thisCluster == thisMatchedTrackCluster){
58 ATH_MSG_DEBUG("Passed cluster energy check");
59 if (thisClusterPair.second && !std::isnan(clusterSubtractedEnergyRatios[clusCounter].first)) {
60 ATH_MSG_DEBUG("Will set ratio to be " << clusterSubtractedEnergyRatios[clusCounter].first);
61 thisEflowCaloObject.setTrackClusterLinkSubtractionStatus(counter, clusterSubtractedEnergyRatios[clusCounter]);
62 }
63 }//if have a match of the cluster
64 counter++;
65 }//loop on track cluster link pairs
66 clusCounter++;
67 }//loop on cluster pair list
68}
69
70void
72 eflowCaloObject& thisEflowCaloObject) const
73{
74
75 ATH_MSG_DEBUG("Executing markAllTracksAnnihStatus");
76
77 const std::vector<std::pair<eflowTrackClusterLink*, std::pair<float,float> > >& matchedTrackList = thisEflowCaloObject.efRecLink();
78
79 auto accumulateTrackEnergy = [](float sum, std::pair<eflowTrackClusterLink*, std::pair<float,float> > thisPair){ return sum + thisPair.first->getTrack()->getTrack()->e();};
80 float totalTrackE = std::accumulate(matchedTrackList.begin(),matchedTrackList.end(),0.0,accumulateTrackEnergy);
81
82 unsigned int counter = 0;
83 for (const auto & thisTrackClusterLinkPair : matchedTrackList){
84 ATH_MSG_DEBUG("Track with e and eta " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->e() << " and " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->eta());
85 ATH_MSG_DEBUG("will annihilate cluster with e and eta " << thisTrackClusterLinkPair.first->getCluster()->getCluster()->e() << " and " << thisTrackClusterLinkPair.first->getCluster()->getCluster()->eta());
86 float trackEFraction = thisTrackClusterLinkPair.first->getTrack()->getTrack()->e()/totalTrackE;
87 //We set the subtracted energy to the cluster energy multiplied by the fraction of total matched track energy belonging to this track
88 //whilst the ratio of new to old enegry is set to 0.0
89 thisEflowCaloObject.setTrackClusterLinkSubtractionStatus(counter, std::pair(0.0,trackEFraction*thisTrackClusterLinkPair.first->getCluster()->getCluster()->e()));
90 counter++;
91 }
92}
93
#define ATH_MSG_DEBUG(x)
void markAllTracksAnnihStatus(eflowCaloObject &thisEflowCaloObject) const
Set the ratio of new to old cluster energy, to zero, for all cluster matched to all tracks attached t...
void markSubtractionStatus(const std::vector< std::pair< xAOD::CaloCluster *, bool > > &clusterList, std::vector< std::pair< float, float > > &clusterSubtractedEnergyRatios, eflowCaloObject &thisEflowCaloObject, unsigned int trackIndex) const
Set the ratio of new to old cluster energy for each cluster matched to a track with trackIndex.
AsgMessaging(const std::string &name)
Constructor with a name.
An internal EDM object which stores information about systems of associated tracks and calorimeter cl...
void setTrackClusterLinkSubtractionStatus(unsigned int index, std::pair< float, float > energyRatio_energyValPair)
const std::vector< std::pair< eflowTrackClusterLink *, std::pair< float, float > > > & efRecLink() const
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.