CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TrigObjTnPHistColl::TrigObjVarF Class Reference

#include <TrigObjTnPHistColl.h>

Public Member Functions

float operator() (const trigger::TriggerObject &obj) const
 
 TrigObjVarF (std::string varName)
 

Private Attributes

bool isAbs_
 
float(trigger::TriggerObject::* varFunc_ )() const
 

Detailed Description

Definition at line 140 of file TrigObjTnPHistColl.h.

Constructor & Destructor Documentation

TrigObjTnPHistColl::TrigObjVarF::TrigObjVarF ( std::string  varName)
explicit

Definition at line 264 of file TrigObjTnPHistColl.cc.

References trigger::TriggerObject::eta(), Exception, isAbs_, mps_check::msg, trigger::TriggerObject::phi(), trigger::TriggerObject::pt(), and varFunc_.

264  :isAbs_(false)
265 {
266  //first look for "Abs" at the end of the string
267  auto absPos = varName.rfind("Abs");
268  if(absPos != std::string::npos && absPos+3 == varName.size() ) {
269  isAbs_ = true;
270  varName = varName.erase(absPos);
271  }
272  if(varName=="pt") varFunc_ = &trigger::TriggerObject::pt;
273  else if(varName=="eta") varFunc_ = &trigger::TriggerObject::eta;
274  else if(varName=="phi") varFunc_ = &trigger::TriggerObject::phi;
275  else{
276  std::ostringstream msg;
277  msg<<"var "<<varName<<" not recognised (use pt or p rather than et or e for speed!) ";
278  if(isAbs_) msg<<" varName was \"Abs\" suffex cleaned where it tried to remove \"Abs\" at the end of the variable name ";
279  msg <<__FILE__<<","<<__LINE__<<std::endl;
280  throw cms::Exception("ConfigError") <<msg.str();
281  }
282 }
float phi() const
Definition: TriggerObject.h:58
float eta() const
Definition: TriggerObject.h:57
float(trigger::TriggerObject::* varFunc_)() const
tuple msg
Definition: mps_check.py:277

Member Function Documentation

float TrigObjTnPHistColl::TrigObjVarF::operator() ( const trigger::TriggerObject obj) const
inline

Definition at line 143 of file TrigObjTnPHistColl.h.

References funct::abs().

143  {
144  return isAbs_ ? std::abs((obj.*varFunc_)()) : (obj.*varFunc_)();
145  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float(trigger::TriggerObject::* varFunc_)() const

Member Data Documentation

bool TrigObjTnPHistColl::TrigObjVarF::isAbs_
private

Definition at line 148 of file TrigObjTnPHistColl.h.

Referenced by TrigObjVarF().

float(trigger::TriggerObject::* TrigObjTnPHistColl::TrigObjVarF::varFunc_) () const
private

Definition at line 147 of file TrigObjTnPHistColl.h.

Referenced by TrigObjVarF().