Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:27

0001 #ifndef JetMETCorrections_FFTJetObjects_FFTJetScaleCalculators_h
0002 #define JetMETCorrections_FFTJetObjects_FFTJetScaleCalculators_h
0003 
0004 #include <cassert>
0005 #include <cmath>
0006 
0007 #include "JetMETCorrections/FFTJetObjects/interface/AbsFFTSpecificScaleCalculator.h"
0008 #include "JetMETCorrections/FFTJetObjects/interface/AbsFFTJetScaleCalculator.h"
0009 #include "FWCore/Utilities/interface/Exception.h"
0010 
0011 template <class MyJet, class Adjustable>
0012 class FFTEtaLogPtConeRadiusMapper : public AbsFFTJetScaleCalculator<MyJet, Adjustable> {
0013 public:
0014   inline explicit FFTEtaLogPtConeRadiusMapper(std::shared_ptr<npstat::AbsMultivariateFunctor> f)
0015       : AbsFFTJetScaleCalculator<MyJet, Adjustable>(f) {}
0016 
0017 private:
0018   inline void map(const MyJet& jet, const Adjustable& current, double* buf, const unsigned dim) const override {
0019     assert(buf);
0020     if (dim != 3)
0021       throw cms::Exception("FFTJetBadConfig") << "In FFTEtaLogPtConeRadiusMapper::map: "
0022                                               << "invalid table dimensionality: " << dim << std::endl;
0023     buf[0] = current.vec().eta();
0024     buf[1] = log(current.vec().pt());
0025     buf[2] = jet.getFFTSpecific().f_recoScale();
0026   }
0027 };
0028 
0029 template <class MyJet, class Adjustable>
0030 class FFTSpecificScaleCalculator : public AbsFFTJetScaleCalculator<MyJet, Adjustable> {
0031 public:
0032   //
0033   // This class will assume the ownership of the
0034   // AbsFFTSpecificScaleCalculator object provided
0035   // in the constructor
0036   //
0037   inline FFTSpecificScaleCalculator(std::shared_ptr<npstat::AbsMultivariateFunctor> f,
0038                                     const AbsFFTSpecificScaleCalculator* p)
0039       : AbsFFTJetScaleCalculator<MyJet, Adjustable>(f), calc_(p) {
0040     assert(p);
0041   }
0042 
0043   inline ~FFTSpecificScaleCalculator() override { delete calc_; }
0044 
0045 private:
0046   inline void map(const MyJet& jet, const Adjustable& current, double* buf, const unsigned dim) const override {
0047     return calc_->mapFFTJet(jet, jet.getFFTSpecific(), current.vec(), buf, dim);
0048   }
0049 
0050   const AbsFFTSpecificScaleCalculator* calc_;
0051 };
0052 
0053 #endif  // JetMETCorrections_FFTJetObjects_FFTJetScaleCalculators_h