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

Member Typedef Documentation

◆ value

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

Definition at line 89 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 92 of file StringBasedNTupler.h.

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

92  {
93  const float defaultValue = 0.;
94  // grab the object
96  iEvent.getByLabel(B.src(), oH);
97  //empty vector if product not found
98  if (oH.failedToGet()) {
99  edm::LogError("StringBranchHelper") << "cannot open: " << B.src();
100  value_ = std::make_unique<std::vector<float>>(0);
101  } else {
102  //parser for the object expression
103  StringObjectFunction<Object> expr(B.expr());
104  //allocate enough memory for the data holder
105  value_ = std::make_unique<std::vector<float>>(1);
106  try {
107  (*value_)[0] = (expr)(*oH);
108  } catch (...) {
109  LogDebug("StringLeaveHelper") << "could not evaluate expression: " << B.expr()
110  << " on class: " << B.className();
111  (*value_)[0] = defaultValue;
112  }
113  }
114  }
Definition: APVGainStruct.h:7
Log< level::Error, false > LogError
bool failedToGet() const
Definition: HandleBase.h:72
int iEvent
Definition: GenABIO.cc:224
#define LogDebug(id)

Member Function Documentation

◆ operator()()

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

Definition at line 90 of file StringBasedNTupler.h.

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

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

Member Data Documentation

◆ value_

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