ATLAS Offline Software
Loading...
Searching...
No Matches
IsolationCloseByCorrectionTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
5#ifndef IsolationSelection_IsolationCloseByCorrectionTool_H
6#define IsolationSelection_IsolationCloseByCorrectionTool_H
7
10#include <AsgTools/AsgTool.h>
12#include <AsgTools/ToolHandle.h>
14#ifndef XAOD_ANALYSIS
18#endif
19
25
26
35
36namespace CP {
38 public:
44
45 using caloDecorNames = std::array<std::string, 4>;
47 static const caloDecorNames& caloDecors();
48 static const caloDecorNames& pflowDecors();
49
50 using IsoHelperMap = std::map<IsoType, std::unique_ptr<IsoVariableHelper>>;
51
52 IsolationCloseByCorrectionTool(const std::string& name);
53 // Proper constructor for athena
55
56 virtual StatusCode initialize() override;
57
58 virtual CorrectionCode getCloseByCorrection(std::vector<float>& corrections, const xAOD::IParticle& par,
59 const std::vector<xAOD::Iso::IsolationType>& types,
60 const xAOD::IParticleContainer& closePar) const override;
61
62 virtual asg::AcceptData acceptCorrected(const xAOD::IParticle& x, const xAOD::IParticleContainer& closePar) const override;
63
65 const EventContext& ctx,
66 const xAOD::ElectronContainer* Electrons,
68 const xAOD::PhotonContainer* Photons) const override;
69
70 virtual float getOriginalIsolation(const xAOD::IParticle& P, IsoType type) const override;
71 virtual float getOriginalIsolation(const xAOD::IParticle* particle, IsoType type) const override;
72
74 TrackSet getTrackCandidates(const EventContext& ctx, const xAOD::IParticle* particle) const override;
75
76 const xAOD::IParticle* isoRefParticle(const xAOD::IParticle* particle) const override;
77
78 void associateCluster(const xAOD::IParticle* particle, float& eta, float& phi, float& energy) const override;
79
80 void associateFlowElement(const EventContext& ctx, const xAOD::IParticle* particle, float& eta, float& phi,
81 float& energy) const override;
82
84 using PrimaryCollection = std::set<const xAOD::IParticle*>;
95
96 private:
98 void isoTypesFromWP(const std::vector<std::unique_ptr<IsolationWP>>& WP, IsoVector& types);
104 void getAssocFlowElements(const EventContext& ctx, ObjectCache& cache) const;
105
106 // Function to pipe each container given by the interfaces through. It loops over all
107 // particles and removes the isolation overlap between the objects
108 CorrectionCode performCloseByCorrection (const EventContext& ctx, ObjectCache& cache) const;
109
110 // Lock decorations that we produced.
111 void lockDecorations (const xAOD::IParticleContainer* parts,
112 const IsoVector& isoTypes) const;
113
114 // Helper function to obtain the isolation cones to use for a given particle
115 const IsoVector& getIsolationTypes(const xAOD::IParticle* particle) const;
116
117 // Functions to perfrom the isolation correction directly
118 CorrectionCode subtractCloseByContribution(const EventContext& ctx, const xAOD::IParticle* P, ObjectCache& cache) const;
119 // Remove close-by tracks from the track isolation variables
120 CorrectionCode getCloseByCorrectionTrackIso(const xAOD::IParticle* primary, const IsoType type, const ObjectCache& cache,
121 float& isoValue) const;
122 // Remove close-by calo clusters from the topo et isolation variables
123 CorrectionCode getCloseByCorrectionTopoIso(const EventContext& ctx, const xAOD::IParticle* primary, const IsoType type,
124 ObjectCache& cache, float& isoValue) const;
125 // Remove close-by flow elements from the neflow isolation variables
126 CorrectionCode getCloseByCorrectionPflowIso(const EventContext& ctx, const xAOD::IParticle* primary, const IsoType type,
127 const ObjectCache& cache, float& isoValue) const;
128 // For primary particles not selected, copy isolation value to output decorator
130
131
133 ClusterSet getAssociatedClusters(const EventContext& ctx, const xAOD::IParticle* particle,
134 ObjectCache& cache) const;
136 PflowSet getAssocFlowElements(const EventContext& ctx, const xAOD::IParticle* particle) const;
137
138#ifndef XAOD_ANALYSIS
140 bool getExtrapEtaPhi(const EventContext& ctx, const xAOD::TrackParticle* tp, float& eta, float& phi) const;
141#endif
142
143 // Returns the Size of the Isolation cone
144 float coneSize(const xAOD::IParticle* particle, IsoType Cone) const;
145 // Retrieves the uncalibrated pt from the particle
146 float unCalibPt(const xAOD::IParticle* particle) const;
147
148 // Clusters and tracks of particles surviving the selection quality
149 // are considered for corrections
150 bool passSelectionQuality(const xAOD::IParticle* particle) const;
151
154 bool passFirstStage(const xAOD::TrackParticle* trk, const xAOD::Vertex* vtx) const;
155
157
158 public:
159 // Extrapolated phi eta needed for proper dR of the muons
160 void getExtrapEtaPhi(const xAOD::IParticle* particlear, float& eta, float& phi) const;
162 void loadPrimaryParticles(const xAOD::IParticleContainer* container, ObjectCache& cache) const;
164 void loadAssociatedObjects(const EventContext& ctx, ObjectCache& cache) const;
165
166 // Some helper functions for Overlap and DeltaR
167 bool isSame(const xAOD::IParticle* particle, const xAOD::IParticle* particle1) const;
168 bool overlap(const xAOD::IParticle* particle, const xAOD::IParticle* particle1, float dR) const;
169 float deltaR2(const xAOD::IParticle* particle, const xAOD::IParticle* particle1, bool AvgCalo = false) const;
170
171 // Fixed cone size isolation variables
173 // Any trackisolation variable with variable con size
175
177 // PtVarcones of the pile-up robust isolation variables
179 // Any track isolation variable
181 // Pileup robust track isolation variables
183 // The pile-up robust isolation cones only accept
184 // tracks with a minimum pt requirement
186
188
190
191 static bool isEgamma(const xAOD::IParticle* particle);
192
193 const xAOD::Vertex* retrieveIDBestPrimaryVertex(const EventContext& ctx) const;
194
195
196
197 static float clusterEtMinusTile(const xAOD::CaloCluster* C);
198
199 static std::string particleName(const xAOD::IParticle* C);
200 static std::string particleName(xAOD::Type::ObjectType T);
201
202 private:
203 // IMPORTANT USER PROPERTIES
204 ToolHandle<InDet::IInDetTrackSelectionTool> m_trkselTool{
205 this, "TrackSelectionTool", "", "TrackSelectionTool to select tracks which made it actually into the isolation"};
206 ToolHandle<CP::ITrackVertexAssociationTool> m_ttvaTool{this, "TTVASelectionTool", "",
207 "TTVASelectionTool to correct for the pile-up robust WPs"};
208 ToolHandle<CP::IIsolationSelectionTool> m_selectorTool{this, "IsolationSelectionTool", "",
209 "Please give me your configured IsolationSelectionTool!"};
210
211 // OPTIONAL PROPERTIES
212 // Name of the isolation selection and input quality decorators
213 Gaudi::Property<std::string> m_quality_name{
214 this, "SelectionDecorator", "",
215 "Name of the char auxdata defining whether the particle shall be considered for iso correction"};
216 Gaudi::Property<std::string> m_passOR_name{this, "PassoverlapDecorator", "",
217 "Does the particle also need to pass the overlap removal?"};
218 Gaudi::Property<std::string> m_isoSelection_name{this, "IsolationSelectionDecorator", "", "Name of the final isolation decorator."};
219
220 Gaudi::Property<std::string> m_backup_prefix{
221 this, "BackupPrefix", "", "Prefix in front of the isolation variables, if the original cone values need to be backuped"};
222
223 Gaudi::Property<std::string> m_isoDecSuffix{
224 this, "IsoDecSuffix", "", "Suffix added to output isolation variable names for close by corrections"};
225 Gaudi::Property<std::string> m_caloDecSuffix{
226 this, "CaloDecSuffix", "", "Suffix added to output cluster variable names for close by corrections"};
227
229 Gaudi::Property<int> m_caloModel{this, "CaloCorrectionModel", TopoConeCorrectionModel::SubtractObjectsDirectly};
230 // The core of the topoEt variables. Clusters within the core shall not be
231 // added to the isolation of the object itself. They are defined to be associated with it.
232 Gaudi::Property<float> m_coreConeEl{this, "CoreConeElectrons", 0.1,
233 "This is the size of the core cone for the topoetcone variables."};
234
235 // Muons have half of the cone-size compared to electrons
236 // (c.f. https://gitlab.cern.ch/atlas/athena/blob/21.2/Reconstruction/RecoTools/IsolationTool/Root/CaloIsolationTool.cxx#L82)
237 Gaudi::Property<float> m_coreConeMu{this, "CoreConeMuons", 0.05, "This is the size of the core cone for the topoetcone variables."};
238
239 // Reference value to calculate the size of the mini-iso variables
240 // dR = min (fixed , m_ptvarcone / particle->pt())
241 Gaudi::Property<float> m_ptvarconeRadius{this, "PtvarconeRadius", 1.e4, "This is the kT parameter for the ptvarcone variables."};
242
243 // Upper limit on the energy fraction of the close-by cluster
244 // to the isolation variable such that it is still subtracted from the cone.
245 // Only considered if the particle to correct is not an Egamma object. Since the reference
246 // position is extrapolated from the ID-track into the calorimeter.
247 // Aim of the game -> Find out whether it might contributed
248 Gaudi::Property<float> m_maxTopoPolution{
249 this, "MaxClusterFrac", 1.1,
250 "Maximum energy fraction a single cluster can make up to be considered as contributed to the isolation"};
251
252 Gaudi::Property<float> m_ConeSizeVariation{
253 this, "ExtrapolationConeSize", 1.2,
254 "Constant factor to be multiplied on top of the topo-etcone size if the reference particle is not a calorimeter particle in "
255 "order to account for extrapolation effects"}; // Extend - shrink the cone size to account for extrapolation effects
256
257 Gaudi::Property<bool> m_declareCaloDecors{this, "declareCaloDecors", false, "If set to true, the data dependency on the calo/pflow decors will be declared"};
261#ifndef XAOD_ANALYSIS
262 Gaudi::Property<std::vector<std::string>> m_elecKeys{
263 this, "EleContainers", {}, "Pipe the list of electron containers given later to the tool"};
264 Gaudi::Property<std::vector<std::string>> m_muonKeys{
265 this, "MuoContainers", {}, "Pipe the list of muon containers given later to the tool"};
266 Gaudi::Property<std::vector<std::string>> m_photKeys{
267 this, "PhoContainers", {}, "Pipe the list of photon containers given later to the tool"};
269 this, "IsoVarKeys", {}, "The list is filled during the initialization"};
271 this, "IsoWriteDecVarKeys", {}, "The list is filled during the initialization"};
272
274 ToolHandle<Trk::IParticleCaloExtensionTool> m_caloExtTool {this, "ParticleCaloExtensionTool", "Trk::ParticleCaloExtensionTool/ParticleCaloExtensionTool"};
275
277 void declareDependency(const std::vector<std::string>& containers, const IsoVector& types);
278#endif
279
280 SG::ReadHandleKey<xAOD::VertexContainer> m_VtxKey{this, "VertexContainer", "PrimaryVertices",
281 "Name of the primary vertex container"};
282 SG::ReadHandleKey<xAOD::CaloClusterContainer> m_CaloClusterKey{this, "CaloClusterContainer", "CaloCalTopoClusters",
283 "Name of the primary calo cluster container"};
284 SG::ReadHandleKey<xAOD::FlowElementContainer> m_PflowKey{this, "PflowContainer", "CHSNeutralParticleFlowObjects",
285 "Name of the neutral pflow elements"};
286
293 bool m_has_nonTTVA{false};
295 bool m_hasPflowIso{false};
297 bool m_hasEtConeIso{false};
298
299
300 bool m_isInitialised{false};
301
305
306 // Functionallity to backup the original cone variables if needed
307 mutable IsoHelperMap m_isohelpers ATLAS_THREAD_SAFE;
312 mutable std::mutex m_isoHelpersMutex ATLAS_THREAD_SAFE;
313 };
314
315} // namespace CP
316#endif
Scalar eta() const
pseudorapidity method
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Property holding a SG store/key/clid from which a ReadHandle is made.
static Double_t P(Double_t *tt, Double_t *par)
#define x
Define macros for attributes used to control the static checker.
Return value from object correction CP tools.
bool m_has_nonTTVA
Switch whether a pile-up non robust TTVA working point is defined.
CorrectionCode getCloseByCorrectionTopoIso(const EventContext &ctx, const xAOD::IParticle *primary, const IsoType type, ObjectCache &cache, float &isoValue) const
bool overlap(const xAOD::IParticle *particle, const xAOD::IParticle *particle1, float dR) const
const xAOD::IParticle * isoRefParticle(const xAOD::IParticle *particle) const override
Retrieve the reference particle to define the cone axis in which the track particles contributing to ...
IsoVector m_electron_isoTypes
Isolation variables used by the electron working point.
IsoVector m_muon_isoTypes
Isolation variables used by the muon working point.
bool passFirstStage(const xAOD::TrackParticle *trk, const xAOD::Vertex *vtx) const
The Track particle has to pass the Track selection tool and the TTVA selection.
CorrectionCode getCloseByCorrectionTrackIso(const xAOD::IParticle *primary, const IsoType type, const ObjectCache &cache, float &isoValue) const
ToolHandle< CP::ITrackVertexAssociationTool > m_ttvaTool
float deltaR2(const xAOD::IParticle *particle, const xAOD::IParticle *particle1, bool AvgCalo=false) const
bool m_hasPflowIso
Switch whether a pflow isolation working point is defined.
void lockDecorations(const xAOD::IParticleContainer *parts, const IsoVector &isoTypes) const
float unCalibPt(const xAOD::IParticle *particle) const
void declareDependency(const std::vector< std::string > &containers, const IsoVector &types)
Helper function to declare the data dependencies.
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
bool getExtrapEtaPhi(const EventContext &ctx, const xAOD::TrackParticle *tp, float &eta, float &phi) const
helper to get eta,phi of muon extrap
bool passSelectionQuality(const xAOD::IParticle *particle) const
void getAssocFlowElements(const EventContext &ctx, ObjectCache &cache) const
Retrieve all Flow elements associated with the particles in the cache.
ToolHandle< CP::IIsolationSelectionTool > m_selectorTool
Gaudi::Property< std::vector< std::string > > m_elecKeys
Declare the data dependencies of the Input containers.
static bool isTrackIso(xAOD::Iso::IsolationType type)
static bool isFixedTrackIso(xAOD::Iso::IsolationType type)
static bool isEgamma(const xAOD::IParticle *particle)
void associateFlowElement(const EventContext &ctx, const xAOD::IParticle *particle, float &eta, float &phi, float &energy) const override
ClusterSet getAssociatedClusters(const EventContext &ctx, const xAOD::IParticle *particle, ObjectCache &cache) const
Loads the topo clusters associated with the primary IParticle.
static bool isVarTrackIso(xAOD::Iso::IsolationType type)
std::set< const xAOD::IParticle * > PrimaryCollection
Helper struct to collect all relevant objects for the procedure.
void loadAssociatedObjects(const EventContext &ctx, ObjectCache &cache) const
Load all associated tracks / clusters / flow elements into the cache.
Gaudi::Property< std::vector< std::string > > m_photKeys
static float trackPtCut(xAOD::Iso::IsolationType type)
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_CaloClusterKey
static bool isFixedTrackIsoTTVA(xAOD::Iso::IsolationType type)
IsoVector m_photon_isoTypes
Isolation variables used by the photon working point.
std::map< IsoType, std::unique_ptr< IsoVariableHelper > > IsoHelperMap
bool m_hasEtConeIso
Switch whether a topoetcone isolation working point is defined.
bool isSame(const xAOD::IParticle *particle, const xAOD::IParticle *particle1) const
void isoTypesFromWP(const std::vector< std::unique_ptr< IsolationWP > > &WP, IsoVector &types)
Helper function to load all Isolation types from the iso working points.
virtual CorrectionCode getCloseByIsoCorrection(const EventContext &ctx, const xAOD::ElectronContainer *Electrons, const xAOD::MuonContainer *Muons, const xAOD::PhotonContainer *Photons) const override
TrackSet getAssociatedTracks(const xAOD::IParticle *P) const
Retrieve all Inner detector tracks associated with the primary particle.
static const caloDecorNames & caloDecors()
Returns an array with the calo cluster decoration names [0]-> eta, [1]->phi, [2]->energy....
void printIsolationCones(const IsoVector &types, xAOD::Type::ObjectType T) const
CorrectionCode subtractCloseByContribution(const EventContext &ctx, const xAOD::IParticle *P, ObjectCache &cache) const
static float clusterEtMinusTile(const xAOD::CaloCluster *C)
virtual float getOriginalIsolation(const xAOD::IParticle &P, IsoType type) const override
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_isoVarKeys
SG::WriteDecorHandleKeyArray< xAOD::IParticleContainer > m_isoWriteDecVarKeys
void loadPrimaryParticles(const xAOD::IParticleContainer *container, ObjectCache &cache) const
Filter all electrons/muons/photons from the collection which pass the selection decoration.
Gaudi::Property< std::string > m_isoSelection_name
SG::ReadHandleKey< xAOD::FlowElementContainer > m_PflowKey
CorrectionCode getCloseByCorrectionPflowIso(const EventContext &ctx, const xAOD::IParticle *primary, const IsoType type, const ObjectCache &cache, float &isoValue) const
static bool isTopoEtIso(xAOD::Iso::IsolationType type)
virtual asg::AcceptData acceptCorrected(const xAOD::IParticle &x, const xAOD::IParticleContainer &closePar) const override
Gaudi::Property< std::vector< std::string > > m_muonKeys
static std::string particleName(const xAOD::IParticle *C)
void associateCluster(const xAOD::IParticle *particle, float &eta, float &phi, float &energy) const override
Retrieve the associated clusters from the Particle and calculate the average eta/phi/energy.
const IsoVector & getIsolationTypes(const xAOD::IParticle *particle) const
ToolHandle< Trk::IParticleCaloExtensionTool > m_caloExtTool
calo extension tool for muon track particle extrapolation to calo
virtual CorrectionCode getCloseByCorrection(std::vector< float > &corrections, const xAOD::IParticle &par, const std::vector< xAOD::Iso::IsolationType > &types, const xAOD::IParticleContainer &closePar) const override
TrackSet getTrackCandidates(const EventContext &ctx, const xAOD::IParticle *particle) const override
Load all TrackParticles associated with the particles in the Container. The particles have to pass th...
SG::ReadHandleKey< xAOD::VertexContainer > m_VtxKey
static bool isVarTrackIsoTTVA(xAOD::Iso::IsolationType Iso)
ToolHandle< InDet::IInDetTrackSelectionTool > m_trkselTool
float coneSize(const xAOD::IParticle *particle, IsoType Cone) const
const xAOD::Vertex * retrieveIDBestPrimaryVertex(const EventContext &ctx) const
CorrectionCode copyIsoValuesForPartsNotSelected(const xAOD::IParticle *part) const
CorrectionCode performCloseByCorrection(const EventContext &ctx, ObjectCache &cache) const
static bool isPFlowIso(xAOD::Iso::IsolationType type)
Gaudi::Property< int > m_caloModel
EXPERT PROPERTIES.
static bool isTrackIsoTTVA(xAOD::Iso::IsolationType type)
Property holding a SG store/key/clid from which a ReadHandle is made.
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
Class providing the definition of the 4-vector interface.
struct color C
Select isolated Photons, Electrons and Muons.
std::unordered_set< const xAOD::CaloCluster * > UnorderedClusterSet
Definition Muons.py:1
DecorHandleKeyArray< ReadDecorHandle< T, S >, ReadDecorHandleKey< T >, Gaudi::DataHandle::Reader > ReadDecorHandleKeyArray
DecorHandleKeyArray< WriteDecorHandle< T, S >, WriteDecorHandleKey< T >, Gaudi::DataHandle::Writer > WriteDecorHandleKeyArray
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
Namespace holding the IsolationType enumeration.
IsolationType
Overall enumeration for isolation types in xAOD files.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
static const EventInfo_v1::Accessor< std::vector< std::string > > types("streamTagTypes")
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.