ATLAS Offline Software
Loading...
Searching...
No Matches
AsgNumDecorationSelectionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7namespace CP
8{
9
10 #ifndef XAOD_STANDALONE
11 template <typename T>
13 const std::string& type,
14 const std::string& myname,
15 const IInterface* parent)
16 : asg::AsgTool(std::string(asg::ptrToString(parent))+"#"+type+"/"+myname)
17 {
18 // cppcheck-suppress missingReturn; false positive
19 }
20 template <typename T>
24 #else
25 template <typename T>
27 : asg::AsgTool(myname)
28 {
29 }
30 #endif
31
32 template <typename T>
34 {
35 if (m_doEqual) {
36 if (m_doMin || m_doMax) {
37 ATH_MSG_WARNING("Equal cut overrides min/max on \"" << m_name << "\"; disabling min/max.");
38 m_doMin = false;
39 m_doMax = false;
40 }
41 ATH_MSG_DEBUG("Applying " << m_name << " == " << m_equal << " selection");
42 m_equalCutIndex = m_accept.addCut("equal", "Exact equality cut");
43 }
44
45 if (m_doMin) {
46 ATH_MSG_DEBUG("Applying " << m_name << " >= " << m_min << " selection");
47 m_minCutIndex = m_accept.addCut("min", "Minimum cut");
48 }
49
50 if (m_doMax) {
51 ATH_MSG_DEBUG("Applying " << m_name << " < " << m_max << " selection");
52 m_maxCutIndex = m_accept.addCut("max", "Maximum cut");
53 }
54
55 // Construct the decoration accessor for the desired type
56 m_accessor = std::make_unique<SG::ConstAccessor<T>>(m_name);
57
58 return StatusCode::SUCCESS;
59 }
60
61 template <typename T>
66
67 template <typename T>
69 {
71
72 if (!m_accessor->isAvailable(*particle)) {
73 ATH_MSG_WARNING("Decoration \"" << m_name << "\" not available; setting all cuts as passed.");
74 if (m_equalCutIndex >= 0) accept.setCutResult(m_equalCutIndex, true);
75 if (m_minCutIndex >= 0) accept.setCutResult(m_minCutIndex, true);
76 if (m_maxCutIndex >= 0) accept.setCutResult(m_maxCutIndex, true);
77 return accept;
78 }
79
80 const double value = (*m_accessor)(*particle);
81
82 if (m_equalCutIndex >= 0) {
83 accept.setCutResult(m_equalCutIndex, value == m_equal);
84 }
85
86 if (m_minCutIndex >= 0) {
87 accept.setCutResult(m_minCutIndex, value >= m_min);
88 }
89
90 if (m_maxCutIndex >= 0) {
91 accept.setCutResult(m_maxCutIndex, value < m_max);
92 }
93
94 return accept;
95 }
96
97 #ifndef XAOD_STANDALONE
99 const std::string& type,
100 const std::string& myname,
101 const IInterface* parent)
102 : AsgNumDecorationSelectionTool<int>(type, myname, parent)
103 {
104 }
106 const std::string& type,
107 const std::string& myname,
108 const IInterface* parent)
109 : AsgNumDecorationSelectionTool<uint8_t>(type, myname, parent)
110 {
111 }
112 #else
115 {
116 }
118 : AsgNumDecorationSelectionTool<uint8_t>(myname)
119 {
120 }
121 #endif
122
123 // Explicit template instantiations
126
127}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
AsgNumDecorationSelectionToolInt(const std::string &type, const std::string &myname, const IInterface *parent)
AsgNumDecorationSelectionToolUInt8(const std::string &type, const std::string &myname, const IInterface *parent)
a templated IAsgSelectionTool that performs basic cut on numerical decorations (e....
virtual const asg::AcceptInfo & getAcceptInfo() const override
Declare the interface ID for this pure-virtual interface class to the Athena framework.
virtual asg::AcceptData accept(const xAOD::IParticle *particle) const override
The main accept method: the actual cuts are applied here.
AsgNumDecorationSelectionTool(const std::string &type, const std::string &myname, const IInterface *parent)
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
std::unique_ptr< SG::ConstAccessor< T > > m_accessor
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
Class providing the definition of the 4-vector interface.
Select isolated Photons, Electrons and Muons.
std::string m_name
The primary name part of this expression.
STL namespace.
setRawEt setRawPhi int