ATLAS Offline Software
Public Member Functions | Public Attributes | Private Attributes | List of all members
Monitored::Scalar< T > Class Template Reference

Declare a monitored scalar variable. More...

#include <MonitoredScalar.h>

Inheritance diagram for Monitored::Scalar< T >:
Collaboration diagram for Monitored::Scalar< T >:

Public Member Functions

 Scalar (Scalar &&)=default
 
 Scalar (Scalar const &)=delete
 
Scalaroperator= (Scalar const &)=delete
 
operator= (T value)
 
 operator T () const
 
 operator T& ()
 
operator-- ()
 
operator-- (int)
 
virtual double get (size_t) const override
 
virtual std::string getString (size_t) const override
 
virtual bool hasStringRepresentation () const override
 indcates that the stored content can be converted to strings More...
 
virtual size_t size () const override
 gives size of vector representation More...
 
const std::string & name () const
 
Client API
 Scalar (std::string name, const T &defaultValue={})
 Scalar with optional default value. More...
 
 Scalar (std::string name, const T &defaultValue, std::function< double(const T &)> valueTransform)
 Scalar with default value and optional transformation applied before filling. More...
 
 Scalar (std::string name, std::function< T()> generator)
 Scalar with generator function to retrieve the value. More...
 

Public Attributes

friend MonitoredGroup
 

Private Attributes

m_value {}
 
std::function< double(const T &)> m_valueTransform
 
std::function< T()> m_valueGenerator
 
const std::string m_name
 

Detailed Description

template<class T>
class Monitored::Scalar< T >

Declare a monitored scalar variable.

A monitored Scalar behaves similar to a regular builtin type:

Template Parameters
TType of scalar (convertable to double or string)

Examples:

auto eta = Monitored::Scalar( "Eta", -3. );
eta = 0.6;
auto count = Monitored::Scalar<float>( "Count", 0 );
bool comparisonResult = count == count;
count += 1;
count++;
--count;
count *= 3;

In case of std::string an alphanumeric histogram fill will be performed:

auto det = Monitored::Scalar<std::string>( "DetID", "SCT" );
Monitored::Group(monTool, det);
det = "PIX";
Monitored::Group(monTool, det);
See also
Monitored::Collection
Monitored::Timer

Definition at line 34 of file MonitoredScalar.h.

Constructor & Destructor Documentation

◆ Scalar() [1/5]

template<class T >
Monitored::Scalar< T >::Scalar ( std::string  name,
const T &  defaultValue = {} 
)
inline

Scalar with optional default value.

Parameters
nameName of monitored quantity
defaultValueOptional default value

Example

auto eta = Monitored::Scalar<double>( "Eta" ); //explicit double
auto phi = Monitored::Scalar( "Phi", -99.0 ); //deduced double
auto group = Monitored::Group( monTool, eta, phi );
phi = 0.1;
eta = -0.2;

Definition at line 50 of file MonitoredScalar.h.

50  {}) :
51  IMonitoredVariable(std::move(name)),
52  m_value(defaultValue)
53  {}

◆ Scalar() [2/5]

template<class T >
Monitored::Scalar< T >::Scalar ( std::string  name,
const T &  defaultValue,
std::function< double(const T &)>  valueTransform 
)
inline

Scalar with default value and optional transformation applied before filling.

Parameters
nameName of monitored quantity
defaultValueDefault value assigned to the monitored scalar
valueTransformOptional transformation applied to value before filling

Example

// Take absolute value before filling
auto phi = Monitored::Scalar<double>( "Phi", -3.0, [](double d){ return fabs(d); } );

Definition at line 65 of file MonitoredScalar.h.

65  :
66  IMonitoredVariable(std::move(name)),
67  m_value(defaultValue),
68  m_valueTransform(std::move(valueTransform))
69  {}

◆ Scalar() [3/5]

template<class T >
Monitored::Scalar< T >::Scalar ( std::string  name,
std::function< T()>  generator 
)
inline

Scalar with generator function to retrieve the value.

Parameters
nameName of monitored quantity
generatorFunction returning the monitored value

Example

std::vector<float> v{1,2,3};
auto eta = Monitored::Scalar<int>( "Eta", [&](){ return v.size(); } );

Definition at line 80 of file MonitoredScalar.h.

80  :
81  IMonitoredVariable(std::move(name)),
82  m_valueGenerator(std::move(generator))
83  {}

◆ Scalar() [4/5]

template<class T >
Monitored::Scalar< T >::Scalar ( Scalar< T > &&  )
default

◆ Scalar() [5/5]

template<class T >
Monitored::Scalar< T >::Scalar ( Scalar< T > const )
delete

Member Function Documentation

◆ get()

template<class T >
virtual double Monitored::Scalar< T >::get ( size_t  ) const
inlineoverridevirtual

