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 
5 
6 #include<vector>
7 #include<map>
8 #include<iostream>
9 #include<boost/cstdint.hpp>
11 #include <sstream>
12 
41 
42  public:
43 
44  struct Data{
45  //used to create the threshold object for the ZS (that has only 2 thresholds)
46  inline void encode (const uint16_t& strip, const float& lTh,const float& hTh) {
49  ((uint32_t)(hTh*5.0+0.5) & sistrip::HighThStripMask_);
50 
51  lowTh=((uint32_t)(lTh*5.0+0.5) & sistrip::LowThStripMask_);
52  clusTh=0; //put as default;
53  }
54 
55 
56  inline void encode (const uint16_t& strip, const float& lTh,const float& hTh, const float& cTh) {
57  encode (strip,lTh,hTh);
58  clusTh=(uint8_t)(cTh*10+.5);
59  }
60 
61  inline uint16_t getFirstStrip() const {return (FirstStrip_and_Hth>>sistrip::FirstThStripShift_);}
62  inline float getHth() const {return (FirstStrip_and_Hth& sistrip::HighThStripMask_)/5.0;}
63  inline float getLth()const {return (lowTh& sistrip::LowThStripMask_)/5.0;}
64  inline float getClusth()const {return clusTh/10.0;}
65 
66  bool operator == (const Data& d) const { return (getHth() == d.getHth()) && (lowTh == d.lowTh) && (clusTh == d.clusTh); }
67  bool operator < (const Data& d) const { return (FirstStrip_and_Hth < d.FirstStrip_and_Hth); }
68 
69  void print(std::stringstream& ss) const{ ss << "firstStrip: " << getFirstStrip() << " \t"
70  << "lTh: " << " " << getLth() << " \t"
71  << "hTh: " << " " << getHth() << " \t"
72  << "cTh: " << " " << getClusth() << " \t";}
73 
75  uint8_t lowTh;
76  uint8_t clusTh;
77 
79 };
80 
81  struct DetRegistry{
82  uint32_t detid;
83  uint32_t ibegin;
84  uint32_t iend;
85 
87 };
88 
89 
91  public:
92  bool operator() (const DetRegistry& p,const uint32_t& i) const {return p.detid < i;}
93  };
94 
96  public:
97  bool operator() (const uint16_t& i, const Data& p) const {return i<p.FirstStrip_and_Hth ;}
98  };
99 
100 
101  typedef std::vector<Data> Container;
102  typedef Container::const_iterator ContainerIterator;
103  typedef std::pair<ContainerIterator, ContainerIterator> Range;
104  typedef std::vector<DetRegistry> Registry;
105  typedef Registry::const_iterator RegistryIterator;
107 
110  v_threshold=orig.v_threshold;
111  indexes=orig.indexes;
112  }
113  virtual ~SiStripThreshold(){};
114 
115  bool put(const uint32_t& detID,const InputVector& vect);
116  const Range getRange(const uint32_t& detID) const;
117  void getDetIds(std::vector<uint32_t>& DetIds_) const;
118 
119 
124 
125  void setData(const uint16_t& strip, const float& lTh,const float& hTh, Container& vthr);
126  void setData(const uint16_t& strip, const float& lTh,const float& hTh, const float& cTh, Container& vthr);
127  SiStripThreshold::Data getData (const uint16_t& strip, const Range& range) const;
128 
129  void allThresholds(std::vector<float> &lowThs, std::vector<float> &highThs, const Range& range) const;
130 
132  void printSummary(std::stringstream& ss) const;
134  void printDebug(std::stringstream& ss) const;
135 
136  private:
137 
138  Container::iterator compact(Container& input);
139  void addToStat(float value, uint16_t& range, float& sum, float& sum2, float& min, float& max) const;
140 
141  private:
144 
146 };
147 
148 #endif
static const uint32_t FirstThStripShift_
bool put(const uint32_t &detID, const InputVector &vect)
int i
Definition: DBlmapReader.cc:9
Container::iterator compact(Container &input)
std::vector< DetRegistry > Registry
ContainerIterator getDataVectorBegin() const
bool operator<(const Data &d) const
void allThresholds(std::vector< float > &lowThs, std::vector< float > &highThs, const Range &range) const
ContainerIterator getDataVectorEnd() const
static std::string const input
Definition: EdmProvDump.cc:43
tuple d
Definition: ztail.py:151
void encode(const uint16_t &strip, const float &lTh, const float &hTh, const float &cTh)
std::vector< Data > Container
SiStripThreshold::Data getData(const uint16_t &strip, const Range &range) const
T min(T a, T b)
Definition: MathUtil.h:58
RegistryIterator getRegistryVectorBegin() const
uint16_t getFirstStrip() const
void encode(const uint16_t &strip, const float &lTh, const float &hTh)
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)
#define COND_SERIALIZABLE
Definition: Serializable.h:37
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