Fork me on GitHub

source: svn/trunk/routines/resolutions.C@ 36

Last change on this file since 36 was 27, checked in by severine ovyn, 16 years ago

Jet resol OK

File size: 5.0 KB
RevLine 
[9]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
[27]11void JetResol()
[9]12{
[27]13
14 setTDRStyle();
15 gROOT->Reset();
16
17 TFile *f1 = new TFile("JETResol.root","read");
18 TTree *Analyze = (TTree*)f1->Get("Analysis");
[9]19
[23]20 const Int_t numBin=7;
[27]21 double bins[numBin]={0,20,40,60,80,100,220};
[23]22 TProfile *ETSoverET = new TProfile("ETSoverET","Jet resolution: E_{T}^{rec}/E_{T}^{mc}",(numBin-1),bins,-10,10);
[9]23
24 double rms[numBin];
25 double mean[numBin];
26
[27]27 TCanvas *c1 = new TCanvas("c1","JET resol",0,0,1000,650);
28 c1->cd(); int frame=0;
29 c1->Divide(6,2);
[9]30
[23]31 float x[numBin-1];
32 float y[numBin-1];
[27]33 float ex[numBin-1];
34 float ey[numBin-1];
35
[9]36 float finval=0;//valeur a remplir puis a fitter
37
[23]38 for ( int i=0; i<(numBin-1); i++) // premiÚre bin : i ==1 et pas i == 0
[9]39 {
40 TAxis *xaxis = ETSoverET->GetXaxis();
41 float binCenter = xaxis->GetBinCenter(i+1);
42 int binMin = (int)xaxis->GetBinLowEdge(i+1);
43 int binMax = (int)xaxis->GetBinUpEdge(i+1);
44 cout<<"binMin "<<binMin<<" binMax "<<binMax<<" bin center "<<binCenter<<endl;
45 char tempMin[500];
[27]46 if(i==0)binMin=5;
47 sprintf(tempMin,"JetPTResol.NonSmearePT > %d",binMin);
[9]48 string mystringMin(tempMin);
49 char tempMax[500];
[27]50 sprintf(tempMax,"JetPTResol.NonSmearePT < %d",binMax);
[9]51 string mystringMax(tempMax);
52 char tempName[500];
[27]53 sprintf(tempName,"(JetPTResol.SmearePT)>>hETSoverET%d",i);
[9]54 string mystringName(tempName);
55
[27]56 c1->cd(++frame);
[9]57 GaussValues(Analyze,tempName,rms[i],mean[i],mystringMin,mystringMax);
58 x[i]=binCenter;
59 finval=rms[i]/mean[i];
[27]60 y[i]=(finval*100);
61 ex[i]=0;
62 ey[i]=0;
[9]63 cout<<"finval "<<finval<<" mean val "<<mean[i]<<" rms value "<<rms[i]<<endl;
64 }
65
[27]66 TCanvas *c2 = new TCanvas("c2","JET resol",100,100,600,450);
67 c2->cd();
[9]68
[27]69 TF1 *fitfun = new TF1("user","sqrt(pow([0],2)+pow([1]/sqrt(x),2)+pow([2]/x,2))",1,170);
[9]70
[27]71 TGraphErrors *gr11 = new TGraphErrors((numBin-1),x,y,ex,ey);
[9]72 gr11->Draw("AP");
[27]73 gr11->SetTitle("");
[9]74 gr11->GetXaxis()->SetTitle("E_{T}^{MC} [GeV]");
[27]75 gr11->GetYaxis()->SetRangeUser(0,50);
76 gr11->GetYaxis()->SetTitle("#sigma(E_{T}^{rec}/E_{T}^{MC})_{fit}/<E_{T}^{rec}/E_{T}^{MC}>_{fit}");
[9]77
[27]78 Double_t* params = fitfun->GetParameters();
79
[9]80 gr11->Fit("user","R");
[27]81 gr11->Fit("user","RI");
82 gr11->Fit("user","RI");
83 gr11->Fit("user","RI");
84 char tempResol[500];
85 sprintf(tempResol,"#frac{#sigma(E_{T}^{rec}/E_{T}^{MC})}{<E_{T}^{rec}/E_{T}^{MC}>} = #frac{%f}{#sqrt{E_{T}^{MC}}} #oplus #frac{%f}{E_{T}^{MC}} #oplus %f",params[1]/100,params[2]/100,params[0]/100);
[9]86
[27]87 TPaveText *leg1 = MakeTPave(0.4,0.6,0.8,0.65,tempResol);
88 leg1->Draw();
[9]89
[27]90 delete fitfun;
[9]91}
[23]92
93
[27]94void ETmisResol()
[23]95{
96
[27]97 setTDRStyle();
98 gROOT->Reset();
[23]99
[27]100 TFile *f1 = new TFile("PTMIS.root","read");
101 TTree *Analyze = (TTree*)f1->Get("Analysis");
[23]102
[27]103 const Int_t numBin=6;
104 double bins[numBin]={10,20,30,50,80,100};
105 TProfile *ETSoverET = new TProfile("ETSoverET","ETmis resol",(numBin-1),bins,-1000,1000);
106
107 double rms[numBin-1];
108 double mean[numBin-1];
109
[23]110 TCanvas *c5 = new TCanvas("c5","gerrors2",0,0,1000,650);
111 c5->cd(); int frame=0;
112 c5->Divide(6,2);
113
[27]114 double x[numBin-1];
115 double y[numBin-1];
[23]116
117 for ( int i=0; i<(numBin-1); i++) // premiÚre bin : i ==1 et pas i == 0
118 {
119 TAxis *xaxis = ETSoverET->GetXaxis();
120 float binCenter = xaxis->GetBinCenter(i+1);
121 int binMin = (int)xaxis->GetBinLowEdge(i+1);
122 int binMax = (int)xaxis->GetBinUpEdge(i+1);
123 cout<<"binMin "<<binMin<<" binMax "<<binMax<<" bin center "<<binCenter<<endl;
124 char tempMin[500];
[27]125 sprintf(tempMin,"ETmisResol.Et>%d",binMin);
[23]126 string mystringMin(tempMin);
127 char tempMax[500];
[27]128 sprintf(tempMax,"ETmisResol.Et<%d",binMax);
[23]129 string mystringMax(tempMax);
[27]130
[23]131 char tempName[500];
[27]132 sprintf(tempName,"ETmisResol.EtSmeare>>hETSoverET%d",i);
[23]133 string mystringName(tempName);
134
135 c5->cd(++frame);
[27]136 GaussValuesETmis(Analyze,tempName,rms[i],mean[i],mystringMin,mystringMax);
[23]137 x[i]=binCenter;
138 y[i]=rms[i];
139 cout<<" mean val "<<mean[i]<<" rms value "<<rms[i]<<endl;
140
141 }
142
143 TCanvas *c6 = new TCanvas("c6","ETmis resolution",100,100,600,450);
144 c6->cd();
145
[27]146 TF1 *fitfun = new TF1("user","sqrt(pow([0],2)+pow([1]/sqrt(x),2)+pow([2]/x,2))",0,200);
[23]147
[27]148 TGraph *gr11 = new TGraph((numBin-1),x,rms);
[23]149 gr11->Draw("AP");
[27]150 gr11->GetXaxis()->SetTitle("MC^{MET} [GeV]");
151 gr11->GetYaxis()->SetTitle("#sigma(REC^{MET}-MC^{MET})");
[23]152 gr11->Fit("user","RQ");
153 gr11->Fit("user","RQ");
154 gr11->Fit("user","RQ");
155 gr11->Fit("user","R");
156
[27]157 TCanvas *c7 = new TCanvas("c7","ETmis resolution",100,100,600,450);
158 c7->cd();
[23]159
[27]160 TGraph *gr12 = new TGraph((numBin-1),x,mean);
161 gr12->Draw("AP");
162 gr12->GetXaxis()->SetTitle("MC^{MET} [GeV]");
163 gr12->GetYaxis()->SetTitle("<(REC^{MET}-MC^{MET})>");
[23]164
[27]165
[23]166 delete fitfun;
167}
168
169void General()
170{
[27]171 JetResol();
172 ETmisResol();
173}
[23]174
175
Note: See TracBrowser for help on using the repository browser.