-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12703 from bsunanda/Run2-hcx57
bsunanda:Run2-hcx57 Utilize a test numbering scheme for HGCal in SIM step (as in #12572)
- Loading branch information
Showing
7 changed files
with
238 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#ifndef SimDataFormats_HGCalTestNumbering_h | ||
#define SimDataFormats_HGCalTestNumbering_h | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// File: HGCalTestNumbering.h | ||
// Description: Numbering scheme for high granularity calorimeter (SIM step) | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
#include <boost/cstdint.hpp> | ||
|
||
class HGCalTestNumbering { | ||
|
||
public: | ||
static const int kHGCalCellSOffset = 0; | ||
static const int kHGCalCellSMask = 0xFFFF; | ||
static const int kHGCalSectorSOffset = 16; | ||
static const int kHGCalSectorSMask = 0x7F; | ||
static const int kHGCalSubSectorSOffset = 23; | ||
static const int kHGCalSubSectorSMask = 0x1; | ||
static const int kHGCalLayerSOffset = 24; | ||
static const int kHGCalLayerSMask = 0x7F; | ||
static const int kHGCalZsideSOffset = 31; | ||
static const int kHGCalZsideSMask = 0x1; | ||
|
||
static const int kHGCalCellHOffset = 0; | ||
static const int kHGCalCellHMask = 0xFF; | ||
static const int kHGCalCellTypHOffset = 8; | ||
static const int kHGCalCellTypHMask = 0x1; | ||
static const int kHGCalWaferHOffset = 9; | ||
static const int kHGCalWaferHMask = 0x1FF; | ||
static const int kHGCalLayerHOffset = 18; | ||
static const int kHGCalLayerHMask = 0x7F; | ||
static const int kHGCalZsideHOffset = 25; | ||
static const int kHGCalZsideHMask = 0x1; | ||
static const int kHGCalSubdetHOffset = 30; | ||
static const int kHGCalSubdetHMask = 0x7; | ||
HGCalTestNumbering() {} | ||
virtual ~HGCalTestNumbering() {} | ||
static uint32_t packSquareIndex(int z, int lay, int sec, int subsec, | ||
int cell); | ||
static uint32_t packHexagonIndex(int subdet, int z, int lay, int wafer, | ||
int celltyp, int cell); | ||
static void unpackSquareIndex(const uint32_t& idx, 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 bool isValidSquare(int z, int lay, int sec, int subsec, int cell); | ||
static bool isValidHexagon(int subdet, int z, int lay, int wafer, | ||
int celltyp, int cell); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#include "SimDataFormats/CaloTest/interface/HGCalTestNumbering.h" | ||
#include <iostream> | ||
|
||
//#define DebugLog | ||
|
||
uint32_t HGCalTestNumbering::packSquareIndex(int zp, int lay, int sec, | ||
int subsec, int cell) { | ||
|
||
if (cell > kHGCalCellSMask || sec>kHGCalSectorSMask || | ||
subsec > kHGCalSubSectorSMask || lay>kHGCalLayerSMask ) { | ||
#ifdef DebugLog | ||
std::cout << "[HGCalTestNumbering] request for new id for layer=" << lay | ||
<< " zp=" << zp | ||
<< " sector=" << sec | ||
<< " subsec=" << subsec | ||
<< " cell=" << cell | ||
<< " has one or more fields out of bounds and will be reset" | ||
<< std::endl; | ||
#endif | ||
zp = lay = sec = subsec = cell = 0; | ||
} | ||
|
||
uint32_t rawid=0; | ||
rawid |= ((cell & kHGCalCellSMask) << kHGCalCellSOffset); | ||
rawid |= ((sec & kHGCalSectorSMask) << kHGCalSectorSOffset); | ||
if (subsec<0) subsec=0; | ||
rawid |= ((subsec & kHGCalSubSectorSMask) << kHGCalSubSectorSOffset); | ||
rawid |= ((lay & kHGCalLayerSMask) << kHGCalLayerSOffset); | ||
if (zp>0) rawid |= ((zp & kHGCalZsideSMask) << kHGCalZsideSOffset); | ||
return rawid; | ||
} | ||
|
||
uint32_t HGCalTestNumbering::packHexagonIndex(int subdet, int zp, int lay, | ||
int wafer, int celltyp, | ||
int cell) { | ||
|
||
if (cell > kHGCalCellHMask || celltyp>kHGCalCellTypHMask || | ||
wafer > kHGCalWaferHMask || lay>kHGCalLayerSMask || | ||
subdet > kHGCalSubdetHMask) { | ||
#ifdef DebugLog | ||
std::cout << "[HGCalTestNumbering] request for new id for layer=" << lay | ||
<< " zp=" << zp | ||
<< " wafer=" << wafer | ||
<< " celltyp=" << celltyp | ||
<< " cell=" << cell | ||
<< " for subdet=" << subdet | ||
<< " has one or more fields out of bounds and will be reset" | ||
<< std::endl; | ||
#endif | ||
subdet = zp = lay = wafer = celltyp = cell = 0; | ||
} | ||
|
||
uint32_t rawid=0; | ||
rawid |= ((cell & kHGCalCellHMask) << kHGCalCellHOffset); | ||
rawid |= ((celltyp& kHGCalCellTypHMask) << kHGCalCellTypHOffset); | ||
rawid |= ((wafer & kHGCalWaferHMask) << kHGCalWaferHOffset); | ||
rawid |= ((lay & kHGCalLayerHMask) << kHGCalLayerHOffset); | ||
if (zp>0) rawid |= ((zp & kHGCalZsideHMask) << kHGCalZsideHOffset); | ||
rawid |= ((subdet & kHGCalSubdetHMask) << kHGCalSubdetHOffset); | ||
return rawid; | ||
} | ||
|
||
void HGCalTestNumbering::unpackSquareIndex(const uint32_t& idx, int& zp, | ||
int& lay, int& sec, int& subsec, | ||
int& cell) { | ||
|
||
cell = (idx>>kHGCalCellSOffset)&kHGCalCellSMask; | ||
subsec = ((idx>>kHGCalSubSectorSOffset)&kHGCalSubSectorSMask ? 1 : -1); | ||
sec = (idx>>kHGCalSectorSOffset)&kHGCalSectorSMask; | ||
lay = (idx>>kHGCalLayerSOffset)&kHGCalLayerSMask; | ||
zp = ((idx>>kHGCalZsideSOffset) & kHGCalZsideSMask ? 1 : -1); | ||
} | ||
|
||
|
||
void HGCalTestNumbering::unpackHexagonIndex(const uint32_t& idx, int& subdet, | ||
int& zp, int& lay, int& wafer, | ||
int& celltyp, int& cell) { | ||
cell = (idx>>kHGCalCellHOffset)&kHGCalCellHMask; | ||
celltyp= (idx>>kHGCalCellTypHOffset)&kHGCalCellTypHMask; | ||
wafer = (idx>>kHGCalWaferHOffset)&kHGCalWaferHMask; | ||
lay = (idx>>kHGCalLayerHOffset)&kHGCalLayerHMask; | ||
zp = ((idx>>kHGCalZsideHOffset) & kHGCalZsideHMask ? 1 : -1); | ||
subdet = (idx>>kHGCalSubdetHOffset)&kHGCalSubdetHMask; | ||
} | ||
|
||
bool HGCalTestNumbering::isValidSquare(int zp, int lay, int sec, int subsec, | ||
int cell) { | ||
|
||
if (cell > kHGCalCellSMask || sec>kHGCalSectorSMask || | ||
subsec > kHGCalSubSectorSMask || lay>kHGCalLayerSMask ) { | ||
#ifdef DebugLog | ||
std::cout << "[HGCalTestNumbering] request for new id for layer=" << lay | ||
<< " zp=" << zp | ||
<< " sector=" << sec | ||
<< " subsec=" << subsec | ||
<< " cell=" << cell | ||
<< " has one or more fields out of bounds and will be reset" | ||
<< std::endl; | ||
#endif | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
bool HGCalTestNumbering::isValidHexagon(int subdet, int zp, int lay, int wafer, | ||
int celltyp, int cell) { | ||
|
||
if (cell > kHGCalCellHMask || celltyp>kHGCalCellTypHMask || | ||
wafer > kHGCalWaferHMask || lay>kHGCalLayerSMask || | ||
subdet > kHGCalSubdetHMask) { | ||
#ifdef DebugLog | ||
std::cout << "[HGCalTestNumbering] request for new id for layer=" << lay | ||
<< " zp=" << zp | ||
<< " wafer=" << wafer | ||
<< " celltyp=" << celltyp | ||
<< " cell=" << cell | ||
<< " for subdet=" << subdet | ||
<< " has one or more fields out of bounds and will be reset" | ||
<< std::endl; | ||
#endif | ||
return false; | ||
} | ||
return true; | ||
} |
Oops, something went wrong.