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 
5 
6 #include <vector>
7 #include <algorithm>
8 #include <stdint.h>
9 #include <sstream>
10 
11 #define READMODEMASK 8
12 
58 {
59  public:
60 
62 
63  // Defined as public for genreflex
64  struct Latency
65  {
66  Latency(const uint32_t inputDetIdAndApv, const uint16_t inputLatency, const uint16_t inputMode) :
67  detIdAndApv(inputDetIdAndApv),
68  latency(inputLatency),
69  mode(inputMode)
70  {}
72  Latency() :
73  detIdAndApv(0),
74  latency(255),
75  mode(0)
76  {}
77  uint32_t detIdAndApv;
78  unsigned char latency;
79  unsigned char mode;
80 
82 };
83  typedef std::vector<Latency>::iterator latIt;
84  typedef std::vector<Latency>::const_iterator latConstIt;
85 
92  bool put( const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode );
93  uint16_t latency(const uint32_t detId, const uint16_t apv) const;
94  uint16_t mode(const uint32_t detId, const uint16_t apv) const;
95  std::pair<uint16_t, uint16_t> latencyAndMode(const uint32_t detId, const uint16_t apv) const;
96  inline std::vector<Latency> allLatencyAndModes() const { return latencies_; }
97 
99  void allLatencies(std::vector<uint16_t> & allLatenciesVector) const;
101  void allModes(std::vector<uint16_t> & allModesVector) const;
102  int16_t singleReadOutMode() const;
103  // bool allPeak() const;
104 
105  std::vector<Latency> allUniqueLatencyAndModes();
106 
111  void compress();
113  uint16_t singleLatency() const;
114  uint16_t singleMode() const;
115 
117  void printSummary(std::stringstream & ss) const;
119  void printDebug(std::stringstream & ss) const;
120 
122  {
123  bool operator()(const Latency & lat1, const uint32_t detIdAndApv) const {
124  return lat1.detIdAndApv < detIdAndApv;
125  }
126  };
127 
129  {
130  bool operator()(const Latency & lat1, const Latency & lat2) {
131  // latency and mode are unsigned short that cannot exceed 255.
132  // Sum them multiplying the mode by 1000 to get a single ordering number.
133  int latencyAndModeSortValue1 = int(lat1.latency) + 1000*int(lat1.mode);
134  int latencyAndModeSortValue2 = int(lat2.latency) + 1000*int(lat2.mode);
135  return( latencyAndModeSortValue1 < latencyAndModeSortValue2 );
136  }
137  };
139  {
140  bool operator()(const Latency & lat1, const Latency & lat2) {
141  return( (lat1.latency == lat2.latency) && (lat1.mode == lat2.mode) );
142  }
143  };
144 
145  private:
146 
148  // If put in the cc file it will not know about the typedefs and the Latency class
149  const latConstIt position(const uint32_t detId, const uint16_t apv) const
150  {
151  if( latencies_.empty() ) {
152  // std::cout << "SiStripLatency: Error, range is empty" << std::endl;
153  return latencies_.end();
154  }
155  uint32_t detIdAndApv = (detId << 3) | apv;
156  latConstIt pos = lower_bound(latencies_.begin(), latencies_.end(), detIdAndApv, OrderByDetIdAndApv());
157  return pos;
158  }
159  std::vector<Latency> latencies_;
160 
162 };
163 
164 #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