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 
15 #include <boost/spirit/include/classic_core.hpp>
16 #include <boost/spirit/include/classic_push_back_actor.hpp>
17 
18 #include <vector>
19 
20 using namespace boost::spirit;
21 using namespace std;
22 using namespace boost::spirit::classic;
23 namespace cand {
24  namespace parser {
25 
26  class ModeSetter {
27  public:
28  ModeSetter(vector<ConjInfo>& iVect, ConjInfo::Mode iMode) : conjInfo_(iVect), mode_(iMode) {}
29  void operator()(const char) const { conjInfo_.back().mode_ = mode_; }
30 
31  private:
32  vector<ConjInfo>& conjInfo_;
34  };
35 
36  typedef scanner_policies<skip_parser_iteration_policy<nothing_parser, iteration_policy>, match_policy, action_policy>
38  typedef scanner<const char*, ScannerPolicy> ScannerUsed_1;
39  typedef rule<ScannerUsed_1> Rule_1;
40 
41  bool decayParser(const string& iValue, vector<ConjInfo>& oStrings) {
42  using namespace boost::spirit;
43 
44  Rule_1 label = ((+alnum_p) >> *ch_p(':') >> *ch_p('_') >> *alnum_p)[push_back_a(oStrings)];
45  Rule_1 conj = (ch_p('@') >> !((ch_p('b') >> ch_p('a') >> ch_p('r')[ModeSetter(oStrings, ConjInfo::kBar)]) |
46  ch_p('+')[ModeSetter(oStrings, ConjInfo::kPlus)] |
47  ch_p('-')[ModeSetter(oStrings, ConjInfo::kMinus)]));
48 
49  return parse(iValue.c_str(), ((label >> !conj) % blank_p), nothing_p).full;
50  }
51  } // namespace parser
52 } // namespace cand
cand::parser::ModeSetter::operator()
void operator()(const char) const
Definition: decayParser.cc:29
cand::parser::ModeSetter
Definition: decayParser.cc:26
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:32
full
Definition: GenABIO.cc:168
decayParser.h
cand::parser::Rule_1
rule< ScannerUsed_1 > Rule_1
Definition: decayParser.cc:39
cand::parser::decayParser
bool decayParser(const string &iValue, vector< ConjInfo > &oStrings)
Definition: decayParser.cc:41
cand::parser::ModeSetter::mode_
ConjInfo::Mode mode_
Definition: decayParser.cc:33
cand::parser::ScannerUsed_1
scanner< const char *, ScannerPolicy > ScannerUsed_1
Definition: decayParser.cc:38
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:37
cand
Definition: decayParser.h:32
cand::parser::ModeSetter::ModeSetter
ModeSetter(vector< ConjInfo > &iVect, ConjInfo::Mode iMode)
Definition: decayParser.cc:28
std
Definition: JetResolutionObject.h:76
label
const char * label
Definition: PFTauDecayModeTools.cc:11
cand::parser::ConjInfo::Mode
Mode
Definition: decayParser.h:35
boost::spirit
Definition: DDPartSelection.cc:9