StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fitCos.C
1 // example to illustrate how to fit excluding points in a given range
2 // Author: Rene Brun
3 #include "TH1.h"
4 #include "TF1.h"
5 Bool_t reject;
6 
7 Double_t fitCos(Double_t *x, Double_t *par) {
8  // Note:
9  // -0.08 is lower end of \eta_\Delta bin centered at 0 when there are 25 bins covering 4 units.
10  // -0.131 is close to lower end of \phi_\Delta bin centered at 0 when there are 24 bins covering 2pi
11  // (we usually duplicate a bin, having one centered at -pi/2 and the same one centered at 3pi/2.)
12  // 3.272492 is close to upper end of bin centered at pi when there are 24 bins covering 2pi
13  double etaD = x[0];
14  double phiD = x[1];
15  if ( reject &&
16  ((etaD<-0.08) || (2.0 < etaD) || (phiD<-0.131) || (3.2724925<phiD)) ) {
17  TF1::RejectPoint();
18  return 0;
19  }
20 
21  double pi = acos(-1);
22  double gx = exp(-pow(etaD/par[4],2)/2);
23  double gy = exp(-pow(phiD/par[5],2)/2);
24  double gyp2pi = exp(-pow((phiD-2*pi)/par[5],2)/2);
25  double gym2pi = exp(-pow((phiD+2*pi)/par[5],2)/2);
26  double rad = sqrt( pow(etaD/par[7],2) + pow(phiD/par[8],2) );
27  double rad2pi = sqrt( pow(etaD/par[7],2) + pow((phiD-2*pi)/par[8],2) );
28 
29  double func = par[0] +
30  par[1] * cos(phiD) +
31  par[2] * cos(2*phiD) +
32  par[3] * gx * (gy + gyp2pi + gym2pi) +
33  par[6] * (exp(-rad) + exp(-rad2pi)) +
34  par[9]*cos(etaD) + par[10]*cos(2*etaD) + par[11]*cos(3*etaD) + par[12]*cos(4*etaD);
35  return func;
36 }