CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCEEDetId.cc
Go to the documentation of this file.
3 #include <ostream>
4 #include <iostream>
5 
6 const HGCEEDetId HGCEEDetId::Undefined(ForwardEmpty, 0, 0, 0, 0, 0);
7 
9 
10 HGCEEDetId::HGCEEDetId(uint32_t rawid) : DetId(rawid) {}
11 
12 HGCEEDetId::HGCEEDetId(ForwardSubdetector subdet, int zp, int lay, int sec, int subsec, int cell)
13  : DetId(Forward, subdet) {
14  id_ |= ((cell & kHGCEECellMask) << kHGCEECellOffset);
15  id_ |= ((sec & kHGCEESectorMask) << kHGCEESectorOffset);
16  if (subsec < 0)
17  subsec = 0;
19  id_ |= ((lay & kHGCEELayerMask) << kHGCEELayerOffset);
20  if (zp > 0)
21  id_ |= ((zp & kHGCEEZsideMask) << kHGCEEZsideOffset);
22 }
23 
25  if (!gen.null()) {
27  if (gen.det() != Forward || (subdet != HGCEE)) {
28  throw cms::Exception("Invalid DetId")
29  << "Cannot initialize HGCEEDetId from " << std::hex << gen.rawId() << std::dec;
30  }
31  }
32  id_ = gen.rawId();
33 }
34 
36  if (!gen.null()) {
38  if (gen.det() != Forward || (subdet != HGCEE)) {
39  throw cms::Exception("Invalid DetId") << "Cannot assign HGCEEDetId from " << std::hex << gen.rawId() << std::dec;
40  }
41  }
42  id_ = gen.rawId();
43  return (*this);
44 }
45 
46 std::ostream& operator<<(std::ostream& s, const HGCEEDetId& id) {
47  switch (id.subdet()) {
48  case (HGCEE):
49  return s << "isEE=" << id.isEE() << " zpos=" << id.zside() << " layer=" << id.layer()
50  << " phi subSector=" << id.subsector() << " sector=" << id.sector() << " cell=" << id.cell();
51  default:
52  return s << id.rawId();
53  }
54 }
static const int kHGCEELayerMask
Definition: HGCEEDetId.h:17
static const int kHGCEECellMask
Definition: HGCEEDetId.h:11
ForwardSubdetector subdet() const
get the subdetector
Definition: HGCEEDetId.h:36
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static const int kHGCEELayerOffset
Definition: HGCEEDetId.h:16
static const int kHGCEEZsideMask
Definition: HGCEEDetId.h:19
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
ForwardSubdetector
static const int kHGCEESectorMask
Definition: HGCEEDetId.h:13
static const HGCEEDetId Undefined
Definition: HGCEEDetId.h:57
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 kHGCEEZsideOffset
Definition: HGCEEDetId.h:18
Definition: DetId.h:17
uint32_t id_
Definition: DetId.h:69
static const int kHGCEESubSectorOffset
Definition: HGCEEDetId.h:14
static const int kHGCEESubSectorMask
Definition: HGCEEDetId.h:15
static const int kHGCEESectorOffset
Definition: HGCEEDetId.h:12
static const int kHGCEECellOffset
Definition: HGCEEDetId.h:10
HGCEEDetId & operator=(const DetId &id)
Definition: HGCEEDetId.cc:35
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46