#include <CondFormats/Calibration/interface/mySiStripNoises.h>
Public Types | |
typedef SiStripNoiseVector::const_iterator | ContainerIterator |
typedef const std::vector< short > | InputVector |
typedef std::pair < ContainerIterator, ContainerIterator > | Range |
typedef std::vector< DetRegistry > | Registry |
typedef Registry::const_iterator | RegistryIterator |
typedef std::vector< unsigned char > | SiStripNoiseVector |
Public Member Functions | |
uint16_t | decode (const uint16_t &strip, const Range &range) const |
void | encode (InputVector &Vi, std::vector< unsigned char > &Vo_CHAR) |
void | getDetIds (std::vector< uint32_t > &DetIds) const |
float | getNoise (const uint16_t &strip, const Range &range) const |
const Range | getRange (const uint32_t &detID) const |
mySiStripNoises () | |
bool | put (const uint32_t detID, InputVector &input) |
void | setData (float noise_, std::vector< short > &vped) |
~mySiStripNoises () | |
Public Attributes | |
std::vector< DetRegistry > | indexes |
std::vector< unsigned char > | v_noises |
Classes | |
struct | DetRegistry |
class | StrictWeakOrdering |
Definition at line 13 of file mySiStripNoises.h.
typedef SiStripNoiseVector::const_iterator mySiStripNoises::ContainerIterator |
Definition at line 30 of file mySiStripNoises.h.
typedef const std::vector<short> mySiStripNoises::InputVector |
Definition at line 34 of file mySiStripNoises.h.
typedef std::pair<ContainerIterator, ContainerIterator> mySiStripNoises::Range |
Definition at line 31 of file mySiStripNoises.h.
typedef std::vector<DetRegistry> mySiStripNoises::Registry |
Definition at line 32 of file mySiStripNoises.h.
typedef Registry::const_iterator mySiStripNoises::RegistryIterator |
Definition at line 33 of file mySiStripNoises.h.
typedef std::vector<unsigned char> mySiStripNoises::SiStripNoiseVector |
Definition at line 29 of file mySiStripNoises.h.
mySiStripNoises::mySiStripNoises | ( | ) | [inline] |
mySiStripNoises::~mySiStripNoises | ( | ) | [inline] |
uint16_t mySiStripNoises::decode | ( | const uint16_t & | strip, | |
const Range & | range | |||
) | const |
Definition at line 67 of file mySiStripNoises.cc.
Referenced by getNoise().
00067 { 00068 const unsigned char *data = &*(range.second -1); // pointer to the last byte of data 00069 static const uint16_t BITS_PER_STRIP = 9; 00070 00071 uint32_t lowBit = strip * BITS_PER_STRIP; 00072 uint8_t firstByteBit = (lowBit & 7);//module 8 00073 uint8_t firstByteNBits = 8 - firstByteBit; 00074 uint8_t firstByteMask = 0xffu << firstByteBit; 00075 uint8_t secondByteMask = ~(0xffu << (BITS_PER_STRIP - firstByteNBits)); 00076 uint16_t value = ((uint16_t(*(data-lowBit/8 )) & firstByteMask) >> firstByteBit) | ((uint16_t(*(data-lowBit/8-1)) & secondByteMask) << firstByteNBits); 00077 return value; 00078 }
void mySiStripNoises::encode | ( | InputVector & | Vi, | |
std::vector< unsigned char > & | Vo_CHAR | |||
) |
Definition at line 46 of file mySiStripNoises.cc.
Referenced by put().
00046 { 00047 static const uint16_t BITS_PER_STRIP = 9; 00048 const size_t VoSize = (size_t)((Vi.size() * BITS_PER_STRIP)/8+.999); 00049 Vo.resize(VoSize); 00050 for(size_t i = 0; i<Vo.size(); ++i) 00051 Vo[i] &= 0x00u; 00052 00053 for(unsigned int stripIndex =0; stripIndex<Vi.size(); ++stripIndex){ 00054 unsigned char* data = &Vo[Vo.size()-1]; 00055 uint32_t lowBit = stripIndex * BITS_PER_STRIP; 00056 uint8_t firstByteBit = (lowBit & 0x7); 00057 uint8_t firstByteNBits = 8 - firstByteBit; 00058 uint8_t firstByteMask = 0xffu << firstByteBit; 00059 uint8_t secondByteNbits = (BITS_PER_STRIP - firstByteNBits); 00060 uint8_t secondByteMask = ~(0xffu << secondByteNbits); 00061 00062 *(data-lowBit/8) = (*(data-lowBit/8) & ~(firstByteMask)) | ((Vi[stripIndex] & 0xffu) <<firstByteBit); 00063 *(data-lowBit/8-1) = (*(data-lowBit/8-1) & ~(secondByteMask)) | ((Vi[stripIndex] >> firstByteNBits) & secondByteMask); 00064 } 00065 }
void mySiStripNoises::getDetIds | ( | std::vector< uint32_t > & | DetIds | ) | const |
Definition at line 29 of file mySiStripNoises.cc.
References begin, end, indexes, and p.
00029 { 00030 // returns vector of DetIds in map 00031 mySiStripNoises::RegistryIterator begin = indexes.begin(); 00032 mySiStripNoises::RegistryIterator end = indexes.end(); 00033 for (mySiStripNoises::RegistryIterator p=begin; p != end; ++p) { 00034 DetIds.push_back(p->detid); 00035 } 00036 }
float mySiStripNoises::getNoise | ( | const uint16_t & | strip, | |
const Range & | range | |||
) | const |
const mySiStripNoises::Range mySiStripNoises::getRange | ( | const uint32_t & | detID | ) | const |
Definition at line 20 of file mySiStripNoises.cc.
References indexes, p, and v_noises.
00020 { 00021 // get SiStripNoises Range of DetId 00022 RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,StrictWeakOrdering()); 00023 if (p==indexes.end()|| p->detid!=DetId) 00024 return mySiStripNoises::Range(v_noises.end(),v_noises.end()); 00025 else 00026 return mySiStripNoises::Range(v_noises.begin()+p->ibegin,v_noises.begin()+p->iend); 00027 }
bool mySiStripNoises::put | ( | const uint32_t | detID, | |
InputVector & | input | |||
) |
Definition at line 3 of file mySiStripNoises.cc.
References mySiStripNoises::DetRegistry::detid, encode(), mySiStripNoises::DetRegistry::ibegin, mySiStripNoises::DetRegistry::iend, indexes, p, and v_noises.
00003 { 00004 // put in SiStripNoises of DetId 00005 std::vector<unsigned char> Vo_CHAR; 00006 encode(input, Vo_CHAR); 00007 Registry::iterator p=std::lower_bound(indexes.begin(),indexes.end(),DetId,mySiStripNoises::StrictWeakOrdering()); 00008 if (p!=indexes.end() && p->detid==DetId) 00009 return false; 00010 size_t sd = Vo_CHAR.end() - Vo_CHAR.begin(); 00011 DetRegistry detregistry; 00012 detregistry.detid=DetId; 00013 detregistry.ibegin=v_noises.size(); 00014 detregistry.iend=v_noises.size()+sd; 00015 indexes.insert(p,detregistry); 00016 v_noises.insert(v_noises.end(),Vo_CHAR.begin(),Vo_CHAR.end()); 00017 return true; 00018 }
void mySiStripNoises::setData | ( | float | noise_, | |
std::vector< short > & | vped | |||
) |
std::vector<DetRegistry> mySiStripNoises::indexes |
std::vector<unsigned char> mySiStripNoises::v_noises |