HadFit2sp.C
Go to the documentation of this file.
1 #include <iostream.h>
2 #include <fstream>
3 #include <iomanip.h>
4 #include <sstream>
5 #include <string>
6 #include <cstring>
7 
8 //To run the fitting stuff, do:
9 //root [0] .L TestFit.C
10 //root [1] myfunc();
11 //root [3] TestFit();
12 
13 Double_t susieFunc(Double_t *x, Double_t *par){
14 
15  Float_t xx = x[0];
16  Double_t f = 0.0;
17 
18  //Parameters:
19 
20  // par[0] = intercept
21  // par[1] = slope 1
22  // par[2] = slope 2
23  // par[3] = stitch point 1
24 
25  if (xx < par[3]){
26  f = par[1]*xx + par[0];
27  }
28 
29  else {
30  f = par[2]*xx + ((par[1]-par[2])*par[3]+par[0]);
31  }
32 
33  return f;
34 }
35 
36 
37 
38 void myfunc(){
39 
40  TF1 *f1 = new TF1("myfunc",susieFunc,0,2.0,4);
41  //f1->SetParameters(0.0459952,1.22247,1.59021,0.08500); //QE Values
42  //f1->SetParameters(0.202837,1.21606,1.56778,0.225007); //NonQE Values
43  f1->SetParameters(0.202837,1.21606,1.56778,0.225007); //CC Values
44  f1->SetParNames("Intercept","Slope1","Slope2","X1Point");
45  f1->Draw();
46 
47 }
48 
49 
50 void HadFit2sp()
51 {
52  std::cout<<"Hello Susie!"<<std::endl;
53 
54  //TFile* file = new TFile("./hadronqeProfile.root","READ"); //QE
55  //TFile* file = new TFile("./hadronnonqeProfile.root","READ"); //NonQE
56  TFile* file = new TFile("./hadronccProfile.root","READ"); //CC
57 
58  TGraphAsymmErrors* SusieProfile = file->Get("1");
59 
60  gStyle->SetOptStat(00000);
61  SusieProfile->SetMarkerStyle(6);
62 
63  TF1 *f1=gROOT->GetFunction("myfunc");
64  //Seed Values
65  //f1->SetParameters(0.04,1.2,1.7,0.08); //QE Values
66  //Final Values
67  //f1->FixParameter(0,0.0450);
68  //f1->FixParameter(1,1.567);
69  //f1->FixParameter(2,1.822);
70  //f1->FixParameter(3,0.0820);
71  //Seed Values
72  //f1->SetParameters(0.05,2.1,2.6,0.25); //NonQE Values
73  //Final Values
74  //f1->FixParameter(0,0.254);
75  //f1->FixParameter(1,1.080);
76  //f1->FixParameter(2,1.889);
77  //f1->FixParameter(3,0.169);
78  //Seed Values
79  //f1->SetParameters(0.04,0.8,1.9,0.05); //CC Values
80  //Final Values
81  f1->FixParameter(0,0.061);
82  f1->FixParameter(1,0.64);
83  f1->FixParameter(2,2.072);
84  f1->FixParameter(3,0.015);
85 
86  SusieProfile->Draw("AP");
87  SusieProfile->Fit("myfunc","EX0","",0,2); //EX means ignores error bars in x
88 
89  std::cout<<"I hope this gives me the right values, then #chi^{2} / ndf = "<<f1->GetChisquare()<<" / "<<f1->GetNDF()<<std::endl;
90 
91 
92 }
93 
94 
95 
Double_t xx
Definition: macro.C:12
Int_t par
Definition: SimpleIterate.C:24
void myfunc()
Definition: HadFit2sp.C:38
Double_t susieFunc(Double_t *x, Double_t *par)
Definition: HadFit2sp.C:13
Float_t f1
OStream cout
Definition: OStream.cxx:6
TFile * file
Definition: cellShifts.C:17
void HadFit2sp()
Definition: HadFit2sp.C:50