CMS 3D CMS Logo

decayParser.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     CandCombiner
00004 // Class  :     decayParser
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  
00010 //         Created:  Sun Aug  7 20:26:31 EDT 2005
00011 // $Id: decayParser.cc,v 1.5 2008/04/11 16:56:15 kaulmer Exp $
00012 //
00013 #include <boost/spirit/core.hpp>
00014 #include <boost/spirit/actor/push_back_actor.hpp>
00015 #include <vector>
00016 #include "PhysicsTools/CandAlgos/interface/decayParser.h"
00017 
00018 using namespace boost::spirit;
00019 using namespace std;
00020 
00021 namespace cand {
00022   namespace parser {
00023     
00024     class ModeSetter {
00025     public:
00026       ModeSetter( vector<ConjInfo>& iVect, ConjInfo::Mode iMode) : 
00027         conjInfo_(iVect), mode_(iMode) {}
00028       void operator()( const char ) const {
00029         conjInfo_.back().mode_ = mode_;
00030       }
00031     private:
00032       vector<ConjInfo>& conjInfo_;
00033       ConjInfo::Mode mode_;
00034     };
00035     
00036     typedef scanner_policies<skip_parser_iteration_policy<nothing_parser, 
00037                                                           iteration_policy>, 
00038                              match_policy,action_policy> ScannerPolicy;
00039     typedef scanner<const char*, ScannerPolicy > ScannerUsed_1;
00040     typedef rule<ScannerUsed_1> Rule_1;
00041     
00042     bool decayParser( const string& iValue, vector<ConjInfo>& oStrings ) {
00043       using namespace boost::spirit;
00044       
00045       Rule_1 label = ((+alnum_p) >> *ch_p(':') >> *ch_p('_') >>*alnum_p)[push_back_a(oStrings)];
00046       Rule_1 conj =  (ch_p('@') >> !((ch_p('b')>>ch_p('a')>>ch_p('r')[ModeSetter(oStrings,ConjInfo::kBar)] )| 
00047                                      ch_p('+')[ModeSetter(oStrings,ConjInfo::kPlus)] | 
00048                                      ch_p('-')[ModeSetter(oStrings,ConjInfo::kMinus)]) );
00049       
00050       return parse( iValue.c_str(),
00051                     (
00052                      (label >> ! conj)
00053                      % blank_p
00054                      )
00055                     ,
00056                     nothing_p).full;
00057     }
00058   }
00059 }

Generated on Tue Jun 9 17:40:59 2009 for CMSSW by  doxygen 1.5.4