File indexing completed on 2024-04-06 12:25:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef RecoJets_FFTJetAlgorithms_gridConverters_h
0012 #define RecoJets_FFTJetAlgorithms_gridConverters_h
0013
0014 #include <cassert>
0015 #include "fftjet/Grid2d.hh"
0016
0017 namespace fftjetcms {
0018 template <typename Numeric>
0019 fftjet::Grid2d<float>* convert_Grid2d_to_float(const fftjet::Grid2d<Numeric>& grid);
0020
0021 template <typename Numeric>
0022 fftjet::Grid2d<double>* convert_Grid2d_to_double(const fftjet::Grid2d<Numeric>& grid);
0023
0024 template <typename F1, typename F2>
0025 void copy_Grid2d_data(fftjet::Grid2d<F2>* to, const fftjet::Grid2d<F1>& from);
0026
0027 template <typename F1, typename F2>
0028 void add_Grid2d_data(fftjet::Grid2d<F2>* to, const fftjet::Grid2d<F1>& from);
0029 }
0030
0031
0032
0033
0034
0035
0036
0037 namespace fftjetcms {
0038 template <typename F1, typename F2>
0039 void copy_Grid2d_data(fftjet::Grid2d<F2>* to, const fftjet::Grid2d<F1>& from) {
0040 assert(to);
0041 assert(from.nEta() == to->nEta());
0042 assert(from.nPhi() == to->nPhi());
0043 const unsigned len = from.nEta() * from.nPhi();
0044 const F1* fromData = from.data();
0045 F2* toData = const_cast<F2*>(to->data());
0046 for (unsigned i = 0; i < len; ++i)
0047 toData[i] = fromData[i];
0048 }
0049
0050 template <typename F1, typename F2>
0051 void add_Grid2d_data(fftjet::Grid2d<F2>* to, const fftjet::Grid2d<F1>& from) {
0052 assert(to);
0053 assert(from.nEta() == to->nEta());
0054 assert(from.nPhi() == to->nPhi());
0055 const unsigned len = from.nEta() * from.nPhi();
0056 const F1* fromData = from.data();
0057 F2* toData = const_cast<F2*>(to->data());
0058 for (unsigned i = 0; i < len; ++i)
0059 toData[i] += fromData[i];
0060 }
0061
0062 template <typename Numeric>
0063 fftjet::Grid2d<float>* convert_Grid2d_to_float(const fftjet::Grid2d<Numeric>& grid) {
0064 fftjet::Grid2d<float>* to = new fftjet::Grid2d<float>(
0065 grid.nEta(), grid.etaMin(), grid.etaMax(), grid.nPhi(), grid.phiBin0Edge(), grid.title());
0066 copy_Grid2d_data(to, grid);
0067 return to;
0068 }
0069
0070 template <typename Numeric>
0071 fftjet::Grid2d<double>* convert_Grid2d_to_double(const fftjet::Grid2d<Numeric>& grid) {
0072 fftjet::Grid2d<double>* to = new fftjet::Grid2d<double>(
0073 grid.nEta(), grid.etaMin(), grid.etaMax(), grid.nPhi(), grid.phiBin0Edge(), grid.title());
0074 copy_Grid2d_data(to, grid);
0075 return to;
0076 }
0077 }
0078
0079 #endif