Back to home page

Project CMSSW displayed by LXR

 
 

    


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 /* \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:22] layer number - 1
0016    [23:23] z-side (0 for +z; 1 for -z)
0017    [24:24] Type (0 fine divisions of wafer with 120 mum thick silicon
0018                  1 coarse divisions of wafer with 200 mum thick silicon)
0019    [25:27] Subdetector type (HFNose)
0020    [28:31] Detector type (Forward)
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   /** Create a null cellid*/
0032   HFNoseDetId();
0033   /** Create cellid from raw id (0=invalid tower id) */
0034   HFNoseDetId(uint32_t rawid);
0035   /** Constructor from subdetector, zplus, layer, module, cell numbers */
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   /** Constructor from a generic cell id */
0039   HFNoseDetId(const DetId& id);
0040   /** Assignment from a generic cell id */
0041   HFNoseDetId& operator=(const DetId& id);
0042 
0043   /// get the subdetector
0044   ForwardSubdetector subdet() const { return HFNose; }
0045 
0046   /** Converter for a geometry cell id */
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   /// get the type
0051   int type() const { return (id_ >> kHFNoseTypeOffset) & kHFNoseTypeMask; }
0052 
0053   /// get the z-side of the cell (1/-1)
0054   int zside() const { return (((id_ >> kHFNoseZsideOffset) & kHFNoseZsideMask) ? -1 : 1); }
0055 
0056   /// get the layer #
0057   int layer() const { return ((id_ >> kHFNoseLayerOffset) & kHFNoseLayerMask) + 1; }
0058 
0059   /// get the cell #'s in u,v or in x,y
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   /// get the wafer #'s in u,v or in x,y
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   // get trigger cell u,v
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   /// consistency check : no bits left => no overhead
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