MuonFitLin.C
Go to the documentation of this file.
1 
2 #include <iostream.h>
3 #include <fstream>
4 #include <iomanip.h>
5 #include <sstream>
6 #include <string>
7 #include <cstring>
8 
9 //To run the fitting stuff, do:
10 //root [0] .L TestFit.C
11 //root [1] myfunc();
12 //root [3] TestFit();
13 
14 Double_t susieFunc(Double_t *x, Double_t *par){
15 
16  Float_t xx = x[0];
17  Double_t f = 0.0;
18 
19  //Parameters:
20 
21  // par[0] = intercept
22  // par[1] = slope 1
23 
24  f = par[1]*xx + par[0];
25 
26  return f;
27 }
28 
29 void myfunc(){
30 
31  TF1 *f1 = new TF1("myfunc",susieFunc,0,300.0,2);
32  //f1->SetParameters(0.230294,0.00513341); //All catcher
33  f1->SetParameters(0.16,0.005); //Act + catcher
34  f1->SetParNames("Intercept","Slope1");
35  f1->Draw();
36 
37 }
38 
39 
40 void MuonFitLin()
41 {
42  std::cout<<"Hello Susie!"<<std::endl;
43 
44  TFile* file = new TFile("./muonProfile.root","READ");
45 
46  TGraphAsymmErrors* SusieProfile = file->Get("1");
47 
48  gStyle->SetOptStat(00000);
49  SusieProfile->SetMarkerStyle(6);
50 
51  TF1 *f1=gROOT->GetFunction("myfunc");
52  //f1->SetParameters(0.230294,0.00513341); //All catcher
53  //Seed Values
54  //f1->SetParameters(0.16,0.005); //Act + catcher
55  //Final Values
56  f1->FixParameter(0,0.152);
57  f1->FixParameter(1,0.00536);
58 
59  SusieProfile->Draw("AP");
60  SusieProfile->Fit("myfunc","EX0","",0,300); //EX means ignores error bars in x
61 
62  std::cout<<"I hope this gives me the right values, then #chi^{2} / ndf = "<<f1->GetChisquare()<<" / "<<f1->GetNDF()<<std::endl;
63 }
64 
65 
66 
Double_t xx
Definition: macro.C:12
void myfunc()
Definition: MuonFitLin.C:29
Int_t par
Definition: SimpleIterate.C:24
void MuonFitLin()
Definition: MuonFitLin.C:40
Float_t f1
OStream cout
Definition: OStream.cxx:6
TFile * file
Definition: cellShifts.C:17
Double_t susieFunc(Double_t *x, Double_t *par)
Definition: MuonFitLin.C:14