Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:49:46

0001 #ifndef DataFormats_BTLDetId_BTLDetId_h
0002 #define DataFormats_BTLDetId_BTLDetId_h
0003 
0004 #include "DataFormats/ForwardDetId/interface/MTDDetId.h"
0005 #include <ostream>
0006 #include <array>
0007 
0008 /** 
0009     @class BTLDetId
0010     @brief Detector identifier class for the Barrel Timing Layer.
0011     The crystal count must start from 0, copy number must be scaled by 1 unit.
0012 
0013     bit 15-10: module sequential number
0014     bit 9-8  : crystal type (1 - 3)
0015     bit 7-6  : readout unit sequential number within a type ( 1 - 2 )
0016     bit 5-0  : crystal sequential number within a module ( 0 - 15 )
0017 */
0018 
0019 class BTLDetId : public MTDDetId {
0020 public:
0021   static constexpr uint32_t kBTLmoduleOffset = 10;
0022   static constexpr uint32_t kBTLmoduleMask = 0x3F;
0023   static constexpr uint32_t kBTLmodTypeOffset = 8;
0024   static constexpr uint32_t kBTLmodTypeMask = 0x3;
0025   static constexpr uint32_t kBTLRUOffset = 6;
0026   static constexpr uint32_t kBTLRUMask = 0x3;
0027   static constexpr uint32_t kBTLCrystalOffset = 0;
0028   static constexpr uint32_t kBTLCrystalMask = 0x3F;
0029 
0030   /// range constants, need two sets for the time being (one for tiles and one for bars)
0031   static constexpr uint32_t HALF_ROD = 36;
0032   static constexpr uint32_t kModulesPerRODBarPhiFlat = 48;
0033   static constexpr uint32_t kModulePerTypeBarPhiFlat = 48 / 3;
0034   static constexpr uint32_t kRUPerTypeV2 = 2;
0035   static constexpr uint32_t kModulesPerRUV2 = 24;
0036   static constexpr uint32_t kCrystalsPerModuleV2 = 16;
0037   static constexpr uint32_t kModulesPerTrkV2 = 3;
0038   static constexpr uint32_t kCrystalTypes = 3;
0039 
0040   // Number of crystals in BTL according to TDR design, valid also for barphiflat scenario:
0041   // 16 crystals x 24 modules x 2 readout units/type x 3 types x 36 rods/side x 2 sides
0042   //
0043   static constexpr uint32_t kCrystalsBTL =
0044       kCrystalsPerModuleV2 * kModulesPerRUV2 * kRUPerTypeV2 * kCrystalTypes * HALF_ROD * 2;
0045 
0046   enum class CrysLayout { tile = 1, bar = 2, barzflat = 3, barphiflat = 4, v2 = 5 };
0047 
0048   // ---------- Constructors, enumerated types ----------
0049 
0050   /** Construct a null id */
0051   BTLDetId() : MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) {
0052     id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset;
0053   }
0054 
0055   /** Construct from a raw value */
0056   BTLDetId(const uint32_t& raw_id) : MTDDetId(raw_id) { ; }
0057 
0058   /** Construct from generic DetId */
0059   BTLDetId(const DetId& det_id) : MTDDetId(det_id.rawId()) { ; }
0060 
0061   /** Construct from complete geometry information, v1 **/
0062   BTLDetId(uint32_t zside, uint32_t rod, uint32_t module, uint32_t modtyp, uint32_t crystal)
0063       : MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) {
0064     id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset | (zside & kZsideMask) << kZsideOffset |
0065            (rod & kRodRingMask) << kRodRingOffset | (module & kBTLmoduleMask) << kBTLmoduleOffset |
0066            (modtyp & kBTLmodTypeMask) << kBTLmodTypeOffset | ((crystal - 1) & kBTLCrystalMask) << kBTLCrystalOffset;
0067   }
0068 
0069   /** Construct from complete geometry information, v2 **/
0070   BTLDetId(uint32_t zside, uint32_t rod, uint32_t runit, uint32_t module, uint32_t modtyp, uint32_t crystal)
0071       : MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) {
0072     id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset | (zside & kZsideMask) << kZsideOffset |
0073            (rod & kRodRingMask) << kRodRingOffset | (module & kBTLmoduleMask) << kBTLmoduleOffset |
0074            (modtyp & kBTLmodTypeMask) << kBTLmodTypeOffset | (runit & kBTLRUMask) << kBTLRUOffset |
0075            ((crystal - 1) & kBTLCrystalMask) << kBTLCrystalOffset;
0076   }
0077 
0078   // ---------- Common methods ----------
0079 
0080   /** Returns BTL module number. */
0081   inline int module() const { return (id_ >> kBTLmoduleOffset) & kBTLmoduleMask; }
0082 
0083   /** Returns BTL crystal type number. */
0084   inline int modType() const { return (id_ >> kBTLmodTypeOffset) & kBTLmodTypeMask; }
0085 
0086   /** Returns BTL crystal number. */
0087   inline int crystal() const { return ((id_ >> kBTLCrystalOffset) & kBTLCrystalMask) + 1; }
0088 
0089   /** Returns BTL readout unit number per type. */
0090   inline int runit() const { return (id_ >> kBTLRUOffset) & kBTLRUMask; }
0091 
0092   /** return the row in GeomDet language **/
0093   inline int row(unsigned nrows = kCrystalsPerModuleV2) const {
0094     return (crystal() - 1) % nrows;  // anything else for now
0095   }
0096 
0097   /** return the column in GeomDetLanguage **/
0098   inline int column(unsigned nrows = kCrystalsPerModuleV2) const { return (crystal() - 1) / nrows; }
0099 
0100   /** create a Geographical DetId for Tracking **/
0101   BTLDetId geographicalId(CrysLayout lay) const;
0102 };
0103 
0104 std::ostream& operator<<(std::ostream&, const BTLDetId&);
0105 
0106 #endif  // DataFormats_BTLDetId_BTLDetId_h