CMS 3D CMS Logo

HFNoseTriggerDetId.cc
Go to the documentation of this file.
4 #include <ostream>
5 #include <iostream>
6 
8 
10 
11 HFNoseTriggerDetId::HFNoseTriggerDetId(uint32_t rawid) : DetId(rawid) {}
12 
14  int subdet, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV)
15  : DetId(HGCalTrigger, ForwardEmpty) {
16  int waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV));
17  int waferUsign = (waferU >= 0) ? 0 : 1;
18  int waferVsign = (waferV >= 0) ? 0 : 1;
19  int zside = (zp < 0) ? 1 : 0;
21  ((waferUabs & kHFNoseWaferUMask) << kHFNoseWaferUOffset) |
23  ((waferVabs & kHFNoseWaferVMask) << kHFNoseWaferVOffset) |
27 }
28 
30  if (!gen.null()) {
31  if ((gen.det() != HGCalTrigger) || ((gen.subdetId() & kHFNoseSubdetMask) != HFNoseTrigger)) {
32  throw cms::Exception("Invalid DetId")
33  << "Cannot initialize HFNoseTriggerDetId from " << std::hex << gen.rawId() << std::dec;
34  }
35  }
36  id_ = gen.rawId();
37 }
38 
40  if (!gen.null()) {
41  if ((gen.det() != HGCalTrigger) || ((gen.subdetId() & kHFNoseSubdetMask) != HFNoseTrigger)) {
42  throw cms::Exception("Invalid DetId")
43  << "Cannot assign HFNoseTriggerDetId from " << std::hex << gen.rawId() << std::dec;
44  }
45  }
46  id_ = gen.rawId();
47  return (*this);
48 }
49 
52  int N = nT * HFNoseTriggerCell;
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 
63  int N = nT * HFNoseTriggerCell;
64  std::vector<int> uc = cellU();
65  std::vector<int> vc = cellV();
66  int y(0);
67  for (unsigned int k = 0; k < uc.size(); ++k) {
68  y += (2 * uc[k] - (N + vc[k]));
69  }
70  return (y / static_cast<int>(vc.size()));
71 }
72 
73 std::vector<int> HFNoseTriggerDetId::cellU() const {
74  std::vector<int> uc;
77  int u0 = nT * triggerCellU();
78  for (int i = 0; i < nT; ++i) {
79  for (int j = 0; j < nT; ++j) {
80  uc.emplace_back(u0 + i);
81  }
82  }
83  } else if ((triggerCellU() < HFNoseTriggerCell) && (triggerCellU() <= triggerCellV())) {
84  int u0 = nT * triggerCellU();
85  for (int i = 0; i < nT; ++i) {
86  for (int j = 0; j < nT; ++j) {
87  uc.emplace_back(u0 + i);
88  }
89  }
90  } else {
91  int u0 = nT * (triggerCellU() - 1) + 1;
92  for (int i = 0; i < nT; ++i) {
93  for (int j = 0; j < nT; ++j) {
94  uc.emplace_back(u0 + j);
95  }
96  ++u0;
97  }
98  }
99  return uc;
100 }
101 
102 std::vector<int> HFNoseTriggerDetId::cellV() const {
103  std::vector<int> vc;
106  int v0 = nT * triggerCellV();
107  for (int i = 0; i < nT; ++i) {
108  for (int j = 0; j < nT; ++j) {
109  vc.emplace_back(v0 + j);
110  }
111  }
112  } else if ((triggerCellU() < HFNoseTriggerCell) && (triggerCellU() <= triggerCellV())) {
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  ++v0;
119  }
120  } else {
121  int v0 = nT * triggerCellV();
122  for (int i = 0; i < nT; ++i) {
123  for (int j = 0; j < nT; ++j) {
124  vc.emplace_back(v0 + i);
125  }
126  }
127  }
128  return vc;
129 }
130 
131 std::vector<std::pair<int, int> > HFNoseTriggerDetId::cellUV() const {
132  std::vector<int> uc = cellU();
133  std::vector<int> vc = cellV();
134  std::vector<std::pair<int, int> > uv;
135  for (unsigned int k = 0; k < uc.size(); ++k) {
136  uv.emplace_back(uc[k], vc[k]);
137  }
138  return uv;
139 }
140 
141 std::ostream& operator<<(std::ostream& s, const HFNoseTriggerDetId& id) {
142  return s << " EE:HSil= " << id.isEE() << ":" << id.isHSilicon() << " type= " << id.type() << " z= " << id.zside()
143  << " layer= " << id.layer() << " wafer(u,v:x,y)= (" << id.waferU() << "," << id.waferV() << ":"
144  << id.waferX() << "," << id.waferY() << ")"
145  << " triggerCell(u,v:x,y)= (" << id.triggerCellU() << "," << id.triggerCellV() << ":" << id.triggerCellX()
146  << "," << id.triggerCellY() << ")";
147 }
static const int kHFNoseWaferUOffset
std::vector< std::pair< int, int > > cellUV() const
static const int kHFNoseCellVMask
static const int kHFNoseWaferVSignOffset
static const int HFNoseCoarseTrigger
Definition: HFNoseDetId.h:28
int32_t waferU(const int32_t index)
static const int kHFNoseTypeOffset
std::ostream & operator<<(std::ostream &s, const HFNoseTriggerDetId &id)
static const int kHFNoseWaferVOffset
int zside() const
get the z-side of the cell (1/-1)
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
static const int HFNoseFineTrigger
Definition: HFNoseDetId.h:27
int layer() const
get the layer #
static const int kHFNoseLayerOffset
static const int kHFNoseWaferUSignOffset
static const int kHFNoseCellVOffset
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int kHFNoseSubdetMask
static const int kHFNoseCellUMask
int triggerCellU() const
get the cell #&#39;s in u,v or in x,y
Definition: DetId.h:17
static const int kHFNoseWaferVSignMask
#define N
Definition: blowfish.cc:9
int type() const
get the type
static const int HFNoseTriggerCell
uint32_t id_
Definition: DetId.h:69
std::vector< int > cellU() const
HGCalTriggerSubdetector subdet() const
get the subdetector
std::vector< int > cellV() const
static const int kHFNoseLayerMask
int32_t waferV(const int32_t index)
static const int kHFNoseWaferUSignMask
static const int kHFNoseZsideOffset
static const int kHFNoseWaferVMask
static const int kHFNoseWaferUMask
static const int kHFNoseZsideMask
static const HFNoseTriggerDetId Undefined
static const int kHFNoseCellUOffset
HFNoseTriggerDetId & operator=(const DetId &id)
static const int kHFNoseSubdetOffset
static const int kHFNoseTypeMask