CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripThreshold.h
Go to the documentation of this file.
1 #ifndef SiStripThreshold_h
2 #define SiStripThreshold_h
3 
4 #include<vector>
5 #include<map>
6 #include<iostream>
7 #include<boost/cstdint.hpp>
9 #include <sstream>
10 
39 
40  public:
41 
42  struct Data{
43  //used to create the threshold object for the ZS (that has only 2 thresholds)
44  inline void encode (const uint16_t& strip, const float& lTh,const float& hTh) {
47  ((uint32_t)(hTh*5.0+0.5) & sistrip::HighThStripMask_);
48 
49  lowTh=((uint32_t)(lTh*5.0+0.5) & sistrip::LowThStripMask_);
50  clusTh=0; //put as default;
51  }
52 
53 
54  inline void encode (const uint16_t& strip, const float& lTh,const float& hTh, const float& cTh) {
55  encode (strip,lTh,hTh);
56  clusTh=(uint8_t)(cTh*10+.5);
57  }
58 
59  inline uint16_t getFirstStrip() const {return (FirstStrip_and_Hth>>sistrip::FirstThStripShift_);}
60  inline float getHth() const {return (FirstStrip_and_Hth& sistrip::HighThStripMask_)/5.0;}
61  inline float getLth()const {return (lowTh& sistrip::LowThStripMask_)/5.0;}
62  inline float getClusth()const {return clusTh/10.0;}
63 
64  bool operator == (const Data& d) const { return (getHth() == d.getHth()) && (lowTh == d.lowTh) && (clusTh == d.clusTh); }
65  bool operator < (const Data& d) const { return (FirstStrip_and_Hth < d.FirstStrip_and_Hth); }
66 
67  void print(std::stringstream& ss) const{ ss << "firstStrip: " << getFirstStrip() << " \t"
68  << "lTh: " << " " << getLth() << " \t"
69  << "hTh: " << " " << getHth() << " \t"
70  << "cTh: " << " " << getClusth() << " \t";}
71 
73  uint8_t lowTh;
74  uint8_t clusTh;
75  };
76 
77  struct DetRegistry{
78  uint32_t detid;
79  uint32_t ibegin;
80  uint32_t iend;
81  };
82 
83 
85  public:
86  bool operator() (const DetRegistry& p,const uint32_t& i) const {return p.detid < i;}
87  };
88 
90  public:
91  bool operator() (const uint16_t& i, const Data& p) const {return i<p.FirstStrip_and_Hth ;}
92  };
93 
94 
95  typedef std::vector<Data> Container;
96  typedef Container::const_iterator ContainerIterator;
97  typedef std::pair<ContainerIterator, ContainerIterator> Range;
98  typedef std::vector<DetRegistry> Registry;
99  typedef Registry::const_iterator RegistryIterator;
101 
104  v_threshold=orig.v_threshold;
105  indexes=orig.indexes;
106  }
107  virtual ~SiStripThreshold(){};
108 
109  bool put(const uint32_t& detID,InputVector vect);
110  const Range getRange(const uint32_t& detID) const;
111  void getDetIds(std::vector<uint32_t>& DetIds_) const;
112 
113 
118 
119  void setData(const uint16_t& strip, const float& lTh,const float& hTh, Container& vthr);
120  void setData(const uint16_t& strip, const float& lTh,const float& hTh, const float& cTh, Container& vthr);
121  SiStripThreshold::Data getData (const uint16_t& strip, const Range& range) const;
122 
123  void allThresholds(std::vector<float> &lowThs, std::vector<float> &highThs, const Range& range) const;
124 
126  void printSummary(std::stringstream& ss) const;
128  void printDebug(std::stringstream& ss) const;
129 
130  private:
131 
132  Container::iterator compact(Container& input);
133  void addToStat(float value, uint16_t& range, float& sum, float& sum2, float& min, float& max) const;
134 
135  private:
138 };
139 
140 #endif
static const uint32_t FirstThStripShift_
int i
Definition: DBlmapReader.cc:9
Container::iterator compact(Container &input)
std::vector< DetRegistry > Registry
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
ContainerIterator getDataVectorBegin() const
#define min(a, b)
Definition: mlp_lapack.h:161
bool operator<(const Data &d) const
void allThresholds(std::vector< float > &lowThs, std::vector< float > &highThs, const Range &range) const
ContainerIterator getDataVectorEnd() const
void encode(const uint16_t &strip, const float &lTh, const float &hTh, const float &cTh)
std::vector< Data > Container
const T & max(const T &a, const T &b)
SiStripThreshold::Data getData(const uint16_t &strip, const Range &range) const
RegistryIterator getRegistryVectorBegin() const
uint16_t getFirstStrip() const
void encode(const uint16_t &strip, const float &lTh, const float &hTh)
bool put(const uint32_t &detID, InputVector vect)
void print(std::stringstream &ss) const
void printDebug(std::stringstream &ss) const
Prints all the thresholds for all DetIds.
std::pair< ContainerIterator, ContainerIterator > Range
static const uint32_t HighThStripMask_
void getDetIds(std::vector< uint32_t > &DetIds_) const
bool operator()(const DetRegistry &p, const uint32_t &i) const
static const uint32_t LowThStripMask_
SiStripThreshold(const SiStripThreshold &orig)
void setData(const uint16_t &strip, const float &lTh, const float &hTh, Container &vthr)
void printSummary(std::stringstream &ss) const
Prints mean, rms, min and max threshold values for each DetId.
virtual ~SiStripThreshold()
static const uint32_t FirstThStripMask_
Registry::const_iterator RegistryIterator
bool operator==(const Data &d) const
void addToStat(float value, uint16_t &range, float &sum, float &sum2, float &min, float &max) const
bool operator()(const uint16_t &i, const Data &p) const
const Range getRange(const uint32_t &detID) const
RegistryIterator getRegistryVectorEnd() const
Container::const_iterator ContainerIterator
float getClusth() const