CMS 3D CMS Logo

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

#include <SiStripThreshold.h>

Classes

struct  Data
 
class  dataStrictWeakOrdering
 
struct  DetRegistry
 
class  StrictWeakOrdering
 

Public Types

typedef std::vector< DataContainer
 
typedef Container::const_iterator ContainerIterator
 
typedef Container InputVector
 
typedef std::pair< ContainerIterator, ContainerIteratorRange
 
typedef std::vector< DetRegistryRegistry
 
typedef Registry::const_iterator RegistryIterator
 

Public Member Functions

void allThresholds (std::vector< float > &lowThs, std::vector< float > &highThs, const Range &range) const
 
SiStripThreshold::Data getData (const uint16_t &strip, const Range &range) const
 
ContainerIterator getDataVectorBegin () const
 
ContainerIterator getDataVectorEnd () const
 
void getDetIds (std::vector< uint32_t > &DetIds_) 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 the thresholds for all DetIds. More...
 
void printSummary (std::stringstream &ss, const TrackerTopology *trackerTopo) const
 Prints mean, rms, min and max threshold values for each DetId. More...
 
bool put (const uint32_t &detID, const InputVector &vect)
 
void setData (const uint16_t &strip, const float &lTh, const float &hTh, Container &vthr)
 
void setData (const uint16_t &strip, const float &lTh, const float &hTh, const float &cTh, Container &vthr)
 
 SiStripThreshold ()
 
 SiStripThreshold (const SiStripThreshold &orig)
 
virtual ~SiStripThreshold ()
 

Private Member Functions

void addToStat (float value, uint16_t &range, float &sum, float &sum2, float &min, float &max) const
 
Container::iterator compact (Container &input)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

Registry indexes
 
Container v_threshold
 

Friends

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

Detailed Description

Holds the thresholds:

Definition at line 42 of file SiStripThreshold.h.

Member Typedef Documentation

typedef std::vector<Data> SiStripThreshold::Container

Definition at line 104 of file SiStripThreshold.h.

typedef Container::const_iterator SiStripThreshold::ContainerIterator

Definition at line 105 of file SiStripThreshold.h.

Definition at line 109 of file SiStripThreshold.h.

Definition at line 106 of file SiStripThreshold.h.

Definition at line 107 of file SiStripThreshold.h.

typedef Registry::const_iterator SiStripThreshold::RegistryIterator

Definition at line 108 of file SiStripThreshold.h.

Constructor & Destructor Documentation

SiStripThreshold::SiStripThreshold ( )
inline

Definition at line 111 of file SiStripThreshold.h.

111 {};
SiStripThreshold::SiStripThreshold ( const SiStripThreshold orig)
inline

Definition at line 112 of file SiStripThreshold.h.

References indexes, and v_threshold.

112  {
113  v_threshold = orig.v_threshold;
114  indexes = orig.indexes;
115  }
virtual SiStripThreshold::~SiStripThreshold ( )
inlinevirtual

Definition at line 116 of file SiStripThreshold.h.

References getDetIds(), getRange(), and put().

116 {};

Member Function Documentation

void SiStripThreshold::addToStat ( float  value,
uint16_t &  range,
float &  sum,
float &  sum2,
float &  min,
float &  max 
) const
private

Definition at line 177 of file SiStripThreshold.cc.

References FastTimerService_cff::range, and relativeConstraints::value.

Referenced by getRegistryVectorEnd(), and printSummary().

177  {
178  sum += value * range;
179  sum2 += value * value * range;
180  if (value < min)
181  min = value;
182  if (value > max)
183  max = value;
184 }
Definition: value.py:1
T min(T a, T b)
Definition: MathUtil.h:58
void SiStripThreshold::allThresholds ( std::vector< float > &  lowThs,
std::vector< float > &  highThs,
const Range range 
) const

Definition at line 82 of file SiStripThreshold.cc.

References ntuplemaker::fill, LaserClient_cfi::high, LaserClient_cfi::low, and DigiDM_cff::strips.

Referenced by getRegistryVectorEnd().

