CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PATStringCutObjectSelector Class Reference

#include <StringParserTools.h>

Public Member Functions

bool operator() (const reco::Candidate &c) const
 
 PATStringCutObjectSelector ()
 
 PATStringCutObjectSelector (const std::string &string)
 

Private Member Functions

void throwBadType (const std::type_info &ty1) const
 
template<typename Obj >
bool tryEval (const reco::Candidate &c, const boost::shared_ptr< StringCutObjectSelector< Obj > > &func) const
 
template<typename Obj >
boost::shared_ptr
< StringCutObjectSelector< Obj > > 
tryGet (const std::string &str)
 

Private Attributes

boost::shared_ptr
< StringCutObjectSelector
< reco::Candidate > > 
candFunc_
 
boost::shared_ptr
< StringCutObjectSelector
< pat::Electron > > 
eleFunc_
 
std::string expr_
 
boost::shared_ptr
< StringCutObjectSelector
< pat::Photon > > 
gamFunc_
 
boost::shared_ptr
< StringCutObjectSelector
< pat::GenericParticle > > 
gpFunc_
 
boost::shared_ptr
< StringCutObjectSelector
< pat::Jet > > 
jetFunc_
 
boost::shared_ptr
< StringCutObjectSelector
< pat::MET > > 
metFunc_
 
boost::shared_ptr
< StringCutObjectSelector
< pat::Muon > > 
muFunc_
 
boost::shared_ptr
< StringCutObjectSelector
< pat::PFParticle > > 
pfFunc_
 
boost::shared_ptr
< StringCutObjectSelector
< pat::Tau > > 
tauFunc_
 

Detailed Description

Definition at line 61 of file StringParserTools.h.

Constructor & Destructor Documentation

PATStringCutObjectSelector::PATStringCutObjectSelector ( )
inline

Definition at line 64 of file StringParserTools.h.

64 {}
PATStringCutObjectSelector::PATStringCutObjectSelector ( const std::string &  string)

Definition at line 40 of file StringParserTools.cc.

References candFunc_, eleFunc_, gamFunc_, gpFunc_, jetFunc_, metFunc_, muFunc_, pfFunc_, and tauFunc_.

40  :
41  expr_(string)
42 {
43  candFunc_ = tryGet<reco::Candidate>(string);
44  if (!candFunc_.get()) {
45  eleFunc_ = tryGet<pat::Electron>(string);
46  muFunc_ = tryGet<pat::Muon>(string);
47  tauFunc_ = tryGet<pat::Tau>(string);
48  gamFunc_ = tryGet<pat::Photon>(string);
49  jetFunc_ = tryGet<pat::Jet>(string);
50  metFunc_ = tryGet<pat::MET>(string);
51  gpFunc_ = tryGet<pat::GenericParticle>(string);
52  pfFunc_ = tryGet<pat::PFParticle>(string);
53  }
54 }
boost::shared_ptr< StringCutObjectSelector< pat::PFParticle > > pfFunc_
boost::shared_ptr< StringCutObjectSelector< pat::Photon > > gamFunc_
boost::shared_ptr< StringCutObjectSelector< pat::Muon > > muFunc_
boost::shared_ptr< StringCutObjectSelector< reco::Candidate > > candFunc_
boost::shared_ptr< StringCutObjectSelector< pat::GenericParticle > > gpFunc_
boost::shared_ptr< StringCutObjectSelector< pat::Jet > > jetFunc_
boost::shared_ptr< StringCutObjectSelector< pat::MET > > metFunc_
boost::shared_ptr< StringCutObjectSelector< pat::Electron > > eleFunc_
boost::shared_ptr< StringCutObjectSelector< pat::Tau > > tauFunc_

Member Function Documentation

bool PATStringCutObjectSelector::operator() ( const reco::Candidate c) const

Definition at line 57 of file StringParserTools.cc.

References trackerHits::c, candFunc_, eleFunc_, edm::hlt::Exception, expr_, gamFunc_, gpFunc_, jetFunc_, metFunc_, muFunc_, pfFunc_, and tauFunc_.

