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 
53  int N = nT * HGCalTriggerCell;
54  std::vector<int> vc = cellV();
55  int x(0);
56  for (auto const& v : vc) {
57  x += (3 * (v - N) + 2);
58  }
59  return (x / static_cast<int>(vc.size()));
60 }
61 
66  int N = nT * HGCalTriggerCell;
67  std::vector<int> uc = cellU();
68  std::vector<int> vc = cellV();
69  int y(0);
70  for (unsigned int k = 0; k < uc.size(); ++k) {
71  y += (2 * uc[k] - (N + vc[k]));
72  }
73  return (y / static_cast<int>(vc.size()));
74 }
75 
76 std::vector<int> HGCalTriggerDetId::cellU() const {
77  std::vector<int> uc;
82  int u0 = nT * triggerCellU();
83  for (int i = 0; i < nT; ++i) {
84  for (int j = 0; j < nT; ++j) {
85  uc.emplace_back(u0 + i);
86  }
87  }
88  } else if ((triggerCellU() < HGCalTriggerCell) && (triggerCellU() <= triggerCellV())) {
89  int u0 = nT * triggerCellU();
90  for (int i = 0; i < nT; ++i) {
91  for (int j = 0; j < nT; ++j) {
92  uc.emplace_back(u0 + i);
93  }
94  }
95  } else {
96  int u0 = nT * (triggerCellU() - 1) + 1;
97  for (int i = 0; i < nT; ++i) {
98  for (int j = 0; j < nT; ++j) {
99  uc.emplace_back(u0 + j);
100  }
101  ++u0;
102  }
103  }
104  return uc;
105 }
106 
107 std::vector<int> HGCalTriggerDetId::cellV() const {
108  std::vector<int> vc;
113  int v0 = nT * triggerCellV();
114  for (int i = 0; i < nT; ++i) {
115  for (int j = 0; j < nT; ++j) {
116  vc.emplace_back(v0 + j);
117  }
118  }
119  } else if ((triggerCellU() < HGCalTriggerCell) && (triggerCellU() <= triggerCellV())) {
120  int v0 = nT * triggerCellV();
121  for (int i = 0; i < nT; ++i) {
122  for (int j = 0; j < nT; ++j) {
123  vc.emplace_back(v0 + j);
124  }
125  ++v0;
126  }
127  } else {
128  int v0 = nT * triggerCellV();
129  for (int i = 0; i < nT; ++i) {
130  for (int j = 0; j < nT; ++j) {
131  vc.emplace_back(v0 + i);
132  }
133  }
134  }
135  return vc;
136 }
137 
138 std::vector<std::pair<int, int> > HGCalTriggerDetId::cellUV() const {
139  std::vector<int> uc = cellU();
140  std::vector<int> vc = cellV();
141  std::vector<std::pair<int, int> > uv;
142  for (unsigned int k = 0; k < uc.size(); ++k) {
143  uv.emplace_back(std::pair<int, int>(uc[k], vc[k]));
144  }
145  return uv;
146 }
147 
148 std::ostream& operator<<(std::ostream& s, const HGCalTriggerDetId& id) {
149  return s << " EE:HSil= " << id.isEE() << ":" << id.isHSilicon() << " type= " << id.type() << " z= " << id.zside()
150  << " layer= " << id.layer() << " wafer(u,v:x,y)= (" << id.waferU() << "," << id.waferV() << ":"
151  << id.waferX() << "," << id.waferY() << ")"
152  << " triggerCell(u,v:x,y)= (" << id.triggerCellU() << "," << id.triggerCellV() << ":" << id.triggerCellX()
153  << "," << id.triggerCellY() << ")";
154 }
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
static const int kHGCalZsideMask
static constexpr int32_t HGCalCoarseTrigger
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 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 constexpr int32_t HGCalFineTrigger
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 kHGCalWaferUSignOffset