CMS 3D CMS Logo

SiStripNoises.h
Go to the documentation of this file.
1 #ifndef SiStripNoises_h
2 #define SiStripNoises_h
3 
5 
6 #include <vector>
7 #include <utility>
8 #include <iostream>
9 
10 #include <cassert>
11 #include <cstring>
12 #include <cstdint>
13 
14 class TrackerTopology;
15 
26 public:
27  struct ratioData {
28  uint32_t detid;
29  std::vector<float> values;
30  };
31 
32  struct DetRegistry {
33  uint32_t detid;
34  uint32_t ibegin;
35  uint32_t iend;
36 
38  };
39 
41  public:
42  bool operator()(const DetRegistry& p, const uint32_t& i) const { return p.detid < i; }
43  };
44 
45  typedef std::vector<unsigned char> Container;
46  typedef std::vector<unsigned char>::const_iterator ContainerIterator;
47  typedef std::pair<ContainerIterator, ContainerIterator> Range;
48  typedef std::vector<DetRegistry> Registry;
49  typedef Registry::const_iterator RegistryIterator;
50  typedef std::vector<uint16_t> InputVector;
51 
55 
56  bool put(const uint32_t& detID, const InputVector& input);
57  const Range getRange(const uint32_t detID) const;
58  Range getRangeByPos(unsigned short pos) const;
59  void getDetIds(std::vector<uint32_t>& DetIds_) const;
60 
61  ContainerIterator getDataVectorBegin() const { return v_noises.begin(); }
62  ContainerIterator getDataVectorEnd() const { return v_noises.end(); }
63  RegistryIterator getRegistryVectorBegin() const { return indexes.begin(); }
64  RegistryIterator getRegistryVectorEnd() const { return indexes.end(); }
65 
66  static inline float getNoiseFast(const uint16_t& strip, const Range& range) {
67  return 0.1f * float(decode(strip, range));
68  }
69 
70  static void verify(uint16_t strip, const Range& range);
71  static float getNoise(uint16_t strip, const Range& range) {
72 #ifdef EDM_ML_DEBUG
73  verify(strip, range);
74 #endif
75  return getNoiseFast(strip, range);
76  }
77 
78  void allNoises(std::vector<float>& noises, const Range& range) const;
79  void setData(float noise_, InputVector& vped);
80 
81  void printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
82  void printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
83 
84  std::vector<ratioData> operator/(const SiStripNoises& d);
85 
86 private:
87  static void encode(const InputVector& Vi, std::vector<unsigned char>& Vo_CHAR);
88 
89  static inline uint16_t decode(uint16_t strip, const Range& range);
90 
93  static inline uint16_t get9bits(const uint8_t*& ptr, int8_t skip);
94 
97 
98  /*
99  const std::string print_as_binary(const uint8_t ch) const;
100  std::string print_char_as_binary(const unsigned char ch) const;
101  std::string print_short_as_binary(const short ch) const;
102  */
103 
105 };
106 
109 inline uint16_t SiStripNoises::get9bits(const uint8_t*& ptr, int8_t skip) {
110  uint8_t maskThis = (0xFF << skip);
111  uint8_t maskThat = ((2 << skip) - 1);
112  uint16_t ret = (((*ptr) & maskThis) >> skip);
113  --ptr;
114  return ret | (((*ptr) & maskThat) << (8 - skip));
115 }
116 
117 inline uint16_t SiStripNoises::decode(uint16_t strip, const Range& range) {
118  const unsigned char* data = &*(range.second - 1); // pointer to the last byte of data
119  static const uint16_t BITS_PER_STRIP = 9;
120 
121  uint32_t lowBit = strip * BITS_PER_STRIP;
122  uint8_t firstByteBit = (lowBit & 7); //module 8
123 
124  uint16_t vin = uint16_t(*(data - lowBit / 8)) | (uint16_t(*(data - lowBit / 8 - 1)) << 8);
125  vin = vin >> firstByteBit;
126  vin &= 0x1FF;
127  return vin;
128 
129  /*
130  uint8_t firstByteNBits = 8 - firstByteBit;
131  uint8_t firstByteMask = 0xffu << firstByteBit;
132  uint8_t secondByteMask = ~(0xffu << (BITS_PER_STRIP - firstByteNBits));
133  uint16_t value = ((uint16_t(*(data-lowBit/8 )) & firstByteMask) >> firstByteBit) | ((uint16_t(*(data-lowBit/8-1)) & secondByteMask) << firstByteNBits);
134 
135  if(vin!=value) std::cout << vin << ',' <<value << std::endl;
136  */
137  /*
138  if(strip < 25){
139  std::cout << "***************DECODE*********************"<<"\n"
140  << "strip "<<strip << " "
141  << value
142  <<"\t :"<<print_as_binary(value)
143  <<"\t :"<<print_as_binary( ((uint16_t(*(data-lowBit/8 )) & firstByteMask) >> firstByteBit) )
144  << "-"<<print_as_binary( ((uint16_t(*(data-lowBit/8-1)) & secondByteMask) <<firstByteNBits) )
145  << "\t *(data-lowBit/8) " << print_as_binary( *(data-lowBit/8 ))
146  << "\t *(data-lowBit/8-1) " << print_as_binary( *(data-lowBit/8 -1 ))
147  << "\tlowBit:"<< lowBit
148  << "\tfirstByteMask :"<<print_as_binary(firstByteMask)
149  << "\tsecondByteMask:"<<print_as_binary(secondByteMask)
150  << "\tfirstByteBit:"<<print_as_binary(firstByteBit)
151  << std::endl;
152  }
153  */
154  //return value;
155 }
156 
157 #endif
SiStripNoises::getDataVectorBegin
ContainerIterator getDataVectorBegin() const
Definition: SiStripNoises.h:61
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
SiStripNoises::printSummary
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Definition: SiStripNoises.cc:224
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
sistrip::extrainfo::noise_
static const char noise_[]
Definition: ConstantsForDqm.h:47
mps_fire.i
i
Definition: mps_fire.py:355
input
static const std::string input
Definition: EdmProvDump.cc:48
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
SiStripNoises::getNoiseFast
static float getNoiseFast(const uint16_t &strip, const Range &range)
Definition: SiStripNoises.h:66
SiStripNoises::DetRegistry::detid
uint32_t detid
Definition: SiStripNoises.h:33
SiStripNoises
Definition: SiStripNoises.h:25
SiStripNoises::put
bool put(const uint32_t &detID, const InputVector &input)
Definition: SiStripNoises.cc:16
SiStripNoises::ratioData::values
std::vector< float > values
Definition: SiStripNoises.h:29
TrackerTopology
Definition: TrackerTopology.h:16
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
pos
Definition: PixelAliasList.h:18
COND_SERIALIZABLE
#define COND_SERIALIZABLE
Definition: Serializable.h:39
SiStripNoises::getRegistryVectorEnd
RegistryIterator getRegistryVectorEnd() const
Definition: SiStripNoises.h:64
SiStripNoises::StrictWeakOrdering
Definition: SiStripNoises.h:40
SiStripNoises::getRange
const Range getRange(const uint32_t detID) const
Definition: SiStripNoises.cc:34
SiStripNoises::getDetIds
void getDetIds(std::vector< uint32_t > &DetIds_) const
Definition: SiStripNoises.cc:58
SiStripNoises::Container
std::vector< unsigned char > Container
Definition: SiStripNoises.h:45
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
optionsL1T.skip
skip
Definition: optionsL1T.py:30
SiStripNoises::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:47
SiStripNoises::setData
void setData(float noise_, InputVector &vped)
Definition: SiStripNoises.cc:74
SiStripNoises::ratioData::detid
uint32_t detid
Definition: SiStripNoises.h:28
SiStripNoises::SiStripNoises
SiStripNoises()
Definition: SiStripNoises.h:53
SiStripNoises::DetRegistry
Definition: SiStripNoises.h:32
SiStripNoises::getRangeByPos
Range getRangeByPos(unsigned short pos) const
Definition: SiStripNoises.cc:48
Serializable.h
SiStripNoises::get9bits
static uint16_t get9bits(const uint8_t *&ptr, int8_t skip)
Definition: SiStripNoises.h:109
SiStripNoises::DetRegistry::ibegin
uint32_t ibegin
Definition: SiStripNoises.h:34
SiStripNoises::indexes
Registry indexes
Definition: SiStripNoises.h:96
SiStripNoises::verify
static void verify(uint16_t strip, const Range &range)
Definition: SiStripNoises.cc:68
SiStripNoises::printDebug
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Definition: SiStripNoises.cc:196
hgcalLayerClusters_cfi.noises
noises
Definition: hgcalLayerClusters_cfi.py:40
SiStripNoises::v_noises
Container v_noises
Definition: SiStripNoises.h:95
SiStripNoises::ratioData
Definition: SiStripNoises.h:27
SiStripNoises::getRegistryVectorBegin
RegistryIterator getRegistryVectorBegin() const
Definition: SiStripNoises.h:63
SiStripNoises::allNoises
void allNoises(std::vector< float > &noises, const Range &range) const
Definition: SiStripNoises.cc:122
SiStripNoises::StrictWeakOrdering::operator()
bool operator()(const DetRegistry &p, const uint32_t &i) const
Definition: SiStripNoises.h:42
SiStripNoises::Registry
std::vector< DetRegistry > Registry
Definition: SiStripNoises.h:48
SiStripNoises::encode
static void encode(const InputVector &Vi, std::vector< unsigned char > &Vo_CHAR)
Definition: SiStripNoises.cc:78
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
SiStripNoises::RegistryIterator
Registry::const_iterator RegistryIterator
Definition: SiStripNoises.h:49
ztail.d
d
Definition: ztail.py:151
SiStripNoises::InputVector
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:50
SiStripNoises::decode
static uint16_t decode(uint16_t strip, const Range &range)
Definition: SiStripNoises.h:117
SiStripNoises::getNoise
static float getNoise(uint16_t strip, const Range &range)
Definition: SiStripNoises.h:71
SiStripNoises::ContainerIterator
std::vector< unsigned char >::const_iterator ContainerIterator
Definition: SiStripNoises.h:46
SiStripNoises::getDataVectorEnd
ContainerIterator getDataVectorEnd() const
Definition: SiStripNoises.h:62
SiStripNoises::operator/
std::vector< ratioData > operator/(const SiStripNoises &d)
Definition: SiStripNoises.cc:267
SiStripNoises::DetRegistry::iend
uint32_t iend
Definition: SiStripNoises.h:35
SiStripNoises::~SiStripNoises
~SiStripNoises()
Definition: SiStripNoises.h:54