test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ScaleCalculators.h
Go to the documentation of this file.
1 #ifndef RecoJets_FFTJetAlgorithms_ScaleCalculators_h
2 #define RecoJets_FFTJetAlgorithms_ScaleCalculators_h
3 
4 #include <vector>
5 #include <algorithm>
6 
7 #include "fftjet/SimpleFunctors.hh"
8 #include "fftjet/RecombinedJet.hh"
9 
11 
12 namespace fftjetcms {
13  // Return a predefined constant
14  template <typename Arg1>
15  class ConstDouble : public fftjet::Functor1<double,Arg1>
16  {
17  public:
18  inline ConstDouble(const double value) : c_(value) {}
19  inline double operator()(const Arg1&) const {return c_;}
20 
21  private:
22  ConstDouble();
23  double c_;
24  };
25 
26 
27  // Multiplication of a constant by the "scale()" member
28  template <class T>
29  class ProportionalToScale : public fftjet::Functor1<double,T>
30  {
31  public:
32  inline ProportionalToScale(const double value) : c_(value) {}
33  inline double operator()(const T& r) const {return r.scale()*c_;}
34 
35  private:
37  double c_;
38  };
39 
40 
41  // Multiplication by a constant
42  template <class T>
43  class MultiplyByConst : public fftjet::Functor1<double,T>
44  {
45  public:
46  inline MultiplyByConst(const double factor,
47  const fftjet::Functor1<double,T>* f,
48  const bool takeOwnership=false)
49  : c_(factor), func_(f), ownsPointer_(takeOwnership) {}
50 
51  inline ~MultiplyByConst() {if (ownsPointer_) delete func_;}
52 
53  inline double operator()(const T& r) const {return (*func_)(r)*c_;}
54 
55  private:
57  double c_;
58  const fftjet::Functor1<double,T>* func_;
59  const bool ownsPointer_;
60  };
61 
62 
63  // Function composition
64  template <class T>
65  class CompositeFunctor : public fftjet::Functor1<double,T>
66  {
67  public:
68  inline CompositeFunctor(const fftjet::Functor1<double,double>* f1,
69  const fftjet::Functor1<double,T>* f2,
70  const bool takeOwnership=false)
71  : f1_(f1), f2_(f2), ownsPointers_(takeOwnership) {}
72 
74  {if (ownsPointers_) {delete f1_; delete f2_;}}
75 
76  inline double operator()(const T& r) const {return (*f1_)((*f2_)(r));}
77 
78  private:
80  const fftjet::Functor1<double,double>* f1_;
81  const fftjet::Functor1<double,T>* f2_;
82  const bool ownsPointers_;
83  };
84 
85 
86  // Product of two functors
87  template <class T>
88  class ProductFunctor : public fftjet::Functor1<double,T>
89  {
90  public:
91  inline ProductFunctor(const fftjet::Functor1<double,T>* f1,
92  const fftjet::Functor1<double,T>* f2,
93  const bool takeOwnership=false)
94  : f1_(f1), f2_(f2), ownsPointers_(takeOwnership) {}
95 
96  inline ~ProductFunctor()
97  {if (ownsPointers_) {delete f1_; delete f2_;}}
98 
99  inline double operator()(const T& r) const
100  {return (*f1_)(r) * (*f2_)(r);}
101 
102  private:
103  ProductFunctor();
104  const fftjet::Functor1<double,T>* f1_;
105  const fftjet::Functor1<double,T>* f2_;
106  const bool ownsPointers_;
107  };
108 
109 
110  // Function dependent on magnitude
111  template <class T>
112  class MagnitudeDependent : public fftjet::Functor1<double,T>
113  {
114  public:
115  inline MagnitudeDependent(const fftjet::Functor1<double,double>* f1,
116  const bool takeOwnership=false)
117  : f1_(f1), ownsPointer_(takeOwnership) {}
118 
119  inline ~MagnitudeDependent() {if (ownsPointer_) delete f1_;}
120 
121  inline double operator()(const T& r) const
122  {return (*f1_)(r.magnitude());}
123 
124  private:
126  const fftjet::Functor1<double,double>* f1_;
127  const bool ownsPointer_;
128  };
129 
130 
131  // Functions dependent on peak eta
132  class PeakEtaDependent : public fftjet::Functor1<double,fftjet::Peak>
133  {
134  public:
135  inline PeakEtaDependent(const fftjet::Functor1<double,double>* f1,
136  const bool takeOwnership=false)
137  : f1_(f1), ownsPointer_(takeOwnership) {}
138 
139  inline ~PeakEtaDependent() {if (ownsPointer_) delete f1_;}
140 
141  inline double operator()(const fftjet::Peak& r) const
142  {return (*f1_)(r.eta());}
143 
144  private:
146  const fftjet::Functor1<double,double>* f1_;
147  const bool ownsPointer_;
148  };
149 
150 
151  class PeakEtaMagSsqDependent : public fftjet::Functor1<double,fftjet::Peak>
152  {
153  public:
155  const fftjet::LinearInterpolator2d* f1,
156  const bool takeOwnership,
157  const fftjet::JetMagnitudeMapper2d<fftjet::Peak>* jmmp,
158  const bool ownjmp, const double fc)
159  : f1_(f1), ownsPointer_(takeOwnership), jmmp_(jmmp),
160  ownsjmmpPointer_(ownjmp), factor_(fc) {}
161 
163  {
164  if (ownsPointer_) delete f1_;
165  if (ownsjmmpPointer_) delete jmmp_;
166  }
167 
168  inline double operator()(const fftjet::Peak& r) const
169  {
170  const double scale = r.scale();
171  const double magnitude = r.magnitude();
172  const double pt = scale*scale*factor_*magnitude;
173  const double partonpt = (*jmmp_)(pt,r);
174  return (*f1_)(std::abs(r.eta()),partonpt) ;
175  }
176 
177  private:
179  const fftjet::LinearInterpolator2d* f1_;
180  const bool ownsPointer_;
181  const fftjet::JetMagnitudeMapper2d <fftjet::Peak>* jmmp_;
182  const bool ownsjmmpPointer_;
183  const double factor_;
184  };
185 
186 
187  // Functions dependent on jet eta
189  public fftjet::Functor1<double,fftjet::RecombinedJet<VectorLike> >
190  {
191  public:
192  inline JetEtaDependent(const fftjet::Functor1<double,double>* f1,
193  const bool takeOwnership=false)
194  : f1_(f1), ownsPointer_(takeOwnership) {}
195 
196  inline ~JetEtaDependent() {if (ownsPointer_) delete f1_;}
197 
198  inline double operator()(
199  const fftjet::RecombinedJet<VectorLike>& r) const
200  {return (*f1_)(r.vec().eta());}
201 
202  private:
203  JetEtaDependent();
204  const fftjet::Functor1<double,double>* f1_;
205  const bool ownsPointer_;
206  };
207 
208 
209  // A simple polynomial. Coefficients are in the order c0, c1, c2, ...
210  class Polynomial : public fftjet::Functor1<double,double>
211  {
212  public:
213  inline Polynomial(const std::vector<double>& coeffs)
214  : coeffs_(0), nCoeffs(coeffs.size())
215  {
216  if (nCoeffs)
217  {
218  coeffs_ = new double[nCoeffs];
219  std::copy(coeffs.begin(), coeffs.end(), coeffs_);
220  }
221  }
222  inline ~Polynomial() {delete [] coeffs_;}
223 
224  inline double operator()(const double& x) const
225  {
226  double sum = 0.0;
227  const double* p = coeffs_ + nCoeffs - 1;
228  for (unsigned i=0; i<nCoeffs; ++i)
229  {
230  sum *= x;
231  sum += *p--;
232  }
233  return sum;
234  }
235 
236  private:
237  Polynomial();
238  double* coeffs_;
239  const unsigned nCoeffs;
240  };
241 }
242 
243 #endif // RecoJets_FFTJetAlgorithms_ScaleCalculators_h
double operator()(const double &x) const
double operator()(const Arg1 &) const
int i
Definition: DBlmapReader.cc:9
MultiplyByConst(const double factor, const fftjet::Functor1< double, T > *f, const bool takeOwnership=false)
JetEtaDependent(const fftjet::Functor1< double, double > *f1, const bool takeOwnership=false)
const fftjet::Functor1< double, double > * f1_
const fftjet::Functor1< double, double > * f1_
double operator()(const T &r) const
const fftjet::Functor1< double, double > * f1_
ProportionalToScale(const double value)
const fftjet::Functor1< double, T > * f2_
MagnitudeDependent(const fftjet::Functor1< double, double > *f1, const bool takeOwnership=false)
double operator()(const T &r) const
double operator()(const fftjet::RecombinedJet< VectorLike > &r) const
double operator()(const fftjet::Peak &r) const
CompositeFunctor(const fftjet::Functor1< double, double > *f1, const fftjet::Functor1< double, T > *f2, const bool takeOwnership=false)
ProductFunctor(const fftjet::Functor1< double, T > *f1, const fftjet::Functor1< double, T > *f2, const bool takeOwnership=false)
Polynomial(const std::vector< double > &coeffs)
const fftjet::Functor1< double, T > * f1_
PeakEtaMagSsqDependent(const fftjet::LinearInterpolator2d *f1, const bool takeOwnership, const fftjet::JetMagnitudeMapper2d< fftjet::Peak > *jmmp, const bool ownjmp, const double fc)
double operator()(const T &r) const
const fftjet::Functor1< double, T > * func_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
const fftjet::LinearInterpolator2d * f1_
PeakEtaDependent(const fftjet::Functor1< double, double > *f1, const bool takeOwnership=false)
double operator()(const T &r) const
double operator()(const fftjet::Peak &r) const
const fftjet::JetMagnitudeMapper2d< fftjet::Peak > * jmmp_
const fftjet::Functor1< double, double > * f1_
long double T
const fftjet::Functor1< double, T > * f2_
tuple size
Write out results.
ConstDouble(const double value)
double operator()(const T &r) const