CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
SiStripPedestals Class Reference

#include <SiStripPedestals.h>

Classes

struct  DetRegistry
 
class  StrictWeakOrdering
 

Public Types

typedef std::vector< char > Container
 
typedef std::vector< char >::const_iterator ContainerIterator
 
typedef std::vector< uint16_t > InputVector
 
typedef std::pair< ContainerIterator, ContainerIteratorRange
 
typedef std::vector< DetRegistryRegistry
 
typedef Registry::const_iterator RegistryIterator
 

Public Member Functions

void allPeds (std::vector< int > &pefs, const Range &range) const
 
ContainerIterator getDataVectorBegin () const
 
ContainerIterator getDataVectorEnd () const
 
void getDetIds (std::vector< uint32_t > &DetIds_) const
 
float getPed (const uint16_t &strip, const Range &range) const
 
const Range getRange (const uint32_t &detID) const
 
RegistryIterator getRegistryVectorBegin () const
 
RegistryIterator getRegistryVectorEnd () const
 
void printDebug (std::stringstream &ss, const TrackerTopology *trackerTopo) const
 Prints all pedestals. More...
 
void printSummary (std::stringstream &ss, const TrackerTopology *trackerTopo) const
 Prints mean pedestal value divided for subdet, layer and mono/stereo. More...
 
bool put (const uint32_t &detID, InputVector &input)
 
void setData (float ped, InputVector &vped)
 
 SiStripPedestals ()
 
 ~SiStripPedestals ()
 

Private Member Functions

uint16_t decode (const uint16_t &strip, const Range &range) const
 
void encode (InputVector &Vi, std::vector< unsigned char > &Vo_CHAR)
 
uint16_t get10bits (const uint8_t *&ptr, int8_t skip) const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

Registry indexes
 
Container v_pedestals
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Stores the pedestal of every strip.
Encodes the information in a vector<char> and uses a vector<DetRegistry> to connect each range of values to the corresponding detId.
The DetRegistry struct contains the detId and two uint32_t giving the index of begin and end of the corresponding range in the vector<char>.
Has methods to return the pedestal of a given strip of of all the strips.

The printSummary method uses SiStripDetSummary. See description therein.
The printDebug method prints the pedestal value for every strip of every detId.

Definition at line 27 of file SiStripPedestals.h.

Member Typedef Documentation

◆ Container

typedef std::vector<char> SiStripPedestals::Container

Definition at line 49 of file SiStripPedestals.h.

◆ ContainerIterator

typedef std::vector<char>::const_iterator SiStripPedestals::ContainerIterator

Definition at line 50 of file SiStripPedestals.h.

◆ InputVector

typedef std::vector<uint16_t> SiStripPedestals::InputVector

Definition at line 54 of file SiStripPedestals.h.

◆ Range

Definition at line 51 of file SiStripPedestals.h.

◆ Registry

Definition at line 52 of file SiStripPedestals.h.

◆ RegistryIterator

typedef Registry::const_iterator SiStripPedestals::RegistryIterator

Definition at line 53 of file SiStripPedestals.h.

Constructor & Destructor Documentation

◆ SiStripPedestals()

SiStripPedestals::SiStripPedestals ( )
inline

Definition at line 56 of file SiStripPedestals.h.

56 {};

◆ ~SiStripPedestals()

SiStripPedestals::~SiStripPedestals ( )
inline

Definition at line 57 of file SiStripPedestals.h.

57 {};

Member Function Documentation

◆ allPeds()

void SiStripPedestals::allPeds ( std::vector< int > &  pefs,
const Range range 
) const

Definition at line 143 of file SiStripPedestals.cc.

References Exception, get10bits(), MillePedeFileConverter_cfg::out, FastTimerService_cff::range, and findQualityFiles::size.

Referenced by sistrip::FEDEmulator::retrievePedestals(), and SiStripPedestalsSubtractor::subtract_().

