CMS 3D CMS Logo

HBHELinearMap.h
Go to the documentation of this file.
1 #ifndef CondFormats_HcalObjects_HBHELinearMap_h_
2 #define CondFormats_HcalObjects_HBHELinearMap_h_
3 
4 //
5 // Linearize the channel id in the HBHE
6 //
7 // I. Volobouev
8 // September 2014
9 //
10 
11 #include <vector>
12 #include <utility>
13 
15 
17 public:
18  enum { ChannelCount = 5184U };
19 
20  HBHELinearMap();
21 
22  // Mapping from the depth/ieta/iphi triple which uniquely
23  // identifies an HBHE channel into a linear index, currently
24  // from 0 to 5183 (inclusive). This linear index should not
25  // be treated as anything meaningful -- consider it to be
26  // just a convenient unique key in a database table.
27  unsigned linearIndex(unsigned depth, int ieta, unsigned iphi) const;
28 
29  // Check whether the given triple is a valid depth/ieta/iphi combination
30  bool isValidTriple(unsigned depth, int ieta, unsigned iphi) const;
31 
32  // Inverse mapping, from a linear index into depth/ieta/iphi triple.
33  // Any of the argument pointers is allowed to be NULL in which case
34  // the corresponding variable is simply not filled out.
35  void getChannelTriple(unsigned index, unsigned* depth, int* ieta, unsigned* iphi) const;
36 
37  // The following assumes a valid HBHE depth/ieta combination
38  static HcalSubdetector getSubdetector(unsigned depth, int ieta);
39 
40 private:
41  class HBHEChannelId {
42  public:
43  inline HBHEChannelId() : depth_(1000U), ieta_(1000), iphi_(1000U) {}
44 
45  inline HBHEChannelId(const unsigned i_depth, const int i_ieta, const unsigned i_iphi)
46  : depth_(i_depth), ieta_(i_ieta), iphi_(i_iphi) {}
47 
48  // Inspectors
49  inline unsigned depth() const { return depth_; }
50  inline int ieta() const { return ieta_; }
51  inline unsigned iphi() const { return iphi_; }
52 
53  inline bool operator<(const HBHEChannelId& r) const {
54  if (depth_ < r.depth_)
55  return true;
56  if (r.depth_ < depth_)
57  return false;
58  if (ieta_ < r.ieta_)
59  return true;
60  if (r.ieta_ < ieta_)
61  return false;
62  return iphi_ < r.iphi_;
63  }
64 
65  inline bool operator==(const HBHEChannelId& r) const {
66  return depth_ == r.depth_ && ieta_ == r.ieta_ && iphi_ == r.iphi_;
67  }
68 
69  inline bool operator!=(const HBHEChannelId& r) const { return !(*this == r); }
70 
71  private:
72  unsigned depth_;
73  int ieta_;
74  unsigned iphi_;
75  };
76 
77  typedef std::pair<HBHEChannelId, unsigned> MapPair;
78  typedef std::vector<MapPair> ChannelMap;
79 
80  unsigned find(unsigned depth, int ieta, unsigned iphi) const;
81 
84 };
85 
86 // Standard map
88 
89 #endif // CondFormats_HcalObjects_HBHELinearMap_h_
bool operator!=(const HBHEChannelId &r) const
Definition: HBHELinearMap.h:69
HBHEChannelId lookup_[ChannelCount]
Definition: HBHELinearMap.h:82
static HcalSubdetector getSubdetector(unsigned depth, int ieta)
ChannelMap inverse_
Definition: HBHELinearMap.h:83
bool isValidTriple(unsigned depth, int ieta, unsigned iphi) const
bool operator<(const HBHEChannelId &r) const
Definition: HBHELinearMap.h:53
void getChannelTriple(unsigned index, unsigned *depth, int *ieta, unsigned *iphi) const
Definition: HBHELinearMap.cc:7
unsigned linearIndex(unsigned depth, int ieta, unsigned iphi) const
HcalSubdetector
Definition: HcalAssistant.h:31
std::vector< MapPair > ChannelMap
Definition: HBHELinearMap.h:78
unsigned find(unsigned depth, int ieta, unsigned iphi) const
bool operator==(const HBHEChannelId &r) const
Definition: HBHELinearMap.h:65
HBHEChannelId(const unsigned i_depth, const int i_ieta, const unsigned i_iphi)
Definition: HBHELinearMap.h:45
const HBHELinearMap & hbheChannelMap()
std::pair< HBHEChannelId, unsigned > MapPair
Definition: HBHELinearMap.h:77