CMS 3D CMS Logo

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.

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

Referenced by initHBEFListFromLmapAscii().

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 }
std::vector< HcalGenericDetId > channel_list
HcalSubdetector
Definition: HcalAssistant.h:31

◆ begin()

int HcalChannelIterator::begin ( void  )

Definition at line 78 of file HcalChannelIterator.cc.

References channel_list, and const_iterator.

78  {
79  const_iterator = channel_list.begin();
80  return 0;
81 }
std::vector< HcalGenericDetId > channel_list
std::vector< HcalGenericDetId >::const_iterator const_iterator

◆ clearChannelList()

int HcalChannelIterator::clearChannelList ( void  )

Definition at line 24 of file HcalChannelIterator.cc.

References channel_list.

Referenced by initHBEFListFromLmapAscii().

24  {
25  channel_list.clear();
26  return 0;
27 }
std::vector< HcalGenericDetId > channel_list

◆ end()

bool HcalChannelIterator::end ( void  )

Definition at line 88 of file HcalChannelIterator.cc.

References channel_list, and const_iterator.

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

88  {
89  if (const_iterator == channel_list.end()) {
90  return true;
91  } else {
92  return false;
93  }
94 }
std::vector< HcalGenericDetId > channel_list
std::vector< HcalGenericDetId >::const_iterator const_iterator

◆ getDepth()

int HcalChannelIterator::getDepth ( void  )

Definition at line 128 of file HcalChannelIterator.cc.

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

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

◆ getHcalGenericDetId()

HcalGenericDetId HcalChannelIterator::getHcalGenericDetId ( void  )

Definition at line 96 of file HcalChannelIterator.cc.

References channel_list, and const_iterator.

96  {
97  if (const_iterator != channel_list.end()) {
98  return *const_iterator;
99  } else {
100  return 0;
101  }
102 }
std::vector< HcalGenericDetId > channel_list
std::vector< HcalGenericDetId >::const_iterator const_iterator

◆ getHcalSubdetector()

HcalSubdetector HcalChannelIterator::getHcalSubdetector ( void  )

Definition at line 104 of file HcalChannelIterator.cc.

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

104  {
105  if (const_iterator != channel_list.end()) {
107  return _id.subdet();
108  } else
109  return HcalOther;
110 }
std::vector< HcalGenericDetId > channel_list
std::vector< HcalGenericDetId >::const_iterator const_iterator

◆ getIeta()

int HcalChannelIterator::getIeta ( void  )

Definition at line 112 of file HcalChannelIterator.cc.

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

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

◆ getIphi()

int HcalChannelIterator::getIphi ( void  )

Definition at line 120 of file HcalChannelIterator.cc.

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

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

◆ init()

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

Definition at line 143 of file HcalChannelIterator.cc.

References channel_list, and genParticles_cff::map.

143  {
144  channel_list.clear();
145  channel_list = map;
146  return channel_list.size();
147 }
std::vector< HcalGenericDetId > channel_list

◆ initHBEFListFromLmapAscii()

int HcalChannelIterator::initHBEFListFromLmapAscii ( void  )

Definition at line 136 of file HcalChannelIterator.cc.

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

136  {
138  addListFromLmapAscii("HCALmapHBEF_Jan.27.2009.txt");
139  addListFromLmapAscii("HCALmapHO_Jan.27.2009.txt");
140  return channel_list.size();
141 }
std::vector< HcalGenericDetId > channel_list
int addListFromLmapAscii(std::string filename)

◆ next()

int HcalChannelIterator::next ( void  )

Definition at line 83 of file HcalChannelIterator.cc.

References const_iterator.

83  {
85  return 0;
86 }
std::vector< HcalGenericDetId >::const_iterator const_iterator

◆ size()

int HcalChannelIterator::size ( void  )

Definition at line 22 of file HcalChannelIterator.cc.

References channel_list.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and addListFromLmapAscii().

22 { return channel_list.size(); }
std::vector< HcalGenericDetId > channel_list

Member Data Documentation

◆ channel_list

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

◆ const_iterator

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