143  {
144  size_t mysize = ((range.second - range.first) << 3) / 10;
145  size_t size = peds.size();
146  if (mysize < size)
147  throw cms::Exception("CorruptedData") << "[SiStripPedestals::allPeds] Requested pedestals for " << peds.size()
148  << " strips, I have it only for " << mysize << " strips\n";
149  size_t size4 = size & (~0x3), carry = size & 0x3; // we have an optimized way of unpacking 4 strips
150  const uint8_t* ptr = reinterpret_cast<const uint8_t*>(&*range.second) - 1;
151  std::vector<int>::iterator out = peds.begin(), end4 = peds.begin() + size4;
152  // we do it this baroque way instead of just loopin on all the strips because it's faster
153  // as the value of 'skip' is a constant, so the compiler can compute the masks directly
154  while (out < end4) {
155  *out = static_cast<int>(get10bits(ptr, 0));
156  ++out;
157  *out = static_cast<int>(get10bits(ptr, 2));
158  ++out;
159  *out = static_cast<int>(get10bits(ptr, 4));
160  ++out;
161  *out = static_cast<int>(get10bits(ptr, 6));
162  ++out;
163  --ptr; // every 4 strips we have to skip one more bit
164  }
165  for (size_t rem = 0; rem < carry; ++rem) {
166  *out = static_cast<int>(get10bits(ptr, 2 * rem));
167  ++out;
168  }
169 }
size
Write out results.
uint16_t get10bits(const uint8_t *&ptr, int8_t skip) const

◆ decode()

uint16_t SiStripPedestals::decode ( const uint16_t &  strip,
const Range range 
) const
private

Definition at line 101 of file SiStripPedestals.cc.

References data, FastTimerService_cff::range, digitizers_cfi::strip, and relativeConstraints::value.

Referenced by ztail.Decoder::follow(), getPed(), and ztail.Decoder::initial_synchronize().

101  {
102  const char* data = &*(range.second - 1); // pointer to the last byte of data
103  static const uint16_t BITS_PER_STRIP = 10;
104 
105  uint32_t lowBit = strip * BITS_PER_STRIP;
106  uint8_t firstByteBit = (lowBit & 6); //module
107  uint8_t firstByteNBits = 8 - firstByteBit;
108  uint8_t firstByteMask = 0xffu << firstByteBit;
109  uint8_t secondByteMask = ~(0xffu << (BITS_PER_STRIP - firstByteNBits));
110  uint16_t value = ((uint16_t(*(data - lowBit / 8)) & firstByteMask) >> firstByteBit) |
111  ((uint16_t(*(data - lowBit / 8 - 1)) & secondByteMask) << firstByteNBits);
112 
113  /*
114  if(strip < 25){
115  std::cout << "***************DECODE*********************"<<"\n"
116  << "strip "<<strip << " "
117  << value
118  <<"\t :"<<print_as_binary(value)
119  <<"\t :"<<print_as_binary( ((uint16_t(*(data-lowBit/8 )) & firstByteMask) >> firstByteBit) )
120  << "-"<<print_as_binary( ((uint16_t(*(data-lowBit/8-1)) & secondByteMask) <<firstByteNBits) )
121  << "\t *(data-lowBit/8) " << print_as_binary( *(data-lowBit/8 ))
122  << "\t *(data-lowBit/8-1) " << print_as_binary( *(data-lowBit/8 -1 ))
123  << "\tlowBit:"<< lowBit
124  << "\tfirstByteMask :"<<print_as_binary(firstByteMask)
125  << "\tsecondByteMask:"<<print_as_binary(secondByteMask)
126  << "\tfirstByteBit:"<<print_as_binary(firstByteBit)
127  << std::endl;
128  }
129  */
130  return value;
131 }
Definition: value.py:1
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ encode()

void SiStripPedestals::encode ( InputVector Vi,
std::vector< unsigned char > &  Vo_CHAR 
)
private

Definition at line 59 of file SiStripPedestals.cc.

References data, and mps_fire::i.

Referenced by put().

