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

Member Typedef Documentation

◆ value

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

Definition at line 92 of file StringBasedNTupler.h.

Constructor & Destructor Documentation

◆ StringLeaveHelper()

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

Definition at line 95 of file StringBasedNTupler.h.

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_.reset(new std::vector<float>(0));
104  } else {
105  //parser for the object expression
107  //allocate enough memory for the data holder
108  value_.reset(new 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  }

References TtFullHadDaughter::B, hltPixelClustersMultiplicity_cfi::defaultValue, jets_cff::expr, edm::HandleBase::failedToGet(), iEvent, LogDebug, and StringLeaveHelper< Object >::value_.

Member Function Documentation

◆ operator()()

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

Definition at line 93 of file StringBasedNTupler.h.

93 { return std::move(value_); }

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

Member Data Documentation

◆ value_

template<typename Object >
value StringLeaveHelper< Object >::value_
private
StringObjectFunction< Object >
edm::Handle
Definition: AssociativeIterator.h:50
hltPixelClustersMultiplicity_cfi.defaultValue
defaultValue
Definition: hltPixelClustersMultiplicity_cfi.py:4
edm::HandleBase::failedToGet
bool failedToGet() const
Definition: HandleBase.h:72
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
iEvent
int iEvent
Definition: GenABIO.cc:224
StringLeaveHelper::value_
value value_
Definition: StringBasedNTupler.h:120
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
eostools.move
def move(src, dest)
Definition: eostools.py:511
jets_cff.expr
expr
Definition: jets_cff.py:449