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

#include <PhotonTruthTool.h>

Inheritance diagram for D3PD::PhotonTruthTool:
Collaboration diagram for D3PD::PhotonTruthTool:

Public Member Functions

 PhotonTruthTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Gaudi tool constructor.
virtual StatusCode initialize ()
 Standard Gaudi initialize method.
const xAOD::TruthParticletoTruthParticle (const xAOD::Photon &g) const
 Go from a photon to a matching TruthParticle.
bool getMCConv (const xAOD::TruthParticle *truePart, float &RconvMC, float &ZconvMC) const
 Check a truth particle for a conversion.
bool isPromptPhotonMC (const xAOD::TruthParticle *truePart) const
 Test for a prompt photon.
bool isPromptParticleMC (const xAOD::TruthParticle *truePart) const
 Test for a prompt particle.
bool isQuarkBremMC (const xAOD::TruthParticle *truePart) const
 Test for a brem.
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

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< StoreGateSvcStoreGateSvc_t

Private Member Functions

bool isFinalStatePhotonMC (const xAOD::TruthParticle *truePart) const
 Test for a final-state photon.
bool isFinalState (const xAOD::TruthParticle *truePart) const
 Test for a final-state particle.
const xAOD::TruthParticlegetMother (const xAOD::TruthParticle *p) const
 Get the (first) mother particle of p.
const xAOD::TruthVertexgetMotherVert (const xAOD::TruthParticle *p) const
 Get the mother vertex for p.
std::vector< const xAOD::TruthParticle * > getMothers (const xAOD::TruthParticle *p) const
 Return list of mother particles of p.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< IMCTruthClassifierm_classifier
 Property: classifier tool.
float m_zTruthConv
 Property: Conversion vertex z cut.
float m_rTruthConv
 Property: Conversion vertex r cut.
bool m_useG4Particles
 Property.
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

Definition at line 33 of file PhotonTruthTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ PhotonTruthTool()

D3PD::PhotonTruthTool::PhotonTruthTool ( 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 30 of file PhotonTruthTool.cxx.

33 : AthAlgTool (type, name, parent),
34 m_classifier ("MCTruthClassifier")
35{
36 declareProperty ("Classifier", m_classifier, "Classifier tool instance.");
37 declareProperty ("ZTruthConv", m_zTruthConv = 50e3);
38 declareProperty ("RTruthConv", m_rTruthConv = 800);
39 declareProperty ("UseG4Particles", m_useG4Particles = false);
40}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< IMCTruthClassifier > m_classifier
Property: classifier tool.
bool m_useG4Particles
Property.
float m_zTruthConv
Property: Conversion vertex z cut.
float m_rTruthConv
Property: Conversion vertex r cut.

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 }

◆ 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.

◆ 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

◆ getMCConv()

bool D3PD::PhotonTruthTool::getMCConv ( const xAOD::TruthParticle * truePart,
float & RconvMC,
float & ZconvMC ) const

Check a truth particle for a conversion.

Parameters
truePartThe particle to check.
[out]RconvMCRadius of the conversion.
[out]ZconvMCZ of the conversion.
Returns
True if this is a conversion; otherwise false.

Definition at line 76 of file PhotonTruthTool.cxx.

79{
80 RconvMC = +9.999e+10 ;
81 ZconvMC = +9.999e+10 ;
82 if (!truePart) return false;
83
84 const xAOD::TruthVertex* v = truePart->decayVtx();
85 if (!v || v->nOutgoingParticles() < 2)
86 return false;
87
88 int pdgId = truePart->pdgId();
89
90 RconvMC = v->perp();
91 ZconvMC = v->z();
92
93 bool OKint = ( RconvMC < m_rTruthConv ) && ( fabs(ZconvMC) < m_zTruthConv );
94
95 if ( pdgId == 22 ) { // photon
96 if ( v->nOutgoingParticles() == 2 ) {
97 int pdgChild[2] = {0};
98 for ( unsigned u=0; u<2 ; ++u) {
99 const xAOD::TruthParticle* p = v->outgoingParticle(u);
100 if (p)
101 pdgChild[u] = p->pdgId();
102 }
103 if ( pdgChild[0]+pdgChild[1]==0 && pdgChild[0]*pdgChild[1]==-121 ) {
104 // gamma -> e+e-
105 return OKint ;
106 }
107 }
108 }
109 else if ( std::abs(pdgId) == 11 ) { // e+/e-
110 v = truePart->prodVtx();
111 if ( v->nIncomingParticles()==1 && v->nOutgoingParticles()==2 ) {
112 int pdgBrother[2] = {0};
113 for ( unsigned u=0 ; u<2 ; ++u ) {
114 const xAOD::TruthParticle* p = v->outgoingParticle(u);
115 if (p)
116 pdgBrother[u] = p->pdgId();
117 }
118 if ( pdgBrother[0]+pdgBrother[1]==(22+pdgId) &&
119 pdgBrother[0]*pdgBrother[1]==(22*pdgId) )
120 {
121 // e(+/-) -> e(+/-)gamma
122 return OKint ;
123 }
124 }
125 }
126 return false ;
127}
int pdgId() const
PDG ID code.
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ getMother()

