ATLAS Offline Software
Loading...
Searching...
No Matches
PFUnifiedMatchingTool Class Reference

#include <PFUnifiedMatchingTool.h>

Inheritance diagram for PFUnifiedMatchingTool:
Collaboration diagram for PFUnifiedMatchingTool:

Public Member Functions

 PFUnifiedMatchingTool (const std::string &type, const std::string &name, const IInterface *parent)
 ~PFUnifiedMatchingTool ()
virtual StatusCode initialize () override
virtual StatusCode processPFlowData (const EventContext &ctx, PFData &thePFData) const override

Protected Member Functions

virtual unsigned int matchAndCreateEflowCaloObj (const EventContext &ctx, PFData &data) const
 This matches ID tracks and CaloClusters, and then creates eflowCaloObjects.
void printAllClusters (const std::vector< eflowRecCluster * > &recClusterVector) const

Static Protected Member Functions

static std::string printTrack (const xAOD::TrackParticle *track)
static std::string printCluster (const xAOD::CaloCluster *cluster)

Protected Attributes

ToolHandle< IEFlowCellEOverPToolm_theEOverPTool {this, "eflowCellEOverPTool", "eflowCellEOverPTool", "Energy Flow E/P Values and Shower Parameters Tool"}
 Tool for getting e/p values and hadronic shower cell ordering principle parameters.
std::unique_ptr< eflowEEtaBinnedParametersm_binnedParameters
std::unique_ptr< PFMatch::TrackEtaPhiInFixedLayersProviderm_trkpos
 Track position provider to be used to preselect clusters.
ToolHandle< PFTrackClusterMatchingToolm_theMatchingTool {this, "PFTrackClusterMatchingTool", "PFTrackClusterMatchingTool/CalObjBldMatchingTool", "The track-cluster matching tool"}
 Default track-cluster matching tool.
ToolHandle< PFTrackClusterMatchingToolm_theMatchingToolForPull_015 {this, "PFTrackClusterMatchingTool_015", "PFTrackClusterMatchingTool/PFPullMatchingTool_015", "The 0.15 track-cluster matching tool to calculate the pull"}
ToolHandle< PFTrackClusterMatchingToolm_theMatchingToolForPull_02 {this, "PFTrackClusterMatchingTool_02", "PFTrackClusterMatchingTool/PFPullMatchingTool_02", "The 0.2 track-cluster matching tool to calculate the pull"}
Gaudi::Property< bool > m_recoverSplitShowers {this,"RecoverSplitShowers",false,"Toggle whether we are recovering split showers or not"}
 Toggle whether we are recovering split showers or not.
Gaudi::Property< int > m_nClusterMatchesToUse {this, "nClusterMatchesToUse", 1, "Number of clusters to match to each track"}
 Number of clusters to match to each track if not doing recover split shower subtraction.
Gaudi::Property< bool > m_addCPData {this,"addCPData",false,"Toggle whether to decorate FlowElements with additional data for Combined Performance studies "}
 Toggle whether to decorate eflowRecTrack with additional data for Combined Performance studies.
eflowSubtract::Subtractor m_subtractor {}
ToolHandle< PFEnergyPredictorToolm_NNEnergyPredictorTool {this, "NNEnergyPredictorTool", "","Tool for getting predictiing the energy using an ONNX model "}
 Tool for getting predictiing the energy using an ONNX model.
Gaudi::Property< bool > m_useNNEnergy {this, "useNNEnergy", false, "Toggle whether we use the neural net energy"}
 Toggle whether we use the neural net energy.
Gaudi::Property< bool > m_useLegacyEBinIndex {this, "useLegacyEBinIndex", true, "Toggle whether we use the legacy energy bin index"}
 Further discussion about why this flag exists can be found in https://its.cern.ch/jira/browse/ATLJETMET-1692 and https://indico.cern.ch/event/1388633/contributions/5837876/attachments/2809591/4903439/PFlow_EOverP_Feb2024.pdf The Jira report discusses assorted problems with the treatment of energy bin indexes for the lookup of e/p values.

Detailed Description

