CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StringParserTools.cc
Go to the documentation of this file.
2 #include <typeinfo>
3 
5  candFunc_ = tryGet<reco::Candidate>(string);
6  if (!candFunc_.get()) {
7  eleFunc_ = tryGet<pat::Electron>(string);
8  muFunc_ = tryGet<pat::Muon>(string);
9  tauFunc_ = tryGet<pat::Tau>(string);
10  gamFunc_ = tryGet<pat::Photon>(string);
11  jetFunc_ = tryGet<pat::Jet>(string);
12  metFunc_ = tryGet<pat::MET>(string);
13  gpFunc_ = tryGet<pat::GenericParticle>(string);
14  pfFunc_ = tryGet<pat::PFParticle>(string);
15  }
16 }
17 
19  if (candFunc_.get())
20  return (*candFunc_)(c);
21  const std::type_info &type = typeid(c);
22  if (type == typeid(pat::Electron))
23  return tryEval<pat::Electron>(c, eleFunc_);
24  else if (type == typeid(pat::Muon))
25  return tryEval<pat::Muon>(c, muFunc_);
26  else if (type == typeid(pat::Tau))
27  return tryEval<pat::Tau>(c, tauFunc_);
28  else if (type == typeid(pat::Photon))
29  return tryEval<pat::Photon>(c, gamFunc_);
30  else if (type == typeid(pat::Jet))
31  return tryEval<pat::Jet>(c, jetFunc_);
32  else if (type == typeid(pat::MET))
33  return tryEval<pat::MET>(c, metFunc_);
34  else if (type == typeid(pat::GenericParticle))
35  return tryEval<pat::GenericParticle>(c, gpFunc_);
36  else if (type == typeid(pat::PFParticle))
37  return tryEval<pat::PFParticle>(c, pfFunc_);
38  else
39  throw cms::Exception("Type Error") << "Cannot evaluate '" << expr_ << "' on an object of unsupported type "
40  << type.name() << "\n";
41 }
42 
43 void PATStringObjectFunction::throwBadType(const std::type_info &ty) const {
44  throw cms::Exception("Type Error") << "Expression '" << expr_ << "' can't be evaluated on an object of type "
45  << ty.name() << "\n(hint: use c++filt to demangle the type name)\n";
46 }
47 
49  candFunc_ = tryGet<reco::Candidate>(string);
50  if (!candFunc_.get()) {
51  eleFunc_ = tryGet<pat::Electron>(string);
52  muFunc_ = tryGet<pat::Muon>(string);
53  tauFunc_ = tryGet<pat::Tau>(string);
54  gamFunc_ = tryGet<pat::Photon>(string);
55  jetFunc_ = tryGet<pat::Jet>(string);
56  metFunc_ = tryGet<pat::MET>(string);
57  gpFunc_ = tryGet<pat::GenericParticle>(string);
58  pfFunc_ = tryGet<pat::PFParticle>(string);
59  }
60 }
61 
63  if (candFunc_.get())
64  return (*candFunc_)(c);
65  const std::type_info &type = typeid(c);
66  if (type == typeid(pat::Electron))
67  return tryEval<pat::Electron>(c, eleFunc_);
68  else if (type == typeid(pat::Muon))
69  return tryEval<pat::Muon>(c, muFunc_);
70  else if (type == typeid(pat::Tau))
71  return tryEval<pat::Tau>(c, tauFunc_);
72  else if (type == typeid(pat::Photon))
73  return tryEval<pat::Photon>(c, gamFunc_);
74  else if (type == typeid(pat::Jet))
75  return tryEval<pat::Jet>(c, jetFunc_);
76  else if (type == typeid(pat::MET))
77  return tryEval<pat::MET>(c, metFunc_);
78  else if (type == typeid(pat::GenericParticle))
79  return tryEval<pat::GenericParticle>(c, gpFunc_);
80  else if (type == typeid(pat::PFParticle))
81  return tryEval<pat::PFParticle>(c, pfFunc_);
82  else
83  throw cms::Exception("Type Error") << "Cannot evaluate '" << expr_ << "' on an object of unsupported type "
84  << type.name() << "\n";
85 }
86 
87 void PATStringCutObjectSelector::throwBadType(const std::type_info &ty) const {
88  throw cms::Exception("Type Error") << "Expression '" << expr_ << "' can't be evaluated on an object of type "
89  << ty.name() << "\n(hint: use c++filt to demangle the type name)\n";
90 }
void throwBadType(const std::type_info &ty1) const
std::shared_ptr< StringCutObjectSelector< pat::Tau > > tauFunc_
Analysis-level MET class.
Definition: MET.h:40
std::shared_ptr< StringObjectFunction< pat::Photon > > gamFunc_
Analysis-level Photon class.
Definition: Photon.h:46
const edm::EventSetup & c
std::shared_ptr< StringObjectFunction< pat::PFParticle > > pfFunc_
std::shared_ptr< StringCutObjectSelector< pat::PFParticle > > pfFunc_
void throwBadType(const std::type_info &ty1) const
std::shared_ptr< StringObjectFunction< pat::Jet > > jetFunc_
std::shared_ptr< StringObjectFunction< pat::GenericParticle > > gpFunc_
std::shared_ptr< StringCutObjectSelector< reco::Candidate > > candFunc_
std::shared_ptr< StringObjectFunction< pat::Tau > > tauFunc_
bool operator()(const reco::Candidate &c) const
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
std::shared_ptr< StringCutObjectSelector< pat::Photon > > gamFunc_
std::shared_ptr< StringCutObjectSelector< pat::Jet > > jetFunc_
std::shared_ptr< StringCutObjectSelector< pat::Electron > > eleFunc_
std::shared_ptr< StringObjectFunction< reco::Candidate > > candFunc_
std::shared_ptr< StringObjectFunction< pat::MET > > metFunc_
Analysis-level tau class.
Definition: Tau.h:53
std::shared_ptr< StringCutObjectSelector< pat::MET > > metFunc_
std::shared_ptr< StringCutObjectSelector< pat::Muon > > muFunc_
std::shared_ptr< StringObjectFunction< pat::Electron > > eleFunc_
Analysis-level electron class.
Definition: Electron.h:51
Analysis-level calorimeter jet class.
Definition: Jet.h:77
Analysis-level class for reconstructed particles.
Definition: PFParticle.h:32
std::shared_ptr< StringObjectFunction< pat::Muon > > muFunc_
double operator()(const reco::Candidate &c) const
Analysis-level muon class.
Definition: Muon.h:51
std::shared_ptr< StringCutObjectSelector< pat::GenericParticle > > gpFunc_