const xAOD::TruthParticle * D3PD::PhotonTruthTool::getMother ( const xAOD::TruthParticle * p) const
private

Get the (first) mother particle of p.

Definition at line 253 of file PhotonTruthTool.cxx.

254{
255 const xAOD::TruthVertex* v = getMotherVert (p);
256
257 if (!v || v->nIncomingParticles() == 0)
258 return 0;
259
260 return v->incomingParticle(0);
261}
const xAOD::TruthVertex * getMotherVert(const xAOD::TruthParticle *p) const
Get the mother vertex for p.

◆ getMothers()

std::vector< const xAOD::TruthParticle * > D3PD::PhotonTruthTool::getMothers ( const xAOD::TruthParticle * p) const
private

Return list of mother particles of p.

Definition at line 268 of file PhotonTruthTool.cxx.

269{
270 std::vector<const xAOD::TruthParticle*> out;
271 const xAOD::TruthVertex* v = getMotherVert (p);
272
273 if (v) {
274 int n = v->nIncomingParticles();
275 out.reserve (n);
276 for (int i = 0; i < n; i++)
277 out.push_back (v->incomingParticle(i));
278 }
279
280 return out;
281}

◆ getMotherVert()

const xAOD::TruthVertex * D3PD::PhotonTruthTool::getMotherVert ( const xAOD::TruthParticle * p) const
private

Get the mother vertex for p.

Definition at line 233 of file PhotonTruthTool.cxx.

234{
235 const xAOD::TruthVertex* v = p->prodVtx();
236
237 // if mother is a duplicate, try climbing up the tree by one step...
238 while (v && v->nIncomingParticles() == 1 &&
239 v->incomingParticle(0)->pdgId() == p->pdgId())
240 {
241 p = v->incomingParticle(0);
242 v = p->prodVtx();
243 }
244
245 return v;
246}

◆ initialize()

StatusCode D3PD::PhotonTruthTool::initialize ( )
virtual

Standard Gaudi initialize method.

Definition at line 46 of file PhotonTruthTool.cxx.

47{
48 CHECK( AthAlgTool::initialize() );
49 CHECK( m_classifier.retrieve() );
50 return StatusCode::SUCCESS;
51}
#define CHECK(...)
Evaluate an expression and check for errors.

◆ 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.

◆ isFinalState()

bool D3PD::PhotonTruthTool::isFinalState ( const xAOD::TruthParticle * truePart) const
private

Test for a final-state particle.

Definition at line 205 of file PhotonTruthTool.cxx.

206{
207 if ( truePart == nullptr ) return false;
208 if ( !MC::isStable(truePart)) return false;
209 if ( !m_useG4Particles ) return ( !HepMC::is_simulation_particle(truePart) );
210 // if it is a photon, keep it regardless of its Geant interaction
211 if ( MC::isPhoton(truePart) ) return true ;
212 // reject Geant electron from conversion
213 if ( MC::isElectron(truePart) && HepMC::is_simulation_particle(truePart) ) {
214 const xAOD::TruthParticle* mother = getMother(truePart) ;
215 if ( mother!=0 && MC::isPhoton(mother) ) return false ;
216 }
217
218 // reject particles interacted in detector
219 const xAOD::TruthVertex* v = truePart->decayVtx();
220 if (!v) return false;// should never happen, but just in case...
221 if ( v->nOutgoingParticles()>0 ) {
222 if ( v->perp()<m_rTruthConv
223 && fabs(v->z())<m_zTruthConv ) return false ;
224 }
225 return true ;
226}
const xAOD::TruthParticle * getMother(const xAOD::TruthParticle *p) const
Get the (first) mother particle of p.
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
bool isPhoton(const T &p)
bool isElectron(const T &p)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.

◆ isFinalStatePhotonMC()

bool D3PD::PhotonTruthTool::isFinalStatePhotonMC ( const xAOD::TruthParticle * truePart) const
private

Test for a final-state photon.

Definition at line 194 of file PhotonTruthTool.cxx.

