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)

Definition at line 5 of file HcalTopologyRestrictionParser.cc.

5 : target_(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 19 of file HcalTopologyRestrictionParser.cc.

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

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

Member Data Documentation

◆ target_

HcalTopology& HcalTopologyRestrictionParser::target_
private

Definition at line 30 of file HcalTopologyRestrictionParser.h.

Referenced by parse().

gather_cfg.cout
cout
Definition: gather_cfg.py:144
hcaltpdigi_cfi.ieta2
ieta2
Definition: hcaltpdigi_cfi.py:21
errors
Definition: errors.py:1
HcalTopology::exclude
void exclude(const HcalDetId &id)
Definition: HcalTopology.cc:377
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiPixelPI::phase
phase
Definition: SiPixelPayloadInspectorHelper.h:39
HcalTopologyRestrictionParser::target_
HcalTopology & target_
Definition: HcalTopologyRestrictionParser.h:30
HcalTopology::excludeSubdetector
void excludeSubdetector(HcalSubdetector subdet)
Definition: HcalTopology.cc:384
hcaltpdigi_cfi.ieta1
ieta1
Definition: hcaltpdigi_cfi.py:20
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
determineSubdet
static HcalSubdetector determineSubdet(const std::string &item)
Definition: HcalTopologyRestrictionParser.cc:7
mps_splice.line
line
Definition: mps_splice.py:76
debug_messages_cfi.errors
errors
Definition: debug_messages_cfi.py:54