CMS 3D CMS Logo

decayParser.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CandCombiner
4 // Class : decayParser
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Sun Aug 7 20:26:31 EDT 2005
11 // $Id: decayParser.cc,v 1.1 2009/03/03 13:50:55 llista Exp $
12 //
14 #include <vector>
15 
16 using namespace boost::spirit;
17 using namespace std;
18 using namespace boost::spirit::classic;
19 namespace cand {
20  namespace parser {
21 
22  class ModeSetter {
23  public:
24  ModeSetter(vector<ConjInfo>& iVect, ConjInfo::Mode iMode) : conjInfo_(iVect), mode_(iMode) {}
25  void operator()(const char) const { conjInfo_.back().mode_ = mode_; }
26 
27  private:
28  vector<ConjInfo>& conjInfo_;
30  };
31 
32  typedef scanner_policies<skip_parser_iteration_policy<nothing_parser, iteration_policy>, match_policy, action_policy>
34  typedef scanner<const char*, ScannerPolicy> ScannerUsed_1;
35  typedef rule<ScannerUsed_1> Rule_1;
36 
37  bool decayParser(const string& iValue, vector<ConjInfo>& oStrings) {
38  using namespace boost::spirit;
39 
40  Rule_1 label = ((+alnum_p) >> *ch_p(':') >> *ch_p('_') >> *alnum_p)[push_back_a(oStrings)];
41  Rule_1 conj = (ch_p('@') >> !((ch_p('b') >> ch_p('a') >> ch_p('r')[ModeSetter(oStrings, ConjInfo::kBar)]) |
42  ch_p('+')[ModeSetter(oStrings, ConjInfo::kPlus)] |
43  ch_p('-')[ModeSetter(oStrings, ConjInfo::kMinus)]));
44 
45  return parse(iValue.c_str(), ((label >> !conj) % blank_p), nothing_p).full;
46  }
47  } // namespace parser
48 } // namespace cand
cand::parser::ModeSetter::operator()
void operator()(const char) const
Definition: decayParser.cc:25
cand::parser::ModeSetter
Definition: decayParser.cc:22
reco::ParticleMasses::kPlus
const double kPlus
Definition: ParticleMasses.h:8
boost::spirit::classic
Definition: DDPartSelection.cc:10
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
cand::parser::ModeSetter::conjInfo_
vector< ConjInfo > & conjInfo_
Definition: decayParser.cc:28
full
Definition: GenABIO.cc:168
decayParser.h
cand::parser::Rule_1
rule< ScannerUsed_1 > Rule_1
Definition: decayParser.cc:35
cand::parser::decayParser
bool decayParser(const string &iValue, vector< ConjInfo > &oStrings)
Definition: decayParser.cc:37
cand::parser::ModeSetter::mode_
ConjInfo::Mode mode_
Definition: decayParser.cc:29
cand::parser::ScannerUsed_1
scanner< const char *, ScannerPolicy > ScannerUsed_1
Definition: decayParser.cc:34
dumpparser.parse
def parse(path, config)
Definition: dumpparser.py:13
cand::parser::ScannerPolicy
scanner_policies< skip_parser_iteration_policy< nothing_parser, iteration_policy >, match_policy, action_policy > ScannerPolicy
Definition: decayParser.cc:33
cand
Definition: decayParser.h:34
cand::parser::ModeSetter::ModeSetter
ModeSetter(vector< ConjInfo > &iVect, ConjInfo::Mode iMode)
Definition: decayParser.cc:24
std
Definition: JetResolutionObject.h:76
label
const char * label
Definition: PFTauDecayModeTools.cc:11
cand::parser::ConjInfo::Mode
Mode
Definition: decayParser.h:37
boost::spirit
Definition: DDPartSelection.cc:9