CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 {
20 }
21 
22 
24 {
25 }
26 
27 
28 
30  return channel_list.size();
31 }
32 
33 
35  channel_list.clear();
36  return 0;
37 }
38 
39 
42  int _current_size = size();
43  std::string _row;
44  std::ifstream inFile( filename . c_str(), std::ios::in );
45  if (!inFile){
46  std::cout << "Unable to open file with the logical map: " << filename << std::endl;
47  }
48  else{
49  std::cout << "File with the logical map opened successfully: " << filename << std::endl;
50  }
51  while ( getline( inFile, _row ) > 0 ){
52  //# side eta phi dphi depth det
53  int _num, _side, _eta, _phi, _dphi, _depth;
54  char subdetbuf[32];
55 
56  int _read;
57  const char * _format = "%d %d %d %d %d %d %s";
58  _read = sscanf( _row . c_str(), _format,
59  &_num, &_side, &_eta, &_phi, &_dphi, &_depth,
60  subdetbuf );
61  if ( _read == 7 ){
62  lines . count();
63 
64  std::string subdet(subdetbuf);
65 
66  HcalSubdetector _det;
67  if ( subdet.find("HB")!=std::string::npos ) _det = HcalBarrel;
68  else if ( subdet.find("HE")!=std::string::npos ) _det = HcalEndcap;
69  else if ( subdet.find("HO")!=std::string::npos ) _det = HcalOuter;
70  else if ( subdet.find("HF")!=std::string::npos ) _det = HcalForward;
71  else _det = HcalOther;
72 
73  HcalDetId _detid(_det, _side*_eta, _phi, _depth);
74 
75  if (_det == HcalBarrel || _det == HcalEndcap || _det == HcalOuter || _det == HcalForward){
76  channel_list . push_back( _detid );
77  }
78  }
79  }
80  inFile.close();
81  std::cout << "Logical map file: " << lines . getCount() << " lines read" << std::endl;
82  std::cout << "Logical map file: " << size() - _current_size << " lines added to the list" << std::endl;
83  //
84  return 0;
85 }
86 
87 
89  const_iterator = channel_list.begin();
90  return 0;
91 }
92 
93 
96  return 0;
97 }
98 
99 
101  if (const_iterator==channel_list.end()){
102  return true;
103  }
104  else{
105  return false;
106  }
107 }
108 
109 
111  if (const_iterator!=channel_list.end()){
112  return *const_iterator;
113  }
114  else{
115  return 0;
116  }
117 }
118 
119 
121  if (const_iterator!=channel_list.end()){
123  return _id.subdet();
124  }
125  else return HcalOther;
126 }
127 
128 
130  if (const_iterator!=channel_list.end()){
132  return _id.ieta();
133  }
134  else return -1000;
135 }
136 
137 
139  if (const_iterator!=channel_list.end()){
141  return _id.iphi();
142  }
143  else return -1000;
144 }
145 
146 
148  if (const_iterator!=channel_list.end()){
150  return _id.depth();
151  }
152  else return -1000;
153 }
154 
155 
158  addListFromLmapAscii("HCALmapHBEF_Jan.27.2009.txt");
159  addListFromLmapAscii("HCALmapHO_Jan.27.2009.txt");
160  return channel_list.size();
161 }
162 
163 
164 int HcalChannelIterator::init(const std::vector<HcalGenericDetId>& map){
165  channel_list.clear();
166  channel_list = map;
167  return channel_list.size();
168 }
169 
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:45
std::vector< HcalGenericDetId > channel_list
int depth() const
get the tower depth
Definition: HcalDetId.h:55
int addListFromLmapAscii(std::string filename)
int init(const std::vector< HcalGenericDetId > &map)
int ieta() const
get the cell ieta
Definition: HcalDetId.h:51
HcalSubdetector
Definition: HcalAssistant.h:31
int iphi() const
get the cell iphi
Definition: HcalDetId.h:53
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
HcalGenericDetId getHcalGenericDetId(void)
std::vector< HcalGenericDetId >::const_iterator const_iterator
HcalSubdetector getHcalSubdetector(void)