CMS 3D CMS Logo

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 
13 class TrackerTopology;
14 
43 
44  public:
45 
46  struct Data{
47  //used to create the threshold object for the ZS (that has only 2 thresholds)
48  inline void encode (const uint16_t& strip, const float& lTh,const float& hTh) {
51  ((uint32_t)(hTh*5.0+0.5) & sistrip::HighThStripMask_);
52 
53  lowTh=((uint32_t)(lTh*5.0+0.5) & sistrip::LowThStripMask_);
54  clusTh=0; //put as default;
55  }
56 
57 
58  inline void encode (const uint16_t& strip, const float& lTh,const float& hTh, const float& cTh) {
59  encode (strip,lTh,hTh);
60  clusTh=(uint8_t)(cTh*10+.5);
61  }
62 
63  inline uint16_t getFirstStrip() const {return (FirstStrip_and_Hth>>sistrip::FirstThStripShift_);}
64  inline float getHth() const {return (FirstStrip_and_Hth& sistrip::HighThStripMask_)/5.0;}
65  inline float getLth()const {return (lowTh& sistrip::LowThStripMask_)/5.0;}
66  inline float getClusth()const {return clusTh/10.0;}
67 
68  bool operator == (const Data& d) const { return (getHth() == d.getHth()) && (lowTh == d.lowTh) && (clusTh == d.clusTh); }
69  bool operator < (const Data& d) const { return (FirstStrip_and_Hth < d.FirstStrip_and_Hth); }
70 
71  void print(std::stringstream& ss) const{ ss << "firstStrip: " << getFirstStrip() << " \t"
72  << "lTh: " << " " << getLth() << " \t"
73  << "hTh: " << " " << getHth() << " \t"
74  << "cTh: " << " " << getClusth() << " \t";}
75 
77  uint8_t lowTh;
78  uint8_t clusTh;
79 
81 };
82 
83  struct DetRegistry{
84  uint32_t detid;
85  uint32_t ibegin;
86  uint32_t iend;
87 
89 };
90 
91 
93  public:
94  bool operator() (const DetRegistry& p,const uint32_t& i) const {return p.detid < i;}
95  };
96 
98  public:
99  bool operator() (const uint16_t& i, const Data& p) const {return i<p.FirstStrip_and_Hth ;}
100  };
101 
102 
103  typedef std::vector<Data> Container;
104  typedef Container::const_iterator ContainerIterator;
105  typedef std::pair<ContainerIterator, ContainerIterator> Range;
106  typedef std::vector<DetRegistry> Registry;
107  typedef Registry::const_iterator RegistryIterator;
108  typedef Container InputVector;
109 
112  v_threshold=orig.v_threshold;
113  indexes=orig.indexes;
114  }
115  virtual ~SiStripThreshold(){};
116 
117  bool put(const uint32_t& detID,const InputVector& vect);
118  const Range getRange(const uint32_t& detID) const;
119  void getDetIds(std::vector<uint32_t>& DetIds_) const;
120 
121 
122  ContainerIterator getDataVectorBegin() const {return v_threshold.begin();}
123  ContainerIterator getDataVectorEnd() const {return v_threshold.end();}
124  RegistryIterator getRegistryVectorBegin() const {return indexes.begin();}
125  RegistryIterator getRegistryVectorEnd() const{return indexes.end();}
126 
127  void setData(const uint16_t& strip, const float& lTh,const float& hTh, Container& vthr);
128  void setData(const uint16_t& strip, const float& lTh,const float& hTh, const float& cTh, Container& vthr);
129  SiStripThreshold::Data getData (const uint16_t& strip, const Range& range) const;
130 
131  void allThresholds(std::vector<float> &lowThs, std::vector<float> &highThs, const Range& range) const;
132 
134  void printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
136  void printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
137 
138  private:
139 
140  Container::iterator compact(Container& input);
141  void addToStat(float value, uint16_t& range, float& sum, float& sum2, float& min, float& max) const;
142 
143  private:
144  Container v_threshold;
145  Registry indexes;
146 
148 };
149 
150 #endif
static const uint32_t FirstThStripShift_
bool put(const uint32_t &detID, const InputVector &vect)
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:44
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints all the thresholds for all DetIds.
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
Definition: value.py:1
T min(T a, T b)
Definition: MathUtil.h:58
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints mean, rms, min and max threshold values for each DetId.
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
std::pair< ContainerIterator, ContainerIterator > Range
static const uint32_t HighThStripMask_
void getDetIds(std::vector< uint32_t > &DetIds_) const
static const uint32_t LowThStripMask_
SiStripThreshold(const SiStripThreshold &orig)
#define COND_SERIALIZABLE
Definition: Serializable.h:38
void setData(const uint16_t &strip, const float &lTh, const float &hTh, Container &vthr)
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
const Range getRange(const uint32_t &detID) const
RegistryIterator getRegistryVectorEnd() const
Container::const_iterator ContainerIterator
float getClusth() const