#include <HcalTopologyRestrictionParser.h>
Public Member Functions | |
HcalTopologyRestrictionParser (HcalTopology &target) | |
std::string | parse (const std::string &line) |
Private Attributes | |
HcalTopology & | target_ |
This utility class is intended to provide a standard way to set restrictions on the HcalTopology to exclude cells for testbeam and other purposes. 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 | ) |
Definition at line 5 of file HcalTopologyRestrictionParser.cc.
: target_(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 gather_cfg::cout, determineSubdet(), benchmark_cfg::errors, HcalTopology::exclude(), HcalTopology::excludeSubdetector(), and target_.
Referenced by HcalTopologyIdealEP::produce().
{ std::ostringstream errors; boost::char_separator<char> sep(" \t",";"); typedef boost::tokenizer<boost::char_separator<char> > myTokType; std::string totaline(line); totaline+=';'; // terminate myTokType tok(totaline, sep); int ieta1=0, ieta2=0, iphi1=-1, iphi2=-1, depth1=1, depth2=4; HcalSubdetector subdet=(HcalSubdetector)0; int phase=0; for (myTokType::iterator beg=tok.begin(); beg!=tok.end() && phase>=0; ++beg){ std::cout << phase << " : <" << *beg << ">\n"; if (*beg==";") { if (phase==0) continue; // empty if (phase!=1 && phase!=5 && phase!=7) { errors << "Expect 1, 5, or 7 arguments, got " << phase; phase=-1; } else { if (phase==1) { // reject whole subdetector... target_.excludeSubdetector(subdet); } else { target_.exclude(subdet,ieta1,ieta2,iphi1,iphi2,depth1,depth2); } phase=0; } } else { switch (phase) { case (0) : subdet=determineSubdet(*beg); break; case (1) : ieta1=atoi(beg->c_str()); break; case (2) : ieta2=atoi(beg->c_str()); break; case (3) : iphi1=atoi(beg->c_str()); break; case (4) : iphi2=atoi(beg->c_str()); depth1=1; depth2=4; break; // also set defaults... case (5) : depth1=atoi(beg->c_str()); break; case (6) : depth2=atoi(beg->c_str()); break; } phase++; } } return errors.str(); }
Definition at line 31 of file HcalTopologyRestrictionParser.h.
Referenced by parse().