Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:37:44

0001 #ifndef RECOLOCALTRACKER_SISTRIPZEROSUPPRESSION_SISTRIPZEROSUPPRESSOR_H
0002 #define RECOLOCALTRACKER_SISTRIPZEROSUPPRESSION_SISTRIPZEROSUPPRESSOR_H
0003 
0004 #include "DataFormats/Common/interface/DetSetVector.h"
0005 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
0006 #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 #include "FWCore/Framework/interface/ESWatcher.h"
0011 #include "FWCore/Framework/interface/ConsumesCollector.h"
0012 
0013 #include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h"
0014 #include "CondFormats/DataRecord/interface/SiStripThresholdRcd.h"
0015 
0016 #include <vector>
0017 class SiStripNoises;
0018 class SiStripThreshold;
0019 
0020 class SiStripFedZeroSuppression {
0021   friend class SiStripRawProcessingFactory;
0022 
0023 public:
0024   SiStripFedZeroSuppression(uint16_t fedalgo,
0025                             edm::ConsumesCollector* iC = nullptr,
0026                             bool trunc = true,
0027                             bool trunc10bits = false)
0028       : noiseToken_{iC ? decltype(noiseToken_){iC->esConsumes<SiStripNoises, SiStripNoisesRcd>()}
0029                        : decltype(noiseToken_){}},
0030         thresholdToken_{iC ? decltype(thresholdToken_){iC->esConsumes<SiStripThreshold, SiStripThresholdRcd>()}
0031                            : decltype(thresholdToken_){}},
0032         theFEDalgorithm(fedalgo),
0033         doTruncate(trunc),
0034         doTruncate10bits(trunc10bits) {}
0035   ~SiStripFedZeroSuppression() {}
0036   void init(const edm::EventSetup& es);
0037   void suppress(const std::vector<SiStripDigi>& in,
0038                 std::vector<SiStripDigi>& selectedSignal,
0039                 uint32_t detId,
0040                 const SiStripNoises&,
0041                 const SiStripThreshold&);
0042   void suppress(const std::vector<SiStripDigi>& in, std::vector<SiStripDigi>& selectedSignal, uint32_t detId);
0043   void suppress(const edm::DetSet<SiStripRawDigi>& in, edm::DetSet<SiStripDigi>& out);
0044   void suppress(const std::vector<int16_t>& in, uint16_t firstAPV, edm::DetSet<SiStripDigi>& out);
0045 
0046   uint16_t truncate(int16_t adc) const {
0047     if (adc > 253 && doTruncate && !doTruncate10bits)
0048       return ((adc == 1023) ? 255 : 254);
0049     return adc;
0050   };
0051 
0052 private:
0053   edm::ESGetToken<SiStripNoises, SiStripNoisesRcd> noiseToken_;
0054   edm::ESGetToken<SiStripThreshold, SiStripThresholdRcd> thresholdToken_;
0055   const SiStripNoises* noise_;
0056   const SiStripThreshold* threshold_;
0057   edm::ESWatcher<SiStripNoisesRcd> noiseWatcher_;
0058   edm::ESWatcher<SiStripThresholdRcd> thresholdWatcher_;
0059 
0060   uint16_t theFEDalgorithm;
0061   bool isAValidDigi();
0062 
0063   bool doTruncate;
0064   bool doTruncate10bits;
0065   int16_t theFEDlowThresh;
0066   int16_t theFEDhighThresh;
0067 
0068   int16_t adc;
0069   int16_t adcPrev;
0070   int16_t adcNext;
0071   int16_t adcMaxNeigh;
0072   int16_t adcPrev2;
0073   int16_t adcNext2;
0074 
0075   int16_t thePrevFEDlowThresh;
0076   int16_t thePrevFEDhighThresh;
0077   int16_t theNextFEDlowThresh;
0078   int16_t theNextFEDhighThresh;
0079 
0080   int16_t theNeighFEDlowThresh;
0081   int16_t theNeighFEDhighThresh;
0082 
0083   int16_t thePrev2FEDlowThresh;
0084   int16_t theNext2FEDlowThresh;
0085 
0086   // working caches
0087   std::vector<int16_t> highThr_, lowThr_;    // thresholds in adc counts
0088   std::vector<float> highThrSN_, lowThrSN_;  // thresholds as S/N
0089   std::vector<float> noises_;
0090 
0091   void fillThresholds_(const uint32_t detID, size_t size);
0092 };
0093 #endif