CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
SiStripLatency Class Reference

#include <SiStripLatency.h>

Classes

struct  EqualByLatencyAndMode
 
struct  Latency
 
struct  OrderByDetIdAndApv
 
struct  OrderByLatencyAndMode
 

Public Types

typedef std::vector< Latency >::const_iterator latConstIt
 
typedef std::vector< Latency >::iterator latIt
 

Public Member Functions

void allLatencies (std::vector< uint16_t > &allLatenciesVector) const
 Fills the passed vector with all the possible latencies in the Tracker. More...
 
std::vector< LatencyallLatencyAndModes () const
 
void allModes (std::vector< uint16_t > &allModesVector) const
 Fills the passed vector with all the possible modes in the Tracker. More...
 
std::vector< LatencyallUniqueLatencyAndModes ()
 
void compress ()
 
uint16_t latency (const uint32_t detId, const uint16_t apv) const
 
std::pair< uint16_t, uint16_t > latencyAndMode (const uint32_t detId, const uint16_t apv) const
 
uint16_t mode (const uint32_t detId, const uint16_t apv) const
 
void printDebug (std::stringstream &ss, const TrackerTopology *trackerTopo) const
 Prints the full list of all ranges and corresponding values of latency and mode. More...
 
void printSummary (std::stringstream &ss, const TrackerTopology *trackerTopo) const
 Prints the number of ranges as well as the value of singleLatency and singleMode. More...
 
bool put (const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode)
 
uint16_t singleLatency () const
 If all the latency values stored are equal return that value, otherwise return -1. More...
 
uint16_t singleMode () const
 
int16_t singleReadOutMode () const
 
 SiStripLatency ()
 

Private Member Functions

const latConstIt position (const uint32_t detId, const uint16_t apv) const
 Used to compute the position with the lower_bound binary search. More...
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

std::vector< Latencylatencies_
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Holds the latency and the mode of the run.
The latency is stored per apv and the information is compressed by reducing sequences of apvs with the same latency to a single value plus information on the start and end of the sequence.
The mode is a single value, stored as a char. The actual operation mode bit is bit number 3 starting from 0. The bitmask to retrieve the information in the number 8 (1000).

Examples:
/tmp/cmsbuild/jenkins/workspace/cmssw-doxygen/cmsdoxy/TMP/CMSSW_14_2_0_pre4/src/CalibTracker/SiStripLorentzAngle/interface/SiStripLorentzAngleCalibrationHelpers.h.

Definition at line 59 of file SiStripLatency.h.

Member Typedef Documentation

◆ latConstIt

typedef std::vector<Latency>::const_iterator SiStripLatency::latConstIt

Definition at line 76 of file SiStripLatency.h.

◆ latIt

typedef std::vector<Latency>::iterator SiStripLatency::latIt

Definition at line 75 of file SiStripLatency.h.

Constructor & Destructor Documentation

◆ SiStripLatency()

SiStripLatency::SiStripLatency ( )
inline

Definition at line 61 of file SiStripLatency.h.

61 {}

Member Function Documentation

◆ allLatencies()

void SiStripLatency::allLatencies ( std::vector< uint16_t > &  allLatenciesVector) const

Fills the passed vector with all the possible latencies in the Tracker.

Definition at line 162 of file SiStripLatency.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, latencies_, jetUpdater_cfi::sort, and tier0::unique().

Referenced by printSummary().

162  {
163  for (latConstIt it = latencies_.begin(); it != latencies_.end(); ++it) {
164  allLatenciesVector.push_back(it->latency);
165  }
166  // The Latencies are sorted by DetIdAndApv, we need to sort the latencies again and then remove duplicates
167  sort(allLatenciesVector.begin(), allLatenciesVector.end());
168  allLatenciesVector.erase(unique(allLatenciesVector.begin(), allLatenciesVector.end()), allLatenciesVector.end());
169 }
def unique(seq, keepstr=True)
Definition: tier0.py:24
std::vector< Latency > latencies_
std::vector< Latency >::const_iterator latConstIt

◆ allLatencyAndModes()

std::vector<Latency> SiStripLatency::allLatencyAndModes ( ) const
inline

Definition at line 88 of file SiStripLatency.h.

References latencies_.

88 { return latencies_; }
std::vector< Latency > latencies_

◆ allModes()

void SiStripLatency::allModes ( std::vector< uint16_t > &  allModesVector) const

Fills the passed vector with all the possible modes in the Tracker.

Definition at line 119 of file SiStripLatency.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, latencies_, jetUpdater_cfi::sort, and tier0::unique().

Referenced by singleReadOutMode().

