Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-09-12 09:51:31

0001 #ifndef DataFormats_MTDDetId_MTDDetId_h
0002 #define DataFormats_MTDDetId_MTDDetId_h
0003 
0004 #include "DataFormats/DetId/interface/DetId.h"
0005 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0006 #include <ostream>
0007 
0008 /** 
0009     @class MTDDetId
0010     @brief Detector identifier base class for the MIP Timing Layer.
0011 
0012     bit 31-28: Detector Forward
0013     bit 27-25: Subdetctor FastTiming
0014 
0015     bit 24-23: MTD subdetector BTL/ETL
0016     bit 22   : side (positive = 1, negative = 0)
0017     bit 21-16: rod/ring sequential number
0018 
0019 */
0020 
0021 class MTDDetId : public DetId {
0022 public:
0023   /** Enumerated type for Forward sub-deteector systems. */
0024   enum SubDetector { subUNKNOWN = 0, FastTime = 1 };
0025 
0026   /** Enumerated type for MTD sub-deteector systems. */
0027   enum MTDType { typeUNKNOWN = 0, BTL = 1, ETL = 2 };
0028 
0029   static const uint32_t kMTDOffset = 25;
0030   static const uint32_t kMTDsubdOffset = 23;
0031   static const uint32_t kMTDsubdMask = 0x3;
0032   static const uint32_t kZsideOffset = 22;
0033   static const uint32_t kZsideMask = 0x1;
0034   static const uint32_t kRodRingOffset = 16;
0035   static const uint32_t kRodRingMask = 0x3F;
0036 
0037   static constexpr uint32_t kMTDMask = 0x31;  // DetId::Detector::Forward && MTDDetId::SubDetector::FastTime
0038   static constexpr uint32_t kBTLMask = 0xc5;  // isMTD && MTDDetId::MTDType::BTL
0039   static constexpr uint32_t kETLMask = 0xc6;  // isMTD && MTDDetId::MTDType::ETL
0040 
0041   // ---------- Constructors, enumerated types ----------
0042 
0043   /** Construct a null id */
0044   MTDDetId() : DetId() { ; }
0045 
0046   /** Construct from a raw value */
0047   MTDDetId(const uint32_t& raw_id) : DetId(raw_id) { ; }
0048 
0049   /** Construct from generic DetId */
0050   MTDDetId(const DetId& det_id) : DetId(det_id.rawId()) { ; }
0051 
0052   /** Construct and fill only the det and sub-det fields. */
0053   MTDDetId(Detector det, int subdet) : DetId(det, subdet) { ; }
0054 
0055   // ---------- Common methods ----------
0056 
0057   /** Returns enumerated type specifying MTD sub-detector. */
0058   inline SubDetector subDetector() const { return static_cast<MTDDetId::SubDetector>(subdetId()); }
0059 
0060   /** Returns enumerated type specifying MTD sub-detector, i.e. BTL or ETL. */
0061   inline int mtdSubDetector() const { return (id_ >> kMTDsubdOffset) & kMTDsubdMask; }
0062 
0063   static inline bool const testForMTD(const DetId& id) {
0064     return (id.rawId() >> MTDDetId::kMTDOffset) == MTDDetId::kMTDMask;
0065   }
0066   static inline bool const testForBTL(const DetId& id) {
0067     return (id.rawId() >> MTDDetId::kMTDsubdOffset) == MTDDetId::kBTLMask;
0068   }
0069   static inline bool const testForETL(const DetId& id) {
0070     return (id.rawId() >> MTDDetId::kMTDsubdOffset) == MTDDetId::kETLMask;
0071   }
0072 
0073   /** Returns MTD side, i.e. Z-=0 or Z+=1. */
0074   inline int mtdSide() const { return (id_ >> kZsideOffset) & kZsideMask; }
0075   /** Return MTD side, i.e. Z-=-1 or Z+=1. */
0076   inline int zside() const { return (mtdSide() == 1 ? (1) : (-1)); }
0077 
0078   /** Returns MTD rod/ring number. */
0079   inline int mtdRR() const { return (id_ >> kRodRingOffset) & kRodRingMask; }
0080 };
0081 
0082 std::ostream& operator<<(std::ostream&, const MTDDetId&);
0083 
0084 #endif  // DataFormats_MTDDetId_MTDDetId_h