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 40 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 42 of file SimpleFlatTableProducer.h.

43  : Variable<ObjType>(aname, cfg),
44  func_(cfg.getParameter<std::string>("expr"), true),
45  precisionFunc_(cfg.existsAs<std::string>("precision") ? cfg.getParameter<std::string>("precision") : "23",
46  true) {}
StringFunctor precisionFunc_

◆ ~FuncVariable()

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

Definition at line 47 of file SimpleFlatTableProducer.h.

47 {}

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

48  {
49  std::vector<ValType> vals(selobjs.size());
50  for (unsigned int i = 0, n = vals.size(); i < n; ++i) {
51  if constexpr (std::is_same<ValType, float>()) {
52  if (this->precision_ == -2) {
54  } else {
55  vals[i] = func_(*selobjs[i]);
56  }
57  } else {
58  vals[i] = func_(*selobjs[i]);
59  }
60  }
61  out.template addColumn<ValType>(this->name_, vals, this->doc_, this->precision_);
62  }
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