Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:30

0001 
0002 #ifndef CalibFormats_SiStripObjects_SiStripModule_H
0003 #define CalibFormats_SiStripObjects_SiStripModule_H
0004 
0005 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
0006 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
0007 #include <map>
0008 #include <ostream>
0009 #include <sstream>
0010 #include <vector>
0011 #include <cstdint>
0012 
0013 class SiStripModule;
0014 
0015 /** Debug info for SiStripModule class. */
0016 std::ostream &operator<<(std::ostream &, const SiStripModule &);
0017 
0018 /**
0019     @class SiStripModule
0020     @author R.Bainbridge
0021     @brief Device and connection information at the level of a
0022     front-end module.
0023 */
0024 class SiStripModule {
0025 public:
0026   // ---------- Constructors and adding devices ----------
0027 
0028   /** Constructor. */
0029   SiStripModule(const FedChannelConnection &conn);
0030 
0031   /** Default constructor. */
0032   ~SiStripModule() { ; }
0033 
0034   /** Sets device info (addresses, DetID, etc) for this module. */
0035   void addDevices(const FedChannelConnection &conn);
0036 
0037   // ---------- Typedefs and enums ----------
0038 
0039   /** Pair containing FED id/channel. */
0040   typedef std::pair<uint16_t, uint16_t> PairOfU16;
0041 
0042   /** Struct containing FED crate/slot/id/channel. */
0043   // typedef PairOfU16 FedChannel;
0044   class FedChannel {
0045   public:
0046     uint16_t fedCrate_;
0047     uint16_t fedSlot_;
0048     uint16_t fedId_;
0049     uint16_t fedCh_;
0050     FedChannel(const uint16_t &crate, const uint16_t &slot, const uint16_t &id, const uint16_t &ch)
0051         : fedCrate_(crate), fedSlot_(slot), fedId_(id), fedCh_(ch) {
0052       ;
0053     }
0054     FedChannel() : fedCrate_(0), fedSlot_(0), fedId_(0), fedCh_(0) { ; }
0055   };
0056 
0057   /** Map between LLD channel and FED channel */
0058   typedef std::map<uint16_t, FedChannel> FedCabling;
0059 
0060   // ---------- Control structure ----------
0061 
0062   inline const uint16_t &fecCrate() const;
0063   inline const uint16_t &fecSlot() const;
0064   inline const uint16_t &fecRing() const;
0065   inline const uint16_t &ccuAddr() const;
0066   inline const uint16_t &ccuChan() const;
0067 
0068   /** Returns control "key" for this module, containing address
0069       information on FEC crate, slot, ring, CCU, and module. */
0070   inline const SiStripFecKey &key() const;
0071 
0072   // ---------- APV devices ----------
0073 
0074   /** Returns I2C addresses of active ("found") APVs. */
0075   std::vector<uint16_t> activeApvs() const;
0076 
0077   /** Identifies whether APV of a given I2C address (32->37) or
0078       footprint position on the hybrid (0->5) is active or
0079       not. Returns device I2C address or zero if not active. */
0080   const uint16_t &activeApv(const uint16_t &apv_address) const;
0081 
0082   /** Identifies APV pairs that are active for given LLD channel
0083       (1->3). Returns device I2C address or zero if not active. */
0084   PairOfU16 activeApvPair(const uint16_t &lld_channel) const;
0085 
0086   /** Add APV to module using I2C address (32->37). */
0087   void addApv(const uint16_t &apv_address);
0088 
0089   // ---------- Other hybrid devices ----------
0090 
0091   /** Identifies whether the DCU device is active ("found") or not. */
0092   inline const uint16_t &dcu() const;
0093 
0094   /** Identifies whether the MUX device is active ("found") or not. */
0095   inline const uint16_t &mux() const;
0096 
0097   /** Identifies whether the PLL device is active ("found") or not. */
0098   inline const uint16_t &pll() const;
0099 
0100   /** Identifies whether the LLD device is active ("found") or not. */
0101   inline const uint16_t &lld() const;
0102 
0103   // ---------- Module information ----------
0104 
0105   /** Returns DCU id for this module. */
0106   inline const uint32_t &dcuId() const;
0107 
0108   /** Returns LLD channel (1->3) for given APV pair (0->1 or 0->2). */
0109   uint16_t lldChannel(const uint16_t &apv_pair_num) const;
0110 
0111   /** Set DCU id for this module. */
0112   inline void dcuId(const uint32_t &dcu_id);
0113 
0114   // ---------- Detector information ----------
0115 
0116   /** Returns unique (geometry-based) identifier for this module. */
0117   inline const uint32_t &detId() const;
0118 
0119   /** Returns APV pair (0->1 or 0->2) for given LLD channel (1->3). */
0120   uint16_t apvPairNumber(const uint16_t &lld_channel) const;
0121 
0122   /** Returns number of APV pairs for this module. */
0123   inline const uint16_t &nApvPairs() const;
0124 
0125   /** Returns number of detector strips for this module. */
0126   inline uint16_t nDetStrips() const;
0127 
0128   /** Set DetId for this module. */
0129   inline void detId(const uint32_t &det_id);
0130 
0131   /** Set number of detector strips for this module. */
0132   void nApvPairs(const uint16_t &npairs);
0133 
0134   // ---------- FED connection information ----------
0135 
0136   /** Returns map of apvPairNumber and FedChannel. */
0137   inline const FedCabling &fedChannels() const;
0138 
0139   /** Returns FedChannel for a given apvPairNumber. */
0140   FedChannel fedCh(const uint16_t &apv_pair_num) const;
0141 
0142   /** Sets FedChannel for given APV address (32->37). Returns true
0143       if connection made, false otherwise. */
0144   bool fedCh(const uint16_t &apv_address, const FedChannel &fed_ch);
0145 
0146   // ---------- Miscellaneous ----------
0147 
0148   /** Prints some debug information for this module. */
0149   void print(std::stringstream &) const;
0150 
0151   /** Prints some terse debug information for this module. */
0152   void terse(std::stringstream &) const;
0153 
0154   /** Returns cable length. */
0155   inline const uint16_t &length() const;
0156 
0157   /** Sets cable length. */
0158   inline void length(const uint16_t &length);
0159 
0160 private:
0161   /** Control key/path for this module. */
0162   SiStripFecKey key_;
0163 
0164   // APVs found (identified by decimal I2C address)
0165   uint16_t apv32_;
0166   uint16_t apv33_;
0167   uint16_t apv34_;
0168   uint16_t apv35_;
0169   uint16_t apv36_;
0170   uint16_t apv37_;
0171 
0172   // Devices found (with hex addr)
0173   uint16_t dcu0x00_;
0174   uint16_t mux0x43_;
0175   uint16_t pll0x44_;
0176   uint16_t lld0x60_;
0177 
0178   // Detector
0179   uint32_t dcuId_;
0180   uint32_t detId_;
0181   uint16_t nApvPairs_;
0182 
0183   /** KEY = LLD channel, DATA = FedId + FedCh */
0184   FedCabling cabling_;
0185   uint16_t length_;
0186 };
0187 
0188 // --------------- inline methods ---------------
0189 
0190 const uint16_t &SiStripModule::fecCrate() const { return key_.fecCrate(); }
0191 const uint16_t &SiStripModule::fecSlot() const { return key_.fecSlot(); }
0192 const uint16_t &SiStripModule::fecRing() const { return key_.fecRing(); }
0193 const uint16_t &SiStripModule::ccuAddr() const { return key_.ccuAddr(); }
0194 const uint16_t &SiStripModule::ccuChan() const { return key_.ccuChan(); }
0195 
0196 const SiStripFecKey &SiStripModule::key() const { return key_; }
0197 
0198 const uint32_t &SiStripModule::dcuId() const { return dcuId_; }
0199 const uint32_t &SiStripModule::detId() const { return detId_; }
0200 const uint16_t &SiStripModule::nApvPairs() const { return nApvPairs_; }
0201 uint16_t SiStripModule::nDetStrips() const { return 256 * nApvPairs_; }
0202 
0203 void SiStripModule::dcuId(const uint32_t &dcu_id) {
0204   if (dcu_id) {
0205     dcuId_ = dcu_id;
0206     dcu0x00_ = true;
0207   }
0208 }
0209 void SiStripModule::detId(const uint32_t &det_id) {
0210   if (det_id) {
0211     detId_ = det_id;
0212   }
0213 }
0214 const SiStripModule::FedCabling &SiStripModule::fedChannels() const { return cabling_; }
0215 
0216 const uint16_t &SiStripModule::length() const { return length_; }
0217 void SiStripModule::length(const uint16_t &length) { length_ = length; }
0218 
0219 const uint16_t &SiStripModule::dcu() const { return dcu0x00_; }
0220 const uint16_t &SiStripModule::mux() const { return mux0x43_; }
0221 const uint16_t &SiStripModule::pll() const { return pll0x44_; }
0222 const uint16_t &SiStripModule::lld() const { return lld0x60_; }
0223 
0224 #endif  // CalibTracker_SiStripObjects_SiStripModule_H