CMS 3D CMS Logo

PATStringCutObjectSelector Class Reference

#include <PhysicsTools/PatUtils/interface/StringParserTools.h>

List of all members.

Public Member Functions

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

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 59 of file StringParserTools.h.


Constructor & Destructor Documentation

PATStringCutObjectSelector::PATStringCutObjectSelector (  )  [inline]

Definition at line 62 of file StringParserTools.h.

00062 {}

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_.

00040                                                                               :
00041     expr_(string)
00042 {
00043    candFunc_ = tryGet<reco::Candidate>(string);
00044    if (!candFunc_.get()) {
00045        eleFunc_ = tryGet<pat::Electron>(string);
00046        muFunc_  = tryGet<pat::Muon>(string);
00047        tauFunc_ = tryGet<pat::Tau>(string);
00048        gamFunc_ = tryGet<pat::Photon>(string);
00049        jetFunc_ = tryGet<pat::Jet>(string);
00050        metFunc_ = tryGet<pat::MET>(string);
00051        gpFunc_  = tryGet<pat::GenericParticle>(string);
00052        pfFunc_  = tryGet<pat::PFParticle>(string);
00053    } 
00054 }


Member Function Documentation

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

Definition at line 57 of file StringParserTools.cc.

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

00057                                                                     {
00058     if (candFunc_.get()) return (*candFunc_)(c);
00059     const std::type_info &type = typeid(c);
00060     if      (type == typeid(pat::Electron       )) return tryEval<pat::Electron       >(c, eleFunc_);
00061     else if (type == typeid(pat::Muon           )) return tryEval<pat::Muon           >(c,  muFunc_);
00062     else if (type == typeid(pat::Tau            )) return tryEval<pat::Tau            >(c, tauFunc_);
00063     else if (type == typeid(pat::Photon         )) return tryEval<pat::Photon         >(c, gamFunc_);
00064     else if (type == typeid(pat::Jet            )) return tryEval<pat::Jet            >(c, jetFunc_);
00065     else if (type == typeid(pat::MET            )) return tryEval<pat::MET            >(c, metFunc_);
00066     else if (type == typeid(pat::GenericParticle)) return tryEval<pat::GenericParticle>(c,  gpFunc_);
00067     else if (type == typeid(pat::PFParticle     )) return tryEval<pat::PFParticle     >(c,  pfFunc_);
00068     else throw cms::Exception("Type Error") << "Cannot evaluate '" << expr_ << "' on an object of unsupported type " << type.name() << "\n"; 
00069 }

void PATStringCutObjectSelector::throwBadType ( const std::type_info &  ty1  )  const [private]

Definition at line 72 of file StringParserTools.cc.

References Exception, and expr_.

Referenced by tryEval().

00072                                                                       {
00073     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";
00074 }

template<typename Obj>
bool PATStringCutObjectSelector::tryEval ( const reco::Candidate c,
const boost::shared_ptr< StringCutObjectSelector< Obj > > &  func 
) const [inline, private]

Definition at line 91 of file StringParserTools.h.

References stor::func(), and throwBadType().

00091                                                                                                       {
00092         if (func.get()) return (*func)(static_cast<const Obj &>(c));
00093         else throwBadType(typeid(c));
00094     }

template<typename Obj>
boost::shared_ptr<StringCutObjectSelector<Obj> > PATStringCutObjectSelector::tryGet ( const std::string &  str  )  [inline, private]

Definition at line 81 of file StringParserTools.h.

00081                                                                                 {
00082         try {
00083             return boost::shared_ptr<StringCutObjectSelector<Obj> >(new StringCutObjectSelector<Obj>(str));
00084         } catch (cms::Exception) { 
00085             return boost::shared_ptr<StringCutObjectSelector<Obj> >();
00086         }
00087     }


Member Data Documentation

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

Definition at line 69 of file StringParserTools.h.

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

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

Definition at line 71 of file StringParserTools.h.

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

std::string PATStringCutObjectSelector::expr_ [private]

Definition at line 68 of file StringParserTools.h.

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

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

Definition at line 74 of file StringParserTools.h.

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

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

Definition at line 77 of file StringParserTools.h.

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

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

Definition at line 75 of file StringParserTools.h.

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

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

Definition at line 76 of file StringParserTools.h.

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

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

Definition at line 72 of file StringParserTools.h.

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

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

Definition at line 78 of file StringParserTools.h.

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

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

Definition at line 73 of file StringParserTools.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:29:28 2009 for CMSSW by  doxygen 1.5.4