CMS 3D CMS Logo

StringParserTools.cc
Go to the documentation of this file.
2 #include <typeinfo>
3 
5  expr_(string)
6 {
7  candFunc_ = tryGet<reco::Candidate>(string);
8  if (!candFunc_.get()) {
9  eleFunc_ = tryGet<pat::Electron>(string);
10  muFunc_ = tryGet<pat::Muon>(string);
11  tauFunc_ = tryGet<pat::Tau>(string);
12  gamFunc_ = tryGet<pat::Photon>(string);
13  jetFunc_ = tryGet<pat::Jet>(string);
14  metFunc_ = tryGet<pat::MET>(string);
15  gpFunc_ = tryGet<pat::GenericParticle>(string);
16  pfFunc_ = tryGet<pat::PFParticle>(string);
17  }
18 }
19 
20 double
22  if (candFunc_.get()) return (*candFunc_)(c);
23  const std::type_info &type = typeid(c);
24  if (type == typeid(pat::Electron )) return tryEval<pat::Electron >(c, eleFunc_);
25  else if (type == typeid(pat::Muon )) return tryEval<pat::Muon >(c, muFunc_);
26  else if (type == typeid(pat::Tau )) return tryEval<pat::Tau >(c, tauFunc_);
27  else if (type == typeid(pat::Photon )) return tryEval<pat::Photon >(c, gamFunc_);
28  else if (type == typeid(pat::Jet )) return tryEval<pat::Jet >(c, jetFunc_);
29  else if (type == typeid(pat::MET )) return tryEval<pat::MET >(c, metFunc_);
30  else if (type == typeid(pat::GenericParticle)) return tryEval<pat::GenericParticle>(c, gpFunc_);
31  else if (type == typeid(pat::PFParticle )) return tryEval<pat::PFParticle >(c, pfFunc_);
32  else throw cms::Exception("Type Error") << "Cannot evaluate '" << expr_ << "' on an object of unsupported type " << type.name() << "\n";
33 }
34 
35 void
36 PATStringObjectFunction::throwBadType(const std::type_info &ty) const {
37  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";
38 }
39 
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 }
55 
56 bool
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 }
70 
71 void
72 PATStringCutObjectSelector::throwBadType(const std::type_info &ty) const {
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 }
void throwBadType(const std::type_info &ty1) const
type
Definition: HCALResponse.h:21
Analysis-level MET class.
Definition: MET.h:43
Analysis-level Photon class.
Definition: Photon.h:47
boost::shared_ptr< StringObjectFunction< pat::Jet > > jetFunc_
void throwBadType(const std::type_info &ty1) const
boost::shared_ptr< StringCutObjectSelector< pat::PFParticle > > pfFunc_
boost::shared_ptr< StringObjectFunction< pat::Muon > > muFunc_
boost::shared_ptr< StringCutObjectSelector< pat::Photon > > gamFunc_
bool operator()(const reco::Candidate &c) const
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_
boost::shared_ptr< StringObjectFunction< pat::Tau > > tauFunc_
boost::shared_ptr< StringObjectFunction< pat::MET > > metFunc_
Analysis-level tau class.
Definition: Tau.h:55
boost::shared_ptr< StringCutObjectSelector< pat::MET > > metFunc_
boost::shared_ptr< StringObjectFunction< reco::Candidate > > candFunc_
boost::shared_ptr< StringObjectFunction< pat::Electron > > eleFunc_
boost::shared_ptr< StringObjectFunction< pat::PFParticle > > pfFunc_
Analysis-level electron class.
Definition: Electron.h:52
Analysis-level calorimeter jet class.
Definition: Jet.h:78
Analysis-level class for reconstructed particles.
Definition: PFParticle.h:35
boost::shared_ptr< StringObjectFunction< pat::Photon > > gamFunc_
boost::shared_ptr< StringCutObjectSelector< pat::Electron > > eleFunc_
boost::shared_ptr< StringObjectFunction< pat::GenericParticle > > gpFunc_
double operator()(const reco::Candidate &c) const
boost::shared_ptr< StringCutObjectSelector< pat::Tau > > tauFunc_
Analysis-level muon class.
Definition: Muon.h:50