CMS 3D CMS Logo

ESDetId.h
Go to the documentation of this file.
1 #ifndef ECALDETID_ESDETID_H
2 #define ECALDETID_ESDETID_H
3 
4 #include <iosfwd>
8 
15 class ESDetId : public DetId {
16  public:
17 
18  enum { Subdet = EcalPreshower } ;
20  ESDetId(){}
22  ESDetId( uint32_t rawid ) : DetId( rawid ) {}
23 
24 
26  ESDetId(int strip, int ixs, int iys, int plane, int iz, bool doverify=false) :
28  id_ |= (strip&0x3F) |
29  ((ixs&0x3F)<<6) |
30  ((iys&0x3F)<<12) |
31  (((plane-1)&0x1)<<18) |
32  ((iz>0)?(1<<19):(0))
33  ;
34  if (doverify) verify(strip, ixs, iys, plane, iz);
35  }
36 
38  ESDetId(const DetId& id);
40  ESDetId& operator=(const DetId& id);
41 
45  int zside() const { return (id_&0x80000)?(1):(-1); }
47  int plane() const { return ((id_>>18)&0x1)+1; }
49  int six() const { return (id_>>6)&0x3F; }
51  int siy() const { return (id_>>12)&0x3F; }
53  int strip() const { return (id_&0x3F); }
55  int hashedIndex() const ;
56 
57  uint32_t denseIndex() const { return hashedIndex() ; }
58 
59  static bool validDenseIndex( uint32_t din ) { return validHashIndex( din ) ; }
60 
61  static ESDetId detIdFromDenseIndex( uint32_t din ) { return unhashIndex( din ) ; }
62 
64  static ESDetId unhashIndex( int hi ) ;
65  static bool validHashIndex( int hi ) { return ( hi < kSizeForDenseIndexing ) ; }
67  static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz) ;
68  static void verify(int istrip, int ixs, int iys, int iplane, int iz) ;
69 
70 
71  static const int IX_MIN=1;
72  static const int IY_MIN=1;
73  static const int IX_MAX=40;
74  static const int IY_MAX=40;
75  static const int ISTRIP_MIN=1;
76  static const int ISTRIP_MAX=32;
77  static const int PLANE_MIN=1;
78  static const int PLANE_MAX=2;
79  static const int IZ_NUM=2;
80 
81  private :
82 
83  enum { kXYMAX=1072,
84  kXYMIN= 1,
85  kXMAX = 40,
86  kYMAX = 40,
87  kXMIN = 1,
88  kYMIN = 1,
89  // now normalize to A-D notation for ease of use
91  kNb =PLANE_MAX - PLANE_MIN + 1,
92  kNc =kXYMAX - kXYMIN + 1,
93  kNd =ISTRIP_MAX - ISTRIP_MIN + 1,
94  kLd =kNd,
97  kLa =kLb*kNa } ;
98 
99  static const unsigned short hxy1[ kXMAX ][ kYMAX ] ;
100  static const unsigned short hx1[ kXYMAX ] ;
101  static const unsigned short hy1[ kXYMAX ] ;
102 
103  static const unsigned short hxy2[ kXMAX ][ kYMAX ] ;
104  static const unsigned short hx2[ kXYMAX ] ;
105  static const unsigned short hy2[ kXYMAX ] ;
106 
107  public:
108 
110 
111 };
112 
113 std::ostream& operator<<(std::ostream&,const ESDetId& id);
114 
115 inline
116 ESDetId::ESDetId( const DetId& gen ) : DetId(gen)
117 {
118 #ifdef EDM_ML_DEBUG
119  if( !gen.null() &&
120  ( gen.det() != Ecal ||
121  gen.subdetId() != EcalPreshower ) )
122  {
123  throw cms::Exception("InvalidDetId");
124  }
125 #endif
126 }
127 
128 inline
129 ESDetId&
131 {
132 #ifdef EDM_ML_DEBUG
133  if (!gen.null() &&
134  ( gen.det() != Ecal ||
135  gen.subdetId() != EcalPreshower ) )
136  {
137  throw cms::Exception("InvalidDetId");
138  }
139 #endif
140  id_=gen.rawId();
141  return *this;
142 }
143 
144 
145 #endif
static bool validDenseIndex(uint32_t din)
Definition: ESDetId.h:59
int strip() const
Definition: ESDetId.h:53
ESDetId(uint32_t rawid)
Definition: ESDetId.h:22
ESDetId(int strip, int ixs, int iys, int plane, int iz, bool doverify=false)
constructor from strip, ix, iy, plane, and iz
Definition: ESDetId.h:26
static const unsigned short hy2[kXYMAX]
Definition: ESDetId.h:105
static const unsigned short hxy2[kXMAX][kYMAX]
Definition: ESDetId.h:103
constexpr bool null() const
is this a null id ?
Definition: DetId.h:49
static const unsigned short hy1[kXYMAX]
Definition: ESDetId.h:101
static const int IY_MAX
Definition: ESDetId.h:74
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
int six() const
Definition: ESDetId.h:49
static const int ISTRIP_MAX
Definition: ESDetId.h:76
ESDetId & operator=(const DetId &id)
Definition: ESDetId.h:130
static const int PLANE_MIN
Definition: ESDetId.h:77
static void verify(int istrip, int ixs, int iys, int iplane, int iz)
Definition: ESDetId.cc:6
int siy() const
Definition: ESDetId.h:51
static const int PLANE_MAX
Definition: ESDetId.h:78
ESDetId()
Definition: ESDetId.h:20
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
std::ostream & operator<<(std::ostream &, const ESDetId &id)
Definition: ESDetId.cc:99
int zside() const
Definition: ESDetId.h:45
static ESDetId detIdFromDenseIndex(uint32_t din)
Definition: ESDetId.h:61
uint32_t denseIndex() const
Definition: ESDetId.h:57
static const unsigned short hxy1[kXMAX][kYMAX]
Definition: ESDetId.h:99
Definition: DetId.h:18
static const int IY_MIN
Definition: ESDetId.h:72
static const int IZ_NUM
Definition: ESDetId.h:79
static const unsigned short hx2[kXYMAX]
Definition: ESDetId.h:104
uint32_t id_
Definition: DetId.h:59
static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz)
check if a valid index combination
Definition: ESDetId.cc:22
static const int IX_MAX
Definition: ESDetId.h:73
int plane() const
Definition: ESDetId.h:47
static ESDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: ESDetId.cc:62
EcalSubdetector
EcalSubdetector subdet() const
get the subdetector
Definition: ESDetId.h:43
static const unsigned short hx1[kXYMAX]
Definition: ESDetId.h:100
static const int ISTRIP_MIN
Definition: ESDetId.h:75
static bool validHashIndex(int hi)
Definition: ESDetId.h:65
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
static const int IX_MIN
Definition: ESDetId.h:71
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]
Definition: ESDetId.cc:44