CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCScintillatorDetId.cc
Go to the documentation of this file.
3 #include <ostream>
4 #include <iostream>
5 
7 
9 
11 
12 HGCScintillatorDetId::HGCScintillatorDetId(int type, int layer, int ring, int phi, bool trigger, int sipm)
13  : DetId(HGCalHSc, ForwardEmpty) {
14  int zside = (ring < 0) ? 1 : 0;
15  int itrig = trigger ? 1 : 0;
16  int ringAbs = std::abs(ring);
17  id_ |= (((type & kHGCalTypeMask) << kHGCalTypeOffset) | ((zside & kHGCalZsideMask) << kHGCalZsideOffset) |
19  ((layer & kHGCalLayerMask) << kHGCalLayerOffset) | ((ringAbs & kHGCalRadiusMask) << kHGCalRadiusOffset) |
20  ((phi & kHGCalPhiMask) << kHGCalPhiOffset));
21 }
22 
24  if (!gen.null()) {
25  if (gen.det() != HGCalHSc) {
26  throw cms::Exception("Invalid DetId")
27  << "Cannot initialize HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
28  }
29  }
30  id_ = gen.rawId();
31 }
32 
34  if (!gen.null()) {
35  if (gen.det() != HGCalHSc) {
36  throw cms::Exception("Invalid DetId")
37  << "Cannot assign HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
38  }
39  }
40  id_ = gen.rawId();
41  return (*this);
42 }
43 
45  if (trigger())
46  return (2 * ((id_ >> kHGCalRadiusOffset) & kHGCalRadiusMask));
47  else
48  return ((id_ >> kHGCalRadiusOffset) & kHGCalRadiusMask);
49 }
50 
52  if (trigger())
53  return ((ring() + 1) / 2);
54  else
55  return ring();
56 }
57 
59  if (trigger())
60  return (2 * ((id_ >> kHGCalPhiOffset) & kHGCalPhiMask));
61  else
62  return ((id_ >> kHGCalPhiOffset) & kHGCalPhiMask);
63 }
64 
66  if (trigger())
67  return ((iphi() + 1) / 2);
68  else
69  return iphi();
70 }
71 
74  id_ |= ((type & kHGCalTypeMask) << kHGCalTypeOffset);
75 }
76 
79  id_ |= ((sipm & kHGCalSiPMMask) << kHGCalSiPMOffset);
80 }
81 
82 std::vector<HGCScintillatorDetId> HGCScintillatorDetId::detectorCells() const {
83  std::vector<HGCScintillatorDetId> cells;
84  int irad = ring();
85  int ifi = iphi();
86  int iz = zside();
87  if (trigger()) {
88  cells.emplace_back(HGCScintillatorDetId(type(), layer(), (2 * irad - 1) * iz, 2 * ifi - 1, false));
89  cells.emplace_back(HGCScintillatorDetId(type(), layer(), 2 * irad * iz, 2 * ifi - 1, false));
90  cells.emplace_back(HGCScintillatorDetId(type(), layer(), (2 * irad - 1) * iz, 2 * ifi, false));
91  cells.emplace_back(HGCScintillatorDetId(type(), layer(), 2 * irad * iz, 2 * ifi, false));
92  } else {
93  cells.emplace_back(HGCScintillatorDetId(type(), layer(), irad * iz, ifi, false));
94  }
95  return cells;
96 }
97 
99  if (trigger()) {
100  return HGCScintillatorDetId(type(), layer(), iradiusTrigger(), iphiTrigger(), false);
101  } else {
102  return HGCScintillatorDetId(type(), layer(), iradius(), iphi(), false);
103  }
104 }
105 
107  if (trigger())
108  return HGCScintillatorDetId(type(), layer(), iradius(), iphi(), true);
109  else
110  return HGCScintillatorDetId(type(), layer(), iradiusTrigger(), iphiTrigger(), true);
111 }
112 
113 std::ostream& operator<<(std::ostream& s, const HGCScintillatorDetId& id) {
114  return s << " HGCScintillatorDetId::EE:HE= " << id.isEE() << ":" << id.isHE() << " trigger= " << id.trigger()
115  << " type= " << id.type() << " SiPM= " << id.sipm() << " layer= " << id.layer() << " ring= " << id.iradius()
116  << ":" << id.iradiusTrigger() << " phi= " << id.iphi() << ":" << id.iphiTrigger();
117 }
static const int kHGCalTriggerOffset
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
static const int kHGCalTypeOffset
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
int type() const
get/set the type
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
constexpr std::array< uint8_t, layerIndexSize > layer
static const int kHGCalSiPMOffset
HGCScintillatorDetId & operator=(const DetId &id)
static const int kHGCalSiPMMask0
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
int ring() const
get the eta index
std::vector< HGCScintillatorDetId > detectorCells() const
trigger or detector cell
static const HGCScintillatorDetId Undefined
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
Definition: DetId.h:17
static const int kHGCalRadiusMask
uint32_t id_
Definition: DetId.h:69
static const int kHGCalTypeMask0
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 kHGCalSiPMMask
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