CMS 3D CMS Logo

SiStripLatency.h
Go to the documentation of this file.
1 #ifndef SiStripLatency_h
2 #define SiStripLatency_h
3 
5 
6 #include <vector>
7 #include <algorithm>
8 #include <cstdint>
9 #include <sstream>
10 
11 class TrackerTopology;
12 
13 #define READMODEMASK 8
14 
60 public:
62 
63  // Defined as public for genreflex
64  struct Latency {
65  Latency(const uint32_t inputDetIdAndApv, const uint16_t inputLatency, const uint16_t inputMode)
66  : detIdAndApv(inputDetIdAndApv), latency(inputLatency), mode(inputMode) {}
68  Latency() : detIdAndApv(0), latency(255), mode(0) {}
69  uint32_t detIdAndApv;
70  unsigned char latency;
71  unsigned char mode;
72 
74  };
75  typedef std::vector<Latency>::iterator latIt;
76  typedef std::vector<Latency>::const_iterator latConstIt;
77 
84  bool put(const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode);
85  uint16_t latency(const uint32_t detId, const uint16_t apv) const;
86  uint16_t mode(const uint32_t detId, const uint16_t apv) const;
87  std::pair<uint16_t, uint16_t> latencyAndMode(const uint32_t detId, const uint16_t apv) const;
88  inline std::vector<Latency> allLatencyAndModes() const { return latencies_; }
89 
91  void allLatencies(std::vector<uint16_t>& allLatenciesVector) const;
93  void allModes(std::vector<uint16_t>& allModesVector) const;
94  int16_t singleReadOutMode() const;
95  // bool allPeak() const;
96 
97  std::vector<Latency> allUniqueLatencyAndModes();
98 
103  void compress();
105  uint16_t singleLatency() const;
106  uint16_t singleMode() const;
107 
109  void printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
111  void printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
112 
114  bool operator()(const Latency& lat1, const uint32_t detIdAndApv) const { return lat1.detIdAndApv < detIdAndApv; }
115  };
116 
118  bool operator()(const Latency& lat1, const Latency& lat2) {
119  // latency and mode are unsigned short that cannot exceed 255.
120  // Sum them multiplying the mode by 1000 to get a single ordering number.
121  int latencyAndModeSortValue1 = int(lat1.latency) + 1000 * int(lat1.mode);
122  int latencyAndModeSortValue2 = int(lat2.latency) + 1000 * int(lat2.mode);
123  return (latencyAndModeSortValue1 < latencyAndModeSortValue2);
124  }
125  };
127  bool operator()(const Latency& lat1, const Latency& lat2) {
128  return ((lat1.latency == lat2.latency) && (lat1.mode == lat2.mode));
129  }
130  };
131 
132 private:
134  // If put in the cc file it will not know about the typedefs and the Latency class
135  const latConstIt position(const uint32_t detId, const uint16_t apv) const {
136  if (latencies_.empty()) {
137  // std::cout << "SiStripLatency: Error, range is empty" << std::endl;
138  return latencies_.end();
139  }
140  uint32_t detIdAndApv = (detId << 3) | apv;
141  latConstIt pos = lower_bound(latencies_.begin(), latencies_.end(), detIdAndApv, OrderByDetIdAndApv());
142  return pos;
143  }
144  std::vector<Latency> latencies_;
145 
147 };
148 
149 #endif
SiStripLatency::position
const latConstIt position(const uint32_t detId, const uint16_t apv) const
Used to compute the position with the lower_bound binary search.
Definition: SiStripLatency.h:135
SiStripLatency::SiStripLatency
SiStripLatency()
Definition: SiStripLatency.h:61
SiStripLatency::OrderByDetIdAndApv
Definition: SiStripLatency.h:113
TrackerTopology
Definition: TrackerTopology.h:16
pos
Definition: PixelAliasList.h:18
SiStripLatency::latencyAndMode
std::pair< uint16_t, uint16_t > latencyAndMode(const uint32_t detId, const uint16_t apv) const
Definition: SiStripLatency.cc:71
SiStripLatency::allLatencyAndModes
std::vector< Latency > allLatencyAndModes() const
Definition: SiStripLatency.h:88
COND_SERIALIZABLE
#define COND_SERIALIZABLE
Definition: Serializable.h:39
SiStripLatency::EqualByLatencyAndMode::operator()
bool operator()(const Latency &lat1, const Latency &lat2)
Definition: SiStripLatency.h:127
SiStripLatency::allUniqueLatencyAndModes
std::vector< Latency > allUniqueLatencyAndModes()
Definition: SiStripLatency.cc:165
SiStripLatency::Latency::detIdAndApv
uint32_t detIdAndApv
Definition: SiStripLatency.h:69
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SiStripLatency::latencies_
std::vector< Latency > latencies_
Definition: SiStripLatency.h:144
SiStripLatency::printDebug
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the full list of all ranges and corresponding values of latency and mode.
Definition: SiStripLatency.cc:198
SiStripLatency::compress
void compress()
Definition: SiStripLatency.cc:43
SiStripLatency::Latency::Latency
Latency()
Default constructor needed by genreflex.
Definition: SiStripLatency.h:68
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
SiStripLatency::Latency::latency
unsigned char latency
Definition: SiStripLatency.h:70
SiStripLatency::put
bool put(const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode)
Definition: SiStripLatency.cc:10
SiStripLatency::printSummary
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the number of ranges as well as the value of singleLatency and singleMode.
Definition: SiStripLatency.cc:173
SiStripLatency::OrderByLatencyAndMode
Definition: SiStripLatency.h:117
SiStripLatency::allLatencies
void allLatencies(std::vector< uint16_t > &allLatenciesVector) const
Fills the passed vector with all the possible latencies in the Tracker.
Definition: SiStripLatency.cc:156
SiStripLatency::latency
uint16_t latency(const uint32_t detId, const uint16_t apv) const
Definition: SiStripLatency.cc:55
SiStripLatency::latIt
std::vector< Latency >::iterator latIt
Definition: SiStripLatency.h:75
SiStripLatency::singleMode
uint16_t singleMode() const
Definition: SiStripLatency.cc:96
createfilelist.int
int
Definition: createfilelist.py:10
Serializable.h
SiStripLatency::singleReadOutMode
int16_t singleReadOutMode() const
Definition: SiStripLatency.cc:122
SiStripLatency::EqualByLatencyAndMode
Definition: SiStripLatency.h:126
SiStripLatency::allModes
void allModes(std::vector< uint16_t > &allModesVector) const
Fills the passed vector with all the possible modes in the Tracker.
Definition: SiStripLatency.cc:113
SiStripLatency::latConstIt
std::vector< Latency >::const_iterator latConstIt
Definition: SiStripLatency.h:76
SiStripLatency::mode
uint16_t mode(const uint32_t detId, const uint16_t apv) const
Definition: SiStripLatency.cc:63
SiStripLatency::OrderByDetIdAndApv::operator()
bool operator()(const Latency &lat1, const uint32_t detIdAndApv) const
Definition: SiStripLatency.h:114
SiStripLatency::singleLatency
uint16_t singleLatency() const
If all the latency values stored are equal return that value, otherwise return -1.
Definition: SiStripLatency.cc:79
SiStripLatency::Latency
Definition: SiStripLatency.h:64
SiStripLatency
Definition: SiStripLatency.h:59
SiStripLatency::Latency::Latency
Latency(const uint32_t inputDetIdAndApv, const uint16_t inputLatency, const uint16_t inputMode)
Definition: SiStripLatency.h:65
SiStripLatency::OrderByLatencyAndMode::operator()
bool operator()(const Latency &lat1, const Latency &lat2)
Definition: SiStripLatency.h:118
SiStripLatency::Latency::mode
unsigned char mode
Definition: SiStripLatency.h:71