ATLAS Offline Software
Loading...
Searching...
No Matches
MCTruthClassifier.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MCTRUTHCLASSIFIER_MCTRUTHCLASSIFIER_H
6#define MCTRUTHCLASSIFIER_MCTRUTHCLASSIFIER_H
7/********************************************************************
8NAME: MCTruthClassifier.h
9PACKAGE: atlasoff/PhysicsAnalysis/MCTruthClassifier
10AUTHORS: O. Fedin
11CREATED: Sep 2007
12 ********************************************************************/
13
15#include "AsgTools/AsgTool.h"
18// EDM includes
22// For making PID selections easier
26
27#ifndef XAOD_ANALYSIS
28#include "GaudiKernel/ToolHandle.h"
31#endif
32
33#ifndef GENERATIONBASE
34//EDM includes
38#include "xAODEgamma/Electron.h"
39#include "xAODEgamma/Photon.h"
40#include "xAODMuon/Muon.h"
41#include "xAODJet/Jet.h"
42#endif
43
44#if !defined(XAOD_ANALYSIS) && !defined(GENERATIONBASE)
50#include "AthenaKernel/Units.h"
51#endif
52
53#include <cmath>
54#include <utility>
55class MCTruthClassifier : virtual public IMCTruthClassifier , public asg::AsgTool
56{
58public:
59 // constructor
60 MCTruthClassifier(const std::string& type) : asg::AsgTool(type) {
61#if !defined(XAOD_ANALYSIS) && !defined(GENERATIONBASE)
62 declareProperty("FwdElectronUseG4Sel", m_FwdElectronUseG4Sel = true,
63 "Use Geant4 selection for forward electrons calo clusters");
64 declareProperty("FwdElectronTruthExtrEtaCut",
66 "Cut on the eta of the truth Particles to be extrapolated "
67 "for Fwd electrons");
69 "FwdElectronTruthExtrEtaWindowCut",
71 "Cut on the delta eta of the truth Particles to be extrapolated for "
72 "Fwd electrons and the current FwdElectron");
73 declareProperty("partExtrConePhi", m_partExtrConePhi = 0.4);
74 declareProperty("partExtrConeEta", m_partExtrConeEta = 0.2);
75 declareProperty("phtClasConePhi", m_phtClasConePhi = 0.05);
76 declareProperty("phtClasConeEta", m_phtClasConeEta = 0.025);
77 declareProperty("phtdRtoTrCut", m_phtdRtoTrCut = 0.1);
78 declareProperty("fwrdEledRtoTrCut", m_fwrdEledRtoTrCut = 0.15);
79 declareProperty("ROICone", m_ROICone = false);
80 //AV: those below are needed in egammaClusMatch
81 declareProperty("pTChargePartCut", m_pTChargePartCut = 1.0);
82 declareProperty("pTNeutralPartCut", m_pTNeutralPartCut = 0.);
83 declareProperty("inclG4part", m_inclG4part = false);
84#endif
85#ifndef GENERATIONBASE
86 declareProperty("deltaRMatchCut", m_deltaRMatchCut = 0.2);
87 declareProperty("deltaPhiMatchCut", m_deltaPhiMatchCut = 0.2);
88 declareProperty("NumOfSiHitsCut", m_NumOfSiHitsCut = 3);
89 declareProperty("jetPartDRMatch", m_jetPartDRMatch = 0.4);
90#endif
91 }
92 virtual ~MCTruthClassifier() = default ;
93
94 // Gaudi algorithm hooks
95 virtual StatusCode initialize() override {
96 ATH_MSG_INFO(" Initializing MCTruthClassifier");
97#ifndef XAOD_ANALYSIS
98 // Only needed for GenParticle interface
100#endif
102
103#if !defined(XAOD_ANALYSIS) && !defined(GENERATIONBASE)
104 if (!m_caloExtensionTool.empty()) {
105 ATH_CHECK(m_caloExtensionTool.retrieve());
106 } else {
107 m_caloExtensionTool.disable();
108 }
109
111
112 if (!m_truthInConeTool.empty()) {
113 ATH_CHECK(m_truthInConeTool.retrieve());
114 } else {
115 m_truthInConeTool.disable();
116 }
117#endif
118 return StatusCode::SUCCESS;
119 }
120
122
123protected:
124 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
126
127#ifndef XAOD_ANALYSIS /*These can not run in Analysis Base*/
128 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
129 particleHepMCTruthClassifier(const HepMcParticleLink& theLink,IMCTruthClassifier::Info* info) const override final;
130
131#endif
132
133public:
134#ifndef GENERATIONBASE /*These can not run in Generation only release*/
135 //Main method for Track to Truth association
136 virtual const xAOD::TruthParticle* getGenPart(const xAOD::TrackParticle*, IMCTruthClassifier::Info* info = nullptr) const override final;
137
138#ifndef XAOD_ANALYSIS
139 //Main method for egamma clusters to Truth Particle association
140 virtual const xAOD::TruthParticle* egammaClusMatch(const xAOD::CaloCluster*,bool,IMCTruthClassifier::Info* info) const override final;
141#endif
142
143protected:
144 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
146
147 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
148 particleTruthClassifier(const xAOD::Electron*,IMCTruthClassifier::Info* info) const override final;
149
150 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
151 particleTruthClassifier(const xAOD::Photon*,IMCTruthClassifier::Info* info) const override final;
152
153 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
155
156 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
158
159 virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
160 particleTruthClassifier(const xAOD::Jet*, bool DR, IMCTruthClassifier::Info* info) const override final;
161#endif
162
163private:
164
166 const xAOD::TruthParticle*,
167 bool& isPrompt,
168 IMCTruthClassifier::Info& info) const;
169
171 const xAOD::TruthParticle*,
172 bool& isPrompt,
173 IMCTruthClassifier::Info& info) const;
174
176 const xAOD::TruthParticle*,
177 int motherPDG,
178 IMCTruthClassifier::Info& info) const;
179
181 const xAOD::TruthParticle*,
182 bool& isPrompt,
183 IMCTruthClassifier::Info& info) const;
184
186 const xAOD::TruthParticle*,
187 bool& isPrompt,
188 IMCTruthClassifier::Info& info) const;
189
190#if !defined(XAOD_ANALYSIS) && !defined(GENERATIONBASE)
191 bool genPartToCalo(const EventContext& ctx,
192 const xAOD::CaloCluster* clus,
193 const xAOD::TruthParticle* thePart,
194 bool isFwrdEle,
195 double& dRmatch,
196 bool& isNarrowCone,
197 const CaloDetDescrManager& caloDDMgr) const;
198#endif
199
200 /* Data members*/
202 m_truthParticleContainerKey{this,"xAODTruthParticleContainerName","TruthParticles","ReadHandleKey for xAOD::TruthParticleContainer"};
203
204#if !defined(XAOD_ANALYSIS) && !defined(GENERATIONBASE)
205 ToolHandle<Trk::IParticleCaloExtensionTool> m_caloExtensionTool{this,"ParticleCaloExtensionTool",""};
207 ToolHandle<xAOD::ITruthParticlesInConeTool>
208 m_truthInConeTool{this,"TruthInConeTool","xAOD::TruthParticlesInConeTool/TruthParticlesInConeTool"};
209
220
224#endif
225
226#ifndef XAOD_ANALYSIS
228 m_truthLinkVecReadHandleKey{this,"xAODTruthLinkVector","xAODTruthLinks", "ReadHandleKey for xAODTruthParticleLinkVector"};
229#endif
230#ifndef GENERATIONBASE
235#endif
236};
237#endif // MCTRUTHCLASSIFIER_MCTRUTHCLASSIFIER_H
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition of CaloDetDescrManager.
ATLAS-specific HepMC functions.
Wrapper to avoid constant divisions when using units.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
This class provides the client interface for accessing the detector description information common to...
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::TruthParticle *, IMCTruthClassifier::Info *info) const =0
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
MCTruthPartClassifier::ParticleOrigin defOrigOfPhoton(const xAOD::TruthParticleContainer &xTruthParticleContainer, const xAOD::TruthParticle *, bool &isPrompt, IMCTruthClassifier::Info &info) const
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::TruthParticle *, IMCTruthClassifier::Info *info) const override final
MCTruthPartClassifier::ParticleOrigin defOrigOfMuon(const xAOD::TruthParticleContainer &xTruthParticleContainer, const xAOD::TruthParticle *, bool &isPrompt, IMCTruthClassifier::Info &info) const
MCTruthPartClassifier::ParticleOrigin defOrigOfTau(const xAOD::TruthParticleContainer &xTruthParticleContainer, const xAOD::TruthParticle *, int motherPDG, IMCTruthClassifier::Info &info) const
MCTruthPartClassifier::ParticleOrigin defOrigOfElectron(const xAOD::TruthParticleContainer &xTruthParticleContainer, const xAOD::TruthParticle *, bool &isPrompt, IMCTruthClassifier::Info &info) const
namespace
SG::ReadHandleKey< xAODTruthParticleLinkVector > m_truthLinkVecReadHandleKey
ToolHandle< xAOD::ITruthParticlesInConeTool > m_truthInConeTool
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleHepMCTruthClassifier(const HepMcParticleLink &theLink, IMCTruthClassifier::Info *info) const override final
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
bool genPartToCalo(const EventContext &ctx, const xAOD::CaloCluster *clus, const xAOD::TruthParticle *thePart, bool isFwrdEle, double &dRmatch, bool &isNarrowCone, const CaloDetDescrManager &caloDDMgr) const
virtual ~MCTruthClassifier()=default
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::CaloCluster *, IMCTruthClassifier::Info *info) const override final
float m_FwdElectronTruthExtrEtaWindowCut
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::Muon *, IMCTruthClassifier::Info *info) const override final
virtual const xAOD::TruthParticle * egammaClusMatch(const xAOD::CaloCluster *, bool, IMCTruthClassifier::Info *info) const override final
MCTruthClassifier(const std::string &type)
ToolHandle< Trk::IParticleCaloExtensionTool > m_caloExtensionTool
virtual const xAOD::TruthParticle * getGenPart(const xAOD::TrackParticle *, IMCTruthClassifier::Info *info=nullptr) const override final
MCTruthPartClassifier::ParticleOrigin defOrigOfNeutrino(const xAOD::TruthParticleContainer &xTruthParticleContainer, const xAOD::TruthParticle *, bool &isPrompt, IMCTruthClassifier::Info &info) const
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainerKey
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
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
Jet_v1 Jet
Definition of the current "jet version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:
Photon_v1 Photon
Definition of the current "egamma version".
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
Electron_v1 Electron
Definition of the current "egamma version".