10 #include "TGraphErrors.h"
16 int referenceVzCorr(){
18 TFile *f0 =
new TFile(
"referenceData.root");
22 double VzErr[numHists];
24 TH1F *clonedhist[numHists];
26 double par0[numHists];
27 double par1[numHists];
28 double hErr[numHists];
29 double chi2perNDF[numHists];
30 double minbin = 320.0;
31 double maxbin = 450.0;
34 for(
int i=0; i<numHists; i++){
35 hist[i] = (TH1F *)f0->Get(Form(
"hRefMultPWVtxZ_%d",i));
36 TF1 *f1 =
new TF1(
"f1",
"([0]/10.0) * (TMath::Erf( -[1]*(x - [2]) ) + 1)", minbin, maxbin);
37 f1->SetParameter(0,1.0e4);
38 f1->SetParameter(1,0.027);
39 f1->SetParameter(2,maxbin-50.0);
40 TFitResultPtr r = hist[i]->Fit(
"f1",
"RLMS");
41 h[i] = r->Parameter(2);
42 par0[i] = r->Parameter(0);
43 par1[i] = r->Parameter(1);
44 hErr[i] = r->ParError(2);
47 TF1 *fit = hist[i]->GetFunction(
"f1");
48 Double_t chi2 = fit->GetChisquare();
49 double numbins = maxbin-minbin+1.0;
50 cout<<
"CHi2/ndf: "<<chi2<<
"/"<<numbins<<endl;
51 chi2perNDF[i] = chi2/numbins;
55 TCanvas *c_100 =
new TCanvas(
"c_100",
"Canvas",1200,600);
57 TPad* pad_100 =
new TPad(
"pad_100",
"Pad",0.,0.,1.,1.);
60 TCanvas *c_200 =
new TCanvas(
"c_200",
"Canvas",1200,600);
62 TPad* pad_200 =
new TPad(
"pad_200",
"Pad",0.,0.,1.,1.);
65 TCanvas *c_300 =
new TCanvas(
"c_300",
"Canvas",1200,600);
67 TPad* pad_300 =
new TPad(
"pad_300",
"Pad",0.,0.,1.,1.);
70 TCanvas *c_400 =
new TCanvas(
"c_400",
"Canvas",1200,600);
72 TPad* pad_400 =
new TPad(
"pad_400",
"Pad",0.,0.,1.,1.);
77 for(
int i=0; i<numHists; i++){
78 hist[i] = (TH1F *)f0->Get(Form(
"hRefMultPWVtxZ_%d",i));
79 hist[i]->GetXaxis()->SetTitle(
"Reference Multiplicity");
81 TF1 *f1 =
new TF1(
"f1",
"([0]/10.0) * (TMath::Erf( -[1]*(x - [2]) ) + 1)",minbin,maxbin);
82 f1->SetParameter(0,par0[i]);
83 f1->SetParameter(1,par1[i]);
84 f1->SetParameter(2,h[i]);
88 pad_100->cd(i+1)->SetLogy();
89 hist[i]->GetXaxis()->SetRangeUser(0,500.0);
95 pad_200->cd(i+1-8)->SetLogy();
96 hist[i]->GetXaxis()->SetRangeUser(0,500.0);
102 pad_300->cd(i+1-16)->SetLogy();
103 hist[i]->GetXaxis()->SetRangeUser(0,500.0);
109 pad_400->cd(i+1-24)->SetLogy();
110 hist[i]->GetXaxis()->SetRangeUser(0,500.0);
117 TCanvas *allRefMult =
new TCanvas(
"allRefMult",
"allRefMult",800,600);
119 TLegend *legP =
new TLegend(0.45,0.65,0.9,0.9,
"",
"NDC");
120 legP->SetNColumns(3);
121 int j[6]={0,0,0,0,0,0};
122 bool secondrepeat =
false;
123 for(
int i=0; i<29;i++){
124 clonedhist[i] = (TH1F*) hist[i]->
Clone();
125 if(clonedhist[i]->GetBinContent(10)==0)
continue;
126 clonedhist[i]->Scale(1.0/clonedhist[i]->Integral(25,50));
127 if(j[5]==5){j[0]=-1;j[1]=-1;j[2]=-1;j[3]=-1;j[4]=-1;j[5]=-1;secondrepeat=
true;}
128 if(secondrepeat){j[0]=-2;j[1]=-2;j[2]=-2;j[3]=-2;j[4]=-2;j[5]=-2;}
129 if(i%6==0){clonedhist[i]->SetLineColor(kRed+j[0]);j[0]++;}
130 if(i%6==1){clonedhist[i]->SetLineColor(kOrange+j[1]);j[1]++;}
131 if(i%6==2){clonedhist[i]->SetLineColor(kGreen+j[2]);j[2]++;}
132 if(i%6==3){clonedhist[i]->SetLineColor(kCyan+j[3]);j[3]++;}
133 if(i%6==4){clonedhist[i]->SetLineColor(kBlue+j[4]);j[4]++;}
134 if(i%6==5){clonedhist[i]->SetLineColor(kMagenta+j[5]);j[5]++;}
135 clonedhist[i]->SetStats(0);
136 if(i==0)clonedhist[i]->Draw(
"HIST");
137 else clonedhist[i]->Draw(
"SAME HIST");
138 TString name=Form(
"(%d,%d)cm",(
int)(-145.0+10.*(i)),(
int)(-145.0+10.*(i+1)));
139 legP->AddEntry(clonedhist[i],name,
"l");
143 auto c1 =
new TCanvas(
"c1",
"c1");
144 TGraphErrors* g =
new TGraphErrors(numHists, Vz, h, VzErr, hErr);
145 g->SetMarkerStyle(kFullCircle);
148 TGraph* g_chi =
new TGraph(numHists, Vz, chi2perNDF);
149 auto cchi =
new TCanvas(
"cchi",
"cchi");
150 g_chi->SetMarkerStyle(kFullCircle);
153 double lowedges[numHists];
154 for(
int i=0; i<numHists+1; i++){
155 lowedges[i]=-145.0+10.0*(i);
156 cout<<
"Bin edges: "<<lowedges[i]<<endl;
158 TH1D* upperEdge =
new TH1D(
"upperEdge",
"h as a function of Vz",numHists, lowedges);
159 for(
int i=0; i<numHists; i++){
160 upperEdge->Fill(Vz[i],h[i]);
161 upperEdge->SetBinError(i+1,hErr[i]);
164 auto c3 =
new TCanvas(
"c3",
"c3");
165 TF1 *f2 =
new TF1(
"f2",
"[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*x*x*x*x*x+[6]*x*x*x*x*x*x",-145.0,145.0);
167 cout<<
"***************************** SIXTH-ORDER VZ CORRECTION ********************************"<<endl;
168 TFitResultPtr r2 = upperEdge->Fit(
"f2",
"RMS");
169 TF1 *Vzfit = upperEdge->GetFunction(
"f2");
170 Double_t Vzchi2 = Vzfit->GetChisquare();
171 cout<<
"CHI2/NDF: "<<Vzchi2/(29.0-f2->GetNumberFreeParameters())<<endl;
173 cout<<
"****************************** POINTWISE VZ CORRECTION ******************************"<<endl;
174 cout<<
"double vz_corr[29];"<<endl;
175 for(
int corrnum=0; corrnum<29; corrnum++){
176 cout<<
"vz_corr["<<corrnum<<
"]="<<h[14]/h[corrnum]<<Form(
"; //Correction for Vz of (%d,%d)cm",(
int)(-145.0+10.*(corrnum)),(
int)(-145.0+10.*(corrnum+1)))<<endl;
virtual TObject * Clone(const char *newname="") const
the custom implementation fo the TObject::Clone