File indexing completed on 2024-04-06 12:04:03
0001 #ifndef ECALDETID_ESDETID_H
0002 #define ECALDETID_ESDETID_H
0003
0004 #include <iosfwd>
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008
0009
0010
0011
0012
0013
0014
0015 class ESDetId : public DetId {
0016 public:
0017 enum { Subdet = EcalPreshower };
0018
0019 ESDetId() {}
0020
0021 ESDetId(uint32_t rawid) : DetId(rawid) {}
0022
0023
0024 ESDetId(int strip, int ixs, int iys, int plane, int iz, bool doverify = false) : DetId(Ecal, EcalPreshower) {
0025 id_ |= (strip & 0x3F) | ((ixs & 0x3F) << 6) | ((iys & 0x3F) << 12) | (((plane - 1) & 0x1) << 18) |
0026 ((iz > 0) ? (1 << 19) : (0));
0027 if (doverify)
0028 verify(strip, ixs, iys, plane, iz);
0029 }
0030
0031
0032 ESDetId(const DetId& id);
0033
0034 ESDetId& operator=(const DetId& id);
0035
0036
0037 EcalSubdetector subdet() const { return EcalSubdetector(subdetId()); }
0038
0039 int zside() const { return (id_ & 0x80000) ? (1) : (-1); }
0040
0041 int plane() const { return ((id_ >> 18) & 0x1) + 1; }
0042
0043 int six() const { return (id_ >> 6) & 0x3F; }
0044
0045 int siy() const { return (id_ >> 12) & 0x3F; }
0046
0047 int strip() const { return (id_ & 0x3F); }
0048
0049 int hashedIndex() const;
0050
0051 uint32_t denseIndex() const { return hashedIndex(); }
0052
0053 static bool validDenseIndex(uint32_t din) { return validHashIndex(din); }
0054
0055 static ESDetId detIdFromDenseIndex(uint32_t din) { return unhashIndex(din); }
0056
0057
0058 static ESDetId unhashIndex(int hi);
0059 static bool validHashIndex(int hi) { return (hi < kSizeForDenseIndexing); }
0060
0061 static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz);
0062 static void verify(int istrip, int ixs, int iys, int iplane, int iz);
0063
0064 static const int IX_MIN = 1;
0065 static const int IY_MIN = 1;
0066 static const int IX_MAX = 40;
0067 static const int IY_MAX = 40;
0068 static const int ISTRIP_MIN = 1;
0069 static const int ISTRIP_MAX = 32;
0070 static const int PLANE_MIN = 1;
0071 static const int PLANE_MAX = 2;
0072 static const int IZ_NUM = 2;
0073
0074 private:
0075 enum {
0076 kXYMAX = 1072,
0077 kXYMIN = 1,
0078 kXMAX = 40,
0079 kYMAX = 40,
0080 kXMIN = 1,
0081 kYMIN = 1,
0082
0083 kNa = IZ_NUM,
0084 kNb = PLANE_MAX - PLANE_MIN + 1,
0085 kNc = kXYMAX - kXYMIN + 1,
0086 kNd = ISTRIP_MAX - ISTRIP_MIN + 1,
0087 kLd = kNd,
0088 kLc = kLd * kNc,
0089 kLb = kLc * kNb,
0090 kLa = kLb * kNa
0091 };
0092
0093 static const unsigned short hxy1[kXMAX][kYMAX];
0094 static const unsigned short hx1[kXYMAX];
0095 static const unsigned short hy1[kXYMAX];
0096
0097 static const unsigned short hxy2[kXMAX][kYMAX];
0098 static const unsigned short hx2[kXYMAX];
0099 static const unsigned short hy2[kXYMAX];
0100
0101 public:
0102 static constexpr int kSizeForDenseIndexing = kLa;
0103 };
0104
0105 std::ostream& operator<<(std::ostream&, const ESDetId& id);
0106
0107 inline ESDetId::ESDetId(const DetId& gen) : DetId(gen) {
0108 #ifdef EDM_ML_DEBUG
0109 if (!gen.null() && (gen.det() != Ecal || gen.subdetId() != EcalPreshower)) {
0110 throw cms::Exception("InvalidDetId");
0111 }
0112 #endif
0113 }
0114
0115 inline ESDetId& ESDetId::operator=(const DetId& gen) {
0116 #ifdef EDM_ML_DEBUG
0117 if (!gen.null() && (gen.det() != Ecal || gen.subdetId() != EcalPreshower)) {
0118 throw cms::Exception("InvalidDetId");
0119 }
0120 #endif
0121 id_ = gen.rawId();
0122 return *this;
0123 }
0124
0125 #endif