ATLAS Offline Software
Loading...
Searching...
No Matches
egammaGenParticleAssociationTool.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$
13
14
16#include "xAODEgamma/Egamma.h"
17#include "xAODEgamma/Electron.h"
18#include "xAODEgamma/Photon.h"
22#include "AtlasHepMC/GenEvent.h"
23#include <cstdlib>
24
25
26namespace D3PD {
27
28
36 (const std::string& type,
37 const std::string& name,
38 const IInterface* parent)
39 : Base (type, name, parent),
40 m_classifier ("MCTruthClassifier")
41{
42 declareProperty ("Classifier", m_classifier, "Classifier tool instance.");
43 declareProperty ("DRVar", m_drvar,
44 "If not empty, the variable name to use for DR.");
45
46 m_dr = 0;
47}
48
49
54{
55 CHECK( Base::initialize() );
56 CHECK( m_classifier.retrieve() );
57 return StatusCode::SUCCESS;
58}
59
60
65{
66 if (!m_drvar.empty())
68 return StatusCode::SUCCESS;
69}
70
71
80{
82 if (const xAOD::Electron* q =
83 dynamic_cast<const xAOD::Electron*> (&p))
84 {
85 m_classifier->particleTruthClassifier (q, &info);
86 }
87 else if (const xAOD::Photon* q =
88 dynamic_cast<const xAOD::Photon*> (&p))
89 {
90 m_classifier->particleTruthClassifier (q, &info);
91 }
92 else
93 std::abort();
94
95 const xAOD::TruthParticle* out = info.genPart;
96
97 if (!m_drvar.empty()) {
98 if (out)
99 *m_dr = p.p4().DeltaR (out->p4());
100 else
101 *m_dr = -999;
102 }
103
104 return out;
105}
106
107
108} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
StatusCode initialize()
Standard Gaudi initialize method.
std::string m_drvar
Property: If not empty, the variable name to use for DR.
ToolHandle< IMCTruthClassifier > m_classifier
Property: classifier tool.
SingleAssociationTool< xAOD::Egamma, xAOD::TruthParticle > Base
StatusCode book()
Create any needed tuple variables.
virtual const xAOD::TruthParticle * get(const xAOD::Egamma &p)
Return the target object.
float * m_dr
Variable: DR between reco and truth.
egammaGenParticleAssociationTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Associate from an electron to a matched GenParticle via classification tool.
Block filler tool for noisy FEB information.
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".