Implements Monitored::IMonitoredVariable.

Definition at line 109 of file MonitoredScalar.h.

109  {
110  if constexpr (std::is_convertible_v<double, T>) {
111  return (m_valueGenerator ? static_cast<double>(m_valueGenerator()) :
112  m_valueTransform ? m_valueTransform(m_value) : static_cast<double>(m_value));
113  }
114  else return 0;
115  }

◆ getString()

template<class T >
virtual std::string Monitored::Scalar< T >::getString ( size_t  ) const
inlineoverridevirtual

Implements Monitored::IMonitoredVariable.

Definition at line 117 of file MonitoredScalar.h.

117  {
118  if constexpr (std::is_constructible_v<std::string, T>) {
120  }
121  else return {};
122  }

◆ hasStringRepresentation()

template<class T >
virtual bool Monitored::Scalar< T >::hasStringRepresentation ( ) const
inlineoverridevirtual

indcates that the stored content can be converted to strings

Implements Monitored::IMonitoredVariable.

Definition at line 124 of file MonitoredScalar.h.

124  {
126  }

◆ name()

const std::string& Monitored::IMonitoredVariable::name ( ) const
inlineinherited

Definition at line 19 of file IMonitoredVariable.h.

19 { return m_name; }

◆ operator T()

template<class T >
Monitored::Scalar< T >::operator T ( ) const
inline

Definition at line 99 of file MonitoredScalar.h.

99 { return m_value; }

◆ operator T&()

template<class T >
Monitored::Scalar< T >::operator T& ( )
inline

Definition at line 101 of file MonitoredScalar.h.

101 { return m_value; }

◆ operator--() [1/2]

template<class T >
T Monitored::Scalar< T >::operator-- ( )
inline

Definition at line 106 of file MonitoredScalar.h.

106 { return --m_value; }

◆ operator--() [2/2]

template<class T >
T Monitored::Scalar< T >::operator-- ( int  )
inline

Definition at line 107 of file MonitoredScalar.h.

107 { return m_value--; }

◆ operator=() [1/2]

template<class T >
Scalar& Monitored::Scalar< T >::operator= ( Scalar< T > const )
delete

◆ operator=() [2/2]

template<class T >
T Monitored::Scalar< T >::operator= ( value)
inline

Definition at line 92 of file MonitoredScalar.h.

93  {
94  m_value = value;
95  return value;
96  }

◆ size()

template<class T >
virtual size_t Monitored::Scalar< T >::size ( ) const
inlineoverridevirtual

gives size of vector representation

Implements Monitored::IMonitoredVariable.

Definition at line 128 of file MonitoredScalar.h.

128  {
129  return 1;
130  }

Member Data Documentation

◆ m_name

const std::string Monitored::IMonitoredVariable::m_name
privateinherited

Definition at line 31 of file IMonitoredVariable.h.

◆ m_value

template<class T >
T Monitored::Scalar< T >::m_value {}
private

Definition at line 133 of file MonitoredScalar.h.

◆ m_valueGenerator

template<class T >
std::function<T()> Monitored::Scalar< T >::m_valueGenerator
private

Definition at line 135 of file MonitoredScalar.h.

◆ m_valueTransform

template<class T >
std::function<double(const T&)> Monitored::Scalar< T >::m_valueTransform
private

Definition at line 134 of file MonitoredScalar.h.

◆ MonitoredGroup

friend Monitored::IMonitoredVariable::MonitoredGroup
inherited

Definition at line 16 of file IMonitoredVariable.h.


The documentation for this class was generated from the following file:
test_pyathena.eta
eta
Definition: test_pyathena.py:10
Monitored::Scalar::m_valueTransform
std::function< double(const T &)> m_valueTransform
Definition: MonitoredScalar.h:134
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
TRTCalib_Extractor.det
det
Definition: TRTCalib_Extractor.py:36
hist_file_dump.d
d
Definition: hist_file_dump.py:137
athena.value
value
Definition: athena.py:124
Monitored::IMonitoredVariable::IMonitoredVariable
IMonitoredVariable(std::string name)
Definition: IMonitoredVariable.h:27
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
Monitored::Scalar::m_value
T m_value
Definition: MonitoredScalar.h:133
python.PyAthena.v
v
Definition: PyAthena.py:154
Monitored::Scalar::m_valueGenerator
std::function< T()> m_valueGenerator
Definition: MonitoredScalar.h:135
mc.generator
generator
Configure Herwig7 These are the commands corresponding to what would go into the regular Herwig infil...
Definition: mc.MGH7_FxFx_H71-DEFAULT_test.py:18
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
Monitored::IMonitoredVariable::name
const std::string & name() const
Definition: IMonitoredVariable.h:19
Monitored::IMonitoredVariable::m_name
const std::string m_name
Definition: IMonitoredVariable.h:31
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34