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 103 of file SiStripThreshold.h.

typedef Container::const_iterator SiStripThreshold::ContainerIterator

Definition at line 104 of file SiStripThreshold.h.

Definition at line 108 of file SiStripThreshold.h.

Definition at line 105 of file SiStripThreshold.h.

Definition at line 106 of file SiStripThreshold.h.

typedef Registry::const_iterator SiStripThreshold::RegistryIterator

Definition at line 107 of file SiStripThreshold.h.

Constructor & Destructor Documentation

SiStripThreshold::SiStripThreshold ( )
inline

Definition at line 110 of file SiStripThreshold.h.

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

Definition at line 111 of file SiStripThreshold.h.

References indexes, and v_threshold.

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

Definition at line 115 of file SiStripThreshold.h.

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

115 {};

Member Function Documentation

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

Definition at line 160 of file SiStripThreshold.cc.

References relativeConstraints::value.

Referenced by getRegistryVectorEnd(), and printSummary().

160  {
161  sum+=value*range;
162  sum2+=value*value*range;
163  if(value<min)
164  min=value;
165  if(value>max)
166  max=value;
167 }
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 80 of file SiStripThreshold.cc.

References lumiContext::fill, and RecoTauPiZeroBuilderPlugins_cfi::strips.

Referenced by getRegistryVectorEnd().

80  {
81  ContainerIterator it = range.first;
82  size_t strips = lowThs.size();
83  assert(strips == highThs.size());
84  while (it != range.second) {
85  size_t firstStrip = it->getFirstStrip();
86  //std::cout << "First strip is " << firstStrip << std::endl;
87  float high = it->getHth(), low = it->getLth();
88  //std::cout << "High is " << high << ", low is " << low << std::endl;
89  ++it; // increment the pointer
90  size_t lastStrip = (it == range.second ? strips : it->getFirstStrip());
91  //std::cout << "Last strip is " << lastStrip << std::endl;
92  if (lastStrip > strips) {
93  it = range.second; // I should stop here,
94  lastStrip = strips; // and fill only 'strips' strips
95  }
96  std::fill( & lowThs[firstStrip] , & lowThs[lastStrip] , low );
97  std::fill( & highThs[firstStrip], & highThs[lastStrip], high );
98  }
99 }
Container::const_iterator ContainerIterator
SiStripThreshold::Container::iterator SiStripThreshold::compact ( Container input)
private

Definition at line 31 of file SiStripThreshold.cc.

References tier0::unique().

Referenced by getRegistryVectorEnd(), and put().

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

Definition at line 68 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().

68  {
70  ContainerIterator p = std::upper_bound(range.first,range.second,estrip,SiStripThreshold::dataStrictWeakOrdering());
71  if (p!=range.first){
72  return *(--p);
73  }
74  else{
75  throw cms::Exception("CorruptedData")
76  << "[SiStripThreshold::getData] asking for data for a strip " << strip << " lower then the first stored strip " << p->getFirstStrip();
77  }
78 }
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 47 of file SiStripThreshold.cc.

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

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

47  {
48  // returns vector of DetIds in map
51  for (SiStripThreshold::RegistryIterator p=begin; p != end; ++p) {
52  DetIds_.push_back(p->detid);
53  }
54 }
#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 36 of file SiStripThreshold.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_threshold.

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

36  {
37  // get SiStripThreshold Range of DetId
38 
39  RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiStripThreshold::StrictWeakOrdering());
40  if (p==indexes.end()|| p->detid!=DetId)
41  return SiStripThreshold::Range(v_threshold.end(),v_threshold.end());
42  else
43  return SiStripThreshold::Range(v_threshold.begin()+p->ibegin,v_threshold.begin()+p->iend);
44 }
Definition: DetId.h:18
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 101 of file SiStripThreshold.cc.

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

Referenced by getRegistryVectorEnd().

