CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
FuncVariable< ObjType, StringFunctor, ValType > Class Template Reference

#include <SimpleFlatTableProducer.h>

Inheritance diagram for FuncVariable< ObjType, StringFunctor, ValType >:
Variable< ObjType > VariableBase

Public Member Functions

void fill (std::vector< const ObjType *> &selobjs, nanoaod::FlatTable &out) const override
 
 FuncVariable (const std::string &aname, const edm::ParameterSet &cfg)
 
 ~FuncVariable () override
 
- Public Member Functions inherited from Variable< ObjType >
 Variable (const std::string &aname, const edm::ParameterSet &cfg)
 
- Public Member Functions inherited from VariableBase
const std::string & name () const
 
 VariableBase (const std::string &aname, const edm::ParameterSet &cfg)
 
virtual ~VariableBase ()
 

Protected Attributes

StringFunctor func_
 
StringFunctor precisionFunc_
 
- Protected Attributes inherited from VariableBase
std::string doc_
 
std::string name_
 
int precision_
 

Detailed Description

template<typename ObjType, typename StringFunctor, typename ValType>
class FuncVariable< ObjType, StringFunctor, ValType >

Definition at line 45 of file SimpleFlatTableProducer.h.

Constructor & Destructor Documentation

◆ FuncVariable()

template<typename ObjType , typename StringFunctor , typename ValType >
FuncVariable< ObjType, StringFunctor, ValType >::FuncVariable ( const std::string &  aname,
const edm::ParameterSet cfg 
)
inline

Definition at line 47 of file SimpleFlatTableProducer.h.

48  : Variable<ObjType>(aname, cfg),
49  func_(cfg.getParameter<std::string>("expr"), true),
50  precisionFunc_(cfg.existsAs<std::string>("precision") ? cfg.getParameter<std::string>("precision") : "23",
51  true) {}
StringFunctor precisionFunc_

◆ ~FuncVariable()

template<typename ObjType , typename StringFunctor , typename ValType >
FuncVariable< ObjType, StringFunctor, ValType >::~FuncVariable ( )
inlineoverride

Definition at line 52 of file SimpleFlatTableProducer.h.

52 {}

Member Function Documentation

◆ fill()

template<typename ObjType , typename StringFunctor , typename ValType >
void FuncVariable< ObjType, StringFunctor, ValType >::fill ( std::vector< const ObjType *> &  selobjs,
nanoaod::FlatTable out 
) const
inlineoverridevirtual

Implements Variable< ObjType >.

Definition at line 53 of file SimpleFlatTableProducer.h.

References VariableBase::doc_, FuncVariable< ObjType, StringFunctor, ValType >::func_, mps_fire::i, dqmiodumpmetadata::n, VariableBase::name_, MillePedeFileConverter_cfg::out, VariableBase::precision_, FuncVariable< ObjType, StringFunctor, ValType >::precisionFunc_, and MiniFloatConverter::reduceMantissaToNbitsRounding().

53  {
54  std::vector<ValType> vals(selobjs.size());
55  for (unsigned int i = 0, n = vals.size(); i < n; ++i) {
56  if constexpr (std::is_same<ValType, float>()) {
57  if (this->precision_ == -2) {
59  } else {
60  vals[i] = func_(*selobjs[i]);
61  }
62  } else {
63  vals[i] = func_(*selobjs[i]);
64  }
65  }
66  out.template addColumn<ValType>(this->name_, vals, this->doc_, this->precision_);
67  }
StringFunctor precisionFunc_
static float reduceMantissaToNbitsRounding(const float &f)
Definition: libminifloat.h:79

Member Data Documentation

◆ func_

template<typename ObjType , typename StringFunctor , typename ValType >
StringFunctor FuncVariable< ObjType, StringFunctor, ValType >::func_
protected

◆ precisionFunc_

template<typename ObjType , typename StringFunctor , typename ValType >
StringFunctor FuncVariable< ObjType, StringFunctor, ValType >::precisionFunc_
protected