StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
residu.C
1 // Loop through detector layers to report
2 // various parameters
3 residu(TString baseName, double min=-1.5, double max=1.5)
4 {
5  double xMin, xMax;
6  TString name;
7  name = baseName;
8  name += "_a"; TH1D * amp = new TH1D(name,name,55,0,54.);
9  name = baseName;
10  name += "_mean"; TH1D * mean = new TH1D(name,name,55,0,54.);
11  name = baseName;
12  name += "_rms"; TH1D * rms = new TH1D(name,name,55,0,54.);
13  TString thisL;
14  TH1D *h=0;
15  TF1 * f;
16  int ii;
17  for(int i=0; i<51;i++)
18  {
19  thisL=baseName+i;
20  if (i<6)
21  {
22  xMin = -0.2;
23  xMax = 0.2;
24  }
25  else
26  {
27  xMin = min;
28  xMax = max;
29  }
30  h=(TH1D*)gDirectory->Get(thisL);
31  h->Fit("gaus","","",xMin,xMax);
32  double entries = h->GetEntries();
33  if (entries>0)
34  {
35  ii = i+1;
36  f = h->GetFunction("gaus");
37  double a = f->GetParameter("Constant"); double ea = f->GetParError(0);
38  double m = f->GetParameter("Mean");double em = f->GetParError(1);
39  double r = f->GetParameter("Sigma");double er = f->GetParError(2);
40  amp->SetBinContent(ii,a);amp->SetBinError(ii,ea);
41  mean->SetBinContent(ii,m);mean->SetBinError(ii,em);
42  rms->SetBinContent(ii,r);rms->SetBinError(ii,er);
43  }
44  }
45  cout << "Fitting completed" << endl;
46 
47  c1->Clear();
48  c1->Divide(1,3);
49  c1->cd(1); amp->Draw();
50  c1->cd(2); mean->Draw();
51  c1->cd(3); rms->Draw();
52 
53 }