CommonTools
Utils
src
cutParser.cc
Go to the documentation of this file.
1
#include "
CommonTools/Utils/interface/cutParser.h
"
2
#include "
CommonTools/Utils/src/AnyObjSelector.h
"
3
#include "
CommonTools/Utils/src/Grammar.h
"
4
#include "
FWCore/Utilities/interface/EDMException.h
"
5
6
using namespace
reco::parser
;
7
bool
reco::parser::cutParser
(
const
edm::TypeWithDict
&
t
,
const
std::string
&
cut
,
SelectorPtr
&
sel
,
bool
lazy =
false
) {
8
bool
justBlanks =
true
;
9
for
(std::string::const_iterator
c
=
cut
.begin();
c
!=
cut
.end(); ++
c
) {
10
if
(*
c
!=
' '
) {
11
justBlanks =
false
;
12
break
;
13
}
14
}
15
if
(justBlanks) {
16
sel
=
SelectorPtr
(
new
AnyObjSelector
);
17
return
true
;
18
}
else
{
19
using namespace
boost::spirit::classic
;
20
Grammar
grammar(
sel
,
t
, lazy);
21
bool
returnValue =
false
;
22
const
char
* startingFrom =
cut
.c_str();
23
try
{
24
returnValue =
parse
(startingFrom, grammar.use_parser<0>() >> end_p, space_p).full;
25
}
catch
(
BaseException
&
e
) {
26
throw
edm::Exception
(
edm::errors::Configuration
)
27
<<
"Cut parser error:"
<<
baseExceptionWhat
(
e
) <<
" (char "
<<
e
.where - startingFrom <<
")\n"
;
28
}
29
return
returnValue;
30
}
31
}
reco::parser::baseExceptionWhat
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate 'what' message for the exception
Definition:
Exception.h:36
TkAlMuonSelectors_cfi.cut
cut
Definition:
TkAlMuonSelectors_cfi.py:5
boost::spirit::classic
Definition:
DDPartSelection.cc:10
reco::parser::cutParser
bool cutParser(const edm::TypeWithDict &t, const std::string &cut, SelectorPtr &sel, bool lazy)
Definition:
cutParser.cc:7
EDMException.h
AnyObjSelector.h
OrderedSet.t
t
Definition:
OrderedSet.py:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
dumpparser.parse
def parse(path, config)
Definition:
dumpparser.py:13
edm::TypeWithDict
Definition:
TypeWithDict.h:38
reco::parser::BaseException
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition:
Exception.h:33
HltBtagPostValidation_cff.c
c
Definition:
HltBtagPostValidation_cff.py:31
reco::parser::Grammar
Definition:
Grammar.h:45
cutParser.h
reco::parser
Definition:
cutParser.h:9
reco::parser::SelectorPtr
std::shared_ptr< SelectorBase > SelectorPtr
Definition:
SelectorPtr.h:18
Exception
Definition:
hltDiff.cc:246
EgammaValidation_Wenu_cff.sel
sel
Definition:
EgammaValidation_Wenu_cff.py:33
edm::errors::Configuration
Definition:
EDMException.h:36
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
Grammar.h
reco::parser::AnyObjSelector
Definition:
AnyObjSelector.h:7
Generated for CMSSW Reference Manual by
1.8.16