CMS 3D CMS Logo

FedChannelConnection.cc
Go to the documentation of this file.
4 #include <iomanip>
5 #include <string>
6 
7 using namespace sistrip;
8 
9 // -----------------------------------------------------------------------------
10 //
12  const uint16_t& fec_slot,
13  const uint16_t& fec_ring,
14  const uint16_t& ccu_addr,
15  const uint16_t& ccu_chan,
16  const uint16_t& apv0,
17  const uint16_t& apv1,
18  const uint32_t& dcu_id,
19  const uint32_t& det_id,
20  const uint16_t& pairs,
21  const uint16_t& fed_id,
22  const uint16_t& fed_ch,
23  const uint16_t& length,
24  const bool& dcu,
25  const bool& pll,
26  const bool& mux,
27  const bool& lld)
28  : fecCrate_(fec_crate),
29  fecSlot_(fec_slot),
30  fecRing_(fec_ring),
31  ccuAddr_(ccu_addr),
32  ccuChan_(ccu_chan),
33  apv0_(apv0),
34  apv1_(apv1),
35  dcuId_(dcu_id),
36  detId_(det_id),
37  nApvPairs_(pairs),
38  fedCrate_(sistrip::invalid_),
39  fedSlot_(sistrip::invalid_),
40  fedId_(fed_id),
41  fedCh_(fed_ch),
42  length_(length),
43  dcu0x00_(dcu),
44  mux0x43_(mux),
45  pll0x44_(pll),
46  lld0x60_(lld) {
47  ;
48 }
49 
50 // -----------------------------------------------------------------------------
51 //
58  apv0_(sistrip::invalid_),
59  apv1_(sistrip::invalid_),
60  dcuId_(sistrip::invalid32_),
61  detId_(sistrip::invalid32_),
62  nApvPairs_(sistrip::invalid_),
63  fedCrate_(sistrip::invalid_),
64  fedSlot_(sistrip::invalid_),
65  fedId_(sistrip::invalid_),
66  fedCh_(sistrip::invalid_),
67  length_(sistrip::invalid_),
68  dcu0x00_(false),
69  mux0x43_(false),
70  pll0x44_(false),
71  lld0x60_(false) {
72  ;
73 }
74 
75 // -----------------------------------------------------------------------------
76 //
77 bool operator<(const FedChannelConnection& conn1, const FedChannelConnection& conn2) {
78  if (conn1.fedId() < conn2.fedId()) {
79  return true;
80  } else if (conn1.fedId() == conn2.fedId()) {
81  return (conn1.fedCh() < conn2.fedCh() ? true : false);
82  } else {
83  return false;
84  }
85 }
86 
87 // -----------------------------------------------------------------------------
88 //
89 const uint16_t& FedChannelConnection::i2cAddr(const uint16_t& apv) const {
90  if (apv == 0) {
91  return apv0_;
92  } else if (apv == 1) {
93  return apv1_;
94  } else {
95  if (edm::isDebugEnabled()) {
96  edm::LogWarning(mlCabling_) << "[FedChannelConnection::" << __func__ << "]"
97  << " Unexpected APV I2C address!" << apv;
98  }
99  static const uint16_t i2c_addr = 0;
100  return i2c_addr;
101  }
102 }
103 
104 // -----------------------------------------------------------------------------
105 //
107  if (apv0_ == 32 || apv1_ == 33) {
108  return 1;
109  } else if (apv0_ == 34 || apv1_ == 35) {
110  return 2;
111  } else if (apv0_ == 36 || apv1_ == 37) {
112  return 3;
113  } else if (apv0_ != sistrip::invalid_ || apv1_ != sistrip::invalid_) {
114  if (edm::isDebugEnabled()) {
115  edm::LogWarning(mlCabling_) << "[FedChannelConnection::" << __func__ << "]"
116  << " Unexpected APV I2C addresses!"
117  << " Apv0: " << apv0_ << " Apv1: " << apv1_;
118  }
119  }
120  return sistrip::invalid_;
121 }
122 
123 // -----------------------------------------------------------------------------
126  if (nApvPairs_ == 2) {
127  if (apv0_ == 32 || apv1_ == 33) {
128  return 0;
129  } else if (apv0_ == 36 || apv1_ == 37) {
130  return 1;
131  } else {
132  if (edm::isDebugEnabled()) {
133  edm::LogWarning(mlCabling_) << "[FedChannelConnection::" << __func__ << "]"
134  << " APV I2C addresses (" << apv0_ << "/" << apv1_ << ") are incompatible with"
135  << " number of APV pairs (" << nApvPairs_ << ") found for this module!";
136  }
137  }
138  } else if (nApvPairs_ == 3) {
139  if (apv0_ == 32 || apv1_ == 33) {
140  return 0;
141  } else if (apv0_ == 34 || apv1_ == 35) {
142  return 1;
143  } else if (apv0_ == 36 || apv1_ == 37) {
144  return 2;
145  } else {
146  if (edm::isDebugEnabled()) {
147  edm::LogWarning(mlCabling_) << "[FedChannelConnection::" << __func__ << "]"
148  << " APV I2C addresses (" << apv0_ << "/" << apv1_ << ") are incompatible with"
149  << " number of APV pairs (" << nApvPairs_ << ") found for this module!";
150  }
151  }
152  } else {
153  if (edm::isDebugEnabled()) {
154  edm::LogWarning(mlCabling_) << "[FedChannelConnection::" << __func__ << "]"
155  << " Unexpected number of APV pairs: " << nApvPairs_;
156  }
157  }
158  return sistrip::invalid_;
159 }
160 
161 // -----------------------------------------------------------------------------
162 //
163 void FedChannelConnection::print(std::stringstream& ss) const {
164  ss << " [FedChannelConnection::" << __func__ << "]" << std::endl
165  << " FedCrate/FedSlot/FedId/FeUnit/FeChan/FedCh : " << fedCrate() << "/" << fedSlot() << "/" << fedId() << "/"
166  << SiStripFedKey::feUnit(fedCh()) << "/" << SiStripFedKey::feChan(fedCh()) << "/" << fedCh() << std::endl
167  << " FecCrate/FecSlot/FecRing/CcuAddr/CcuChan : " << fecCrate() << "/" << fecSlot() << "/" << fecRing() << "/"
168  << ccuAddr() << "/" << ccuChan() << std::endl
169  << " DcuId/DetId : " << std::hex << "0x" << std::setfill('0') << std::setw(8)
170  << dcuId() << "/"
171  << "0x" << std::setfill('0') << std::setw(8) << detId() << std::endl
172  << std::dec << " LldChan/APV0/APV1 : " << lldChannel() << "/" << i2cAddr(0) << "/"
173  << i2cAddr(1) << std::endl
174  << " pairNumber/nPairs/nStrips : " << apvPairNumber() << "/" << nApvPairs() << "/"
175  << 256 * nApvPairs() << std::endl
176  << " DCU/MUX/PLL/LLD found : " << std::boolalpha << dcu() << "/" << mux() << "/" << pll()
177  << "/" << lld() << std::noboolalpha;
178 }
179 
180 // -----------------------------------------------------------------------------
181 //
182 void FedChannelConnection::terse(std::stringstream& ss) const {
183  ss << " FED:cr/sl/id/fe/ch/chan=" << fedCrate() << "/" << fedSlot() << "/" << fedId() << "/"
184  << SiStripFedKey::feUnit(fedCh()) << "/" << SiStripFedKey::feChan(fedCh()) << "/" << fedCh() << ","
185  << " FEC:cr/sl/ring/ccu/mod=" << fecCrate() << "/" << fecSlot() << "/" << fecRing() << "/" << ccuAddr() << "/"
186  << ccuChan() << ","
187  << " apvs=" << i2cAddr(0) << "/" << i2cAddr(1) << ","
188  << " pair=" << apvPairNumber() + 1 << " (from " << nApvPairs() << "),"
189  << " dcu/detid=" << std::hex << "0x" << std::setfill('0') << std::setw(8) << dcuId() << "/"
190  << "0x" << std::setfill('0') << std::setw(8) << detId() << std::dec;
191 }
192 
193 // -----------------------------------------------------------------------------
194 //
195 std::ostream& operator<<(std::ostream& os, const FedChannelConnection& conn) {
196  std::stringstream ss;
197  conn.print(ss);
198  os << ss.str();
199  return os;
200 }
const uint16_t & fecCrate() const
bool isDebugEnabled()
const uint16_t & ccuAddr() const
uint16_t apvPairNumberDebug() const
const uint16_t & fedSlot() const
const bool & dcu() const
const uint16_t & feChan() const
const uint16_t & feUnit() const
static const uint32_t invalid32_
Definition: Constants.h:15
const uint32_t & dcuId() const
const uint16_t & i2cAddr(const uint16_t &apv0_or_1) const
const uint16_t & fecSlot() const
void print(std::stringstream &) const
sistrip classes
static const char fecSlot_[]
std::ostream & operator<<(std::ostream &os, const FedChannelConnection &conn)
static const char ccuChan_[]
static const char ccuAddr_[]
static const char mlCabling_[]
const bool & pll() const
Class containning control, module, detector and connection information, at the level of a FED channel...
const uint16_t & ccuChan() const
const uint16_t & fedId() const
static const char fecCrate_[]
const uint16_t & fecRing() const
const bool & lld() const
const uint32_t & detId() const
const uint16_t & fedCrate() const
const uint16_t & nApvPairs() const
static const char fecRing_[]
static const uint16_t invalid_
Definition: Constants.h:16
uint16_t apvPairNumber() const
conn
Definition: getInfo.py:9
void terse(std::stringstream &) const
const bool & mux() const
Log< level::Warning, false > LogWarning
bool operator<(const FedChannelConnection &conn1, const FedChannelConnection &conn2)
const uint16_t & fedCh() const