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 // $Id: HcalChannelIterator.cc,v 1.5 2010/08/06 20:24:11 wmtan Exp $
12 //
13 
14 #include <fstream>
18 
20 {
21 }
22 
23 
25 {
26 }
27 
28 
29 
31  return channel_list.size();
32 }
33 
34 
36  channel_list.clear();
37  return 0;
38 }
39 
40 
43  int _current_size = size();
44  std::string _row;
45  std::ifstream inFile( filename . c_str(), std::ios::in );
46  if (!inFile){
47  std::cout << "Unable to open file with the logical map: " << filename << std::endl;
48  }
49  else{
50  std::cout << "File with the logical map opened successfully: " << filename << std::endl;
51  }
52  while ( getline( inFile, _row ) > 0 ){
53  //# side eta phi dphi depth det
54  int _num, _side, _eta, _phi, _dphi, _depth;
55  char subdetbuf[32];
56 
57  int _read;
58  const char * _format = "%d %d %d %d %d %d %s";
59  _read = sscanf( _row . c_str(), _format,
60  &_num, &_side, &_eta, &_phi, &_dphi, &_depth,
61  subdetbuf );
62  if ( _read == 7 ){
63  lines . count();
64 
65  std::string subdet(subdetbuf);
66 
67  HcalSubdetector _det;
68  if ( subdet.find("HB")!=std::string::npos ) _det = HcalBarrel;
69  else if ( subdet.find("HE")!=std::string::npos ) _det = HcalEndcap;
70  else if ( subdet.find("HO")!=std::string::npos ) _det = HcalOuter;
71  else if ( subdet.find("HF")!=std::string::npos ) _det = HcalForward;
72  else _det = HcalOther;
73 
74  HcalDetId _detid(_det, _side*_eta, _phi, _depth);
75 
76  if (_det == HcalBarrel || _det == HcalEndcap || _det == HcalOuter || _det == HcalForward){
77  channel_list . push_back( _detid );
78  }
79  }
80  }
81  inFile.close();
82  std::cout << "Logical map file: " << lines . getCount() << " lines read" << std::endl;
83  std::cout << "Logical map file: " << size() - _current_size << " lines added to the list" << std::endl;
84  //
85  return 0;
86 }
87 
88 
90  const_iterator = channel_list.begin();
91  return 0;
92 }
93 
94 
97  return 0;
98 }
99 
100 
102  if (const_iterator==channel_list.end()){
103  return true;
104  }
105  else{
106  return false;
107  }
108 }
109 
110 
112  if (const_iterator!=channel_list.end()){
113  return *const_iterator;
114  }
115  else{
116  return 0;
117  }
118 }
119 
120 
122  if (const_iterator!=channel_list.end()){
124  return _id.subdet();
125  }
126  else return HcalOther;
127 }
128 
129 
131  if (const_iterator!=channel_list.end()){
133  return _id.ieta();
134  }
135  else return -1000;
136 }
137 
138 
140  if (const_iterator!=channel_list.end()){
142  return _id.iphi();
143  }
144  else return -1000;
145 }
146 
147 
149  if (const_iterator!=channel_list.end()){
151  return _id.depth();
152  }
153  else return -1000;
154 }
155 
156 
159  addListFromLmapAscii("HCALmapHBEF_Jan.27.2009.txt");
160  addListFromLmapAscii("HCALmapHO_Jan.27.2009.txt");
161  return channel_list.size();
162 }
163 
164 
165 int HcalChannelIterator::init(std::vector<HcalGenericDetId> map){
166  channel_list.clear();
167  channel_list = map;
168  return channel_list.size();
169 }
170 
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:32
std::vector< HcalGenericDetId > channel_list
#define _depth
Definition: Pythia6jets.h:5
int depth() const
get the tower depth
Definition: HcalDetId.h:42
int addListFromLmapAscii(std::string filename)
int ieta() const
get the cell ieta
Definition: HcalDetId.h:38
HcalSubdetector
Definition: HcalAssistant.h:32
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
int init(std::vector< HcalGenericDetId > map)
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)