File indexing completed on 2023-03-17 10:49:47
0001 #ifndef DataFormats_ForwardDetId_HGCSiliconDetId_H
0002 #define DataFormats_ForwardDetId_HGCSiliconDetId_H 1
0003
0004 #include <iosfwd>
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 class HGCSiliconDetId : public DetId {
0023 public:
0024 enum waferType { HGCalFine = 0, HGCalCoarseThin = 1, HGCalCoarseThick = 2 };
0025 static const int HGCalFineN = 12;
0026 static const int HGCalCoarseN = 8;
0027 static const int HGCalFineTrigger = 3;
0028 static const int HGCalCoarseTrigger = 2;
0029
0030
0031 HGCSiliconDetId();
0032
0033 HGCSiliconDetId(uint32_t rawid);
0034
0035 HGCSiliconDetId(DetId::Detector det, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV);
0036
0037 HGCSiliconDetId(const DetId& id);
0038
0039 HGCSiliconDetId& operator=(const DetId& id);
0040
0041
0042 HGCSiliconDetId geometryCell() const { return HGCSiliconDetId(det(), zside(), 0, layer(), waferU(), waferV(), 0, 0); }
0043 HGCSiliconDetId moduleId() const {
0044 return HGCSiliconDetId(det(), zside(), type(), layer(), waferU(), waferV(), 0, 0);
0045 }
0046
0047
0048 DetId::Detector subdet() const { return det(); }
0049
0050
0051 int type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }
0052
0053
0054 int zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); }
0055
0056
0057 int layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }
0058
0059
0060 int cellU() const { return (id_ >> kHGCalCellUOffset) & kHGCalCellUMask; }
0061 int cellV() const { return (id_ >> kHGCalCellVOffset) & kHGCalCellVMask; }
0062 std::pair<int, int> cellUV() const { return std::pair<int, int>(cellU(), cellV()); }
0063 int cellX() const {
0064 int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN;
0065 return (3 * (cellV() - N) + 2);
0066 }
0067 int cellY() const {
0068 int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN;
0069 return (2 * cellU() - (N + cellV()));
0070 }
0071 std::pair<int, int> cellXY() const { return std::pair<int, int>(cellX(), cellY()); }
0072
0073
0074 int waferUAbs() const { return (id_ >> kHGCalWaferUOffset) & kHGCalWaferUMask; }
0075 int waferVAbs() const { return (id_ >> kHGCalWaferVOffset) & kHGCalWaferVMask; }
0076 int waferU() const { return (((id_ >> kHGCalWaferUSignOffset) & kHGCalWaferUSignMask) ? -waferUAbs() : waferUAbs()); }
0077 int waferV() const { return (((id_ >> kHGCalWaferVSignOffset) & kHGCalWaferVSignMask) ? -waferVAbs() : waferVAbs()); }
0078 std::pair<int, int> waferUV() const { return std::pair<int, int>(waferU(), waferV()); }
0079 int waferX() const { return (-2 * waferU() + waferV()); }
0080 int waferY() const { return (2 * waferV()); }
0081 std::pair<int, int> waferXY() const { return std::pair<int, int>(waferX(), waferY()); }
0082
0083
0084 int triggerCellU() const {
0085 int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN;
0086 int NT = (type() == HGCalFine) ? HGCalFineTrigger : HGCalCoarseTrigger;
0087 return (cellU() >= N && cellV() >= N)
0088 ? cellU() / NT
0089 : ((cellU() < N && cellU() <= cellV()) ? cellU() / NT : (1 + (cellU() - (cellV() % NT + 1)) / NT));
0090 }
0091 int triggerCellV() const {
0092 int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN;
0093 int NT = (type() == HGCalFine) ? HGCalFineTrigger : HGCalCoarseTrigger;
0094 return (cellU() >= N && cellV() >= N)
0095 ? cellV() / NT
0096 : ((cellU() < N && cellU() <= cellV()) ? ((cellV() - cellU()) / NT + cellU() / NT) : cellV() / NT);
0097 }
0098 std::pair<int, int> triggerCellUV() const { return std::pair<int, int>(triggerCellU(), triggerCellV()); }
0099
0100
0101 bool isEE() const { return (det() == HGCalEE); }
0102 bool isHE() const { return (det() == HGCalHSi); }
0103 bool isForward() const { return true; }
0104
0105 static const HGCSiliconDetId Undefined;
0106
0107 public:
0108 static const int kHGCalCellUOffset = 0;
0109 static const int kHGCalCellUMask = 0x1F;
0110 static const int kHGCalCellVOffset = 5;
0111 static const int kHGCalCellVMask = 0x1F;
0112 static const int kHGCalWaferUOffset = 10;
0113 static const int kHGCalWaferUMask = 0xF;
0114 static const int kHGCalWaferUSignOffset = 14;
0115 static const int kHGCalWaferUSignMask = 0x1;
0116 static const int kHGCalWaferVOffset = 15;
0117 static const int kHGCalWaferVMask = 0xF;
0118 static const int kHGCalWaferVSignOffset = 19;
0119 static const int kHGCalWaferVSignMask = 0x1;
0120 static const int kHGCalLayerOffset = 20;
0121 static const int kHGCalLayerMask = 0x1F;
0122 static const int kHGCalZsideOffset = 25;
0123 static const int kHGCalZsideMask = 0x1;
0124 static const int kHGCalTypeOffset = 26;
0125 static const int kHGCalTypeMask = 0x3;
0126 };
0127
0128 std::ostream& operator<<(std::ostream&, const HGCSiliconDetId& id);
0129
0130 #endif