CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
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,
ContainerIterator
Range
 
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
 Prints all the thresholds for all DetIds. More...
 
void printSummary (std::stringstream &ss) const
 Prints mean, rms, min and max threshold values for each DetId. More...
 
bool put (const uint32_t &detID, 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)
 

Private Attributes

Registry indexes
 
Container v_threshold
 

Detailed Description

Holds the thresholds:

Definition at line 38 of file SiStripThreshold.h.

Member Typedef Documentation

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

Definition at line 95 of file SiStripThreshold.h.

typedef Container::const_iterator SiStripThreshold::ContainerIterator

Definition at line 96 of file SiStripThreshold.h.

Definition at line 100 of file SiStripThreshold.h.

Definition at line 97 of file SiStripThreshold.h.

Definition at line 98 of file SiStripThreshold.h.

typedef Registry::const_iterator SiStripThreshold::RegistryIterator

Definition at line 99 of file SiStripThreshold.h.

Constructor & Destructor Documentation

SiStripThreshold::SiStripThreshold ( )
inline

Definition at line 102 of file SiStripThreshold.h.

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

Definition at line 103 of file SiStripThreshold.h.

References indexes, and v_threshold.

103  {
104  v_threshold=orig.v_threshold;
105  indexes=orig.indexes;
106  }
virtual SiStripThreshold::~SiStripThreshold ( )
inlinevirtual

Definition at line 107 of file SiStripThreshold.h.

107 {};

Member Function Documentation

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

Definition at line 159 of file SiStripThreshold.cc.

References relativeConstraints::value.

Referenced by printSummary().

159  {
160  sum+=value*range;
161  sum2+=value*value*range;
162  if(value<min)
163  min=value;
164  if(value>max)
165  max=value;
166 }
#define min(a, b)
Definition: mlp_lapack.h:161
const T & max(const T &a, const T &b)
void SiStripThreshold::allThresholds ( std::vector< float > &  lowThs,
std::vector< float > &  highThs,
const Range range 
) const

Definition at line 79 of file SiStripThreshold.cc.

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

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

Definition at line 30 of file SiStripThreshold.cc.

Referenced by put().

30  {
31  std::stable_sort(input.begin(),input.end());
32  return std::unique(input.begin(),input.end());
33 }
SiStripThreshold::Data SiStripThreshold::getData ( const uint16_t &  strip,
const Range range 
) const

Definition at line 67 of file SiStripThreshold.cc.

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

Referenced by ShapeTools.ShapeBuilder::doCombinedDataset().

67  {
69  ContainerIterator p = std::upper_bound(range.first,range.second,estrip,SiStripThreshold::dataStrictWeakOrdering());
70  if (p!=range.first){
71  return *(--p);
72  }
73  else{
74  throw cms::Exception("CorruptedData")
75  << "[SiStripThreshold::getData] asking for data for a strip " << strip << " lower then the first stored strip " << p->getFirstStrip();
76  }
77 }
static const uint32_t FirstThStripShift_
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
static const uint32_t HighThStripMask_
static const uint32_t FirstThStripMask_
Container::const_iterator ContainerIterator
ContainerIterator SiStripThreshold::getDataVectorBegin ( ) const
inline

Definition at line 114 of file SiStripThreshold.h.

References v_threshold.

Referenced by printDebug(), and printSummary().

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

Definition at line 115 of file SiStripThreshold.h.

References v_threshold.

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

Definition at line 46 of file SiStripThreshold.cc.

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

46  {
47  // returns vector of DetIds in map
50  for (SiStripThreshold::RegistryIterator p=begin; p != end; ++p) {
51  DetIds_.push_back(p->detid);
52  }
53 }
#define end
Definition: vmac.h:38
#define begin
Definition: vmac.h:31
Registry::const_iterator RegistryIterator
const SiStripThreshold::Range SiStripThreshold::getRange ( const uint32_t &  detID) const

Definition at line 35 of file SiStripThreshold.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_threshold.

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

Definition at line 116 of file SiStripThreshold.h.

References indexes.

Referenced by printDebug(), and printSummary().

116 {return indexes.begin();}
RegistryIterator SiStripThreshold::getRegistryVectorEnd ( ) const
inline

Definition at line 117 of file SiStripThreshold.h.

References indexes.

Referenced by printDebug(), and printSummary().

117 {return indexes.end();}
void SiStripThreshold::printDebug ( std::stringstream &  ss) const

Prints all the thresholds for all DetIds.

Definition at line 100 of file SiStripThreshold.cc.

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

Referenced by SiStripThresholdGenerator::createObject().

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

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

Definition at line 114 of file SiStripThreshold.cc.

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

114  {
116  ContainerIterator it,eit,itp;
117  float meanLth, meanHth, meanCth; //mean value
118  float rmsLth, rmsHth, rmsCth; //rms value
119  float maxLth, maxHth, maxCth; //max value
120  float minLth, minHth, minCth; //min value
121  uint16_t n;
122  uint16_t firstStrip,stripRange;
123  for(;rit!=erit;++rit){
124  it=getDataVectorBegin()+rit->ibegin;
125  eit=getDataVectorBegin()+rit->iend;
126  ss << "\ndetid: " << rit->detid << " \t ";
127 
128  meanLth=0; meanHth=0; meanCth=0; //mean value
129  rmsLth=0; rmsHth=0; rmsCth=0; //rms value
130  maxLth=0; maxHth=0; maxCth=0; //max value
131  minLth=10000; minHth=10000; minCth=10000; //min value
132  n=0;
133  firstStrip=0;
134  for(;it!=eit;++it){
135  itp=it+1;
136  firstStrip=it->getFirstStrip();
137  if(itp!=eit)
138  stripRange=(itp->getFirstStrip()-firstStrip);
139  else
140  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
141 
142  addToStat(it->getLth() ,stripRange,meanLth,rmsLth,minLth,maxLth);
143  addToStat(it->getHth() ,stripRange,meanHth,rmsHth,minHth,maxHth);
144  addToStat(it->getClusth(),stripRange,meanCth,rmsCth,minCth,maxCth);
145  n+=stripRange;
146  }
147  meanLth/=n;
148  meanHth/=n;
149  meanCth/=n;
150  rmsLth= sqrt(rmsLth/n-meanLth*meanLth);
151  rmsHth= sqrt(rmsHth/n-meanHth*meanHth);
152  rmsCth= sqrt(rmsCth/n-meanCth*meanCth);
153  ss<< "\nn " << n << " \tmeanLth " << meanLth << " \t rmsLth " << rmsLth << " \t minLth " << minLth << " \t maxLth " << maxLth;
154  ss<< "\n\tmeanHth " << meanHth << " \t rmsHth " << rmsHth << " \t minHth " << minHth << " \t maxHth " << maxHth;
155  ss<< "\n\tmeanCth " << meanCth << " \t rmsCth " << rmsCth << " \t minCth " << minCth << " \t maxCth " << maxCth;
156  }
157 }
ContainerIterator getDataVectorBegin() const
T sqrt(T t)
Definition: SSEVec.h:46
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,
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(), SiStripThresholdGenerator::createObject(), and SiStripCondObjBuilderFromDb::storeThreshold().

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

Definition at line 55 of file SiStripThreshold.cc.

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

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

55  {
56  Data a;
57  a.encode(strip,lTh,hTh);
58  vthr.push_back(a);
59 }
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
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 61 of file SiStripThreshold.cc.

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

61  {
62  Data a;
63  a.encode(strip,lTh,hTh,cTh);
64  vthr.push_back(a);
65 }
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
double a
Definition: hdecay.h:121

Member Data Documentation

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