CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HcalChannelIterator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalOnlineDb
4 // Class : HcalChannelIterator
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Gena Kukartsev
10 // Created: Mon Jul 13 12:15:33 CEST 2009
11 //
12 
13 #include <fstream>
17 
19 
21 
22 int HcalChannelIterator::size(void) { return channel_list.size(); }
23 
25  channel_list.clear();
26  return 0;
27 }
28 
31  int _current_size = size();
32  std::string _row;
33  std::ifstream inFile(filename.c_str(), std::ios::in);
34  if (!inFile) {
35  std::cout << "Unable to open file with the logical map: " << filename << std::endl;
36  } else {
37  std::cout << "File with the logical map opened successfully: " << filename << std::endl;
38  }
39  while (getline(inFile, _row)) {
40  //# side eta phi dphi depth det
41  int _num, _side, _eta, _phi, _dphi, _depth;
42  char subdetbuf[32];
43 
44  int _read;
45  const char* _format = "%d %d %d %d %d %d %s";
46  _read = sscanf(_row.c_str(), _format, &_num, &_side, &_eta, &_phi, &_dphi, &_depth, subdetbuf);
47  if (_read == 7) {
48  lines.count();
49 
50  std::string subdet(subdetbuf);
51 
52  HcalSubdetector _det;
53  if (subdet.find("HB") != std::string::npos)
54  _det = HcalBarrel;
55  else if (subdet.find("HE") != std::string::npos)
56  _det = HcalEndcap;
57  else if (subdet.find("HO") != std::string::npos)
58  _det = HcalOuter;
59  else if (subdet.find("HF") != std::string::npos)
60  _det = HcalForward;
61  else
62  _det = HcalOther;
63 
64  HcalDetId _detid(_det, _side * _eta, _phi, _depth);
65 
66  if (_det == HcalBarrel || _det == HcalEndcap || _det == HcalOuter || _det == HcalForward) {
67  channel_list.push_back(_detid);
68  }
69  }
70  }
71  inFile.close();
72  std::cout << "Logical map file: " << lines.getCount() << " lines read" << std::endl;
73  std::cout << "Logical map file: " << size() - _current_size << " lines added to the list" << std::endl;
74  //
75  return 0;
76 }
77 
79  const_iterator = channel_list.begin();
80  return 0;
81 }
82 
85  return 0;
86 }
87 
89  if (const_iterator == channel_list.end()) {
90  return true;
91  } else {
92  return false;
93  }
94 }
95 
97  if (const_iterator != channel_list.end()) {
98  return *const_iterator;
99  } else {
100  return 0;
101  }
102 }
103 
105  if (const_iterator != channel_list.end()) {
107  return _id.subdet();
108  } else
109  return HcalOther;
110 }
111 
113  if (const_iterator != channel_list.end()) {
115  return _id.ieta();
116  } else
117  return -1000;
118 }
119 
121  if (const_iterator != channel_list.end()) {
123  return _id.iphi();
124  } else
125  return -1000;
126 }
127 
129  if (const_iterator != channel_list.end()) {
131  return _id.depth();
132  } else
133  return -1000;
134 }
135 
138  addListFromLmapAscii("HCALmapHBEF_Jan.27.2009.txt");
139  addListFromLmapAscii("HCALmapHO_Jan.27.2009.txt");
140  return channel_list.size();
141 }
142 
143 int HcalChannelIterator::init(const std::vector<HcalGenericDetId>& map) {
144  channel_list.clear();
145  channel_list = map;
146  return channel_list.size();
147 }
std::vector< HcalGenericDetId > channel_list
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
int addListFromLmapAscii(std::string filename)
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
int init(const std::vector< HcalGenericDetId > &map)
HcalSubdetector
Definition: HcalAssistant.h:31
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
void count(void)
Definition: RooGKCounter.cc:54
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:144
HcalGenericDetId getHcalGenericDetId(void)
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164
std::vector< HcalGenericDetId >::const_iterator const_iterator
HcalSubdetector getHcalSubdetector(void)