CMS 3D CMS Logo

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