Fork me on GitHub

source: svn/trunk/interface/FuncDef.h@ 480

Last change on this file since 480 was 478, checked in by Xavier Rouby, 15 years ago

updates needed for Atlas resolution

File size: 6.8 KB
Line 
1#ifndef __FuncDef__
2#define __FuncDef__
3
4#include "TStyle.h"
5#include "TCanvas.h"
6#include "TH1F.h"
7#include "TLegend.h"
8#include "TPad.h"
9#include "TTree.h"
10#include "TFile.h"
11#include "THStack.h"
12#include "TLine.h"
13#include "TArrow.h"
14#include "TMarker.h"
15#include "TStyle.h"
16#include "TROOT.h"
17
18#include <iomanip>
19#include <vector>
20#include <iostream>
21#include <string>
22#include "TPaveText.h"
23#include "TProfile.h"
24#include "TF1.h"
25#include "TGraph.h"
26#include "TGraphErrors.h"
27
28#include "interface/TdrStyle.h"
29
30using namespace std;
31
32TPaveText * MakeTPave(Float_t xmin,Float_t ymin,Float_t xmax,Float_t ymax,string text)
33{
34
35 TPaveText *leg1 = new TPaveText(xmin,ymin,xmax,ymax,"NDC");
36 leg1->AddText(text.c_str());
37 leg1->SetFillColor(10);
38 leg1->SetBorderSize(0);
39 leg1->SetTextFont(42);
40 leg1->SetTextSize(0.03791469);
41 return leg1;
42
43
44}
45
46
47TLegend * MakeLegend(Int_t FilledColor,Int_t BorderSize,Float_t TextSize,Double_t x1 = 0.60, Double_t y1 = 0.71, Double_t x2= 0.92, Double_t y2 = 0.92)
48{
49 TLegend *leg = new TLegend(x1,y1,x2,y2,NULL,"NDC");
50 leg->SetFillColor(FilledColor);
51 leg->SetBorderSize(BorderSize);
52 leg->SetTextSize(TextSize);
53 leg->SetTextFont(42);
54
55 return leg;
56}
57
58TH1F * MakeNormTH1F(Int_t numBin,Float_t minX,Float_t maxX, TTree * Analyze,string histo, Int_t Lcolor, Int_t Fcolor, Int_t Lstyle,Int_t width=2,bool Log=false)
59{
60 string temp = histo;
61 string nom = histo.erase(0,histo.find(">>")+2);
62 TH1F *h = new TH1F(nom.c_str(),"pt_lept ",numBin,minX,maxX);
63 //Analyze->Draw(temp.c_str(),"(JetPTResol.NonSmearePT >0 && JetPTResol.NonSmearePT < 20)");
64 Analyze->Draw(temp.c_str());
65 h->SetLineColor(Lcolor);
66 h->SetFillColor(Fcolor);
67 h->SetLineStyle(Lstyle);
68 h->SetLineWidth(width);
69 if(Log)gPad->SetLogy();
70 if(h->Integral()!=0)h->Scale(1./h->Integral());
71 return h;
72}
73
74void GaussValues(TTree * Analyze,string histo,double &rms, double &mean, string min,string max)
75{
76 string temp = histo;
77 string mintemp = min;
78 string maxtemp = max;
79
80 string nom = histo.erase(0,histo.find(">>")+2);
81 TH1F *h = new TH1F(nom.c_str(),"",100,0,3);
82 string all = min + " && " + max;
83 Analyze->Draw(temp.c_str(),all.c_str());
84 h->SetMarkerSize(0.6);
85 double MeanFix = h->GetMean();
86 double RangMin = (h->GetMean()-1.5*h->GetRMS());
87 double RangMax = (h->GetMean()+1.5*h->GetRMS());
88 TF1 *Gauss = new TF1("Gauss","gaus",RangMin,RangMax);
89// Gauss->FixParameter(1,MeanFix);
90 h->Fit("Gauss","QR");
91 h->Fit("Gauss","QRI");
92 h->Fit("Gauss","QRI");
93 Double_t* params = Gauss->GetParameters();
94 rms=params[2];
95 //mean= MeanFix;
96 mean=params[1];
97 h->Draw("P");
98 h->GetXaxis()->SetTitle("E_{T}^{rec}/E_{T}^{MC} [GeV]");
99Gauss->Delete();
100}
101
102
103void GaussValuesAsymmetry(TTree * Analyze,string histo, double &mean, string min,string max)
104{
105 string temp = histo;
106 string mintemp = min;
107 string maxtemp = max;
108
109 string nom = histo.erase(0,histo.find(">>")+2);
110 TH1F *h = new TH1F(nom.c_str(),"",500,-10,40);
111 string all = min + " && " + max;
112 Analyze->Draw(temp.c_str(),all.c_str());
113 h->SetMarkerSize(0.6);
114 mean = h->GetMean();
115 double RangMin = (h->GetMean()-2*h->GetRMS());
116 double RangMax = (h->GetMean()+2*h->GetRMS());
117}
118
119
120
121
122void GaussValuesElec(TTree * Analyze,string histo,double &rms, double &mean, string min,string max)
123{
124 string temp = histo;
125 string mintemp = min;
126 string maxtemp = max;
127
128 string nom = histo.erase(0,histo.find(">>")+2);
129 TH1F *h = new TH1F(nom.c_str(),"",20,-1,3);
130 string all = min + " && " + max;
131 Analyze->Draw(temp.c_str(),all.c_str());
132 h->SetMarkerSize(0.6);
133 double MeanFix = h->GetMean();
134 TF1 *Gauss = new TF1("Gauss","gaus",-0.5,1.5);
135 Gauss->FixParameter(1,MeanFix);
136 h->Fit("Gauss","QR");
137 h->Fit("Gauss","QRI");
138 h->Fit("Gauss","QRI");
139 Double_t* params = Gauss->GetParameters();
140 rms=params[2];
141 //mean= MeanFix;
142 mean=params[1];
143 h->Draw("P");
144 h->GetXaxis()->SetTitle("E_{T}^{rec}/E_{T}^{MC} [GeV]");
145 Gauss->Delete();
146}
147
148
149
150void GaussValuesETmis(TTree * Analyze,string histo,double &rms, string min,string max)
151{
152 string temp = histo;
153 string mintemp = min;
154 string maxtemp = max;
155
156 string nom = histo.erase(0,histo.find(">>")+2);
157 TH1F *h = new TH1F(nom.c_str(),"",50,-50,50);
158
159 string all = min + " && " + max;
160 Analyze->Draw(temp.c_str(),all.c_str());
161 h->SetMarkerSize(0.6);
162 double RangMin = (h->GetMean()-1.9*h->GetRMS());
163 double RangMax = (h->GetMean()+1.9*h->GetRMS());
164 //TF1 *Gauss = new TF1("Gauss","gaus");
165 TF1 *Gauss = new TF1("Gauss","gaus",RangMin,RangMax);
166 //TF1 *Gauss = new TF1("Gauss","gaus");
167 h->Fit("Gauss","QR");
168 h->Fit("Gauss","QRI");
169 h->Fit("Gauss","QRI");
170 Double_t* params = Gauss->GetParameters();
171 rms=params[2];
172 //rms=h->GetRMS();
173 //mean=params[1];
174 h->Draw("P");
175 h->GetXaxis()->SetTitle("E_{T}^{rec}-E_{T}^{MC} [GeV]");
176}
177
178
179TH1F * HiggsMakeNormTH1F(Float_t Scale, Int_t numBin,Float_t minX,Float_t maxX, TTree * Analyze,string histo, Int_t Lcolor, Int_t Fcolor, Int_t Lstyle,Int_t width=2,bool Log=false)
180{
181 string temp = histo;
182 string nom = histo.erase(0,histo.find(">>")+2);
183 TH1F *h = new TH1F(nom.c_str(),"pt_lept ",numBin,minX,maxX);
184 Analyze->Draw(temp.c_str());
185 h->SetLineColor(Lcolor);
186 h->SetFillColor(Fcolor);
187 h->SetLineStyle(Lstyle);
188 h->SetLineWidth(width);
189 if(Log)gPad->SetLogy();
190 if(h->Integral()!=0)h->Scale(1*Scale);
191 return h;
192}
193
194
195TH1F * MakeNormTH1FSum(Int_t numBin,Float_t minX,Float_t maxX,TTree * analyze1,TTree * analyze2,TTree * analyze3,
196string * histo,float * weight, Int_t Lcolor, Int_t Fcolor, Int_t Lstyle,Int_t width=2,bool Log=false)
197{
198
199 TTree *analyse[3]={analyze1,analyze2,analyze3};
200 TH1F *hq = new TH1F("hq","pt_lept ",numBin,minX,maxX);
201
202 for(unsigned int i=0; i<3; i++)
203 {
204 string temp = histo[i];
205 string nom = histo[i].erase(0,histo[i].find(">>")+2);
206 TH1F *h = new TH1F(nom.c_str(),"pt_lept ",numBin,minX,maxX);
207 analyse[i]->Draw(temp.c_str());
208 h->Scale(weight[i]);
209 hq->Add(h);
210 }
211
212 hq->SetLineColor(Lcolor);
213 hq->SetFillColor(Fcolor);
214 hq->SetLineStyle(Lstyle);
215 hq->SetLineWidth(width);
216 if(Log)gPad->SetLogy();
217 if(hq->Integral()!=0)hq->Scale(1./hq->Integral());
218
219 return hq;
220}
221
222TH1F * HiggsMakeNormTH1FSum(Int_t numBin,Float_t minX,Float_t maxX,TTree * analyze1,TTree * analyze2,TTree * analyze3,
223string * histo,float * weight, Int_t Lcolor, Int_t Fcolor, Int_t Lstyle,Int_t width=2,bool Log=false)
224{
225
226 TTree *analyse[3]={analyze1,analyze2,analyze3};
227 TH1F *hq = new TH1F("hq","pt_lept ",numBin,minX,maxX);
228
229 for(unsigned int i=0; i<3; i++)
230 {
231 string temp = histo[i];
232 string nom = histo[i].erase(0,histo[i].find(">>")+2);
233 TH1F *h = new TH1F(nom.c_str(),"pt_lept ",numBin,minX,maxX);
234 analyse[i]->Draw(temp.c_str());
235 h->Scale(weight[i]);
236 hq->Add(h);
237 }
238
239 hq->SetLineColor(Lcolor);
240 hq->SetFillColor(Fcolor);
241 hq->SetLineStyle(Lstyle);
242 hq->SetLineWidth(width);
243 if(Log)gPad->SetLogy();
244 if(hq->Integral()!=0)hq->Scale(1./hq->Integral());
245
246 return hq;
247}
248
249
250#endif
Note: See TracBrowser for help on using the repository browser.