CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCalTestNumbering.cc
Go to the documentation of this file.
3 #include <iostream>
4 
5 uint32_t HGCalTestNumbering::packSquareIndex(int zp, int lay, int sec, int subsec, int cell) {
6  if (!HGCalTestNumbering::isValidSquare(zp, lay, sec, subsec, lay)) {
7  zp = lay = sec = subsec = cell = 0;
8  }
9 
10  uint32_t rawid = 0;
11  rawid |= ((cell & kHGCalCellSMask) << kHGCalCellSOffset);
12  rawid |= ((sec & kHGCalSectorSMask) << kHGCalSectorSOffset);
13  if (subsec < 0)
14  subsec = 0;
15  rawid |= ((subsec & kHGCalSubSectorSMask) << kHGCalSubSectorSOffset);
16  rawid |= ((lay & kHGCalLayerSMask) << kHGCalLayerSOffset);
17  if (zp > 0)
18  rawid |= ((zp & kHGCalZsideSMask) << kHGCalZsideSOffset);
19  return rawid;
20 }
21 
22 uint32_t HGCalTestNumbering::packHexagonIndex(int subdet, int zp, int lay, int wafer, int celltyp, int cell) {
23  if (!HGCalTestNumbering::isValidHexagon(subdet, zp, lay, wafer, celltyp, cell)) {
24  subdet = zp = lay = wafer = celltyp = cell = 0;
25  }
26 
27  uint32_t rawid = 0;
28  rawid |= ((cell & kHGCalCellHMask) << kHGCalCellHOffset);
29  rawid |= ((celltyp & kHGCalCellTypHMask) << kHGCalCellTypHOffset);
30  rawid |= ((wafer & kHGCalWaferHMask) << kHGCalWaferHOffset);
31  rawid |= ((lay & kHGCalLayerHMask) << kHGCalLayerHOffset);
32  if (zp > 0)
33  rawid |= ((zp & kHGCalZsideHMask) << kHGCalZsideHOffset);
34  rawid |= ((subdet & kHGCalSubdetHMask) << kHGCalSubdetHOffset);
35  return rawid;
36 }
37 
38 void HGCalTestNumbering::unpackSquareIndex(const uint32_t& idx, int& zp, int& lay, int& sec, int& subsec, int& cell) {
39  cell = (idx >> kHGCalCellSOffset) & kHGCalCellSMask;
40  subsec = ((idx >> kHGCalSubSectorSOffset) & kHGCalSubSectorSMask ? 1 : -1);
41  sec = (idx >> kHGCalSectorSOffset) & kHGCalSectorSMask;
42  lay = (idx >> kHGCalLayerSOffset) & kHGCalLayerSMask;
43  zp = ((idx >> kHGCalZsideSOffset) & kHGCalZsideSMask ? 1 : -1);
44 }
45 
47  const uint32_t& idx, int& subdet, int& zp, int& lay, int& wafer, int& celltyp, int& cell) {
48  cell = (idx >> kHGCalCellHOffset) & kHGCalCellHMask;
49  celltyp = (idx >> kHGCalCellTypHOffset) & kHGCalCellTypHMask;
50  wafer = (idx >> kHGCalWaferHOffset) & kHGCalWaferHMask;
51  lay = (idx >> kHGCalLayerHOffset) & kHGCalLayerHMask;
52  zp = ((idx >> kHGCalZsideHOffset) & kHGCalZsideHMask ? 1 : -1);
53  subdet = (idx >> kHGCalSubdetHOffset) & kHGCalSubdetHMask;
54 }
55 
56 bool HGCalTestNumbering::isValidSquare(int zp, int lay, int sec, int subsec, int cell) {
57  if (cell > kHGCalCellSMask || sec > kHGCalSectorSMask || subsec > kHGCalSubSectorSMask || lay > kHGCalLayerSMask) {
58 #ifdef EDM_ML_DEBUG
59  std::cout << "[HGCalTestNumbering] request for new id for layer=" << lay << " zp=" << zp << " sector=" << sec
60  << " subsec=" << subsec << " cell=" << cell << " has one or more fields out of bounds and will be reset"
61  << std::endl;
62 #endif
63  return false;
64  }
65  return true;
66 }
67 
68 bool HGCalTestNumbering::isValidHexagon(int subdet, int zp, int lay, int wafer, int celltyp, int cell) {
69  if (cell > kHGCalCellHMask || celltyp > kHGCalCellTypHMask || wafer > kHGCalWaferHMask || lay > kHGCalLayerSMask ||
70  subdet > kHGCalSubdetHMask) {
71  edm::LogWarning("HGCSim") << "[HGCalTestNumbering] request for new id for layer=" << lay << " zp=" << zp
72  << " wafer=" << wafer << " celltyp=" << celltyp << " cell=" << cell
73  << " for subdet=" << subdet
74  << " has one or more fields out of bounds and will be reset *****";
75  return false;
76  }
77  return true;
78 }
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
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:144
Log< level::Warning, false > LogWarning
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