ATLAS Offline Software
Loading...
Searching...
No Matches
MuonGenParticleAssociationTool.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 "xAODMuon/Muon.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 : Base (type, name, parent),
37 m_classifier ("MCTruthClassifier")
38{
39 declareProperty ("Classifier", m_classifier, "Classifier tool instance.");
40 declareProperty ("DRVar", m_drvar,
41 "If not empty, the variable name to use for DR.");
42
43 m_dr = nullptr;
44}
45
46
51{
52 CHECK( Base::initialize() );
53 CHECK( m_classifier.retrieve() );
54 return StatusCode::SUCCESS;
55}
56
57
62{
63 if (!m_drvar.empty())
65 return StatusCode::SUCCESS;
66}
67
68
77{
79 const xAOD::TruthParticle* out = nullptr;
80 if (m_classifier->particleTruthClassifier (&p, &info).first !=
82 {
83 out = info.genPart;
84 }
85
86 if (!m_drvar.empty()) {
87 if (out)
88 *m_dr = p.p4().DeltaR(out->p4());
89 else
90 *m_dr = -999;
91 }
92
93 return out;
94}
95
96
97} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Associate from a muon to a matched GenParticle via classification tool.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
SingleAssociationTool< xAOD::Muon, xAOD::TruthParticle > Base
MuonGenParticleAssociationTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
std::string m_drvar
Property: If not empty, the variable name to use for DR.
StatusCode initialize()
Standard Gaudi initialize method.
ToolHandle< IMCTruthClassifier > m_classifier
Property: classifier tool.
virtual const xAOD::TruthParticle * get(const xAOD::Muon &p)
Return the target object.
float * m_dr
Variable: DR between reco and truth.
StatusCode book()
Create any needed tuple variables.
Block filler tool for noisy FEB information.
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version: