ATLAS Offline Software
Loading...
Searching...
No Matches
D3PD::D3PDMCTruthClassifier Class Reference

Work around MCTruthClassifier brain-damage. More...

#include <D3PDMCTruthClassifier.h>

Inheritance diagram for D3PD::D3PDMCTruthClassifier:
Collaboration diagram for D3PD::D3PDMCTruthClassifier:

Public Member Functions

 D3PDMCTruthClassifier (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Gaudi tool constructor.
virtual StatusCode initialize ()
 Standard Gaudi initialize method.
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier (const xAOD::Electron *el)
 Run the classifier for an electron.
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier (const xAOD::Photon *el)
 Run the classifier for a photon.
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier (const xAOD::Muon *mu)
 Run the classifier for a muon.
virtual Result particleTruthClassifier (const EventContext &ctx, const xAOD::TruthParticle *thePart) const override final
virtual Result particleTruthClassifier (const EventContext &ctx, const xAOD::TrackParticle *) const override final
virtual Result particleTruthClassifier (const EventContext &ctx, const xAOD::Electron *) const override final
virtual Result particleTruthClassifier (const EventContext &ctx, const xAOD::Photon *) const override final
template<typename T>
std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier (const T *p, std::optional< std::reference_wrapper< const EventContext > > ctx=std::nullopt) const
const xAOD::TruthParticle * getGenPart (const xAOD::TrackParticle *) const
const xAOD::TruthParticle * egammaClusMatch (const EventContext &ctx, const xAOD::CaloCluster *, bool isFwrdEle) const
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
template<typename T>
Result particleTruthClassifier_full (const T *p, std::optional< std::reference_wrapper< const EventContext > > ctx=std::nullopt) const
 Returns more info than the particleTruthClassifier.
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Types

using Result

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

bool get_tptruth_name (const std::string &tp_name, std::string &tptruth_name)
 Try to find a TrackParticleTruthCollection pointing at TP_NAME.
void getProperty1 (const std::string &pname, std::string &value)
 Helper to retrieve the value of a Gaudi property.
void setProperty1 (const std::string &pname, const std::string &value)
 Helper to set the value of a Gaudi property.
bool genPartToCalo (const EventContext &ctx, const xAOD::CaloCluster *clus, const xAOD::TruthParticle *thePart, bool isFwrdEle, double &dRmatch, bool &isNarrowCone, const CaloDetDescrManager &caloDDMgr) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< StoreGateSvc > m_sg
 The StoreGate service.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainerKey {this,"xAODTruthParticleContainerName","TruthParticles","ReadHandleKey for xAOD::TruthParticleContainer"}
 Key of the xAOD truth particle container that is searched when classifying (ancestors, decay products, ...).
ToolHandle< Trk::IParticleCaloExtensionTool > m_caloExtensionTool {this,"ParticleCaloExtensionTool",""}
 Extrapolates truth particles to the calorimeter (egammaClusMatch); optional, disabled if empty.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey {this,"CaloDetDescrManager",""}
 Calorimeter detector description, needed together with the extension tool; optional, may be empty.
ToolHandle< xAOD::ITruthParticlesInConeTool > m_truthInConeTool {this,"TruthInConeTool","xAOD::TruthParticlesInConeTool/TruthParticlesInConeTool"}
 Finds the truth particles in a cone around a cluster (egammaClusMatch); optional, disabled if empty.
bool m_FwdElectronUseG4Sel
 skip Geant4 particles also for forward electrons
float m_FwdElectronTruthExtrEtaCut
 forward electrons: truth particles with |eta| below this are not extrapolated
float m_FwdElectronTruthExtrEtaWindowCut
 forward electrons: max |delta eta| to the cluster for a truth particle to be extrapolated
float m_partExtrConeEta
 eta half-width of the cone in which truth particles are extrapolated
float m_partExtrConePhi
 phi half-width of the cone in which truth particles are extrapolated
float m_phtClasConePhi
 phi half-width of the narrow cone around the cluster (not forward electrons)
float m_phtClasConeEta
 eta half-width of the narrow cone around the cluster (not forward electrons)
float m_phtdRtoTrCut
 max dR cluster - extrapolated truth particle (not forward electrons)
float m_fwrdEledRtoTrCut
 max dR cluster - extrapolated truth particle (forward electrons)
bool m_ROICone
 only extrapolate truth particles inside the partExtrCone ellipse
float m_pTChargePartCut
 minimum pT of charged truth particles considered
float m_pTNeutralPartCut
 minimum pT of neutral truth particles considered
bool m_inclG4part
 also try Geant4 particles if no generator particle matched
SG::ReadHandleKey< xAODTruthParticleLinkVector > m_truthLinkVecReadHandleKey {this,"xAODTruthLinkVector","xAODTruthLinks", "ReadHandleKey for xAODTruthParticleLinkVector"}
float m_deltaRMatchCut
 max dR track - truth particle if the track has more than NumOfSiHitsCut Si hits
float m_deltaPhiMatchCut
 max delta phi track - truth particle if the track has at most NumOfSiHitsCut Si hits
int m_NumOfSiHitsCut
 Si (pixel + SCT) hit count selecting between deltaRMatchCut and deltaPhiMatchCut.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Work around MCTruthClassifier brain-damage.

This avoids having to specify the container names during configuration.

MCTruthClassifier requires specifying, at configuration time, the names of the TrackParticleContainer and TrackParticleTruthCollection objects to use for the mapping. This is painful in for electrons in the case where one may have several different track containers.

What we do to make this easier is to search through SG to find a truth collection that points at the TrackParticleContainer that contains the tracks for the electron we're looking at.

Definition at line 41 of file D3PDMCTruthClassifier.h.

Member Typedef Documentation

◆ Result

using IMCTruthClassifier::Result
protectedinherited
Initial value:
ParticleOutCome
Outcome of a (simulated) truth particle: what happened to it after being produced,...
ParticleOrigin
Origin of a truth particle, as assigned by MCTruthClassifier::particleTruthClassifier (the second mem...
ParticleType
Type of a truth particle, as assigned by MCTruthClassifier::particleTruthClassifier (the first member...
TruthParticle_v1 TruthParticle
Typedef to implementation.

Definition at line 40 of file IMCTruthClassifier.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ D3PDMCTruthClassifier()

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

Standard Gaudi tool constructor.

Parameters
typeThe name of the tool type.
nameThe tool name.
parentThe tool's Gaudi parent.

Definition at line 39 of file D3PDMCTruthClassifier.cxx.

42 : MCTruthClassifier (type, name, parent),
43 m_sg ("StoreGateSvc", name)
44{
45}
ServiceHandle< StoreGateSvc > m_sg
The StoreGate service.
MCTruthClassifier(const std::string &type)

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ egammaClusMatch()

const xAOD::TruthParticle * MCTruthClassifier::egammaClusMatch ( const EventContext & ctx,
const xAOD::CaloCluster * clus,
bool isFwrdEle ) const
inherited

Definition at line 44 of file MCTruthClassifierAthena.cxx.

45{
46 ATH_MSG_DEBUG("Executing egammaClusMatch ");
47 const xAOD::TruthParticle* theMatchPart = nullptr;
48 // retrieve collection and get a pointer
49 SG::ReadHandle<xAOD::TruthParticleContainer> truthParticleContainerReadHandle(m_truthParticleContainerKey, ctx);
50
51 if (!truthParticleContainerReadHandle.isValid()) {
52 ATH_MSG_WARNING( " Invalid ReadHandle for xAOD::TruthParticleContainer with key: " << truthParticleContainerReadHandle.key());
53 return theMatchPart;
54 }
55
56 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{ m_caloMgrKey, ctx };
57 if (!caloMgrHandle.isValid()) {
58 ATH_MSG_WARNING(" Invalid ReadCondHandle for CaloDetDescrManager with key: " << m_caloMgrKey.key());
59 return theMatchPart;
60 }
61
62 const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
63 const xAOD::TruthParticle* theEgamma(nullptr);
64 const xAOD::TruthParticle* theLeadingPartInCone(nullptr);
65 const xAOD::TruthParticle* theBestPartOutCone(nullptr);
66 const xAOD::TruthParticle* theBestPartdR(nullptr);
67 double LeadingPhtPT(0);
68 double LeadingPartPT(0);
69 double BestPartdR(999.);
70 double etaClus = clus->etaBE(2);
71 double phiClus = clus->phiBE(2);
72 if (etaClus < -900) {
73 etaClus = clus->eta();
74 }
75 if (phiClus < -900) {
76 phiClus = clus->phi();
77 }
78 std::vector<const xAOD::TruthParticle*> tps;
79 if (!m_truthInConeTool->particlesInCone(ctx, etaClus, phiClus, 0.5, tps)) {
80 ATH_MSG_WARNING("Truth Particle in Cone failed");
81 return theMatchPart;
82 }
83
84 for (const auto* const thePart : tps) {
85 if (!thePart)[[unlikely]] continue;
86 // loop over the stable particle
87 if (!MC::isStable(thePart)) continue;
88 // excluding G4 particle
89 if ((!isFwrdEle || (isFwrdEle && m_FwdElectronUseG4Sel)) && HepMC::is_simulation_particle(thePart)) continue;
90 long iParticlePDG = thePart->pdgId();
91 // excluding neutrino
92 if (std::abs(iParticlePDG) == 12 || std::abs(iParticlePDG) == 14 || std::abs(iParticlePDG) == 16) continue;
93 double pt = thePart->pt() / Athena::Units::GeV;
94 double q = thePart->charge();
95 // exclude charged particles with pT<1 GeV
96 if (q != 0 && pt < m_pTChargePartCut) continue;
97 if (q == 0 && pt < m_pTNeutralPartCut) continue;
98 float deltaPhi = std::abs(std::remainder(phiClus - thePart->phi(), 2*std::numbers::pi));
99 float deteta = std::abs(etaClus - thePart->eta());
100 // eleptical cone for extrapolations m_partExtrConePhi X m_partExtrConeEta
101 if (!isFwrdEle && m_ROICone && std::hypot( deltaPhi/m_partExtrConePhi, deteta/m_partExtrConeEta) > 1.0) {
102 continue;
103 }
104 // Also check if the clus and true have different sign , i they need both to be <0 or >0
105 if (isFwrdEle && // It is forward and
106 (((etaClus < 0) - (thePart->eta() < 0) != 0)
107 // The truth eta has different sign wrt to the fwd electron
108 || (std::fabs(thePart->eta()) < m_FwdElectronTruthExtrEtaCut) // or the truth is less than 2.4 (default cut)
109 || (std::fabs(thePart->eta() - etaClus) > m_FwdElectronTruthExtrEtaWindowCut) // or if the delta Eta between el and truth is > 0.15
110 ) // then do no extrapolate this truth Particle for this fwd electron
111 ) {
112 continue;
113 }
114 double dR(-999.);
115 bool isNCone = false;
116 bool isExt = genPartToCalo(ctx, clus, thePart, isFwrdEle, dR, isNCone, *caloDDMgr);
117 if (!isExt) continue;
118 // Gen particles Not forward
119 if (!isFwrdEle) {
120 // the leading photon or electron inside narrow eleptical cone
121 // m_phtClasConePhi X m_phtClasConeEta
122 if ((iParticlePDG == 22 || std::abs(iParticlePDG) == 11) && isNCone && pt > LeadingPhtPT) {
123 theEgamma = thePart;
124 LeadingPhtPT = pt;
125 }
126 // leading particle (excluding photon and electron) inside narrow eleptic
127 // cone m_phtClasConePhi X m_phtClasConeEta
128 if ((iParticlePDG != 22 && std::abs(iParticlePDG) != 11) && isNCone && pt > LeadingPartPT) {
129 theLeadingPartInCone = thePart;
130 LeadingPartPT = pt;
131 };
132 // the best dR matched particle outside narrow eleptic cone cone
133 // m_phtClasConePhi X m_phtClasConeEta
134 if (!isNCone && dR < BestPartdR) {
135 theBestPartOutCone = thePart;
136 BestPartdR = dR;
137 };
138 } else {
139 if (dR < BestPartdR) {
140 theBestPartdR = thePart;
141 BestPartdR = dR;
142 };
143 }
144 }
145
146 if (theEgamma != nullptr) {
147 theMatchPart = MC::findMatching(truthParticleContainerReadHandle.ptr(), theEgamma);
148 } else if (theLeadingPartInCone != nullptr) {
149 theMatchPart = MC::findMatching(truthParticleContainerReadHandle.ptr(),theLeadingPartInCone);
150 } else if (theBestPartOutCone != nullptr) {
151 theMatchPart = MC::findMatching(truthParticleContainerReadHandle.ptr(),theBestPartOutCone);
152 } else if (isFwrdEle && theBestPartdR != nullptr) {
153 theMatchPart = MC::findMatching(truthParticleContainerReadHandle.ptr(),theBestPartdR );
154 } else {
155 theMatchPart = nullptr;
156 }
157 if (isFwrdEle || theMatchPart != nullptr || !m_inclG4part) return theMatchPart;
158
159 // additional loop over G4 particles,
160 for (const auto* const thePart : tps) {
161 if (!MC::isStable(thePart)) continue;
162 if (!HepMC::is_simulation_particle(thePart)) continue;
163 long iParticlePDG = thePart->pdgId();
164 // exclude neutrino
165 if (std::abs(iParticlePDG) == 12 || std::abs(iParticlePDG) == 14 || std::abs(iParticlePDG) == 16) continue;
166 if (thePart->decayVtx() != nullptr) continue;
167 const double dPhi = std::abs(std::remainder(phiClus - thePart->phi(), 2*std::numbers::pi));
168 const double dEta = std::abs(etaClus - thePart->eta());
169 if (std::hypot( dPhi/m_partExtrConePhi, dEta/m_partExtrConeEta ) > 1.0) continue;
170
171 double pt = thePart->pt() / Athena::Units::GeV;
172 double q = thePart->charge();
173 // exclude charged particles with pT<1 GeV
174 if (q != 0 && pt < m_pTChargePartCut) continue;
175 if (q == 0 && pt < m_pTNeutralPartCut) continue;
176
177 double dR(-999.);
178 bool isNCone = false;
179 bool isExt = genPartToCalo(ctx, clus, thePart, isFwrdEle, dR, isNCone, *caloDDMgr);
180 if (!isExt) continue;
181
182 // the leading photon or electron inside narrow eleptical cone
183 // m_phtClasConePhi X m_phtClasConeEta
184 if ((iParticlePDG == 22 || std::abs(iParticlePDG) == 11) && isNCone && pt > LeadingPhtPT) {
185 theEgamma = thePart;
186 LeadingPhtPT = pt;
187 }
188 // leading particle (excluding photon or electron) inside narrow eleptic
189 // cone m_phtClasConePhi X m_phtClasConeEta
190 if ((iParticlePDG != 22 && std::abs(iParticlePDG) != 11) && isNCone && pt > LeadingPartPT) {
191 theLeadingPartInCone = thePart;
192 LeadingPartPT = pt;
193 }
194 // the best dR matched particle outside narrow eleptic cone cone
195 // m_phtClasConePhi X m_phtClasConeEta
196 if (!isNCone && dR < BestPartdR) {
197 theBestPartOutCone = thePart;
198 BestPartdR = dR;
199 }
200 }
201
202 if (theEgamma != nullptr) {
203 theMatchPart = MC::findMatching(truthParticleContainerReadHandle.ptr(),theEgamma);
204 } else if (theLeadingPartInCone != nullptr) {
205 theMatchPart = MC::findMatching(truthParticleContainerReadHandle.ptr(),theLeadingPartInCone);
206 } else if (theBestPartOutCone != nullptr) {
207 theMatchPart = MC::findMatching(truthParticleContainerReadHandle.ptr(),theBestPartOutCone);
208 } else {
209 theMatchPart = nullptr;
210 }
211 ATH_MSG_DEBUG("succeeded egammaClusMatch ");
212 return theMatchPart;
213}
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
float m_partExtrConePhi
phi half-width of the cone in which truth particles are extrapolated
bool m_ROICone
only extrapolate truth particles inside the partExtrCone ellipse
float m_pTNeutralPartCut
minimum pT of neutral truth particles considered
ToolHandle< xAOD::ITruthParticlesInConeTool > m_truthInConeTool
Finds the truth particles in a cone around a cluster (egammaClusMatch); optional, disabled if empty.
float m_partExtrConeEta
eta half-width of the cone in which truth particles are extrapolated
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Calorimeter detector description, needed together with the extension tool; optional,...
bool genPartToCalo(const EventContext &ctx, const xAOD::CaloCluster *clus, const xAOD::TruthParticle *thePart, bool isFwrdEle, double &dRmatch, bool &isNarrowCone, const CaloDetDescrManager &caloDDMgr) const
float m_FwdElectronTruthExtrEtaWindowCut
forward electrons: max |delta eta| to the cluster for a truth particle to be extrapolated
bool m_FwdElectronUseG4Sel
skip Geant4 particles also for forward electrons
float m_pTChargePartCut
minimum pT of charged truth particles considered
float m_FwdElectronTruthExtrEtaCut
forward electrons: truth particles with |eta| below this are not extrapolated
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainerKey
Key of the xAOD truth particle container that is searched when classifying (ancestors,...
bool m_inclG4part
also try Geant4 particles if no generator particle matched
float phiBE(const unsigned layer) const
Get the phi in one layer of the EM Calo.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
bool is_simulation_particle(const T &p)
Method to establish if a particle was created during the simulation (based on the status value).
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
T findMatching(const C &TruthContainer, T p)
Function to find in the container the particle that p descends from in the simulation (see HepMC::is_...
bool dPhi(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool dEta(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
#define unlikely(x)

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ genPartToCalo()

bool MCTruthClassifier::genPartToCalo ( const EventContext & ctx,
const xAOD::CaloCluster * clus,
const xAOD::TruthParticle * thePart,
bool isFwrdEle,
double & dRmatch,
bool & isNarrowCone,
const CaloDetDescrManager & caloDDMgr ) const
privateinherited

Definition at line 215 of file MCTruthClassifierAthena.cxx.

222{
223 dRmatch = -999.;
224 isNarrowCone = false;
225 if (thePart == nullptr) return false;
226 double phiClus = clus->phiBE(2);
227 double etaClus = clus->etaBE(2);
228 if (etaClus < -900) {
229 etaClus = clus->eta();
230 }
231 if (phiClus < -900) {
232 phiClus = clus->phi();
233 }
234 //--FixMe
235 if (isFwrdEle || (etaClus == 0. && phiClus == 0.)) {
236 phiClus = clus->phi();
237 etaClus = clus->eta();
238 }
239 // define calo sample
240 CaloSampling::CaloSample sample = CaloSampling::EMB2;
241 if ((clus->inBarrel() && !clus->inEndcap()) ||
242 (clus->inBarrel() && clus->inEndcap() && clus->eSample(CaloSampling::EMB2) >= clus->eSample(CaloSampling::EME2))) {
243 // Barrel
244 sample = CaloSampling::EMB2;
245 } else if ((!clus->inBarrel() && clus->inEndcap() && !isFwrdEle) ||
246 (clus->inBarrel() && clus->inEndcap() && clus->eSample(CaloSampling::EME2) > clus->eSample(CaloSampling::EMB2))) {
247 // End-cap
248 sample = CaloSampling::EME2;
249 } else if (isFwrdEle && clus->inEndcap()) {
250 // FCAL
251 sample = CaloSampling::FCAL2;
252 } else {
253 return false;
254 }
255 std::unique_ptr<Trk::CurvilinearParameters> params = extractParamFromTruth(*thePart);
256 if (!params) return false;
257 // create extension to sample
258 std::vector<CaloSampling::CaloSample> samples = { sample };
259 auto extension = m_caloExtensionTool->layersCaloExtension(ctx, *params, samples, etaClus, caloDDMgr);
260 bool extensionOK = (!extension.empty());
261 if (!extensionOK) {
262 ATH_MSG_WARNING("extrapolation of Truth Particle with eta " << thePart->eta() << " , charge " << thePart->charge() << " , Pt " << thePart->pt() << " to calo failed");
263 return false;
264 }
265 double etaCalo = extension[0].second->position().eta();
266 double phiCalo = extension[0].second->position().phi();
267
268 const double dPhi = std::abs(std::remainder(phiCalo - phiClus, 2*std::numbers::pi));
269 const double dEta = std::abs(etaCalo - etaClus);
270 dRmatch = std::hypot(dPhi, dEta);
271
272 if ((!isFwrdEle && dRmatch > m_phtdRtoTrCut) || (isFwrdEle && dRmatch > m_fwrdEledRtoTrCut)) return false;
273 if (!isFwrdEle && std::hypot( dPhi/m_phtClasConePhi, dEta/m_phtClasConeEta ) <= 1.0) isNarrowCone = true;
274 return true;
275}
float m_phtdRtoTrCut
max dR cluster - extrapolated truth particle (not forward electrons)
float m_phtClasConeEta
eta half-width of the narrow cone around the cluster (not forward electrons)
ToolHandle< Trk::IParticleCaloExtensionTool > m_caloExtensionTool
Extrapolates truth particles to the calorimeter (egammaClusMatch); optional, disabled if empty.
float m_fwrdEledRtoTrCut
max dR cluster - extrapolated truth particle (forward electrons)
float m_phtClasConePhi
phi half-width of the narrow cone around the cluster (not forward electrons)
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
float eSample(const CaloSample sampling) const
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
double charge() const
Physical charge.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.

◆ get_tptruth_name()

bool D3PD::D3PDMCTruthClassifier::get_tptruth_name ( const std::string & tp_name,
std::string & tptruth_name )
private

Try to find a TrackParticleTruthCollection pointing at TP_NAME.

Parameters
tp_nameThe name of a TrackParticleContainer.
tptruth_name[out]The name of a TrackParticleTruthCollection pointing at it.
Returns
True if we found a good truth collection.

Definition at line 174 of file D3PDMCTruthClassifier.cxx.

176{
177 // Check all TrackParticleTruthCollections to try to find one
178 // pointing at the desired TrackParticle container.
179 std::vector<std::string> keys;
181
182 for (size_t i = 0; i < keys.size(); i++) {
183 const TrackParticleTruthCollection* tptc = 0;
184 if (m_sg->retrieve (tptc, keys[i]).isFailure() || !tptc)
185 {
186 ATH_MSG_WARNING( "Can't retrieve TrackParticleTruthCollection/"
187 << keys[i] );
188 continue;
189 }
190 tptruth_name = keys[i];
191
192 std::string target_tp_name;
194 // Older files didn't have this link. Hardcode this case.
195 target_tp_name = "TrackParticleCandidate";
196 }
197 else if (!tptc->trackParticleContainerLink().isValid())
198 continue;
199 else
200 target_tp_name = tptc->trackParticleContainerLink().dataID();
201
202 if (tp_name == target_tp_name)
203 return true;
204 }
205 return false;
206}
Athena::TPCnvVers::Old TrackParticleTruthCollection
bool isDefault() const
Test to see if we're in the default state.
DataLink< Rec::TrackParticleContainer > trackParticleContainerLink() const

◆ getGenPart()

const xAOD::TruthParticle * MCTruthClassifier::getGenPart ( const xAOD::TrackParticle * trk) const
inherited

Definition at line 98 of file MCRecoToTruth.cxx.

99{
100 // return GenParticle corresponding to given TrackParticle
101 ATH_MSG_DEBUG("Executing getGenPart ");
102 if (!trk) return nullptr;
103 uint8_t NumOfPixHits = 0;
104 uint8_t NumOfSCTHits = 0;
105 typedef ElementLink<xAOD::TruthParticleContainer> TruthLink_t;
106
107 static const SG::Accessor<TruthLink_t> tPL("truthParticleLink");
108 if (!tPL.isAvailable(*trk)) {
109 ATH_MSG_DEBUG("Track particle is not associated to truth particle");
110 return nullptr;
111 }
112
113 const auto& truthLink = tPL(*trk);
114 if (!truthLink.isValid()) {
115 ATH_MSG_DEBUG("Invalid link to truth particle");
116 return nullptr;
117 }
118
119 const xAOD::TruthParticle* theGenParticle = (*truthLink);
120 if (!theGenParticle) {
121 ATH_MSG_DEBUG("Could not find truth matching for track");
122 return nullptr;
123 }
124
125 if (theGenParticle->status() == 3) {
126 ATH_MSG_WARNING("track matched to the truth with status " << theGenParticle->status());
127 }
128 else if (MC::isDecayed(theGenParticle)) {
129 // Matching to status == 2 particles is to be expected if
130 // quasi-stable particle simulation was used.
131 ATH_MSG_DEBUG("track matched to the truth with status " << theGenParticle->status());
132 }
133
134 if (MC::isDecayed(theGenParticle) && (MC::isElectron(theGenParticle) || MC::isMuon(theGenParticle))) {
135 const xAOD::TruthVertex* EndVrtx = theGenParticle->decayVtx();
136 const xAOD::TruthParticle* theGenPartTmp(nullptr);
137
138 if (EndVrtx != nullptr) {
139 int itr = 0;
140 do {
141 theGenPartTmp = nullptr;
142 for (const auto & theDaugt: EndVrtx->particles_out()) {
143 if (!theDaugt) continue;
144 if (theDaugt->pdgId() == theGenParticle->pdgId()) theGenPartTmp = theDaugt;
145 if (theDaugt->pdgId() != theGenParticle->pdgId() && !MC::isPhoton(theDaugt)) theGenPartTmp = nullptr;
146 }
147 itr++;
148 if (itr > 100) {
149 ATH_MSG_WARNING("getGenPart infinite while");
150 break;
151 }
152 EndVrtx = theGenPartTmp ? theGenPartTmp->decayVtx() : nullptr;
153 } while (theGenPartTmp && theGenPartTmp->pdgId() == theGenParticle->pdgId() && MC::isDecayed(theGenPartTmp) && EndVrtx != nullptr);
154
155 if (theGenPartTmp && theGenPartTmp->pdgId() == theGenParticle->pdgId()) theGenParticle = theGenPartTmp;
156 }
157 }
158
159 if (!trk->summaryValue(NumOfSCTHits, xAOD::numberOfSCTHits)) ATH_MSG_DEBUG("Could not retrieve number of SCT hits");
160 if (!trk->summaryValue(NumOfPixHits, xAOD::numberOfPixelHits)) ATH_MSG_DEBUG("Could not retrieve number of Pixel hits");
161
162 uint8_t NumOfSiHits = NumOfSCTHits + NumOfPixHits;
163
164 float deltaPhi = std::abs(std::remainder(theGenParticle->phi() - trk->phi(), 2*std::numbers::pi));
165 float deteta = std::abs(theGenParticle->eta() - trk->eta());
166 float deltaRMatch = std::hypot(deltaPhi, deteta);
167 if ((NumOfSiHits > m_NumOfSiHitsCut && deltaRMatch > m_deltaRMatchCut) ||
168 (NumOfSiHits <= m_NumOfSiHitsCut && deltaPhi > m_deltaPhiMatchCut)) theGenParticle = nullptr;
169
170 ATH_MSG_DEBUG("getGenPart succeeded ");
171 return (theGenParticle);
172}
ElementLink< xAOD::TruthParticleContainer > TruthLink_t
int m_NumOfSiHitsCut
Si (pixel + SCT) hit count selecting between deltaRMatchCut and deltaPhiMatchCut.
float m_deltaPhiMatchCut
max delta phi track - truth particle if the track has at most NumOfSiHitsCut Si hits
float m_deltaRMatchCut
max dR track - truth particle if the track has more than NumOfSiHitsCut Si hits
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
bool summaryValue(uint8_t &value, const SummaryType &information) const
Accessor for TrackSummary values.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
int status() const
Status code.
int pdgId() const
PDG ID code.
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
std::vector< const TruthParticle * > particles_out() const
Get the outgoing particles.
bool isPhoton(const T &p)
bool isElectron(const T &p)
bool isMuon(const T &p)
bool isDecayed(const T &p)
Identify if the particle decayed.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:573
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::Event, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::Event, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ getProperty1()

void D3PD::D3PDMCTruthClassifier::getProperty1 ( const std::string & pname,
std::string & value )
private

Helper to retrieve the value of a Gaudi property.

Parameters
pnameThe name of the property. param value[out] The value of the property.

Definition at line 214 of file D3PDMCTruthClassifier.cxx.

216{
217 StatusCode sc = getProperty (pname, value);
218 if (sc.isFailure())
219 REPORT_ERROR (sc) << "Can't get property " << pname << "\n";
220}
#define REPORT_ERROR(SC)
Report an error.
static Double_t sc
const T * getProperty(const std::string &name) const
Get one of the tool's properties.
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ initialize()

StatusCode D3PD::D3PDMCTruthClassifier::initialize ( void )
virtual

Standard Gaudi initialize method.

Reimplemented from MCTruthClassifier.

Definition at line 51 of file D3PDMCTruthClassifier.cxx.

52{
54 CHECK( m_sg.retrieve() );
55 return StatusCode::SUCCESS;
56}
#define CHECK(...)
Evaluate an expression and check for errors.
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ particleTruthClassifier() [1/8]

IMCTruthClassifier::Result MCTruthClassifier::particleTruthClassifier ( const EventContext & ctx,
const xAOD::Electron * elec ) const
finaloverridevirtual

Reimplemented from MCTruthClassifier.

Definition at line 185 of file MCRecoToTruth.cxx.

22{
23 ATH_MSG_DEBUG("Executing egamma electron Classifier");
24 const xAOD::TruthParticle* genPart = nullptr;
25 const xAOD::TrackParticle* trkPtr = elec->trackParticle();
26 if (elec->author() != xAOD::EgammaParameters::AuthorFwdElectron ||trkPtr) {
27 // Central electron or forward electron with track (when reco
28 // implemented in the future)
29 if (!trkPtr){
30 return {Unknown, NonDefined, nullptr, UnknownOutCome};
31 }
32 genPart = getGenPart(trkPtr);
33 } else {
34#ifndef XAOD_ANALYSIS // cluster matching available only in Athena
35 const xAOD::CaloCluster* clus = elec->caloCluster();
36 genPart = egammaClusMatch(ctx, clus, true);
37#else
38 ATH_MSG_WARNING("Forward Electron classification using extrapolation to Calo is available only in Athena , check your enviroment. ");
39#endif
40 }
41
42 if (!genPart) return {Unknown, NonDefined, nullptr, UnknownOutCome};
43 ATH_MSG_DEBUG("egamma electron Classifier succeeded ");
44 return particleTruthClassifier(ctx, genPart);
45}
virtual std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > particleTruthClassifier(const xAOD::Electron *el)
Run the classifier for an electron.
const xAOD::TruthParticle * getGenPart(const xAOD::TrackParticle *) const
const xAOD::TruthParticle * egammaClusMatch(const EventContext &ctx, const xAOD::CaloCluster *, bool isFwrdEle) const
uint16_t author(uint16_t bitmask=EgammaParameters::AuthorALL) const
Get author.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
@ UnknownOutCome
End vertex exists, but its content matches none of the patterns below.
@ NonDefined
Origin could not be determined (no production vertex, no ancestor, or particle not classified).
@ Unknown
Not classified: not a lepton, photon, neutrino or hadron (e.g. a quark, a gluon, a boson),...
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
Definition EgammaDefs.h:30
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ particleTruthClassifier() [2/8]

IMCTruthClassifier::Result MCTruthClassifier::particleTruthClassifier ( const EventContext & ctx,
const xAOD::Photon * phot ) const
finaloverridevirtual

Reimplemented from MCTruthClassifier.

Definition at line 187 of file MCRecoToTruth.cxx.

49{
50 ATH_MSG_DEBUG("Executing egamma photon Classifier");
51 const xAOD::CaloCluster* clus = phot->caloCluster();
52 if (!clus) return {Unknown, NonDefined, nullptr, UnknownOutCome};
53 if (std::fabs(clus->eta()) > 10.0 || std::fabs(clus->phi()) > 6.28 || (clus->et()) <= 0.) return {Unknown, NonDefined, nullptr, UnknownOutCome};
54
55 const xAOD::TruthParticle* genPart = nullptr;
56#ifndef XAOD_ANALYSIS // Fwd electron available only in Athena
57 genPart = egammaClusMatch(ctx, clus, false);
58#else
59 ATH_MSG_WARNING("Photon Classification using extrapolation to Calo is available only in Athena , check your enviroment. ");
60#endif
61 if (!genPart) return {Unknown, NonDefined, nullptr, UnknownOutCome};
62 ATH_MSG_DEBUG("egamma photon Classifier succeeded ");
63 return particleTruthClassifier(ctx, genPart);
64}

◆ particleTruthClassifier() [3/8]

IMCTruthClassifier::Result MCTruthClassifier::particleTruthClassifier ( const EventContext & ctx,
const xAOD::TrackParticle * trkPtr ) const
finaloverridevirtual

Reimplemented from MCTruthClassifier.

Definition at line 183 of file MCRecoToTruth.cxx.

12{
13 ATH_MSG_DEBUG("Executing trackClassifier");
14 const xAOD::TruthParticle* genPart = getGenPart(trkPtr);
15 if (!genPart) return {Unknown, NonDefined, nullptr, UnknownOutCome};
16 ATH_MSG_DEBUG("trackClassifier succeeded ");
17 return particleTruthClassifier(ctx, genPart);
18}

◆ particleTruthClassifier() [4/8]

virtual Result MCTruthClassifier::particleTruthClassifier ( const EventContext & ctx,
const xAOD::TruthParticle * thePart ) const
inlinefinaloverridevirtual

Reimplemented from MCTruthClassifier.

Definition at line 155 of file MCTruthClassifier.h.

155 {
156 using namespace MCTruthPartClassifier;
157 if (!thePart) {
158 return {Unknown, NonDefined, nullptr, UnknownOutCome};
159 }
160
161 // retrieve collection and get a pointer
162 SG::ReadHandle<xAOD::TruthParticleContainer> truthParticleContainerReadHandle(m_truthParticleContainerKey, ctx);
163 if (!truthParticleContainerReadHandle.isValid()) {
164 ATH_MSG_WARNING(" Invalid ReadHandle for xAOD::TruthParticleContainer with key: " << truthParticleContainerReadHandle.key());
165 return {Unknown, NonDefined, thePart, UnknownOutCome};
166 }
167
169 const auto [type, origin] = classifyTruthParticle(*truthParticleContainerReadHandle, thePart, outCome);
170 return {type, origin, thePart, outCome};
171 }
struct TBPatternUnitContext Unknown
std::pair< ParticleType, ParticleOrigin > classifyTruthParticle(const xAOD::TruthParticleContainer &truthParticleContainer, const xAOD::TruthParticle *const thePart, ParticleOutCome &outCome)
Classify thePart (not nullptr), using truthParticleContainer to look up its ancestors.

◆ particleTruthClassifier() [5/8]

std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > D3PD::D3PDMCTruthClassifier::particleTruthClassifier ( const xAOD::Electron * el)
virtual

Run the classifier for an electron.

Parameters
elThe input electron.

Definition at line 65 of file D3PDMCTruthClassifier.cxx.

66{
67 // Try to find the name of the truth map container,
68 // given the name of the TrackParticleContainer.
69 bool got_names = false;
70 std::string tp_truth_name, tp_name;
71 if (el->trackParticleLink().isValid()) {
72 tp_name = el->trackParticleLink().dataID();
73 got_names = get_tptruth_name (tp_name, tp_truth_name);
74 }
75
76 // If we found the truth map container, diddle the properties
77 // for the base tool (remembering the original values).
78 std::string old_tp_truth_name, old_tp_name;
79 if (got_names) {
80 getProperty1 ("TrackParticleTruthCollection", old_tp_truth_name);
81 getProperty1 ("TrackParticleContainerName", old_tp_name);
82 setProperty1 ("TrackParticleTruthCollection", tp_truth_name);
83 setProperty1 ("TrackParticleContainerName", tp_name);
84 }
85
86 // Call the base tool.
90
91 // Restore original properties, if we changed them.
92 if (got_names) {
93 setProperty1 ("TrackParticleTruthCollection", old_tp_truth_name);
94 setProperty1 ("TrackParticleContainerName", old_tp_name);
95 }
96
97 return ret;
98}
bool get_tptruth_name(const std::string &tp_name, std::string &tptruth_name)
Try to find a TrackParticleTruthCollection pointing at TP_NAME.
void setProperty1(const std::string &pname, const std::string &value)
Helper to set the value of a Gaudi property.
void getProperty1(const std::string &pname, std::string &value)
Helper to retrieve the value of a Gaudi property.
virtual Result particleTruthClassifier(const EventContext &ctx, const xAOD::TruthParticle *thePart) const override final

◆ particleTruthClassifier() [6/8]

std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > D3PD::D3PDMCTruthClassifier::particleTruthClassifier ( const xAOD::Muon * mu)
virtual

Run the classifier for a muon.

This function is here to avoid a problem on the mc12 validation samples.

Parameters
elThe input photon.

Definition at line 155 of file D3PDMCTruthClassifier.cxx.

156{
157 // Avoid using forward muons that have a tracklet associated to them:
158 if( mu->muonType() == xAOD::Muon::MuonType::SiliconAssociatedForwardMuon ) {
160 }
161
162 // For all other muons just use the base class's function:
164}

◆ particleTruthClassifier() [7/8]

std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > D3PD::D3PDMCTruthClassifier::particleTruthClassifier ( const xAOD::Photon * ph)
virtual

Run the classifier for a photon.

Parameters
elThe input photon.

Definition at line 107 of file D3PDMCTruthClassifier.cxx.

108{
109 // Try to find the name of the truth map container,
110 // given the name of the TrackParticleContainer.
111 bool got_names = false;
112 std::string tp_truth_name, tp_name;
113 const xAOD::Vertex* vx = ph->vertex();
114 if (vx) {
116 for (auto trklink : links) {
117 if (trklink.isValid()) {
118 tp_name = trklink.dataID();
119 got_names = get_tptruth_name (tp_name, tp_truth_name);
120 if (got_names) break;
121 }
122 }
123 }
124
125 // If we found the truth map container, diddle the properties
126 // for the base tool (remembering the original values).
127 std::string old_tp_truth_name, old_tp_name;
128 if (got_names) {
129 getProperty1 ("TrackParticleTruthCollection", old_tp_truth_name);
130 getProperty1 ("TrackParticleContainerName", old_tp_name);
131 setProperty1 ("TrackParticleTruthCollection", tp_truth_name);
132 setProperty1 ("TrackParticleContainerName", tp_name);
133 }
134
135 // Call the base tool.
139
140 // Restore original properties, if we changed them.
141 if (got_names) {
142 setProperty1 ("TrackParticleTruthCollection", old_tp_truth_name);
143 setProperty1 ("TrackParticleContainerName", old_tp_name);
144 }
145
146 return ret;
147}
const xAOD::Vertex * vertex(size_t index=0) const
Pointer to the xAOD::Vertex/es that match the photon candidate.
Definition Photon_v1.cxx:61
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
std::vector< ElementLink< xAOD::TrackParticleContainer > > TrackParticleLinks_t
Type for the associated track particles.
Definition Vertex_v1.h:128
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ particleTruthClassifier() [8/8]

template<typename T>
std::pair< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin > IMCTruthClassifier::particleTruthClassifier ( const T * p,
std::optional< std::reference_wrapper< const EventContext > > ctx = std::nullopt ) const
inlineinherited

Definition at line 69 of file IMCTruthClassifier.h.

70 {
72 return {std::get<0>(r), std::get<1>(r)};
73 }
std::tuple< MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin, const xAOD::TruthParticle *, MCTruthPartClassifier::ParticleOutCome > Result
Result particleTruthClassifier_full(const T *p, std::optional< std::reference_wrapper< const EventContext > > ctx=std::nullopt) const
Returns more info than the particleTruthClassifier.
int r
Definition globals.cxx:22

◆ particleTruthClassifier_full()

template<typename T>
Result IMCTruthClassifier::particleTruthClassifier_full ( const T * p,
std::optional< std::reference_wrapper< const EventContext > > ctx = std::nullopt ) const
inlineinherited

Returns more info than the particleTruthClassifier.

Definition at line 64 of file IMCTruthClassifier.h.

64 {
65 return particleTruthClassifier(ctx ? ctx->get() : Gaudi::Hive::currentContext(), p);
66 }
virtual Result particleTruthClassifier(const EventContext &ctx, const xAOD::TruthParticle *) const =0

◆ print()

void asg::AsgTool::print ( ) const
virtualinherited

Print the state of the tool.

Implements asg::IAsgTool.

Reimplemented in AsgHelloTool, HI::HIPileupTool, JetFromPseudojet, JetPileupLabelingTool, JetPseudojetRetriever, JetSubStructureMomentToolsBase, JetTruthLabelingTool, and KtDeltaRTool.

Definition at line 131 of file AsgTool.cxx.

131 {
132
133 ATH_MSG_INFO( "AsgTool " << name() << " @ " << this );
134 return;
135 }
#define ATH_MSG_INFO(x,...)

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ setProperty1()

void D3PD::D3PDMCTruthClassifier::setProperty1 ( const std::string & pname,
const std::string & value )
private

Helper to set the value of a Gaudi property.

Parameters
pnameThe name of the property. param value The new value of the property.

Definition at line 228 of file D3PDMCTruthClassifier.cxx.

230{
231 StatusCode sc = setProperty (pname, value);
232 if (sc.isFailure())
233 REPORT_ERROR (sc) << "Can't set property " << pname << "\n";
234}
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_caloExtensionTool

ToolHandle<Trk::IParticleCaloExtensionTool> MCTruthClassifier::m_caloExtensionTool {this,"ParticleCaloExtensionTool",""}
privateinherited

Extrapolates truth particles to the calorimeter (egammaClusMatch); optional, disabled if empty.

Definition at line 215 of file MCTruthClassifier.h.

215{this,"ParticleCaloExtensionTool",""};

◆ m_caloMgrKey

SG::ReadCondHandleKey<CaloDetDescrManager> MCTruthClassifier::m_caloMgrKey {this,"CaloDetDescrManager",""}
privateinherited

Calorimeter detector description, needed together with the extension tool; optional, may be empty.

Definition at line 217 of file MCTruthClassifier.h.

217{this,"CaloDetDescrManager",""};

◆ m_deltaPhiMatchCut

float MCTruthClassifier::m_deltaPhiMatchCut
privateinherited

max delta phi track - truth particle if the track has at most NumOfSiHitsCut Si hits

Definition at line 247 of file MCTruthClassifier.h.

◆ m_deltaRMatchCut

float MCTruthClassifier::m_deltaRMatchCut
privateinherited

max dR track - truth particle if the track has more than NumOfSiHitsCut Si hits

Definition at line 246 of file MCTruthClassifier.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_FwdElectronTruthExtrEtaCut

float MCTruthClassifier::m_FwdElectronTruthExtrEtaCut
privateinherited

forward electrons: truth particles with |eta| below this are not extrapolated

Definition at line 225 of file MCTruthClassifier.h.

◆ m_FwdElectronTruthExtrEtaWindowCut

float MCTruthClassifier::m_FwdElectronTruthExtrEtaWindowCut
privateinherited

forward electrons: max |delta eta| to the cluster for a truth particle to be extrapolated

Definition at line 226 of file MCTruthClassifier.h.

◆ m_FwdElectronUseG4Sel

bool MCTruthClassifier::m_FwdElectronUseG4Sel
privateinherited

skip Geant4 particles also for forward electrons

Definition at line 224 of file MCTruthClassifier.h.

◆ m_fwrdEledRtoTrCut

float MCTruthClassifier::m_fwrdEledRtoTrCut
privateinherited

max dR cluster - extrapolated truth particle (forward electrons)

Definition at line 232 of file MCTruthClassifier.h.

◆ m_inclG4part

bool MCTruthClassifier::m_inclG4part
privateinherited

also try Geant4 particles if no generator particle matched

Definition at line 237 of file MCTruthClassifier.h.

◆ m_NumOfSiHitsCut

int MCTruthClassifier::m_NumOfSiHitsCut
privateinherited

Si (pixel + SCT) hit count selecting between deltaRMatchCut and deltaPhiMatchCut.

Definition at line 248 of file MCTruthClassifier.h.

◆ m_partExtrConeEta

float MCTruthClassifier::m_partExtrConeEta
privateinherited

eta half-width of the cone in which truth particles are extrapolated

Definition at line 227 of file MCTruthClassifier.h.

◆ m_partExtrConePhi

float MCTruthClassifier::m_partExtrConePhi
privateinherited

phi half-width of the cone in which truth particles are extrapolated

Definition at line 228 of file MCTruthClassifier.h.

◆ m_phtClasConeEta

float MCTruthClassifier::m_phtClasConeEta
privateinherited

eta half-width of the narrow cone around the cluster (not forward electrons)

Definition at line 230 of file MCTruthClassifier.h.

◆ m_phtClasConePhi

float MCTruthClassifier::m_phtClasConePhi
privateinherited

phi half-width of the narrow cone around the cluster (not forward electrons)

Definition at line 229 of file MCTruthClassifier.h.

◆ m_phtdRtoTrCut

float MCTruthClassifier::m_phtdRtoTrCut
privateinherited

max dR cluster - extrapolated truth particle (not forward electrons)

Definition at line 231 of file MCTruthClassifier.h.

◆ m_pTChargePartCut

float MCTruthClassifier::m_pTChargePartCut
privateinherited

minimum pT of charged truth particles considered

Definition at line 235 of file MCTruthClassifier.h.

◆ m_pTNeutralPartCut

float MCTruthClassifier::m_pTNeutralPartCut
privateinherited

minimum pT of neutral truth particles considered

Definition at line 236 of file MCTruthClassifier.h.

◆ m_ROICone

bool MCTruthClassifier::m_ROICone
privateinherited

only extrapolate truth particles inside the partExtrCone ellipse

Definition at line 233 of file MCTruthClassifier.h.

◆ m_sg

ServiceHandle<StoreGateSvc> D3PD::D3PDMCTruthClassifier::m_sg
private

The StoreGate service.

Definition at line 119 of file D3PDMCTruthClassifier.h.

◆ m_truthInConeTool

ToolHandle<xAOD::ITruthParticlesInConeTool> MCTruthClassifier::m_truthInConeTool {this,"TruthInConeTool","xAOD::TruthParticlesInConeTool/TruthParticlesInConeTool"}
privateinherited

Finds the truth particles in a cone around a cluster (egammaClusMatch); optional, disabled if empty.

Definition at line 220 of file MCTruthClassifier.h.

220{this,"TruthInConeTool","xAOD::TruthParticlesInConeTool/TruthParticlesInConeTool"};

◆ m_truthLinkVecReadHandleKey

SG::ReadHandleKey<xAODTruthParticleLinkVector> MCTruthClassifier::m_truthLinkVecReadHandleKey {this,"xAODTruthLinkVector","xAODTruthLinks", "ReadHandleKey for xAODTruthParticleLinkVector"}
privateinherited

Definition at line 242 of file MCTruthClassifier.h.

242{this,"xAODTruthLinkVector","xAODTruthLinks", "ReadHandleKey for xAODTruthParticleLinkVector"};

◆ m_truthParticleContainerKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> MCTruthClassifier::m_truthParticleContainerKey {this,"xAODTruthParticleContainerName","TruthParticles","ReadHandleKey for xAOD::TruthParticleContainer"}
privateinherited

Key of the xAOD truth particle container that is searched when classifying (ancestors, decay products, ...).

Definition at line 211 of file MCTruthClassifier.h.

211{this,"xAODTruthParticleContainerName","TruthParticles","ReadHandleKey for xAOD::TruthParticleContainer"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 386 of file AthCommonDataStore.h.


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