CMS 3D CMS Logo

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 }
PATStringCutObjectSelector::candFunc_
std::shared_ptr< StringCutObjectSelector< reco::Candidate > > candFunc_
Definition: StringParserTools.h:68
PATStringObjectFunction::PATStringObjectFunction
PATStringObjectFunction()
Definition: StringParserTools.h:18
PATStringCutObjectSelector::pfFunc_
std::shared_ptr< StringCutObjectSelector< pat::PFParticle > > pfFunc_
Definition: StringParserTools.h:77
pat::Tau
Analysis-level tau class.
Definition: Tau.h:53
pat::Photon
Analysis-level Photon class.
Definition: Photon.h:46
PATStringObjectFunction::pfFunc_
std::shared_ptr< StringObjectFunction< pat::PFParticle > > pfFunc_
Definition: StringParserTools.h:34
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
pat::PFParticle
Analysis-level class for reconstructed particles.
Definition: PFParticle.h:32
PATStringCutObjectSelector::tauFunc_
std::shared_ptr< StringCutObjectSelector< pat::Tau > > tauFunc_
Definition: StringParserTools.h:72
PATStringObjectFunction::jetFunc_
std::shared_ptr< StringObjectFunction< pat::Jet > > jetFunc_
Definition: StringParserTools.h:31
PATStringCutObjectSelector::jetFunc_
std::shared_ptr< StringCutObjectSelector< pat::Jet > > jetFunc_
Definition: StringParserTools.h:74
PATStringObjectFunction::gpFunc_
std::shared_ptr< StringObjectFunction< pat::GenericParticle > > gpFunc_
Definition: StringParserTools.h:33
PATStringObjectFunction::candFunc_
std::shared_ptr< StringObjectFunction< reco::Candidate > > candFunc_
Definition: StringParserTools.h:25
pat::Jet
Analysis-level calorimeter jet class.
Definition: Jet.h:77
PATStringObjectFunction::tauFunc_
std::shared_ptr< StringObjectFunction< pat::Tau > > tauFunc_
Definition: StringParserTools.h:29
PATStringCutObjectSelector::eleFunc_
std::shared_ptr< StringCutObjectSelector< pat::Electron > > eleFunc_
Definition: StringParserTools.h:70
PATStringCutObjectSelector::PATStringCutObjectSelector
PATStringCutObjectSelector()
Definition: StringParserTools.h:61
PATStringObjectFunction::eleFunc_
std::shared_ptr< StringObjectFunction< pat::Electron > > eleFunc_
Definition: StringParserTools.h:27
pat::GenericParticle
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed)
Definition: GenericParticle.h:38
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
PATStringCutObjectSelector::operator()
bool operator()(const reco::Candidate &c) const
Definition: StringParserTools.cc:62
PATStringCutObjectSelector::metFunc_
std::shared_ptr< StringCutObjectSelector< pat::MET > > metFunc_
Definition: StringParserTools.h:75
StringParserTools.h
pat::MET
Analysis-level MET class.
Definition: MET.h:40
PATStringCutObjectSelector::gamFunc_
std::shared_ptr< StringCutObjectSelector< pat::Photon > > gamFunc_
Definition: StringParserTools.h:73
PATStringObjectFunction::metFunc_
std::shared_ptr< StringObjectFunction< pat::MET > > metFunc_
Definition: StringParserTools.h:32
PATStringObjectFunction::expr_
std::string expr_
Definition: StringParserTools.h:24
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::Candidate
Definition: Candidate.h:27
PATStringCutObjectSelector::gpFunc_
std::shared_ptr< StringCutObjectSelector< pat::GenericParticle > > gpFunc_
Definition: StringParserTools.h:76
PATStringCutObjectSelector::throwBadType
void throwBadType(const std::type_info &ty1) const
Definition: StringParserTools.cc:87
PATStringObjectFunction::throwBadType
void throwBadType(const std::type_info &ty1) const
Definition: StringParserTools.cc:43
Exception
Definition: hltDiff.cc:245
PATStringObjectFunction::gamFunc_
std::shared_ptr< StringObjectFunction< pat::Photon > > gamFunc_
Definition: StringParserTools.h:30
PATStringCutObjectSelector::muFunc_
std::shared_ptr< StringCutObjectSelector< pat::Muon > > muFunc_
Definition: StringParserTools.h:71
pat::Electron
Analysis-level electron class.
Definition: Electron.h:51
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
PATStringObjectFunction::muFunc_
std::shared_ptr< StringObjectFunction< pat::Muon > > muFunc_
Definition: StringParserTools.h:28
PATStringObjectFunction::operator()
double operator()(const reco::Candidate &c) const
Definition: StringParserTools.cc:18
PATStringCutObjectSelector::expr_
std::string expr_
Definition: StringParserTools.h:67