119  {
120  for (latConstIt it = latencies_.begin(); it != latencies_.end(); ++it) {
121  allModesVector.push_back(it->mode);
122  }
123  // The Latencies are sorted by DetIdAndApv, we need to sort the modes again and then remove duplicates
124  sort(allModesVector.begin(), allModesVector.end());
125  allModesVector.erase(unique(allModesVector.begin(), allModesVector.end()), allModesVector.end());
126 }
def unique(seq, keepstr=True)
Definition: tier0.py:24
std::vector< Latency > latencies_
std::vector< Latency >::const_iterator latConstIt

◆ allUniqueLatencyAndModes()

std::vector< SiStripLatency::Latency > SiStripLatency::allUniqueLatencyAndModes ( )

Definition at line 171 of file SiStripLatency.cc.

References latencies_, jetUpdater_cfi::sort, and tier0::unique().

171  {
172  std::vector<Latency> latencyCopy(latencies_);
173  sort(latencyCopy.begin(), latencyCopy.end(), OrderByLatencyAndMode());
174  latencyCopy.erase(unique(latencyCopy.begin(), latencyCopy.end(), SiStripLatency::EqualByLatencyAndMode()),
175  latencyCopy.end());
176  return latencyCopy;
177 }
def unique(seq, keepstr=True)
Definition: tier0.py:24
std::vector< Latency > latencies_

◆ compress()

void SiStripLatency::compress ( )

Reduce ranges of consecutive detIdsAndApvs with the same latency and mode to one value (the latest) so that lower_bound will return the correct value for latency and mode.

Definition at line 43 of file SiStripLatency.cc.

References latencies_.

Referenced by SiStripCondObjBuilderFromDb::buildFECRelatedObjects().

43  {
44  latIt lat = latencies_.begin();
45  while (lat != latencies_.end()) {
46  // If it is not the last and it has the same latency and mode as the next one remove it
47  if (((lat + 1) != latencies_.end()) && ((lat + 1)->mode == lat->mode) && ((lat + 1)->latency == lat->latency)) {
48  lat = latencies_.erase(lat);
49  } else {
50  ++lat;
51  }
52  }
53 }
std::vector< Latency >::iterator latIt
std::vector< Latency > latencies_

◆ latency()

uint16_t SiStripLatency::latency ( const uint32_t  detId,
const uint16_t  apv 
) const

Definition at line 55 of file SiStripLatency.cc.

References hcalRecHitTable_cff::detId, latencies_, and position().

Referenced by SiStripDB2Tree::analyze(), and put().

55  {
56  const latConstIt& pos = position(detId, apv);
57  if (pos == latencies_.end()) {
58  return 255;
59  }
60  return pos->latency;
61 }
const latConstIt position(const uint32_t detId, const uint16_t apv) const
Used to compute the position with the lower_bound binary search.
std::vector< Latency > latencies_
std::vector< Latency >::const_iterator latConstIt

◆ latencyAndMode()

std::pair< uint16_t, uint16_t > SiStripLatency::latencyAndMode ( const uint32_t  detId,
const uint16_t  apv 
) const

Definition at line 71 of file SiStripLatency.cc.

References hcalRecHitTable_cff::detId, latencies_, and position().

71  {
72  const latConstIt& pos = position(detId, apv);
73  if (pos == latencies_.end()) {
74  return std::make_pair(255, 0);
75  }
76  return std::make_pair(pos->latency, pos->mode);
77 }
const latConstIt position(const uint32_t detId, const uint16_t apv) const
Used to compute the position with the lower_bound binary search.
std::vector< Latency > latencies_
std::vector< Latency >::const_iterator latConstIt

◆ mode()

uint16_t SiStripLatency::mode ( const uint32_t  detId,
const uint16_t  apv 
) const

Definition at line 63 of file SiStripLatency.cc.

References hcalRecHitTable_cff::detId, latencies_, and position().

Referenced by put(), and singleReadOutMode().

63  {
64  const latConstIt& pos = position(detId, apv);
65  if (pos == latencies_.end()) {
66  return 0;
67  }
68  return pos->mode;
69 }
const latConstIt position(const uint32_t detId, const uint16_t apv) const
Used to compute the position with the lower_bound binary search.
std::vector< Latency > latencies_
std::vector< Latency >::const_iterator latConstIt

◆ position()

const latConstIt SiStripLatency::position ( const uint32_t  detId,
const uint16_t  apv 
) const
inlineprivate

Used to compute the position with the lower_bound binary search.

Definition at line 135 of file SiStripLatency.h.

References hcalRecHitTable_cff::detId, latencies_, and pfDeepBoostedJetPreprocessParams_cfi::lower_bound.

Referenced by latency(), latencyAndMode(), and mode().

135  {
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  }
std::vector< Latency > latencies_
std::vector< Latency >::const_iterator latConstIt

