ATLAS Offline Software
Loading...
Searching...
No Matches
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$
12
13
15#include "xAODEgamma/Egamma.h"
16#include "xAODEgamma/Electron.h"
17#include "xAODEgamma/Photon.h"
20#include <cstdlib>
21
22
23namespace D3PD {
24
25
33 (const std::string& type,
34 const std::string& name,
35 const IInterface* parent)
36 : BlockFillerTool<xAOD::Egamma> (type, name, 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
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
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
std::pair< std::vector< unsigned int >, bool > res
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Type-safe wrapper for block filler tools.
ToolHandle< IMCTruthClassifier > m_classifier
Property: classifier tool.
virtual StatusCode fill(const xAOD::Egamma &p) override
Fill one block — type-safe version.
egammaTruthClassificationFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
int * m_originbkg
Variable: Origin of photon for background electron from conversions.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
virtual StatusCode book() final
Book variables for this block.
bool m_doBkgElecOrigin
Property: Should we fill origin of background electrons?
int * m_typebkg
Variable: Type of photon for background electron from conversions.
Fill in type/origin from MC classifier tool for an egamma.
Block filler tool for noisy FEB information.
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.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
TruthParticle_v1 TruthParticle
Typedef to implementation.
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".