File indexing completed on 2024-09-07 04:37:39
0001 #ifndef CSCRecHitD_CSCPedestalChoice_h
0002 #define CSCRecHitD_CSCPedestalChoice_h
0003
0004
0005
0006
0007
0008
0009
0010 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0011 #include "RecoLocalMuon/CSCRecHitD/src/CSCRecoConditions.h"
0012 #include <vector>
0013
0014 class CSCPedestalChoice {
0015 public:
0016 CSCPedestalChoice() : defaultPed(0.) {}
0017 virtual ~CSCPedestalChoice() {}
0018
0019 float getDefault() const { return defaultPed; }
0020
0021 void setDefault(float ped) { defaultPed = ped; }
0022
0023
0024
0025
0026
0027 virtual float pedestal(const std::vector<float>& sca,
0028 const CSCRecoConditions* cond = nullptr,
0029 const CSCDetId id = 0,
0030 int ichan = 0) = 0;
0031
0032 private:
0033 float defaultPed;
0034 };
0035
0036
0037
0038
0039
0040
0041
0042
0043 class CSCDynamicPedestal2 : public CSCPedestalChoice {
0044 public:
0045 CSCDynamicPedestal2() {}
0046 ~CSCDynamicPedestal2() override {}
0047 float pedestal(const std::vector<float>& sca, const CSCRecoConditions*, const CSCDetId, int) override {
0048 float ped = getDefault();
0049 if (!sca.empty()) {
0050 ped = (sca[0] + sca[1]) / 2.;
0051 }
0052 return ped;
0053 }
0054 };
0055
0056
0057
0058
0059
0060
0061
0062
0063 class CSCDynamicPedestal1 : public CSCPedestalChoice {
0064 public:
0065 CSCDynamicPedestal1() {}
0066 ~CSCDynamicPedestal1() override {}
0067 float pedestal(const std::vector<float>& sca, const CSCRecoConditions*, const CSCDetId, int) override {
0068 float ped = getDefault();
0069 if (!sca.empty()) {
0070 ped = sca[0];
0071 }
0072 return ped;
0073 }
0074 };
0075
0076
0077
0078
0079
0080
0081
0082
0083 class CSCStaticPedestal : public CSCPedestalChoice {
0084 public:
0085 CSCStaticPedestal() {}
0086 ~CSCStaticPedestal() override {}
0087 float pedestal(const std::vector<float>& sca, const CSCRecoConditions* cond, const CSCDetId id, int ichan) override {
0088 float ped = cond->pedestal(id, ichan);
0089 return ped;
0090 }
0091 };
0092
0093
0094
0095
0096
0097
0098
0099
0100 class CSCSubtractPedestal {
0101 public:
0102 CSCSubtractPedestal(float ped) : ped_(ped) {}
0103 void operator()(float& elem) const { elem -= ped_; }
0104 void operator()(int& elem) const {
0105 elem -= static_cast<int>(ped_);
0106 }
0107
0108 private:
0109 float ped_;
0110 };
0111
0112 #endif