BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
dEdxVsEang.cxx
Go to the documentation of this file.
1//This code is to fit graph gain vs eangle and get the slope
2TString old_file = "../../Eangle1DSec/eangle.root";
3TString new_file = "eangle.root";
4
6{
7 TFile *f=new TFile(old_file);
8 ostringstream strout;
9 strout<<"ddgcalib";
10 TTree *tree = (TTree*)f->Get(strout.str().c_str());
11 double dedx[100],eangle[100], err[100];
12 tree->SetBranchAddress("gain",dedx);
13 tree->SetBranchAddress("eangle",eangle);
14 tree->SetBranchAddress("fitmeanerr", err);
15 tree->GetEntry(0);
16 double sum=0;
17 for(int i=0;i<100;i++)
18 {
19 sum+=dedx[i];
20 err[i] = err[i]/550;
21 }
22 sum = sum/100;
23 gStyle->SetOptFit(0111);
24 TCanvas *c1 = new TCanvas("c1","c1",10,10,800,642);
25 // TGraphErrors* gr = new TGraphErrors(100,eangle,dedx,eangle,err);
26 TGraph* gr = new TGraphErrors(100,eangle,dedx);
27 gr->SetMarkerColor(2);
28 gr->SetLineColor(2);
29 gr->Draw("A*");
30
31 // graph of check
32 f=new TFile(new_file);
33 tree = (TTree*)f->Get(strout.str().c_str());
34 double dedx2[100],eangle2[100], err2[100];
35 tree->SetBranchAddress("gain",dedx2);
36 tree->SetBranchAddress("eangle",eangle2);
37 tree->SetBranchAddress("fitmeanerr", err2);
38 tree->GetEntry(0);
39 double sum=0;
40 for(int i=0;i<100;i++)
41 {
42 sum+=dedx[i];
43 err[i] = err[i]/550;
44 }
45 sum = sum/100;
46 TGraph* gr2 = new TGraphErrors(100,eangle2,dedx2);
47 gr2->Draw("*,same");
48
49 TLegend* leg = new TLegend(.65, .75, .89, .89);
50 leg->AddEntry(gr,"ori","p");
51 leg->AddEntry(gr2,"cor","p");
52 leg->Draw();
53
54 TFile f_save("dEdxVsEang.root","recreate");
55 c1->Write();
56 f_save.Close();
57 f->Close();
58}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
TGraph * gr
TString new_file
Definition: dEdxVsEang.cxx:3
TString old_file
Definition: dEdxVsEang.cxx:2
void dEdxVsEang()
Definition: dEdxVsEang.cxx:5