Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:14

0001 #ifndef CondFormats_HcalObjects_OOTPileupCorrDataFcn_h_
0002 #define CondFormats_HcalObjects_OOTPileupCorrDataFcn_h_
0003 
0004 #include "CondFormats/HcalObjects/interface/PiecewiseScalingPolynomial.h"
0005 #include "CondFormats/HcalObjects/interface/ScalingExponential.h"
0006 
0007 class OOTPileupCorrDataFcn {
0008 public:
0009   inline OOTPileupCorrDataFcn() {}
0010 
0011   inline OOTPileupCorrDataFcn(const PiecewiseScalingPolynomial& a1,
0012                               const PiecewiseScalingPolynomial& a2,
0013                               const PiecewiseScalingPolynomial& a3,
0014                               const ScalingExponential& a_1)
0015       : a1_(a1), a2_(a2), a3_(a3), a_1_(a_1) {}
0016 
0017   inline bool operator==(const OOTPileupCorrDataFcn& r) const {
0018     return a1_ == r.a1_ && a2_ == r.a2_ && a3_ == r.a3_ && a_1_ == r.a_1_;
0019   }
0020 
0021   inline bool operator!=(const OOTPileupCorrDataFcn& r) const { return !(*this == r); }
0022 
0023   inline void pucorrection(double* ts, const int tsTrig) const {
0024     // TS4 correction with functions a1(x) and a2(x)
0025     double ts20 = ts[tsTrig - 2];
0026     double ts30 = ts[tsTrig - 1] - a_1_(ts[tsTrig]);  // ts[3] correction with a_1(x)
0027     double ts21 = ts20 > 0 ? a2_(ts20) : 0;
0028     double ts22 = ts20 > 0 ? a1_(ts20) : 0;
0029     double ts321 = ts30 - ts22 > 0 ? a1_(ts30 - ts22) : 0;
0030     ts[tsTrig] -= (ts321 + ts21);  // ts[4] after pu correction
0031 
0032     // ts5 estimation from ts4
0033     ts[tsTrig + 1] = a1_(ts[tsTrig]);
0034   }
0035 
0036   // Access the correction functions
0037   inline const PiecewiseScalingPolynomial& getA1() const { return a1_; }
0038   inline const PiecewiseScalingPolynomial& getA2() const { return a2_; }
0039   inline const PiecewiseScalingPolynomial& getA3() const { return a3_; }
0040   inline const ScalingExponential& getA_1() const { return a_1_; }
0041 
0042 private:
0043   PiecewiseScalingPolynomial a1_, a2_, a3_;
0044   ScalingExponential a_1_;
0045 
0046   friend class boost::serialization::access;
0047 
0048   template <class Archive>
0049   inline void serialize(Archive& ar, unsigned /* version */) {
0050     ar& a1_& a2_& a3_& a_1_;
0051   }
0052 };
0053 
0054 BOOST_CLASS_VERSION(OOTPileupCorrDataFcn, 1)
0055 
0056 #endif  // CondFormats_HcalObjects_OOTPileupCorrDataFcn_h_