CMS 3D CMS Logo

HGCalTestNumbering.cc
Go to the documentation of this file.
2 #include <iostream>
3 
4 //#define EDM_ML_DEBUG
5 
6 uint32_t HGCalTestNumbering::packSquareIndex(int zp, int lay, int sec, int subsec, int cell) {
7  if (!HGCalTestNumbering::isValidSquare(zp, lay, sec, subsec, lay)) {
8  zp = lay = sec = subsec = cell = 0;
9  }
10 
11  uint32_t rawid = 0;
12  rawid |= ((cell & kHGCalCellSMask) << kHGCalCellSOffset);
13  rawid |= ((sec & kHGCalSectorSMask) << kHGCalSectorSOffset);
14  if (subsec < 0)
15  subsec = 0;
16  rawid |= ((subsec & kHGCalSubSectorSMask) << kHGCalSubSectorSOffset);
17  rawid |= ((lay & kHGCalLayerSMask) << kHGCalLayerSOffset);
18  if (zp > 0)
19  rawid |= ((zp & kHGCalZsideSMask) << kHGCalZsideSOffset);
20  return rawid;
21 }
22 
23 uint32_t HGCalTestNumbering::packHexagonIndex(int subdet, int zp, int lay, int wafer, int celltyp, int cell) {
24  if (!HGCalTestNumbering::isValidHexagon(subdet, zp, lay, wafer, celltyp, cell)) {
25  subdet = zp = lay = wafer = celltyp = cell = 0;
26  }
27 
28  uint32_t rawid = 0;
29  rawid |= ((cell & kHGCalCellHMask) << kHGCalCellHOffset);
30  rawid |= ((celltyp & kHGCalCellTypHMask) << kHGCalCellTypHOffset);
31  rawid |= ((wafer & kHGCalWaferHMask) << kHGCalWaferHOffset);
32  rawid |= ((lay & kHGCalLayerHMask) << kHGCalLayerHOffset);
33  if (zp > 0)
34  rawid |= ((zp & kHGCalZsideHMask) << kHGCalZsideHOffset);
35  rawid |= ((subdet & kHGCalSubdetHMask) << kHGCalSubdetHOffset);
36  return rawid;
37 }
38 
39 void HGCalTestNumbering::unpackSquareIndex(const uint32_t& idx, int& zp, int& lay, int& sec, int& subsec, int& cell) {
41  subsec = ((idx >> kHGCalSubSectorSOffset) & kHGCalSubSectorSMask ? 1 : -1);
44  zp = ((idx >> kHGCalZsideSOffset) & kHGCalZsideSMask ? 1 : -1);
45 }
46 
48  const uint32_t& idx, int& subdet, int& zp, int& lay, int& wafer, int& celltyp, int& cell) {
53  zp = ((idx >> kHGCalZsideHOffset) & kHGCalZsideHMask ? 1 : -1);
55 }
56 
57 bool HGCalTestNumbering::isValidSquare(int zp, int lay, int sec, int subsec, int cell) {
58  if (cell > kHGCalCellSMask || sec > kHGCalSectorSMask || subsec > kHGCalSubSectorSMask || lay > kHGCalLayerSMask) {
59 #ifdef EDM_ML_DEBUG
60  std::cout << "[HGCalTestNumbering] request for new id for layer=" << lay << " zp=" << zp << " sector=" << sec
61  << " subsec=" << subsec << " cell=" << cell << " has one or more fields out of bounds and will be reset"
62  << std::endl;
63 #endif
64  return false;
65  }
66  return true;
67 }
68 
69 bool HGCalTestNumbering::isValidHexagon(int subdet, int zp, int lay, int wafer, int celltyp, int cell) {
70  if (cell > kHGCalCellHMask || celltyp > kHGCalCellTypHMask || wafer > kHGCalWaferHMask || lay > kHGCalLayerSMask ||
71  subdet > kHGCalSubdetHMask) {
72 #ifdef EDM_ML_DEBUG
73  std::cout << "[HGCalTestNumbering] request for new id for layer=" << lay << " zp=" << zp << " wafer=" << wafer
74  << " celltyp=" << celltyp << " cell=" << cell << " for subdet=" << subdet
75  << " has one or more fields out of bounds and will be reset" << std::endl;
76 #endif
77  return false;
78  }
79  return true;
80 }
HGCalTestNumbering::kHGCalCellHOffset
static const int kHGCalCellHOffset
Definition: HGCalTestNumbering.h:22
HGCalTestNumbering::kHGCalSectorSMask
static const int kHGCalSectorSMask
Definition: HGCalTestNumbering.h:14
HGCalTestNumbering::kHGCalLayerHMask
static const int kHGCalLayerHMask
Definition: HGCalTestNumbering.h:29
HGCalTestNumbering::kHGCalZsideSOffset
static const int kHGCalZsideSOffset
Definition: HGCalTestNumbering.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HGCalTestNumbering::unpackHexagonIndex
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
Definition: HGCalTestNumbering.cc:47
HGCalTestNumbering::kHGCalWaferHOffset
static const int kHGCalWaferHOffset
Definition: HGCalTestNumbering.h:26
HGCalTestNumbering::kHGCalLayerHOffset
static const int kHGCalLayerHOffset
Definition: HGCalTestNumbering.h:28
HGCalTestNumbering::kHGCalCellSMask
static const int kHGCalCellSMask
Definition: HGCalTestNumbering.h:12
HGCalTestNumbering::unpackSquareIndex
static void unpackSquareIndex(const uint32_t &idx, int &z, int &lay, int &sec, int &subsec, int &cell)
Definition: HGCalTestNumbering.cc:39
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
HGCalTestNumbering::kHGCalSubdetHOffset
static const int kHGCalSubdetHOffset
Definition: HGCalTestNumbering.h:32
HGCalTestNumbering::kHGCalZsideSMask
static const int kHGCalZsideSMask
Definition: HGCalTestNumbering.h:20
HGCalTestNumbering::packSquareIndex
static uint32_t packSquareIndex(int z, int lay, int sec, int subsec, int cell)
Definition: HGCalTestNumbering.cc:6
HGCalTestNumbering::kHGCalLayerSMask
static const int kHGCalLayerSMask
Definition: HGCalTestNumbering.h:18
HGCalTestNumbering::kHGCalZsideHMask
static const int kHGCalZsideHMask
Definition: HGCalTestNumbering.h:31
HGCalTestNumbering::kHGCalSubSectorSMask
static const int kHGCalSubSectorSMask
Definition: HGCalTestNumbering.h:16
HGCalTestNumbering::kHGCalCellHMask
static const int kHGCalCellHMask
Definition: HGCalTestNumbering.h:23
HGCalTestNumbering::kHGCalCellTypHMask
static const int kHGCalCellTypHMask
Definition: HGCalTestNumbering.h:25
HGCalTestNumbering::kHGCalSubdetHMask
static const int kHGCalSubdetHMask
Definition: HGCalTestNumbering.h:33
HGCalTestNumbering::kHGCalLayerSOffset
static const int kHGCalLayerSOffset
Definition: HGCalTestNumbering.h:17
HGCalTestNumbering::kHGCalSubSectorSOffset
static const int kHGCalSubSectorSOffset
Definition: HGCalTestNumbering.h:15
HGCalTestNumbering::kHGCalZsideHOffset
static const int kHGCalZsideHOffset
Definition: HGCalTestNumbering.h:30
HGCalTestNumbering::packHexagonIndex
static uint32_t packHexagonIndex(int subdet, int z, int lay, int wafer, int celltyp, int cell)
Definition: HGCalTestNumbering.cc:23
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:87
HGCalTestNumbering::kHGCalCellSOffset
static const int kHGCalCellSOffset
Definition: HGCalTestNumbering.h:11
HGCalTestNumbering::kHGCalSectorSOffset
static const int kHGCalSectorSOffset
Definition: HGCalTestNumbering.h:13
HGCalTestNumbering::kHGCalWaferHMask
static const int kHGCalWaferHMask
Definition: HGCalTestNumbering.h:27
HGCalTestNumbering::isValidHexagon
static bool isValidHexagon(int subdet, int z, int lay, int wafer, int celltyp, int cell)
Definition: HGCalTestNumbering.cc:69
HGCalTestNumbering::isValidSquare
static bool isValidSquare(int z, int lay, int sec, int subsec, int cell)
Definition: HGCalTestNumbering.cc:57
HGCalTestNumbering::kHGCalCellTypHOffset
static const int kHGCalCellTypHOffset
Definition: HGCalTestNumbering.h:24
HGCalTestNumbering.h