Definition at line 25 of file PFUnifiedMatchingTool.h.

Constructor & Destructor Documentation

◆ PFUnifiedMatchingTool()

PFUnifiedMatchingTool::PFUnifiedMatchingTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 28 of file PFUnifiedMatchingTool.cxx.

28 : base_class(type, name, parent),
29 m_binnedParameters(std::make_unique<eflowEEtaBinnedParameters>())
30{
31}
std::unique_ptr< eflowEEtaBinnedParameters > m_binnedParameters

◆ ~PFUnifiedMatchingTool()

PFUnifiedMatchingTool::~PFUnifiedMatchingTool ( )
default

Member Function Documentation

◆ initialize()

StatusCode PFUnifiedMatchingTool::initialize ( )
overridevirtual

Reimplemented in PFUnifiedMatchingTruthTool.

Definition at line 36 of file PFUnifiedMatchingTool.cxx.

37{
38
39 ATH_CHECK(m_theEOverPTool.retrieve());
40
41 ATH_CHECK(m_theEOverPTool->fillBinnedParameters(m_binnedParameters.get()));
42
43 m_trkpos.reset(dynamic_cast<PFMatch::TrackEtaPhiInFixedLayersProvider *>(PFMatch::TrackPositionFactory::Get("EM2EtaPhi").release()));
44 if (!m_trkpos)
45 {
46 ATH_MSG_ERROR("Failed to get TrackPositionProvider for cluster preselection!");
47 return StatusCode::FAILURE;
48 }
49
50 //Retrieve track-cluster matching tools
51 ATH_CHECK(m_theMatchingTool.retrieve());
54
55 return StatusCode::SUCCESS;
56
57}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
static std::unique_ptr< IPositionProvider > Get(const std::string &positionType)
ToolHandle< PFTrackClusterMatchingTool > m_theMatchingToolForPull_015
ToolHandle< IEFlowCellEOverPTool > m_theEOverPTool
Tool for getting e/p values and hadronic shower cell ordering principle parameters.
ToolHandle< PFTrackClusterMatchingTool > m_theMatchingToolForPull_02
std::unique_ptr< PFMatch::TrackEtaPhiInFixedLayersProvider > m_trkpos
Track position provider to be used to preselect clusters.
ToolHandle< PFTrackClusterMatchingTool > m_theMatchingTool
Default track-cluster matching tool.
static std::string release
Definition computils.h:50

◆ matchAndCreateEflowCaloObj()

unsigned int PFUnifiedMatchingTool::matchAndCreateEflowCaloObj ( const EventContext & ctx,
PFData & data ) const
protectedvirtual

This matches ID tracks and CaloClusters, and then creates eflowCaloObjects.

No point to do anything if e/p reference bin does not exist

Add cluster matches needed for pull calculation (in eflowCaloObject::simulateShowers) which is used to determine whether to run the charged shower subtraction or not. / Clusters in both a cone of 0.15 and 0.2 are needed for this. / The clusters in a cone of 0.2 are also used as the matched cluster list for recover split showers mode.

Reimplemented in PFUnifiedMatchingTruthTool.

Definition at line 98 of file PFUnifiedMatchingTool.cxx.

