CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
HcalTopologyRestrictionParser Class Reference

#include <HcalTopologyRestrictionParser.h>

Public Member Functions

 HcalTopologyRestrictionParser (HcalTopology &target)
 
std::string parse (const std::string &line)
 

Private Attributes

HcalTopologytarget_
 

Detailed Description

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"

Author
J. Mans - Minnesota

Definition at line 21 of file HcalTopologyRestrictionParser.h.

Constructor & Destructor Documentation

HcalTopologyRestrictionParser::HcalTopologyRestrictionParser ( HcalTopology target)

Definition at line 5 of file HcalTopologyRestrictionParser.cc.

5  : target_(target) {
6 }

Member Function Documentation

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(), cmsHarvester::sep, AlCaHLTBitMon_QueryRunRegistry::string, and target_.

Referenced by HcalTopologyIdealEP::produce().

16  {
17 
18  std::ostringstream errors;
19  boost::char_separator<char> sep(" \t",";");
20  typedef boost::tokenizer<boost::char_separator<char> > myTokType;
21 
22  std::string totaline(line); totaline+=';'; // terminate
23  myTokType tok(totaline, sep);
24  int ieta1=0, ieta2=0, iphi1=-1, iphi2=-1, depth1=1, depth2=4;
26 
27  int phase=0;
28  for (myTokType::iterator beg=tok.begin(); beg!=tok.end() && phase>=0; ++beg){
29  std::cout << phase << " : <" << *beg << ">\n";
30  if (*beg==";") {
31  if (phase==0) continue; // empty
32  if (phase!=1 && phase!=5 && phase!=7) {
33  errors << "Expect 1, 5, or 7 arguments, got " << phase;
34  phase=-1;
35  } else {
36  if (phase==1) { // reject whole subdetector...
38  } else {
39  target_.exclude(subdet,ieta1,ieta2,iphi1,iphi2,depth1,depth2);
40  }
41  phase=0;
42  }
43  } else {
44  switch (phase) {
45  case (0) : subdet=determineSubdet(*beg); break;
46  case (1) : ieta1=atoi(beg->c_str()); break;
47  case (2) : ieta2=atoi(beg->c_str()); break;
48  case (3) : iphi1=atoi(beg->c_str()); break;
49  case (4) : iphi2=atoi(beg->c_str()); depth1=1; depth2=4; break; // also set defaults...
50  case (5) : depth1=atoi(beg->c_str()); break;
51  case (6) : depth2=atoi(beg->c_str()); break;
52  }
53  phase++;
54  }
55  }
56 
57  return errors.str();
58 
59 }
void excludeSubdetector(HcalSubdetector subdet)
static HcalSubdetector determineSubdet(const std::string &item)
void exclude(const HcalDetId &id)
HcalSubdetector
Definition: HcalAssistant.h:31
tuple cout
Definition: gather_cfg.py:145

Member Data Documentation

HcalTopology& HcalTopologyRestrictionParser::target_
private

Definition at line 29 of file HcalTopologyRestrictionParser.h.

Referenced by parse().