196{
197 return ( isFinalState(truePart) && MC::isPhoton(truePart) ) ;
198}
bool isFinalState(const xAOD::TruthParticle *truePart) const
Test for a final-state particle.

◆ isPromptParticleMC()

bool D3PD::PhotonTruthTool::isPromptParticleMC ( const xAOD::TruthParticle * truePart) const

Test for a prompt particle.

Definition at line 143 of file PhotonTruthTool.cxx.

145{
146 if ( truePart == 0 ) return false ;
147 const std::vector<const xAOD::TruthParticle*> mothers =
148 getMothers(truePart);
149 unsigned nmothers = mothers.size() ;
150 if ( nmothers == 0 ) {
151 // particles with NO mother are NEVER classified as PROMPT:
152 return false ;
153 }
154 else if ( nmothers == 1 ) {
155 // particles with ONE mother are classified as PROMPT if coming
156 // from non-QCD-boson decay:
157 // (including exotics like heavy bosons, MSSM Higgs, graviton)
158 int aPdgMother = abs(mothers[0]->pdgId());
159 return (( aPdgMother>=23 && aPdgMother<=39 ) || aPdgMother==5000039 ) ;
160 }
161 else {
162 // particles with more mothers are classified as PROMPT
163 // if they come from at least 1 parton:
164 // (is this sensible?)
165 int nParentPartons = 0 ;
166 for ( unsigned u=0 ; u<nmothers ; ++u ) {
167 int pdgMother = mothers[u]->pdgId() ;
168 if ( pdgMother==21 || ( std::abs(pdgMother)<7 && pdgMother!=0 ) )
169 ++nParentPartons ;
170 }
171 return ( nParentPartons >= 1 ) ;
172 }
173}
std::vector< const xAOD::TruthParticle * > getMothers(const xAOD::TruthParticle *p) const
Return list of mother particles of p.

◆ isPromptPhotonMC()

bool D3PD::PhotonTruthTool::isPromptPhotonMC ( const xAOD::TruthParticle * truePart) const

Test for a prompt photon.

Definition at line 133 of file PhotonTruthTool.cxx.

135{
136 return ( isFinalStatePhotonMC(truePart) && isPromptParticleMC(truePart) ) ;
137}
bool isFinalStatePhotonMC(const xAOD::TruthParticle *truePart) const
Test for a final-state photon.
bool isPromptParticleMC(const xAOD::TruthParticle *truePart) const
Test for a prompt particle.

◆ isQuarkBremMC()

bool D3PD::PhotonTruthTool::isQuarkBremMC ( const xAOD::TruthParticle * truePart) const

Test for a brem.

Definition at line 179 of file PhotonTruthTool.cxx.

181{
182 if ( ! isFinalStatePhotonMC(truePart) ) return false ;
183 const std::vector<const xAOD::TruthParticle*> mothers =
184 getMothers(truePart) ;
185 if ( mothers.size() != 1 ) return false ;
186 int pdgMother = mothers[0]->pdgId() ;
187 return ( pdgMother==21 || ( std::abs(pdgMother)<7 && pdgMother!=0 ) ) ;
188}

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ 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.

◆ 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 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
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 364 of file AthCommonDataStore.h.

364 {
366 }

◆ 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 >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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.

◆ toTruthParticle()

const xAOD::TruthParticle * D3PD::PhotonTruthTool::toTruthParticle ( const xAOD::Photon & g) const

Go from a photon to a matching TruthParticle.

Parameters
gThe input photon.
cacheTruth classifier association cache.
Returns
The matching TruthParticle, or null.
Parameters
gThe input photon.
Returns
The matching TruthParticle, or null.

Definition at line 60 of file PhotonTruthTool.cxx.

61{
62 MCTruthPartClassifier::Info info;
63 m_classifier->particleTruthClassifier (&g, &info);
64 return info.genPart;
65}

◆ updateVHKA()

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

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_classifier

ToolHandle<IMCTruthClassifier> D3PD::PhotonTruthTool::m_classifier
private

Property: classifier tool.

Definition at line 110 of file PhotonTruthTool.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_rTruthConv

float D3PD::PhotonTruthTool::m_rTruthConv
private

Property: Conversion vertex r cut.

Definition at line 116 of file PhotonTruthTool.h.

◆ m_useG4Particles

bool D3PD::PhotonTruthTool::m_useG4Particles
private

Property.

Definition at line 119 of file PhotonTruthTool.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_zTruthConv

float D3PD::PhotonTruthTool::m_zTruthConv
private

Property: Conversion vertex z cut.

Definition at line 113 of file PhotonTruthTool.h.


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