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 {
61  public:
62 
64 
65  // Defined as public for genreflex
66  struct Latency
67  {
68  Latency(const uint32_t inputDetIdAndApv, const uint16_t inputLatency, const uint16_t inputMode) :
69  detIdAndApv(inputDetIdAndApv),
70  latency(inputLatency),
71  mode(inputMode)
72  {}
74  Latency() :
75  detIdAndApv(0),
76  latency(255),
77  mode(0)
78  {}
79  uint32_t detIdAndApv;
80  unsigned char latency;
81  unsigned char mode;
82 
84 };
85  typedef std::vector<Latency>::iterator latIt;
86  typedef std::vector<Latency>::const_iterator latConstIt;
87 
94  bool put( const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode );
95  uint16_t latency(const uint32_t detId, const uint16_t apv) const;
96  uint16_t mode(const uint32_t detId, const uint16_t apv) const;
97  std::pair<uint16_t, uint16_t> latencyAndMode(const uint32_t detId, const uint16_t apv) const;
98  inline std::vector<Latency> allLatencyAndModes() const { return latencies_; }
99 
101  void allLatencies(std::vector<uint16_t> & allLatenciesVector) const;
103  void allModes(std::vector<uint16_t> & allModesVector) const;
104  int16_t singleReadOutMode() const;
105  // bool allPeak() const;
106 
107  std::vector<Latency> allUniqueLatencyAndModes();
108 
113  void compress();
115  uint16_t singleLatency() const;
116  uint16_t singleMode() const;
117 
119  void printSummary(std::stringstream & ss, const TrackerTopology* trackerTopo) const;
121  void printDebug(std::stringstream & ss, const TrackerTopology* trackerTopo) const;
122 
124  {
125  bool operator()(const Latency & lat1, const uint32_t detIdAndApv) const {
126  return lat1.detIdAndApv < detIdAndApv;
127  }
128  };
129 
131  {
132  bool operator()(const Latency & lat1, const Latency & lat2) {
133  // latency and mode are unsigned short that cannot exceed 255.
134  // Sum them multiplying the mode by 1000 to get a single ordering number.
135  int latencyAndModeSortValue1 = int(lat1.latency) + 1000*int(lat1.mode);
136  int latencyAndModeSortValue2 = int(lat2.latency) + 1000*int(lat2.mode);
137  return( latencyAndModeSortValue1 < latencyAndModeSortValue2 );
138  }
139  };
141  {
142  bool operator()(const Latency & lat1, const Latency & lat2) {
143  return( (lat1.latency == lat2.latency) && (lat1.mode == lat2.mode) );
144  }
145  };
146 
147  private:
148 
150  // If put in the cc file it will not know about the typedefs and the Latency class
151  const latConstIt position(const uint32_t detId, const uint16_t apv) const
152  {
153  if( latencies_.empty() ) {
154  // std::cout << "SiStripLatency: Error, range is empty" << std::endl;
155  return latencies_.end();
156  }
157  uint32_t detIdAndApv = (detId << 3) | apv;
158  latConstIt pos = lower_bound(latencies_.begin(), latencies_.end(), detIdAndApv, OrderByDetIdAndApv());
159  return pos;
160  }
161  std::vector<Latency> latencies_;
162 
164 };
165 
166 #endif
Latency()
Default constructor needed by genreflex.
bool put(const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode)
std::vector< Latency > allUniqueLatencyAndModes()
int16_t singleReadOutMode() const
Latency(const uint32_t inputDetIdAndApv, const uint16_t inputLatency, const uint16_t inputMode)
std::vector< Latency >::iterator latIt
bool operator()(const Latency &lat1, const Latency &lat2)
void allLatencies(std::vector< uint16_t > &allLatenciesVector) const
Fills the passed vector with all the possible latencies in the Tracker.
bool operator()(const Latency &lat1, const uint32_t detIdAndApv) const
uint16_t singleLatency() const
If all the latency values stored are equal return that value, otherwise return -1.
void allModes(std::vector< uint16_t > &allModesVector) const
Fills the passed vector with all the possible modes in the Tracker.
uint16_t singleMode() const
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the full list of all ranges and corresponding values of latency and mode.
const latConstIt position(const uint32_t detId, const uint16_t apv) const
Used to compute the position with the lower_bound binary search.
bool operator()(const Latency &lat1, const Latency &lat2)
std::vector< Latency > latencies_
#define COND_SERIALIZABLE
Definition: Serializable.h:38
std::vector< Latency >::const_iterator latConstIt
std::vector< Latency > allLatencyAndModes() const
std::pair< uint16_t, uint16_t > latencyAndMode(const uint32_t detId, const uint16_t apv) const
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the number of ranges as well as the value of singleLatency and singleMode. ...