CMS 3D CMS Logo

HGCScintillatorDetId.cc
Go to the documentation of this file.
3 #include <ostream>
4 #include <iostream>
5 
7 
9 }
10 
12 }
13 
15  int phi, bool trigger) : DetId(HGCalHSc,ForwardEmpty) {
16 
17  int zside = (radius < 0) ? 1 : 0;
18  int itrig = trigger ? 1 : 0;
19  int radiusAbs = std::abs(radius);
20  id_ |= (((type&kHGCalTypeMask)<<kHGCalTypeOffset) |
24  ((radiusAbs&kHGCalRadiusMask)<<kHGCalRadiusOffset) |
26 }
27 
29  if (!gen.null()) {
30  if (gen.det()!=HGCalHSc) {
31  throw cms::Exception("Invalid DetId") << "Cannot initialize HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
32  }
33  }
34  id_ = gen.rawId();
35 }
36 
38  if (!gen.null()) {
39  if (gen.det()!=HGCalHSc) {
40  throw cms::Exception("Invalid DetId") << "Cannot assign HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
41  }
42  }
43  id_ = gen.rawId();
44  return (*this);
45 }
46 
48  if (trigger()) return (2*((id_>>kHGCalRadiusOffset)&kHGCalRadiusMask));
49  else return ((id_>>kHGCalRadiusOffset)&kHGCalRadiusMask);
50 }
51 
53  if (trigger()) return ((iradiusAbs()+1)/2);
54  else return iradiusAbs();
55 }
56 
58  if (trigger()) return (2*((id_>>kHGCalPhiOffset)&kHGCalPhiMask));
59  else return ((id_>>kHGCalPhiOffset)&kHGCalPhiMask);
60 }
61 
63  if (trigger()) return ((iphi()+1)/2);
64  else return iphi();
65 }
66 
67 std::vector<HGCScintillatorDetId> HGCScintillatorDetId::detectorCells() const {
68 
69  std::vector<HGCScintillatorDetId> cells;
70  int irad = iradiusAbs();
71  int ifi = iphi();
72  int iz = zside();
73  if (trigger()) {
74  cells.emplace_back(HGCScintillatorDetId(type(), layer(), (2*irad-1)*iz,
75  2*ifi-1, false));
76  cells.emplace_back(HGCScintillatorDetId(type(), layer(), 2*irad*iz,
77  2*ifi-1, false));
78  cells.emplace_back(HGCScintillatorDetId(type(), layer(), (2*irad-1)*iz,
79  2*ifi, false));
80  cells.emplace_back(HGCScintillatorDetId(type(), layer(), 2*irad*iz,
81  2*ifi, false));
82  } else {
83  cells.emplace_back(HGCScintillatorDetId(type(), layer(), irad*iz, ifi,
84  false));
85 
86  }
87  return cells;
88 }
89 
91 
92  if (trigger()) {
94  iphiTrigger(), false);
95  } else {
96  return HGCScintillatorDetId (type(), layer(), iradius(), iphi(), false);
97  }
98 }
99 
101 
102  if (trigger())
103  return HGCScintillatorDetId (type(), layer(), iradius(), iphi(), true);
104  else
106  iphiTrigger(), true);
107 }
108 
109 std::ostream& operator<<(std::ostream& s,const HGCScintillatorDetId& id) {
110  return s << " HGCScintillatorDetId::EE:HE= " << id.isEE() << ":" << id.isHE()
111  << " trigger= " << id.trigger() << " type= " << id.type()
112  << " layer= " << id.layer() << " radius= " << id.iradius()
113  << ":" << id.iradiusTrigger() << " phi= " << id.iphi() << ":"
114  << id.iphiTrigger();
115 }
type
Definition: HCALResponse.h:21
static const int kHGCalTriggerOffset
constexpr bool null() const
is this a null id ?
Definition: DetId.h:52
int iradiusAbs() const
get the eta index
static const int kHGCalTypeOffset
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
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:18
static const int kHGCalRadiusMask
uint32_t id_
Definition: DetId.h:62
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:39