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{
93 std::tuple<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin, const xAOD::TruthParticle*,MCTruthPartClassifier::ParticleOutCome> res;
94
95 if (const xAOD::Electron* q =
96 dynamic_cast<const xAOD::Electron*>(&p))
97 {
98 res = m_classifier->particleTruthClassifier_full (q);
99 }
100 else if (const xAOD::Photon* q =
101 dynamic_cast<const xAOD::Photon*>(&p))
102 {
103 res = m_classifier->particleTruthClassifier_full (q);
104 }
105 else
106 std::abort();
107
108 std::tie(*m_type, *m_origin, std::ignore, std::ignore) = res;
109
110 if (m_doBkgElecOrigin) {
111 if (std::get<0>(res) == MCTruthPartClassifier::BkgElectron &&
112 std::get<1>(res) == MCTruthPartClassifier::PhotonConv &&
113 std::get<2>(res))
114 {
116 if(last){
117 std::tie(*m_typebkg, *m_originbkg, std::ignore, std::ignore) = m_classifier->particleTruthClassifier_full(last);
118 }
119 }
120 }
121
122 return StatusCode::SUCCESS;
123}
124
125
126} // 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".