84  {
85  ContainerIterator it = range.first;
86  size_t strips = lowThs.size();
87  assert(strips == highThs.size());
88  while (it != range.second) {
89  size_t firstStrip = it->getFirstStrip();
90  //std::cout << "First strip is " << firstStrip << std::endl;
91  float high = it->getHth(), low = it->getLth();
92  //std::cout << "High is " << high << ", low is " << low << std::endl;
93  ++it; // increment the pointer
94  size_t lastStrip = (it == range.second ? strips : it->getFirstStrip());
95  //std::cout << "Last strip is " << lastStrip << std::endl;
96  if (lastStrip > strips) {
97  it = range.second; // I should stop here,
98  lastStrip = strips; // and fill only 'strips' strips
99  }
100  std::fill(&lowThs[firstStrip], &lowThs[lastStrip], low);
101  std::fill(&highThs[firstStrip], &highThs[lastStrip], high);
102  }
103 }
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
Definition: DigiDM_cff.py:32
Container::const_iterator ContainerIterator
SiStripThreshold::Container::iterator SiStripThreshold::compact ( Container input)
private

Definition at line 33 of file SiStripThreshold.cc.

References tier0::unique().

Referenced by getRegistryVectorEnd(), and put().

33  {
34  std::stable_sort(input.begin(), input.end());
35  return std::unique(input.begin(), input.end());
36 }
static std::string const input
Definition: EdmProvDump.cc:48
def unique(seq, keepstr=True)
Definition: tier0.py:24
SiStripThreshold::Data SiStripThreshold::getData ( const uint16_t &  strip,
const Range range 
) const

Definition at line 70 of file SiStripThreshold.cc.

References Exception, sistrip::FirstThStripMask_, sistrip::FirstThStripShift_, sistrip::HighThStripMask_, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by SiStripThresholdReader::analyze(), SiStripThresholdDQM::fillMEsForDet(), SiStripThresholdDQM::fillMEsForLayer(), getRegistryVectorEnd(), and SiStripFedZeroSuppression::suppress().

70  {
71  uint16_t estrip =
73  ContainerIterator p = std::upper_bound(range.first, range.second, estrip, SiStripThreshold::dataStrictWeakOrdering());
74  if (p != range.first) {
75  return *(--p);
76  } else {
77  throw cms::Exception("CorruptedData") << "[SiStripThreshold::getData] asking for data for a strip " << strip
78  << " lower then the first stored strip " << p->getFirstStrip();
79  }
80 }
static const uint32_t FirstThStripShift_
static const uint32_t HighThStripMask_
static const uint32_t FirstThStripMask_
Container::const_iterator ContainerIterator
ContainerIterator SiStripThreshold::getDataVectorBegin ( ) const
inline

Definition at line 122 of file SiStripThreshold.h.

References v_threshold.

Referenced by printDebug(), and printSummary().

122 { return v_threshold.begin(); }
ContainerIterator SiStripThreshold::getDataVectorEnd ( ) const
inline

Definition at line 123 of file SiStripThreshold.h.

References v_threshold.

123 { return v_threshold.end(); }
void SiStripThreshold::getDetIds ( std::vector< uint32_t > &  DetIds_) const

Definition at line 48 of file SiStripThreshold.cc.

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

Referenced by SiStripThresholdReader::analyze(), SiStripThresholdDQM::fillMEsForDet(), SiStripThresholdDQM::getActiveDetIds(), and ~SiStripThreshold().

48  {
49  // returns vector of DetIds in map
52  for (SiStripThreshold::RegistryIterator p = begin; p != end; ++p) {
53  DetIds_.push_back(p->detid);
54  }
55 }
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
Registry::const_iterator RegistryIterator
const SiStripThreshold::Range SiStripThreshold::getRange ( const uint32_t &  detID) const

Definition at line 38 of file SiStripThreshold.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_threshold.

Referenced by SiStripThresholdReader::analyze(), SiStripThresholdDQM::fillMEsForDet(), SiStripThresholdDQM::fillMEsForLayer(), SiStripFedZeroSuppression::suppress(), and ~SiStripThreshold().

