CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes
HGCalWaferMask Class Reference

#include <HGCalWaferMask.h>

Public Member Functions

 HGCalWaferMask ()=default
 

Static Public Member Functions

static std::pair< int, int > getTypeMode (const double &xpos, const double &ypos, const double &delX, const double &delY, const double &rin, const double &rout, const int &waferType, const int &mode, bool deug=false)
 
static bool goodCell (int u, int v, int N, int type, int rotn)
 
static bool maskCell (int u, int v, int N, int ncor, int fcor, int corners)
 

Static Public Attributes

static const int k_OffsetRotation = 10
 

Detailed Description

this class determines the masking of wafers to mimic partial wafers

Date
2019/01/15 00:06:50
Author
Sunanda Banerjee, Fermilab sunan.nosp@m.da.b.nosp@m.anerj.nosp@m.ee@c.nosp@m.ern.c.nosp@m.h

Definition at line 16 of file HGCalWaferMask.h.

Constructor & Destructor Documentation

◆ HGCalWaferMask()

HGCalWaferMask::HGCalWaferMask ( )
default

Member Function Documentation

◆ getTypeMode()

std::pair< int, int > HGCalWaferMask::getTypeMode ( const double &  xpos,
const double &  ypos,
const double &  delX,
const double &  delY,
const double &  rin,
const double &  rout,
const int &  waferType,
const int &  mode,
bool  deug = false 
)
static

Definition at line 336 of file HGCalWaferMask.cc.

