CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
19  id_ |= (((cellU & kHGCalCellUMask) << kHGCalCellUOffset) | ((cellV & kHGCalCellVMask) << kHGCalCellVOffset) |
20  ((waferUabs & kHGCalWaferUMask) << kHGCalWaferUOffset) |
21  ((waferUsign & kHGCalWaferUSignMask) << kHGCalWaferUSignOffset) |
22  ((waferVabs & kHGCalWaferVMask) << kHGCalWaferVOffset) |
23  ((waferVsign & kHGCalWaferVSignMask) << kHGCalWaferVSignOffset) |
24  ((layer & kHGCalLayerMask) << kHGCalLayerOffset) | ((zside & kHGCalZsideMask) << kHGCalZsideOffset) |
25  ((type & kHGCalTypeMask) << kHGCalTypeOffset) | ((subdet & kHGCalSubdetMask) << kHGCalSubdetOffset));
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
int32_t waferU(const int32_t index)
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
static const int kHGCalWaferVSignMask
int triggerCellU() const
get the cell #&#39;s in u,v or in x,y
std::vector< std::pair< int, int > > cellUV() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
int zside() const
get the z-side of the cell (1/-1)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
static const int kHGCalTypeOffset
int type() const
get the type
constexpr std::array< uint8_t, layerIndexSize > layer
static const int kHGCalLayerOffset
int triggerCellX() const
static const int kHGCalCellVOffset
static const int kHGCalZsideMask
static const int kHGCalWaferUSignMask
static const int HGCalTriggerCell
static const int kHGCalWaferUOffset
static const int kHGCalZsideOffset
static const int HGCalCoarseTrigger
int triggerCellY() const
static const int kHGCalWaferVMask
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int kHGCalTypeMask
std::vector< int > cellV() const
int triggerCellV() 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)
static const int kHGCalWaferUMask
uint32_t id_
Definition: DetId.h:69
static const int kHGCalLayerMask
static const int kHGCalWaferVSignOffset
std::vector< int > cellU() const
static const int kHGCalCellUOffset
int32_t waferV(const int32_t index)
static const int kHGCalWaferVOffset
static const int kHGCalCellUMask
static const int HGCalFineTrigger
static const int kHGCalWaferUSignOffset
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46