Go to the documentation of this file.00001 #ifndef RECOLOCALTRACKER_SISTRIPZEROSUPPRESSION_SISTRIPAPVRESTORER_H
00002 #define RECOLOCALTRACKER_SISTRIPZEROSUPPRESSION_SISTRIPAPVRESTORER_H
00003
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "FWCore/Framework/interface/EventSetup.h"
00006 #include "DataFormats/Common/interface/Handle.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
00010 #include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
00011 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
00012 #include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h"
00013 #include "CondFormats/DataRecord/interface/SiStripPedestalsRcd.h"
00014 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
00015 #include "DataFormats/Common/interface/DetSet.h"
00016 #include "DataFormats/Common/interface/DetSetVector.h"
00017 #include "DataFormats/DetId/interface/DetId.h"
00018 #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
00019 #include "DataFormats/SiStripDigi/interface/SiStripProcessedRawDigi.h"
00020 #include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripCommonModeNoiseSubtractor.h"
00021
00022 #include <vector>
00023 #include <stdint.h>
00024
00025 typedef std::map<uint16_t, int16_t> DigiMap;
00026 typedef std::map<uint16_t, std::vector < int16_t> > RawDigiMap;
00027 typedef std::map<uint16_t, int16_t>::iterator DigiMapIter;
00028 typedef std::map<uint32_t, std::vector<float> > CMMap;
00029
00030
00031 class SiStripAPVRestorer {
00032
00033 friend class SiStripRawProcessingFactory;
00034
00035 public:
00036
00037 virtual ~SiStripAPVRestorer() {};
00038
00039 void init(const edm::EventSetup& es);
00040 int16_t inspect(const uint32_t&, const uint16_t&, std::vector<int16_t>&, const std::vector< std::pair<short,float> >&);
00041 void restore(const uint16_t&, std::vector<int16_t>&);
00042 int16_t InspectAndRestore(const uint32_t&, const uint16_t&, std::vector<int16_t>&, std::vector<int16_t>&, const std::vector< std::pair<short,float> >&);
00043
00044 void LoadMeanCMMap(const edm::Event&);
00045
00046 RawDigiMap& GetBaselineMap(){return BaselineMap_;}
00047
00048 std::map< uint16_t, DigiMap >& GetSmoothedPoints(){return SmoothedMaps_;}
00049 std::vector<bool>& GetAPVFlags();
00050
00051 protected:
00052
00053 SiStripAPVRestorer(const edm::ParameterSet& conf);
00054
00055 private:
00056
00057
00058
00059
00060 template<typename T >int16_t NullInspect(const uint16_t&, std::vector<T>&);
00061 template<typename T >int16_t AbnormalBaselineInspect(const uint16_t&, std::vector<T>&);
00062 template<typename T >int16_t BaselineFollowerInspect(const uint16_t&, std::vector<T>&);
00063 template<typename T >int16_t BaselineAndSaturationInspect(const uint16_t&, std::vector<T>&);
00064
00065 void FlatRestore(const uint16_t&, const uint16_t&, std::vector<int16_t>& );
00066 bool CheckBaseline(const std::vector<int16_t> &) const;
00067 void BaselineFollowerRestore(const uint16_t&, const uint16_t&, const float&, std::vector<int16_t>& );
00068
00069 void BaselineFollower(DigiMap&, std::vector<int16_t>&, const float&);
00070 bool FlatRegionsFinder(const std::vector<int16_t>&, DigiMap&, const uint16_t&);
00071
00072 void BaselineCleaner(const std::vector<int16_t>&, DigiMap&, const uint16_t& );
00073 void Cleaner_MonotonyChecker(DigiMap&);
00074 void Cleaner_HighSlopeChecker(DigiMap&);
00075 void Cleaner_LocalMinimumAdder(const std::vector<int16_t>&, DigiMap&, const uint16_t& );
00076
00077
00078 void CreateCMMapRealPed(const edm::DetSetVector<SiStripRawDigi>& );
00079 void CreateCMMapCMstored(const edm::DetSetVector<SiStripProcessedRawDigi>& );
00080
00081 float pairMedian( std::vector<std::pair<float,float> >&);
00082
00083
00084 edm::ESHandle<SiStripQuality> qualityHandle;
00085 uint32_t quality_cache_id;
00086
00087 edm::ESHandle<SiStripNoises> noiseHandle;
00088 uint32_t noise_cache_id;
00089
00090 edm::ESHandle<SiStripPedestals> pedestalHandle;
00091 uint32_t pedestal_cache_id;
00092
00093 std::vector<std::string> apvFlags_;
00094 std::vector<bool> apvFlagsBool_;
00095 std::vector<bool> apvFlagsBoolOverride_;
00096 std::vector<float> median_;
00097 std::vector<bool> badAPVs_;
00098 std::map<uint16_t, DigiMap> SmoothedMaps_;
00099 RawDigiMap BaselineMap_;
00100
00101
00102 uint32_t detId_;
00103
00104 CMMap MeanCMmap_;
00105 edm::InputTag inputTag_;
00106
00107
00108 bool ForceNoRestore_;
00109 bool SelfSelectRestoreAlgo_;
00110 std::string InspectAlgo_;
00111 std::string RestoreAlgo_;
00112 bool useRealMeanCM_;
00113
00114
00115
00116
00117
00118 double fraction_;
00119 uint32_t deviation_;
00120 double restoreThreshold_;
00121 uint32_t DeltaCMThreshold_;
00122
00123 uint32_t nSigmaNoiseDerTh_;
00124 uint32_t consecThreshold_;
00125 uint32_t hitStripThreshold_;
00126 uint32_t nSmooth_;
00127 uint32_t minStripsToFit_;
00128 uint32_t distortionThreshold_;
00129 double CutToAvoidSignal_;
00130 uint32_t nSaturatedStrip_;
00131 bool ApplyBaselineCleaner_;
00132 int32_t slopeX_;
00133 int32_t slopeY_;
00134 uint32_t CleaningSequence_;
00135 bool ApplyBaselineRejection_;
00136 int32_t MeanCM_;
00137 double filteredBaselineMax_;
00138 double filteredBaselineDerivativeSumSquare_;
00139
00140 };
00141
00142 #endif