CMS 3D CMS Logo

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