00001 #ifndef SiStripNoises_h 00002 #define SiStripNoises_h 00003 00004 #include<vector> 00005 #include<map> 00006 #include<iostream> 00007 #include<boost/cstdint.hpp> 00008 00009 00010 class SiStripNoises { 00011 00012 public: 00013 00014 struct DetRegistry{ 00015 uint32_t detid; 00016 uint32_t ibegin; 00017 uint32_t iend; 00018 }; 00019 00020 class StrictWeakOrdering{ 00021 public: 00022 bool operator() (const DetRegistry& p,const uint32_t& i) const {return p.detid < i;} 00023 }; 00024 00025 00026 typedef std::vector<unsigned char> Container; 00027 typedef std::vector<unsigned char>::const_iterator ContainerIterator; 00028 typedef std::pair<ContainerIterator, ContainerIterator> Range; 00029 typedef std::vector<DetRegistry> Registry; 00030 typedef Registry::const_iterator RegistryIterator; 00031 typedef std::vector<uint16_t> InputVector; 00032 00033 SiStripNoises(const SiStripNoises& ); 00034 SiStripNoises(){}; 00035 ~SiStripNoises(){}; 00036 00037 bool put(const uint32_t& detID,const InputVector &input); 00038 const Range getRange(const uint32_t& detID) const; 00039 void getDetIds(std::vector<uint32_t>& DetIds_) const; 00040 00041 ContainerIterator getDataVectorBegin() const {return v_noises.begin();} 00042 ContainerIterator getDataVectorEnd() const {return v_noises.end();} 00043 RegistryIterator getRegistryVectorBegin() const {return indexes.begin();} 00044 RegistryIterator getRegistryVectorEnd() const{return indexes.end();} 00045 00046 float getNoise (const uint16_t& strip, const Range& range) const; 00047 void allNoises (std::vector<float> & noises, const Range& range) const; 00048 void setData(float noise_, InputVector& vped); 00049 00050 private: 00051 void encode(const InputVector& Vi, std::vector<unsigned char>& Vo_CHAR); 00052 uint16_t decode (const uint16_t& strip, const Range& range) const; 00055 inline uint16_t get9bits(const uint8_t * &ptr, int8_t skip) const ; 00056 00057 00058 Container v_noises; 00059 Registry indexes; 00060 00061 /* 00062 const std::string print_as_binary(const uint8_t ch) const; 00063 std::string print_char_as_binary(const unsigned char ch) const; 00064 std::string print_short_as_binary(const short ch) const; 00065 */ 00066 }; 00067 00068 #endif