CMS 3D CMS Logo

HGCalTriggerDetId.cc
Go to the documentation of this file.
3 #include <ostream>
4 #include <iostream>
5 
6 const HGCalTriggerDetId HGCalTriggerDetId::Undefined(HGCalEE,0,0,0,0,0,0,0);
7 
9 }
10 
11 HGCalTriggerDetId::HGCalTriggerDetId(uint32_t rawid) : DetId(rawid) {
12 }
13 
15  int waferU, int waferV, int cellU,
17 
18  int waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV));
19  int waferUsign = (waferU >= 0) ? 0 : 1;
20  int waferVsign = (waferV >= 0) ? 0 : 1;
21  int zside = (zp < 0) ? 1 : 0;
22  id_ |= (((cellU & kHGCalCellUMask) << kHGCalCellUOffset) |
23  ((cellV & kHGCalCellVMask) << kHGCalCellVOffset) |
24  ((waferUabs & kHGCalWaferUMask) << kHGCalWaferUOffset) |
25  ((waferUsign& kHGCalWaferUSignMask) << kHGCalWaferUSignOffset) |
26  ((waferVabs & kHGCalWaferVMask) << kHGCalWaferVOffset) |
27  ((waferVsign& kHGCalWaferVSignMask) << kHGCalWaferVSignOffset) |
28  ((layer & kHGCalLayerMask) << kHGCalLayerOffset) |
29  ((zside & kHGCalZsideMask) << kHGCalZsideOffset) |
30  ((type & kHGCalTypeMask) << kHGCalTypeOffset) |
31  ((subdet & kHGCalSubdetMask)<< kHGCalSubdetOffset));
32 }
33 
35  if (!gen.null()) {
36  if ((gen.det()!=HGCalTrigger) ||
39  throw cms::Exception("Invalid DetId") << "Cannot initialize HGCalTriggerDetId from " << std::hex << gen.rawId() << std::dec;
40  }
41  }
42  id_ = gen.rawId();
43 }
44 
46  if (!gen.null()) {
47  if ((gen.det()!=HGCalTrigger) ||
50  throw cms::Exception("Invalid DetId") << "Cannot assign HGCalTriggerDetId from " << std::hex << gen.rawId() << std::dec;
51  }
52  }
53  id_ = gen.rawId();
54  return (*this);
55 }
56 
58  int nT = (type() == HGCSiliconDetId::HGCalFine) ?
60  int N = nT*HGCalTriggerCell;
61  std::vector<int> vc = cellV();
62  int x(0);
63  for (auto const & v : vc) {
64  x += (3*(v-N)+2);
65  }
66  return (x/vc.size());
67 }
68 
70  int nT = (type() == HGCSiliconDetId::HGCalFine) ?
72  int N = nT*HGCalTriggerCell;
73  std::vector<int> uc = cellU();
74  std::vector<int> vc = cellV();
75  int y(0);
76  for (unsigned int k=0; k<uc.size(); ++k) {
77  y += (2*uc[k]-(N+vc[k]));
78  }
79  return (y/vc.size());
80 }
81 
82 std::vector<int> HGCalTriggerDetId::cellU() const {
83  std::vector<int> uc;
84  int nT = (type() == HGCSiliconDetId::HGCalFine) ?
86  if ((triggerCellU() >= HGCalTriggerCell) &&
88  int u0 = nT*triggerCellU();
89  for (int i=0; i<nT; ++i) {
90  for (int j=0; j<nT; ++j) {
91  uc.emplace_back(u0+i);
92  }
93  }
94  } else if ((triggerCellU() < HGCalTriggerCell) &&
95  (triggerCellU() <= triggerCellV())) {
96  int u0 = nT*triggerCellU();
97  for (int i=0; i<nT; ++i) {
98  for (int j=0; j<nT; ++j) {
99  uc.emplace_back(u0+i);
100  }
101  }
102  } else {
103  int u0 = nT*(triggerCellU()-1)+1;
104  for (int i=0; i<nT; ++i) {
105  for (int j=0; j<nT; ++j) {
106  uc.emplace_back(u0+j);
107  }
108  ++u0;
109  }
110  }
111  return uc;
112 }
113 
114 std::vector<int> HGCalTriggerDetId::cellV() const {
115 
116  std::vector<int> vc;
117  int nT = (type() == HGCSiliconDetId::HGCalFine) ?
119  if ((triggerCellU() >= HGCalTriggerCell) &&
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+j);
125  }
126  }
127  } else if ((triggerCellU() < HGCalTriggerCell) &&
128  (triggerCellU() <= triggerCellV())) {
129  int v0 = nT*triggerCellV();
130  for (int i=0; i<nT; ++i) {
131  for (int j=0; j<nT; ++j) {
132  vc.emplace_back(v0+j);
133  }
134  ++v0;
135  }
136  } else {
137  int v0 = nT*triggerCellV();
138  for (int i=0; i<nT; ++i) {
139  for (int j=0; j<nT; ++j) {
140  vc.emplace_back(v0+i);
141  }
142  }
143  }
144  return vc;
145 }
146 
147 std::vector<std::pair<int,int> > HGCalTriggerDetId::cellUV() const {
148 
149  std::vector<int> uc = cellU();
150  std::vector<int> vc = cellV();
151  std::vector<std::pair<int,int> > uv;
152  for (unsigned int k=0; k<uc.size(); ++k) {
153  uv.emplace_back(std::pair<int,int>(uc[k],vc[k]));
154  }
155  return uv;
156 }
157 
158 std::ostream& operator<<(std::ostream& s,const HGCalTriggerDetId& id) {
159  return s << " EE:HSil= " << id.isEE() << ":" << id.isHSilicon()
160  << " type= " << id.type() << " z= " << id.zside()
161  << " layer= " << id.layer()
162  << " wafer(u,v:x,y)= (" << id.waferU() << "," << id.waferV() << ":"
163  << id.waferX() << "," << id.waferY() << ")"
164  << " triggerCell(u,v:x,y)= (" << id.triggerCellU() << ","
165  << id.triggerCellV() << ":" << id.triggerCellX() << ","
166  << id.triggerCellY() << ")";
167 }
168 
169 
type
Definition: HCALResponse.h:21
static const int kHGCalSubdetMask
HGCalTriggerSubdetector subdet() const
get the subdetector
constexpr bool null() const
is this a null id ?
Definition: DetId.h:49
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:47
int zside() const
get the z-side of the cell (1/-1)
static const int kHGCalTypeOffset
int type() const
get the type
static const int kHGCalLayerOffset
int triggerCellX() const
static const int kHGCalCellVOffset
int layer() const
get the layer #
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
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
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
int k[5][pyjets_maxn]
static const HGCalTriggerDetId Undefined
Definition: DetId.h:18
#define N
Definition: blowfish.cc:9
HGCalTriggerDetId & operator=(const DetId &id)
static const int kHGCalWaferUMask
uint32_t id_
Definition: DetId.h:59
static const int kHGCalLayerMask
static const int kHGCalWaferVSignOffset
std::vector< int > cellU() const
static const int kHGCalCellUOffset
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
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39