#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. | |
std::vector< Latency > | allLatencyAndModes () const |
void | allModes (std::vector< uint16_t > &allModesVector) const |
Fills the passed vector with all the possible modes in the Tracker. | |
std::vector< Latency > | allUniqueLatencyAndModes () |
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 |
Prints the full list of all ranges and corresponding values of latency and mode. | |
void | printSummary (std::stringstream &ss) const |
Prints the number of ranges as well as the value of singleLatency and singleMode. | |
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. | |
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. | |
Private Attributes | |
std::vector< Latency > | latencies_ |
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).
Definition at line 55 of file SiStripLatency.h.
typedef std::vector<Latency>::const_iterator SiStripLatency::latConstIt |
Definition at line 80 of file SiStripLatency.h.
typedef std::vector<Latency>::iterator SiStripLatency::latIt |
Definition at line 79 of file SiStripLatency.h.
SiStripLatency::SiStripLatency | ( | ) | [inline] |
Definition at line 59 of file SiStripLatency.h.
{}
void SiStripLatency::allLatencies | ( | std::vector< uint16_t > & | allLatenciesVector | ) | const |
Fills the passed vector with all the possible latencies in the Tracker.
Definition at line 153 of file SiStripLatency.cc.
References latencies_, and python::multivaluedict::sort().
Referenced by printSummary().
{ for( latConstIt it = latencies_.begin(); it != latencies_.end(); ++it ) { allLatenciesVector.push_back(it->latency); } // The Latencies are sorted by DetIdAndApv, we need to sort the latencies again and then remove duplicates sort( allLatenciesVector.begin(), allLatenciesVector.end() ); allLatenciesVector.erase( unique( allLatenciesVector.begin(), allLatenciesVector.end() ), allLatenciesVector.end() ); }
std::vector<Latency> SiStripLatency::allLatencyAndModes | ( | ) | const [inline] |
void SiStripLatency::allModes | ( | std::vector< uint16_t > & | allModesVector | ) | const |
Fills the passed vector with all the possible modes in the Tracker.
Definition at line 114 of file SiStripLatency.cc.
References latencies_, and python::multivaluedict::sort().
Referenced by singleReadOutMode().
{ for( latConstIt it = latencies_.begin(); it != latencies_.end(); ++it ) { allModesVector.push_back(it->mode); } // The Latencies are sorted by DetIdAndApv, we need to sort the modes again and then remove duplicates sort( allModesVector.begin(), allModesVector.end() ); allModesVector.erase( unique( allModesVector.begin(), allModesVector.end() ), allModesVector.end() ); }
std::vector< SiStripLatency::Latency > SiStripLatency::allUniqueLatencyAndModes | ( | ) |
Definition at line 165 of file SiStripLatency.cc.
References latencies_, and python::multivaluedict::sort().
{ std::vector<Latency> latencyCopy(latencies_); sort( latencyCopy.begin(), latencyCopy.end(), OrderByLatencyAndMode() ); latencyCopy.erase( unique( latencyCopy.begin(), latencyCopy.end(), SiStripLatency::EqualByLatencyAndMode() ), latencyCopy.end() ); return latencyCopy; }
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 37 of file SiStripLatency.cc.
References latencies_.
Referenced by SiStripCondObjBuilderFromDb::buildFECRelatedObjects(), and SiStripLatencyGenerator::createObject().
{ latIt lat = latencies_.begin(); while( lat != latencies_.end() ) { // If it is not the last and it has the same latency and mode as the next one remove it if( ((lat+1) != latencies_.end()) && ((lat+1)->mode == lat->mode) && ((lat+1)->latency == lat->latency) ) { lat = latencies_.erase(lat); } else { ++lat; } } }
uint16_t SiStripLatency::latency | ( | const uint32_t | detId, |
const uint16_t | apv | ||
) | const |
Definition at line 51 of file SiStripLatency.cc.
References latencies_, pos, and position().
{ const latConstIt & pos = position(detId, apv); if( pos == latencies_.end() ) { return 255; } return pos->latency; }
std::pair< uint16_t, uint16_t > SiStripLatency::latencyAndMode | ( | const uint32_t | detId, |
const uint16_t | apv | ||
) | const |
Definition at line 69 of file SiStripLatency.cc.
References latencies_, pos, and position().
{ const latConstIt & pos = position(detId, apv); if( pos == latencies_.end() ) { return std::make_pair(255, 0); } return std::make_pair(pos->latency, pos->mode); }
uint16_t SiStripLatency::mode | ( | const uint32_t | detId, |
const uint16_t | apv | ||
) | const |
Definition at line 60 of file SiStripLatency.cc.
References latencies_, pos, and position().
Referenced by singleReadOutMode().
{ const latConstIt & pos = position(detId, apv); if( pos == latencies_.end() ) { return 0; } return pos->mode; }
const latConstIt SiStripLatency::position | ( | const uint32_t | detId, |
const uint16_t | apv | ||
) | const [inline, private] |
Used to compute the position with the lower_bound binary search.
Definition at line 145 of file SiStripLatency.h.
References latencies_, and pos.
Referenced by latency(), latencyAndMode(), and mode().
{ if( latencies_.empty() ) { // std::cout << "SiStripLatency: Error, range is empty" << std::endl; return latencies_.end(); } uint32_t detIdAndApv = (detId << 3) | apv; latConstIt pos = lower_bound(latencies_.begin(), latencies_.end(), detIdAndApv, OrderByDetIdAndApv()); return pos; }
void SiStripLatency::printDebug | ( | std::stringstream & | ss | ) | const |
Prints the full list of all ranges and corresponding values of latency and mode.
Definition at line 202 of file SiStripLatency.cc.
References latencies_.
Referenced by SiStripCondObjBuilderFromDb::buildFECRelatedObjects(), and printSummary().
{ ss << "List of all the latencies and modes for the " << latencies_.size() << " ranges in the object:" << std::endl; for( latConstIt it = latencies_.begin(); it != latencies_.end(); ++it ) { int detId = it->detIdAndApv >> 3; int apv = it->detIdAndApv & 7; // 7 is 0...0111 ss << "for detId = " << detId << " and apv pair = " << apv << " latency = " << int(it->latency) << " and mode = " << int(it->mode) << std::endl; } }
void SiStripLatency::printSummary | ( | std::stringstream & | ss | ) | const |
Prints the number of ranges as well as the value of singleLatency and singleMode.
Definition at line 173 of file SiStripLatency.cc.
References allLatencies(), latencies_, printDebug(), singleLatency(), and singleReadOutMode().
Referenced by SiStripCondObjBuilderFromDb::buildFECRelatedObjects().
{ ss << std::endl; if(singleReadOutMode()==1){ ss << "SingleReadOut = PEAK" << std::endl; }else if(singleReadOutMode()==0){ ss << "SingleReadOut = DECO" << std::endl; }else{ ss << "SingleReadOut = MIXED" << std::endl; } uint16_t lat = singleLatency(); if( lat != 255 ) { ss << "All the Tracker has the same latency = " << lat << std::endl; } else { std::vector<uint16_t> allLatenciesVector; allLatencies(allLatenciesVector); if( allLatenciesVector.size() > 1 ) { ss << "There is more than one latency value in the Tracker" << std::endl; } else { ss << "Latency value is " << lat << " that means invalid" << std::endl; } } ss << "Total number of ranges = " << latencies_.size() << std::endl; printDebug(ss); }
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, error, Exception, latencies_, and pos.
Referenced by SiStripLatencyGenerator::createObject(), SiStripCondObjBuilderFromDb::setDefaultValuesApvLatency(), and SiStripCondObjBuilderFromDb::setValuesApvLatency().
{ if( detId > 536870911 ) { std::stringstream error; error << "ERROR: the detId = " << detId << " is bigger than the maximum acceptable value = 2^(29) - 1 = " << 536870911 << std::endl; error << "Since we are using 29 bits for the detId and 3 bits for the apv value. The maximum tracker detId at the moment" << std::endl; error << "of the writing of this class was 47017836 as defined in CalibTracker/SiStripCommon/data/SiStripDetInfo.dat." << std::endl; error << "If the maximum value has changed a revision of this calss is needed, possibly changing the detIdAndApv value from" << std::endl; error << "from uint32_t to uint64_t." << std::endl; edm::LogError("SiStripLatency::put") << error; throw cms::Exception("InsertFailure"); } // Store all the values in the vectors uint32_t detIdAndApv = (detId << 3) | apv; latIt pos = lower_bound(latencies_.begin(), latencies_.end(), detIdAndApv, OrderByDetIdAndApv()); if( pos != latencies_.end() && pos->detIdAndApv == detIdAndApv ) { std::cout << "Value already inserted, skipping insertion" << std::endl; return false; } // std::cout << "Filling with: latency = " << latency << ", mode = " << mode << std::endl; latencies_.insert(pos, Latency(detIdAndApv, latency, mode)); return true; }
uint16_t SiStripLatency::singleLatency | ( | ) | const |
If all the latency values stored are equal return that value, otherwise return -1.
Definition at line 78 of file SiStripLatency.cc.
References latencies_.
Referenced by printSummary().
{ if( latencies_.size() == 1 ) { return latencies_[0].latency; } int differentLatenciesNum = 0; // Count the number of different latencies for( latConstIt it = latencies_.begin(); it != latencies_.end()-1; ++it ) { if( it->latency != (it+1)->latency ) { ++differentLatenciesNum; } } if( differentLatenciesNum == 0 ) { return latencies_[0].latency; } return 255; }
uint16_t SiStripLatency::singleMode | ( | ) | const |
Definition at line 96 of file SiStripLatency.cc.
References latencies_.
Referenced by singleReadOutMode().
{ if( latencies_.size() == 1 ) { return latencies_[0].mode; } int differentModesNum = 0; // Count the number of different modes for( latConstIt it = latencies_.begin(); it != latencies_.end()-1; ++it ) { if( it->mode != (it+1)->mode ) { ++differentModesNum; } } if( differentModesNum == 0 ) { return latencies_[0].mode; } return 0; }
int16_t SiStripLatency::singleReadOutMode | ( | ) | const |
Definition at line 124 of file SiStripLatency.cc.
References allModes(), mode(), READMODEMASK, and singleMode().
Referenced by printSummary().
{ uint16_t mode = singleMode(); if(mode != 0 ) { if( (mode & READMODEMASK) == READMODEMASK ) return 1; if( (mode & READMODEMASK) == 0 ) return 0; } else { // If we are here the Tracker is not in single mode. Check if it is in single Read-out mode. bool allInPeakMode = true; bool allInDecoMode = true; std::vector<uint16_t> allModesVector; allModes(allModesVector); std::vector<uint16_t>::const_iterator it = allModesVector.begin(); if (allModesVector.size() == 1 && allModesVector[0] == 0) allInPeakMode = false; else{ for( ; it != allModesVector.end(); ++it ) { if( (*it) % 2 == 0 ) continue; if( ((*it) & READMODEMASK) == READMODEMASK ) allInDecoMode = false; if( ((*it) & READMODEMASK) == 0 ) allInPeakMode = false; } } if( allInPeakMode ) return 1; if( allInDecoMode ) return 0; } return -1; }
std::vector<Latency> SiStripLatency::latencies_ [private] |
Definition at line 155 of file SiStripLatency.h.
Referenced by allLatencies(), allLatencyAndModes(), allModes(), allUniqueLatencyAndModes(), compress(), latency(), latencyAndMode(), mode(), position(), printDebug(), printSummary(), put(), singleLatency(), and singleMode().