CMS 3D CMS Logo

HGCHEDetId.cc
Go to the documentation of this file.
3 #include <ostream>
4 
5 const HGCHEDetId HGCHEDetId::Undefined(ForwardEmpty, 0, 0, 0, 0, 0);
6 
8 
9 HGCHEDetId::HGCHEDetId(uint32_t rawid) : DetId(rawid) {}
10 
11 HGCHEDetId::HGCHEDetId(ForwardSubdetector subdet, int zp, int lay, int sec, int subsec, int cell)
12  : DetId(Forward, subdet) {
13  id_ |= ((cell & kHGCHECellMask) << kHGCHECellOffset);
14  id_ |= ((sec & kHGCHESectorMask) << kHGCHESectorOffset);
15  if (subsec < 0)
16  subsec = 0;
18  id_ |= ((lay & kHGCHELayerMask) << kHGCHELayerOffset);
19  if (zp > 0)
20  id_ |= ((zp & kHGCHEZsideMask) << kHGCHEZsideOffset);
21 }
22 
24  if (!gen.null()) {
26  if ((gen.det() != Forward) || (subdet != HGCHEF && subdet != HGCHEB)) {
27  throw cms::Exception("Invalid DetId") << "Cannot initialize HGCHEDetId from " << std::hex << gen.rawId()
28  << std::dec << " Det|SubDet " << gen.det() << "|" << subdet;
29  }
30  }
31  id_ = gen.rawId();
32 }
33 
35  if (!gen.null()) {
37  if ((gen.det() != Forward) || (subdet != HGCHEF && subdet != HGCHEB)) {
38  throw cms::Exception("Invalid DetId") << "Cannot assign HGCHEDetId from " << std::hex << gen.rawId() << std::dec
39  << " Det|SubDet " << gen.det() << "|" << subdet;
40  }
41  }
42  id_ = gen.rawId();
43  return (*this);
44 }
45 
47  int sub = ((subdet() == HGCHEF) ? 0 : ((id_ >> kHGCHESubSectorOffset) & kHGCHESubSectorMask));
48  return HGCHEDetId(subdet(), zside(), layer(), sector(), sub, 0);
49 }
50 
51 std::ostream& operator<<(std::ostream& s, const HGCHEDetId& id) {
52  if (id.subdet() == HGCHEF || id.subdet() == HGCHEB) {
53  return s << "isHE=" << id.isHE() << " zpos=" << id.zside() << " layer=" << id.layer()
54  << " phi subSector=" << id.subsector() << " sector=" << id.sector() << " cell=" << id.cell();
55  } else {
56  return s << std::hex << id.rawId() << std::dec;
57  }
58 }
static const int kHGCHESubSectorOffset
Definition: HGCHEDetId.h:14
static const int kHGCHELayerOffset
Definition: HGCHEDetId.h:16
std::ostream & operator<<(std::ostream &s, const HGCHEDetId &id)
Definition: HGCHEDetId.cc:51
static const int kHGCHESubSectorMask
Definition: HGCHEDetId.h:15
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
int cell() const
get the absolute value of the cell #&#39;s in x and y
Definition: HGCHEDetId.h:40
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static const int kHGCHESectorOffset
Definition: HGCHEDetId.h:12
int layer() const
get the layer #
Definition: HGCHEDetId.h:49
static const int kHGCHECellOffset
Definition: HGCHEDetId.h:10
ForwardSubdetector
HGCHEDetId geometryCell() const
Definition: HGCHEDetId.cc:46
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static const int kHGCHELayerMask
Definition: HGCHEDetId.h:17
static const int kHGCHEZsideOffset
Definition: HGCHEDetId.h:18
static const int kHGCHEZsideMask
Definition: HGCHEDetId.h:19
Definition: DetId.h:17
int zside() const
get the z-side of the cell (1/-1)
Definition: HGCHEDetId.h:52
uint32_t id_
Definition: DetId.h:69
static const int kHGCHECellMask
Definition: HGCHEDetId.h:11
static const int kHGCHESectorMask
Definition: HGCHEDetId.h:13
int sector() const
get the sector #
Definition: HGCHEDetId.h:43
ForwardSubdetector subdet() const
get the subdetector
Definition: HGCHEDetId.h:37
static const HGCHEDetId Undefined
Definition: HGCHEDetId.h:58
HGCHEDetId & operator=(const DetId &id)
Definition: HGCHEDetId.cc:34
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46