38  {
39  // get SiStripThreshold Range of DetId
40 
41  RegistryIterator p = std::lower_bound(indexes.begin(), indexes.end(), DetId, SiStripThreshold::StrictWeakOrdering());
42  if (p == indexes.end() || p->detid != DetId)
43  return SiStripThreshold::Range(v_threshold.end(), v_threshold.end());
44  else
45  return SiStripThreshold::Range(v_threshold.begin() + p->ibegin, v_threshold.begin() + p->iend);
46 }
Definition: DetId.h:17
std::pair< ContainerIterator, ContainerIterator > Range
Registry::const_iterator RegistryIterator
RegistryIterator SiStripThreshold::getRegistryVectorBegin ( ) const
inline

Definition at line 124 of file SiStripThreshold.h.

References indexes.

Referenced by printDebug(), and printSummary().

124 { return indexes.begin(); }
RegistryIterator SiStripThreshold::getRegistryVectorEnd ( ) const
inline
void SiStripThreshold::printDebug ( std::stringstream &  ss,
const TrackerTopology trackerTopo 
) const

Prints all the thresholds for all DetIds.

Definition at line 105 of file SiStripThreshold.cc.

References getDataVectorBegin(), getRegistryVectorBegin(), and getRegistryVectorEnd().

Referenced by getRegistryVectorEnd().

105  {
107  ContainerIterator it, eit;
108  for (; rit != erit; ++rit) {
109  it = getDataVectorBegin() + rit->ibegin;
110  eit = getDataVectorBegin() + rit->iend;
111  ss << "\ndetid: " << rit->detid << " \t ";
112  for (; it != eit; ++it) {
113  ss << "\n \t ";
114  it->print(ss);
115  }
116  }
117 }
ContainerIterator getDataVectorBegin() const
RegistryIterator getRegistryVectorBegin() const
Registry::const_iterator RegistryIterator
RegistryIterator getRegistryVectorEnd() const
Container::const_iterator ContainerIterator
void SiStripThreshold::printSummary ( std::stringstream &  ss,
const TrackerTopology trackerTopo 
) const

Prints mean, rms, min and max threshold values for each DetId.

Definition at line 119 of file SiStripThreshold.cc.

References addToStat(), getDataVectorBegin(), getRegistryVectorBegin(), getRegistryVectorEnd(), dqmiodumpmetadata::n, and mathSSE::sqrt().

Referenced by getRegistryVectorEnd().

119  {
121  ContainerIterator it, eit, itp;
122  float meanLth, meanHth, meanCth; //mean value
123  float rmsLth, rmsHth, rmsCth; //rms value
124  float maxLth, maxHth, maxCth; //max value
125  float minLth, minHth, minCth; //min value
126  uint16_t n;
127  uint16_t firstStrip, stripRange;
128  for (; rit != erit; ++rit) {
129  it = getDataVectorBegin() + rit->ibegin;
130  eit = getDataVectorBegin() + rit->iend;
131  ss << "\ndetid: " << rit->detid << " \t ";
132 
133  meanLth = 0;
134  meanHth = 0;
135  meanCth = 0; //mean value
136  rmsLth = 0;
137  rmsHth = 0;
138  rmsCth = 0; //rms value
139  maxLth = 0;
140  maxHth = 0;
141  maxCth = 0; //max value
142  minLth = 10000;
143  minHth = 10000;
144  minCth = 10000; //min value
145  n = 0;
146  firstStrip = 0;
147  for (; it != eit; ++it) {
148  itp = it + 1;
149  firstStrip = it->getFirstStrip();
150  if (itp != eit)
151  stripRange = (itp->getFirstStrip() - firstStrip);
152  else
153  stripRange =
154  firstStrip > 511
155  ? 768 - firstStrip
156  : 512 -
157  firstStrip; //*FIXME, I dont' know ithis class the strip number of a detector, so I assume wrongly that if the last firstStrip<511 the detector has only 512 strips. Clearly wrong. to be fixed
158 
159  addToStat(it->getLth(), stripRange, meanLth, rmsLth, minLth, maxLth);
160  addToStat(it->getHth(), stripRange, meanHth, rmsHth, minHth, maxHth);
161  addToStat(it->getClusth(), stripRange, meanCth, rmsCth, minCth, maxCth);
162  n += stripRange;
163  }
164  meanLth /= n;
165  meanHth /= n;
166  meanCth /= n;
167  rmsLth = sqrt(rmsLth / n - meanLth * meanLth);
168  rmsHth = sqrt(rmsHth / n - meanHth * meanHth);
169  rmsCth = sqrt(rmsCth / n - meanCth * meanCth);
170  ss << "\nn " << n << " \tmeanLth " << meanLth << " \t rmsLth " << rmsLth << " \t minLth " << minLth << " \t maxLth "
171  << maxLth;
172  ss << "\n\tmeanHth " << meanHth << " \t rmsHth " << rmsHth << " \t minHth " << minHth << " \t maxHth " << maxHth;
173  ss << "\n\tmeanCth " << meanCth << " \t rmsCth " << rmsCth << " \t minCth " << minCth << " \t maxCth " << maxCth;
174  }
175 }
ContainerIterator getDataVectorBegin() const
T sqrt(T t)
Definition: SSEVec.h:19
RegistryIterator getRegistryVectorBegin() const
Registry::const_iterator RegistryIterator
void addToStat(float value, uint16_t &range, float &sum, float &sum2, float &min, float &max) const
RegistryIterator getRegistryVectorEnd() const
Container::const_iterator ContainerIterator
bool SiStripThreshold::put ( const uint32_t &  detID,
const InputVector vect 
)

