CMS 3D CMS Logo

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 92 of file StringBasedNTupler.h.

Member Typedef Documentation

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

Definition at line 94 of file StringBasedNTupler.h.

Constructor & Destructor Documentation

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

Definition at line 97 of file StringBasedNTupler.h.

References TreeBranch::className(), TreeBranch::expr(), edm::HandleBase::failedToGet(), edm::Event::getByLabel(), LogDebug, and TreeBranch::src().

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

Member Function Documentation

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

Definition at line 95 of file StringBasedNTupler.h.

References eostools::move().

95 { return std::move(value_);}
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

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

Definition at line 122 of file StringBasedNTupler.h.