ATLAS Offline Software
egammaTruthClassificationFillerTool.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$
15 #include "xAODEgamma/Egamma.h"
16 #include "xAODEgamma/Electron.h"
17 #include "xAODEgamma/Photon.h"
20 #include <cstdlib>
21 
22 
23 namespace D3PD {
24 
25 
33  (const std::string& type,
34  const std::string& name,
35  const IInterface* parent)
37  m_classifier ("MCTruthClassifier")
38 {
39  declareProperty ("Classifier", m_classifier, "Classifier tool instance.");
40 
41  declareProperty ("DoBkgElecOrigin", m_doBkgElecOrigin = false,
42  "If true, fill in variables for the origin and type "
43  " of a photon for background electrons from conversions.");
44 
45  book().ignore(); // Avoid coverity warnings.
46 }
47 
48 
53 {
55  CHECK( m_classifier.retrieve() );
56  return StatusCode::SUCCESS;
57 }
58 
59 
64 {
65  CHECK( addVariable ("type", m_type,
66  "MC particle type, from classifier tool.") );
67  CHECK( addVariable ("origin", m_origin,
68  "MC particle origin, from classifier tool.") );
69 
70  if (m_doBkgElecOrigin) {
71  CHECK( addVariable ("typebkg", m_typebkg,
72  "Type of photon for background electron "
73  "from conversions, from classifier tool") );
74  CHECK( addVariable ("originbkg", m_originbkg,
75  "Origin of photon for background electron "
76  "from conversions, from classifier tool.") );
77  }
78 
79  return StatusCode::SUCCESS;
80 }
81 
82 
92 {
95 
97  if (const xAOD::Electron* q =
98  dynamic_cast<const xAOD::Electron*>(&p))
99  {
100  res = m_classifier->particleTruthClassifier (q, &info);
101  }
102  else if (const xAOD::Photon* q =
103  dynamic_cast<const xAOD::Photon*>(&p))
104  {
105  res = m_classifier->particleTruthClassifier (q, &info);
106  }
107  else
108  std::abort();
109 
110  *m_type = res.first;
111  *m_origin = res.second;
112 
113  if (m_doBkgElecOrigin) {
116  info.genPart)
117  {
119  if(last){
120  res = m_classifier->particleTruthClassifier(last, &info);
121  *m_typebkg = res.first;
122  *m_originbkg = res.second;
123  }
124  }
125  }
126 
127  return StatusCode::SUCCESS;
128 }
129 
130 
131 } // namespace D3PD
grepfile.info
info
Definition: grepfile.py:38
Egamma
Definition: ClusMomentumPlots.cxx:11
PhotonConv
@ PhotonConv
Definition: TruthClasses.h:59
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
D3PD::AddVariable::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
Definition: AddVariable.cxx:85
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
xAOD::EgammaHelpers::getBkgElectronMother
const xAOD::TruthParticle * getBkgElectronMother(const xAOD::Electron *el, const bool allTheWayBack=true)
Helper wrapper function for calling the function above extracting the truth from a reco electron.
Definition: EgammaTruthxAODHelpers.cxx:133
D3PD::egammaTruthClassificationFillerTool::fill
virtual StatusCode fill(const xAOD::Egamma &p) override
Fill one block — type-safe version.
Definition: egammaTruthClassificationFillerTool.cxx:91
egammaTruthClassificationFillerTool.h
Fill in type/origin from MC classifier tool for an egamma.
Egamma.h
D3PD
Block filler tool for noisy FEB information.
Definition: CaloCellDetailsFillerTool.cxx:29
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
D3PD::egammaTruthClassificationFillerTool::initialize
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Definition: egammaTruthClassificationFillerTool.cxx:52
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
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
test_pyathena.parent
parent
Definition: test_pyathena.py:15
D3PD::BlockFillerTool
Type-safe wrapper for block filler tools.
Definition: BlockFillerTool.h:65
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::egammaTruthClassificationFillerTool::m_doBkgElecOrigin
bool m_doBkgElecOrigin
Property: Should we fill origin of background electrons?
Definition: egammaTruthClassificationFillerTool.h:75
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
D3PD::egammaTruthClassificationFillerTool::m_origin
int * m_origin
Variable: Particle origin.
Definition: egammaTruthClassificationFillerTool.h:83
errorcheck.h
Helpers for checking error return status codes and reporting errors.
D3PD::egammaTruthClassificationFillerTool::m_type
int * m_type
Variable: Particle type.
Definition: egammaTruthClassificationFillerTool.h:79
xAOD::Electron_v1
Definition: Electron_v1.h:34
D3PD::egammaTruthClassificationFillerTool::m_classifier
ToolHandle< IMCTruthClassifier > m_classifier
Property: classifier tool.
Definition: egammaTruthClassificationFillerTool.h:71
D3PD::egammaTruthClassificationFillerTool::m_typebkg
int * m_typebkg
Variable: Type of photon for background electron from conversions.
Definition: egammaTruthClassificationFillerTool.h:87
D3PD::egammaTruthClassificationFillerTool::book
virtual StatusCode book() final
Book variables for this block.
Definition: egammaTruthClassificationFillerTool.cxx:63
xAOD::Photon_v1
Definition: Photon_v1.h:37
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
extractSporadic.q
list q
Definition: extractSporadic.py:98
Electron.h
D3PD::egammaTruthClassificationFillerTool::m_originbkg
int * m_originbkg
Variable: Origin of photon for background electron from conversions.
Definition: egammaTruthClassificationFillerTool.h:91
ParticleType
ParticleType
Definition: TruthClasses.h:8
MCTruthPartClassifier::Info
Definition: IMCTruthClassifier.h:49
BkgElectron
@ BkgElectron
Definition: TruthClasses.h:13
D3PD::egammaTruthClassificationFillerTool::egammaTruthClassificationFillerTool
egammaTruthClassificationFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: egammaTruthClassificationFillerTool.cxx:33
EgammaTruthxAODHelpers.h