Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:35

0001 #ifndef DATAFORMATS_HCALDETID_CASTORELECTRONICSID_H
0002 #define DATAFORMATS_HCALDETID_CASTORELECTRONICSID_H 1
0003 
0004 #include <string>
0005 #include <ostream>
0006 #include <cstdint>
0007 
0008 /** \brief Readout chain identification for Castor 
0009 Bits for the readout chain : some names need change!
0010     [31:26] not used
0011     [25]    
0012     [24:20] 
0013     [19] 
0014     [18:14] 
0015     [13:9]  
0016     [8:5]   
0017     [4:2]   
0018     [1:0]   
0019  */
0020 class CastorElectronicsId {
0021 public:
0022   /** Constructors */
0023   CastorElectronicsId();
0024   CastorElectronicsId(uint32_t);
0025   CastorElectronicsId(int fiberChan, int fiberIndex, int spigot, int dccid);
0026   CastorElectronicsId(int slbChan, int slbSite, int spigot, int dccid, int crate, int slot, int tb);
0027   uint32_t operator()() { return castorElectronicsId_; }
0028 
0029   uint32_t rawId() const { return castorElectronicsId_; }
0030 
0031   bool isTriggerChainId() const { return (castorElectronicsId_ & 0x02000000) != 0; }
0032 
0033   void setHTR(int crate, int slot, int tb);
0034   int fiberChanId() const { return castorElectronicsId_ & 0x3; }
0035   int fiberIndex() const { return ((castorElectronicsId_ >> 2) & 0xf) + 1; }
0036   int slbChannelIndex() const { return castorElectronicsId_ & 0x3; }
0037   int slbSiteNumber() const { return ((castorElectronicsId_ >> 2) & 0xf) + 1; }
0038 
0039   std::string slbChannelCode() const;
0040 
0041   int htrChanId() const { return (fiberChanId() + 1) + ((fiberIndex() - 1) * 3); }
0042   int spigot() const { return (castorElectronicsId_ >> 6) & 0xF; }
0043   int dccid() const { return (castorElectronicsId_ >> 10) & 0xF; }
0044   int htrSlot() const { return (castorElectronicsId_ >> 14) & 0x1F; }
0045   int htrTopBottom() const { return (castorElectronicsId_ >> 19) & 0x1; }
0046   int readoutVMECrateId() const { return (castorElectronicsId_ >> 20) & 0x1F; }
0047   int linearIndex() const { return (castorElectronicsId_)&0x3FFF; }
0048 
0049   static const int maxLinearIndex = 0x3FFF;
0050   static const int maxDCCId = 15;
0051 
0052   /** operators */
0053   int operator==(const CastorElectronicsId& id) const { return id.castorElectronicsId_ == castorElectronicsId_; }
0054   int operator!=(const CastorElectronicsId& id) const { return id.castorElectronicsId_ != castorElectronicsId_; }
0055   /// Compare the id to another one for use in a map
0056   int operator<(const CastorElectronicsId& id) const { return castorElectronicsId_ < id.castorElectronicsId_; }
0057 
0058 private:
0059   uint32_t castorElectronicsId_;
0060 };
0061 
0062 std::ostream& operator<<(std::ostream&, const CastorElectronicsId&);
0063 
0064 #endif