File indexing completed on 2024-04-06 12:02:39
0001 #ifndef CondFormats_SiStripObjects_SiStripFedCabling_H
0002 #define CondFormats_SiStripObjects_SiStripFedCabling_H
0003
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005
0006 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
0007 #include <boost/range/iterator_range.hpp>
0008 #include <sstream>
0009 #include <vector>
0010 #include <string>
0011 #include <cstdint>
0012
0013 #define SISTRIPCABLING_USING_NEW_STRUCTURE
0014 #define SISTRIPCABLING_USING_NEW_INTERFACE
0015
0016 class TrackerTopology;
0017
0018 class SiStripFedCabling;
0019
0020
0021
0022
0023
0024
0025 class SiStripFedCabling {
0026 public:
0027
0028
0029 typedef std::vector<uint16_t> Feds;
0030
0031 typedef Feds::iterator FedsIter;
0032
0033 typedef Feds::const_iterator FedsConstIter;
0034
0035 typedef boost::iterator_range<FedsIter> FedsIterRange;
0036
0037 typedef boost::iterator_range<FedsConstIter> FedsConstIterRange;
0038
0039 typedef std::vector<FedChannelConnection> Conns;
0040
0041 typedef Conns::iterator ConnsIter;
0042
0043 typedef Conns::const_iterator ConnsConstIter;
0044
0045 typedef boost::iterator_range<ConnsIter> ConnsIterRange;
0046
0047 typedef boost::iterator_range<ConnsConstIter> ConnsConstIterRange;
0048
0049 typedef std::pair<uint32_t, uint32_t> ConnsPair;
0050
0051 typedef std::vector<ConnsPair> Registry;
0052
0053
0054
0055
0056 SiStripFedCabling(ConnsConstIterRange);
0057
0058
0059 SiStripFedCabling(const SiStripFedCabling&);
0060
0061
0062 SiStripFedCabling();
0063
0064
0065 ~SiStripFedCabling();
0066
0067
0068
0069
0070 FedsConstIterRange fedIds() const;
0071
0072
0073 ConnsConstIterRange fedConnections(uint16_t fed_id) const;
0074
0075
0076 FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const;
0077
0078
0079 ConnsConstIterRange detectedDevices() const;
0080
0081
0082 ConnsConstIterRange undetectedDevices() const;
0083
0084
0085
0086
0087 void buildFedCabling(ConnsConstIterRange connections);
0088
0089
0090 void printDebug(std::stringstream&, const TrackerTopology* trackerTopo) const;
0091
0092
0093 void print(std::stringstream& ss, const TrackerTopology* trackerTopo) const { printDebug(ss, trackerTopo); }
0094
0095
0096 void terse(std::stringstream&) const;
0097
0098
0099 void printSummary(std::stringstream&, const TrackerTopology* trackerTopo) const;
0100
0101 void summary(std::stringstream& ss, const TrackerTopology* trackerTopo) const { printSummary(ss, trackerTopo); }
0102
0103
0104 class ConnsRange {
0105 public:
0106 ConnsRange(const Conns&, ConnsPair);
0107 ConnsRange(const Conns&);
0108 ConnsRange() { ; }
0109
0110 ConnsConstIter begin() const;
0111 ConnsConstIter end() const;
0112 ConnsConstIterRange range() const;
0113 ConnsConstIterRange invalid() const;
0114
0115 bool empty() const;
0116 uint32_t size() const;
0117
0118 ConnsPair connsPair() const;
0119 static ConnsPair emptyPair();
0120
0121 void print(std::stringstream&) const;
0122
0123 private:
0124 ConnsConstIterRange vector_;
0125 ConnsConstIterRange range_;
0126 };
0127
0128
0129 ConnsRange range(ConnsPair) const;
0130
0131
0132
0133 private:
0134
0135 Feds feds_;
0136
0137
0138 Registry registry_;
0139
0140
0141 Conns connections_;
0142
0143
0144 Conns detected_;
0145
0146
0147 Conns undetected_;
0148
0149 COND_SERIALIZABLE;
0150 };
0151
0152 std::ostream& operator<<(std::ostream&, const SiStripFedCabling::ConnsRange&);
0153
0154 inline SiStripFedCabling::FedsConstIterRange SiStripFedCabling::fedIds() const {
0155 return FedsConstIterRange(feds_.begin(), feds_.end());
0156 }
0157
0158 inline SiStripFedCabling::ConnsConstIterRange SiStripFedCabling::detectedDevices() const {
0159 return ConnsConstIterRange(detected_.begin(), detected_.end());
0160 }
0161
0162 inline SiStripFedCabling::ConnsConstIterRange SiStripFedCabling::undetectedDevices() const {
0163 return ConnsConstIterRange(undetected_.begin(), undetected_.end());
0164 }
0165
0166 inline SiStripFedCabling::ConnsConstIter SiStripFedCabling::ConnsRange::begin() const { return range_.begin(); }
0167
0168 inline SiStripFedCabling::ConnsConstIter SiStripFedCabling::ConnsRange::end() const { return range_.end(); }
0169
0170 inline SiStripFedCabling::ConnsConstIterRange SiStripFedCabling::ConnsRange::range() const { return range_; }
0171
0172 inline SiStripFedCabling::ConnsConstIterRange SiStripFedCabling::ConnsRange::invalid() const {
0173 return ConnsConstIterRange(vector_.end(), vector_.end());
0174 }
0175
0176 inline bool SiStripFedCabling::ConnsRange::empty() const { return (range_.begin() == range_.end()); }
0177
0178 inline uint32_t SiStripFedCabling::ConnsRange::size() const { return std::distance(range_.begin(), range_.end()); }
0179
0180 inline SiStripFedCabling::ConnsPair SiStripFedCabling::ConnsRange::connsPair() const {
0181 return (
0182 (range_.begin() == vector_.end() && range_.end() == vector_.end())
0183 ? ConnsPair(sistrip::invalid32_, sistrip::invalid32_)
0184 : ConnsPair(std::distance(vector_.begin(), range_.begin()), std::distance(vector_.begin(), range_.end())));
0185 }
0186
0187 inline SiStripFedCabling::ConnsPair SiStripFedCabling::ConnsRange::emptyPair() {
0188 return ConnsPair(sistrip::invalid32_, sistrip::invalid32_);
0189 }
0190
0191 inline SiStripFedCabling::ConnsRange SiStripFedCabling::range(SiStripFedCabling::ConnsPair p) const {
0192 return ConnsRange(connections_, p);
0193 }
0194
0195 #endif