CMS 3D CMS Logo

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 }
HcalOther
Definition: HcalAssistant.h:38
HcalChannelIterator::getDepth
int getDepth(void)
Definition: HcalChannelIterator.cc:128
HcalGenericDetId
Definition: HcalGenericDetId.h:15
HcalDetId::iphi
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
HcalChannelIterator.h
HcalChannelIterator::getIphi
int getIphi(void)
Definition: HcalChannelIterator.cc:120
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalDetId::depth
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164
HcalBarrel
Definition: HcalAssistant.h:33
HcalChannelIterator::getHcalGenericDetId
HcalGenericDetId getHcalGenericDetId(void)
Definition: HcalChannelIterator.cc:96
HcalChannelIterator::channel_list
std::vector< HcalGenericDetId > channel_list
Definition: HcalChannelIterator.h:50
RooGKCounter.h
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
RooGKCounter
Definition: RooGKCounter.h:10
HcalOuter
Definition: HcalAssistant.h:35
HcalChannelIterator::addListFromLmapAscii
int addListFromLmapAscii(std::string filename)
Definition: HcalChannelIterator.cc:29
HcalChannelIterator::getIeta
int getIeta(void)
Definition: HcalChannelIterator.cc:112
HcalChannelIterator::size
int size(void)
Definition: HcalChannelIterator.cc:22
HcalDetId::ieta
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
groupFilesInBlocks.lines
lines
Definition: groupFilesInBlocks.py:95
HcalChannelIterator::HcalChannelIterator
HcalChannelIterator()
Definition: HcalChannelIterator.cc:18
HcalChannelIterator::initHBEFListFromLmapAscii
int initHBEFListFromLmapAscii(void)
Definition: HcalChannelIterator.cc:136
HcalDetId.h
recoMuon::in
Definition: RecoMuonEnumerators.h:6
HcalDetId::subdet
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
HcalDetId
Definition: HcalDetId.h:12
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalForward
Definition: HcalAssistant.h:36
HcalChannelIterator::next
int next(void)
Definition: HcalChannelIterator.cc:83
HcalEndcap
Definition: HcalAssistant.h:34
HcalChannelIterator::end
bool end(void)
Definition: HcalChannelIterator.cc:88
HcalChannelIterator::clearChannelList
int clearChannelList(void)
Definition: HcalChannelIterator.cc:24
HcalChannelIterator::init
int init(const std::vector< HcalGenericDetId > &map)
Definition: HcalChannelIterator.cc:143
genParticles_cff.map
map
Definition: genParticles_cff.py:11
HcalChannelIterator::getHcalSubdetector
HcalSubdetector getHcalSubdetector(void)
Definition: HcalChannelIterator.cc:104
HcalChannelIterator::begin
int begin(void)
Definition: HcalChannelIterator.cc:78
HcalChannelIterator::~HcalChannelIterator
virtual ~HcalChannelIterator()
Definition: HcalChannelIterator.cc:20
HcalChannelIterator::const_iterator
std::vector< HcalGenericDetId >::const_iterator const_iterator
Definition: HcalChannelIterator.h:51