Definition at line 8 of file SiStripThreshold.cc.

References compact(), SiStripThreshold::DetRegistry::detid, SiStripThreshold::DetRegistry::ibegin, SiStripThreshold::DetRegistry::iend, indexes, AlCaHLTBitMon_ParallelJobs::p, sd, and v_threshold.

Referenced by SiStripThresholdBuilder::analyze(), SiStripCondObjBuilderFromDb::storeThreshold(), and ~SiStripThreshold().

8  {
9  InputVector vect = _vect;
10  // put in SiStripThreshold::v_threshold of DetId
11  Registry::iterator p =
12  std::lower_bound(indexes.begin(), indexes.end(), DetId, SiStripThreshold::StrictWeakOrdering());
13  if (p != indexes.end() && p->detid == DetId) {
14  edm::LogError("SiStripThreshold") << "[" << __PRETTY_FUNCTION__ << "] SiStripThreshold for DetID " << DetId
15  << " is already stored. Skippig this put" << std::endl;
16  return false;
17  }
18 
19  SiStripThreshold::Container::iterator new_end = compact(vect);
20 
21  size_t sd = new_end - vect.begin();
22  DetRegistry detregistry;
23  detregistry.detid = DetId;
24  detregistry.ibegin = v_threshold.size();
25  detregistry.iend = v_threshold.size() + sd;
26  indexes.insert(p, detregistry);
27 
28  v_threshold.insert(v_threshold.end(), vect.begin(), new_end);
29 
30  return true;
31 }
Container::iterator compact(Container &input)
Definition: DetId.h:17
double sd
template<class Archive >
void SiStripThreshold::serialize ( Archive &  ar,
const unsigned int  version 
)
private
void SiStripThreshold::setData ( const uint16_t &  strip,
const float &  lTh,
const float &  hTh,
Container vthr 
)

Definition at line 57 of file SiStripThreshold.cc.

References a, and SiStripThreshold::Data::encode().

Referenced by SiStripThresholdBuilder::analyze(), getRegistryVectorEnd(), SiStripCondObjBuilderFromDb::setDefaultValuesCabling(), and SiStripCondObjBuilderFromDb::setValuesCabling().

57  {
58  Data a;
59  a.encode(strip, lTh, hTh);
60  vthr.push_back(a);
61 }
double a
Definition: hdecay.h:119
void SiStripThreshold::setData ( const uint16_t &  strip,
const float &  lTh,
const float &  hTh,
const float &  cTh,
Container vthr 
)

Definition at line 63 of file SiStripThreshold.cc.

References a, and SiStripThreshold::Data::encode().

64  {
65  Data a;
66  a.encode(strip, lTh, hTh, cTh);
67  vthr.push_back(a);
68 }
double a
Definition: hdecay.h:119

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 146 of file SiStripThreshold.h.

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

Definition at line 146 of file SiStripThreshold.h.

Member Data Documentation

Registry SiStripThreshold::indexes
private
Container SiStripThreshold::v_threshold
private