ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
JetVar::Variable Class Referenceabstract

#include <JetVariable.h>

Inherited by JetVar::AbsEtaVar, JetVar::EM3FracVar, JetVar::EtVar, JetVar::EVar, JetVar::FChargedVar, JetVar::NconstitVar, JetVar::PzVar, JetVar::Rapidity, JetVar::Tile0FracVar, JetVar::VariableAtt< T >, and JetVar::VariableAtt< std::vector< T > >.

Collaboration diagram for JetVar::Variable:

Public Member Functions

 Variable (const std::string &name)
 
virtual ~Variable ()=default
 
virtual float value (const xAOD::Jet &) const =0
 
virtual bool isVector () const
 return true if the underlying variable is of type vector<X> More...
 
virtual VectorValue vector (const xAOD::Jet &) const
 return a helper object allowing to iterate over the underlying vector. !!! use only if isVector()==true !!! More...
 
virtual std::string name () const
 
float scale () const
 
void setScale (float s)
 

Static Public Member Functions

static std::unique_ptr< Variablecreate (const std::string &name, const std::string &type="float", int index=-1)
 create and return a new Variable of a given name & type. More...
 

Public Attributes

std::string m_name
 
float m_scale = 1
 
int m_index = -1
 

Detailed Description

The goal of this class is to define a common way to access any "jet variable". Here "jet variable" is any quantity calculable from a single jet. Often this will be a jet attribute stored in the xAOD::Jet class, but it can also be kinematics (ex: rapidity()) or an other quantity. JetVar::Variable allows access to the variables independently of their type or implementation details. It can then be used in generic tools to fill histograms (JetHistoAttributeFiller) or to select Jets (JetHistoSelectSort).

JetVar::Variable is the base class providing the acces methods. Concrete classes derive from it, in particular VariableAtt is the generic (templated) class to access atributes stored in the xAOD::Jet object. The function JetVar::Variable::create() allows to dynamicaly instantiate a variable from a name and a type passed as strings.

Definition at line 51 of file JetVariable.h.

Constructor & Destructor Documentation

◆ Variable()

JetVar::Variable::Variable ( const std::string &  name)
inline

Definition at line 54 of file JetVariable.h.

54 : m_name(name) {}

◆ ~Variable()

virtual JetVar::Variable::~Variable ( )
virtualdefault

Member Function Documentation

◆ create()

std::unique_ptr< Variable > Variable::create ( const std::string &  name,
const std::string &  type = "float",
int  index = -1 
)
static

create and return a new Variable of a given name & type.

If type is a vector an index can be specified : the variable will behave as a non-vector Variable corresponding to the value at the given index

Definition at line 10 of file JetVariable.cxx.

10  {
11 
12  // if known name, return the corresponding dedicated class
13  if(name=="e") return std::make_unique<EVar>(name);
14  if(name=="et") return std::make_unique<EtVar>(name);
15  if(name=="pz") return std::make_unique<PzVar>(name);
16  if(name=="nconstit") return std::make_unique<NconstitVar>(name);
17  if(name=="abseta") return std::make_unique<AbsEtaVar>(name);
18  if(name=="|eta|") return std::make_unique<AbsEtaVar>(name);
19  if(name=="rapidity") return std::make_unique<Rapidity>(name);
20  if(name=="fCharged") return std::make_unique<FChargedVar>(name);
21  if(name=="EM3Frac") return std::make_unique<EM3FracVar>(name);
22  if(name=="Tile0Frac") return std::make_unique<Tile0FracVar>(name);
23 
24  // Else assume we're looking for an attribute attached to the jet
25  if(type=="float") return std::make_unique<VariableAtt<float> >(name);
26  if(type=="int") return std::make_unique<VariableAtt<int> >(name);
27  if(type=="vecfloat") return std::make_unique<VariableAtt<std::vector<float> > >(name, index);
28  if(type=="vecint") return std::make_unique<VariableAtt< std::vector<int> > >(name, index);
29 
30 
31  return nullptr;
32  }

◆ isVector()

virtual bool JetVar::Variable::isVector ( ) const
inlinevirtual

return true if the underlying variable is of type vector<X>

Reimplemented in JetVar::VariableAtt< std::vector< T > >.

Definition at line 59 of file JetVariable.h.

59 {return false;}

◆ name()

virtual std::string JetVar::Variable::name ( ) const
inlinevirtual

Reimplemented in JetVar::VariableAtt< std::vector< T > >.

Definition at line 65 of file JetVariable.h.

65 {return m_name;}

◆ scale()

float JetVar::Variable::scale ( ) const
inline

Definition at line 67 of file JetVariable.h.

67 {return m_scale;}

◆ setScale()

void JetVar::Variable::setScale ( float  s)
inline

Definition at line 68 of file JetVariable.h.

68 { m_scale=s;}

◆ value()

virtual float JetVar::Variable::value ( const xAOD::Jet ) const
pure virtual

◆ vector()

virtual VectorValue JetVar::Variable::vector ( const xAOD::Jet ) const
inlinevirtual

return a helper object allowing to iterate over the underlying vector. !!! use only if isVector()==true !!!

Reimplemented in JetVar::VariableAtt< std::vector< T > >.

Definition at line 62 of file JetVariable.h.

62 {return VectorValue();}

Member Data Documentation

◆ m_index

int JetVar::Variable::m_index = -1

Definition at line 78 of file JetVariable.h.

◆ m_name

std::string JetVar::Variable::m_name

Definition at line 76 of file JetVariable.h.

◆ m_scale

float JetVar::Variable::m_scale = 1

Definition at line 77 of file JetVariable.h.


The documentation for this class was generated from the following files:
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
JetVar::Variable::name
virtual std::string name() const
Definition: JetVariable.h:65
DeMoScan.index
string index
Definition: DeMoScan.py:362
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
JetVar::Variable::m_name
std::string m_name
Definition: JetVariable.h:76
JetVar::Variable::m_scale
float m_scale
Definition: JetVariable.h:77