Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DataFormats_ForwardDetId_HGCalTriggerBackendDetId_H
0002 #define DataFormats_ForwardDetId_HGCalTriggerBackendDetId_H 1
0003 
0004 #include "DataFormats/DetId/interface/DetId.h"
0005 #include "DataFormats/ForwardDetId/interface/HGCalTriggerBackendCommon.h"
0006 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0007 
0008 /* \brief description of the bit assigment
0009    [0:10]  ID of the lpGBT or Stage 1 FPGA in sector 0 
0010    [11:12] sector (0,1,2 counter-clockwise from u-axis)
0011    [13:15] Type (0 lpGBT
0012                  1 Stage 1 FPGA
0013                  2 Stage 1 link
0014                  3 Stage 2 FPGA)
0015    [16:16] z-side (0 for +z; 1 for -z)
0016    [19:23] reserved for future use
0017    [24:24] Class identifier (0 for HGCalTriggerModuleDetID, 1 for HGCalTriggerBackendDetID)
0018    [25:27] Subdetector Type (HGCTrigger)
0019    [28:31] Detector type (Forward)
0020 */
0021 
0022 class HGCalTriggerBackendDetId : public DetId {
0023 public:
0024   /** Create a null backend id*/
0025   HGCalTriggerBackendDetId();
0026   /** Create backend id from raw id (0=invalid id) */
0027   HGCalTriggerBackendDetId(uint32_t rawid);
0028   /** Constructor from zplus, type, sector, label */
0029   HGCalTriggerBackendDetId(int zp, int type, int sector, int label);
0030   /** Constructor from a generic det id */
0031   HGCalTriggerBackendDetId(const DetId& id);
0032   /** Assignment from a generic det id */
0033   HGCalTriggerBackendDetId& operator=(const DetId& id);
0034 
0035   /// get the class
0036   int classId() const { return (id_ >> kHGCalTriggerClassIdentifierOffset) & kHGCalTriggerClassIdentifierMask; }
0037 
0038   /// get the type
0039   int type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }
0040 
0041   /// get the z-side of the backend object (1/-1)
0042   int zside() const { return ((id_ >> kHGCalZsideOffset) & kHGCalZsideMask ? -1 : 1); }
0043 
0044   /// get the sector #
0045   int sector() const { return (id_ >> kHGCalSectorOffset) & kHGCalSectorMask; }
0046 
0047   /// get the value
0048   int label() const { return (id_ >> kHGCalLabelOffset) & kHGCalLabelMask; }
0049 
0050   bool isLpGBT() const { return (type() == BackendType::LpGBT); }
0051   bool isStage1FPGA() const { return (type() == BackendType::Stage1FPGA); }
0052   bool isStage1Link() const { return (type() == BackendType::Stage1Link); }
0053   bool isStage2FPGA() const { return (type() == BackendType::Stage2FPGA); }
0054   bool isForward() const { return true; }
0055   bool isHGCalModuleDetId() const { return (classId() == HGCalTriggerClassIdentifier::ModuleDetId); }
0056   bool isHGCalBackendDetId() const { return (classId() == HGCalTriggerClassIdentifier::BackendDetId); }
0057 
0058   static const HGCalTriggerBackendDetId Undefined;
0059 
0060   static const int kHGCalLabelOffset = 0;
0061   static const int kHGCalLabelMask = 0x7FF;
0062   static const int kHGCalSectorOffset = 11;
0063   static const int kHGCalSectorMask = 0x3;
0064   static const int kHGCalTypeOffset = 13;
0065   static const int kHGCalTypeMask = 0x7;
0066   static const int kHGCalZsideOffset = 16;
0067   static const int kHGCalZsideMask = 0x1;
0068   static const int kHGCalTriggerClassIdentifierOffset = 24;
0069   static const int kHGCalTriggerClassIdentifierMask = 0x1;
0070 
0071   enum BackendType { LpGBT, Stage1FPGA, Stage1Link, Stage2FPGA };
0072 };
0073 
0074 std::ostream& operator<<(std::ostream&, const HGCalTriggerBackendDetId& id);
0075 
0076 #endif