CMS 3D CMS Logo

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::HcalTopologyRestrictionParser ( HcalTopology target)

Member Function Documentation

◆ parse()

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 20 of file HcalTopologyRestrictionParser.cc.

References determineSubdet(), nano_mu_digi_cff::errors, HcalTopology::exclude(), HcalTopology::excludeSubdetector(), hcaltpdigi_cfi::ieta1, hcaltpdigi_cfi::ieta2, mps_splice::line, AlCaHLTBitMon_QueryRunRegistry::string, and target_.

20  {
21  std::ostringstream errors;
22  boost::char_separator<char> sep(" \t", ";");
23  typedef boost::tokenizer<boost::char_separator<char> > myTokType;
24 
25  std::string totaline(line);
26  totaline += ';'; // terminate
27  myTokType tok(totaline, sep);
28  int ieta1 = 0, ieta2 = 0, iphi1 = -1, iphi2 = -1, depth1 = 1, depth2 = 4;
29  HcalSubdetector subdet = (HcalSubdetector)0;
30 
31  int phase = 0;
32  for (myTokType::iterator beg = tok.begin(); beg != tok.end() && phase >= 0; ++beg) {
33  edm::LogVerbatim("HCalGeom") << phase << " : <" << *beg << ">";
34  if (*beg == ";") {
35  if (phase == 0)
36  continue; // empty
37  if (phase != 1 && phase != 5 && phase != 7) {
38  errors << "Expect 1, 5, or 7 arguments, got " << phase;
39  phase = -1;
40  } else {
41  if (phase == 1) { // reject whole subdetector...
43  } else {
44  target_.exclude(subdet, ieta1, ieta2, iphi1, iphi2, depth1, depth2);
45  }
46  phase = 0;
47  }
48  } else {
49  switch (phase) {
50  case (0):
51  subdet = determineSubdet(*beg);
52  break;
53  case (1):
54  ieta1 = atoi(beg->c_str());
55  break;
56  case (2):
57  ieta2 = atoi(beg->c_str());
58  break;
59  case (3):
60  iphi1 = atoi(beg->c_str());
61  break;
62  case (4):
63  iphi2 = atoi(beg->c_str());
64  depth1 = 1;
65  depth2 = 4;
66  break; // also set defaults...
67  case (5):
68  depth1 = atoi(beg->c_str());
69  break;
70  case (6):
71  depth2 = atoi(beg->c_str());
72  break;
73  }
74  phase++;
75  }
76  }
77 
78  return errors.str();
79 }
Log< level::Info, true > LogVerbatim
void excludeSubdetector(HcalSubdetector subdet)
static HcalSubdetector determineSubdet(const std::string &item)
void exclude(const HcalDetId &id)
HcalSubdetector
Definition: HcalAssistant.h:31
Definition: errors.py:1

Member Data Documentation

◆ target_

HcalTopology& HcalTopologyRestrictionParser::target_
private

Definition at line 30 of file HcalTopologyRestrictionParser.h.

Referenced by parse().