CMS 3D CMS Logo

HGCalTriggerDetId.cc
Go to the documentation of this file.
3 #include <ostream>
4 #include <iostream>
5 
7 
9 
10 HGCalTriggerDetId::HGCalTriggerDetId(uint32_t rawid) : DetId(rawid) {}
11 
13  int subdet, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV)
14  : DetId(HGCalTrigger, ForwardEmpty) {
15  int waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV));
16  int waferUsign = (waferU >= 0) ? 0 : 1;
17  int waferVsign = (waferV >= 0) ? 0 : 1;
18  int zside = (zp < 0) ? 1 : 0;
20  ((waferUabs & kHGCalWaferUMask) << kHGCalWaferUOffset) |
21  ((waferUsign & kHGCalWaferUSignMask) << kHGCalWaferUSignOffset) |
22  ((waferVabs & kHGCalWaferVMask) << kHGCalWaferVOffset) |
23  ((waferVsign & kHGCalWaferVSignMask) << kHGCalWaferVSignOffset) |
26 }
27 
29  if (!gen.null()) {
30  if (gen.det() != HGCalTrigger) {
31  throw cms::Exception("Invalid DetId")
32  << "Cannot initialize HGCalTriggerDetId from " << std::hex << gen.rawId() << std::dec;
33  }
34  }
35  id_ = gen.rawId();
36 }
37 
39  if (!gen.null()) {
40  if (gen.det() != HGCalTrigger) {
41  throw cms::Exception("Invalid DetId")
42  << "Cannot assign HGCalTriggerDetId from " << std::hex << gen.rawId() << std::dec;
43  }
44  }
45  id_ = gen.rawId();
46  return (*this);
47 }
48 
50  int nT =
52  int N = nT * HGCalTriggerCell;
53  std::vector<int> vc = cellV();
54  int x(0);
55  for (auto const& v : vc) {
56  x += (3 * (v - N) + 2);
57  }
58  return (x / static_cast<int>(vc.size()));
59 }
60 
62  int nT =
64  int N = nT * HGCalTriggerCell;
65  std::vector<int> uc = cellU();
66  std::vector<int> vc = cellV();
67  int y(0);
68  for (unsigned int k = 0; k < uc.size(); ++k) {
69  y += (2 * uc[k] - (N + vc[k]));
70  }
71  return (y / static_cast<int>(vc.size()));
72 }
73 
74 std::vector<int> HGCalTriggerDetId::cellU() const {
75  std::vector<int> uc;
76  int nT =
79  int u0 = nT * triggerCellU();
80  for (int i = 0; i < nT; ++i) {
81  for (int j = 0; j < nT; ++j) {
82  uc.emplace_back(u0 + i);
83  }
84  }
85  } else if ((triggerCellU() < HGCalTriggerCell) && (triggerCellU() <= triggerCellV())) {
86  int u0 = nT * triggerCellU();
87  for (int i = 0; i < nT; ++i) {
88  for (int j = 0; j < nT; ++j) {
89  uc.emplace_back(u0 + i);
90  }
91  }
92  } else {
93  int u0 = nT * (triggerCellU() - 1) + 1;
94  for (int i = 0; i < nT; ++i) {
95  for (int j = 0; j < nT; ++j) {
96  uc.emplace_back(u0 + j);
97  }
98  ++u0;
99  }
100  }
101  return uc;
102 }
103 
104 std::vector<int> HGCalTriggerDetId::cellV() const {
105  std::vector<int> vc;
106  int nT =
109  int v0 = nT * triggerCellV();
110  for (int i = 0; i < nT; ++i) {
111  for (int j = 0; j < nT; ++j) {
112  vc.emplace_back(v0 + j);
113  }
114  }
115  } else if ((triggerCellU() < HGCalTriggerCell) && (triggerCellU() <= triggerCellV())) {
116  int v0 = nT * triggerCellV();
117  for (int i = 0; i < nT; ++i) {
118  for (int j = 0; j < nT; ++j) {
119  vc.emplace_back(v0 + j);
120  }
121  ++v0;
122  }
123  } else {
124  int v0 = nT * triggerCellV();
125  for (int i = 0; i < nT; ++i) {
126  for (int j = 0; j < nT; ++j) {
127  vc.emplace_back(v0 + i);
128  }
129  }
130  }
131  return vc;
132 }
133 
134 std::vector<std::pair<int, int> > HGCalTriggerDetId::cellUV() const {
135  std::vector<int> uc = cellU();
136  std::vector<int> vc = cellV();
137  std::vector<std::pair<int, int> > uv;
138  for (unsigned int k = 0; k < uc.size(); ++k) {
139  uv.emplace_back(std::pair<int, int>(uc[k], vc[k]));
140  }
141  return uv;
142 }
143 
144 std::ostream& operator<<(std::ostream& s, const HGCalTriggerDetId& id) {
145  return s << " EE:HSil= " << id.isEE() << ":" << id.isHSilicon() << " type= " << id.type() << " z= " << id.zside()
146  << " layer= " << id.layer() << " wafer(u,v:x,y)= (" << id.waferU() << "," << id.waferV() << ":"
147  << id.waferX() << "," << id.waferY() << ")"
148  << " triggerCell(u,v:x,y)= (" << id.triggerCellU() << "," << id.triggerCellV() << ":" << id.triggerCellX()
149  << "," << id.triggerCellY() << ")";
150 }
static const int kHGCalSubdetMask
std::vector< int > cellV() const
std::vector< int > cellU() const
int32_t waferU(const int32_t index)
static const int kHGCalWaferVSignMask
int zside() const
get the z-side of the cell (1/-1)
int triggerCellU() const
get the cell #&#39;s in u,v or in x,y
static const int kHGCalTypeOffset
static const int kHGCalLayerOffset
int layer() const
get the layer #
static const int kHGCalCellVOffset
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
static const int kHGCalZsideMask
static const int kHGCalWaferUSignMask
static const int HGCalTriggerCell
std::vector< std::pair< int, int > > cellUV() const
static const int kHGCalWaferUOffset
static const int kHGCalZsideOffset
int triggerCellX() const
static const int HGCalCoarseTrigger
static const int kHGCalWaferVMask
HGCalTriggerSubdetector subdet() const
get the subdetector
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int kHGCalTypeMask
int triggerCellY() const
static const int kHGCalSubdetOffset
static const int kHGCalCellVMask
static const HGCalTriggerDetId Undefined
Definition: DetId.h:17
#define N
Definition: blowfish.cc:9
HGCalTriggerDetId & operator=(const DetId &id)
int triggerCellV() const
static const int kHGCalWaferUMask
uint32_t id_
Definition: DetId.h:69
int type() const
get the type
static const int kHGCalLayerMask
static const int kHGCalWaferVSignOffset
static const int kHGCalCellUOffset
int32_t waferV(const int32_t index)
static const int kHGCalWaferVOffset
static const int kHGCalCellUMask
std::ostream & operator<<(std::ostream &s, const HGCalTriggerDetId &id)
static const int HGCalFineTrigger
static const int kHGCalWaferUSignOffset