test
CMS 3D CMS Logo

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

#include <HBHELinearMap.h>

Classes

class  HBHEChannelId
 

Public Types

enum  { ChannelCount = 5184U }
 

Public Member Functions

void getChannelTriple (unsigned index, unsigned *depth, int *ieta, unsigned *iphi) const
 
 HBHELinearMap ()
 
bool isValidTriple (unsigned depth, int ieta, unsigned iphi) const
 
unsigned linearIndex (unsigned depth, int ieta, unsigned iphi) const
 

Static Public Member Functions

static HcalSubdetector getSubdetector (unsigned depth, int ieta)
 

Private Types

typedef std::vector< MapPairChannelMap
 
typedef std::pair
< HBHEChannelId, unsigned > 
MapPair
 

Private Member Functions

unsigned find (unsigned depth, int ieta, unsigned iphi) const
 

Private Attributes

ChannelMap inverse_
 
HBHEChannelId lookup_ [ChannelCount]
 

Detailed Description

Definition at line 16 of file HBHELinearMap.h.

Member Typedef Documentation

typedef std::vector<MapPair> HBHELinearMap::ChannelMap
private

Definition at line 80 of file HBHELinearMap.h.

typedef std::pair<HBHEChannelId,unsigned> HBHELinearMap::MapPair
private

Definition at line 79 of file HBHELinearMap.h.

Member Enumeration Documentation

anonymous enum
Enumerator
ChannelCount 

Definition at line 19 of file HBHELinearMap.h.

Constructor & Destructor Documentation

HBHELinearMap::HBHELinearMap ( )

Definition at line 51 of file HBHELinearMap.cc.

References assert(), ChannelCount, HLT_25ns10e33_v2_cff::depth, i, inverse_, cmsLHEtoEOSManager::l, and lookup_.

52 {
53  unsigned l = 0;
54  unsigned depth = 1;
55 
56  for (int ieta = -29; ieta <= -21; ++ieta)
57  for (unsigned iphi=1; iphi<72; iphi+=2)
58  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
59 
60  for (int ieta = -20; ieta <= 20; ++ieta)
61  if (ieta)
62  for (unsigned iphi=1; iphi<=72; ++iphi)
63  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
64 
65  for (int ieta = 21; ieta <= 29; ++ieta)
66  for (unsigned iphi=1; iphi<72; iphi+=2)
67  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
68 
69  depth = 2;
70 
71  for (int ieta = -29; ieta <= -21; ++ieta)
72  for (unsigned iphi=1; iphi<72; iphi+=2)
73  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
74 
75  for (int ieta = -20; ieta <= -18; ++ieta)
76  for (unsigned iphi=1; iphi<=72; ++iphi)
77  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
78 
79  for (int ieta = -16; ieta <= -15; ++ieta)
80  for (unsigned iphi=1; iphi<=72; ++iphi)
81  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
82 
83  for (int ieta = 15; ieta <= 16; ++ieta)
84  for (unsigned iphi=1; iphi<=72; ++iphi)
85  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
86 
87  for (int ieta = 18; ieta <= 20; ++ieta)
88  for (unsigned iphi=1; iphi<=72; ++iphi)
89  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
90 
91  for (int ieta = 21; ieta <= 29; ++ieta)
92  for (unsigned iphi=1; iphi<72; iphi+=2)
93  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
94 
95  depth = 3;
96 
97  for (int ieta = -28; ieta <= -27; ++ieta)
98  for (unsigned iphi=1; iphi<72; iphi+=2)
99  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
100 
101  for (int ieta = -16; ieta <= -16; ++ieta)
102  for (unsigned iphi=1; iphi<=72; ++iphi)
103  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
104 
105  for (int ieta = 16; ieta <= 16; ++ieta)
106  for (unsigned iphi=1; iphi<=72; ++iphi)
107  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
108 
109  for (int ieta = 27; ieta <= 28; ++ieta)
110  for (unsigned iphi=1; iphi<72; iphi+=2)
111  lookup_[l++] = HBHEChannelId(depth, ieta, iphi);
112 
113  assert(l == ChannelCount);
114 
115  inverse_.reserve(ChannelCount);
116  for (unsigned i=0; i<ChannelCount; ++i)
117  inverse_.push_back(MapPair(lookup_[i], i));
118  std::sort(inverse_.begin(), inverse_.end());
119 }
Definition: DDLMap.h:23
int i
Definition: DBlmapReader.cc:9
HBHEChannelId lookup_[ChannelCount]
Definition: HBHELinearMap.h:84
assert(m_qm.get())
ChannelMap inverse_
Definition: HBHELinearMap.h:85

