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 46 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 48 of file SimpleFlatTableProducer.h.

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

◆ ~FuncVariable()

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

Definition at line 53 of file SimpleFlatTableProducer.h.

53 {}

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

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

54  {
55  std::vector<ValType> vals(selobjs.size());
56  for (unsigned int i = 0, n = vals.size(); i < n; ++i) {
57  ValType val = func_(*selobjs[i]);
58  if constexpr (std::is_same<ValType, float>()) {
59  if (this->precision_ == -2) {
60  auto prec = precisionFunc_(*selobjs[i]);
61  vals[i] = prec > 0 ? MiniFloatConverter::reduceMantissaToNbitsRounding(val, prec) : val;
62  } else
63  vals[i] = val;
64  } else {
65  vals[i] = val;
66  }
67  }
68  out.template addColumn<ValType>(this->name_, vals, this->doc_, this->precision_);
69  }
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