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>
10 #include <sstream>
11 #include <cstdint>
12 
13 class TrackerTopology;
14 
43 public:
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) {
48  ((uint32_t)(hTh * 5.0 + 0.5) & sistrip::HighThStripMask_);
49 
50  lowTh = ((uint32_t)(lTh * 5.0 + 0.5) & sistrip::LowThStripMask_);
51  clusTh = 0; //put as default;
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 {
65  return (getHth() == d.getHth()) && (lowTh == d.lowTh) && (clusTh == d.clusTh);
66  }
67  bool operator<(const Data& d) const { return (FirstStrip_and_Hth < d.FirstStrip_and_Hth); }
68 
69  void print(std::stringstream& ss) const {
70  ss << "firstStrip: " << getFirstStrip() << " \t"
71  << "lTh: "
72  << " " << getLth() << " \t"
73  << "hTh: "
74  << " " << getHth() << " \t"
75  << "cTh: "
76  << " " << getClusth() << " \t";
77  }
78 
80  uint8_t lowTh;
81  uint8_t clusTh;
82 
84  };
85 
86  struct DetRegistry {
87  uint32_t detid;
88  uint32_t ibegin;
89  uint32_t iend;
90 
92  };
93 
95  public:
96  bool operator()(const DetRegistry& p, const uint32_t& i) const { return p.detid < i; }
97  };
98 
100  public:
101  bool operator()(const uint16_t& i, const Data& p) const { return i < p.FirstStrip_and_Hth; }
102  };
103 
104  typedef std::vector<Data> Container;
105  typedef Container::const_iterator ContainerIterator;
106  typedef std::pair<ContainerIterator, ContainerIterator> Range;
107  typedef std::vector<DetRegistry> Registry;
108  typedef Registry::const_iterator RegistryIterator;
110 
113  v_threshold = orig.v_threshold;
114  indexes = orig.indexes;
115  }
116  virtual ~SiStripThreshold() {}
117 
118  bool put(const uint32_t& detID, const InputVector& vect);
119  const Range getRange(const uint32_t& detID) const;
120  void getDetIds(std::vector<uint32_t>& DetIds_) const;
121 
124  RegistryIterator getRegistryVectorBegin() const { return indexes.begin(); }
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  Container::iterator compact(Container& input);
140  void addToStat(float value, uint16_t& range, float& sum, float& sum2, float& min, float& max) const;
141 
142 private:
145 
147 };
148 
149 #endif
static const uint32_t FirstThStripShift_
bool put(const uint32_t &detID, const InputVector &vect)
Container::iterator compact(Container &input)
std::vector< DetRegistry > Registry
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
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints mean, rms, min and max threshold values for each DetId.
uint16_t getFirstStrip() const
bool operator==(const Data &d) const
static std::string const input
Definition: EdmProvDump.cc:50
void encode(const uint16_t &strip, const float &lTh, const float &hTh, const float &cTh)
std::vector< Data > Container
ContainerIterator getDataVectorEnd() const
void addToStat(float value, uint16_t &range, float &sum, float &sum2, float &min, float &max) const
Definition: value.py:1
void print(std::stringstream &ss) const
d
Definition: ztail.py:151
void encode(const uint16_t &strip, const float &lTh, const float &hTh)
bool operator()(const uint16_t &i, const Data &p) const
std::pair< ContainerIterator, ContainerIterator > Range
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints all the thresholds for all DetIds.
static const uint32_t HighThStripMask_
static const uint32_t LowThStripMask_
SiStripThreshold(const SiStripThreshold &orig)
#define COND_SERIALIZABLE
Definition: Serializable.h:39
void setData(const uint16_t &strip, const float &lTh, const float &hTh, Container &vthr)
const Range getRange(const uint32_t &detID) const
virtual ~SiStripThreshold()
static const uint32_t FirstThStripMask_
RegistryIterator getRegistryVectorEnd() const
Registry::const_iterator RegistryIterator
ContainerIterator getDataVectorBegin() const
bool operator<(const Data &d) const
void getDetIds(std::vector< uint32_t > &DetIds_) const
RegistryIterator getRegistryVectorBegin() const
Container::const_iterator ContainerIterator
bool operator()(const DetRegistry &p, const uint32_t &i) const