ATLAS Offline Software
PhotonTruthAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
14 #include "PhotonTruthAlg.h"
15 #include "PhotonTruthTool.h"
17 #include "xAODEgamma/Photon.h"
19 
20 
21 namespace D3PD {
22 
23 
25  ISvcLocator* svcloc)
26  : AthAlgorithm (name, svcloc),
27  m_truthTool ("D3PD::PhotonTruthTool", this),
28  m_photonGetter (this)
29 {
30  declareProperty ("AuxPrefix", m_auxPrefix,
31  "Prefix to add to aux data items.");
32  declareProperty ("TruthTool", m_truthTool,
33  "Photon truth analysis tool instance.");
34  declareProperty ("PhotonGetter", m_photonGetter,
35  "Getter instance for the input photon objects.");
36  declareProperty ("AllowMissing", m_allowMissing = false,
37  "If true, don't complain if input objects are missing.");
38 }
39 
40 
45 {
47  CHECK( m_truthTool.retrieve() );
48  CHECK( m_photonGetter.retrieve() );
49  CHECK( m_photonGetter->configureD3PD<xAOD::Photon>() );
50  return StatusCode::SUCCESS;
51 }
52 
53 
58 {
59 #define DECOR(TYPE,N) xAOD::Photon::Decorator<TYPE> N (m_auxPrefix + #N)
60  DECOR(bool, truth_isConv);
61  DECOR(float, truth_Rconv);
62  DECOR(float, truth_zconv);
63  DECOR(bool, truth_isPhotonFromHardProc);
64  DECOR(bool, truth_isFromHardProc);
65  DECOR(bool, truth_isBrem);
66 #undef DECOR
67 
69  while (const xAOD::Photon* g =
71  {
72  const xAOD::TruthParticle* p = m_truthTool->toTruthParticle (*g);
73 
74  truth_isConv(*g) = m_truthTool->getMCConv (p,
75  truth_Rconv(*g),
76  truth_zconv(*g));
77 
78  truth_isPhotonFromHardProc(*g) = m_truthTool->isPromptPhotonMC(p);
79  truth_isFromHardProc(*g) = m_truthTool->isPromptParticleMC(p);
80 
81  truth_isBrem(*g) = !truth_isPhotonFromHardProc(*g) && m_truthTool->isQuarkBremMC(p) ;
82 
83  m_photonGetter->releaseElement (g);
84  }
85 
86  return StatusCode::SUCCESS;
87 }
88 
89 
90 } // namespace D3PD
D3PD::PhotonTruthAlg::m_truthTool
ToolHandle< PhotonTruthTool > m_truthTool
Property: Truth analysis tool.
Definition: PhotonTruthAlg.h:60
D3PD::PhotonTruthAlg::m_photonGetter
ToolHandle< ICollectionGetterTool > m_photonGetter
Property: Getter for input photon objects.
Definition: PhotonTruthAlg.h:63
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
initialize
void initialize()
Definition: run_EoverP.cxx:894
ICollectionGetterTool.h
Abstract interface to get a collection of objects and iterate over it.
PhotonTruthAlg.h
Analyze GenParticle's matching photons and make UD decorations.
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
PhotonTruthTool.h
Helpers to categorize photon TruthParticle's.
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
Photon.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
D3PD::PhotonTruthAlg::execute
virtual StatusCode execute()
Standard Gaudi execute method.
Definition: PhotonTruthAlg.cxx:57
D3PD::PhotonTruthAlg::initialize
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition: PhotonTruthAlg.cxx:44
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DECOR
#define DECOR(TYPE, N)
errorcheck.h
Helpers for checking error return status codes and reporting errors.
D3PD::PhotonTruthAlg::m_allowMissing
bool m_allowMissing
Property: If true, don't complain if input objects are missing.
Definition: PhotonTruthAlg.h:66
D3PD::PhotonTruthAlg::m_auxPrefix
std::string m_auxPrefix
Property: Prefix to add to aux data items.
Definition: PhotonTruthAlg.h:57
xAOD::Photon_v1
Definition: Photon_v1.h:37
D3PD::PhotonTruthAlg::PhotonTruthAlg
PhotonTruthAlg(const std::string &name, ISvcLocator *svcloc)
Standard Gaudi algorithm constructor.
Definition: PhotonTruthAlg.cxx:24