CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/JetMETCorrections/FFTJetObjects/interface/FFTJetAdjusters.h

Go to the documentation of this file.
00001 #include <cassert>
00002 
00003 #include "JetMETCorrections/FFTJetObjects/interface/AbsFFTJetAdjuster.h"
00004 #include "FWCore/Utilities/interface/Exception.h"
00005 
00006 template<class MyJet, class Adjustable>
00007 struct FFTSimpleScalingAdjuster : public AbsFFTJetAdjuster<MyJet, Adjustable>
00008 {
00009     inline virtual ~FFTSimpleScalingAdjuster() {}
00010 
00011     virtual void adjust(const MyJet& /* jet */, const Adjustable& in,
00012                         const double* factors, const unsigned lenFactors,
00013                         Adjustable* out) const
00014     {
00015         if (lenFactors != 1U)
00016             throw cms::Exception("FFTJetBadConfig")
00017                 << "In FFTSimpleScalingAdjuster::adjust: wrong number of "
00018                 << "scales (expected 1, got " << lenFactors << ")\n";
00019         assert(factors);
00020         assert(out);
00021         *out = in;
00022         *out *= factors[0];
00023     }
00024 };
00025 
00026 template<class MyJet, class Adjustable>
00027 struct FFTUncertaintyAdjuster : public AbsFFTJetAdjuster<MyJet, Adjustable>
00028 {
00029     inline virtual ~FFTUncertaintyAdjuster() {}
00030 
00031     virtual void adjust(const MyJet& /* jet */, const Adjustable& in,
00032                         const double* factors, const unsigned lenFactors,
00033                         Adjustable* out) const
00034     {
00035         if (lenFactors != 1U)
00036             throw cms::Exception("FFTJetBadConfig")
00037                 << "In FFTUncertaintyAdjuster::adjust: wrong number of "
00038                 << "scales (expected 1, got " << lenFactors << ")\n";
00039         assert(factors);
00040         assert(out);
00041         *out = in;
00042         const double s = factors[0];
00043         out->setVariance(in.variance() + s*s);
00044     }
00045 };
00046 
00047 template<class MyJet, class Adjustable>
00048 struct FFTScalingAdjusterWithUncertainty : 
00049     public AbsFFTJetAdjuster<MyJet, Adjustable>
00050 {
00051     inline virtual ~FFTScalingAdjusterWithUncertainty() {}
00052 
00053     virtual void adjust(const MyJet& /* jet */, const Adjustable& in,
00054                         const double* factors, const unsigned lenFactors,
00055                         Adjustable* out) const
00056     {
00057         if (lenFactors != 2U)
00058             throw cms::Exception("FFTJetBadConfig")
00059                 << "In FFTScalingAdjusterWithUncertainty::adjust: wrong "
00060                 << "number of scales (expected 2, got " << lenFactors << ")\n";
00061         assert(factors);
00062         assert(out);
00063         *out = in;
00064         *out *= factors[0];
00065         const double s = factors[1];
00066         out->setVariance(in.variance() + s*s);
00067     }
00068 };