CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Public Attributes

mySiStripNoises Class Reference

#include <mySiStripNoises.h>

List of all members.

Classes

struct  DetRegistry
class  StrictWeakOrdering

Public Types

typedef
SiStripNoiseVector::const_iterator 
ContainerIterator
typedef const std::vector< short > InputVector
typedef std::pair
< ContainerIterator,
ContainerIterator
Range
typedef std::vector< DetRegistryRegistry
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< DetRegistryindexes
std::vector< unsigned char > v_noises

Detailed Description

Definition at line 13 of file mySiStripNoises.h.


Member Typedef Documentation

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.

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.


Constructor & Destructor Documentation

mySiStripNoises::mySiStripNoises ( ) [inline]

Definition at line 16 of file mySiStripNoises.h.

{}
mySiStripNoises::~mySiStripNoises ( ) [inline]

Definition at line 17 of file mySiStripNoises.h.

{}

Member Function Documentation

uint16_t mySiStripNoises::decode ( const uint16_t &  strip,
const Range range 
) const

Definition at line 67 of file mySiStripNoises.cc.

References data, and relativeConstraints::value.

Referenced by getNoise().

                                                                                {
  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);
  return value;
}
void mySiStripNoises::encode ( InputVector Vi,
std::vector< unsigned char > &  Vo_CHAR 
)

Definition at line 46 of file mySiStripNoises.cc.

References 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<Vo.size(); ++i)
    Vo[i]   &=      0x00u;
  
  for(unsigned int stripIndex =0; stripIndex<Vi.size(); ++stripIndex){
    unsigned char*  data    =       &Vo[Vo.size()-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);
  }
}
void mySiStripNoises::getDetIds ( std::vector< uint32_t > &  DetIds) const

Definition at line 29 of file mySiStripNoises.cc.

References begin, end, indexes, and AlCaHLTBitMon_ParallelJobs::p.

                                                                 {
  // returns vector of DetIds in map
  mySiStripNoises::RegistryIterator begin = indexes.begin();
  mySiStripNoises::RegistryIterator end   = indexes.end();
  for (mySiStripNoises::RegistryIterator p=begin; p != end; ++p) {
    DetIds.push_back(p->detid);
  }
}
float mySiStripNoises::getNoise ( const uint16_t &  strip,
const Range range 
) const

Definition at line 38 of file mySiStripNoises.cc.

References decode().

                                                                                {
  return   static_cast<float> (decode(strip,range)/10.0);
} 
const mySiStripNoises::Range mySiStripNoises::getRange ( const uint32_t &  detID) const

Definition at line 20 of file mySiStripNoises.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_noises.

                                                                                {
  // get SiStripNoises Range of DetId
  RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,StrictWeakOrdering());
  if (p==indexes.end()|| p->detid!=DetId) 
    return mySiStripNoises::Range(v_noises.end(),v_noises.end()); 
  else 
    return mySiStripNoises::Range(v_noises.begin()+p->ibegin,v_noises.begin()+p->iend);
}
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, AlCaHLTBitMon_ParallelJobs::p, sd, and v_noises.

                                                                  {
  // put in SiStripNoises of DetId
  std::vector<unsigned char>    Vo_CHAR;
  encode(input, Vo_CHAR);
  Registry::iterator p=std::lower_bound(indexes.begin(),indexes.end(),DetId,mySiStripNoises::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 mySiStripNoises::setData ( float  noise_,
std::vector< short > &  vped 
)

Definition at line 42 of file mySiStripNoises.cc.

                                                              {
  v.push_back((static_cast<int16_t>  (noise_*10.0 + 0.5) & 0x01FF)) ;
}

Member Data Documentation

Definition at line 47 of file mySiStripNoises.h.

Referenced by getDetIds(), getRange(), and put().

std::vector<unsigned char> mySiStripNoises::v_noises

Definition at line 46 of file mySiStripNoises.h.

Referenced by getRange(), and put().