File indexing completed on 2024-04-06 12:02:12
0001 #ifndef CondFormats_HcalObjects_HBHELinearMap_h_
0002 #define CondFormats_HcalObjects_HBHELinearMap_h_
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <vector>
0012 #include <utility>
0013
0014 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0015
0016 class HBHELinearMap {
0017 public:
0018 enum { ChannelCount = 5184U };
0019
0020 HBHELinearMap();
0021
0022
0023
0024
0025
0026
0027 unsigned linearIndex(unsigned depth, int ieta, unsigned iphi) const;
0028
0029
0030 bool isValidTriple(unsigned depth, int ieta, unsigned iphi) const;
0031
0032
0033
0034
0035 void getChannelTriple(unsigned index, unsigned* depth, int* ieta, unsigned* iphi) const;
0036
0037
0038 static HcalSubdetector getSubdetector(unsigned depth, int ieta);
0039
0040 private:
0041 class HBHEChannelId {
0042 public:
0043 inline HBHEChannelId() : depth_(1000U), ieta_(1000), iphi_(1000U) {}
0044
0045 inline HBHEChannelId(const unsigned i_depth, const int i_ieta, const unsigned i_iphi)
0046 : depth_(i_depth), ieta_(i_ieta), iphi_(i_iphi) {}
0047
0048
0049 inline unsigned depth() const { return depth_; }
0050 inline int ieta() const { return ieta_; }
0051 inline unsigned iphi() const { return iphi_; }
0052
0053 inline bool operator<(const HBHEChannelId& r) const {
0054 if (depth_ < r.depth_)
0055 return true;
0056 if (r.depth_ < depth_)
0057 return false;
0058 if (ieta_ < r.ieta_)
0059 return true;
0060 if (r.ieta_ < ieta_)
0061 return false;
0062 return iphi_ < r.iphi_;
0063 }
0064
0065 inline bool operator==(const HBHEChannelId& r) const {
0066 return depth_ == r.depth_ && ieta_ == r.ieta_ && iphi_ == r.iphi_;
0067 }
0068
0069 inline bool operator!=(const HBHEChannelId& r) const { return !(*this == r); }
0070
0071 private:
0072 unsigned depth_;
0073 int ieta_;
0074 unsigned iphi_;
0075 };
0076
0077 typedef std::pair<HBHEChannelId, unsigned> MapPair;
0078 typedef std::vector<MapPair> ChannelMap;
0079
0080 unsigned find(unsigned depth, int ieta, unsigned iphi) const;
0081
0082 HBHEChannelId lookup_[ChannelCount];
0083 ChannelMap inverse_;
0084 };
0085
0086
0087 const HBHELinearMap& hbheChannelMap();
0088
0089 #endif