File indexing completed on 2024-04-06 12:19:17
0001 #ifndef JetMETCorrections_FFTJetObjects_AbsFFTJetScaleCalculator_h
0002 #define JetMETCorrections_FFTJetObjects_AbsFFTJetScaleCalculator_h
0003
0004 #include "JetMETCorrections/InterpolationTables/interface/AbsMultivariateFunctor.h"
0005
0006 #include <memory>
0007 #include <vector>
0008
0009 template <class Jet, class Adjustable>
0010 class AbsFFTJetScaleCalculator {
0011 public:
0012 typedef Jet jet_type;
0013 typedef Adjustable adjustable_type;
0014
0015 inline explicit AbsFFTJetScaleCalculator(std::shared_ptr<npstat::AbsMultivariateFunctor> f)
0016 : functor(f), buffer_(f->minDim()) {}
0017 AbsFFTJetScaleCalculator() = delete;
0018
0019 inline virtual ~AbsFFTJetScaleCalculator() {}
0020
0021 inline double scale(const Jet& jet, const Adjustable& current) const {
0022 const unsigned dim = buffer_.size();
0023 double* buf = dim ? &buffer_[0] : static_cast<double*>(nullptr);
0024 this->map(jet, current, buf, dim);
0025 return (*functor)(buf, dim);
0026 }
0027
0028 private:
0029 virtual void map(const Jet& jet, const Adjustable& current, double* buf, unsigned dim) const = 0;
0030
0031 std::shared_ptr<npstat::AbsMultivariateFunctor> functor;
0032 mutable std::vector<double> buffer_;
0033 };
0034
0035 #endif