Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:48:27

0001 #include "Geometry/HGCalCommonData/interface/HGCalProperty.h"
0002 #include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h"
0003 
0004 int32_t HGCalWaferIndex::waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old) {
0005   int32_t id(0);
0006   if (old) {
0007     id |= (((waferU & HGCalProperty::kHGCalWaferCopyMask) << HGCalProperty::kHGCalWaferCopyOffset) |
0008            ((layer & HGCalProperty::kHGCalLayerMask) << HGCalProperty::kHGCalLayerOffset) |
0009            HGCalProperty::kHGCalLayerOldMask);
0010   } else {
0011     int waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV));
0012     int waferUsign = (waferU >= 0) ? 0 : 1;
0013     int waferVsign = (waferV >= 0) ? 0 : 1;
0014     id |= (((waferUabs & HGCalProperty::kHGCalWaferUMask) << HGCalProperty::kHGCalWaferUOffset) |
0015            ((waferUsign & HGCalProperty::kHGCalWaferUSignMask) << HGCalProperty::kHGCalWaferUSignOffset) |
0016            ((waferVabs & HGCalProperty::kHGCalWaferVMask) << HGCalProperty::kHGCalWaferVOffset) |
0017            ((waferVsign & HGCalProperty::kHGCalWaferVSignMask) << HGCalProperty::kHGCalWaferVSignOffset) |
0018            ((layer & HGCalProperty::kHGCalLayerMask) << HGCalProperty::kHGCalLayerOffset));
0019   }
0020   return id;
0021 }
0022 
0023 int32_t HGCalWaferIndex::waferLayer(const int32_t id) {
0024   return (id >> HGCalProperty::kHGCalLayerOffset) & HGCalProperty::kHGCalLayerMask;
0025 }
0026 
0027 int32_t HGCalWaferIndex::waferU(const int32_t id) {
0028   int32_t iu = (id >> HGCalProperty::kHGCalWaferUOffset) & HGCalProperty::kHGCalWaferUMask;
0029   return (((id >> HGCalProperty::kHGCalWaferUSignOffset) & HGCalProperty::kHGCalWaferUSignMask) ? -iu : iu);
0030 }
0031 
0032 int32_t HGCalWaferIndex::waferV(const int32_t id) {
0033   int32_t iv = (id >> HGCalProperty::kHGCalWaferVOffset) & HGCalProperty::kHGCalWaferVMask;
0034   return (((id >> HGCalProperty::kHGCalWaferVSignOffset) & HGCalProperty::kHGCalWaferVSignMask) ? -iv : iv);
0035 }
0036 
0037 int32_t HGCalWaferIndex::waferCopy(const int32_t id) {
0038   return (id >> HGCalProperty::kHGCalWaferCopyOffset) & HGCalProperty::kHGCalWaferCopyMask;
0039 }
0040 
0041 bool HGCalWaferIndex::waferFormat(const int32_t id) { return ((id & HGCalProperty::kHGCalLayerOldMask) == 0); }