57  {
58  if (candFunc_.get()) return (*candFunc_)(c);
59  const std::type_info &type = typeid(c);
60  if (type == typeid(pat::Electron )) return tryEval<pat::Electron >(c, eleFunc_);
61  else if (type == typeid(pat::Muon )) return tryEval<pat::Muon >(c, muFunc_);
62  else if (type == typeid(pat::Tau )) return tryEval<pat::Tau >(c, tauFunc_);
63  else if (type == typeid(pat::Photon )) return tryEval<pat::Photon >(c, gamFunc_);
64  else if (type == typeid(pat::Jet )) return tryEval<pat::Jet >(c, jetFunc_);
65  else if (type == typeid(pat::MET )) return tryEval<pat::MET >(c, metFunc_);
66  else if (type == typeid(pat::GenericParticle)) return tryEval<pat::GenericParticle>(c, gpFunc_);
67  else if (type == typeid(pat::PFParticle )) return tryEval<pat::PFParticle >(c, pfFunc_);
68  else throw cms::Exception("Type Error") << "Cannot evaluate '" << expr_ << "' on an object of unsupported type " << type.name() << "\n";
69 }
type
Definition: HCALResponse.h:22
Analysis-level MET class.
Definition: MET.h:42
Analysis-level Photon class.
Definition: Photon.h:46
boost::shared_ptr< StringCutObjectSelector< pat::PFParticle > > pfFunc_
boost::shared_ptr< StringCutObjectSelector< pat::Photon > > gamFunc_
boost::shared_ptr< StringCutObjectSelector< pat::Muon > > muFunc_
boost::shared_ptr< StringCutObjectSelector< reco::Candidate > > candFunc_
boost::shared_ptr< StringCutObjectSelector< pat::GenericParticle > > gpFunc_
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
boost::shared_ptr< StringCutObjectSelector< pat::Jet > > jetFunc_
Analysis-level tau class.
Definition: Tau.h:50
boost::shared_ptr< StringCutObjectSelector< pat::MET > > metFunc_
Analysis-level electron class.
Definition: Electron.h:52
Analysis-level calorimeter jet class.
Definition: Jet.h:72
Analysis-level class for reconstructed particles.
Definition: PFParticle.h:37
boost::shared_ptr< StringCutObjectSelector< pat::Electron > > eleFunc_
boost::shared_ptr< StringCutObjectSelector< pat::Tau > > tauFunc_
Analysis-level muon class.
Definition: Muon.h:51
void PATStringCutObjectSelector::throwBadType ( const std::type_info &  ty1) const
private

Definition at line 72 of file StringParserTools.cc.

References edm::hlt::Exception, and expr_.

Referenced by tryEval().

72  {
73  throw cms::Exception("Type Error") << "Expression '" << expr_ << "' can't be evaluated on an object of type " << ty.name() << "\n(hint: use c++filt to demangle the type name)\n";
74 }
template<typename Obj >
bool PATStringCutObjectSelector::tryEval ( const reco::Candidate c,
const boost::shared_ptr< StringCutObjectSelector< Obj > > &  func 
) const
inlineprivate

Definition at line 93 of file StringParserTools.h.

References trackerHits::c, and throwBadType().

93  {
94  if (func.get()) return (*func)(static_cast<const Obj &>(c));
95  else throwBadType(typeid(c));
96  assert(false);
97  return false;
98  }
void throwBadType(const std::type_info &ty1) const
template<typename Obj >
boost::shared_ptr<StringCutObjectSelector<Obj> > PATStringCutObjectSelector::tryGet ( const std::string &  str)
inlineprivate

Definition at line 83 of file StringParserTools.h.

83  {
84  try {
85  return boost::shared_ptr<StringCutObjectSelector<Obj> >(new StringCutObjectSelector<Obj>(str));
86  } catch (cms::Exception) {
87  return boost::shared_ptr<StringCutObjectSelector<Obj> >();
88  }
89  }

Member Data Documentation

boost::shared_ptr<StringCutObjectSelector<reco::Candidate> > PATStringCutObjectSelector::candFunc_
private

Definition at line 71 of file StringParserTools.h.

Referenced by operator()(), and PATStringCutObjectSelector().

boost::shared_ptr<StringCutObjectSelector<pat::Electron> > PATStringCutObjectSelector::eleFunc_
private

Definition at line 73 of file StringParserTools.h.

Referenced by operator()(), and PATStringCutObjectSelector().

std::string PATStringCutObjectSelector::expr_
private

Definition at line 70 of file StringParserTools.h.

Referenced by operator()(), and throwBadType().

boost::shared_ptr<StringCutObjectSelector<pat::Photon> > PATStringCutObjectSelector::gamFunc_
private

Definition at line 76 of file StringParserTools.h.

Referenced by operator()(), and PATStringCutObjectSelector().

boost::shared_ptr<StringCutObjectSelector<pat::GenericParticle> > PATStringCutObjectSelector::gpFunc_
private

Definition at line 79 of file StringParserTools.h.

Referenced by operator()(), and PATStringCutObjectSelector().

boost::shared_ptr<StringCutObjectSelector<pat::Jet> > PATStringCutObjectSelector::jetFunc_
private

Definition at line 77 of file StringParserTools.h.

Referenced by operator()(), and PATStringCutObjectSelector().

boost::shared_ptr<StringCutObjectSelector<pat::MET> > PATStringCutObjectSelector::metFunc_
private

Definition at line 78 of file StringParserTools.h.

Referenced by operator()(), and PATStringCutObjectSelector().

boost::shared_ptr<StringCutObjectSelector<pat::Muon> > PATStringCutObjectSelector::muFunc_
private

Definition at line 74 of file StringParserTools.h.

Referenced by operator()(), and PATStringCutObjectSelector().

boost::shared_ptr<StringCutObjectSelector<pat::PFParticle> > PATStringCutObjectSelector::pfFunc_
private

Definition at line 80 of file StringParserTools.h.

Referenced by operator()(), and PATStringCutObjectSelector().

boost::shared_ptr<StringCutObjectSelector<pat::Tau> > PATStringCutObjectSelector::tauFunc_
private

Definition at line 75 of file StringParserTools.h.

Referenced by operator()(), and PATStringCutObjectSelector().