Fork me on GitHub

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

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

Jet resol OK

File size: 5.5 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(),"",200,0,3);
82
83 string all = min + " && " + max;
84 Analyze->Draw(temp.c_str(),all.c_str());
85 h->SetMarkerSize(0.6);
86// double MeanFix = ;
87 double MeanFix = h->GetMean();
88 double RangMin = h->GetMean()-h->GetRMS();
89 double RangMax = h->GetMean()+h->GetRMS();
90 TF1 *Gauss = new TF1("Gauss","gaus",RangMin,RangMax);
91 Gauss->FixParameter(1,MeanFix);
92 h->Fit("Gauss","R");
93 h->Fit("Gauss","RI");
94 h->Fit("Gauss","RI");
95 Double_t* params = Gauss->GetParameters();
96 rms=params[2];
97 mean=params[1];
98 h->Draw("P");
99 h->GetXaxis()->SetTitle("E_{T}^{rec}/E_{T}^{MC} [GeV]");
100Gauss->Delete();
101
102}
103
104void GaussValuesETmis(TTree * Analyze,string histo,double &rms, double &mean, string min,string max)
105{
106 string temp = histo;
107 string mintemp = min;
108 string maxtemp = max;
109
110 string nom = histo.erase(0,histo.find(">>")+2);
111 TH1F *h = new TH1F(nom.c_str(),"",50,-300,300);
112
113 string all = min + " && " + max;
114 Analyze->Draw(temp.c_str(),all.c_str());
115 h->SetMarkerSize(0.6);
116 double RangMin = h->GetMean()-h->GetRMS();
117 double RangMax = h->GetMean()+h->GetRMS();
118 TF1 *Gauss = new TF1("Gauss","gaus",RangMin,RangMax);
119 h->Fit("Gauss","R");
120 h->Fit("Gauss","RI");
121 h->Fit("Gauss","RI");
122 Double_t* params = Gauss->GetParameters();
123 rms=params[2];
124 mean=params[1];
125 h->Draw("P");
126 h->GetXaxis()->SetTitle("E_{T}^{rec}-E_{T}^{MC} [GeV]");
127}
128
129
130TH1F * 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)
131{
132 string temp = histo;
133 string nom = histo.erase(0,histo.find(">>")+2);
134 TH1F *h = new TH1F(nom.c_str(),"pt_lept ",numBin,minX,maxX);
135 Analyze->Draw(temp.c_str());
136 h->SetLineColor(Lcolor);
137 h->SetFillColor(Fcolor);
138 h->SetLineStyle(Lstyle);
139 h->SetLineWidth(width);
140 if(Log)gPad->SetLogy();
141 if(h->Integral()!=0)h->Scale(1*Scale);
142 return h;
143}
144
145
146TH1F * MakeNormTH1FSum(Int_t numBin,Float_t minX,Float_t maxX,TTree * analyze1,TTree * analyze2,TTree * analyze3,
147string * histo,float * weight, Int_t Lcolor, Int_t Fcolor, Int_t Lstyle,Int_t width=2,bool Log=false)
148{
149
150 TTree *analyse[3]={analyze1,analyze2,analyze3};
151 TH1F *hq = new TH1F("hq","pt_lept ",numBin,minX,maxX);
152
153 for(unsigned int i=0; i<3; i++)
154 {
155 string temp = histo[i];
156 string nom = histo[i].erase(0,histo[i].find(">>")+2);
157 TH1F *h = new TH1F(nom.c_str(),"pt_lept ",numBin,minX,maxX);
158 analyse[i]->Draw(temp.c_str());
159 h->Scale(weight[i]);
160 hq->Add(h);
161 }
162
163 hq->SetLineColor(Lcolor);
164 hq->SetFillColor(Fcolor);
165 hq->SetLineStyle(Lstyle);
166 hq->SetLineWidth(width);
167 if(Log)gPad->SetLogy();
168 if(hq->Integral()!=0)hq->Scale(1./hq->Integral());
169
170 return hq;
171}
172
173TH1F * HiggsMakeNormTH1FSum(Int_t numBin,Float_t minX,Float_t maxX,TTree * analyze1,TTree * analyze2,TTree * analyze3,
174string * histo,float * weight, Int_t Lcolor, Int_t Fcolor, Int_t Lstyle,Int_t width=2,bool Log=false)
175{
176
177 TTree *analyse[3]={analyze1,analyze2,analyze3};
178 TH1F *hq = new TH1F("hq","pt_lept ",numBin,minX,maxX);
179
180 for(unsigned int i=0; i<3; i++)
181 {
182 string temp = histo[i];
183 string nom = histo[i].erase(0,histo[i].find(">>")+2);
184 TH1F *h = new TH1F(nom.c_str(),"pt_lept ",numBin,minX,maxX);
185 analyse[i]->Draw(temp.c_str());
186 h->Scale(weight[i]);
187 hq->Add(h);
188 }
189
190 hq->SetLineColor(Lcolor);
191 hq->SetFillColor(Fcolor);
192 hq->SetLineStyle(Lstyle);
193 hq->SetLineWidth(width);
194 if(Log)gPad->SetLogy();
195 if(hq->Integral()!=0)hq->Scale(1./hq->Integral());
196
197 return hq;
198}
199
200
201#endif
Note: See TracBrowser for help on using the repository browser.