Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:08

0001 #ifndef DataFormats_ForwardDetId_HGCalDetId_H
0002 #define DataFormats_ForwardDetId_HGCalDetId_H 1
0003 
0004 #include <iosfwd>
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0007 
0008 class HGCalDetId : public DetId {
0009 public:
0010   static const int kHGCalCellOffset = 0;
0011   static const int kHGCalCellMask = 0xFF;
0012   static const int kHGCalWaferOffset = 8;
0013   static const int kHGCalWaferMask = 0x3FF;
0014   static const int kHGCalWaferTypeOffset = 18;
0015   static const int kHGCalWaferTypeMask = 0x1;
0016   static const int kHGCalLayerOffset = 19;
0017   static const int kHGCalLayerMask = 0x1F;
0018   static const int kHGCalZsideOffset = 24;
0019   static const int kHGCalZsideMask = 0x1;
0020   static const int kHGCalMaskCell = 0xFFFBFF00;
0021 
0022   /** Create a null cellid*/
0023   HGCalDetId();
0024   /** Create cellid from raw id (0=invalid tower id) */
0025   HGCalDetId(uint32_t rawid);
0026   /** Constructor from subdetector, zplus, layer, module, cell numbers */
0027   HGCalDetId(ForwardSubdetector subdet, int zp, int lay, int wafertype, int wafer, int cell);
0028   /** Constructor from a generic cell id */
0029   HGCalDetId(const DetId& id);
0030   /** Assignment from a generic cell id */
0031   HGCalDetId& operator=(const DetId& id);
0032 
0033   /** Converter for a geometry cell id */
0034   HGCalDetId geometryCell() const { return HGCalDetId(id_ & static_cast<uint32_t>(kHGCalMaskCell)); }
0035 
0036   /// get the absolute value of the cell #'s in x and y
0037   int cell() const { return id_ & kHGCalCellMask; }
0038 
0039   /// get the wafer #
0040   int wafer() const { return (id_ >> kHGCalWaferOffset) & kHGCalWaferMask; }
0041 
0042   /// get the wafer type
0043   int waferType() const { return ((id_ >> kHGCalWaferTypeOffset) & kHGCalWaferTypeMask ? 1 : -1); }
0044 
0045   /// get the layer #
0046   int layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }
0047 
0048   /// get the z-side of the cell (1/-1)
0049   int zside() const { return ((id_ >> kHGCalZsideOffset) & kHGCalZsideMask ? 1 : -1); }
0050 
0051   /// consistency check : no bits left => no overhead
0052   bool isHGCal() const { return true; }
0053   bool isForward() const { return true; }
0054   static bool isValid(ForwardSubdetector subdet, int zp, int lay, int wafertype, int wafer, int cell);
0055 
0056   static const HGCalDetId Undefined;
0057 };
0058 
0059 std::ostream& operator<<(std::ostream&, const HGCalDetId& id);
0060 
0061 #endif