CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Attributes
HcalChannelIterator Class Reference

#include <CaloOnlineTools/HcalOnlineDb/interface/HcalChannelIterator.h>

Public Member Functions

int addListFromLmapAscii (std::string filename)
 
int begin (void)
 
int clearChannelList (void)
 
bool end (void)
 
int getDepth (void)
 
HcalGenericDetId getHcalGenericDetId (void)
 
HcalSubdetector getHcalSubdetector (void)
 
int getIeta (void)
 
int getIphi (void)
 
 HcalChannelIterator ()
 
int init (const std::vector< HcalGenericDetId > &map)
 
int initHBEFListFromLmapAscii (void)
 
int next (void)
 
int size (void)
 
virtual ~HcalChannelIterator ()
 

Private Attributes

std::vector< HcalGenericDetIdchannel_list
 
std::vector< HcalGenericDetId >::const_iterator const_iterator
 

Detailed Description

Description: Iterators over HCAL channels using various sources

Usage: <usage>

Definition at line 26 of file HcalChannelIterator.h.

Constructor & Destructor Documentation

◆ HcalChannelIterator()

HcalChannelIterator::HcalChannelIterator ( )

Definition at line 18 of file HcalChannelIterator.cc.

18 {}

◆ ~HcalChannelIterator()

HcalChannelIterator::~HcalChannelIterator ( )
virtual

Definition at line 20 of file HcalChannelIterator.cc.

20 {}

Member Function Documentation

◆ addListFromLmapAscii()

int HcalChannelIterator::addListFromLmapAscii ( std::string  filename)

Definition at line 29 of file HcalChannelIterator.cc.

29  {
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 }

References channel_list, gather_cfg::cout, corrVsCorr::filename, HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, recoMuon::in, groupFilesInBlocks::lines, size(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by initHBEFListFromLmapAscii().

◆ begin()

int HcalChannelIterator::begin ( void  )

Definition at line 78 of file HcalChannelIterator.cc.

78  {
79  const_iterator = channel_list.begin();
80  return 0;
81 }

References channel_list, and const_iterator.

◆ clearChannelList()

int HcalChannelIterator::clearChannelList ( void  )

Definition at line 24 of file HcalChannelIterator.cc.

24  {
25  channel_list.clear();
26  return 0;
27 }

References channel_list.

Referenced by initHBEFListFromLmapAscii().

◆ end()

bool HcalChannelIterator::end ( void  )

Definition at line 88 of file HcalChannelIterator.cc.

88  {
89  if (const_iterator == channel_list.end()) {
90  return true;
91  } else {
92  return false;
93  }
94 }

References channel_list, and const_iterator.

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

◆ getDepth()

int HcalChannelIterator::getDepth ( void  )

Definition at line 128 of file HcalChannelIterator.cc.

128  {
129  if (const_iterator != channel_list.end()) {
131  return _id.depth();
132  } else
133  return -1000;
134 }

References channel_list, const_iterator, and HcalDetId::depth().

◆ getHcalGenericDetId()

HcalGenericDetId HcalChannelIterator::getHcalGenericDetId ( void  )

Definition at line 96 of file HcalChannelIterator.cc.

96  {
97  if (const_iterator != channel_list.end()) {
98  return *const_iterator;
99  } else {
100  return 0;
101  }
102 }

References channel_list, and const_iterator.

◆ getHcalSubdetector()

HcalSubdetector HcalChannelIterator::getHcalSubdetector ( void  )

Definition at line 104 of file HcalChannelIterator.cc.

104  {
105  if (const_iterator != channel_list.end()) {
107  return _id.subdet();
108  } else
109  return HcalOther;
110 }

References channel_list, const_iterator, HcalOther, and HcalDetId::subdet().

◆ getIeta()

int HcalChannelIterator::getIeta ( void  )

Definition at line 112 of file HcalChannelIterator.cc.

112  {
113  if (const_iterator != channel_list.end()) {
115  return _id.ieta();
116  } else
117  return -1000;
118 }

References channel_list, const_iterator, and HcalDetId::ieta().

◆ getIphi()

int HcalChannelIterator::getIphi ( void  )

Definition at line 120 of file HcalChannelIterator.cc.

120  {
121  if (const_iterator != channel_list.end()) {
123  return _id.iphi();
124  } else
125  return -1000;
126 }

References channel_list, const_iterator, and HcalDetId::iphi().

◆ init()

int HcalChannelIterator::init ( const std::vector< HcalGenericDetId > &  map)

Definition at line 143 of file HcalChannelIterator.cc.

143  {
144  channel_list.clear();
145  channel_list = map;
146  return channel_list.size();
147 }

References channel_list, and genParticles_cff::map.

◆ initHBEFListFromLmapAscii()

int HcalChannelIterator::initHBEFListFromLmapAscii ( void  )

Definition at line 136 of file HcalChannelIterator.cc.

136  {
138  addListFromLmapAscii("HCALmapHBEF_Jan.27.2009.txt");
139  addListFromLmapAscii("HCALmapHO_Jan.27.2009.txt");
140  return channel_list.size();
141 }

References addListFromLmapAscii(), channel_list, and clearChannelList().

◆ next()

int HcalChannelIterator::next ( void  )

Definition at line 83 of file HcalChannelIterator.cc.

83  {
85  return 0;
86 }

References const_iterator.

◆ size()

int HcalChannelIterator::size ( void  )

Member Data Documentation

◆ channel_list

std::vector<HcalGenericDetId> HcalChannelIterator::channel_list
private

◆ const_iterator

std::vector<HcalGenericDetId>::const_iterator HcalChannelIterator::const_iterator
private
HcalOther
Definition: HcalAssistant.h:38
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalBarrel
Definition: HcalAssistant.h:33
HcalChannelIterator::channel_list
std::vector< HcalGenericDetId > channel_list
Definition: HcalChannelIterator.h:50
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::size
int size(void)
Definition: HcalChannelIterator.cc:22
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
groupFilesInBlocks.lines
lines
Definition: groupFilesInBlocks.py:95
recoMuon::in
Definition: RecoMuonEnumerators.h:6
HcalDetId
Definition: HcalDetId.h:12
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalForward
Definition: HcalAssistant.h:36
HcalEndcap
Definition: HcalAssistant.h:34
HcalChannelIterator::clearChannelList
int clearChannelList(void)
Definition: HcalChannelIterator.cc:24
genParticles_cff.map
map
Definition: genParticles_cff.py:11
HcalChannelIterator::const_iterator
std::vector< HcalGenericDetId >::const_iterator const_iterator
Definition: HcalChannelIterator.h:51