1 | #include "TROOT.h"
|
---|
2 | #include "TFile.h"
|
---|
3 | #include "TTree.h"
|
---|
4 | #include "TCanvas.h"
|
---|
5 | #include "TProfile.h"
|
---|
6 | #include "TF1.h"
|
---|
7 | #include "TGraph.h"
|
---|
8 |
|
---|
9 | #include "interface/FuncDef.h"
|
---|
10 |
|
---|
11 | void Plot()
|
---|
12 | {
|
---|
13 |
|
---|
14 | setTDRStyle();
|
---|
15 | gROOT->Reset();
|
---|
16 |
|
---|
17 | TFile *f1 = new TFile("Smearing.root","read");
|
---|
18 | TTree *Analyze = (TTree*)f1->Get("Analysis");
|
---|
19 |
|
---|
20 |
|
---|
21 | //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
---|
22 | //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
---|
23 |
|
---|
24 | TCanvas *c1 = new TCanvas("c1","gerrors2",100,100,600,450);
|
---|
25 | c1->cd();
|
---|
26 |
|
---|
27 | const Int_t numBin=5;
|
---|
28 | // double bins[numBin]={5,10,25,55,85,115,205,400};
|
---|
29 | double bins[5]={10,30,50,80,120};
|
---|
30 | TProfile *ETSoverET = new TProfile("ETSoverET","Resolution des electrons",(numBin-1),bins,-10,10);
|
---|
31 | Analyze->Draw("JetPTResol.SmearePT:JetPTResol.NonSmearePT>>ETSoverET","JetPTResol.NonSmearePT>1");
|
---|
32 |
|
---|
33 | double rms[numBin];
|
---|
34 | double mean[numBin];
|
---|
35 | //TF1 *Gauss = new TF1("Gauss","gaus",0,4);
|
---|
36 |
|
---|
37 | TCanvas *c2 = new TCanvas("c2","gerrors2",0,0,1000,650);
|
---|
38 | c2->cd(); int frame=0;
|
---|
39 | c2->Divide(6,2);
|
---|
40 | // c2->Divide(6,2);
|
---|
41 |
|
---|
42 | float x[numBin];
|
---|
43 | float y[numBin];
|
---|
44 | float finval=0;//valeur a remplir puis a fitter
|
---|
45 |
|
---|
46 | for ( int i=0; i<numBin; i++) // premiÚre bin : i ==1 et pas i == 0
|
---|
47 | {
|
---|
48 | TAxis *xaxis = ETSoverET->GetXaxis();
|
---|
49 | float binCenter = xaxis->GetBinCenter(i+1);
|
---|
50 | int binMin = (int)xaxis->GetBinLowEdge(i+1);
|
---|
51 | int binMax = (int)xaxis->GetBinUpEdge(i+1);
|
---|
52 | cout<<"binMin "<<binMin<<" binMax "<<binMax<<" bin center "<<binCenter<<endl;
|
---|
53 | char tempMin[500];
|
---|
54 | sprintf(tempMin,"JetPTResol.NonSmearePT>%d",binMin);
|
---|
55 | string mystringMin(tempMin);
|
---|
56 | char tempMax[500];
|
---|
57 | sprintf(tempMax,"JetPTResol.NonSmearePT<%d",binMax);
|
---|
58 | string mystringMax(tempMax);
|
---|
59 | char tempName[500];
|
---|
60 | sprintf(tempName,"JetPTResol.SmearePT>>hETSoverET%d",i);
|
---|
61 | string mystringName(tempName);
|
---|
62 |
|
---|
63 | c2->cd(++frame);
|
---|
64 | GaussValues(Analyze,tempName,rms[i],mean[i],mystringMin,mystringMax);
|
---|
65 | x[i]=binCenter;
|
---|
66 | mean[i]=ETSoverET->GetBinContent(i+1);
|
---|
67 | // rms[i]=ETSoverET->GetBinError(i+1);
|
---|
68 | finval=rms[i]/mean[i];
|
---|
69 | y[i]=finval;
|
---|
70 | cout<<"finval "<<finval<<" mean val "<<mean[i]<<" rms value "<<rms[i]<<endl;
|
---|
71 |
|
---|
72 | }
|
---|
73 |
|
---|
74 | y[0]=0.2;
|
---|
75 |
|
---|
76 | TCanvas *c3 = new TCanvas("c3","gerrors2",100,100,600,450);
|
---|
77 | c3->cd();
|
---|
78 |
|
---|
79 | TF1 *fitfun = new TF1("user","sqrt(pow([0],2)+pow([1]/sqrt(x),2)+pow([2]/x,2))",10,500);
|
---|
80 |
|
---|
81 | TGraph *gr11 = new TGraph((numBin),x,y);
|
---|
82 | gr11->Draw("AP");
|
---|
83 | gr11->GetXaxis()->SetTitle("E_{T}^{MC} [GeV]");
|
---|
84 | gr11->GetYaxis()->SetTitle("#sigma(E_{T}^{rec}/E_{T}^{MC})/<E_{T}^{rec}/E_{T}^{MC}>");
|
---|
85 |
|
---|
86 | //fitfun->FixParameter(0,0.0541930);
|
---|
87 | //fitfun->FixParameter(1,0.634908);
|
---|
88 | gr11->Fit("user","RQ");
|
---|
89 | gr11->Fit("user","RQ");
|
---|
90 | gr11->Fit("user","RQ");
|
---|
91 | gr11->Fit("user","R");
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 | delete fitfun;
|
---|
96 | // delete Gauss;
|
---|
97 | }
|
---|