File indexing completed on 2024-04-06 12:02: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
0014 std::ostream& operator<<(std::ostream&, const FedChannelConnection&);
0015
0016
0017 bool operator<(const FedChannelConnection&, const FedChannelConnection&);
0018
0019
0020
0021
0022
0023
0024
0025
0026 class FedChannelConnection {
0027 public:
0028
0029
0030
0031
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
0051 FedChannelConnection();
0052
0053
0054 ~FedChannelConnection() { ; }
0055
0056
0057
0058
0059 bool isConnected() const;
0060
0061
0062 void consistencyCheck() const { ; }
0063
0064
0065 void print(std::stringstream&) const;
0066
0067
0068 void terse(std::stringstream&) const;
0069
0070
0071
0072
0073 const uint32_t& dcuId() const;
0074
0075
0076 const uint32_t& detId() const;
0077
0078
0079 uint16_t nDetStrips() const;
0080
0081
0082 const uint16_t& nApvPairs() const;
0083
0084
0085 uint16_t nApvs() const;
0086
0087
0088
0089
0090
0091 uint16_t apvPairNumber() const;
0092 uint16_t apvPairNumberDebug() const;
0093
0094
0095 uint16_t lldChannel() const;
0096
0097
0098 const uint16_t& fedCrate() const;
0099
0100
0101 const uint16_t& fedSlot() const;
0102
0103
0104 const uint16_t& fedId() const;
0105
0106
0107 const uint16_t& fedCh() const;
0108
0109
0110 void fedCrate(uint16_t& fed_crate);
0111
0112
0113 void fedSlot(uint16_t& fed_slot);
0114
0115
0116 void fedId(uint16_t& fed_id);
0117
0118
0119 void fedCh(uint16_t& fed_ch);
0120
0121
0122
0123
0124 const uint16_t& fecCrate() const;
0125
0126
0127 const uint16_t& fecSlot() const;
0128
0129
0130 const uint16_t& fecRing() const;
0131
0132
0133 const uint16_t& ccuAddr() const;
0134
0135
0136 const uint16_t& ccuChan() const;
0137
0138
0139
0140
0141
0142
0143 const uint16_t& i2cAddr(const uint16_t& apv0_or_1) const;
0144
0145
0146 const bool& dcu() const;
0147
0148
0149 const bool& mux() const;
0150
0151
0152 const bool& pll() const;
0153
0154
0155 const bool& lld() const;
0156
0157
0158 const uint16_t& fiberLength() const;
0159
0160 private:
0161
0162
0163
0164 uint16_t fecCrate_;
0165 uint16_t fecSlot_;
0166 uint16_t fecRing_;
0167 uint16_t ccuAddr_;
0168 uint16_t ccuChan_;
0169
0170
0171 uint16_t apv0_;
0172 uint16_t apv1_;
0173
0174
0175 uint32_t dcuId_;
0176 uint32_t detId_;
0177 uint16_t nApvPairs_;
0178
0179
0180 uint16_t fedCrate_;
0181 uint16_t fedSlot_;
0182 uint16_t fedId_;
0183 uint16_t fedCh_;
0184 uint16_t length_;
0185
0186
0187 bool dcu0x00_;
0188 bool mux0x43_;
0189 bool pll0x44_;
0190 bool lld0x60_;
0191
0192 COND_SERIALIZABLE;
0193 };
0194
0195
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 {
0236 return nApvPairs_ - 1;
0237 }
0238 }
0239
0240 #endif