Member Function Documentation

unsigned HBHELinearMap::find ( unsigned  depth,
int  ieta,
unsigned  iphi 
) const
private

Definition at line 22 of file HBHELinearMap.cc.

References ChannelCount, plotBeamSpotDB::first, and inverse_.

Referenced by BeautifulSoup.Tag::__getattr__(), BeautifulSoup.Tag::firstText(), isValidTriple(), and linearIndex().

24 {
25  const HBHEChannelId id(depth, ieta, iphi);
26  const unsigned loc = std::lower_bound(
27  inverse_.begin(), inverse_.end(), MapPair(id, 0U)) - inverse_.begin();
28  if (loc < ChannelCount)
29  if (inverse_[loc].first == id)
30  return inverse_[loc].second;
31  return ChannelCount;
32 }
ChannelMap inverse_
Definition: HBHELinearMap.h:85
std::pair< HBHEChannelId, unsigned > MapPair
Definition: HBHELinearMap.h:79
void HBHELinearMap::getChannelTriple ( unsigned  index,
unsigned *  depth,
int *  ieta,
unsigned *  iphi 
) const

Definition at line 7 of file HBHELinearMap.cc.

References ChannelCount, HBHELinearMap::HBHEChannelId::depth(), Exception, cmsHarvester::index, and lookup_.

9 {
10  if (index >= ChannelCount)
11  throw cms::Exception("In HBHELinearMap::getChannelTriple: "
12  "input index out of range");
13  const HBHEChannelId& id = lookup_[index];
14  if (depth)
15  *depth = id.depth();
16  if (ieta)
17  *ieta = id.ieta();
18  if (iphi)
19  *iphi = id.iphi();
20 }
HBHEChannelId lookup_[ChannelCount]
Definition: HBHELinearMap.h:84
HcalSubdetector HBHELinearMap::getSubdetector ( unsigned  depth,
int  ieta 
)
static

Definition at line 121 of file HBHELinearMap.cc.

References funct::abs(), Exception, HcalBarrel, and HcalEndcap.

123 {
124  const unsigned abseta = std::abs(ieta);
125 
126  // Make sure the arguments are in range
127  if (!(abseta <= 29U))
128  throw cms::Exception("In HBHELinearMap::getSubdetector: "
129  "eta argument out of range");
130  if (!(depth > 0U && depth < 4U))
131  throw cms::Exception("In HBHELinearMap::getSubdetector: "
132  "depth argument out of range");
133  if (abseta == 29U)
134  if (!(depth <= 2U))
135  throw cms::Exception("In HBHELinearMap::getSubdetector: "
136  "depth argument out of range "
137  "for |ieta| = 29");
138  if (abseta <= 15U)
139  return HcalBarrel;
140  else if (abseta == 16U)
141  return depth <= 2U ? HcalBarrel : HcalEndcap;
142  else
143  return HcalEndcap;
144 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool HBHELinearMap::isValidTriple ( unsigned  depth,
int  ieta,
unsigned  iphi 
) const

Definition at line 34 of file HBHELinearMap.cc.

References ChannelCount, and find().

36 {
37  const unsigned ind = find(depth, ieta, iphi);
38  return ind < ChannelCount;
39 }
unsigned find(unsigned depth, int ieta, unsigned iphi) const
unsigned HBHELinearMap::linearIndex ( unsigned  depth,
int  ieta,
unsigned  iphi 
) const

Definition at line 41 of file HBHELinearMap.cc.

References ChannelCount, Exception, and find().

Referenced by HcalInterpolatedPulseColl::getChannelPulse().

43 {
44  const unsigned ind = find(depth, ieta, iphi);
45  if (ind >= ChannelCount)
46  throw cms::Exception("In HBHELinearMap::linearIndex: "
47  "invalid channel triple");
48  return ind;
49 }
unsigned find(unsigned depth, int ieta, unsigned iphi) const

Member Data Documentation

ChannelMap HBHELinearMap::inverse_
private

Definition at line 85 of file HBHELinearMap.h.

Referenced by find(), and HBHELinearMap().

HBHEChannelId HBHELinearMap::lookup_[ChannelCount]
private

Definition at line 84 of file HBHELinearMap.h.

Referenced by getChannelTriple(), and HBHELinearMap().