CMS 3D CMS Logo

HGCScintillatorDetId.cc
Go to the documentation of this file.
3 #include <ostream>
4 #include <iostream>
5 
7 
9 
11 
14  int zside = (radius < 0) ? 1 : 0;
15  int itrig = trigger ? 1 : 0;
16  int radiusAbs = std::abs(radius);
17  id_ |= (((type & kHGCalTypeMask) << kHGCalTypeOffset) | ((zside & kHGCalZsideMask) << kHGCalZsideOffset) |
19  ((radiusAbs & kHGCalRadiusMask) << kHGCalRadiusOffset) | ((phi & kHGCalPhiMask) << kHGCalPhiOffset));
20 }
21 
23  if (!gen.null()) {
24  if (gen.det() != HGCalHSc) {
25  throw cms::Exception("Invalid DetId")
26  << "Cannot initialize HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
27  }
28  }
29  id_ = gen.rawId();
30 }
31 
33  if (!gen.null()) {
34  if (gen.det() != HGCalHSc) {
35  throw cms::Exception("Invalid DetId")
36  << "Cannot assign HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
37  }
38  }
39  id_ = gen.rawId();
40  return (*this);
41 }
42 
44  if (trigger())
45  return (2 * ((id_ >> kHGCalRadiusOffset) & kHGCalRadiusMask));
46  else
47  return ((id_ >> kHGCalRadiusOffset) & kHGCalRadiusMask);
48 }
49 
51  if (trigger())
52  return ((iradiusAbs() + 1) / 2);
53  else
54  return iradiusAbs();
55 }
56 
58  if (trigger())
59  return (2 * ((id_ >> kHGCalPhiOffset) & kHGCalPhiMask));
60  else
61  return ((id_ >> kHGCalPhiOffset) & kHGCalPhiMask);
62 }
63 
65  if (trigger())
66  return ((iphi() + 1) / 2);
67  else
68  return iphi();
69 }
70 
71 std::vector<HGCScintillatorDetId> HGCScintillatorDetId::detectorCells() const {
72  std::vector<HGCScintillatorDetId> cells;
73  int irad = iradiusAbs();
74  int ifi = iphi();
75  int iz = zside();
76  if (trigger()) {
77  cells.emplace_back(HGCScintillatorDetId(type(), layer(), (2 * irad - 1) * iz, 2 * ifi - 1, false));
78  cells.emplace_back(HGCScintillatorDetId(type(), layer(), 2 * irad * iz, 2 * ifi - 1, false));
79  cells.emplace_back(HGCScintillatorDetId(type(), layer(), (2 * irad - 1) * iz, 2 * ifi, false));
80  cells.emplace_back(HGCScintillatorDetId(type(), layer(), 2 * irad * iz, 2 * ifi, false));
81  } else {
82  cells.emplace_back(HGCScintillatorDetId(type(), layer(), irad * iz, ifi, false));
83  }
84  return cells;
85 }
86 
88  if (trigger()) {
89  return HGCScintillatorDetId(type(), layer(), iradiusTrigger(), iphiTrigger(), false);
90  } else {
91  return HGCScintillatorDetId(type(), layer(), iradius(), iphi(), false);
92  }
93 }
94 
96  if (trigger())
97  return HGCScintillatorDetId(type(), layer(), iradius(), iphi(), true);
98  else
99  return HGCScintillatorDetId(type(), layer(), iradiusTrigger(), iphiTrigger(), true);
100 }
101 
102 std::ostream& operator<<(std::ostream& s, const HGCScintillatorDetId& id) {
103  return s << " HGCScintillatorDetId::EE:HE= " << id.isEE() << ":" << id.isHE() << " trigger= " << id.trigger()
104  << " type= " << id.type() << " layer= " << id.layer() << " radius= " << id.iradius() << ":"
105  << id.iradiusTrigger() << " phi= " << id.iphi() << ":" << id.iphiTrigger();
106 }
type
Definition: HCALResponse.h:21
static const int kHGCalTriggerOffset
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
int iradiusAbs() const
get the eta index
static const int kHGCalTypeOffset
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
int type() const
get the type
HGCScintillatorDetId & operator=(const DetId &id)
std::ostream & operator<<(std::ostream &s, const HGCScintillatorDetId &id)
static const int kHGCalLayerMask
static const int kHGCalRadiusOffset
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int iphi() const
get the phi index
static const int kHGCalTriggerMask
HGCScintillatorDetId geometryCell() const
std::vector< HGCScintillatorDetId > detectorCells() const
trigger or detector cell
static const HGCScintillatorDetId Undefined
Definition: DetId.h:17
static const int kHGCalRadiusMask
uint32_t id_
Definition: DetId.h:69
static const int kHGCalPhiMask
int layer() const
get the layer #
int zside() const
get the z-side of the cell (1/-1)
static const int kHGCalZsideMask
static const int kHGCalZsideOffset
static const int kHGCalLayerOffset
static const int kHGCalTypeMask
static const int kHGCalPhiOffset
HGCScintillatorDetId triggerCell() const
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46