98 {
99
100 //Counts up how many tracks found at least 1 calorimeter cluster matched to it.
101 unsigned int nMatches(0);
102
103 /* Cache the original number of eflowCaloObjects, if there were any */
104 const unsigned int nCaloObj = data.caloObjects->size();
105
106 /* loop tracks in data.tracks and do matching */
107 for (auto *thisEfRecTrack : data.tracks)
108 {
110 if (!thisEfRecTrack->hasBin()) {
111 std::unique_ptr<eflowCaloObject> thisEflowCaloObject = std::make_unique<eflowCaloObject>();
112 thisEflowCaloObject->addTrack(thisEfRecTrack);
113 data.caloObjects->push_back(std::move(thisEflowCaloObject));
114 continue;
115 }
116
117 if (msgLvl(MSG::DEBUG))
118 {
119 const xAOD::TrackParticle *track = thisEfRecTrack->getTrack();
120 ATH_MSG_DEBUG("Matching track with e,pt, eta and phi " << track->e() << ", " << track->pt() << ", " << track->eta() << " and " << track->phi());
121 }
122
123 std::vector<eflowTrackClusterLink*> bestClusters;
124 std::vector<float> deltaRPrime;
125
131 std::vector<std::pair<eflowRecCluster *, float>> bestClusters_02 = m_theMatchingToolForPull_02->doMatches(thisEfRecTrack, data.clusters, -1);
132 for (auto &matchpair : bestClusters_02)
133 {
134 eflowRecCluster *theCluster = matchpair.first;
135 float distancesq = matchpair.second;
136 eflowTrackClusterLink *trackClusterLink = eflowTrackClusterLink::getInstance(thisEfRecTrack, theCluster, ctx);
137 if (distancesq < 0.15 * 0.15)
138 {
139 // Narrower cone is a subset of the selected clusters
140 // Distance returned is deltaR^2
141 static const std::string cone15Str{"cone_015"};
142 thisEfRecTrack->addAlternativeClusterMatch(trackClusterLink, cone15Str);
143 }
144 static const std::string cone2Str{"cone_02"};
145 thisEfRecTrack->addAlternativeClusterMatch(trackClusterLink, cone2Str);
146 }//loop over bestClusters_02
147
148 //This matching scheme is used to match the calorimeter cluster(s) to be used in the charged showers subtraction for this track.
149 std::vector<std::pair<eflowRecCluster *, float>> matchedClusters = m_theMatchingTool->doMatches(thisEfRecTrack, data.clusters,m_nClusterMatchesToUse);
150 for (auto thePair : matchedClusters) {
151 bestClusters.push_back(eflowTrackClusterLink::getInstance(thisEfRecTrack, thePair.first, ctx));
152 if (m_addCPData) deltaRPrime.push_back(std::sqrt(thePair.second));
153 }
154 }
155 else {
156 const std::vector<eflowTrackClusterLink*>* matchedClusters_02 = thisEfRecTrack->getAlternativeClusterMatches("cone_02");
157 if (!matchedClusters_02) continue;
158 else bestClusters = *matchedClusters_02;
159 }
160
161 if (bestClusters.empty()) continue;
162
163 if (msgLvl(MSG::DEBUG))
164 {
165 for (auto *thisClusterLink : bestClusters ) {
166 xAOD::CaloCluster* thisCluster = thisClusterLink->getCluster()->getCluster();
167 ATH_MSG_DEBUG("Matched this track to cluster with e,pt, eta and phi " << thisCluster->e() << ", " << thisCluster->pt() << ", " << thisCluster->eta() << " and " << thisCluster->phi());
168 }
169 }
170
171 nMatches++;
172
173 //loop over the matched calorimeter clusters and associate tracks and clusters to each other as needed.
174 unsigned int linkIndex = 0;
175 for (auto *trkClusLink : bestClusters){
176
177 eflowRecCluster *thisEFRecCluster = trkClusLink->getCluster();
178
180 // Look up whether this cluster is intended for recovery
181 if (std::find(data.clusters.begin(), data.clusters.end(), trkClusLink->getCluster()) == data.clusters.end()) {
182 linkIndex++;
183 continue;
184 }
185 }
186
187 eflowTrackClusterLink *trackClusterLink = eflowTrackClusterLink::getInstance(thisEfRecTrack, thisEFRecCluster, ctx);
188 thisEfRecTrack->addClusterMatch(trackClusterLink);
189 if (m_addCPData) {
190 thisEfRecTrack->addDeltaRPrime(deltaRPrime[linkIndex]);
191 }
192 thisEFRecCluster->addTrackMatch(trackClusterLink);
193 }
194 linkIndex++;
195 }
196
197 /* Create 3 types eflowCaloObjects: track-only, cluster-only, track-cluster-link */
198 std::vector<eflowRecCluster *> clusters(data.clusters.begin(), data.clusters.end());
199 if (m_recoverSplitShowers) std::sort(clusters.begin(), clusters.end(), eflowRecCluster::SortDescendingPt());
200 unsigned int nCaloObjects = eflowCaloObjectMaker::makeTrkCluCaloObjects(data.tracks, clusters, data.caloObjects);
201 ATH_MSG_DEBUG("Created " << nCaloObjects << " eflowCaloObjects.");
202 if (msgLvl(MSG::DEBUG)){
203 for (auto thisEFlowCaloObject : *(data.caloObjects)){
204 ATH_MSG_DEBUG("This eflowCaloObject has " << thisEFlowCaloObject->nTracks() << " tracks and " << thisEFlowCaloObject->nClusters() << " clusters ");
205 for (unsigned int count = 0; count < thisEFlowCaloObject->nTracks(); count++){
206 const xAOD::TrackParticle* thisTrack = thisEFlowCaloObject->efRecTrack(count)->getTrack();
207 ATH_MSG_DEBUG("Have track with e, pt, eta and phi of " << thisTrack->e() << ", " << thisTrack->pt() << ", " << thisTrack->eta() << " and " << thisTrack->phi());
208 }
209 for (unsigned int count = 0; count < thisEFlowCaloObject->nClusters(); count++){
210 const xAOD::CaloCluster* thisCluster = thisEFlowCaloObject->efRecCluster(count)->getCluster();
211 ATH_MSG_DEBUG("Have cluster with e, pt, eta and phi of " << thisCluster->e() << ", " << thisCluster->pt() << ", " << thisCluster->eta() << " and " << thisCluster->phi());
212 }
213 }
214 }
215
216 if (!m_recoverSplitShowers) return nMatches;
217 else return nCaloObj;
218}
#define ATH_MSG_DEBUG(x)
Gaudi::Property< bool > m_recoverSplitShowers
Toggle whether we are recovering split showers or not.
Gaudi::Property< int > m_nClusterMatchesToUse
Number of clusters to match to each track if not doing recover split shower subtraction.
Gaudi::Property< bool > m_addCPData
Toggle whether to decorate eflowRecTrack with additional data for Combined Performance studies.
static unsigned int makeTrkCluCaloObjects(eflowRecTrackContainer *eflowTrackContainer, eflowRecClusterContainer *eflowClusterContainer, eflowCaloObjectContainer *caloObjectContainer)
void addTrackMatch(eflowTrackClusterLink *trackMatch)
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters).
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
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.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
@ linkIndex
link index for multiple track and vertex matches
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ printAllClusters()

