ATLAS Offline Software
Loading...
Searching...
No Matches
JetAttributeSelector.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <limits>
7
8namespace {
9
10 template <class T>
11 struct ValueRetriever : public JetAttributeSelector::SelValueRetriever {
12 ValueRetriever(const std::string &n) : acc(n) {}
13 virtual float value(const xAOD::Jet& j) const override { return acc(j);}
15 };
16
17 template <class T>
18 struct VecValueRetriever : public JetAttributeSelector::SelValueRetriever {
19 VecValueRetriever(const std::string &n, int ind) : acc(n), index(ind) {}
20 virtual float value(const xAOD::Jet& j) const override { return acc(j)[index];}
22 int index;
23 };
24
25}
26
27
29 : asg::AsgTool(t)
30 , m_min(-std::numeric_limits<float>::max())
31 , m_max( std::numeric_limits<float>::max())
32 , m_attName("")
33 , m_attType("float")
35 , m_vretriever(NULL)
36{
37
38 declareProperty("CutMin", m_min );
39 declareProperty("CutMax", m_max );
40 declareProperty("Attribute",m_attName) ;
41 declareProperty("AttributeType",m_attType) ;
42 declareProperty("VectorIndex",m_vectorAttIndex) ;
43
44}
45
49
50
52 SelValueRetriever* retriever = NULL;
53 if(type=="float") retriever = new ::ValueRetriever<float>(name);
54 else if(type=="int") retriever = new ::ValueRetriever<int>(name);
55 else if(type=="vector<float>") retriever = new ::VecValueRetriever<float>(name, index);
56 else if(type=="vector<int>") retriever = new ::VecValueRetriever<int>(name, index);
57 else {
58 ATH_MSG_ERROR("Unsupported attribute type : "<< type);
59 // will return NULL
60 }
61 return retriever;
62}
63
64
66 if(m_attName=="") {
67 ATH_MSG_ERROR("Please specify an attribute name");
68 return StatusCode::FAILURE;
69 }
70
72 if(m_vretriever==NULL) {
73 ATH_MSG_ERROR("Can't retrieve attribute type : "<< m_attType<< " name : "<< m_attName);
74 return StatusCode::FAILURE;
75 }
76 ATH_MSG_INFO(" will select on attribute of type : "<< m_attType<< ". "<<m_min << " < "<< m_attName << " < "<< m_max);
77 return StatusCode::SUCCESS;
78}
79
81 float v = m_vretriever->value(jet);
82 return (m_min <= v ) && (v<=m_max);
83}
84
85
87
89 float v = fabs(m_vretriever->value(jet));
90 return (m_min <= v ) && (v<=m_max);
91}
92
94 , m_attName2("")
95 , m_attType2("float")
97 , m_vretriever2(NULL) {
98 declareProperty("Attribute2",m_attName2) ;
99 declareProperty("AttributeType2",m_attType2) ;
100 declareProperty("VectorIndex2",m_vectorAttIndex2) ;
101
102}
103
104
107
109 if(m_vretriever2==NULL) {
110 ATH_MSG_ERROR("Can't retrieve attribute type : "<< m_attType2<< " name : "<< m_attName2);
111 return StatusCode::FAILURE;
112 }
113 ATH_MSG_INFO(" will select on RATIO of attribute of type : "<< m_attType<< " , "<< m_attName );
114 ATH_MSG_INFO(" over attribute of type : "<< m_attType2<< " , "<< m_attName << " within "<<m_min << " < r < "<< m_max);
115 return StatusCode::SUCCESS;
116
117}
118
120 float v1 = m_vretriever->value(jet);
121 float v2 = m_vretriever2->value(jet);
122 if( v2 == 0.) return false;
123 double r = v1/v2;
124 return (m_min <= r ) && (r<=m_max);
125}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
define simple IJetSelector based on jet attributes
#define max(a, b)
Definition cfImp.cxx:41
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual int keep(const xAOD::Jet &jet) const
Method to select.
JetAbsAttributeSelector(const std::string &t)
JetAttributeRatioSelector(const std::string &t)
SelValueRetriever * m_vretriever2
if the attribute is a vector we'll use the value at this index. else it is ignored.
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
virtual int keep(const xAOD::Jet &jet) const
Method to select.
virtual int keep(const xAOD::Jet &jet) const
Method to select.
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
JetAttributeSelector(const std::string &t)
SelValueRetriever * m_vretriever
if the attribute is a vector we'll use the value at this index. else it is ignored.
SelValueRetriever * buildValueRetriever(const std::string &type, const std::string &name, int index)
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
int r
Definition globals.cxx:22
Definition index.py:1
STL namespace.
Jet_v1 Jet
Definition of the current "jet version".
value on which this tool select jets.