CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
StringLeaveHelper< Object > Class Template Reference

#include <StringBasedNTupler.h>

Public Types

typedef TreeBranch::value value
 

Public Member Functions

value operator() ()
 
 StringLeaveHelper (const TreeBranch &B, const edm::Event &iEvent)
 

Private Attributes

value value_
 

Detailed Description

template<typename Object>
class StringLeaveHelper< Object >

Definition at line 93 of file StringBasedNTupler.h.

Member Typedef Documentation

template<typename Object >
typedef TreeBranch::value StringLeaveHelper< Object >::value

Definition at line 95 of file StringBasedNTupler.h.

Constructor & Destructor Documentation

template<typename Object >
StringLeaveHelper< Object >::StringLeaveHelper ( const TreeBranch B,
const edm::Event iEvent 
)
inline

Definition at line 98 of file StringBasedNTupler.h.

References TreeBranch::className(), TreeBranch::expr(), edm::HandleBase::failedToGet(), edm::Event::getByLabel(), LogDebug, TreeBranch::src(), and StringLeaveHelper< Object >::value_.

99  {
100  const float defaultValue = 0.;
101  // grab the object
103  iEvent.getByLabel(B.src(), oH);
104  //empty vector if product not found
105  if (oH.failedToGet()){
106  edm::LogError("StringBranchHelper")<<"cannot open: "<<B.src();
107  value_.reset(new std::vector<float>(0));
108  }
109  else{
110  //parser for the object expression
112  //allocate enough memory for the data holder
113  value_.reset(new std::vector<float>(1));
114  try{
115  (*value_)[0]=(expr)(*oH);
116  }catch(...){
117  LogDebug("StringLeaveHelper")<<"could not evaluate expression: "<<B.expr()<<" on class: "<<B.className();
118  (*value_)[0]=defaultValue;
119  }
120  }
121  }
#define LogDebug(id)
const edm::InputTag & src() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
bool failedToGet() const
Definition: HandleBase.h:79
const std::string & className() const
const std::string & expr() const

Member Function Documentation

template<typename Object >
value StringLeaveHelper< Object >::operator() ( )
inline

Definition at line 96 of file StringBasedNTupler.h.

References StringLeaveHelper< Object >::value_.

96 { return value_;}

Member Data Documentation

template<typename Object >
value StringLeaveHelper< Object >::value_
private