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

Member Typedef Documentation

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

Definition at line 97 of file StringBasedNTupler.h.

Constructor & Destructor Documentation

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

Definition at line 100 of file StringBasedNTupler.h.

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

100  {
101  const float defaultValue = 0.;
102  // grab the object
104  iEvent.getByLabel(B.src(), oH);
105  //empty vector if product not found
106  if (oH.failedToGet()) {
107  edm::LogError("StringBranchHelper") << "cannot open: " << B.src();
108  value_.reset(new std::vector<float>(0));
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()
118  << " on class: " << B.className();
119  (*value_)[0] = defaultValue;
120  }
121  }
122  }
#define LogDebug(id)
const edm::InputTag & src() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
bool failedToGet() const
Definition: HandleBase.h:72
const std::string & className() const
const std::string & expr() const

Member Function Documentation

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

Definition at line 98 of file StringBasedNTupler.h.

References eostools::move().

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

Member Data Documentation

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

Definition at line 125 of file StringBasedNTupler.h.