void PFUnifiedMatchingTool::printAllClusters ( const std::vector< eflowRecCluster * > & recClusterVector) const
protected

Definition at line 233 of file PFUnifiedMatchingTool.cxx.

233 {
234
235 for ( const auto *thisEFRecCluster : recClusterVector){
236 if (thisEFRecCluster->getTrackMatches().empty()) {
237 ATH_MSG_DEBUG("Isolated" << printCluster(thisEFRecCluster->getCluster()));
238 } else {
239 ATH_MSG_DEBUG("Matched" << printCluster(thisEFRecCluster->getCluster()));
240 std::vector<eflowTrackClusterLink*> theTrackLinks = thisEFRecCluster->getTrackMatches();
241 for ( auto *thisTrack : theTrackLinks){
242 ATH_MSG_DEBUG("Matched" << printTrack(thisTrack->getTrack()->getTrack()));
243 }
244 }
245 }
246}
static std::string printTrack(const xAOD::TrackParticle *track)
static std::string printCluster(const xAOD::CaloCluster *cluster)

◆ printCluster()

std::string PFUnifiedMatchingTool::printCluster ( const xAOD::CaloCluster * cluster)
staticprotected

Definition at line 227 of file PFUnifiedMatchingTool.cxx.

227 {
228 std::stringstream result;
229 result << " cluster with E, eta and phi of " << cluster->e() << ", " << cluster->eta() << " and " << cluster->phi();
230 return result.str();
231}

◆ printTrack()

std::string PFUnifiedMatchingTool::printTrack ( const xAOD::TrackParticle * track)
staticprotected

Definition at line 221 of file PFUnifiedMatchingTool.cxx.

