ATLAS Offline Software
Loading...
Searching...
No Matches
JetSelectorAttributeRunII.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 JetSelectorAttributeRunII::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 JetSelectorAttributeRunII::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(nullptr)
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
51 if(m_attName.empty()) {
52 ATH_MSG_ERROR("Please specify an attribute name");
53 return StatusCode::FAILURE;
54 }
55
56 if(m_attType=="float") m_vretriever = new ::ValueRetriever<float>(m_attName);
57 else if(m_attType=="int") m_vretriever = new ::ValueRetriever<int>(m_attName);
58 else if(m_attType=="vector<float>") m_vretriever = new ::VecValueRetriever<float>(m_attName, m_vectorAttIndex);
59 else {
60 ATH_MSG_ERROR("Unsupported attribute type : "<< m_attType);
61 return StatusCode::FAILURE;
62 }
63 ATH_MSG_INFO(" will select on attribute of type : "<< m_attType<< ". "<<m_min << " < "<< m_attName << " < "<< m_max);
64 return StatusCode::SUCCESS;
65}
66
68 float v = m_vretriever->value(jet);
69 return (m_min < v ) && (v<m_max);
70}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define max(a, b)
Definition cfImp.cxx:41
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
int keep(const xAOD::Jet &jet) const
Method to select.
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
SelValueRetriever * m_vretriever
if the attribute is a vector we'll use the value at this index. else it is ignored.
JetSelectorAttributeRunII(const std::string &t)
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
STL namespace.
Jet_v1 Jet
Definition of the current "jet version".
SelValueRetriever retrieves the value on which this tool select jets.