#include <SiStripNoises.h>
Classes | |
struct | DetRegistry |
struct | ratioData |
class | StrictWeakOrdering |
Public Types | |
typedef std::vector< unsigned char > | Container |
typedef std::vector< unsigned char >::const_iterator | ContainerIterator |
typedef std::vector< uint16_t > | InputVector |
typedef std::pair < ContainerIterator, ContainerIterator > | Range |
typedef std::vector< DetRegistry > | Registry |
typedef Registry::const_iterator | RegistryIterator |
Public Member Functions | |
void | allNoises (std::vector< float > &noises, const Range &range) const |
ContainerIterator | getDataVectorBegin () const |
ContainerIterator | getDataVectorEnd () const |
void | getDetIds (std::vector< uint32_t > &DetIds_) const |
const Range | getRange (const uint32_t &detID) const |
RegistryIterator | getRegistryVectorBegin () const |
RegistryIterator | getRegistryVectorEnd () const |
std::vector< ratioData > | operator/ (SiStripNoises d) |
void | printDebug (std::stringstream &ss) const |
void | printSummary (std::stringstream &ss) const |
bool | put (const uint32_t &detID, const InputVector &input) |
void | setData (float noise_, InputVector &vped) |
SiStripNoises () | |
SiStripNoises (const SiStripNoises &) | |
~SiStripNoises () | |
Static Public Member Functions | |
static float | getNoise (uint16_t strip, const Range &range) |
static float | getNoiseFast (const uint16_t &strip, const Range &range) |
Static Private Member Functions | |
static uint16_t | decode (uint16_t strip, const Range &range) |
static void | encode (const InputVector &Vi, std::vector< unsigned char > &Vo_CHAR) |
static uint16_t | get9bits (const uint8_t *&ptr, int8_t skip) |
Private Attributes | |
Registry | indexes |
Container | v_noises |
Stores the noise value for all the strips.
The values are encoded from a vector<uint16_t> to a vector<unsigned char>
The printSummary method prints: Nstrips, mean, rms, min and max noise for each detId. The print Debug method prints the noise for every strip.
Definition at line 18 of file SiStripNoises.h.
typedef std::vector<unsigned char> SiStripNoises::Container |
Definition at line 39 of file SiStripNoises.h.
typedef std::vector<unsigned char>::const_iterator SiStripNoises::ContainerIterator |
Definition at line 40 of file SiStripNoises.h.
typedef std::vector<uint16_t> SiStripNoises::InputVector |
Definition at line 44 of file SiStripNoises.h.
typedef std::pair<ContainerIterator, ContainerIterator> SiStripNoises::Range |
Definition at line 41 of file SiStripNoises.h.
typedef std::vector<DetRegistry> SiStripNoises::Registry |
Definition at line 42 of file SiStripNoises.h.
typedef Registry::const_iterator SiStripNoises::RegistryIterator |
Definition at line 43 of file SiStripNoises.h.
SiStripNoises::SiStripNoises | ( | const SiStripNoises & | input | ) |
SiStripNoises::SiStripNoises | ( | ) | [inline] |
Definition at line 47 of file SiStripNoises.h.
{}
SiStripNoises::~SiStripNoises | ( | ) | [inline] |
Definition at line 48 of file SiStripNoises.h.
{}
void SiStripNoises::allNoises | ( | std::vector< float > & | noises, |
const Range & | range | ||
) | const |
Definition at line 111 of file SiStripNoises.cc.
References Exception, get9bits(), dbtoconf::out, and findQualityFiles::size.
Referenced by printDebug(), and printSummary().
{ size_t mysize = ((range.second-range.first) << 3) / 9; size_t size = noises.size(); if (mysize < size) throw cms::Exception("CorruptedData") << "[SiStripNoises::allNoises] Requested noise for " << noises.size() << " strips, I have it only for " << mysize << " strips\n"; size_t size8 = size & (~0x7), carry = size & 0x7; // we have an optimized way of unpacking 8 strips const uint8_t *ptr = (&*range.second) - 1; std::vector<float>::iterator out = noises.begin(), end8 = noises.begin() + size8; // we do it this baroque way instead of just loopin on all the strips because it's faster // as the value of 'skip' is a constant, so the compiler can compute the masks directly while (out < end8) { *out = static_cast<float> ( get9bits(ptr, 0) / 10.0f ); ++out; *out = static_cast<float> ( get9bits(ptr, 1) / 10.0f ); ++out; *out = static_cast<float> ( get9bits(ptr, 2) / 10.0f ); ++out; *out = static_cast<float> ( get9bits(ptr, 3) / 10.0f ); ++out; *out = static_cast<float> ( get9bits(ptr, 4) / 10.0f ); ++out; *out = static_cast<float> ( get9bits(ptr, 5) / 10.0f ); ++out; *out = static_cast<float> ( get9bits(ptr, 6) / 10.0f ); ++out; *out = static_cast<float> ( get9bits(ptr, 7) / 10.0f ); ++out; --ptr; // every 8 strips we have to skip one more bit } for (size_t rem = 0; rem < carry; ++rem ) { *out = static_cast<float> ( get9bits(ptr, rem) / 10.0f ); ++out; } }
uint16_t SiStripNoises::decode | ( | uint16_t | strip, |
const Range & | range | ||
) | [inline, static, private] |
Definition at line 103 of file SiStripNoises.h.
References runTheMatrix::data, and relativeConstraints::value.
Referenced by getNoiseFast().
{ const unsigned char *data = &*(range.second -1); // pointer to the last byte of data static const uint16_t BITS_PER_STRIP = 9; uint32_t lowBit = strip * BITS_PER_STRIP; uint8_t firstByteBit = (lowBit & 7);//module 8 uint8_t firstByteNBits = 8 - firstByteBit; uint8_t firstByteMask = 0xffu << firstByteBit; uint8_t secondByteMask = ~(0xffu << (BITS_PER_STRIP - firstByteNBits)); uint16_t value = ((uint16_t(*(data-lowBit/8 )) & firstByteMask) >> firstByteBit) | ((uint16_t(*(data-lowBit/8-1)) & secondByteMask) << firstByteNBits); /* if(strip < 25){ std::cout << "***************DECODE*********************"<<"\n" << "strip "<<strip << " " << value <<"\t :"<<print_as_binary(value) <<"\t :"<<print_as_binary( ((uint16_t(*(data-lowBit/8 )) & firstByteMask) >> firstByteBit) ) << "-"<<print_as_binary( ((uint16_t(*(data-lowBit/8-1)) & secondByteMask) <<firstByteNBits) ) << "\t *(data-lowBit/8) " << print_as_binary( *(data-lowBit/8 )) << "\t *(data-lowBit/8-1) " << print_as_binary( *(data-lowBit/8 -1 )) << "\tlowBit:"<< lowBit << "\tfirstByteMask :"<<print_as_binary(firstByteMask) << "\tsecondByteMask:"<<print_as_binary(secondByteMask) << "\tfirstByteBit:"<<print_as_binary(firstByteBit) << std::endl; } */ return value; }
void SiStripNoises::encode | ( | const InputVector & | Vi, |
std::vector< unsigned char > & | Vo_CHAR | ||
) | [static, private] |
Definition at line 65 of file SiStripNoises.cc.
References runTheMatrix::data, and i.
Referenced by put().
{ static const uint16_t BITS_PER_STRIP = 9; const size_t VoSize = (size_t)((Vi.size() * BITS_PER_STRIP)/8+.999); Vo.resize(VoSize); for(size_t i = 0; i<VoSize; ++i) Vo[i] &= 0x00u; for(unsigned int stripIndex =0; stripIndex<Vi.size(); ++stripIndex){ unsigned char* data = &Vo[VoSize-1]; uint32_t lowBit = stripIndex * BITS_PER_STRIP; uint8_t firstByteBit = (lowBit & 0x7); uint8_t firstByteNBits = 8 - firstByteBit; uint8_t firstByteMask = 0xffu << firstByteBit; uint8_t secondByteNbits = (BITS_PER_STRIP - firstByteNBits); uint8_t secondByteMask = ~(0xffu << secondByteNbits); *(data-lowBit/8) = (*(data-lowBit/8) & ~(firstByteMask)) | ((Vi[stripIndex] & 0xffu) <<firstByteBit); *(data-lowBit/8-1) = (*(data-lowBit/8-1) & ~(secondByteMask)) | ((Vi[stripIndex] >> firstByteNBits) & secondByteMask); /* if(stripIndex < 25 ){ std::cout << "***************ENCODE*********************"<<std::endl << "\tdata-lowBit/8 :"<<print_as_binary((*(data-lowBit/8) & ~(firstByteMask))) << "-"<<print_as_binary(((Vi[stripIndex] & 0xffu) <<firstByteBit)) << "\tdata-lowBit/8-1 :"<<print_as_binary((*(data-lowBit/8-1) & ~(secondByteMask))) << "-"<<print_as_binary((((Vi[stripIndex]>> firstByteNBits) & secondByteMask))) << std::endl; std::cout << "strip "<<stripIndex<<"\tvi: " << Vi[stripIndex] <<"\t" << print_short_as_binary(Vi[stripIndex]) << "\tvo1:"<< print_char_as_binary(*(data-lowBit/8)) << "\tvo2:"<< print_char_as_binary(*(data-lowBit/8-1)) << "\tlowBit:"<< lowBit << "\tfirstByteMask :"<<print_as_binary(firstByteMask) << "\tsecondByteMask:"<<print_as_binary(secondByteMask) << "\tfirstByteBit:"<<print_as_binary(firstByteBit) << std::endl; } */ } }
uint16_t SiStripNoises::get9bits | ( | const uint8_t *& | ptr, |
int8_t | skip | ||
) | [inline, static, private] |
Get 9 bits from a bit stream, starting from the right, skipping the first 'skip' bits (0 < skip < 8). Ptr must point to the rightmost bit, and is updated by this function
Get 9 bit words from a bit stream, starting from the right, skipping the first 'skip' bits (0 < skip < 8). Ptr must point to the rightmost byte that has some bits of this word, and is updated by this function
Definition at line 95 of file SiStripNoises.h.
References runTheMatrix::ret, and createPayload::skip.
Referenced by allNoises().
ContainerIterator SiStripNoises::getDataVectorBegin | ( | ) | const [inline] |
Definition at line 54 of file SiStripNoises.h.
References v_noises.
Referenced by printDebug(), and printSummary().
{return v_noises.begin();}
ContainerIterator SiStripNoises::getDataVectorEnd | ( | ) | const [inline] |
void SiStripNoises::getDetIds | ( | std::vector< uint32_t > & | DetIds_ | ) | const |
Definition at line 44 of file SiStripNoises.cc.
References begin, end, indexes, and L1TEmulatorMonitor_cff::p.
{ // returns vector of DetIds in map SiStripNoises::RegistryIterator begin = indexes.begin(); SiStripNoises::RegistryIterator end = indexes.end(); for (SiStripNoises::RegistryIterator p=begin; p != end; ++p) { DetIds_.push_back(p->detid); } }
float SiStripNoises::getNoise | ( | uint16_t | strip, |
const Range & | range | ||
) | [static] |
Definition at line 53 of file SiStripNoises.cc.
References Exception, getNoiseFast(), and strip().
Referenced by operator/(), and jptJetAnalysis::StripSignalOverNoiseCalculator::signalOverNoise().
{ if (9*strip>=(range.second-range.first)*8){ throw cms::Exception("CorruptedData") << "[SiStripNoises::getNoise] looking for SiStripNoises for a strip out of range: strip " << strip; } return getNoiseFast(strip,range); }
static float SiStripNoises::getNoiseFast | ( | const uint16_t & | strip, |
const Range & | range | ||
) | [inline, static] |
const SiStripNoises::Range SiStripNoises::getRange | ( | const uint32_t & | detID | ) | const |
Definition at line 34 of file SiStripNoises.cc.
References indexes, L1TEmulatorMonitor_cff::p, and v_noises.
Referenced by operator/(), and jptJetAnalysis::StripSignalOverNoiseCalculator::signalOverNoise().
{ // get SiStripNoises Range of DetId RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiStripNoises::StrictWeakOrdering()); if (p==indexes.end()|| p->detid!=DetId) return SiStripNoises::Range(v_noises.end(),v_noises.end()); else return SiStripNoises::Range(v_noises.begin()+p->ibegin,v_noises.begin()+p->iend); }
RegistryIterator SiStripNoises::getRegistryVectorBegin | ( | ) | const [inline] |
Definition at line 56 of file SiStripNoises.h.
References indexes.
Referenced by operator/(), printDebug(), and printSummary().
{return indexes.begin();}
RegistryIterator SiStripNoises::getRegistryVectorEnd | ( | ) | const [inline] |
Definition at line 57 of file SiStripNoises.h.
References indexes.
Referenced by operator/(), printDebug(), and printSummary().
{return indexes.end();}
std::vector< SiStripNoises::ratioData > SiStripNoises::operator/ | ( | SiStripNoises | d | ) |
Definition at line 242 of file SiStripNoises.cc.
References SiStripNoises::ratioData::detid, getNoise(), getRange(), getRegistryVectorBegin(), getRegistryVectorEnd(), query::result, strip(), v_noises, relativeConstraints::value, and SiStripNoises::ratioData::values.
{ std::vector<ratioData> result; ratioData aData; RegistryIterator iter=getRegistryVectorBegin(); RegistryIterator iterE=getRegistryVectorEnd(); //Divide result by d for(;iter!=iterE;++iter){ float value; //get noise from d aData.detid=iter->detid; aData.values.clear(); Range d_range=d.getRange(iter->detid); Range range=Range(v_noises.begin()+iter->ibegin,v_noises.begin()+iter->iend); //if denominator is missing, put the ratio value to 0xFFFF (=inf) size_t strip=0, stripE= (range.second-range.first)*8/9; for (;strip<stripE;++strip){ if(d_range.first==d_range.second){ value=0xFFFF; }else{ value=getNoise(strip,range)/d.getNoise(strip,d_range); } aData.values.push_back(value); } result.push_back(aData); } iter=d.getRegistryVectorBegin(); iterE=d.getRegistryVectorEnd(); //Divide result by d for(;iter!=iterE;++iter){ float value; //get noise from d Range range=this->getRange(iter->detid); Range d_range=Range(d.v_noises.begin()+iter->ibegin,d.v_noises.begin()+iter->iend); if(range.first==range.second){ aData.detid=iter->detid; aData.values.clear(); size_t strip=0, stripE= (d_range.second-d_range.first)*8/9; for (;strip<stripE;++strip){ value=0.; aData.values.push_back(value); } result.push_back(aData); } } return result; }
void SiStripNoises::printDebug | ( | std::stringstream & | ss | ) | const |
Definition at line 176 of file SiStripNoises.cc.
References allNoises(), getDataVectorBegin(), getRegistryVectorBegin(), getRegistryVectorEnd(), and i.
{ RegistryIterator rit=getRegistryVectorBegin(), erit=getRegistryVectorEnd(); uint16_t Nstrips; std::vector<float> vstripnoise; ss << "detid" << std::setw(15) << "strip" << std::setw(10) << "noise" << std::endl; int detId = 0; int oldDetId = 0; for(;rit!=erit;++rit){ Nstrips = (rit->iend-rit->ibegin)*8/9; //number of strips = number of chars * char size / strip noise size vstripnoise.resize(Nstrips); allNoises(vstripnoise,make_pair(getDataVectorBegin()+rit->ibegin,getDataVectorBegin()+rit->iend)); detId = rit->detid; if( detId != oldDetId ) { oldDetId = detId; ss << detId; } else ss << " "; for(size_t i=0;i<Nstrips;++i){ if( i != 0 ) ss << " "; ss << std::setw(15) << i << std::setw(10) << vstripnoise[i] << std::endl; } } }
void SiStripNoises::printSummary | ( | std::stringstream & | ss | ) | const |
Definition at line 203 of file SiStripNoises.cc.
References SiStripDetSummary::add(), allNoises(), getDataVectorBegin(), getRegistryVectorBegin(), getRegistryVectorEnd(), i, max(), plotscripts::mean(), min, SiStripDetSummary::print(), plotscripts::rms(), mathSSE::sqrt(), and edmLumisInFiles::summary.
{ SiStripDetSummary summary; std::stringstream tempss; RegistryIterator rit=getRegistryVectorBegin(), erit=getRegistryVectorEnd(); uint16_t Nstrips; std::vector<float> vstripnoise; double mean,rms,min, max; for(;rit!=erit;++rit){ Nstrips = (rit->iend-rit->ibegin)*8/9; //number of strips = number of chars * char size / strip noise size vstripnoise.resize(Nstrips); allNoises(vstripnoise,make_pair(getDataVectorBegin()+rit->ibegin,getDataVectorBegin()+rit->iend)); tempss << "\ndetid: " << rit->detid << " \t "; mean=0; rms=0; min=10000; max=0; DetId detId(rit->detid); for(size_t i=0;i<Nstrips;++i){ mean+=vstripnoise[i]; rms+=vstripnoise[i]*vstripnoise[i]; if(vstripnoise[i]<min) min=vstripnoise[i]; if(vstripnoise[i]>max) max=vstripnoise[i]; summary.add(detId, vstripnoise[i]); } mean/=Nstrips; rms= sqrt(rms/Nstrips-mean*mean); tempss << "Nstrips " << Nstrips << " \t; mean " << mean << " \t; rms " << rms << " \t; min " << min << " \t; max " << max << "\t " ; } ss << std::endl << "Summary:" << std::endl; summary.print(ss); ss << std::endl; ss << tempss.str(); }
bool SiStripNoises::put | ( | const uint32_t & | detID, |
const InputVector & | input | ||
) |
Definition at line 16 of file SiStripNoises.cc.
References SiStripNoises::DetRegistry::detid, encode(), SiStripNoises::DetRegistry::ibegin, SiStripNoises::DetRegistry::iend, indexes, L1TEmulatorMonitor_cff::p, and v_noises.
Referenced by SiStripNoiseNormalizedWithApvGainBuilder::analyze(), SiStripNoisesBuilder::analyze(), SiStripNoisesGenerator::createObject(), SiStripNoisesDQMService::readNoises(), and SiStripCondObjBuilderFromDb::storeNoise().
{ std::vector<unsigned char> Vo_CHAR; encode(input, Vo_CHAR); Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiStripNoises::StrictWeakOrdering()); if (p!=indexes.end() && p->detid==DetId) return false; size_t sd = Vo_CHAR.end() - Vo_CHAR.begin(); DetRegistry detregistry; detregistry.detid = DetId; detregistry.ibegin = v_noises.size(); detregistry.iend = v_noises.size()+sd; indexes.insert(p,detregistry); v_noises.insert(v_noises.end(),Vo_CHAR.begin(),Vo_CHAR.end()); return true; }
void SiStripNoises::setData | ( | float | noise_, |
InputVector & | vped | ||
) |
Definition at line 61 of file SiStripNoises.cc.
Referenced by SiStripNoiseNormalizedWithApvGainBuilder::analyze(), SiStripNoisesBuilder::analyze(), SiStripNoisesGenerator::createObject(), SiStripNoisesDQMService::readNoises(), SiStripCondObjBuilderFromDb::setDefaultValuesCabling(), and SiStripCondObjBuilderFromDb::setValuesCabling().
Registry SiStripNoises::indexes [private] |
Definition at line 83 of file SiStripNoises.h.
Referenced by getDetIds(), getRange(), getRegistryVectorBegin(), getRegistryVectorEnd(), put(), and SiStripNoises().
Container SiStripNoises::v_noises [private] |
Definition at line 82 of file SiStripNoises.h.
Referenced by getDataVectorBegin(), getDataVectorEnd(), getRange(), operator/(), put(), and SiStripNoises().