File indexing completed on 2024-09-07 04:35:41
0001 #ifndef SiStripThreshold_h
0002 #define SiStripThreshold_h
0003
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005
0006 #include <vector>
0007 #include <map>
0008 #include <iostream>
0009 #include "DataFormats/SiStripCommon/interface/ConstantsForCondObjects.h"
0010 #include <sstream>
0011 #include <cstdint>
0012
0013 class TrackerTopology;
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 class SiStripThreshold {
0043 public:
0044 struct Data {
0045
0046 inline void encode(const uint16_t& strip, const float& lTh, const float& hTh) {
0047 FirstStrip_and_Hth = ((strip & sistrip::FirstThStripMask_) << sistrip::FirstThStripShift_) |
0048 ((uint32_t)(hTh * 5.0 + 0.5) & sistrip::HighThStripMask_);
0049
0050 lowTh = ((uint32_t)(lTh * 5.0 + 0.5) & sistrip::LowThStripMask_);
0051 clusTh = 0;
0052 }
0053
0054 inline void encode(const uint16_t& strip, const float& lTh, const float& hTh, const float& cTh) {
0055 encode(strip, lTh, hTh);
0056 clusTh = (uint8_t)(cTh * 10 + .5);
0057 }
0058
0059 inline uint16_t getFirstStrip() const { return (FirstStrip_and_Hth >> sistrip::FirstThStripShift_); }
0060 inline float getHth() const { return (FirstStrip_and_Hth & sistrip::HighThStripMask_) / 5.0; }
0061 inline float getLth() const { return (lowTh & sistrip::LowThStripMask_) / 5.0; }
0062 inline float getClusth() const { return clusTh / 10.0; }
0063
0064 bool operator==(const Data& d) const {
0065 return (getHth() == d.getHth()) && (lowTh == d.lowTh) && (clusTh == d.clusTh);
0066 }
0067 bool operator<(const Data& d) const { return (FirstStrip_and_Hth < d.FirstStrip_and_Hth); }
0068
0069 void print(std::stringstream& ss) const {
0070 ss << "firstStrip: " << getFirstStrip() << " \t"
0071 << "lTh: "
0072 << " " << getLth() << " \t"
0073 << "hTh: "
0074 << " " << getHth() << " \t"
0075 << "cTh: "
0076 << " " << getClusth() << " \t";
0077 }
0078
0079 uint16_t FirstStrip_and_Hth;
0080 uint8_t lowTh;
0081 uint8_t clusTh;
0082
0083 COND_SERIALIZABLE;
0084 };
0085
0086 struct DetRegistry {
0087 uint32_t detid;
0088 uint32_t ibegin;
0089 uint32_t iend;
0090
0091 COND_SERIALIZABLE;
0092 };
0093
0094 class StrictWeakOrdering {
0095 public:
0096 bool operator()(const DetRegistry& p, const uint32_t& i) const { return p.detid < i; }
0097 };
0098
0099 class dataStrictWeakOrdering {
0100 public:
0101 bool operator()(const uint16_t& i, const Data& p) const { return i < p.FirstStrip_and_Hth; }
0102 };
0103
0104 typedef std::vector<Data> Container;
0105 typedef Container::const_iterator ContainerIterator;
0106 typedef std::pair<ContainerIterator, ContainerIterator> Range;
0107 typedef std::vector<DetRegistry> Registry;
0108 typedef Registry::const_iterator RegistryIterator;
0109 typedef Container InputVector;
0110
0111 SiStripThreshold() {}
0112 SiStripThreshold(const SiStripThreshold& orig) {
0113 v_threshold = orig.v_threshold;
0114 indexes = orig.indexes;
0115 }
0116 virtual ~SiStripThreshold() {}
0117
0118 bool put(const uint32_t& detID, const InputVector& vect);
0119 const Range getRange(const uint32_t& detID) const;
0120 void getDetIds(std::vector<uint32_t>& DetIds_) const;
0121
0122 ContainerIterator getDataVectorBegin() const { return v_threshold.begin(); }
0123 ContainerIterator getDataVectorEnd() const { return v_threshold.end(); }
0124 RegistryIterator getRegistryVectorBegin() const { return indexes.begin(); }
0125 RegistryIterator getRegistryVectorEnd() const { return indexes.end(); }
0126
0127 void setData(const uint16_t& strip, const float& lTh, const float& hTh, Container& vthr);
0128 void setData(const uint16_t& strip, const float& lTh, const float& hTh, const float& cTh, Container& vthr);
0129 SiStripThreshold::Data getData(const uint16_t& strip, const Range& range) const;
0130
0131 void allThresholds(std::vector<float>& lowThs, std::vector<float>& highThs, const Range& range) const;
0132
0133
0134 void printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
0135
0136 void printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
0137
0138 private:
0139 Container::iterator compact(Container& input);
0140 void addToStat(float value, uint16_t& range, float& sum, float& sum2, float& min, float& max) const;
0141
0142 private:
0143 Container v_threshold;
0144 Registry indexes;
0145
0146 COND_SERIALIZABLE;
0147 };
0148
0149 #endif