CMS 3D CMS Logo

HcalTopologyRestrictionParser.cc
Go to the documentation of this file.
3 #include <boost/tokenizer.hpp>
4 #include <sstream>
5 #include <iostream>
7 
9  if (item == "HB")
10  return HcalBarrel;
11  if (item == "HE")
12  return HcalEndcap;
13  if (item == "HF")
14  return HcalForward;
15  if (item == "HO")
16  return HcalOuter;
17  return (HcalSubdetector)0;
18 }
19 
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)
std::string parse(const std::string &line)
static HcalSubdetector determineSubdet(const std::string &item)
void exclude(const HcalDetId &id)
HcalSubdetector
Definition: HcalAssistant.h:31
HcalTopologyRestrictionParser(HcalTopology &target)
Definition: errors.py:1