344  {
345  int ncor(0), iok(0);
347 
348  static const int corners = 6;
349  static const int base = 10;
350  double dx0[corners] = {0.0, delX, delX, 0.0, -delX, -delX};
351  double dy0[corners] = {-delY, -0.5 * delY, 0.5 * delY, delY, 0.5 * delY, -0.5 * delY};
352  double xc[corners], yc[corners];
353  for (int k = 0; k < corners; ++k) {
354  xc[k] = xpos + dx0[k];
355  yc[k] = ypos + dy0[k];
356  double rpos = sqrt(xc[k] * xc[k] + yc[k] * yc[k]);
357  if (rpos <= rout && rpos >= rin) {
358  ++ncor;
359  iok = iok * base + 1;
360  } else {
361  iok *= base;
362  }
363  }
364  if (debug)
365  edm::LogVerbatim("HGCalGeom") << "I/p " << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
366  << rout << ":" << wType << ":" << mode << " Corners " << ncor << " iok " << iok;
367 
368  static const int ipat5[corners] = {101111, 110111, 111011, 111101, 111110, 11111};
369  static const int ipat4[corners] = {100111, 110011, 111001, 111100, 11110, 1111};
370  static const int ipat3[corners] = {100011, 110001, 111000, 11100, 1110, 111};
371  double dx1[corners] = {0.5 * delX, delX, 0.5 * delX, -0.5 * delX, -delX, -0.5 * delX};
372  double dy1[corners] = {-0.75 * delY, 0.0, 0.75 * delY, 0.75 * delY, 0.0, -0.75 * delY};
373  double dx2[corners] = {0.5 * delX, -0.5 * delX, -delX, -0.5 * delX, 0.5 * delX, delX};
374  double dy2[corners] = {0.75 * delY, 0.75 * delY, 0.0, -0.75 * delY, -0.75 * delY, 0.0};
375  double dx3[corners] = {0.25 * delX, delX, 0.75 * delX, -0.25 * delX, -delX, -0.75 * delX};
376  double dy3[corners] = {-0.875 * delY, -0.25 * delY, 0.625 * delY, 0.875 * delY, 0.25 * delY, -0.625 * delY};
377  double dx4[corners] = {0.25 * delX, -0.75 * delX, -delX, -0.25 * delX, 0.75 * delX, delX};
378  double dy4[corners] = {0.875 * delY, 0.625 * delY, -0.25 * delY, -0.875 * delY, -0.625 * delY, 0.25 * delY};
379  double dx5[corners] = {-0.5 * delX, -delX, -0.5 * delX, 0.5 * delX, delX, 0.5 * delX};
380  double dy5[corners] = {0.75 * delY, 0.0, -0.75 * delY, -0.75 * delY, 0.0, 0.75 * delY};
381  double dx6[corners] = {-0.75 * delX, -delX, -0.25 * delX, 0.75 * delX, delX, 0.25 * delX};
382  double dy6[corners] = {0.625 * delY, -0.25 * delY, -0.875 * delY, -0.625 * delY, 0.25 * delY, 0.875 * delY};
383 
384  if (ncor == HGCalGeomTools::k_allCorners) {
385  } else if (ncor == HGCalGeomTools::k_fiveCorners) {
386  rotn = static_cast<int>(std::find(ipat5, ipat5 + 6, iok) - ipat5);
388  } else if (ncor == HGCalGeomTools::k_fourCorners) {
389  rotn = static_cast<int>(std::find(ipat4, ipat4 + 6, iok) - ipat4);
391  double rpos1 = sqrt((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
392  double rpos2(0);
393  if (rpos1 <= rout && rpos1 >= rin) {
394  rpos2 = sqrt((xpos + dx2[rotn]) * (xpos + dx2[rotn]) + (ypos + dy2[rotn]) * (ypos + dy2[rotn]));
395  if (rpos2 <= rout && rpos2 >= rin)
397  }
398  if (debug)
399  edm::LogVerbatim("HGCalGeom") << "Test for Chop2 " << rpos1 << ":" << rpos2 << " Type " << type;
400  if ((type == HGCalTypes::WaferHalf) && (wType == 0)) {
401  rpos1 = sqrt((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
402  if (rpos1 <= rout && rpos1 >= rin) {
403  rpos2 = sqrt((xpos + dx4[rotn]) * (xpos + dx4[rotn]) + (ypos + dy4[rotn]) * (ypos + dy4[rotn]));
404  if (rpos2 <= rout && rpos2 >= rin)
406  }
407  if (debug)
408  edm::LogVerbatim("HGCalGeom") << "Test for Chop2M " << rpos1 << ":" << rpos2 << " Type " << type;
409  }
410  } else if (ncor == HGCalGeomTools::k_threeCorners) {
411  rotn = static_cast<int>(std::find(ipat3, ipat3 + 6, iok) - ipat3);
413  double rpos1 = sqrt((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
414  double rpos2(0);
415  if (rpos1 <= rout && rpos1 >= rin) {
416  rpos2 = sqrt((xpos + dx5[rotn]) * (xpos + dx5[rotn]) + (ypos + dy5[rotn]) * (ypos + dy5[rotn]));
417  if (rpos2 <= rout && rpos2 >= rin)
419  }
420  if (debug)
421  edm::LogVerbatim("HGCalGeom") << "Test for Semi " << rpos1 << ":" << rpos2 << " Type " << type;
422  if ((type == HGCalTypes::WaferThree) && (wType == 0)) {
423  rpos1 = sqrt((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
424  if (rpos1 <= rout && rpos1 >= rin) {
425  rpos2 = sqrt((xpos + dx6[rotn]) * (xpos + dx6[rotn]) + (ypos + dy6[rotn]) * (ypos + dy6[rotn]));
426  if (rpos2 <= rout && rpos2 >= rin)
428  }
429  if (debug)
430  edm::LogVerbatim("HGCalGeom") << "Test for SemiM " << rpos1 << ":" << rpos2 << " Type " << type;
431  }
432  } else {
434  }
435 
436  if (debug)
437  edm::LogVerbatim("HGCalGeom") << "I/p " << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
438  << rout << ":" << wType << ":" << mode << " o/p " << iok << ":" << ncor << ":" << type
439  << ":" << rotn;
440  return ((mode == 0) ? std::make_pair(ncor, rotn) : std::make_pair(type, (rotn + HGCalWaferMask::k_OffsetRotation)));
441 }

References newFWLiteAna::base, debug, spr::find(), dqmdumpme::k, HGCalGeomTools::k_allCorners, HGCalGeomTools::k_fiveCorners, HGCalGeomTools::k_fourCorners, k_OffsetRotation, HGCalGeomTools::k_threeCorners, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, mathSSE::sqrt(), HGCalTypes::WaferChopTwo, HGCalTypes::WaferChopTwoM, HGCalTypes::WaferCorner0, HGCalTypes::WaferFive, HGCalTypes::WaferFull, HGCalTypes::WaferHalf, HGCalTypes::WaferOut, HGCalTypes::WaferSemi, HGCalTypes::WaferSemi2, and HGCalTypes::WaferThree.

Referenced by HGCalGeomParameters::loadWaferHexagon8().

◆ goodCell()

bool HGCalWaferMask::goodCell ( int  u,
int  v,
int  N,
int  type,
int  rotn 
)
static

Definition at line 107 of file HGCalWaferMask.cc.

107  {
108  bool good(false);
109  int n2 = n / 2;
110  int n3 = (n + 1) / 3;
111  int n4 = n / 4;
112  switch (type) {
113  case (HGCalTypes::WaferFull): { //WaferFull
114  good = true;
115  break;
116  }
117  case (HGCalTypes::WaferFive): { //WaferFive
118  switch (rotn) {
119  case (HGCalTypes::WaferCorner0): {
120  int u2 = u / 2;
121  good = ((v - u2) < n);
122  break;
123  }
124  case (HGCalTypes::WaferCorner1): {
125  good = ((v + u) < (3 * n - 1));
126  break;
127  }
128  case (HGCalTypes::WaferCorner2): {
129  int v2 = (v + 1) / 2;
130  good = ((u - v2) < n);
131  break;
132  }
133  case (HGCalTypes::WaferCorner3): {
134  int u2 = (u + 1) / 2;
135  good = (u2 <= v);
136  break;
137  }
138  case (HGCalTypes::WaferCorner4): {
139  good = ((v + u) >= n);
140  break;
141  }
142  default: {
143  int v2 = v / 2;
144  good = (u > v2);
145  break;
146  }
147  }
148  break;
149  }
150  case (HGCalTypes::WaferChopTwo): { //WaferChopTwo
151  switch (rotn) {
152  case (HGCalTypes::WaferCorner0): {
153  good = (v < (3 * n2));
154  break;
155  }
156  case (HGCalTypes::WaferCorner1): {
157  good = (u < (3 * n2));
158  break;
159  }
160  case (HGCalTypes::WaferCorner2): {
161  good = ((u - v) <= n2);
162  break;
163  }
164  case (HGCalTypes::WaferCorner3): {
165  good = (v >= n2);
166  break;
167  }
168  case (HGCalTypes::WaferCorner4): {
169  good = (u >= n2);
170  break;
171  }
172  default: {
173  good = ((v - u) < n2);
174  break;
175  }
176  }
177  break;
178  }
179  case (HGCalTypes::WaferChopTwoM): { //WaferChopTwoM
180  switch (rotn) {
181  case (HGCalTypes::WaferCorner0): {
182  good = (v < (5 * n4));
183  break;
184  }
185  case (HGCalTypes::WaferCorner1): {
186  good = (u < (5 * n4));
187  break;
188  }
189  case (HGCalTypes::WaferCorner2): {
190  good = ((u - v) <= n4);
191  break;
192  }
193  case (HGCalTypes::WaferCorner3): {
194  good = (v >= (3 * n4));
195  break;
196  }
197  case (HGCalTypes::WaferCorner4): {
198  good = (u >= (3 * n4));
199  break;
200  }
201  default: {
202  good = ((v - u) < n4);
203  break;
204  }
205  }
206  break;
207  }
208  case (HGCalTypes::WaferHalf): { //WaferHalf
209  switch (rotn) {
210  case (HGCalTypes::WaferCorner0): {
211  good = (v < n);
212  break;
213  }
214  case (HGCalTypes::WaferCorner1): {
215  good = (u < n);
216  break;
217  }
218  case (HGCalTypes::WaferCorner2): {
219  good = (v >= u);
220  break;
221  }
222  case (HGCalTypes::WaferCorner3): {
223  good = (v >= n);
224  break;
225  }
226  case (HGCalTypes::WaferCorner4): {
227  good = (u >= n);
228  break;
229  }
230  default: {
231  good = (u > v);
232  break;
233  }
234  }
235  break;
236  }
237  case (HGCalTypes::WaferSemi): { //WaferSemi
238  switch (rotn) {
239  case (HGCalTypes::WaferCorner0): {
240  good = ((u + v) < (2 * n));
241  break;
242  }
243  case (HGCalTypes::WaferCorner1): {
244  good = ((2 * u - v) < n);
245  break;
246  }
247  case (HGCalTypes::WaferCorner2): {
248  good = ((2 * v - u) >= n);
249  break;
250  }
251  case (HGCalTypes::WaferCorner3): {
252  good = ((u + v) >= (2 * n));
253  break;
254  }
255  case (HGCalTypes::WaferCorner4): {
256  good = ((2 * u - v) > n);
257  break;
258  }
259  default: {
260  good = ((2 * v - u) < n);
261  break;
262  }
263  }
264  break;
265  }
266  case (HGCalTypes::WaferThree): { //WaferThree
267  switch (rotn) {
268  case (HGCalTypes::WaferCorner0): {
269  good = ((v + u) < n);
270  break;
271  }
272  case (HGCalTypes::WaferCorner1): {
273  int v2 = v / 2;
274  good = (u <= v2);
275  break;
276  }
277  case (HGCalTypes::WaferCorner2): {
278  int u2 = (u / 2);
279  good = ((v - u2) >= n);
280  break;
281  }
282  case (HGCalTypes::WaferCorner3): {
283  good = ((v + u) >= (3 * n - 1));
284  break;
285  }
286  case (HGCalTypes::WaferCorner4): {
287  int v2 = v / 2;
288  good = ((u - v2) >= n);
289  break;
290  }
291  default: {
292  int u2 = ((u + 1) / 2);
293  good = (v < u2);
294  break;
295  }
296  }
297  break;
298  }
299  case (HGCalTypes::WaferSemi2): { //WaferSemi2
300  switch (rotn) {
301  case (HGCalTypes::WaferCorner0): {
302  good = ((u + v) < (4 * n3));
303  break;
304  }
305  case (HGCalTypes::WaferCorner1): {
306  good = ((2 * u - v) <= n2);
307  break;
308  }
309  case (HGCalTypes::WaferCorner2): {
310  good = ((2 * v - u) > (3 * n2));
311  break;
312  }
313  case (HGCalTypes::WaferCorner3): {
314  good = ((u + v) >= (5 * n2 - 1));
315  break;
316  }
317  case (HGCalTypes::WaferCorner4): {
318  good = ((2 * u - v) < (3 * n2));
319  break;
320  }
321  default: {
322  good = ((2 * v - u) <= n3);
323  break;
324  }
325  }
326  break;
327  }
328  }
329 #ifdef EDM_ML_DEBUG
330  edm::LogVerbatim("HGCalGeom") << "u|v " << u << ":" << v << " N " << n << " type " << type << " rot " << rotn
331  << " good " << good;
332 #endif
333  return good;
334 }

References dqmiodumpmetadata::n, MetAnalyzer::u2, findQualityFiles::v, HGCalTypes::WaferChopTwo, HGCalTypes::WaferChopTwoM, HGCalTypes::WaferCorner0, HGCalTypes::WaferCorner1, HGCalTypes::WaferCorner2, HGCalTypes::WaferCorner3, HGCalTypes::WaferCorner4, HGCalTypes::WaferFive, HGCalTypes::WaferFull, HGCalTypes::WaferHalf, HGCalTypes::WaferSemi, HGCalTypes::WaferSemi2, and HGCalTypes::WaferThree.

Referenced by HGCalDDDConstants::maskCell().

◆ maskCell()

bool HGCalWaferMask::maskCell ( int  u,
int  v,
int  N,
int  ncor,
int  fcor,
int  corners 
)
static

Definition at line 10 of file HGCalWaferMask.cc.

10  {
11  /*
12 Masks each cell (or not) according to its wafer and cell position (detId) and to the user needs (corners).
13 Each wafer has k_CornerSize corners which are defined in anti-clockwise order starting from the corner at the top, which is always #0. 'ncor' denotes the number of corners inside the physical region. 'fcor' is the defined to be the first corner that appears inside the detector's physical volume in anti-clockwise order.
14 The argument 'corners' controls the types of wafers the user wants: for instance, corners=3 masks all wafers that have at least 3 corners inside the physical region.
15  */
16  bool mask(false);
17  if (ncor < corners) {
18  mask = true;
19  } else {
20  if (ncor == HGCalGeomTools::k_fourCorners) {
21  switch (fcor) {
22  case (0): {
23  mask = (v >= n);
24  break;
25  }
26  case (1): {
27  mask = (u >= n);
28  break;
29  }
30  case (2): {
31  mask = (u > v);
32  break;
33  }
34  case (3): {
35  mask = (v < n);
36  break;
37  }
38  case (4): {
39  mask = (u < n);
40  break;
41  }
42  default: {
43  mask = (u <= v);
44  break;
45  }
46  }
47  } else {
48  switch (fcor) {
49  case (0): {
50  if (ncor == HGCalGeomTools::k_threeCorners) {
51  mask = !((u > 2 * v) && (v < n));
52  } else {
53  mask = ((u >= n) && (v >= n) && ((u + v) > (3 * n - 2)));
54  }
55  break;
56  }
57  case (1): {
58  if (ncor == HGCalGeomTools::k_threeCorners) {
59  mask = !((u + v) < n);
60  } else {
61  mask = ((u >= n) && (u > v) && ((2 * u - v) > 2 * n));
62  }
63  break;
64  }
65  case (2): {
66  if (ncor == HGCalGeomTools::k_threeCorners) {
67  mask = !((u < n) && (v > u) && (v > (2 * u - 1)));
68  } else {
69  mask = ((u > 2 * v) && (v < n));
70  }
71  break;
72  }
73  case (3): {
74  if (ncor == HGCalGeomTools::k_threeCorners) {
75  mask = !((v >= u) && ((2 * v - u) > (2 * n - 2)));
76  } else {
77  mask = ((u + v) < n);
78  }
79  break;
80  }
81  case (4): {
82  if (ncor == HGCalGeomTools::k_threeCorners) {
83  mask = !((u >= n) && (v >= n) && ((u + v) > (3 * n - 2)));
84  } else {
85  mask = ((u < n) && (v > u) && (v > (2 * u - 1)));
86  }
87  break;
88  }
89  default: {
90  if (ncor == HGCalGeomTools::k_threeCorners) {
91  mask = !((u >= n) && (u > v) && ((2 * u - v) > 2 * n));
92  } else {
93  mask = ((v >= u) && ((2 * v - u) > (2 * n - 2)));
94  }
95  break;
96  }
97  }
98  }
99  }
100 #ifdef EDM_ML_DEBUG
101  edm::LogVerbatim("HGCalGeom") << "Corners: " << ncor << ":" << fcor << " N " << n << " u " << u << " v " << v
102  << " Mask " << mask;
103 #endif
104  return mask;
105 }

References HGCalGeomTools::k_fourCorners, HGCalGeomTools::k_threeCorners, dqmiodumpmetadata::n, and findQualityFiles::v.

Referenced by HGCalDDDConstants::maskCell().

Member Data Documentation

◆ k_OffsetRotation

const int HGCalWaferMask::k_OffsetRotation = 10
static
HGCalTypes::WaferChopTwo
Definition: HGCalTypes.h:52
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HGCalTypes::WaferThree
Definition: HGCalTypes.h:57
HGCalTypes::WaferFull
Definition: HGCalTypes.h:50
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
HGCalTypes::WaferCorner1
Definition: HGCalTypes.h:31
HGCalTypes::WaferOut
Definition: HGCalTypes.h:58
findQualityFiles.v
v
Definition: findQualityFiles.py:179
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
HGCalTypes::WaferFive
Definition: HGCalTypes.h:51
HGCalGeomTools::k_fiveCorners
static const int k_fiveCorners
Definition: HGCalGeomTools.h:14
debug
#define debug
Definition: HDRShower.cc:19
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HGCalGeomTools::k_allCorners
static const int k_allCorners
Definition: HGCalGeomTools.h:13
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HGCalTypes::WaferSemi
Definition: HGCalTypes.h:55
HGCalTypes::WaferCorner2
Definition: HGCalTypes.h:32
HGCalTypes::WaferSemi2
Definition: HGCalTypes.h:56
HGCalTypes::WaferCorner4
Definition: HGCalTypes.h:34
edm::LogVerbatim
Definition: MessageLogger.h:297
HGCalTypes::WaferChopTwoM
Definition: HGCalTypes.h:53
HGCalWaferMask::k_OffsetRotation
static const int k_OffsetRotation
Definition: HGCalWaferMask.h:31
type
type
Definition: HCALResponse.h:21
HGCalTypes::WaferCorner3
Definition: HGCalTypes.h:33
HGCalGeomTools::k_threeCorners
static const int k_threeCorners
Definition: HGCalGeomTools.h:16
HGCalTypes::WaferHalf
Definition: HGCalTypes.h:54
HGCalGeomTools::k_fourCorners
static const int k_fourCorners
Definition: HGCalGeomTools.h:15
MetAnalyzer.u2
u2
Definition: MetAnalyzer.py:61
newFWLiteAna.base
base
Definition: newFWLiteAna.py:92
HGCalTypes::WaferCorner0
Definition: HGCalTypes.h:30