ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetToolHelpers
JetToolHelpers
InputVariable.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef JETTOOLHELPERS_INPUTVARIABLE_H
6
#define JETTOOLHELPERS_INPUTVARIABLE_H
7
8
9
#include "
JetToolHelpers/JetContext.h
"
//used here
10
#include "
xAODJet/Jet.h
"
//used here
11
#include "
AthContainers/AuxElement.h
"
//member variable
12
#include "
JetAnalysisInterfaces/IInputVariable.h
"
//inheritance
13
14
#include <memory>
//std::unique_ptr
15
#include <functional>
//std::function
16
#include <string>
17
#include <stdexcept>
//std::runtime_error
18
19
20
namespace
JetHelper
{
21
25
26
class
InputVariable
:
public
IInputVariable
27
{
28
29
public
:
30
32
static
std::unique_ptr<InputVariable>
createVariable
(
33
const
std::string& name,
34
const
std::string&
type
,
35
bool
isJetVar,
36
float
scale);
37
38
40
InputVariable
(
const
std::string& name):
m_name
{name},
m_scale
{1.} {}
41
InputVariable
(
42
const
std::string& name,
43
std::function<
float
(
const
xAOD::Jet
&
jet
,
const
JetContext
& jc)> func
44
);
45
47
virtual
~InputVariable
() =
default
;
48
50
[[nodiscard]]
float
getValue
(
const
xAOD::Jet
&
jet
,
const
JetContext
& jc)
const override
{
51
return
getValue_prot
(
jet
, jc);
52
}
53
55
const
std::string&
getName
()
const
{
return
m_name
; }
57
float
getScale
()
const
{
return
m_scale
; }
59
void
setScale
(
const
float
scale) {
m_scale
= scale; }
61
void
setGeV
() {
m_scale
= 1.e-3; }
63
void
setMeV
() {
m_scale
= 1.; }
64
65
InputVariable
(
const
InputVariable
&) =
delete
;
66
67
protected
:
68
const
std::string
m_name
;
69
float
m_scale
;
70
71
std::function<float(
const
xAOD::Jet
&
jet
,
const
JetContext
& jc)>
m_customFunction
;
72
73
[[nodiscard]]
virtual
float
getValue_prot
(
const
xAOD::Jet
&
jet
,
const
JetContext
& jc)
const
{
74
return
(
m_customFunction
(
jet
, jc));
75
}
76
};
77
79
template
<
typename
T>
class
InputVariableJetContext
:
public
InputVariable
{
80
public
:
81
InputVariableJetContext
(
const
std::string& name) :
InputVariable
(name) {}
82
// should be T
83
virtual
float
getValue
(
const
xAOD::Jet
&,
const
JetContext
& event)
const
{
84
if
(event.isAvailable(
m_name
)) {
85
return
event
.getValue<T>(
m_name
);
86
}
else
{
87
throw
std::runtime_error(
"Value "
+
m_name
+
" is not available"
);
88
}
89
}
90
};
91
92
template
<
typename
T>
class
InputVariableAttribute
:
public
InputVariable
{
93
public
:
94
InputVariableAttribute
(
const
std::string& name) :
InputVariable
(name),
m_acc
{name} {}
95
virtual
float
getValue
(
const
xAOD::Jet
&
jet
,
const
JetContext
&)
const
{
96
if
(
m_acc
.isAvailable(
jet
)) {
97
return
m_acc
(
jet
)*
m_scale
;
98
}
else
{
99
throw
std::runtime_error(
"Value "
+
m_name
+
" is not available"
);
100
}
101
}
102
private
:
103
SG::AuxElement::ConstAccessor<T>
m_acc
;
104
};
105
}
// namespace JetHelper
106
107
#endif
108
AuxElement.h
Base class for elements of a container that can have aux data.
Jet.h
IInputVariable.h
JetContext.h
JetHelper::IInputVariable
Definition
IInputVariable.h:21
JetHelper::InputVariableAttribute::getValue
virtual float getValue(const xAOD::Jet &jet, const JetContext &) const
return the value of the variable choose by the user
Definition
InputVariable.h:95
JetHelper::InputVariableAttribute::InputVariableAttribute
InputVariableAttribute(const std::string &name)
Definition
InputVariable.h:94
JetHelper::InputVariableAttribute::m_acc
SG::AuxElement::ConstAccessor< T > m_acc
Definition
InputVariable.h:103
JetHelper::InputVariableJetContext::InputVariableJetContext
InputVariableJetContext(const std::string &name)
Definition
InputVariable.h:81
JetHelper::InputVariableJetContext::getValue
virtual float getValue(const xAOD::Jet &, const JetContext &event) const
return the value of the variable choose by the user
Definition
InputVariable.h:83
JetHelper::InputVariable::setGeV
void setGeV()
This function set the scale to GeV, assuming MeV by default.
Definition
InputVariable.h:61
JetHelper::InputVariable::setMeV
void setMeV()
This function set the scale to MeV, assuming MeV by default (it does nothing).
Definition
InputVariable.h:63
JetHelper::InputVariable::InputVariable
InputVariable(const std::string &name, std::function< float(const xAOD::Jet &jet, const JetContext &jc)> func)
JetHelper::InputVariable::getScale
float getScale() const
This function return the scale of the variable.
Definition
InputVariable.h:57
JetHelper::InputVariable::m_customFunction
std::function< float(const xAOD::Jet &jet, const JetContext &jc)> m_customFunction
Definition
InputVariable.h:71
JetHelper::InputVariable::InputVariable
InputVariable(const std::string &name)
Constructors.
Definition
InputVariable.h:40
JetHelper::InputVariable::getValue_prot
virtual float getValue_prot(const xAOD::Jet &jet, const JetContext &jc) const
Definition
InputVariable.h:73
JetHelper::InputVariable::setScale
void setScale(const float scale)
This function set the scale of the variable.
Definition
InputVariable.h:59
JetHelper::InputVariable::getName
const std::string & getName() const
This function return the name of the variable.
Definition
InputVariable.h:55
JetHelper::InputVariable::m_name
const std::string m_name
Definition
InputVariable.h:68
JetHelper::InputVariable::m_scale
float m_scale
Definition
InputVariable.h:69
JetHelper::InputVariable::~InputVariable
virtual ~InputVariable()=default
Default destructor.
JetHelper::InputVariable::createVariable
static std::unique_ptr< InputVariable > createVariable(const std::string &name, const std::string &type, bool isJetVar, float scale)
This function specialize the variable to the one choose by the user.
JetHelper::InputVariable::getValue
float getValue(const xAOD::Jet &jet, const JetContext &jc) const override
return the value of the variable choose by the user
Definition
InputVariable.h:50
JetHelper::InputVariable::InputVariable
InputVariable(const InputVariable &)=delete
JetHelper::JetContext
Class JetContext Designed to read AOD information related to the event, N vertices,...
Definition
JetContext.h:27
JetHelper
class IJetCalibStep
Definition
IInputVariable.h:18
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
type
Generated on
for ATLAS Offline Software by
1.17.0