#include <Geometry/CaloTopology/interface/HcalTopologyRestrictionParser.h>
Public Member Functions | |
HcalTopologyRestrictionParser (HcalTopology &target) | |
std::string | parse (const std::string &line) |
Parses a line of restrictions and returns an error string if there is a problem. | |
Private Attributes | |
HcalTopology & | target_ |
It functions as a parser to convert textually-encoded restrictions into calls to HcalTopology::exclude().
The grammer is (using a rough notation)
line = rule >> *(; >> rule ) rule = region | subdetector region = subdetname ieta1 ieta2 iphi1 iphi2 [depth1 depth2] subdetector = subdetname subdetname = "HB" | "HE" | "HO" | "HF"
Definition at line 23 of file HcalTopologyRestrictionParser.h.
HcalTopologyRestrictionParser::HcalTopologyRestrictionParser | ( | HcalTopology & | target | ) |
std::string HcalTopologyRestrictionParser::parse | ( | const std::string & | line | ) |
Parses a line of restrictions and returns an error string if there is a problem.
The line must be formated as described in the class description.
Definition at line 16 of file HcalTopologyRestrictionParser.cc.
References GenMuonPlsPt100GeV_cfg::cout, determineSubdet(), HLT_VtxMuL3::errors, HcalTopology::exclude(), HcalTopology::excludeSubdetector(), and target_.
Referenced by HcalTopologyIdealEP::produce().
00016 { 00017 00018 std::ostringstream errors; 00019 boost::char_separator<char> sep(" \t",";"); 00020 typedef boost::tokenizer<boost::char_separator<char> > myTokType; 00021 00022 std::string totaline(line); totaline+=';'; // terminate 00023 myTokType tok(totaline, sep); 00024 int ieta1=0, ieta2=0, iphi1=-1, iphi2=-1, depth1=1, depth2=4; 00025 HcalSubdetector subdet=(HcalSubdetector)0; 00026 00027 int phase=0; 00028 for (myTokType::iterator beg=tok.begin(); beg!=tok.end() && phase>=0; ++beg){ 00029 std::cout << phase << " : <" << *beg << ">\n"; 00030 if (*beg==";") { 00031 if (phase==0) continue; // empty 00032 if (phase!=1 && phase!=5 && phase!=7) { 00033 errors << "Expect 1, 5, or 7 arguments, got " << phase; 00034 phase=-1; 00035 } else { 00036 if (phase==1) { // reject whole subdetector... 00037 target_.excludeSubdetector(subdet); 00038 } else { 00039 target_.exclude(subdet,ieta1,ieta2,iphi1,iphi2,depth1,depth2); 00040 } 00041 phase=0; 00042 } 00043 } else { 00044 switch (phase) { 00045 case (0) : subdet=determineSubdet(*beg); break; 00046 case (1) : ieta1=atoi(beg->c_str()); break; 00047 case (2) : ieta2=atoi(beg->c_str()); break; 00048 case (3) : iphi1=atoi(beg->c_str()); break; 00049 case (4) : iphi2=atoi(beg->c_str()); depth1=1; depth2=4; break; // also set defaults... 00050 case (5) : depth1=atoi(beg->c_str()); break; 00051 case (6) : depth2=atoi(beg->c_str()); break; 00052 } 00053 phase++; 00054 } 00055 } 00056 00057 return errors.str(); 00058 00059 }