Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:17

0001 #include <cassert>
0002 
0003 #include "JetMETCorrections/FFTJetObjects/interface/AbsFFTJetAdjuster.h"
0004 #include "FWCore/Utilities/interface/Exception.h"
0005 
0006 template <class MyJet, class Adjustable>
0007 struct FFTSimpleScalingAdjuster : public AbsFFTJetAdjuster<MyJet, Adjustable> {
0008   inline ~FFTSimpleScalingAdjuster() override {}
0009 
0010   void adjust(const MyJet& /* jet */,
0011               const Adjustable& in,
0012               const double* factors,
0013               const unsigned lenFactors,
0014               Adjustable* out) const override {
0015     if (lenFactors != 1U)
0016       throw cms::Exception("FFTJetBadConfig") << "In FFTSimpleScalingAdjuster::adjust: wrong number of "
0017                                               << "scales (expected 1, got " << lenFactors << ")\n";
0018     assert(factors);
0019     assert(out);
0020     *out = in;
0021     *out *= factors[0];
0022   }
0023 };
0024 
0025 template <class MyJet, class Adjustable>
0026 struct FFTUncertaintyAdjuster : public AbsFFTJetAdjuster<MyJet, Adjustable> {
0027   inline ~FFTUncertaintyAdjuster() override {}
0028 
0029   void adjust(const MyJet& /* jet */,
0030               const Adjustable& in,
0031               const double* factors,
0032               const unsigned lenFactors,
0033               Adjustable* out) const override {
0034     if (lenFactors != 1U)
0035       throw cms::Exception("FFTJetBadConfig") << "In FFTUncertaintyAdjuster::adjust: wrong number of "
0036                                               << "scales (expected 1, got " << lenFactors << ")\n";
0037     assert(factors);
0038     assert(out);
0039     *out = in;
0040     const double s = factors[0];
0041     out->setVariance(in.variance() + s * s);
0042   }
0043 };
0044 
0045 template <class MyJet, class Adjustable>
0046 struct FFTScalingAdjusterWithUncertainty : public AbsFFTJetAdjuster<MyJet, Adjustable> {
0047   inline ~FFTScalingAdjusterWithUncertainty() override {}
0048 
0049   void adjust(const MyJet& /* jet */,
0050               const Adjustable& in,
0051               const double* factors,
0052               const unsigned lenFactors,
0053               Adjustable* out) const override {
0054     if (lenFactors != 2U)
0055       throw cms::Exception("FFTJetBadConfig") << "In FFTScalingAdjusterWithUncertainty::adjust: wrong "
0056                                               << "number of scales (expected 2, got " << lenFactors << ")\n";
0057     assert(factors);
0058     assert(out);
0059     *out = in;
0060     *out *= factors[0];
0061     const double s = factors[1];
0062     out->setVariance(in.variance() + s * s);
0063   }
0064 };