Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:21

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 /* \brief description of the bit assigment
0009    [0:4]   u-coordinate of the cell (measured from the lower left
0010    [5:9]   v-coordinate of the cell  corner of the wafer)
0011    [10:13] abs(u) of the wafer (u-axis points along -x axis)
0012    [14:14] sign of u (0:+u; 1:-u) (u=0 is at the center of beam line)
0013    [15:18] abs(v) of the wafer (v-axis points 60-degree wrt x-axis)
0014    [19:19] sign of v (0:+v; 1:-v) (v=0 is at the center of beam line)
0015    [20:24] layer number 
0016    [25:25] z-side (0 for +z; 1 for -z)
0017    [26:27] Type (0 fine divisions of wafer with 120 mum thick silicon
0018                  1 coarse divisions of wafer with 200 mum thick silicon
0019                  2 coarse divisions of wafer with 300 mum thick silicon)
0020    [28:31] Detector type (HGCalEE or HGCalHSi)
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   /** Create a null cellid*/
0031   HGCSiliconDetId();
0032   /** Create cellid from raw id (0=invalid tower id) */
0033   HGCSiliconDetId(uint32_t rawid);
0034   /** Constructor from subdetector, zplus, layer, module, cell numbers */
0035   HGCSiliconDetId(DetId::Detector det, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV);
0036   /** Constructor from a generic cell id */
0037   HGCSiliconDetId(const DetId& id);
0038   /** Assignment from a generic cell id */
0039   HGCSiliconDetId& operator=(const DetId& id);
0040 
0041   /** Converter for a geometry cell id */
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   /// get the subdetector
0048   DetId::Detector subdet() const { return det(); }
0049 
0050   /// get the type
0051   int type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }
0052 
0053   /// get the z-side of the cell (1/-1)
0054   int zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); }
0055 
0056   /// get the layer #
0057   int layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }
0058 
0059   /// get the cell #'s in u,v or in x,y
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   /// get the wafer #'s in u,v or in x,y
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   // get trigger cell u,v
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   /// consistency check : no bits left => no overhead
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