[17] | 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 |
|
---|
| 30 | using namespace std;
|
---|
| 31 |
|
---|
| 32 | TPaveText * 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 |
|
---|
| 47 | TLegend * 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 |
|
---|
| 58 | TH1F * 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 |
|
---|
[27] | 74 | void GaussValues(TTree * Analyze,string histo,double &rms, double &mean, string min,string max)
|
---|
[17] | 75 | {
|
---|
| 76 | string temp = histo;
|
---|
| 77 | string mintemp = min;
|
---|
| 78 | string maxtemp = max;
|
---|
| 79 |
|
---|
| 80 | string nom = histo.erase(0,histo.find(">>")+2);
|
---|
[153] | 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()-2*h->GetRMS());
|
---|
| 87 | double RangMax = (h->GetMean()+2*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]");
|
---|
| 99 | Gauss->Delete();
|
---|
| 100 | }
|
---|
[27] | 101 |
|
---|
[153] | 102 | void GaussValuesElec(TTree * Analyze,string histo,double &rms, double &mean, string min,string max)
|
---|
| 103 | {
|
---|
| 104 | string temp = histo;
|
---|
| 105 | string mintemp = min;
|
---|
| 106 | string maxtemp = max;
|
---|
| 107 |
|
---|
| 108 | string nom = histo.erase(0,histo.find(">>")+2);
|
---|
| 109 | TH1F *h = new TH1F(nom.c_str(),"",20,-1,3);
|
---|
[27] | 110 | string all = min + " && " + max;
|
---|
| 111 | Analyze->Draw(temp.c_str(),all.c_str());
|
---|
[17] | 112 | h->SetMarkerSize(0.6);
|
---|
[23] | 113 | double MeanFix = h->GetMean();
|
---|
[153] | 114 | TF1 *Gauss = new TF1("Gauss","gaus",-0.5,1.5);
|
---|
[23] | 115 | Gauss->FixParameter(1,MeanFix);
|
---|
[39] | 116 | h->Fit("Gauss","QR");
|
---|
| 117 | h->Fit("Gauss","QRI");
|
---|
| 118 | h->Fit("Gauss","QRI");
|
---|
[17] | 119 | Double_t* params = Gauss->GetParameters();
|
---|
| 120 | rms=params[2];
|
---|
[153] | 121 | //mean= MeanFix;
|
---|
[17] | 122 | mean=params[1];
|
---|
| 123 | h->Draw("P");
|
---|
| 124 | h->GetXaxis()->SetTitle("E_{T}^{rec}/E_{T}^{MC} [GeV]");
|
---|
[153] | 125 | Gauss->Delete();
|
---|
| 126 | }
|
---|
[27] | 127 |
|
---|
[17] | 128 |
|
---|
[153] | 129 |
|
---|
[39] | 130 | void GaussValuesETmis(TTree * Analyze,string histo,double &rms, string min,string max)
|
---|
[27] | 131 | {
|
---|
| 132 | string temp = histo;
|
---|
| 133 | string mintemp = min;
|
---|
| 134 | string maxtemp = max;
|
---|
| 135 |
|
---|
| 136 | string nom = histo.erase(0,histo.find(">>")+2);
|
---|
[153] | 137 | TH1F *h = new TH1F(nom.c_str(),"",50,-50,50);
|
---|
[27] | 138 |
|
---|
| 139 | string all = min + " && " + max;
|
---|
| 140 | Analyze->Draw(temp.c_str(),all.c_str());
|
---|
| 141 | h->SetMarkerSize(0.6);
|
---|
[153] | 142 | double RangMin = (h->GetMean()-2*h->GetRMS());
|
---|
| 143 | double RangMax = (h->GetMean()+2*h->GetRMS());
|
---|
| 144 | //TF1 *Gauss = new TF1("Gauss","gaus");
|
---|
[27] | 145 | TF1 *Gauss = new TF1("Gauss","gaus",RangMin,RangMax);
|
---|
[39] | 146 | //TF1 *Gauss = new TF1("Gauss","gaus");
|
---|
| 147 | h->Fit("Gauss","QR");
|
---|
| 148 | h->Fit("Gauss","QRI");
|
---|
| 149 | h->Fit("Gauss","QRI");
|
---|
[27] | 150 | Double_t* params = Gauss->GetParameters();
|
---|
| 151 | rms=params[2];
|
---|
[39] | 152 | //rms=h->GetRMS();
|
---|
| 153 | //mean=params[1];
|
---|
[27] | 154 | h->Draw("P");
|
---|
| 155 | h->GetXaxis()->SetTitle("E_{T}^{rec}-E_{T}^{MC} [GeV]");
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 |
|
---|
[17] | 159 | TH1F * 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)
|
---|
| 160 | {
|
---|
| 161 | string temp = histo;
|
---|
| 162 | string nom = histo.erase(0,histo.find(">>")+2);
|
---|
| 163 | TH1F *h = new TH1F(nom.c_str(),"pt_lept ",numBin,minX,maxX);
|
---|
| 164 | Analyze->Draw(temp.c_str());
|
---|
| 165 | h->SetLineColor(Lcolor);
|
---|
| 166 | h->SetFillColor(Fcolor);
|
---|
| 167 | h->SetLineStyle(Lstyle);
|
---|
| 168 | h->SetLineWidth(width);
|
---|
| 169 | if(Log)gPad->SetLogy();
|
---|
| 170 | if(h->Integral()!=0)h->Scale(1*Scale);
|
---|
| 171 | return h;
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | TH1F * MakeNormTH1FSum(Int_t numBin,Float_t minX,Float_t maxX,TTree * analyze1,TTree * analyze2,TTree * analyze3,
|
---|
| 176 | string * histo,float * weight, Int_t Lcolor, Int_t Fcolor, Int_t Lstyle,Int_t width=2,bool Log=false)
|
---|
| 177 | {
|
---|
| 178 |
|
---|
| 179 | TTree *analyse[3]={analyze1,analyze2,analyze3};
|
---|
| 180 | TH1F *hq = new TH1F("hq","pt_lept ",numBin,minX,maxX);
|
---|
| 181 |
|
---|
| 182 | for(unsigned int i=0; i<3; i++)
|
---|
| 183 | {
|
---|
| 184 | string temp = histo[i];
|
---|
| 185 | string nom = histo[i].erase(0,histo[i].find(">>")+2);
|
---|
| 186 | TH1F *h = new TH1F(nom.c_str(),"pt_lept ",numBin,minX,maxX);
|
---|
| 187 | analyse[i]->Draw(temp.c_str());
|
---|
| 188 | h->Scale(weight[i]);
|
---|
| 189 | hq->Add(h);
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | hq->SetLineColor(Lcolor);
|
---|
| 193 | hq->SetFillColor(Fcolor);
|
---|
| 194 | hq->SetLineStyle(Lstyle);
|
---|
| 195 | hq->SetLineWidth(width);
|
---|
| 196 | if(Log)gPad->SetLogy();
|
---|
| 197 | if(hq->Integral()!=0)hq->Scale(1./hq->Integral());
|
---|
| 198 |
|
---|
| 199 | return hq;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | TH1F * HiggsMakeNormTH1FSum(Int_t numBin,Float_t minX,Float_t maxX,TTree * analyze1,TTree * analyze2,TTree * analyze3,
|
---|
| 203 | string * histo,float * weight, Int_t Lcolor, Int_t Fcolor, Int_t Lstyle,Int_t width=2,bool Log=false)
|
---|
| 204 | {
|
---|
| 205 |
|
---|
| 206 | TTree *analyse[3]={analyze1,analyze2,analyze3};
|
---|
| 207 | TH1F *hq = new TH1F("hq","pt_lept ",numBin,minX,maxX);
|
---|
| 208 |
|
---|
| 209 | for(unsigned int i=0; i<3; i++)
|
---|
| 210 | {
|
---|
| 211 | string temp = histo[i];
|
---|
| 212 | string nom = histo[i].erase(0,histo[i].find(">>")+2);
|
---|
| 213 | TH1F *h = new TH1F(nom.c_str(),"pt_lept ",numBin,minX,maxX);
|
---|
| 214 | analyse[i]->Draw(temp.c_str());
|
---|
| 215 | h->Scale(weight[i]);
|
---|
| 216 | hq->Add(h);
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 | hq->SetLineColor(Lcolor);
|
---|
| 220 | hq->SetFillColor(Fcolor);
|
---|
| 221 | hq->SetLineStyle(Lstyle);
|
---|
| 222 | hq->SetLineWidth(width);
|
---|
| 223 | if(Log)gPad->SetLogy();
|
---|
| 224 | if(hq->Integral()!=0)hq->Scale(1./hq->Integral());
|
---|
| 225 |
|
---|
| 226 | return hq;
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 |
|
---|
| 230 | #endif
|
---|