Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:38

0001 #ifndef CondFormats_SiStripObjects_FedChannelConnection_H
0002 #define CondFormats_SiStripObjects_FedChannelConnection_H
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0007 #include <ostream>
0008 #include <sstream>
0009 #include <cstdint>
0010 
0011 class FedChannelConnection;
0012 
0013 /** Debug info for FedChannelConnection class. */
0014 std::ostream& operator<<(std::ostream&, const FedChannelConnection&);
0015 
0016 /** Overload less than operator. */
0017 bool operator<(const FedChannelConnection&, const FedChannelConnection&);
0018 
0019 /** 
0020     @class FedChannelConnection 
0021     @author R.Bainbridge
0022 
0023     @brief Class containning control, module, detector and connection
0024     information, at the level of a FED channel.
0025 */
0026 class FedChannelConnection {
0027 public:
0028   // ---------- Constructor ----------
0029 
0030   /** Constructor requires at least information to uniquely identify a
0031    front-end module: ie, crate + FEC + ring + CCU + module. */
0032   FedChannelConnection(const uint16_t& fec_crate,
0033                        const uint16_t& fec_slot,
0034                        const uint16_t& fec_ring,
0035                        const uint16_t& ccu_addr,
0036                        const uint16_t& ccu_chan,
0037                        const uint16_t& apv0 = 0,
0038                        const uint16_t& apv1 = 0,
0039                        const uint32_t& dcu_id = 0,
0040                        const uint32_t& det_id = 0,
0041                        const uint16_t& pairs = 0,
0042                        const uint16_t& fed_id = 0,
0043                        const uint16_t& fed_ch = 0,
0044                        const uint16_t& length = 0,
0045                        const bool& dcu = false,
0046                        const bool& pll = false,
0047                        const bool& mux = false,
0048                        const bool& lld = false);
0049 
0050   /** Default constructor. */
0051   FedChannelConnection();
0052 
0053   /** Default destructor. */
0054   ~FedChannelConnection() { ; }
0055 
0056   // ---------- Utility methods ----------
0057 
0058   /** Identifies a valid connection. */
0059   bool isConnected() const;
0060 
0061   /** Performs consistency check for this connection object. */
0062   void consistencyCheck() const { ; }  //@@ TO BE IMPLEMENTED...
0063 
0064   /** Prints all information for this connection object. */
0065   void print(std::stringstream&) const;
0066 
0067   /** Prints terse information for this connection object. */
0068   void terse(std::stringstream&) const;
0069 
0070   // -------------------- Module and detector information --------------------
0071 
0072   /** Returns DCUid for this module. */
0073   const uint32_t& dcuId() const;
0074 
0075   /** Returns DetId for this module. */
0076   const uint32_t& detId() const;
0077 
0078   /** Returns number of detector strips for this module. */
0079   uint16_t nDetStrips() const;
0080 
0081   /** Returns number of APV pairs for this module. */
0082   const uint16_t& nApvPairs() const;
0083 
0084   /** Returns number of APVs for this module. */
0085   uint16_t nApvs() const;
0086 
0087   // -------------------- FED connection information --------------------
0088 
0089   /** Returns APV pair number for this connection object. This can be
0090       either 0->1 or 0->2, depending on number of detector strips. */
0091   uint16_t apvPairNumber() const;
0092   uint16_t apvPairNumberDebug() const;
0093 
0094   /** Returns Laser Driver channel (1->3) for this channel. */
0095   uint16_t lldChannel() const;
0096 
0097   /** Returns FED crate for this channel. */
0098   const uint16_t& fedCrate() const;
0099 
0100   /** Returns FED slot for this channel. */
0101   const uint16_t& fedSlot() const;
0102 
0103   /** Returns FED id for this channel. */
0104   const uint16_t& fedId() const;
0105 
0106   /** Returns FED id for this channel. */
0107   const uint16_t& fedCh() const;
0108 
0109   /** Sets FED crate for this channel. */
0110   void fedCrate(uint16_t& fed_crate);
0111 
0112   /** Sets FED slot for this channel. */
0113   void fedSlot(uint16_t& fed_slot);
0114 
0115   /** Sets FED id for this channel. */
0116   void fedId(uint16_t& fed_id);
0117 
0118   /** Sets FED id for this channel. */
0119   void fedCh(uint16_t& fed_ch);
0120 
0121   // -------------------- Control structure information --------------------
0122 
0123   /** Returns FEC crate number. */
0124   const uint16_t& fecCrate() const;
0125 
0126   /** Returns slot number of FEC. */
0127   const uint16_t& fecSlot() const;
0128 
0129   /** Returns FEC ring number. */
0130   const uint16_t& fecRing() const;
0131 
0132   /** Returns CCU address. */
0133   const uint16_t& ccuAddr() const;
0134 
0135   /** Returns CCU channel. */
0136   const uint16_t& ccuChan() const;
0137 
0138   // -------------------- Front-end ASICs --------------------
0139 
0140   /** Indicates whether APV0 or APV1 of the pair has been found: a
0141       non-zero value indicates the I2C address; a null value signifies
0142       a problematic APV. */
0143   const uint16_t& i2cAddr(const uint16_t& apv0_or_1) const;
0144 
0145   /** Indicates whether DCU ASIC is found. */
0146   const bool& dcu() const;
0147 
0148   /** Indicates whether APV-MUX ASIC is found. */
0149   const bool& mux() const;
0150 
0151   /** Indicates whether PLL ASIC is found. */
0152   const bool& pll() const;
0153 
0154   /** Indicates whether Linear Laser Driver ASIC is found. */
0155   const bool& lld() const;
0156 
0157   /** Returns the length of the optical fiber */
0158   const uint16_t& fiberLength() const;
0159 
0160 private:
0161   // ---------- Private member data ----------
0162 
0163   // Control
0164   uint16_t fecCrate_;
0165   uint16_t fecSlot_;
0166   uint16_t fecRing_;
0167   uint16_t ccuAddr_;
0168   uint16_t ccuChan_;
0169 
0170   // I2C addresses
0171   uint16_t apv0_;
0172   uint16_t apv1_;
0173 
0174   // Module / Detector
0175   uint32_t dcuId_;
0176   uint32_t detId_;
0177   uint16_t nApvPairs_;
0178 
0179   // FED
0180   uint16_t fedCrate_;
0181   uint16_t fedSlot_;
0182   uint16_t fedId_;
0183   uint16_t fedCh_;
0184   uint16_t length_;
0185 
0186   // Found devices
0187   bool dcu0x00_;
0188   bool mux0x43_;
0189   bool pll0x44_;
0190   bool lld0x60_;
0191 
0192   COND_SERIALIZABLE;
0193 };
0194 
0195 // ---------- inline methods ----------
0196 
0197 inline bool FedChannelConnection::isConnected() const {
0198   return (fedId_ != sistrip::invalid_ && fedCh_ != sistrip::invalid_);
0199 }
0200 
0201 inline const uint16_t& FedChannelConnection::fecCrate() const { return fecCrate_; }
0202 inline const uint16_t& FedChannelConnection::fecSlot() const { return fecSlot_; }
0203 inline const uint16_t& FedChannelConnection::fecRing() const { return fecRing_; }
0204 inline const uint16_t& FedChannelConnection::ccuAddr() const { return ccuAddr_; }
0205 inline const uint16_t& FedChannelConnection::ccuChan() const { return ccuChan_; }
0206 
0207 inline const bool& FedChannelConnection::dcu() const { return dcu0x00_; }
0208 inline const bool& FedChannelConnection::mux() const { return mux0x43_; }
0209 inline const bool& FedChannelConnection::pll() const { return pll0x44_; }
0210 inline const bool& FedChannelConnection::lld() const { return lld0x60_; }
0211 
0212 inline const uint32_t& FedChannelConnection::dcuId() const { return dcuId_; }
0213 inline const uint32_t& FedChannelConnection::detId() const { return detId_; }
0214 inline uint16_t FedChannelConnection::nDetStrips() const { return 256 * nApvPairs_; }
0215 inline const uint16_t& FedChannelConnection::nApvPairs() const { return nApvPairs_; }
0216 inline uint16_t FedChannelConnection::nApvs() const { return 2 * nApvPairs(); }
0217 
0218 inline const uint16_t& FedChannelConnection::fedCrate() const { return fedCrate_; }
0219 inline const uint16_t& FedChannelConnection::fedSlot() const { return fedSlot_; }
0220 inline const uint16_t& FedChannelConnection::fedId() const { return fedId_; }
0221 inline const uint16_t& FedChannelConnection::fedCh() const { return fedCh_; }
0222 
0223 inline const uint16_t& FedChannelConnection::fiberLength() const { return length_; }
0224 
0225 inline void FedChannelConnection::fedId(uint16_t& fed_id) { fedId_ = fed_id; }
0226 inline void FedChannelConnection::fedCh(uint16_t& fed_ch) { fedCh_ = fed_ch; }
0227 inline void FedChannelConnection::fedCrate(uint16_t& fed_crate) { fedCrate_ = fed_crate; }
0228 inline void FedChannelConnection::fedSlot(uint16_t& fed_slot) { fedSlot_ = fed_slot; }
0229 
0230 inline uint16_t FedChannelConnection::apvPairNumber() const {
0231   if (apv0_ == 32 || apv1_ == 33) {
0232     return 0;
0233   } else if (apv0_ == 34 || apv1_ == 35) {
0234     return 1;
0235   } else {  // if (apv0_ == 36 || apv1_ == 37) {
0236     return nApvPairs_ - 1;
0237   }
0238 }
0239 
0240 #endif  // CondFormats_SiStripObjects_FedChannelConnection_H