Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-02 00:53:32

0001 #ifndef DataFormats_ForwardDetId_HGCalTriggerDetId_H
0002 #define DataFormats_ForwardDetId_HGCalTriggerDetId_H 1
0003 
0004 #include <iosfwd>
0005 #include <vector>
0006 #include "DataFormats/DetId/interface/DetId.h"
0007 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0008 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0009 
0010 /* \brief description of the bit assigment
0011    [0:3]   u-coordinate of the cell (measured from the lower left
0012    [4:7]   v-coordinate of the cell  corner of the wafer)
0013    [8:11]  abs(u) of the wafer (u-axis points along -x axis)
0014    [12:12] sign of u (0:+u; 1:-u) (u=0 is at the center of beam line)
0015    [13:16] abs(v) of the wafer (v-axis points 60-degree wrt x-axis)
0016    [17:17] sign of v (0:+v; 1:-v) (v=0 is at the center of beam line)
0017    [18:22] layer number 
0018    [23:24] Type (0 high density wafer with depltetion thickness of 120 mum
0019                  1 low density wafer with depletion thickness of 200 mum
0020                  2 low density wafer with depletion thickness of 300 mum
0021                  3 high density wafer with depletion thickness of 200 mum)
0022    [25:26] Subdetector Type (HGCalEETrigger/HGCalHSiTrigger)
0023    [27:27] z-side (0 for +z; 1 for -z)
0024    [28:31] Detector type (HGCalTrigger)
0025 */
0026 
0027 class HGCalTriggerDetId : public DetId {
0028 public:
0029   static const int HGCalTriggerCell = 4;
0030 
0031   /** Create a null cellid*/
0032   HGCalTriggerDetId();
0033   /** Create cellid from raw id (0=invalid tower id) */
0034   HGCalTriggerDetId(uint32_t rawid);
0035   /** Constructor from subdetector, zplus, layer, module, cell numbers */
0036   HGCalTriggerDetId(int subdet, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV);
0037   /** Constructor from a generic cell id */
0038   HGCalTriggerDetId(const DetId& id);
0039   /** Assignment from a generic cell id */
0040   HGCalTriggerDetId& operator=(const DetId& id);
0041 
0042   /// get the subdetector
0043   HGCalTriggerSubdetector subdet() const {
0044     return (HGCalTriggerSubdetector)((id_ >> kHGCalSubdetOffset) & kHGCalSubdetMask);
0045   }
0046 
0047   /// get the type
0048   int type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }
0049 
0050   /// get the z-side of the cell (1/-1)
0051   int zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); }
0052 
0053   /// get the layer #
0054   int layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }
0055 
0056   /** Converter for a geometry cell id */
0057   HGCSiliconDetId geometryCell() const { return HGCSiliconDetId(det(), zside(), 0, layer(), waferU(), waferV(), 0, 0); }
0058   HGCSiliconDetId moduleId() const {
0059     return HGCSiliconDetId(det(), zside(), type(), layer(), waferU(), waferV(), 0, 0);
0060   }
0061 
0062   /// get the cell #'s in u,v or in x,y
0063   int triggerCellU() const { return (id_ >> kHGCalCellUOffset) & kHGCalCellUMask; }
0064   int triggerCellV() const { return (id_ >> kHGCalCellVOffset) & kHGCalCellVMask; }
0065   std::pair<int, int> triggerCellUV() const { return std::pair<int, int>(triggerCellU(), triggerCellV()); }
0066   int triggerCellX() const;
0067   int triggerCellY() const;
0068   std::pair<int, int> triggerCellXY() const { return std::pair<int, int>(triggerCellX(), triggerCellY()); }
0069 
0070   /// get the wafer #'s in u,v or in x,y
0071   int waferUAbs() const { return (id_ >> kHGCalWaferUOffset) & kHGCalWaferUMask; }
0072   int waferVAbs() const { return (id_ >> kHGCalWaferVOffset) & kHGCalWaferVMask; }
0073   int waferU() const { return (((id_ >> kHGCalWaferUSignOffset) & kHGCalWaferUSignMask) ? -waferUAbs() : waferUAbs()); }
0074   int waferV() const { return (((id_ >> kHGCalWaferVSignOffset) & kHGCalWaferVSignMask) ? -waferVAbs() : waferVAbs()); }
0075   std::pair<int, int> waferUV() const { return std::pair<int, int>(waferU(), waferV()); }
0076   int waferX() const { return (-2 * waferU() + waferV()); }
0077   int waferY() const { return (2 * waferV()); }
0078   std::pair<int, int> waferXY() const { return std::pair<int, int>(waferX(), waferY()); }
0079 
0080   // get trigger cell u,v
0081   std::vector<int> cellU() const;
0082   std::vector<int> cellV() const;
0083   std::vector<std::pair<int, int> > cellUV() const;
0084 
0085   /// consistency check : no bits left => no overhead
0086   bool isEE() const { return (subdet() == HGCalEETrigger); }
0087   bool isHSilicon() const { return (subdet() == HGCalHSiTrigger); }
0088   bool isForward() const { return true; }
0089 
0090   static const HGCalTriggerDetId Undefined;
0091 
0092   static const int kHGCalCellUOffset = 0;
0093   static const int kHGCalCellUMask = 0xF;
0094   static const int kHGCalCellVOffset = 4;
0095   static const int kHGCalCellVMask = 0xF;
0096   static const int kHGCalWaferUOffset = 8;
0097   static const int kHGCalWaferUMask = 0xF;
0098   static const int kHGCalWaferUSignOffset = 12;
0099   static const int kHGCalWaferUSignMask = 0x1;
0100   static const int kHGCalWaferVOffset = 13;
0101   static const int kHGCalWaferVMask = 0xF;
0102   static const int kHGCalWaferVSignOffset = 17;
0103   static const int kHGCalWaferVSignMask = 0x1;
0104   static const int kHGCalLayerOffset = 18;
0105   static const int kHGCalLayerMask = 0x1F;
0106   static const int kHGCalTypeOffset = 23;
0107   static const int kHGCalTypeMask = 0x3;
0108   static const int kHGCalZsideOffset = 27;
0109   static const int kHGCalZsideMask = 0x1;
0110   static const int kHGCalSubdetOffset = 25;
0111   static const int kHGCalSubdetMask = 0x3;
0112 };
0113 
0114 std::ostream& operator<<(std::ostream&, const HGCalTriggerDetId& id);
0115 
0116 #endif