ATLAS Offline Software
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 /********************************************************************
8 NAME: MCTruthClassifier.h
9 PACKAGE: atlasoff/PhysicsAnalysis/MCTruthClassifier
10 AUTHORS: O. Fedin
11 CREATED: Sep 2007
12  ********************************************************************/
13 
15 #include "AsgTools/AsgTool.h"
18 // EDM includes
20 #include "xAODTruth/TruthVertex.h"
22 // For making PID selections easier
26 
27 #ifndef XAOD_ANALYSIS
28 #include "GaudiKernel/ToolHandle.h"
30 #include "AtlasHepMC/GenParticle.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>
55 class MCTruthClassifier : virtual public IMCTruthClassifier , public asg::AsgTool
56 {
58 public:
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("useCaching", m_useCaching = true);
78  declareProperty("phtdRtoTrCut", m_phtdRtoTrCut = 0.1);
79  declareProperty("fwrdEledRtoTrCut", m_fwrdEledRtoTrCut = 0.15);
80  declareProperty("ROICone", m_ROICone = false);
81  //AV: those below are needed in egammaClusMatch
82  declareProperty("pTChargePartCut", m_pTChargePartCut = 1.0);
83  declareProperty("pTNeutralPartCut", m_pTNeutralPartCut = 0.);
84  declareProperty("inclG4part", m_inclG4part = false);
85 #endif
86 #ifndef GENERATIONBASE
87  declareProperty("deltaRMatchCut", m_deltaRMatchCut = 0.2);
88  declareProperty("deltaPhiMatchCut", m_deltaPhiMatchCut = 0.2);
89  declareProperty("NumOfSiHitsCut", m_NumOfSiHitsCut = 3);
90  declareProperty("jetPartDRMatch", m_jetPartDRMatch = 0.4);
91 #endif
92  }
93  virtual ~MCTruthClassifier() = default ;
94 
95  // Gaudi algorithm hooks
96  virtual StatusCode initialize() override {
97  ATH_MSG_INFO(" Initializing MCTruthClassifier");
98 #ifndef XAOD_ANALYSIS
99  // Only needed for GenParticle interface
100  if (!m_truthLinkVecReadHandleKey.key().empty()) {
102  }
103 #endif
105 
106 #if !defined(XAOD_ANALYSIS) && !defined(GENERATIONBASE)
107  if (!m_caloExtensionTool.empty()) {
108  ATH_CHECK(m_caloExtensionTool.retrieve());
109  } else {
110  m_caloExtensionTool.disable();
111  }
112 
114 
115  if (!m_truthInConeTool.empty()) {
116  ATH_CHECK(m_truthInConeTool.retrieve());
117  } else {
118  m_truthInConeTool.disable();
119  }
120 #endif
121  return StatusCode::SUCCESS;
122  }
123  virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
125 
126 #ifndef XAOD_ANALYSIS /*These can not run in Analysis Base*/
127  virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
128  particleTruthClassifier(const HepMcParticleLink& theLink,MCTruthPartClassifier::Info* info = nullptr) const override final;
129 
132 
133 #endif
134 
135 #ifndef GENERATIONBASE /*These can not run in Generation only release*/
136  //Main method for Track to Truth association
137  virtual const xAOD::TruthParticle* getGenPart(const xAOD::TrackParticle*, MCTruthPartClassifier::Info* info = nullptr) const override final;
138 
139 #ifndef XAOD_ANALYSIS
140  //Main method for egamma clusters to Truth Particle association
141  virtual const xAOD::TruthParticle* egammaClusMatch(const xAOD::CaloCluster*,bool,MCTruthPartClassifier::Info* info) const override final;
142 #endif
143 
144  virtual std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin>
146 
148  particleTruthClassifier(const xAOD::Electron*,MCTruthPartClassifier::Info* info = nullptr) const override final;
149 
151  particleTruthClassifier(const xAOD::Photon*,MCTruthPartClassifier::Info* info = nullptr) const override final;
152 
154  particleTruthClassifier(const xAOD::Muon*,MCTruthPartClassifier::Info* info = nullptr) const override final;
155 
157  particleTruthClassifier(const xAOD::CaloCluster*,MCTruthPartClassifier::Info* info = nullptr) const override final;
158 
160  particleTruthClassifier(const xAOD::Jet*, bool DR, MCTruthPartClassifier::Info* info = nullptr) const override final;
161 #endif
162 
163 private:
164  inline double detEta(double x, double y) const { return std::abs(x - y); }
165  inline double detPhi(double x, double y) const {
166  double det = x - y;
167  if (det > M_PI) det = det - 2. * M_PI;
168  if (det < -M_PI) det = det + 2. * M_PI;
169  return std::abs(det);
170  }
171 
172 
174  const xAOD::TruthParticle*,
175  bool& isPrompt,
177 
179  const xAOD::TruthParticle*,
180  bool& isPrompt,
182 
184  const xAOD::TruthParticle*,
185  int motherPDG,
187 
189  const xAOD::TruthParticle*,
190  bool& isPrompt,
192 
194  const xAOD::TruthParticle*,
195  bool& isPrompt,
197 
198 #if !defined(XAOD_ANALYSIS) && !defined(GENERATIONBASE)
199  bool genPartToCalo(const EventContext& ctx,
200  const xAOD::CaloCluster* clus,
201  const xAOD::TruthParticle* thePart,
202  bool isFwrdEle,
203  double& dRmatch,
204  bool& isNarrowCone,
205  const CaloDetDescrManager& caloDDMgr) const;
206 
207 #endif
208 
209 #ifndef GENERATIONBASE
210  double fracParticleInJet(const xAOD::TruthParticle*, const xAOD::Jet*, bool DR, bool nparts) const;
211  void findJetConstituents(const xAOD::Jet*, std::set<const xAOD::TruthParticle*>& constituents, bool DR) const;
212 #endif
213 
214  /* Data members*/
216  m_truthParticleContainerKey{this,"xAODTruthParticleContainerName","TruthParticles","ReadHandleKey for xAOD::TruthParticleContainer"};
217 
218 #if !defined(XAOD_ANALYSIS) && !defined(GENERATIONBASE)
219  ToolHandle<Trk::IParticleCaloExtensionTool> m_caloExtensionTool{this,"ParticleCaloExtensionTool",""};
220  SG::ReadCondHandleKey<CaloDetDescrManager> m_caloMgrKey{this,"CaloDetDescrManager",""};
221  ToolHandle<xAOD::ITruthParticlesInConeTool>
222  m_truthInConeTool{this,"TruthInConeTool","xAOD::TruthParticlesInConeTool/TruthParticlesInConeTool"};
223 
228  float m_partExtrConePhi;
234  bool m_ROICone;
235 
239 #endif
240 
241 #ifndef XAOD_ANALYSIS
243  m_truthLinkVecReadHandleKey{this,"xAODTruthLinkVector","xAODTruthLinks", "ReadHandleKey for xAODTruthParticleLinkVector"};
244 #endif
245 #ifndef GENERATIONBASE
246  float m_deltaRMatchCut;
247  float m_deltaPhiMatchCut;
249  float m_jetPartDRMatch;
250 #endif
251 };
252 #endif // MCTRUTHCLASSIFIER_MCTRUTHCLASSIFIER_H
grepfile.info
info
Definition: grepfile.py:38
MCTruthClassifier::defOrigOfNeutrino
MCTruthPartClassifier::ParticleOrigin defOrigOfNeutrino(const xAOD::TruthParticleContainer *m_xTruthParticleContainer, const xAOD::TruthParticle *, bool &isPrompt, MCTruthPartClassifier::Info *info) const
Definition: MCTruthClassifierGen.cxx:1203
Jet.h
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
MCTruthClassifier::m_FwdElectronTruthExtrEtaWindowCut
float m_FwdElectronTruthExtrEtaWindowCut
Definition: MCTruthClassifier.h:231
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Jet
Basic data class defines behavior for all Jet objects The Jet class is the principal data class for...
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
MCTruthClassifier::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: MCTruthClassifier.h:101
TRTCalib_Extractor.det
det
Definition: TRTCalib_Extractor.py:36
Muon.h
MCTruthClassifier::findJetConstituents
void findJetConstituents(const xAOD::Jet *, std::set< const xAOD::TruthParticle * > &constituents, bool DR) const
Definition: MCRecoToTruth.cxx:273
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TruthParticleContainer.h
MCTruthClassifier::m_phtClasConeEta
float m_phtClasConeEta
Definition: MCTruthClassifier.h:236
MCTruthClassifier::m_useCaching
bool m_useCaching
Definition: MCTruthClassifier.h:234
MCTruthClassifier::m_partExtrConeEta
float m_partExtrConeEta
Definition: MCTruthClassifier.h:232
M_PI
#define M_PI
Definition: ActiveFraction.h:11
MCTruthClassifier::m_caloExtensionTool
ToolHandle< Trk::IParticleCaloExtensionTool > m_caloExtensionTool
Definition: MCTruthClassifier.h:224
PropDirection.h
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
MCTruthClassifier::defOrigOfElectron
MCTruthPartClassifier::ParticleOrigin defOrigOfElectron(const xAOD::TruthParticleContainer *xTruthParticleContainer, const xAOD::TruthParticle *, bool &isPrompt, MCTruthPartClassifier::Info *info) const
Definition: MCTruthClassifierGen.cxx:226
MCTruthClassifier::m_pTNeutralPartCut
float m_pTNeutralPartCut
Definition: MCTruthClassifier.h:242
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
SG::ReadHandleKey< xAOD::TruthParticleContainer >
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
x
#define x
GenParticle.h
MCTruthClassifier::m_truthParticleContainerKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainerKey
Definition: MCTruthClassifier.h:221
Photon
Class describing an photon
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
MCTruthClassifier::m_NumOfSiHitsCut
int m_NumOfSiHitsCut
Definition: MCTruthClassifier.h:253
MCTruthClassifier::m_jetPartDRMatch
float m_jetPartDRMatch
Definition: MCTruthClassifier.h:254
MCTruthClassifierDefs.h
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
EgammaxAODHelpers.h
MCTruthClassifier::m_FwdElectronTruthExtrEtaCut
float m_FwdElectronTruthExtrEtaCut
Definition: MCTruthClassifier.h:230
IMCTruthClassifier.h
TrackParametersIdHelper.h
CaloCluster.h
Photon.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ParticleOrigin
ParticleOrigin
Definition: TruthClasses.h:51
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
MCTruthClassifier::egammaClusMatch
virtual const xAOD::TruthParticle * egammaClusMatch(const xAOD::CaloCluster *, bool, MCTruthPartClassifier::Info *info) const override final
Definition: MCTruthClassifierAthena.cxx:44
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ITruthParticlesInConeTool.h
MCTruthClassifier::m_truthLinkVecReadHandleKey
SG::ReadHandleKey< xAODTruthParticleLinkVector > m_truthLinkVecReadHandleKey
Definition: MCTruthClassifier.h:248
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
MCTruthClassifier::m_phtClasConePhi
float m_phtClasConePhi
Definition: MCTruthClassifier.h:235
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
MCTruthClassifier::m_partExtrConePhi
float m_partExtrConePhi
Definition: MCTruthClassifier.h:233
MCTruthClassifier::genPartToCalo
bool genPartToCalo(const EventContext &ctx, const xAOD::CaloCluster *clus, const xAOD::TruthParticle *thePart, bool isFwrdEle, double &dRmatch, bool &isNarrowCone, const CaloDetDescrManager &caloDDMgr) const
Definition: MCTruthClassifierAthena.cxx:237
TruthVertex.h
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
MagicNumbers.h
MCTruthClassifier::m_inclG4part
bool m_inclG4part
Definition: MCTruthClassifier.h:243
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Units.h
Wrapper to avoid constant divisions when using units.
IMCTruthClassifier
Definition: IMCTruthClassifier.h:92
MCTruthClassifier
Definition: MCTruthClassifier.h:56
MCTruthClassifier::MCTruthClassifier
MCTruthClassifier(const std::string &type)
Definition: MCTruthClassifier.h:65
SG::ReadCondHandleKey< CaloDetDescrManager >
TrackParticle.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
MCTruthClassifier::defOrigOfMuon
MCTruthPartClassifier::ParticleOrigin defOrigOfMuon(const xAOD::TruthParticleContainer *m_xTruthParticleContainer, const xAOD::TruthParticle *, bool &isPrompt, MCTruthPartClassifier::Info *info) const
Definition: MCTruthClassifierGen.cxx:531
IParticleCaloExtensionTool.h
MCTruthClassifier::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: MCTruthClassifier.h:225
y
#define y
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
MCTruthPartClassifier::isPrompt
int isPrompt(const unsigned int classify, bool allow_prompt_tau_decays=true)
Definition: TruthClassifiers.h:180
MCTruthPartClassifier
Definition: TruthClassifiers.h:12
HepMC
Definition: Barcode.h:14
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
MCTruthClassifier::m_deltaRMatchCut
float m_deltaRMatchCut
Definition: MCTruthClassifier.h:251
Electron
Class describing an electron.
MCTruthClassifier::m_deltaPhiMatchCut
float m_deltaPhiMatchCut
Definition: MCTruthClassifier.h:252
MCTruthClassifier::defOrigOfTau
MCTruthPartClassifier::ParticleOrigin defOrigOfTau(const xAOD::TruthParticleContainer *m_xTruthParticleContainer, const xAOD::TruthParticle *, int motherPDG, MCTruthPartClassifier::Info *info) const
Definition: MCTruthClassifierGen.cxx:767
DecayProducts.h
MCTruthClassifier::m_pTChargePartCut
float m_pTChargePartCut
Definition: MCTruthClassifier.h:241
MCTruthClassifier::m_truthInConeTool
ToolHandle< xAOD::ITruthParticlesInConeTool > m_truthInConeTool
Definition: MCTruthClassifier.h:227
Electron.h
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
AsgTool.h
TruthParticle.h
MCTruthClassifier::~MCTruthClassifier
virtual ~MCTruthClassifier()=default
MCTruthClassifier::particleTruthClassifier
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::TruthParticle *, MCTruthPartClassifier::Info *info=nullptr) const override final
Definition: MCTruthClassifierGen.cxx:75
MCTruthClassifier::m_FwdElectronUseG4Sel
bool m_FwdElectronUseG4Sel
Definition: MCTruthClassifier.h:229
ParticleType
ParticleType
Definition: TruthClasses.h:8
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
MCTruthClassifier::m_fwrdEledRtoTrCut
float m_fwrdEledRtoTrCut
Definition: MCTruthClassifier.h:238
MCTruthPartClassifier::Info
Definition: IMCTruthClassifier.h:49
MCTruthClassifier::detEta
double detEta(double x, double y) const
Definition: MCTruthClassifier.h:169
MCTruthClassifier::fracParticleInJet
double fracParticleInJet(const xAOD::TruthParticle *, const xAOD::Jet *, bool DR, bool nparts) const
Definition: MCRecoToTruth.cxx:305
MCTruthClassifier::m_ROICone
bool m_ROICone
Definition: MCTruthClassifier.h:239
HepMCHelpers.h
MCTruthClassifier::defOrigOfPhoton
MCTruthPartClassifier::ParticleOrigin defOrigOfPhoton(const xAOD::TruthParticleContainer *m_xTruthParticleContainer, const xAOD::TruthParticle *, bool &isPrompt, MCTruthPartClassifier::Info *info) const
Definition: MCTruthClassifierGen.cxx:944
MCTruthClassifier::m_phtdRtoTrCut
float m_phtdRtoTrCut
Definition: MCTruthClassifier.h:237
MCTruthClassifier::detPhi
double detPhi(double x, double y) const
Definition: MCTruthClassifier.h:170
MCTruthClassifier::getGenPart
virtual const xAOD::TruthParticle * getGenPart(const xAOD::TrackParticle *, MCTruthPartClassifier::Info *info=nullptr) const override final
Definition: MCRecoToTruth.cxx:181