File indexing completed on 2024-04-06 12:04:07
0001 #ifndef DataFormats_ForwardDetId_HFNoseDetId_H
0002 #define DataFormats_ForwardDetId_HFNoseDetId_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 HFNoseDetId : public DetId {
0023 public:
0024 enum hfNoseWaferType { HFNoseFine = 0, HFNoseCoarseThin = 1, HFNoseCoarseThick = 2 };
0025 static const int HFNoseFineN = 12;
0026 static const int HFNoseCoarseN = 8;
0027 static const int HFNoseFineTrigger = 3;
0028 static const int HFNoseCoarseTrigger = 2;
0029 static const int HFNoseLayerEEmax = 6;
0030
0031
0032 HFNoseDetId();
0033
0034 HFNoseDetId(uint32_t rawid);
0035
0036 HFNoseDetId(DetId::Detector det, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV);
0037 HFNoseDetId(int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV);
0038
0039 HFNoseDetId(const DetId& id);
0040
0041 HFNoseDetId& operator=(const DetId& id);
0042
0043
0044 ForwardSubdetector subdet() const { return HFNose; }
0045
0046
0047 HFNoseDetId geometryCell() const { return HFNoseDetId(zside(), 0, layer(), waferU(), waferV(), 0, 0); }
0048 HFNoseDetId moduleId() const { return HFNoseDetId(zside(), type(), layer(), waferU(), waferV(), 0, 0); }
0049
0050
0051 int type() const { return (id_ >> kHFNoseTypeOffset) & kHFNoseTypeMask; }
0052
0053
0054 int zside() const { return (((id_ >> kHFNoseZsideOffset) & kHFNoseZsideMask) ? -1 : 1); }
0055
0056
0057 int layer() const { return ((id_ >> kHFNoseLayerOffset) & kHFNoseLayerMask) + 1; }
0058
0059
0060 int cellU() const { return (id_ >> kHFNoseCellUOffset) & kHFNoseCellUMask; }
0061 int cellV() const { return (id_ >> kHFNoseCellVOffset) & kHFNoseCellVMask; }
0062 std::pair<int, int> cellUV() const { return std::pair<int, int>(cellU(), cellV()); }
0063 int cellX() const {
0064 int N = (type() == HFNoseFine) ? HFNoseFineN : HFNoseCoarseN;
0065 return (3 * (cellV() - N) + 2);
0066 }
0067 int cellY() const {
0068 int N = (type() == HFNoseFine) ? HFNoseFineN : HFNoseCoarseN;
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_ >> kHFNoseWaferUOffset) & kHFNoseWaferUMask; }
0075 int waferVAbs() const { return (id_ >> kHFNoseWaferVOffset) & kHFNoseWaferVMask; }
0076 int waferU() const {
0077 return (((id_ >> kHFNoseWaferUSignOffset) & kHFNoseWaferUSignMask) ? -waferUAbs() : waferUAbs());
0078 }
0079 int waferV() const {
0080 return (((id_ >> kHFNoseWaferVSignOffset) & kHFNoseWaferVSignMask) ? -waferVAbs() : waferVAbs());
0081 }
0082 std::pair<int, int> waferUV() const { return std::pair<int, int>(waferU(), waferV()); }
0083 int waferX() const { return (-2 * waferU() + waferV()); }
0084 int waferY() const { return (2 * waferV()); }
0085 std::pair<int, int> waferXY() const { return std::pair<int, int>(waferX(), waferY()); }
0086
0087
0088 int triggerCellU() const {
0089 int N = (type() == HFNoseFine) ? HFNoseFineN : HFNoseCoarseN;
0090 int NT = (type() == HFNoseFine) ? HFNoseFineTrigger : HFNoseCoarseTrigger;
0091 return (cellU() >= N && cellV() >= N)
0092 ? cellU() / NT
0093 : ((cellU() < N && cellU() <= cellV()) ? cellU() / NT : (1 + (cellU() - (cellV() % NT + 1)) / NT));
0094 }
0095 int triggerCellV() const {
0096 int N = (type() == HFNoseFine) ? HFNoseFineN : HFNoseCoarseN;
0097 int NT = (type() == HFNoseFine) ? HFNoseFineTrigger : HFNoseCoarseTrigger;
0098 return (cellU() >= N && cellV() >= N)
0099 ? cellV() / NT
0100 : ((cellU() < N && cellU() <= cellV()) ? ((cellV() - cellU()) / NT + cellU() / NT) : cellV() / NT);
0101 }
0102 std::pair<int, int> triggerCellUV() const { return std::pair<int, int>(triggerCellU(), triggerCellV()); }
0103
0104
0105 bool isEE() const { return (layer() <= HFNoseLayerEEmax); }
0106 bool isHE() const { return (layer() > HFNoseLayerEEmax); }
0107 bool isForward() const { return true; }
0108
0109 static const HFNoseDetId Undefined;
0110
0111 private:
0112 static const int kHFNoseCellUOffset = 0;
0113 static const int kHFNoseCellUMask = 0x1F;
0114 static const int kHFNoseCellVOffset = 5;
0115 static const int kHFNoseCellVMask = 0x1F;
0116 static const int kHFNoseWaferUOffset = 10;
0117 static const int kHFNoseWaferUMask = 0xF;
0118 static const int kHFNoseWaferUSignOffset = 14;
0119 static const int kHFNoseWaferUSignMask = 0x1;
0120 static const int kHFNoseWaferVOffset = 15;
0121 static const int kHFNoseWaferVMask = 0xF;
0122 static const int kHFNoseWaferVSignOffset = 19;
0123 static const int kHFNoseWaferVSignMask = 0x1;
0124 static const int kHFNoseLayerOffset = 20;
0125 static const int kHFNoseLayerMask = 0x7;
0126 static const int kHFNoseZsideOffset = 23;
0127 static const int kHFNoseZsideMask = 0x1;
0128 static const int kHFNoseTypeOffset = 24;
0129 static const int kHFNoseTypeMask = 0x1;
0130 };
0131
0132 std::ostream& operator<<(std::ostream&, const HFNoseDetId& id);
0133
0134 #endif