Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-12 02:58:07

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-0  : crystal sequential number within a module ( 0 - 63 )
0016 */
0017 
0018 class BTLDetId : public MTDDetId {
0019 public:
0020   static constexpr uint32_t kBTLmoduleOffset = 10;
0021   static constexpr uint32_t kBTLmoduleMask = 0x3F;
0022   static constexpr uint32_t kBTLmodTypeOffset = 8;
0023   static constexpr uint32_t kBTLmodTypeMask = 0x3;
0024   static constexpr uint32_t kBTLCrystalOffset = 0;
0025   static constexpr uint32_t kBTLCrystalMask = 0x3F;
0026 
0027   /// range constants, need two sets for the time being (one for tiles and one for bars)
0028   static constexpr uint32_t HALF_ROD = 36;
0029   static constexpr uint32_t kModulesPerRODBarPhiFlat = 48;
0030   static constexpr uint32_t kModulePerTypeBarPhiFlat = 48 / 3;
0031   static constexpr uint32_t kCrystalsPerModuleTdr = 16;
0032 
0033   // Number of crystals in BTL according to TDR design, valid also for barphiflat scenario:
0034   // 16 crystals x 24 modules x 6 readout units x 36 rods/side x 2 sides
0035   //
0036   static constexpr uint32_t kCrystalsBTL = kCrystalsPerModuleTdr * 24 * 6 * HALF_ROD * 2;
0037 
0038   enum class CrysLayout { tile = 1, bar = 2, barzflat = 3, barphiflat = 4, tdr = 5 };
0039 
0040   // ---------- Constructors, enumerated types ----------
0041 
0042   /** Construct a null id */
0043   BTLDetId() : MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) {
0044     id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset;
0045   }
0046 
0047   /** Construct from a raw value */
0048   BTLDetId(const uint32_t& raw_id) : MTDDetId(raw_id) { ; }
0049 
0050   /** Construct from generic DetId */
0051   BTLDetId(const DetId& det_id) : MTDDetId(det_id.rawId()) { ; }
0052 
0053   /** Construct and fill only the det and sub-det fields. */
0054   BTLDetId(uint32_t zside, uint32_t rod, uint32_t module, uint32_t modtyp, uint32_t crystal)
0055       : MTDDetId(DetId::Forward, ForwardSubdetector::FastTime) {
0056     id_ |= (MTDType::BTL & kMTDsubdMask) << kMTDsubdOffset | (zside & kZsideMask) << kZsideOffset |
0057            (rod & kRodRingMask) << kRodRingOffset | (module & kBTLmoduleMask) << kBTLmoduleOffset |
0058            (modtyp & kBTLmodTypeMask) << kBTLmodTypeOffset | ((crystal - 1) & kBTLCrystalMask) << kBTLCrystalOffset;
0059   }
0060 
0061   // ---------- Common methods ----------
0062 
0063   /** Returns BTL module number. */
0064   inline int module() const { return (id_ >> kBTLmoduleOffset) & kBTLmoduleMask; }
0065 
0066   /** Returns BTL crystal type number. */
0067   inline int modType() const { return (id_ >> kBTLmodTypeOffset) & kBTLmodTypeMask; }
0068 
0069   /** Returns BTL crystal number. */
0070   inline int crystal() const { return ((id_ >> kBTLCrystalOffset) & kBTLCrystalMask) + 1; }
0071 
0072   /** return the row in GeomDet language **/
0073   inline int row(unsigned nrows = kCrystalsPerModuleTdr) const {
0074     return (crystal() - 1) % nrows;  // anything else for now
0075   }
0076 
0077   /** return the column in GeomDetLanguage **/
0078   inline int column(unsigned nrows = kCrystalsPerModuleTdr) const { return (crystal() - 1) / nrows; }
0079 
0080   /** create a Geographical DetId for Tracking **/
0081   BTLDetId geographicalId(CrysLayout lay) const;
0082 };
0083 
0084 std::ostream& operator<<(std::ostream&, const BTLDetId&);
0085 
0086 #endif  // DataFormats_BTLDetId_BTLDetId_h