CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HGCalTestNumbering.cc
Go to the documentation of this file.
2 #include <iostream>
3 
4 //#define DebugLog
5 
6 uint32_t HGCalTestNumbering::packSquareIndex(int zp, int lay, int sec,
7  int subsec, int cell) {
8 
9  if (!HGCalTestNumbering::isValidSquare(zp, lay, sec, subsec,lay)) {
10  zp = lay = sec = subsec = cell = 0;
11  }
12 
13  uint32_t rawid=0;
14  rawid |= ((cell & kHGCalCellSMask) << kHGCalCellSOffset);
15  rawid |= ((sec & kHGCalSectorSMask) << kHGCalSectorSOffset);
16  if (subsec<0) subsec=0;
17  rawid |= ((subsec & kHGCalSubSectorSMask) << kHGCalSubSectorSOffset);
18  rawid |= ((lay & kHGCalLayerSMask) << kHGCalLayerSOffset);
19  if (zp>0) rawid |= ((zp & kHGCalZsideSMask) << kHGCalZsideSOffset);
20  return rawid;
21 }
22 
23 uint32_t HGCalTestNumbering::packHexagonIndex(int subdet, int zp, int lay,
24  int wafer, int celltyp,
25  int cell) {
26 
27  if (!HGCalTestNumbering::isValidHexagon(subdet,zp,lay,wafer,celltyp,cell)) {
28  subdet = zp = lay = wafer = celltyp = cell = 0;
29  }
30 
31  uint32_t rawid=0;
32  rawid |= ((cell & kHGCalCellHMask) << kHGCalCellHOffset);
33  rawid |= ((celltyp& kHGCalCellTypHMask) << kHGCalCellTypHOffset);
34  rawid |= ((wafer & kHGCalWaferHMask) << kHGCalWaferHOffset);
35  rawid |= ((lay & kHGCalLayerHMask) << kHGCalLayerHOffset);
36  if (zp>0) rawid |= ((zp & kHGCalZsideHMask) << kHGCalZsideHOffset);
37  rawid |= ((subdet & kHGCalSubdetHMask) << kHGCalSubdetHOffset);
38  return rawid;
39 }
40 
41 void HGCalTestNumbering::unpackSquareIndex(const uint32_t& idx, int& zp,
42  int& lay, int& sec, int& subsec,
43  int& cell) {
44 
45  cell = (idx>>kHGCalCellSOffset)&kHGCalCellSMask;
46  subsec = ((idx>>kHGCalSubSectorSOffset)&kHGCalSubSectorSMask ? 1 : -1);
49  zp = ((idx>>kHGCalZsideSOffset) & kHGCalZsideSMask ? 1 : -1);
50 }
51 
52 
53 void HGCalTestNumbering::unpackHexagonIndex(const uint32_t& idx, int& subdet,
54  int& zp, int& lay, int& wafer,
55  int& celltyp, int& cell) {
56  cell = (idx>>kHGCalCellHOffset)&kHGCalCellHMask;
58  wafer = (idx>>kHGCalWaferHOffset)&kHGCalWaferHMask;
60  zp = ((idx>>kHGCalZsideHOffset) & kHGCalZsideHMask ? 1 : -1);
61  subdet = (idx>>kHGCalSubdetHOffset)&kHGCalSubdetHMask;
62 }
63 
64 bool HGCalTestNumbering::isValidSquare(int zp, int lay, int sec, int subsec,
65  int cell) {
66 
67  if (cell > kHGCalCellSMask || sec>kHGCalSectorSMask ||
68  subsec > kHGCalSubSectorSMask || lay>kHGCalLayerSMask ) {
69 #ifdef DebugLog
70  std::cout << "[HGCalTestNumbering] request for new id for layer=" << lay
71  << " zp=" << zp
72  << " sector=" << sec
73  << " subsec=" << subsec
74  << " cell=" << cell
75  << " has one or more fields out of bounds and will be reset"
76  << std::endl;
77 #endif
78  return false;
79  }
80  return true;
81 }
82 
83 bool HGCalTestNumbering::isValidHexagon(int subdet, int zp, int lay, int wafer,
84  int celltyp, int cell) {
85 
86  if (cell > kHGCalCellHMask || celltyp>kHGCalCellTypHMask ||
87  wafer > kHGCalWaferHMask || lay>kHGCalLayerSMask ||
88  subdet > kHGCalSubdetHMask) {
89 #ifdef DebugLog
90  std::cout << "[HGCalTestNumbering] request for new id for layer=" << lay
91  << " zp=" << zp
92  << " wafer=" << wafer
93  << " celltyp=" << celltyp
94  << " cell=" << cell
95  << " for subdet=" << subdet
96  << " has one or more fields out of bounds and will be reset"
97  << std::endl;
98 #endif
99  return false;
100  }
101  return true;
102 }
static const int kHGCalZsideHMask
static const int kHGCalSubSectorSMask
static const int kHGCalWaferHMask
static const int kHGCalCellSMask
static const int kHGCalZsideHOffset
static const int kHGCalCellHMask
static const int kHGCalSubdetHMask
static const int kHGCalZsideSMask
static const int kHGCalLayerSOffset
static uint32_t packHexagonIndex(int subdet, int z, int lay, int wafer, int celltyp, int cell)
static const int kHGCalSectorSMask
static const int kHGCalZsideSOffset
static bool isValidHexagon(int subdet, int z, int lay, int wafer, int celltyp, int cell)
static bool isValidSquare(int z, int lay, int sec, int subsec, int cell)
static const int kHGCalLayerHOffset
static const int kHGCalSubSectorSOffset
static const int kHGCalCellHOffset
static const int kHGCalCellSOffset
static const int kHGCalLayerHMask
static const int kHGCalWaferHOffset
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static void unpackSquareIndex(const uint32_t &idx, int &z, int &lay, int &sec, int &subsec, int &cell)
static const int kHGCalCellTypHMask
static const int kHGCalCellTypHOffset
static const int kHGCalSubdetHOffset
tuple cout
Definition: gather_cfg.py:145
static uint32_t packSquareIndex(int z, int lay, int sec, int subsec, int cell)
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
static const int kHGCalLayerSMask
static const int kHGCalSectorSOffset