CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PATStringCutObjectSelector Class Reference

#include <StringParserTools.h>

List of all members.

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.

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

                                                                              :
    expr_(string)
{
   candFunc_ = tryGet<reco::Candidate>(string);
   if (!candFunc_.get()) {
       eleFunc_ = tryGet<pat::Electron>(string);
       muFunc_  = tryGet<pat::Muon>(string);
       tauFunc_ = tryGet<pat::Tau>(string);
       gamFunc_ = tryGet<pat::Photon>(string);
       jetFunc_ = tryGet<pat::Jet>(string);
       metFunc_ = tryGet<pat::MET>(string);
       gpFunc_  = tryGet<pat::GenericParticle>(string);
       pfFunc_  = tryGet<pat::PFParticle>(string);
   } 
}

Member Function Documentation

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

Definition at line 57 of file StringParserTools.cc.

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

                                                                    {
    if (candFunc_.get()) return (*candFunc_)(c);
    const std::type_info &type = typeid(c);
    if      (type == typeid(pat::Electron       )) return tryEval<pat::Electron       >(c, eleFunc_);
    else if (type == typeid(pat::Muon           )) return tryEval<pat::Muon           >(c,  muFunc_);
    else if (type == typeid(pat::Tau            )) return tryEval<pat::Tau            >(c, tauFunc_);
    else if (type == typeid(pat::Photon         )) return tryEval<pat::Photon         >(c, gamFunc_);
    else if (type == typeid(pat::Jet            )) return tryEval<pat::Jet            >(c, jetFunc_);
    else if (type == typeid(pat::MET            )) return tryEval<pat::MET            >(c, metFunc_);
    else if (type == typeid(pat::GenericParticle)) return tryEval<pat::GenericParticle>(c,  gpFunc_);
    else if (type == typeid(pat::PFParticle     )) return tryEval<pat::PFParticle     >(c,  pfFunc_);
    else throw cms::Exception("Type Error") << "Cannot evaluate '" << expr_ << "' on an object of unsupported type " << type.name() << "\n"; 
}
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().

                                                                      {
    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";
}
template<typename Obj >
bool PATStringCutObjectSelector::tryEval ( const reco::Candidate c,
const boost::shared_ptr< StringCutObjectSelector< Obj > > &  func 
) const [inline, private]

Definition at line 93 of file StringParserTools.h.

References trackerHits::c, and throwBadType().

                                                                                                      {
        if (func.get()) return (*func)(static_cast<const Obj &>(c));
        else throwBadType(typeid(c));
        assert(false);
        return false;
    }
template<typename Obj >
boost::shared_ptr<StringCutObjectSelector<Obj> > PATStringCutObjectSelector::tryGet ( const std::string &  str) [inline, private]

Definition at line 83 of file StringParserTools.h.

                                                                                {
        try {
            return boost::shared_ptr<StringCutObjectSelector<Obj> >(new StringCutObjectSelector<Obj>(str));
        } catch (cms::Exception) { 
            return boost::shared_ptr<StringCutObjectSelector<Obj> >();
        }
    }

Member Data Documentation

Definition at line 71 of file StringParserTools.h.

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

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().

Definition at line 76 of file StringParserTools.h.

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

Definition at line 79 of file StringParserTools.h.

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

Definition at line 77 of file StringParserTools.h.

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

Definition at line 78 of file StringParserTools.h.

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

Definition at line 74 of file StringParserTools.h.

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

Definition at line 80 of file StringParserTools.h.

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

Definition at line 75 of file StringParserTools.h.

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