CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions
helper::Parser Class Reference

#include <ScannerHelpers.h>

Public Member Functions

 Parser ()
 Empty constructor, necessary for Root, useless. More...
 

Static Public Member Functions

static edm::TypeWithDict elementType (const edm::TypeWithDict &wrapperType)
 Perform the type deduction form edm::Wrapper<C> to C::value_type and resolves typedefs. More...
 
static double eval (const reco::parser::ExpressionPtr &sel, const edm::TypeWithDict type, const void *obj)
 Make a edm::ObjectWithDict(type, obj) and pass it to the expression. More...
 
static reco::parser::ExpressionPtr makeExpression (const std::string &expr, const edm::TypeWithDict &type)
 Parse an expression for a given object type (using lazy parsing when resolving methods) More...
 
static reco::parser::SelectorPtr makeSelector (const std::string &expr, const edm::TypeWithDict &type)
 Parse an expression for a given object type (using lazy parsing when resolving methods) More...
 
static bool test (const reco::parser::SelectorPtr &sel, const edm::TypeWithDict type, const void *obj)
 Make a edm::ObjectWithDict(type, obj) and pass it to the selector. More...
 

Detailed Description

Class helper::Parser has collection of useful static methods related to StringParser that can be exported to CINT via dictionaries. It's mosly meant to be used through the helper::ScannerBase class.

Definition at line 23 of file ScannerHelpers.h.

Constructor & Destructor Documentation

◆ Parser()

helper::Parser::Parser ( )
inline

Empty constructor, necessary for Root, useless.

Definition at line 26 of file ScannerHelpers.h.

26 {}

Member Function Documentation

◆ elementType()

edm::TypeWithDict helper::Parser::elementType ( const edm::TypeWithDict wrapperType)
static

Perform the type deduction form edm::Wrapper<C> to C::value_type and resolves typedefs.

Definition at line 42 of file ScannerHelpers.cc.

42  {
44  // now search for value_type
45  edm::TypeWithDict objtype = collection.nestedType("value_type");
46  if (bool(objtype)) {
47  return objtype;
48  }
49  std::cerr << "Can't get a type out of " << wrapperType.name() << std::endl;
50  return edm::TypeWithDict();
51 }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, universalConfigTemplate::collection, edm::TypeWithDict::name(), and edm::TypeWithDict::templateArgumentAt().

Referenced by fwlite::Scanner< Collection >::Scanner().

◆ eval()

double helper::Parser::eval ( const reco::parser::ExpressionPtr sel,
const edm::TypeWithDict  type,
const void *  obj 
)
static

Make a edm::ObjectWithDict(type, obj) and pass it to the expression.

Definition at line 60 of file ScannerHelpers.cc.

60  {
61  if (expr.get() == nullptr)
62  return 0;
63  edm::ObjectWithDict obj(type, const_cast<void *>(ptr));
64  return expr->value(obj);
65 }

References jets_cff::expr, and getGTfromDQMFile::obj.

◆ makeExpression()

reco::parser::ExpressionPtr helper::Parser::makeExpression ( const std::string &  expr,
const edm::TypeWithDict type 
)
static

Parse an expression for a given object type (using lazy parsing when resolving methods)

NOTA BENE: <0> for cuts, <1> for expresions (why? boh!)

Definition at line 8 of file ScannerHelpers.cc.

8  {
10 
11  using namespace boost::spirit::classic;
12  reco::parser::Grammar grammar(ret, type, true);
13  const char *startingFrom = expr.c_str();
14  try {
15  parse(startingFrom,
16  grammar.use_parser<1>() >> end_p,
17  space_p);
18  } catch (reco::parser::BaseException &e) {
19  std::cerr << "Expression parser error:" << reco::parser::baseExceptionWhat(e) << " (char " << e.where - startingFrom
20  << ")" << std::endl;
21  }
22  return ret;
23 }

References reco::parser::baseExceptionWhat(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, MillePedeFileConverter_cfg::e, jets_cff::expr, dumpparser::parse(), and runTheMatrix::ret.

Referenced by helper::ScannerBase::addExpression().

◆ makeSelector()

reco::parser::SelectorPtr helper::Parser::makeSelector ( const std::string &  expr,
const edm::TypeWithDict type 
)
static

Parse an expression for a given object type (using lazy parsing when resolving methods)

NOTA BENE: <0> for cuts, <1> for expresions (why? boh!)

Definition at line 25 of file ScannerHelpers.cc.

25  {
27 
28  using namespace boost::spirit::classic;
29  reco::parser::Grammar grammar(ret, type, true);
30  const char *startingFrom = expr.c_str();
31  try {
32  parse(startingFrom,
33  grammar.use_parser<0>() >> end_p,
34  space_p);
35  } catch (reco::parser::BaseException &e) {
36  std::cerr << "Selector parser error:" << reco::parser::baseExceptionWhat(e) << " (char " << e.where - startingFrom
37  << ")" << std::endl;
38  }
39  return ret;
40 }

References reco::parser::baseExceptionWhat(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, MillePedeFileConverter_cfg::e, jets_cff::expr, dumpparser::parse(), and runTheMatrix::ret.

Referenced by helper::ScannerBase::addExtraCut(), and helper::ScannerBase::setCut().

◆ test()

bool helper::Parser::test ( const reco::parser::SelectorPtr sel,
const edm::TypeWithDict  type,
const void *  obj 
)
static

Make a edm::ObjectWithDict(type, obj) and pass it to the selector.

Definition at line 53 of file ScannerHelpers.cc.

53  {
54  if (sel.get() == nullptr)
55  return false;
56  edm::ObjectWithDict obj(type, const_cast<void *>(ptr));
57  return (*sel)(obj);
58 }

References getGTfromDQMFile::obj, and EgammaValidation_Wenu_cff::sel.

Referenced by edmIntegrityCheck.IntegrityCheck::report(), and edmIntegrityCheck.IntegrityCheck::structured().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
reco::parser::baseExceptionWhat
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate 'what' message for the exception
Definition: Exception.h:36
boost::spirit::classic
Definition: DDPartSelection.cc:10
edm::ObjectWithDict
Definition: ObjectWithDict.h:17
edm::TypeWithDict::templateArgumentAt
TypeWithDict templateArgumentAt(size_t index) const
Definition: TypeWithDict.cc:697
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
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
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
universalConfigTemplate.collection
collection
Definition: universalConfigTemplate.py:81
reco::parser::ExpressionPtr
std::shared_ptr< ExpressionBase > ExpressionPtr
Definition: ExpressionBase.h:25
reco::parser::Grammar
Definition: Grammar.h:45
jets_cff.expr
expr
Definition: jets_cff.py:483
reco::parser::SelectorPtr
std::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:18
EgammaValidation_Wenu_cff.sel
sel
Definition: EgammaValidation_Wenu_cff.py:33
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
edm::TypeWithDict::name
std::string name() const
Definition: TypeWithDict.cc:456
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37