221 {
222 std::stringstream result;
223 result << " track with E, eta and phi "<< track->e() << ", " << track->eta() << " and " << track->phi();
224 return result.str();
225}

◆ processPFlowData()

StatusCode PFUnifiedMatchingTool::processPFlowData ( const EventContext & ctx,
PFData & thePFData ) const
overridevirtual

Definition at line 59 of file PFUnifiedMatchingTool.cxx.

63{
64
65 if (!data.caloObjects) {
66 ATH_MSG_ERROR("PFData::caloObjects is null; caller must set it before invoking the matching tool");
67 return StatusCode::FAILURE;
68 }
69
70 ATH_MSG_DEBUG("Executing");
71
73 // reset tracks in data and refill only with those needed for split showers
74 data.tracks.clear();
76 }
77
79 // reset clusters in data and refill only with those needed for split showers
80 data.clusters.clear();
82 }
83
84 ATH_MSG_DEBUG("This event has " << data.tracks.size() << " tracks " << data.clusters.size() << " clusters ");
85
86 if (msgLvl(MSG::DEBUG)) printAllClusters(data.clusters);
87
88 unsigned int numMatches = matchAndCreateEflowCaloObj(ctx, data);
89
90 // store numMatches for later use in subtraction tool
91 if (m_recoverSplitShowers) data.nOrigCaloObj = numMatches;
92 else data.nMatches = numMatches;
93
94
95 return StatusCode::SUCCESS;
96}
static void fillClustersToRecover(PFData &data)
static void fillTracksToRecover(PFData &data)
void printAllClusters(const std::vector< eflowRecCluster * > &recClusterVector) const
virtual unsigned int matchAndCreateEflowCaloObj(const EventContext &ctx, PFData &data) const
This matches ID tracks and CaloClusters, and then creates eflowCaloObjects.

Member Data Documentation

◆ m_addCPData

Gaudi::Property<bool> PFUnifiedMatchingTool::m_addCPData {this,"addCPData",false,"Toggle whether to decorate FlowElements with additional data for Combined Performance studies "}
protected

Toggle whether to decorate eflowRecTrack with additional data for Combined Performance studies.

Definition at line 69 of file PFUnifiedMatchingTool.h.

69{this,"addCPData",false,"Toggle whether to decorate FlowElements with additional data for Combined Performance studies "};

◆ m_binnedParameters

std::unique_ptr<eflowEEtaBinnedParameters> PFUnifiedMatchingTool::m_binnedParameters
protected

Definition at line 50 of file PFUnifiedMatchingTool.h.

◆ m_nClusterMatchesToUse

Gaudi::Property<int> PFUnifiedMatchingTool::m_nClusterMatchesToUse {this, "nClusterMatchesToUse", 1, "Number of clusters to match to each track"}
protected

Number of clusters to match to each track if not doing recover split shower subtraction.

Definition at line 66 of file PFUnifiedMatchingTool.h.

66{this, "nClusterMatchesToUse", 1, "Number of clusters to match to each track"};

◆ m_NNEnergyPredictorTool

ToolHandle<PFEnergyPredictorTool> PFUnifiedMatchingTool::m_NNEnergyPredictorTool {this, "NNEnergyPredictorTool", "","Tool for getting predictiing the energy using an ONNX model "}
protected

Tool for getting predictiing the energy using an ONNX model.

Definition at line 75 of file PFUnifiedMatchingTool.h.

75{this, "NNEnergyPredictorTool", "","Tool for getting predictiing the energy using an ONNX model "};

◆ m_recoverSplitShowers

Gaudi::Property<bool> PFUnifiedMatchingTool::m_recoverSplitShowers {this,"RecoverSplitShowers",false,"Toggle whether we are recovering split showers or not"}
protected

Toggle whether we are recovering split showers or not.

Definition at line 63 of file PFUnifiedMatchingTool.h.

63{this,"RecoverSplitShowers",false,"Toggle whether we are recovering split showers or not"};

◆ m_subtractor

eflowSubtract::Subtractor PFUnifiedMatchingTool::m_subtractor {}
protected

