Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef RecoLocalCalo_HcalRecAlgos_PulseShapeFunctor_h
0002 #define RecoLocalCalo_HcalRecAlgos_PulseShapeFunctor_h
0003 
0004 #include "CalibCalorimetry/HcalAlgos/interface/HcalPulseShapes.h"
0005 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalConstants.h"
0006 
0007 namespace FitterFuncs {
0008 
0009   class PulseShapeFunctor {
0010   public:
0011     PulseShapeFunctor(const HcalPulseShapes::Shape &pulse,
0012                       bool iPedestalConstraint,
0013                       bool iTimeConstraint,
0014                       bool iAddPulseJitter,
0015                       double iPulseJitter,
0016                       double iTimeMean,
0017                       double iPedMean,
0018                       unsigned int nSamplesToFit);
0019     ~PulseShapeFunctor();
0020 
0021     void EvalPulse(const float *pars);
0022     double EvalPulseM2(const double *pars, const unsigned nPar);
0023 
0024     void setDefaultcntNANinfit() { cntNANinfit = 0; }
0025     int getcntNANinfit() { return cntNANinfit; }
0026 
0027     void setpsFitx(double *x) {
0028       for (int i = 0; i < hcal::constants::maxSamples; ++i)
0029         psFit_x[i] = x[i];
0030     }
0031     void setpsFity(double *y) {
0032       for (int i = 0; i < hcal::constants::maxSamples; ++i)
0033         psFit_y[i] = y[i];
0034     }
0035     void setpsFiterry(double *erry) {
0036       for (int i = 0; i < hcal::constants::maxSamples; ++i)
0037         psFit_erry[i] = erry[i];
0038     }
0039     void setpsFiterry2(double *erry2) {
0040       for (int i = 0; i < hcal::constants::maxSamples; ++i)
0041         psFit_erry2[i] = erry2[i];
0042     }
0043     void setpsFitslew(double *slew) {
0044       for (int i = 0; i < hcal::constants::maxSamples; ++i) {
0045         psFit_slew[i] = slew[i];
0046       }
0047     }
0048     double getSiPMDarkCurrent(double darkCurrent, double fcByPE, double lambda);
0049     void setinvertpedSig2(double x) { invertpedSig2_ = x; }
0050     void setinverttimeSig2(double x) { inverttimeSig2_ = x; }
0051 
0052     inline void singlePulseShapeFuncMahi(const float *x) { return EvalPulse(x); }
0053     inline double singlePulseShapeFunc(const double *x) { return EvalPulseM2(x, 3); }
0054     inline double doublePulseShapeFunc(const double *x) { return EvalPulseM2(x, 5); }
0055     inline double triplePulseShapeFunc(const double *x) { return EvalPulseM2(x, 7); }
0056 
0057     void getPulseShape(std::array<double, hcal::constants::maxSamples> &fillPulseShape) {
0058       fillPulseShape = pulse_shape_;
0059     }
0060 
0061     // getters
0062     inline std::vector<float> const &acc25nsVec() const { return acc25nsVec_; }
0063     inline std::vector<float> const &diff25nsItvlVec() const { return diff25nsItvlVec_; }
0064     inline std::vector<float> const &accVarLenIdxZEROVec() const { return accVarLenIdxZEROVec_; }
0065     inline std::vector<float> const &diffVarItvlIdxZEROVec() const { return diffVarItvlIdxZEROVec_; }
0066     inline std::vector<float> const &accVarLenIdxMinusOneVec() const { return accVarLenIdxMinusOneVec_; }
0067     inline std::vector<float> const &diffVarItvlIdxMinusOneVec() const { return diffVarItvlIdxMinusOneVec_; }
0068 
0069   private:
0070     std::array<float, hcal::constants::maxPSshapeBin> pulse_hist;
0071 
0072     int cntNANinfit;
0073     std::vector<float> acc25nsVec_, diff25nsItvlVec_;
0074     std::vector<float> accVarLenIdxZEROVec_, diffVarItvlIdxZEROVec_;
0075     std::vector<float> accVarLenIdxMinusOneVec_, diffVarItvlIdxMinusOneVec_;
0076 
0077     void funcShape(std::array<double, hcal::constants::maxSamples> &ntmpbin,
0078                    const double pulseTime,
0079                    const double pulseHeight,
0080                    const double slew,
0081                    bool scalePulse);
0082     double psFit_x[hcal::constants::maxSamples], psFit_y[hcal::constants::maxSamples],
0083         psFit_erry[hcal::constants::maxSamples], psFit_erry2[hcal::constants::maxSamples],
0084         psFit_slew[hcal::constants::maxSamples];
0085 
0086     unsigned nSamplesToFit_;
0087     bool pedestalConstraint_;
0088     bool timeConstraint_;
0089     bool addPulseJitter_;
0090     bool unConstrainedFit_;
0091     double pulseJitter_;
0092     double timeMean_;
0093     double timeSig_;
0094     double pedMean_;
0095     double timeShift_;
0096 
0097     double inverttimeSig2_;
0098     double invertpedSig2_;
0099     std::array<double, hcal::constants::maxSamples> pulse_shape_;
0100     std::array<double, hcal::constants::maxSamples> pulse_shape_sum_;
0101   };
0102 
0103 }  // namespace FitterFuncs
0104 
0105 #endif  // PulseShapeFunctor_h