Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DataFormats_ForwardDetId_HGCTriggerDetId_H
0002 #define DataFormats_ForwardDetId_HGCTriggerDetId_H 1
0003 
0004 #include <iosfwd>
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0007 
0008 class HGCTriggerDetId : public DetId {
0009   // |   DetId           | HGCTriggerDetId
0010   // | 1111     | 111    | 1     | 11111 | 111111 | 111111 | 1111111
0011   // | detector | subdet | zside | layer | sector | mod    | cell
0012   // | 15       | 7      | 2     | 31    |  64    | 64     | 127
0013 
0014   const static uint32_t cell_shift = 0;
0015   const static uint32_t cell_mask = 0x7F;
0016   const static uint32_t module_mask = 0x3F;
0017   const static uint32_t module_shift = 7;
0018   const static uint32_t sector_shift = 13;
0019   const static uint32_t sector_mask = 0x3F;
0020   const static uint32_t layer_shift = 19;
0021   const static uint32_t layer_mask = 0x1F;
0022   const static uint32_t zside_shift = 24;
0023   const static uint32_t zside_mask = 0x1;
0024 
0025   const inline int getMaskedId(const uint32_t& shift, const uint32_t& mask) const { return (id_ >> shift) & mask; }
0026   inline void setMaskedId(const uint32_t value, const uint32_t& shift, const uint32_t& mask) {
0027     id_ |= ((value & mask) << shift);
0028   }
0029 
0030 public:
0031   // undefined cell, for module det id
0032   const static uint32_t UndefinedCell() { return cell_mask; }
0033 
0034   enum { Subdet = HGCTrigger };
0035   /** Create a null cellid*/
0036   HGCTriggerDetId();
0037   virtual ~HGCTriggerDetId() {}
0038   /** Create cellid from raw id (0=invalid tower id) */
0039   HGCTriggerDetId(uint32_t rawid);
0040   /** Constructor from subdetector, zplus, layer, module, cell numbers */
0041   HGCTriggerDetId(ForwardSubdetector subdet, int zp, int lay, int sector, int mod, int cell);
0042   /** Constructor from a generic cell id */
0043   HGCTriggerDetId(const DetId& id);
0044   /** Assignment from a generic cell id */
0045   HGCTriggerDetId& operator=(const DetId& id);
0046 
0047   /** Converter for a geometry cell id
0048    * @param id full EKDetId 
0049    */
0050   //HGCTriggerDetId geometryCell () const {return HGCTriggerDetId (subdet(), zside(), layer(), sector(), 0, 0);}
0051 
0052   /// get the subdetector
0053   ForwardSubdetector subdet() const { return HGCTrigger; }
0054 
0055   /// get the absolute value of the cell #'s in x and y
0056   int cell() const { return getMaskedId(cell_shift, cell_mask); }
0057 
0058   /// get the sector #
0059   int sector() const { return getMaskedId(sector_shift, sector_mask); }
0060 
0061   /// get the degree module
0062   int module() const { return getMaskedId(module_shift, module_mask); }
0063 
0064   /// get the layer #
0065   int layer() const { return getMaskedId(layer_shift, layer_mask); }
0066 
0067   /// get the z-side of the cell (1/-1)
0068   int zside() const { return (getMaskedId(zside_shift, zside_mask) ? 1 : -1); }
0069 
0070   /// consistency check : no bits left => no overhead
0071   bool isEE() const { return true; }
0072   bool isForward() const { return true; }
0073 
0074   static const HGCTriggerDetId Undefined;
0075 };
0076 
0077 std::ostream& operator<<(std::ostream&, const HGCTriggerDetId& id);
0078 
0079 #endif