◆ printDebug()

void SiStripLatency::printDebug ( std::stringstream &  ss,
const TrackerTopology trackerTopo 
) const

Prints the full list of all ranges and corresponding values of latency and mode.

Definition at line 204 of file SiStripLatency.cc.

References hcalRecHitTable_cff::detId, createfilelist::int, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, latencies_, and contentValuesCheck::ss.

Referenced by SiStripCondObjBuilderFromDb::buildFECRelatedObjects(), and printSummary().

204  {
205  ss << "List of all the latencies and modes for the " << latencies_.size() << " ranges in the object:" << std::endl;
206  for (latConstIt it = latencies_.begin(); it != latencies_.end(); ++it) {
207  int detId = it->detIdAndApv >> 3;
208  int apv = it->detIdAndApv & 7; // 7 is 0...0111
209  ss << "for detId = " << detId << " and apv pair = " << apv << " latency = " << int(it->latency)
210  << " and mode = " << int(it->mode) << std::endl;
211  }
212 }
std::vector< Latency > latencies_
std::vector< Latency >::const_iterator latConstIt

◆ printSummary()

void SiStripLatency::printSummary ( std::stringstream &  ss,
const TrackerTopology trackerTopo 
) const

Prints the number of ranges as well as the value of singleLatency and singleMode.

Definition at line 179 of file SiStripLatency.cc.

References allLatencies(), latencies_, printDebug(), singleLatency(), singleReadOutMode(), and contentValuesCheck::ss.

Referenced by SiStripCondObjBuilderFromDb::buildFECRelatedObjects().

179  {
180  ss << std::endl;
181  if (singleReadOutMode() == 1) {
182  ss << "SingleReadOut = PEAK" << std::endl;
183  } else if (singleReadOutMode() == 0) {
184  ss << "SingleReadOut = DECO" << std::endl;
185  } else {
186  ss << "SingleReadOut = MIXED" << std::endl;
187  }
188  uint16_t lat = singleLatency();
189  if (lat != 255) {
190  ss << "All the Tracker has the same latency = " << lat << std::endl;
191  } else {
192  std::vector<uint16_t> allLatenciesVector;
193  allLatencies(allLatenciesVector);
194  if (allLatenciesVector.size() > 1) {
195  ss << "There is more than one latency value in the Tracker" << std::endl;
196  } else {
197  ss << "Latency value is " << lat << " that means invalid" << std::endl;
198  }
199  }
200  ss << "Total number of ranges = " << latencies_.size() << std::endl;
201  printDebug(ss, trackerTopo);
202 }
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the full list of all ranges and corresponding values of latency and mode.
void allLatencies(std::vector< uint16_t > &allLatenciesVector) const
Fills the passed vector with all the possible latencies in the Tracker.
int16_t singleReadOutMode() const
std::vector< Latency > latencies_
uint16_t singleLatency() const
If all the latency values stored are equal return that value, otherwise return -1.

◆ put()

bool SiStripLatency::put ( const uint32_t  detId,
const uint16_t  apv,
const uint16_t  latency,
const uint16_t  mode 
)

Saves the detIdAndApv and latency values in the vector of Latency objects. At the end of the filling phase, the compress method should be called to collapse all ranges in single values. Note that everything would work even if the compress method is not called, only the space used would be more than needed.

Definition at line 10 of file SiStripLatency.cc.

