CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripLatency.h
Go to the documentation of this file.
1 #ifndef SiStripLatency_h
2 #define SiStripLatency_h
3 
4 #include <vector>
5 #include <algorithm>
6 #include <stdint.h>
7 #include <sstream>
8 
9 #define READMODEMASK 8
10 
56 {
57  public:
58 
60 
61  // Defined as public for genreflex
62  struct Latency
63  {
64  Latency(const uint32_t inputDetIdAndApv, const uint16_t inputLatency, const uint16_t inputMode) :
65  detIdAndApv(inputDetIdAndApv),
66  latency(inputLatency),
67  mode(inputMode)
68  {}
70  Latency() :
71  detIdAndApv(0),
72  latency(255),
73  mode(0)
74  {}
75  uint32_t detIdAndApv;
76  unsigned char latency;
77  unsigned char mode;
78  };
79  typedef std::vector<Latency>::iterator latIt;
80  typedef std::vector<Latency>::const_iterator latConstIt;
81 
88  bool put( const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode );
89  uint16_t latency(const uint32_t detId, const uint16_t apv) const;
90  uint16_t mode(const uint32_t detId, const uint16_t apv) const;
91  std::pair<uint16_t, uint16_t> latencyAndMode(const uint32_t detId, const uint16_t apv) const;
92  inline std::vector<Latency> allLatencyAndModes() const { return latencies_; }
93 
95  void allLatencies(std::vector<uint16_t> & allLatenciesVector) const;
97  void allModes(std::vector<uint16_t> & allModesVector) const;
98  int16_t singleReadOutMode() const;
99  // bool allPeak() const;
100 
101  std::vector<Latency> allUniqueLatencyAndModes();
102 
107  void compress();
109  uint16_t singleLatency() const;
110  uint16_t singleMode() const;
111 
113  void printSummary(std::stringstream & ss) const;
115  void printDebug(std::stringstream & ss) const;
116 
117  private:
118 
120  {
121  bool operator()(const Latency & lat1, const uint32_t detIdAndApv) const {
122  return lat1.detIdAndApv < detIdAndApv;
123  }
124  };
125 
127  {
128  bool operator()(const Latency & lat1, const Latency & lat2) {
129  // latency and mode are unsigned short that cannot exceed 255.
130  // Sum them multiplying the mode by 1000 to get a single ordering number.
131  int latencyAndModeSortValue1 = int(lat1.latency) + 1000*int(lat1.mode);
132  int latencyAndModeSortValue2 = int(lat2.latency) + 1000*int(lat2.mode);
133  return( latencyAndModeSortValue1 < latencyAndModeSortValue2 );
134  }
135  };
137  {
138  bool operator()(const Latency & lat1, const Latency & lat2) {
139  return( (lat1.latency == lat2.latency) && (lat1.mode == lat2.mode) );
140  }
141  };
142 
144  // If put in the cc file it will not know about the typedefs and the Latency class
145  const latConstIt position(const uint32_t detId, const uint16_t apv) const
146  {
147  if( latencies_.empty() ) {
148  // std::cout << "SiStripLatency: Error, range is empty" << std::endl;
149  return latencies_.end();
150  }
151  uint32_t detIdAndApv = (detId << 3) | apv;
152  latConstIt pos = lower_bound(latencies_.begin(), latencies_.end(), detIdAndApv, OrderByDetIdAndApv());
153  return pos;
154  }
155  std::vector<Latency> latencies_;
156 };
157 
158 #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)
uint16_t mode(const uint32_t detId, const uint16_t apv) const
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.
void printSummary(std::stringstream &ss) const
Prints the number of ranges as well as the value of singleLatency and singleMode. ...
uint16_t singleMode() const
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)
uint16_t latency(const uint32_t detId, const uint16_t apv) const
std::vector< Latency > latencies_
void printDebug(std::stringstream &ss) const
Prints the full list of all ranges and corresponding values of latency and mode.
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