CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 90 of file StringBasedNTupler.h.

Member Typedef Documentation

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

Definition at line 92 of file StringBasedNTupler.h.

Constructor & Destructor Documentation

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

Definition at line 95 of file StringBasedNTupler.h.

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

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

Member Function Documentation

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

Definition at line 93 of file StringBasedNTupler.h.

References eostools::move(), and StringLeaveHelper< Object >::value_.

93 { return std::move(value_); }
def move
Definition: eostools.py:511

Member Data Documentation

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