References gather_cfg::cout, hcalRecHitTable_cff::detId, relativeConstraints::error, Exception, latencies_, latency(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, and mode().

Referenced by SiStripCondObjBuilderFromDb::setDefaultValuesApvLatency(), and SiStripCondObjBuilderFromDb::setValuesApvLatency().

10  {
11  if (detId > 536870911) {
12  std::stringstream error;
13  error << "ERROR: the detId = " << detId
14  << " is bigger than the maximum acceptable value = 2^(29) - 1 = " << 536870911 << std::endl;
15  error << "Since we are using 29 bits for the detId and 3 bits for the apv value. The maximum tracker detId at the "
16  "moment"
17  << std::endl;
18  error
19  << "of the writing of this class was 47017836 as defined in CalibTracker/SiStripCommon/data/SiStripDetInfo.dat."
20  << std::endl;
21  error << "If the maximum value has changed a revision of this calss is needed, possibly changing the detIdAndApv "
22  "value from"
23  << std::endl;
24  error << "from uint32_t to uint64_t." << std::endl;
25  edm::LogError("SiStripLatency::put") << error.str();
26  throw cms::Exception("InsertFailure");
27  }
28 
29  // Store all the values in the vectors
30  uint32_t detIdAndApv = (detId << 3) | apv;
31  latIt pos = lower_bound(latencies_.begin(), latencies_.end(), detIdAndApv, OrderByDetIdAndApv());
32 
33  if (pos != latencies_.end() && pos->detIdAndApv == detIdAndApv) {
34  std::cout << "Value already inserted, skipping insertion" << std::endl;
35  return false;
36  }
37  // std::cout << "Filling with: latency = " << latency << ", mode = " << mode << std::endl;
38  latencies_.insert(pos, Latency(detIdAndApv, latency, mode));
39 
40  return true;
41 }
Log< level::Error, false > LogError
uint16_t mode(const uint32_t detId, const uint16_t apv) const
std::vector< Latency >::iterator latIt
std::vector< Latency > latencies_
uint16_t latency(const uint32_t detId, const uint16_t apv) const

◆ serialize()

template<class Archive >
void SiStripLatency::serialize ( Archive &  ar,
const unsigned int  version 
)
private

◆ singleLatency()

uint16_t SiStripLatency::singleLatency ( ) const

If all the latency values stored are equal return that value, otherwise return -1.

Definition at line 79 of file SiStripLatency.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, and latencies_.

Referenced by printSummary().

79  {
80  if (latencies_.empty()) {
81  return 255;
82  }
83  if (latencies_.size() == 1) {
84  return latencies_[0].latency;
85  }
86  int differentLatenciesNum = 0;
87  // Count the number of different latencies
88  for (latConstIt it = latencies_.begin(); it != latencies_.end() - 1; ++it) {
89  if (it->latency != (it + 1)->latency) {
90  ++differentLatenciesNum;
91  }
92  }
93  if (differentLatenciesNum == 0) {
94  return latencies_[0].latency;
95  }
96  return 255;
97 }
std::vector< Latency > latencies_
std::vector< Latency >::const_iterator latConstIt

◆ singleMode()

uint16_t SiStripLatency::singleMode ( ) const

Definition at line 99 of file SiStripLatency.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, and latencies_.

Referenced by singleReadOutMode().

99  {
100  if (latencies_.empty()) {
101  return 0;
102  }
103  if (latencies_.size() == 1) {
104  return latencies_[0].mode;
105  }
106  int differentModesNum = 0;
107  // Count the number of different modes
108  for (latConstIt it = latencies_.begin(); it != latencies_.end() - 1; ++it) {
109  if (it->mode != (it + 1)->mode) {
110  ++differentModesNum;
111  }
112  }
113  if (differentModesNum == 0) {
114  return latencies_[0].mode;
115  }
116  return 0;
117 }
std::vector< Latency > latencies_
std::vector< Latency >::const_iterator latConstIt

◆ singleReadOutMode()

int16_t SiStripLatency::singleReadOutMode ( ) const

Definition at line 128 of file SiStripLatency.cc.

References allModes(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, mode(), READMODEMASK, and singleMode().

Referenced by GeneralPurposeTrackAnalyzer::beginRun(), DMRChecker::beginRun(), printSummary(), SiStripBackPlaneCorrectionDepESProducer::SiStripBackPlaneCorrectionDepESProducer(), and SiStripLorentzAngleDepESProducer::SiStripLorentzAngleDepESProducer().

128  {
129  uint16_t mode = singleMode();
130  if (mode != 0) {
131  if ((mode & READMODEMASK) == READMODEMASK)
132  return 1;
133  if ((mode & READMODEMASK) == 0)
134  return 0;
135  } else {
136  // If we are here the Tracker is not in single mode. Check if it is in single Read-out mode.
137  bool allInPeakMode = true;
138  bool allInDecoMode = true;
139  std::vector<uint16_t> allModesVector;
140  allModes(allModesVector);
141  std::vector<uint16_t>::const_iterator it = allModesVector.begin();
142  if (allModesVector.size() == 1 && allModesVector[0] == 0)
143  allInPeakMode = false;
144  else {
145  for (; it != allModesVector.end(); ++it) {
146  if ((*it) % 2 == 0)
147  continue;
148  if (((*it) & READMODEMASK) == READMODEMASK)
149  allInDecoMode = false;
150  if (((*it) & READMODEMASK) == 0)
151  allInPeakMode = false;
152  }
153  }
154  if (allInPeakMode)
155  return 1;
156  if (allInDecoMode)
157  return 0;
158  }
159  return -1;
160 }
uint16_t mode(const uint32_t detId, const uint16_t apv) const
uint16_t singleMode() const
void allModes(std::vector< uint16_t > &allModesVector) const
Fills the passed vector with all the possible modes in the Tracker.
#define READMODEMASK

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 146 of file SiStripLatency.h.

◆ cond::serialization::access

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 146 of file SiStripLatency.h.

Member Data Documentation

◆ latencies_

std::vector<Latency> SiStripLatency::latencies_
private