Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:58

0001 #ifndef CSCRecHitD_CSCPedestalChoice_h
0002 #define CSCRecHitD_CSCPedestalChoice_h
0003 
0004 /**
0005  * \class CSCPedestalChoice
0006  *
0007  * ABC for concrete classes which estimate SCA pedestal in alternative ways
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   /// Return default pedestal (typically zero)
0019   float getDefault() const { return defaultPed; }
0020   /// Allow reseting of default pedestal (not currently used)
0021   void setDefault(float ped) { defaultPed = ped; }
0022   /** 
0023     * Return appropriate pedestal for supplied SCA vector.
0024     * If using conditions data then must also supply pointer to CSCRecoConditions
0025     * and CSCDetId + channel
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  * \class CSCDynamicPedestal2
0038  *
0039  * Concrete CSCPedestalChoice... 
0040  * Pedestal is dynamic, averages first two SCA time bins
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  * \class CSCDynamicPedestal1
0058  *
0059  * Concrete CSCPedestalChoice... 
0060  * Pedestal is dynamic, take first SCA time bin
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  * \class CSCStaticPedestal
0078  *
0079  * Concrete CSCPedestalChoice... 
0080  * Pedestal is static, taken from conditions data
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  * \class CSCSubtractPedestal
0095  *
0096  * A class to be used as a function in a for_each algorithm
0097  * to subtract the pedestal. That is set as the ctor arg.
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_);  // not strictly correct but OK for the typical large pedestals
0106   }
0107 
0108 private:
0109   float ped_;
0110 };
0111 
0112 #endif