59  {
60  static const uint16_t BITS_PER_STRIP = 10;
61  const size_t VoSize = (size_t)((Vi.size() * BITS_PER_STRIP) / 8 + .999);
62  Vo.resize(VoSize);
63  for (size_t i = 0; i < Vo.size(); ++i)
64  Vo[i] &= 0x00u;
65 
66  for (unsigned int stripIndex = 0; stripIndex < Vi.size(); ++stripIndex) {
67  unsigned char* data = &Vo[Vo.size() - 1];
68  uint32_t lowBit = stripIndex * BITS_PER_STRIP;
69  uint8_t firstByteBit = (lowBit & 0x6);
70  uint8_t firstByteNBits = 8 - firstByteBit;
71  uint8_t firstByteMask = 0xffu << firstByteBit;
72  uint8_t secondByteNbits = (BITS_PER_STRIP - firstByteNBits);
73  uint8_t secondByteMask = ~(0xffu << secondByteNbits);
74 
75  *(data - lowBit / 8) = (*(data - lowBit / 8) & ~(firstByteMask)) | ((Vi[stripIndex] & 0xffu) << firstByteBit);
76  *(data - lowBit / 8 - 1) =
77  (*(data - lowBit / 8 - 1) & ~(secondByteMask)) | ((Vi[stripIndex] >> firstByteNBits) & secondByteMask);
78 
79  /*
80  if(stripIndex < 25 ){
81  std::cout << "***************ENCODE*********************"<<std::endl
82  << "\tdata-lowBit/8 :"<<print_as_binary((*(data-lowBit/8) & ~(firstByteMask)))
83  << "-"<<print_as_binary(((Vi[stripIndex] & 0xffu) <<firstByteBit))
84  << "\tdata-lowBit/8-1 :"<<print_as_binary((*(data-lowBit/8-1) & ~(secondByteMask)))
85  << "-"<<print_as_binary((((Vi[stripIndex]>> firstByteNBits) & secondByteMask)))
86  << std::endl;
87  std::cout << "strip "<<stripIndex<<"\tvi: " << Vi[stripIndex] <<"\t"
88  << print_short_as_binary(Vi[stripIndex])
89  << "\tvo1:"<< print_char_as_binary(*(data-lowBit/8))
90  << "\tvo2:"<< print_char_as_binary(*(data-lowBit/8-1))
91  << "\tlowBit:"<< lowBit
92  << "\tfirstByteMask :"<<print_as_binary(firstByteMask)
93  << "\tsecondByteMask:"<<print_as_binary(secondByteMask)
94  << "\tfirstByteBit:"<<print_as_binary(firstByteBit)
95  << std::endl;
96  }
97  */
98  }
99 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ get10bits()

uint16_t SiStripPedestals::get10bits ( const uint8_t *&  ptr,
int8_t  skip 
) const
inlineprivate

Get 9 bit words from a bit stream, starting from the right, skipping the first 'skip' bits (0 < skip < 7). Ptr must point to the rightmost byte that has some bits of this word, and is updated by this function

Definition at line 135 of file SiStripPedestals.cc.

References runTheMatrix::ret, and optionsL1T::skip.

Referenced by allPeds().

135  {
136  uint8_t maskThis = (0xFF << skip);
137  uint8_t maskThat = ((4 << skip) - 1);
138  uint16_t ret = (((*ptr) & maskThis) >> skip);
139  --ptr;
140  return ret | (((*ptr) & maskThat) << (8 - skip));
141 }
ret
prodAgent to be discontinued

◆ getDataVectorBegin()

ContainerIterator SiStripPedestals::getDataVectorBegin ( ) const
inline

Definition at line 64 of file SiStripPedestals.h.

References v_pedestals.

64 { return v_pedestals.begin(); }

◆ getDataVectorEnd()

ContainerIterator SiStripPedestals::getDataVectorEnd ( ) const
inline

Definition at line 65 of file SiStripPedestals.h.

References v_pedestals.

65 { return v_pedestals.end(); }

◆ getDetIds()

void SiStripPedestals::getDetIds ( std::vector< uint32_t > &  DetIds_) const

Definition at line 38 of file SiStripPedestals.cc.

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

Referenced by SiStripPedestalsDQM::getActiveDetIds(), printDebug(), and printSummary().

38  {
39  // returns vector of DetIds in map
42  for (SiStripPedestals::RegistryIterator p = begin; p != end; ++p) {
43  DetIds_.push_back(p->detid);
44  }
45 }
Registry::const_iterator RegistryIterator

◆ getPed()

float SiStripPedestals::getPed ( const uint16_t &  strip,
const Range range 
) const

Definition at line 51 of file SiStripPedestals.cc.

References decode(), Exception, FastTimerService_cff::range, and digitizers_cfi::strip.

Referenced by SiStripDB2Tree::analyze(), CalibrationScanTask::CalibrationScanTask(), CalibrationTask::CalibrationTask(), SiStripAPVRestorer::createCMMapRealPed(), SiStripPedestalsDQM::fillMEsForDet(), SiStripPedestalsDQM::fillMEsForLayer(), LaserAlignment::fillPedestalProfiles(), printDebug(), printSummary(), and DigiSimLinkAlgorithm::run().

51  {
52  if (10 * strip >= (range.second - range.first) * 8) {
53  throw cms::Exception("CorruptedData")
54  << "[SiStripPedestals::getPed] looking for SiStripPedestals for a strip out of range: strip " << strip;
55  }
56  return static_cast<float>(decode(strip, range));
57 }
uint16_t decode(const uint16_t &strip, const Range &range) const

◆ getRange()

const SiStripPedestals::Range SiStripPedestals::getRange ( const uint32_t &  detID) const

Definition at line 28 of file SiStripPedestals.cc.

References indexes, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

Referenced by SiStripDB2Tree::analyze(), CalibrationScanTask::CalibrationScanTask(), CalibrationTask::CalibrationTask(), SiStripAPVRestorer::createCMMapRealPed(), SiStripPedestalsDQM::fillMEsForDet(), SiStripPedestalsDQM::fillMEsForLayer(), LaserAlignment::fillPedestalProfiles(), printDebug(), printSummary(), sistrip::FEDEmulator::retrievePedestals(), DigiSimLinkAlgorithm::run(), and SiStripPedestalsSubtractor::subtract_().

28  {
29  // get SiStripPedestals Range of DetId
30 
32  if (p == indexes.end() || p->detid != DetId)
33  return SiStripPedestals::Range(v_pedestals.end(), v_pedestals.end());
34  else
35  return SiStripPedestals::Range(v_pedestals.begin() + p->ibegin, v_pedestals.begin() + p->iend);
36 }
std::pair< ContainerIterator, ContainerIterator > Range
Definition: DetId.h:17
Registry::const_iterator RegistryIterator

◆ getRegistryVectorBegin()

RegistryIterator SiStripPedestals::getRegistryVectorBegin ( ) const
inline

Definition at line 66 of file SiStripPedestals.h.

References indexes.

66 { return indexes.begin(); }

◆ getRegistryVectorEnd()

RegistryIterator SiStripPedestals::getRegistryVectorEnd ( ) const
inline

Definition at line 67 of file SiStripPedestals.h.

References indexes.

67 { return indexes.end(); }

◆ printDebug()

void SiStripPedestals::printDebug ( std::stringstream &  ss,
const TrackerTopology trackerTopo 
) const

Prints all pedestals.

Definition at line 185 of file SiStripPedestals.cc.

References getDetIds(), getPed(), getRange(), l1ctLayer2EG_cff::id, FastTimerService_cff::range, contentValuesCheck::ss, and digitizers_cfi::strip.

185  {
186  std::vector<uint32_t> detid;
187  getDetIds(detid);
188 
189  ss << "Number of detids = " << detid.size() << std::endl;
190 
191  for (size_t id = 0; id < detid.size(); ++id) {
193 
194  int strip = 0;
195  ss << "detid" << std::setw(15) << "strip" << std::setw(10) << "pedestal" << std::endl;
196  int detId = 0;
197  int oldDetId = 0;
198  for (int it = 0; it < (range.second - range.first) * 8 / 10; ++it) {
199  detId = detid[id];
200  if (detId != oldDetId) {
201  oldDetId = detId;
202  ss << detid[id];
203  } else
204  ss << " ";
205  ss << std::setw(15) << strip++ << std::setw(10) << getPed(it, range) << std::endl;
206  }
207  }
208 }
const Range getRange(const uint32_t &detID) const
std::pair< ContainerIterator, ContainerIterator > Range
float getPed(const uint16_t &strip, const Range &range) const
void getDetIds(std::vector< uint32_t > &DetIds_) const

◆ printSummary()

void SiStripPedestals::printSummary ( std::stringstream &  ss,
const TrackerTopology trackerTopo 
) const

Prints mean pedestal value divided for subdet, layer and mono/stereo.

Definition at line 171 of file SiStripPedestals.cc.

References getDetIds(), getPed(), getRange(), l1ctLayer2EG_cff::id, FastTimerService_cff::range, contentValuesCheck::ss, and edmLumisInFiles::summary.

171  {
172  std::vector<uint32_t> detid;
173  getDetIds(detid);
174  SiStripDetSummary summary{trackerTopo};
175  for (size_t id = 0; id < detid.size(); ++id) {
177  for (int it = 0; it < (range.second - range.first) * 8 / 10; ++it) {
178  summary.add(detid[id], getPed(it, range));
179  }
180  }
181  ss << "Summary of pedestals:" << std::endl;
182  summary.print(ss);
183 }
const Range getRange(const uint32_t &detID) const
std::pair< ContainerIterator, ContainerIterator > Range
float getPed(const uint16_t &strip, const Range &range) const
void getDetIds(std::vector< uint32_t > &DetIds_) const

◆ put()

bool SiStripPedestals::put ( const uint32_t &  detID,
InputVector input 
)

Definition at line 5 of file SiStripPedestals.cc.

References SiStripPedestals::DetRegistry::detid, encode(), SiStripPedestals::DetRegistry::ibegin, SiStripPedestals::DetRegistry::iend, indexes, input, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

Referenced by SiStripPopConPedestalsHandlerFromDQM::dqmEndJob(), and SiStripCondObjBuilderFromDb::storePedestals().

5  {
6  // put in SiStripPedestals of DetId
7  std::vector<unsigned char> Vo_CHAR;
8  encode(input, Vo_CHAR);
9 
10  Registry::iterator p =
12  if (p != indexes.end() && p->detid == DetId)
13  return false;
14 
15  //size_t sd= input.second-input.first;
16  size_t sd = Vo_CHAR.end() - Vo_CHAR.begin();
17  DetRegistry detregistry;
18  detregistry.detid = DetId;
19  detregistry.ibegin = v_pedestals.size();
20  detregistry.iend = v_pedestals.size() + sd;
21  indexes.insert(p, detregistry);
22 
23  //v_pedestals.insert(v_pedestals.end(),input.first,input.second);
24  v_pedestals.insert(v_pedestals.end(), Vo_CHAR.begin(), Vo_CHAR.end());
25  return true;
26 }
void encode(InputVector &Vi, std::vector< unsigned char > &Vo_CHAR)
static std::string const input
Definition: EdmProvDump.cc:50
Definition: DetId.h:17

◆ serialize()

template<class Archive >
void SiStripPedestals::serialize ( Archive &  ar,
const unsigned int  version 
)
private

◆ setData()

void SiStripPedestals::setData ( float  ped,
SiStripPedestals::InputVector vped 
)

Definition at line 47 of file SiStripPedestals.cc.

Referenced by SiStripPopConPedestalsHandlerFromDQM::dqmEndJob(), SiStripCondObjBuilderFromDb::setDefaultValuesCabling(), and SiStripCondObjBuilderFromDb::setValuesCabling().

47  {
48  vped.push_back((static_cast<uint16_t>(ped) & 0x3FF));
49 }

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 86 of file SiStripPedestals.h.

◆ cond::serialization::access

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 86 of file SiStripPedestals.h.

Member Data Documentation

◆ indexes

Registry SiStripPedestals::indexes
private

◆ v_pedestals

Container SiStripPedestals::v_pedestals
private

Definition at line 83 of file SiStripPedestals.h.

Referenced by getDataVectorBegin(), getDataVectorEnd(), getRange(), and put().