CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FedChannelConnection.cc
Go to the documentation of this file.
4 #include <iomanip>
5 #include <string>
6 
7 using namespace sistrip;
8 
9 // -----------------------------------------------------------------------------
10 //
11 FedChannelConnection::FedChannelConnection( const uint16_t& fec_crate,
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 //
52  fecCrate_(sistrip::invalid_),
53  fecSlot_(sistrip::invalid_),
54  fecRing_(sistrip::invalid_),
55  ccuAddr_(sistrip::invalid_),
56  ccuChan_(sistrip::invalid_),
57  apv0_(sistrip::invalid_),
58  apv1_(sistrip::invalid_),
59  dcuId_(sistrip::invalid32_),
60  detId_(sistrip::invalid32_),
61  nApvPairs_(sistrip::invalid_),
62  fedCrate_(sistrip::invalid_),
63  fedSlot_(sistrip::invalid_),
64  fedId_(sistrip::invalid_),
65  fedCh_(sistrip::invalid_),
66  length_(sistrip::invalid_),
67  dcu0x00_(false),
68  mux0x43_(false),
69  pll0x44_(false),
70  lld0x60_(false)
71 {;}
72 
73 // -----------------------------------------------------------------------------
74 //
75 bool operator< ( const FedChannelConnection& conn1, const FedChannelConnection& conn2 ) {
76  if ( conn1.fedId() < conn2.fedId() ) { return true; }
77  else if ( conn1.fedId() == conn2.fedId() ) { return ( conn1.fedCh() < conn2.fedCh() ? true : false ); }
78  else { return false; }
79 }
80 
81 // -----------------------------------------------------------------------------
82 //
83 const uint16_t& FedChannelConnection::i2cAddr( const uint16_t& apv ) const {
84  if ( apv == 0 ) { return apv0_; }
85  else if ( apv == 1 ) { return apv1_; }
86  else {
87  if ( edm::isDebugEnabled() ) {
89  << "[FedChannelConnection::" << __func__ << "]"
90  << " Unexpected APV I2C address!" << apv;
91  }
92  static const uint16_t i2c_addr = 0;
93  return i2c_addr;
94  }
95 }
96 
97 // -----------------------------------------------------------------------------
98 //
100  if ( apv0_ == 32 || apv1_ == 33 ) { return 1; }
101  else if ( apv0_ == 34 || apv1_ == 35 ) { return 2; }
102  else if ( apv0_ == 36 || apv1_ == 37 ) { return 3; }
103  else if ( apv0_ != sistrip::invalid_ ||
104  apv1_ != sistrip::invalid_ ) {
105  if ( edm::isDebugEnabled() ) {
107  << "[FedChannelConnection::" << __func__ << "]"
108  << " Unexpected APV I2C addresses!"
109  << " Apv0: " << apv0_
110  << " Apv1: " << apv1_;
111  }
112  }
113  return sistrip::invalid_;
114 }
115 
116 // -----------------------------------------------------------------------------
119  if ( nApvPairs_ == 2 ) {
120  if ( apv0_ == 32 || apv1_ == 33 ) { return 0; }
121  else if ( apv0_ == 36 || apv1_ == 37 ) { return 1; }
122  else {
123  if ( edm::isDebugEnabled() ) {
125  << "[FedChannelConnection::" << __func__ << "]"
126  << " APV I2C addresses ("
127  << apv0_ << "/" << apv1_
128  << ") are incompatible with"
129  << " number of APV pairs ("
130  << nApvPairs_ << ") found for this module!";
131  }
132  }
133  } else if ( nApvPairs_ == 3 ) {
134  if ( apv0_ == 32 || apv1_ == 33 ) { return 0; }
135  else if ( apv0_ == 34 || apv1_ == 35 ) { return 1; }
136  else if ( apv0_ == 36 || apv1_ == 37 ) { return 2; }
137  else {
138  if ( edm::isDebugEnabled() ) {
140  << "[FedChannelConnection::" << __func__ << "]"
141  << " APV I2C addresses ("
142  << apv0_ << "/" << apv1_
143  << ") are incompatible with"
144  << " number of APV pairs ("
145  << nApvPairs_ << ") found for this module!";
146  }
147  }
148  } else {
149  if ( edm::isDebugEnabled() ) {
151  << "[FedChannelConnection::" << __func__ << "]"
152  << " Unexpected number of APV pairs: " << nApvPairs_;
153  }
154  }
155  return sistrip::invalid_;
156 }
157 
158 // -----------------------------------------------------------------------------
159 //
160 void FedChannelConnection::print( std::stringstream& ss ) const {
161  ss << " [FedChannelConnection::" << __func__ << "]" << std::endl
162  << " FedCrate/FedSlot/FedId/FeUnit/FeChan/FedCh : "
163  << fedCrate() << "/"
164  << fedSlot() << "/"
165  << fedId() << "/"
166  << SiStripFedKey::feUnit( fedCh() ) << "/"
167  << SiStripFedKey::feChan( fedCh() ) << "/"
168  << fedCh() << std::endl
169  << " FecCrate/FecSlot/FecRing/CcuAddr/CcuChan : "
170  << fecCrate() << "/"
171  << fecSlot() << "/"
172  << fecRing() << "/"
173  << ccuAddr() << "/"
174  << ccuChan() << std::endl
175  << " DcuId/DetId : "
176  << std::hex
177  << "0x" << std::setfill('0') << std::setw(8) << dcuId() << "/"
178  << "0x" << std::setfill('0') << std::setw(8) << detId() << std::endl
179  << std::dec
180  << " LldChan/APV0/APV1 : "
181  << lldChannel() << "/"
182  << i2cAddr(0) << "/"
183  << i2cAddr(1) << std::endl
184  << " pairNumber/nPairs/nStrips : "
185  << apvPairNumber() << "/"
186  << nApvPairs() << "/"
187  << 256*nApvPairs() << std::endl
188  << " DCU/MUX/PLL/LLD found : "
189  << std::boolalpha
190  << dcu() << "/"
191  << mux() << "/"
192  << pll() << "/"
193  << lld()
194  << std::noboolalpha;
195 }
196 
197 // -----------------------------------------------------------------------------
198 //
199 void FedChannelConnection::terse( std::stringstream& ss ) const {
200  ss << " FED:cr/sl/id/fe/ch/chan="
201  << fedCrate() << "/"
202  << fedSlot() << "/"
203  << fedId() << "/"
204  << SiStripFedKey::feUnit( fedCh() ) << "/"
205  << SiStripFedKey::feChan( fedCh() ) << "/"
206  << fedCh() << ","
207  << " FEC:cr/sl/ring/ccu/mod="
208  << fecCrate() << "/"
209  << fecSlot() << "/"
210  << fecRing() << "/"
211  << ccuAddr() << "/"
212  << ccuChan() << ","
213  << " apvs="
214  << i2cAddr(0) << "/"
215  << i2cAddr(1) << ","
216  << " pair=" << apvPairNumber()+1
217  << " (from " << nApvPairs() << "),"
218  << " dcu/detid="
219  << std::hex
220  << "0x" << std::setfill('0') << std::setw(8) << dcuId() << "/"
221  << "0x" << std::setfill('0') << std::setw(8) << detId()
222  << std::dec;
223 }
224 
225 // -----------------------------------------------------------------------------
226 //
227 std::ostream& operator<< ( std::ostream& os, const FedChannelConnection& conn ) {
228  std::stringstream ss;
229  conn.print(ss);
230  os << ss.str();
231  return os;
232 }
233 
const uint16_t & fecSlot() const
bool isDebugEnabled()
const uint16_t & fecCrate() const
const bool & lld() const
const uint16_t & fedCh() const
static const uint32_t invalid32_
Definition: Constants.h:15
uint16_t apvPairNumber() const
void terse(std::stringstream &) const
void print(std::stringstream &) const
uint16_t lldChannel() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
const uint16_t & fedId() const
static const char fecSlot_[]
static const char ccuChan_[]
static const char ccuAddr_[]
static const char mlCabling_[]
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
const uint16_t & fecRing() const
const uint16_t & fedSlot() const
const uint32_t & detId() const
Class containning control, module, detector and connection information, at the level of a FED channel...
const uint16_t & ccuChan() const
static const char fecCrate_[]
const bool & mux() const
const bool & dcu() const
const uint16_t & ccuAddr() const
const uint32_t & dcuId() const
const uint16_t & feUnit() const
const uint16_t & nApvPairs() const
static const char fecRing_[]
static const uint16_t invalid_
Definition: Constants.h:16
const bool & pll() const
const uint16_t & fedCrate() const
const uint16_t & feChan() const
volatile std::atomic< bool > shutdown_flag false
const uint16_t & i2cAddr(const uint16_t &apv0_or_1) const
tuple conn
Definition: results_mgr.py:53