Definition at line 72 of file PFUnifiedMatchingTool.h.

72{};

◆ m_theEOverPTool

ToolHandle<IEFlowCellEOverPTool> PFUnifiedMatchingTool::m_theEOverPTool {this, "eflowCellEOverPTool", "eflowCellEOverPTool", "Energy Flow E/P Values and Shower Parameters Tool"}
protected

Tool for getting e/p values and hadronic shower cell ordering principle parameters.

Definition at line 48 of file PFUnifiedMatchingTool.h.

48{this, "eflowCellEOverPTool", "eflowCellEOverPTool", "Energy Flow E/P Values and Shower Parameters Tool"};

◆ m_theMatchingTool

ToolHandle<PFTrackClusterMatchingTool> PFUnifiedMatchingTool::m_theMatchingTool {this, "PFTrackClusterMatchingTool", "PFTrackClusterMatchingTool/CalObjBldMatchingTool", "The track-cluster matching tool"}
protected

Default track-cluster matching tool.

Definition at line 56 of file PFUnifiedMatchingTool.h.

56{this, "PFTrackClusterMatchingTool", "PFTrackClusterMatchingTool/CalObjBldMatchingTool", "The track-cluster matching tool"};

◆ m_theMatchingToolForPull_015

ToolHandle<PFTrackClusterMatchingTool> PFUnifiedMatchingTool::m_theMatchingToolForPull_015 {this, "PFTrackClusterMatchingTool_015", "PFTrackClusterMatchingTool/PFPullMatchingTool_015", "The 0.15 track-cluster matching tool to calculate the pull"}
protected

Definition at line 59 of file PFUnifiedMatchingTool.h.

59{this, "PFTrackClusterMatchingTool_015", "PFTrackClusterMatchingTool/PFPullMatchingTool_015", "The 0.15 track-cluster matching tool to calculate the pull"};

◆ m_theMatchingToolForPull_02

ToolHandle<PFTrackClusterMatchingTool> PFUnifiedMatchingTool::m_theMatchingToolForPull_02 {this, "PFTrackClusterMatchingTool_02", "PFTrackClusterMatchingTool/PFPullMatchingTool_02", "The 0.2 track-cluster matching tool to calculate the pull"}
protected

Definition at line 60 of file PFUnifiedMatchingTool.h.

60{this, "PFTrackClusterMatchingTool_02", "PFTrackClusterMatchingTool/PFPullMatchingTool_02", "The 0.2 track-cluster matching tool to calculate the pull"};

◆ m_trkpos

std::unique_ptr<PFMatch::TrackEtaPhiInFixedLayersProvider> PFUnifiedMatchingTool::m_trkpos
protected

Track position provider to be used to preselect clusters.

Definition at line 53 of file PFUnifiedMatchingTool.h.

◆ m_useLegacyEBinIndex

Gaudi::Property<bool> PFUnifiedMatchingTool::m_useLegacyEBinIndex {this, "useLegacyEBinIndex", true, "Toggle whether we use the legacy energy bin index"}
protected

Further discussion about why this flag exists can be found in https://its.cern.ch/jira/browse/ATLJETMET-1692 and https://indico.cern.ch/event/1388633/contributions/5837876/attachments/2809591/4903439/PFlow_EOverP_Feb2024.pdf The Jira report discusses assorted problems with the treatment of energy bin indexes for the lookup of e/p values.

In order to not change the behaviour of produciton code a legacy option is introduced to allow us to fix the problem in future iterations of e/p derivations.s

Definition at line 85 of file PFUnifiedMatchingTool.h.

85{this, "useLegacyEBinIndex", true, "Toggle whether we use the legacy energy bin index"};

◆ m_useNNEnergy

Gaudi::Property<bool> PFUnifiedMatchingTool::m_useNNEnergy {this, "useNNEnergy", false, "Toggle whether we use the neural net energy"}
protected

Toggle whether we use the neural net energy.

Definition at line 78 of file PFUnifiedMatchingTool.h.

78{this, "useNNEnergy", false, "Toggle whether we use the neural net energy"};

The documentation for this class was generated from the following files: