ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
JetVar::VariableAtt< std::vector< T > > Struct Template Reference

Specialization of VariableAtt for the vector<> type. More...

#include <JetVariable.h>

Inheritance diagram for JetVar::VariableAtt< std::vector< T > >:
Collaboration diagram for JetVar::VariableAtt< std::vector< T > >:

Classes

struct  VectorWrapperT
 

Public Types

typedef std::vector< T > vect_t
 

Public Member Functions

 VariableAtt (const std::string &name, int index)
 
virtual std::string name () const
 
virtual bool isVector () const
 return true if the underlying variable is of type vector<X> More...
 
virtual float value (const xAOD::Jet &j) const
 
virtual VectorValue vector (const xAOD::Jet &j) const
 return a helper object allowing to iterate over the underlying vector. !!! use only if isVector()==true !!! More...
 
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

Accessor< vect_tm_acc
 
std::string m_name
 
float m_scale = 1
 
int m_index = -1
 

Static Public Attributes

static const vect_t s_dummy {-999}
 

Detailed Description

template<typename T>
struct JetVar::VariableAtt< std::vector< T > >

Specialization of VariableAtt for the vector<> type.

Definition at line 103 of file JetVariable.h.

Member Typedef Documentation

◆ vect_t

template<typename T >
typedef std::vector<T> JetVar::VariableAtt< std::vector< T > >::vect_t

Definition at line 104 of file JetVariable.h.

Constructor & Destructor Documentation

◆ VariableAtt()

template<typename T >
JetVar::VariableAtt< std::vector< T > >::VariableAtt ( const std::string &  name,
int  index 
)
inline

Definition at line 112 of file JetVariable.h.

112  : Variable(name), m_acc(name) {
113  m_index=index;
114  }

Member Function Documentation

◆ create()

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

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()

template<typename T >
virtual bool JetVar::VariableAtt< std::vector< T > >::isVector ( ) const
inlinevirtual

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

Reimplemented from JetVar::Variable.

Definition at line 122 of file JetVariable.h.

122 {return m_index==-1;}

◆ name()

template<typename T >
virtual std::string JetVar::VariableAtt< std::vector< T > >::name ( ) const
inlinevirtual

Reimplemented from JetVar::Variable.

Definition at line 116 of file JetVariable.h.

116  {
117  if(isVector() )return m_name;
118  return m_name+std::to_string(m_index);
119  }

◆ scale()

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

Definition at line 67 of file JetVariable.h.

67 {return m_scale;}

◆ setScale()

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

Definition at line 68 of file JetVariable.h.

68 { m_scale=s;}

◆ value()

template<typename T >
virtual float JetVar::VariableAtt< std::vector< T > >::value ( const xAOD::Jet j) const
inlinevirtual

Implements JetVar::Variable.

Definition at line 125 of file JetVariable.h.

125  {
126  if ( m_acc.isAvailable( j ) && m_index >= 0 && m_acc(j).size() > (unsigned) m_index ) {
127  return m_acc(j)[m_index]*m_scale;
128  }
129  else return -999.;
130  }

◆ vector()

template<typename T >
virtual VectorValue JetVar::VariableAtt< std::vector< T > >::vector ( const xAOD::Jet ) const
inlinevirtual

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

Reimplemented from JetVar::Variable.

Definition at line 132 of file JetVariable.h.

132  {
133  if ( m_acc.isAvailable( j ) ) {
134  VectorValue v( new VectorWrapperT(&m_acc(j)) , m_scale ) ;
135  return v;
136  }
137  else {
138  VectorValue junk( new VectorWrapperT(&s_dummy), m_scale );
139  return junk;
140  }
141  }

Member Data Documentation

◆ m_acc

template<typename T >
Accessor<vect_t> JetVar::VariableAtt< std::vector< T > >::m_acc

Definition at line 144 of file JetVariable.h.

◆ m_index

int JetVar::Variable::m_index = -1
inherited

Definition at line 78 of file JetVariable.h.

◆ m_name

std::string JetVar::Variable::m_name
inherited

Definition at line 76 of file JetVariable.h.

◆ m_scale

float JetVar::Variable::m_scale = 1
inherited

Definition at line 77 of file JetVariable.h.

◆ s_dummy

template<typename T >
const vect_t JetVar::VariableAtt< std::vector< T > >::s_dummy {-999}
inlinestatic

Definition at line 146 of file JetVariable.h.


The documentation for this struct was generated from the following file:
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
JetVar::VariableAtt< std::vector< T > >::isVector
virtual bool isVector() const
return true if the underlying variable is of type vector<X>
Definition: JetVariable.h:122
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
JetVar::Variable::m_index
int m_index
Definition: JetVariable.h:78
JetVar::Variable::Variable
Variable(const std::string &name)
Definition: JetVariable.h:54
JetVar::VariableAtt< std::vector< T > >::m_acc
Accessor< vect_t > m_acc
Definition: JetVariable.h:144
JetVar::VariableAtt< std::vector< T > >::s_dummy
static const vect_t s_dummy
Definition: JetVariable.h:146
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
JetVar::Variable::name
virtual std::string name() const
Definition: JetVariable.h:65
JetVar::VariableAtt< std::vector< T > >::name
virtual std::string name() const
Definition: JetVariable.h:116
python.PyAthena.v
v
Definition: PyAthena.py:157
DeMoScan.index
string index
Definition: DeMoScan.py:362
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
JetVar::Variable::m_name
std::string m_name
Definition: JetVariable.h:76
JetVar::Variable::m_scale
float m_scale
Definition: JetVariable.h:77