101  {
103  ContainerIterator it,eit;
104  for(;rit!=erit;++rit){
105  it=getDataVectorBegin()+rit->ibegin;
106  eit=getDataVectorBegin()+rit->iend;
107  ss << "\ndetid: " << rit->detid << " \t ";
108  for(;it!=eit;++it){
109  ss << "\n \t ";
110  it->print(ss);
111  }
112  }
113 }
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 115 of file SiStripThreshold.cc.

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

Referenced by getRegistryVectorEnd().

115  {
117  ContainerIterator it,eit,itp;
118  float meanLth, meanHth, meanCth; //mean value
119  float rmsLth, rmsHth, rmsCth; //rms value
120  float maxLth, maxHth, maxCth; //max value
121  float minLth, minHth, minCth; //min value
122  uint16_t n;
123  uint16_t firstStrip,stripRange;
124  for(;rit!=erit;++rit){
125  it=getDataVectorBegin()+rit->ibegin;
126  eit=getDataVectorBegin()+rit->iend;
127  ss << "\ndetid: " << rit->detid << " \t ";
128 
129  meanLth=0; meanHth=0; meanCth=0; //mean value
130  rmsLth=0; rmsHth=0; rmsCth=0; //rms value
131  maxLth=0; maxHth=0; maxCth=0; //max value
132  minLth=10000; minHth=10000; minCth=10000; //min value
133  n=0;
134  firstStrip=0;
135  for(;it!=eit;++it){
136  itp=it+1;
137  firstStrip=it->getFirstStrip();
138  if(itp!=eit)
139  stripRange=(itp->getFirstStrip()-firstStrip);
140  else
141  stripRange=firstStrip>511?768-firstStrip:512-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
142 
143  addToStat(it->getLth() ,stripRange,meanLth,rmsLth,minLth,maxLth);
144  addToStat(it->getHth() ,stripRange,meanHth,rmsHth,minHth,maxHth);
145  addToStat(it->getClusth(),stripRange,meanCth,rmsCth,minCth,maxCth);
146  n+=stripRange;
147  }
148  meanLth/=n;
149  meanHth/=n;
150  meanCth/=n;
151  rmsLth= sqrt(rmsLth/n-meanLth*meanLth);
152  rmsHth= sqrt(rmsHth/n-meanHth*meanHth);
153  rmsCth= sqrt(rmsCth/n-meanCth*meanCth);
154  ss<< "\nn " << n << " \tmeanLth " << meanLth << " \t rmsLth " << rmsLth << " \t minLth " << minLth << " \t maxLth " << maxLth;
155  ss<< "\n\tmeanHth " << meanHth << " \t rmsHth " << rmsHth << " \t minHth " << minHth << " \t maxHth " << maxHth;
156  ss<< "\n\tmeanCth " << meanCth << " \t rmsCth " << rmsCth << " \t minCth " << minCth << " \t maxCth " << maxCth;
157  }
158 }
ContainerIterator getDataVectorBegin() const
T sqrt(T t)
Definition: SSEVec.h:18
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 = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiStripThreshold::StrictWeakOrdering());
12  if (p!=indexes.end() && p->detid==DetId){
13  edm::LogError("SiStripThreshold") << "[" << __PRETTY_FUNCTION__ << "] SiStripThreshold for DetID " << DetId << " is already stored. Skippig this put" << std::endl;
14  return false;
15  }
16 
17  SiStripThreshold::Container::iterator new_end=compact(vect);
18 
19  size_t sd= new_end-vect.begin();
20  DetRegistry detregistry;
21  detregistry.detid=DetId;
22  detregistry.ibegin=v_threshold.size();
23  detregistry.iend=v_threshold.size()+sd;
24  indexes.insert(p,detregistry);
25 
26  v_threshold.insert(v_threshold.end(),vect.begin(),new_end);
27 
28  return true;
29 }
Container::iterator compact(Container &input)
Definition: DetId.h:18
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 56 of file SiStripThreshold.cc.

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

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

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

Definition at line 62 of file SiStripThreshold.cc.

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

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

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 147 of file SiStripThreshold.h.

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

Definition at line 147 of file SiStripThreshold.h.

Member Data Documentation

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