CbmRoot
fit_ybox.h
Go to the documentation of this file.
1 // box with polynomial filling
2 Double_t f1_xboxe(double* x, double* par) {
3  double xx = x[0];
4  double wx = 1. - par[4] * TMath::Power(xx + par[5], 2);
5  double xboxe = par[0] * 0.25
6  * (1. + TMath::Erf((xx + par[1] - par[3]) / par[2]))
7  * (1. + TMath::Erf((-xx + par[1] + par[3]) / par[2]));
8  return xboxe * wx;
9 
10  /*
11  common/pawpar/p(6)
12  real wx
13  wx=1.-p(5)*(x+p(6))**2
14 C wx=1.
15  xboxe=p(1)*0.25*(1.+erf(( x+p(2)-p(4))/p(3)))
16  & *(1.+erf((-x+p(2)+p(4))/p(3)))
17  xboxe=xboxe*wx
18  */
19 }
20 void fit_ybox(const char* hname) {
21  TH1* h1;
22  TH2* h2;
23  h1 = (TH1*) gROOT->FindObjectAny(hname);
24  if (NULL != h1) {
25  TAxis* xaxis = h1->GetXaxis();
26  Double_t Ymin = xaxis->GetXmin();
27  Double_t Ymax = xaxis->GetXmax();
28  TF1* f1 = new TF1("YBox", f1_xboxe, Ymin, Ymax, 6);
29  Double_t yini = (h1->GetMaximum() + h1->GetMinimum()) * 0.5;
30  f1->SetParameters(yini, Ymax * 0.8, 2., -1., 0., 0.);
31  h1->Fit("YBox");
32 
33  double res[10];
34  double err[10];
35  res[9] = f1->GetChisquare();
36 
37  for (int i = 0; i < 6; i++) {
38  res[i] = f1->GetParameter(i);
39  err[i] = f1->GetParError(i);
40  //cout << " FPar "<< i << ": " << res[i] << ", " << err[i] << endl;
41  }
42  cout << "YBox Fit of " << hname << " ended with chi2 = " << res[9]
43  << Form(", strip length %7.2f +/- %5.2f, position resolution %7.2f "
44  "+/- %5.2f at y_cen = %7.2f +/- %5.2f",
45  2. * res[1],
46  2. * err[1],
47  res[2],
48  err[2],
49  res[3],
50  err[3])
51  << endl;
52  }
53 }
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
f1_xboxe
Double_t f1_xboxe(double *x, double *par)
Definition: fit_ybox.h:2
fit_ybox
void fit_ybox(const char *hname)
Definition: fit_ybox.h:20
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68