CMS 3D CMS Logo

SiStripAPVRestorer.h
Go to the documentation of this file.
1 #ifndef RECOLOCALTRACKER_SISTRIPZEROSUPPRESSION_SISTRIPAPVRESTORER_H
2 #define RECOLOCALTRACKER_SISTRIPZEROSUPPRESSION_SISTRIPAPVRESTORER_H
3 
21 
22 #include <vector>
23 #include <cstdint>
24 
27 protected:
29 public:
30  virtual ~SiStripAPVRestorer() {};
31 
32  using digi_t = int16_t;
33  using digivector_t = std::vector<digi_t>;
34  using digimap_t = std::map<uint16_t, digi_t>;
35  using medians_t = std::vector<std::pair<short,float>>;
36  using baselinemap_t = std::map<uint16_t, digivector_t>;
37 
38  void init(const edm::EventSetup& es);
39 
40  uint16_t inspect(uint32_t detId, uint16_t firstAPV, const digivector_t& digis, const medians_t& vmedians);
41  void restore(uint16_t firstAPV, digivector_t& digis);
42 
43  uint16_t inspectAndRestore(uint32_t detId, uint16_t firstAPV, const digivector_t& rawDigisPedSubtracted, digivector_t& processedRawDigi, const medians_t& vmedians);
44 
45  void loadMeanCMMap(const edm::Event&);
46 
47  const baselinemap_t& getBaselineMap() const { return baselineMap_; }
48  const std::map<uint16_t, digimap_t>& getSmoothedPoints() const { return smoothedMaps_; }
49  const std::vector<bool>& getAPVFlags() const { return apvFlagsBool_; }
50 
51 private:
52  using CMMap = std::map<uint32_t, std::vector<float>>; //detId, Vector of MeanCM per detId
53  constexpr static uint16_t nTotStripsPerAPV = 128;
54 
55  uint16_t nullInspect(uint16_t firstAPV, const digivector_t& digis);
56  uint16_t abnormalBaselineInspect(uint16_t firstAPV, const digivector_t& digis);
57  uint16_t baselineFollowerInspect(uint16_t firstAPV, const digivector_t& digis);
58  uint16_t baselineAndSaturationInspect(uint16_t firstAPV, const digivector_t& digis);
59  uint16_t forceRestoreInspect(uint16_t firstAPV, const digivector_t& digis);
60  uint16_t hybridFormatInspect(uint16_t firstAPV, const digivector_t& digis);
61  uint16_t hybridEmulationInspect(uint16_t firstAPV, const digivector_t& digis);
62 
63  void flatRestore(uint16_t apvN, uint16_t firstAPV, digivector_t& digis);
64  bool checkBaseline(const std::vector<int16_t> & baseline) const;
65  void baselineFollowerRestore(uint16_t apvN, uint16_t firstAPV, float median, digivector_t& digis);
66  void derivativeFollowerRestore(uint16_t apvN, uint16_t firstAPV, digivector_t& digis);
67 
68  void baselineFollower(const digimap_t&, digivector_t& baseline, float median);
69  bool flatRegionsFinder(const digivector_t& adcs, digimap_t& smoothedpoints, uint16_t apvN);
70 
71  void baselineCleaner(const digivector_t& adcs, digimap_t& smoothedpoints, uint16_t apvN);
72  void cleaner_MonotonyChecker(digimap_t& smoothedpoints);
73  void cleaner_HighSlopeChecker(digimap_t& smoothedpoints);
74  void cleaner_LocalMinimumAdder(const digivector_t& adcs, digimap_t& smoothedpoints, uint16_t apvN);
75 
78 
79 private: // members
84 
85  // event state
87  // state
88  uint32_t detId_;
89  std::vector<std::string> apvFlags_;
90  std::vector<bool> apvFlagsBool_;
91  std::vector<bool> apvFlagsBoolOverride_;
92  std::vector<float> median_;
93  std::vector<bool> badAPVs_;
94  std::map<uint16_t, digimap_t> smoothedMaps_;
96 
97  //--------------------------------------------------
98  // Configurable Parameters of Algorithm
99  //--------------------------------------------------
104  int32_t meanCM_;
105  uint32_t deltaCMThreshold_; // for BaselineFollower inspect
106  double fraction_; // fraction of strips deviating from nominal baseline
107  uint32_t deviation_; // ADC value of deviation from nominal baseline
108  double restoreThreshold_; // for Null inspect (fraction of adc=0 channels)
109  uint32_t nSaturatedStrip_; // for BaselineAndSaturation inspect
110  uint32_t nSigmaNoiseDerTh_; // threshold for rejecting hits strips
111  uint32_t consecThreshold_; // minimum length of flat region
112  uint32_t nSmooth_; // for smoothing and local minimum determination (odd number)
113  uint32_t distortionThreshold_; // (max-min) of flat regions to trigger baseline follower
116  int32_t slopeX_;
117  int32_t slopeY_;
118  uint32_t hitStripThreshold_; // height above median when strip is definitely a hit
119  uint32_t minStripsToFit_; // minimum strips to try spline algo (otherwise default to median)
127 };
128 #endif
bool checkBaseline(const std::vector< int16_t > &baseline) const
void init(const edm::EventSetup &es)
const baselinemap_t & getBaselineMap() const
void baselineFollowerRestore(uint16_t apvN, uint16_t firstAPV, float median, digivector_t &digis)
uint16_t baselineAndSaturationInspect(uint16_t firstAPV, const digivector_t &digis)
std::map< uint32_t, std::vector< float >> CMMap
std::map< uint16_t, digimap_t > smoothedMaps_
uint16_t baselineFollowerInspect(uint16_t firstAPV, const digivector_t &digis)
double filteredBaselineDerivativeSumSquare_
edm::ESHandle< SiStripPedestals > pedestalHandle
void flatRestore(uint16_t apvN, uint16_t firstAPV, digivector_t &digis)
#define constexpr
static std::string const input
Definition: EdmProvDump.cc:45
void baselineFollower(const digimap_t &, digivector_t &baseline, float median)
const std::vector< bool > & getAPVFlags() const
void loadMeanCMMap(const edm::Event &)
uint16_t hybridEmulationInspect(uint16_t firstAPV, const digivector_t &digis)
std::vector< std::string > apvFlags_
baselinemap_t baselineMap_
edm::ESHandle< SiStripQuality > qualityHandle
std::map< uint16_t, digivector_t > baselinemap_t
std::vector< std::pair< short, float >> medians_t
void baselineCleaner(const digivector_t &adcs, digimap_t &smoothedpoints, uint16_t apvN)
const std::map< uint16_t, digimap_t > & getSmoothedPoints() const
void cleaner_LocalMinimumAdder(const digivector_t &adcs, digimap_t &smoothedpoints, uint16_t apvN)
void cleaner_HighSlopeChecker(digimap_t &smoothedpoints)
static uint16_t nTotStripsPerAPV
bool flatRegionsFinder(const digivector_t &adcs, digimap_t &smoothedpoints, uint16_t apvN)
void cleaner_MonotonyChecker(digimap_t &smoothedpoints)
uint16_t inspectAndRestore(uint32_t detId, uint16_t firstAPV, const digivector_t &rawDigisPedSubtracted, digivector_t &processedRawDigi, const medians_t &vmedians)
void derivativeFollowerRestore(uint16_t apvN, uint16_t firstAPV, digivector_t &digis)
void createCMMapCMstored(const edm::DetSetVector< SiStripProcessedRawDigi > &input)
uint16_t hybridFormatInspect(uint16_t firstAPV, const digivector_t &digis)
std::vector< bool > apvFlagsBoolOverride_
std::map< uint16_t, digi_t > digimap_t
edm::ESHandle< SiStripNoises > noiseHandle
uint16_t nullInspect(uint16_t firstAPV, const digivector_t &digis)
std::vector< bool > badAPVs_
std::vector< bool > apvFlagsBool_
uint16_t abnormalBaselineInspect(uint16_t firstAPV, const digivector_t &digis)
std::vector< digi_t > digivector_t
std::vector< float > median_
void restore(uint16_t firstAPV, digivector_t &digis)
uint16_t forceRestoreInspect(uint16_t firstAPV, const digivector_t &digis)
void createCMMapRealPed(const edm::DetSetVector< SiStripRawDigi > &input)
SiStripAPVRestorer(const edm::ParameterSet &conf)
uint16_t inspect(uint32_t detId, uint16_t firstAPV, const digivector_t &digis, const medians_t &vmedians)