From 17241a4d6682b68988767f7d3e3bcfed4d59785e Mon Sep 17 00:00:00 2001 From: Namitha Suresh Date: Thu, 21 Jul 2016 13:58:55 +0200 Subject: [PATCH] Btag efficiency analysis --- Analysis/Objects/bin/BtagEffAnalysis.C | 122 ++++ Analysis/Objects/bin/Hists_after_adding.C | 119 ++++ Analysis/Objects/btagEff/customFitSpline.C | 589 ++++++++++++++++ Analysis/Tools/bin/AnalysisJetsBtagEff.cc | 174 ++++- Analysis/Tools/bin/proj.C | 397 +++++++++++ Analysis/Tools/bin/proj_flavour.C | 760 +++++++++++++++++++++ 6 files changed, 2141 insertions(+), 20 deletions(-) create mode 100644 Analysis/Objects/bin/BtagEffAnalysis.C create mode 100644 Analysis/Objects/bin/Hists_after_adding.C create mode 100644 Analysis/Objects/btagEff/customFitSpline.C create mode 100644 Analysis/Tools/bin/proj.C create mode 100644 Analysis/Tools/bin/proj_flavour.C diff --git a/Analysis/Objects/bin/BtagEffAnalysis.C b/Analysis/Objects/bin/BtagEffAnalysis.C new file mode 100644 index 0000000..2a7c90a --- /dev/null +++ b/Analysis/Objects/bin/BtagEffAnalysis.C @@ -0,0 +1,122 @@ +void BtagEffAnalysis() +{ + TFile * f[13]; + + + f[0] = new TFile("50 to 80.root", "READ"); + f[1] = new TFile("80 to 120.root", "READ"); + f[2] = new TFile("120 to 170.root" , "READ"); + f[3] = new TFile("170 to 300.root" , "READ"); + f[4] = new TFile("300 to 470.root" , "READ"); + f[5] = new TFile("470 to 600.root" , "READ"); + f[6] = new TFile("600 to 800.root" , "READ"); + f[7] = new TFile("800 to 1000.root" , "READ"); + f[8] = new TFile("1000 to 1400.root" , "READ"); + f[9] = new TFile("1400 to 1800.root" , "READ"); + f[10] = new TFile("1800 to 2400.root" , "READ"); + f[11] = new TFile("2400 to 3200.root" , "READ"); + f[12] = new TFile("3200 to inf.root" , "READ"); + + std::string flavour[5] = {"b","c","l","bb","cc"}; + std::string jet[3] = {"jet","jet1","jet2"}; + + std::map > h2_total; + std::map > h2_wp; + std::map > h2_eff; + + std::map > h_pt_total[6]; + std::map > h_pt_wp[6]; + std::map > g_pt_eff[6]; + + + std::map g[6]; + + // READING HISTOGRAMS FROM FILES AND ADDING THEM + for ( int i = 0; i < 13 ; ++i ) // loop on files + { + for ( int j = 0 ; j < 5 ; ++j ) // loop on flavours + { + for ( int k = 0; k < 3; ++k ) // loop on jet rank + { + std::string type = flavour[j]+jet[k]; + if ( i == 0 ) + { + h2_total[flavour[j]][jet[k]] = (TH2F*)f[i]->Get(Form("h_%s_pt_eta",type.c_str())); + h2_wp[flavour[j]][jet[k]] = (TH2F*)f[i]->Get(Form("h_%s_pt_eta_wp",type.c_str())); + + + } + + + else + { + h2_total[flavour[j]][jet[k]] -> Add((TH2F*)f[i]->Get(Form("h_%s_pt_eta",type.c_str()))); + h2_wp[flavour[j]][jet[k]] -> Add((TH2F*)f[i]->Get(Form("h_%s_pt_eta_wp",type.c_str()))); + + + } + + } + } + } + + TFile *newFile = new TFile("final_extended.root","RECREATE"); + + // 2D EFFICIENCIES AND PT PROJECTIONS AND EFFICIENCIES + for ( int j = 0 ; j < 5 ; ++j ) // loop on flavours + { + for ( int k = 0; k < 3; ++k ) // loop on jet rank + { + // 2D efficiencies + std::string type = flavour[j]+jet[k]; + + h2_eff[flavour[j]][jet[k]]= (TH2F*) h2_wp[flavour[j]][jet[k]]-> Clone(Form("h_eff_%s",type.c_str())); + h2_eff[flavour[j]][jet[k]] -> Divide(h2_total[flavour[j]][jet[k]]); + + h2_eff[flavour[j]][jet[k]] -> Write(); + + + // pt distribution projections in bins of eta ( 5 bins) and corresponding efficiencies + int bin[2] = {0,-1}; // means project all eta bins; will be index 0 + for ( int l = 0; l < 6; ++l ) // eta bins + { + if ( l != 0 ) + { + bin[0] = l; + bin[1] = l; + } + + + h_pt_total[l][flavour[j]][jet[k]] = h2_total[flavour[j]][jet[k]]-> ProjectionX(Form("h_pt_total_%s_eta%i",type.c_str(),bin[0]),bin[0],bin[1],"e"); + h_pt_wp [l] [flavour[j]][jet[k]] = h2_wp [flavour[j]] [jet[k]]-> ProjectionX(Form("h_pt_wp_%s_eta%i", type.c_str(),bin[0]),bin[0],bin[1],"e"); + g_pt_eff [l][flavour[j]] [jet[k]] = new TGraphAsymmErrors(h_pt_wp[l][flavour[j]][jet[k]],h_pt_total[l][flavour[j]][jet[k]],"cl=0.683 b(1,1) mode"); + + } + } + } + + + + for ( int j=0 ; j < 5 ; ++j) + { + for ( int l = 0; l < 6; ++l) + { + + std::string type = flavour[j]; + g[l][flavour[j]] = new TMultiGraph(Form("%s_jet_bin%i",type.c_str(),l),Form("%s_jet_bin%i",type.c_str(),l)); + g[l][flavour[j]] -> Add(g_pt_eff[l][flavour[j]]["jet1"]); + g[l][flavour[j]] -> Add(g_pt_eff[l][flavour[j]]["jet2"]); + g_pt_eff[l][flavour[j]]["jet2"]->SetLineColor(kRed); + + g[l][flavour[j]] -> Write(); + } + + } + + newFile->Close(); + + return; +// h_pt_total[0]["c"]["jet1"] -> Draw(); +// h_pt_wp[0]["c"]["jet1"] -> Draw("same"); + +} diff --git a/Analysis/Objects/bin/Hists_after_adding.C b/Analysis/Objects/bin/Hists_after_adding.C new file mode 100644 index 0000000..19799ad --- /dev/null +++ b/Analysis/Objects/bin/Hists_after_adding.C @@ -0,0 +1,119 @@ +void Hists_after_adding() +{ + TFile * f[13]; + + + f[0] = new TFile("50 to 80.root", "READ"); + f[1] = new TFile("80 to 120.root", "READ"); + f[2] = new TFile("120 to 170.root" , "READ"); + f[3] = new TFile("170 to 300.root" , "READ"); + f[4] = new TFile("300 to 470.root" , "READ"); + f[5] = new TFile("470 to 600.root" , "READ"); + f[6] = new TFile("600 to 800.root" , "READ"); + f[7] = new TFile("800 to 1000.root" , "READ"); + f[8] = new TFile("1000 to 1400.root" , "READ"); + f[9] = new TFile("1400 to 1800.root" , "READ"); + f[10] = new TFile("1800 to 2400.root" , "READ"); + f[11] = new TFile("2400 to 3200.root" , "READ"); + f[12] = new TFile("3200 to inf.root" , "READ"); + + std::string flavour[5] = {"b","c","l","bb","cc"}; + std::string jet[1] = {"jet"}; + + std::map > h2_total; + std::map > h2_wp; + std::map > h2_eff; + std::map > h_eff; + + std::map > h_pt_total[6]; + std::map > h_pt_wp[6]; + std::map > g_pt_eff[6]; + std::map g[6]; + + // READING HISTOGRAMS FROM FILES AND ADDING THEM + + TFile *file = new TFile("final_extended_delR0.3.root","RECREATE"); + + + for ( int j = 0 ; j < 5 ; ++j ) // loop on flavours // h2_total["b"]["jet"] = (TH2F*) f[i] -> Get("h_bjet_pt_eta" ); + { // h2_total["b"]["jet1"] = (TH2F*) f[i] -> Get("h_bjet1_pt_eta" ); + for ( int k = 0; k < 1; ++k ) // loop on jet rank // h2_total["b"]["jet2"] = (TH2F*) f[i] -> Get("h_bjet2_pt_eta" ); + { // h2_total["c"]["jet"] = (TH2F*) f[i] -> Get("h_cjet_pt_eta" ); + for ( int i = 0; i < 13 ; ++i ) // loop on files + { + std::string type = flavour[j]+jet[k]; // h2_total["c"]["jet1"] = (TH2F*) f[i] -> Get("h_cjet1_pt_eta" ); + if ( i == 0 ) // h2_total["c"]["jet2"] = (TH2F*) f[i] -> Get("h_cjet2_pt_eta" ); + { // h2_total["l"]["jet"] = (TH2F*) f[i] -> Get("h_ljet_pt_eta" ); + h2_total[flavour[j]][jet[k]] = (TH2F*)f[i]->Get(Form("h_%s_pt_eta",type.c_str())); // h2_total["l"]["jet1"] = (TH2F*) f[i] -> Get("h_ljet1_pt_eta" ); + h2_wp[flavour[j]][jet[k]] = (TH2F*)f[i]->Get(Form("h_%s_pt_eta_wp",type.c_str())); // h2_total["l"]["jet2"] = (TH2F*) f[i] -> Get("h_ljet2_pt_eta" ); + } // h2_total["bb"]["jet"] = (TH2F*) f[i] -> Get("h_bbjet_pt_eta" ); + else // h2_total["bb"]["jet1"] = (TH2F*) f[i] -> Get("h_bbjet1_pt_eta"); + { // h2_total["bb"]["jet2"] = (TH2F*) f[i] -> Get("h_bbjet2_pt_eta"); + h2_total[flavour[j]][jet[k]] -> Add((TH2F*)f[i]->Get(Form("h_%s_pt_eta",type.c_str()))); // h2_total["cc"]["jet"] = (TH2F*) f[i] -> Get("h_ccjet_pt_eta" ); + h2_wp[flavour[j]][jet[k]] -> Add((TH2F*)f[i]->Get(Form("h_%s_pt_eta_wp",type.c_str()))); // h2_total["cc"]["jet1"] = (TH2F*) f[i] -> Get("h_ccjet1_pt_eta"); + } + } + h2_total[flavour[j]][jet[k]] ->Write(); + h2_wp[flavour[j]][jet[k]] -> Write(); // h2_total["cc"]["jet2"] = (TH2F*) f[i] -> Get("h_ccjet2_pt_eta"); + } // ------ + } // And the same for h2_wp + + + + + + + + // 2D EFFICIENCIES AND PT PROJECTIONS AND EFFICIENCIES + for ( int j = 0 ; j < 5 ; ++j ) // loop on flavours + { + for ( int k = 0; k < 1; ++k ) // loop on jet rank + { + // 2D efficiencies + std::string type = flavour[j]+jet[k]; + h2_eff[flavour[j]][jet[k]]= (TH2F*) h2_wp[flavour[j]][jet[k]]-> Clone(Form("h_%s_eff_pt_eta",type.c_str())); + h2_eff[flavour[j]][jet[k]] -> Divide(h2_total[flavour[j]][jet[k]]); + // pt distribution projections in bins of eta ( 5 bins) and corresponding efficiencies + h2_eff[flavour[j]][jet[k]] -> Write(); + int bin[2] = {0,-1}; // means project all eta bins; will be index 0 + for ( int l = 0; l < 6; ++l ) // eta bins + { + if ( l != 0 ) + { + bin[0] = l; + bin[1] = l; + } + h_pt_total[l][flavour[j]][jet[k]] = h2_total[flavour[j]][jet[k]]-> ProjectionX(Form("h_pt_total_%s_eta%i",type.c_str(),bin[0]),bin[0],bin[1],"e"); + h_pt_wp [l][flavour[j]][jet[k]] = h2_wp [flavour[j]] [jet[k]]-> ProjectionX(Form("h_pt_wp_%s_eta%i", type.c_str(),bin[0]),bin[0],bin[1],"e"); + g_pt_eff [l][flavour[j]] [jet[k]] = new TGraphAsymmErrors(h_pt_wp[l][flavour[j]][jet[k]],h_pt_total[l][flavour[j]][jet[k]],"cl=0.683 b(1,1) mode"); + } + } + } + + file->Close(); + +// TFile *newFile = new TFile("all_files_hadron.root","RECREATE"); +// +// for ( int j=0 ; j < 3 ; ++j) +// { +// for ( int l = 0; l < 6; ++l) +// { +// std::string type = flavour[j]; +// g[l][flavour[j]] = new TMultiGraph(Form("%s_jet_bin%i",type.c_str(),l),Form("%s_jet_bin%i",type.c_str(),l)); +// g[l][flavour[j]] -> Add(g_pt_eff[l][flavour[j]]["jet1"]); +// g[l][flavour[j]] -> Add(g_pt_eff[l][flavour[j]]["jet2"]); +// g_pt_eff[l][flavour[j]]["jet2"]->SetLineColor(kRed); +// +// +// +// g[l][flavour[j]]-> Write(); +// } +// } +// +// newFile->Close(); + + return; +// h_pt_total[0]["c"]["jet1"] -> Draw(); +// h_pt_wp[0]["c"]["jet1"] -> Draw("same"); + +} diff --git a/Analysis/Objects/btagEff/customFitSpline.C b/Analysis/Objects/btagEff/customFitSpline.C new file mode 100644 index 0000000..245a099 --- /dev/null +++ b/Analysis/Objects/btagEff/customFitSpline.C @@ -0,0 +1,589 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class splineFitter; +splineFitter* gSplineFitter; // pointer needs to be global, to be called in fcn + +// polynomial degree is an overall constant +int theDegree = 3; +int theSplineNumber = 0; + + +void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag); // declaration is needed in splineFitter + +class splineFitter { + +public: + TH1D* data; + int fitLow; + int fitHigh; + double lambda; // weight for penalty term + double fitChi2; + int fitNdf; + int fitStat; + TMinuit* theMinuit; + double* nodes; + int numberOfNodes; + splineFitter(TH1D* theData,double theLambda=0) { + data = theData; + lambda= theLambda; + fitLow = -1; + fitHigh = -1; + + fitLow = 1; // TH convention, count from 1...nbins + fitHigh = theData->GetNbinsX(); + theMinuit = NULL; + nodes = NULL; + numberOfNodes = 0; + } + ~splineFitter() { + std::cout << "SplineFitter destructor called " << std::endl; + if (theMinuit != NULL) delete theMinuit; + std::cout << "SplineFitter destructor done " << std::endl; + } + void SetRangeX(int theLow,int theHigh) { + fitLow = theLow; + fitHigh = theHigh; + } + void SetKnots(const double* theNodes) { + numberOfNodes = 0; + for (int iKnot=0; iKnot<999; ++iKnot) { + if (theNodes[iKnot] == -1) break; + if (theNodes[iKnot] <-10000) break; + if (theNodes[iKnot] >10000) break; + ++numberOfNodes; + } + std::cout << "The number of knots is: " << numberOfNodes << std::endl; + nodes = new double[numberOfNodes]; + for (int iKnot=0; iKnotGetSum() / data->GetNbinsX(); + return M; + } + void GetResult(int iPar, double& theValue, double& theError){ + // parameter numbering from zero + double value; + double error; + int getpar = theMinuit->GetParameter(iPar,value,error); + theValue = value; + theError = error; + }; + Double_t GetParameter(int iPar){ + // parameter numbering from zero + double value; + double error; + int getpar = theMinuit->GetParameter(iPar,value,error); + return value; + }; + double GetLambda() { + return lambda; + }; + double GetChisquare() { + return fitChi2; + }; + int GetNDF() { + return fitNdf; + }; + double GetProb() { + return TMath::Prob(fitChi2,fitNdf); + }; + + TMatrixDSym & GetCovMatrix() { + Int_t npars = theMinuit->GetNumPars(); + TMatrixDSym* _corrMatrix = new TMatrixDSym(npars); + cout<<"External correlation Matrix from TMinuit"<<"\n"; + theMinuit->mnemat(_corrMatrix->GetMatrixArray(),npars ); + for (int i=0;iSetFCN(fcn); + Double_t arglist[10]; + arglist[0] = 1; + Int_t ierflg = 0; + // set error definition to 1 (correct for chi2 fits) + theMinuit->mnexcm("SET ERR",arglist,1,ierflg); + Double_t* vstart = new Double_t[nFitPar]; + Double_t* vstep = new Double_t[nFitPar]; + for (int i=0; imnparm(i,Form("par%d",i),vstart[i],vstep[i],0.,0.,ierflg); + } + +// // tell minuit to use gradient +// arglist[0] = 1; +// arglist[1] = 1; +// theMinuit->mnexcm("SET GRA",arglist,2,ierflg); +#ifdef INIHESSE + arglist[0] = 0; + arglist[1] = 0; + theMinuit->mnexcm("HESSE",arglist,0,ierflg); +#endif + arglist[0] = 50000; + arglist[1] = .1; + theMinuit->mnexcm("MIGRAD",arglist,2,ierflg); + // get statistics from minuit + Double_t fmin; + Double_t fedm; + Double_t errdef; + Int_t npari; + Int_t nparx; + Int_t istat; + theMinuit->mnstat(fmin,fedm,errdef,npari,nparx,istat); + fitChi2 = fmin; + fitNdf = (gSplineFitter->fitHigh - gSplineFitter->fitLow + 1) - npari; + fitStat = istat; + std::cout << " fmin=" << fmin << " fedm=" << fedm << " errdef=" << errdef + << " npari=" << npari << " nparx=" << nparx << " istat=" << istat << std::endl; + std::cout << " ndf=" << fitNdf << std::endl; + +// arglist[0] = 0; +// arglist[1] = 0; +// theMinuit->mnexcm("HESSE",arglist,0,ierflg); + + + return fitStat; + }; +}; + + +Double_t mySpline(Double_t x,int degree,int i) { + double* xKnots = gSplineFitter->GetKnots(); + int nKnots = gSplineFitter->GetNKnots(); + if (i < 0 || i>=(nKnots-1)) { + std::cout << "mySpline: bad spline number " << i << endl; + return -1; + } + if (degree == 0) { + if (x >= xKnots[i] && x < xKnots[i+1]) { +// std::cout << "mySpline called for x=" << x << " Degree " << degree << " piece " << i +// << " return 1" << std::endl; + return 1; + } else { +// std::cout << "mySpline called for x=" << x << " Degree " << degree << " piece " << i +// << " return 0" << std::endl; + return 0; + } + } else { + // recursion + int p = degree; + Double_t Spl1 = mySpline(x,p-1,i); + Double_t Spl2 = mySpline(x,p-1,i+1); + Double_t fac1 = (x - xKnots[i]) / (xKnots[i+p] - xKnots[i]); + Double_t fac2 = (xKnots[i+p+1] - x) / (xKnots[i+p+1] - xKnots[i+1]); +// std::cout << "Spl1 =" << Spl1 << " Spl2 =" << Spl2 +// << " fac1 =" << fac1 << " fac2 =" << fac2 << std::endl; + Double_t Nip = fac1 * Spl1 + fac2 * Spl2; +// std::cout << "mySpline called for x=" << x << " Degree " << degree << " piece " << i +// << " return " << Nip << std::endl; + return Nip; + } + return 0; +} + + +Double_t fitf(Double_t *v, Double_t *par) { + + // the fitting function is a linear combination of b splines + int nSpline = gSplineFitter->GetNKnots()-1-theDegree; + Double_t theFunc = 0; + for (int iSpline=0; iSplineGetMeanBinContent(); + Double_t v[1]; + // loop over the histogram bins + for (int binx=gSplineFitter->fitLow; binx<=gSplineFitter->fitHigh; ++binx) { + double errData = gSplineFitter->GetData()->GetBinError(binx); + if (errData > 0) { + v[0] = gSplineFitter->GetData()->GetBinCenter(binx); + double delta = gSplineFitter->GetData()->GetBinContent(binx) - fitf(v,par); + + chisq += (delta*delta) / (errData * errData); + } + } + // here we should add the penalty term + double penalty = 0; + int nSpline = gSplineFitter->GetNKnots()-1-theDegree; + for (int iSpline=2; iSplineGetLambda() * penalty; + + f = chisq; + + if (iflag == 2) { + // compute derivative + std::cout << "Derivative currently not operational" << std::endl; + } +} + + + + + + + + + + + + + +void customFitSpline() { + + bool writeOut = true; + bool range1TeV = false; + + // create new canvas + TCanvas* tabcan = new TCanvas ("cg1","mycanvas",10,10,800,600); + gStyle->SetPadColor(0); + tabcan->SetFillColor(0); + + + string flav[5] = {"b","c","l","bb","cc"}; + gStyle->SetPadColor(0); + // open Root file +// TFile*f = TFile::Open("/afs/desy.de/group/cms/mssmhbb/CommonFiles/OfflineBtagEff/v127/btagefficiencies_v127_mediummass.root"); + TFile*f = TFile::Open("final_extended.root"); + + // pointers to Root files + + // just for the stupidity of CINT which cannot handle const array sizes + + const int nfl = 5; + const int neta = 5; + + int nbinsPt = 40; + double maxPt = 2000.; + if (range1TeV) { + nbinsPt = 50; + maxPt = 1000.; + } + + TH2D** hEff = new TH2D*[nfl]; + TH1D*** hEffPt = new TH1D**[nfl]; + for (int ifl=0; iflGet(Form("h_%sjet_eff_pt_eta",flav[ifl].c_str())); + //hEff[ifl]->Draw("LEGO2"); + //gPad->Print(Form("pteta_CSVT_%s_eff.png",flav[ifl].c_str())); + + // loop over eta bins + for (int ieta=0; ietaProjectionX(Form("h_%sjet_eff_etabin%d",flav[ifl].c_str(),ieta),ieta+1,ieta+1,""); + hEffPt[ifl][ieta]->SetMarkerStyle(20); + hEffPt[ifl][ieta]->SetStats(0); + hEffPt[ifl][ieta]->GetXaxis()->SetRangeUser(0,800); + hEffPt[ifl][ieta]->GetXaxis()->SetTitleOffset(1.1); + hEffPt[ifl][ieta]->GetYaxis()->SetTitle("#epsilon_{btag}"); + hEffPt[ifl][ieta]->GetYaxis()->SetTitleOffset(0.9); + //std::cout << "GetTitleSize=" << hEffPt[ifl][ieta]->GetYaxis()->GetTitleSize() << std::endl; + hEffPt[ifl][ieta]->GetYaxis()->SetTitleSize(0.05); + //hEffPt[ifl][ieta]->Draw("EP1"); + //gPad->Print(Form("pt_CSVT_%s_eff_etabin%d.png",flav[ifl].c_str(),ieta)); + } + } + + // f->Close(); + +#ifdef DODRAW + // just do drawing + TF1 *pfunc = new TF1("pfunc",fitf,0,1000,3); + pfunc->SetParameter(0,0.6); + pfunc->SetParName(0,"Constant"); + + for (int iSplineNumber=0; iSplineNumber<(gSplineFitter->GetNKnots()-1-theDegree); ++iSplineNumber) { + theSplineNumber = iSplineNumber; + pfunc->SetParameter(1,theDegree); + pfunc->SetParName(1,"Degree"); + pfunc->SetParameter(2,iSplineNumber); + pfunc->SetParName(2,"SplineNumber"); + pfunc->SetLineColor(iSplineNumber+2); + if (iSplineNumber>=3) pfunc->SetLineColor(iSplineNumber+3); + //pfunc->Draw(""); + //gPad->Print(Form("pfunc%d.png",iSplineNumber)); + + + if (iSplineNumber == 0) { + pfunc->DrawCopy(""); + } else { + pfunc->DrawCopy("SAME"); + } + } + // pfunc->Draw(); + gPad->Print("pfunc.png"); +#endif + + // create 2D histograms for later plotting + const static int nptbins = 41; + float ptbins[nptbins+1] = {0,5,10,20,40,60,80,100,120,140,160,180,200,220,240,280,320,360,400,430,460,500,520,560,620,680,700,750,850,960,1000,1300,1500,1600,1800,2000,2400,2800,3000,3300,3500,4000}; + const static int netabins = 5; + float etabins[netabins+1] = {0.,0.5,1.0,1.5,2.2,2.4}; + TH2D** hEffSm = new TH2D*[nfl]; + for (int ifl=0; iflGetXaxis()->SetTitle("p_{T} [GeV]"); + hEffSm[ifl]->GetXaxis()->SetRangeUser(0,800); + hEffSm[ifl]->GetYaxis()->SetTitle("#eta"); + hEffSm[ifl]->GetZaxis()->SetTitle("#epsilon_{btag}"); + hEffSm[ifl]->SetStats(0); + hEffSm[ifl]->GetXaxis()->SetTitleOffset(2); + hEffSm[ifl]->GetYaxis()->SetTitleOffset(2); + hEffSm[ifl]->GetZaxis()->SetTitleOffset(1.4); + // hEffSm[ifl]->SetLeftMargin(3); + hEffSm[ifl]->SetStats(0); + } + + for (int ifl=0; iflClone( Form("%s_Fit",hEffPt[ifl][ieta]->GetName()) ); + + hEffPtFit->SetName( Form("%s_Fit",hEffPt[ifl][ieta]->GetName()) ); + hEffPtFit->SetTitle( Form("%s_Fit",hEffPt[ifl][ieta]->GetTitle()) ); + + // set up Minuit fitter + if (flav[ifl] == "c" ) { + gSplineFitter = new splineFitter(hEffPtFit,20); + double k2[] = {0, 10,20,40, 60, 80, 100,120,140, 160,200, 220,260,300, 350,600,800,1100,1500,1900, 2800,3600, -1}; + gSplineFitter->SetKnots( k2 ); + } else if (flav[ifl] == "l") { + gSplineFitter = new splineFitter(hEffPtFit,10); + double k3[] = {0, 10, 20, 40, 60, 80, 110, 130, 200, 300, 400, 600,950,1200,1600, 2000,2600,3000, 4000, -1}; + gSplineFitter->SetKnots( k3 ); + } else if (flav[ifl] == "cc") { + gSplineFitter = new splineFitter(hEffPtFit,10); + double k4[] = {0, 10, 20, 40, 60, 80, 100,120, 150,180, 200, 300, 400, 600,950,1200,1600, 2000,2600,3000, 4000, -1}; + gSplineFitter->SetKnots( k4 ); + } + else { + gSplineFitter = new splineFitter(hEffPtFit,10); + double k1[] = {0, 20, 40, 60, 80, 110,180, 200,240, 320, 400,600,1200,1900,2400, 2800,3400, 4000, -1}; + gSplineFitter->SetKnots( k1 ); + } + + Int_t status = gSplineFitter->Fit(); + cout << " fit status: " << status << endl; + + int nSpline = gSplineFitter->GetNKnots()-1-theDegree; + + // TFitResultPtr r = hEffPtFit->Fit("fit","S"); + + // now determine the smoothed errors + TH1D* hEffPtErr = new TH1D( *hEffPt[ifl][ieta] ); + hEffPtErr->SetName( Form("%s_Errors",hEffPt[ifl][ieta]->GetName()) ); + //hEffPtErr->SetTitle( Form("%s_Errors",hEffPt[ifl][ieta]->GetTitle()) ); + float etamin = ieta*0.5; + float etamax = (ieta+1)*0.5; + + if( ieta == 3) + etamax = 2.2; + + else if ( ieta == 4) + { + etamin = 2.2; + etamax = 2.4; + } + + + hEffPtErr->SetTitle(Form("Offline btag #epsilon, jet flavor %s, %3.1f #leq #eta #leq %3.1f",flav[ifl].c_str(),etamin,etamax)); + + + // get covariance matrix of the fit parameters + TMatrixDSym& cov = gSplineFitter->GetCovMatrix(); // to access the covariance matrix + + // get the fitted parameters + Double_t* par = new Double_t[nSpline]; + for (int ipar=0; iparGetParameter(ipar); + } + + // prepare a dummy vector of parameters + Double_t* upar = new Double_t[nSpline]; + + // prepare a vector for the derivatives + Double_t* deriv = new Double_t[nSpline]; + + // loop over the bins + for (int ibin=0; ibin < hEffPtErr->GetNbinsX(); ++ibin) { + Double_t v[1]; + v[0] = hEffPtErr->GetXaxis()->GetBinCenter(ibin+1); + Double_t fval = fitf( v, par ); + if (fval<0) fval = 0; // do not allow negative efficiencies + hEffPtErr->SetBinContent( ibin+1, fval ); + + // compute the derivatives + for (int ipar=0; ipar0) err = sqrt( eSqr); + hEffPtErr->SetBinError( ibin+1, err ); + + } + + // create function for drawing + TF1 *func = new TF1("fit",fitf,40,1000,nSpline); + for (int ipar=0; iparSetParameter(ipar,par[ipar]); + func->SetParName(ipar,Form("Spline %d",ipar)); + } + + hEffPtErr->SetFillColor(kCyan); + hEffPtErr->SetMarkerStyle(0); + hEffPtErr->GetXaxis()->SetRangeUser(0,800); + hEffPtErr->Draw("E3"); + hEffPt[ifl][ieta]->Draw("EP1,SAME"); // to avoid drawing of function + gPad->Print(Form("Splsmooth_Degree_%d_pt_CSVIVF_%s_etabin%d.png",theDegree,flav[ifl].c_str(),ieta)); + gPad->Print(Form("Splsmooth_Degree_%d_pt_CSVIVF_%s_etabin%d.pdf",theDegree,flav[ifl].c_str(),ieta)); + + hEffPtErr->Draw("E3"); + hEffPtFit->Draw("EP1,SAME"); // this drawing with function + func->Draw("SAME"); + gPad->Print(Form("Splfit_Degree_%d_pt_CSVIVF_%s_etabin%d.png",theDegree,flav[ifl].c_str(),ieta)); + gPad->Print(Form("Splfit_Degree_%d_pt_CSVIVF_%s_etabin%d.pdf",theDegree,flav[ifl].c_str(),ieta)); + + // fill the eta column in the 2D smoothed efficiency histogram + for (int ibin=0; ibin < hEffSm[ifl]->GetNbinsX(); ++ibin) { + hEffSm[ifl]->SetBinContent(ibin+1,ieta+1, func->Eval(hEffSm[ifl]->GetXaxis()->GetBinCenter(ibin+1),0,0)); + hEffSm[ifl]->SetBinError(ibin+1,ieta+1, hEffPtErr->GetBinError( ibin+1 )); + } + } + // draw the 2D histogram + hEffSm[ifl]->Draw("LEGO2"); + gPad->Print(Form("Smooth2D_Lego_%s.png",flav[ifl].c_str())); + gPad->Print(Form("Smooth2D_Lego_%s.pdf",flav[ifl].c_str())); + hEffSm[ifl]->Draw("SURF1"); + gPad->Print(Form("Smooth2D_Surf_%s.png",flav[ifl].c_str())); + gPad->Print(Form("Smooth2D_Surf_%s.pdf",flav[ifl].c_str())); + + // make interpolated 2D histogram + TH2D* hEffInt = new TH2D( Form("EffInt_%s",flav[ifl].c_str()), + Form("%s",flav[ifl].c_str()), + nptbins,ptbins,netabins,etabins); + hEffInt->GetXaxis()->SetTitle("p_{T} [GeV]"); + hEffInt->GetYaxis()->SetTitle("#eta"); + hEffInt->GetZaxis()->SetTitle("#epsilon_{btag}"); + hEffInt->SetStats(0); + hEffInt->GetXaxis()->SetTitleOffset(2); + hEffInt->GetYaxis()->SetTitleOffset(2); + hEffInt->GetZaxis()->SetTitleOffset(1.4); + for (int ibinpt=0; ibinpt < hEffInt->GetNbinsX(); ++ibinpt) { + for (int ibineta=0; ibineta < hEffInt->GetNbinsY(); ++ibineta) { + double thePt = hEffInt->GetXaxis()->GetBinCenter(ibinpt+1); + double theEta = hEffInt->GetYaxis()->GetBinCenter(ibineta+1); + double theInter = hEffSm[ifl]->Interpolate(thePt,theEta); + hEffInt->SetBinContent(ibinpt+1,ibineta+1,theInter); + } + } + double oldPhi = gPad->GetPhi(); + double oldTheta = gPad->GetTheta(); + gPad->SetPhi(310); + hEffInt->Draw("SURF4"); + gPad->Print(Form("Inter2D_Surf_%s.png",flav[ifl].c_str())); + gPad->Print(Form("Inter2D_Surf_%s.pdf",flav[ifl].c_str())); + gPad->SetPhi(oldPhi); + } + + // write out the smoothed btag efficiencies + //f->Close(); + if (writeOut) { + TFile*fout = new TFile("final_extended_smoothed.root","RECREATE"); + for (int ifl=0; iflGetName() ); + hEff[ifl]->Delete(); + hEffSm[ifl]->SetName( theOldName.c_str() ); + hEffSm[ifl]->Write(); + TH2D *h1 = (TH2D*) f->Get(Form("h_%sjet_pt_eta",flav[ifl].c_str())); + TH2D *h2 = (TH2D*) f->Get(Form("h_%sjet_pt_eta_wp",flav[ifl].c_str())); + + h1->Write(); + h2->Write(); + + } + fout->Close(); + f->Close(); + } +} diff --git a/Analysis/Tools/bin/AnalysisJetsBtagEff.cc b/Analysis/Tools/bin/AnalysisJetsBtagEff.cc index 976dce7..3aad5b3 100644 --- a/Analysis/Tools/bin/AnalysisJetsBtagEff.cc +++ b/Analysis/Tools/bin/AnalysisJetsBtagEff.cc @@ -1,11 +1,15 @@ #include #include #include +#include #include "TFile.h" #include "TFileCollection.h" #include "TChain.h" +#include "TCanvas.h" #include "TH1.h" +#include "TH2.h" +#include "TLorentzVector.h" #include "Analysis/Tools/interface/Analysis.h" @@ -17,27 +21,59 @@ using namespace analysis::tools; // ============================================================================================= int main(int argc, char * argv[]) { + TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms // Input files list + std::string inputList = "rootFileList.txt"; Analysis analysis(inputList); - + // Physics Objects Collections analysis.addTree ("Jets","MssmHbb/Events/slimmedJetsReapplyJEC"); // GenParticles (when needed) analysis.addTree ("GenParticles","MssmHbb/Events/prunedGenParticles"); + //Cross-sections + analysis.crossSections("MssmHbb/Metadata/CrossSections"); + //Luminosity + //float lumiScale = analysis.scaleLuminosity(1000.); + // Use external btagging efficiencies - analysis.addBtagEfficiencies("/afs/desy.de/user/w/walsh/cms/analysis/cmssw/dev/CMSSW_7_6_5/src/Analysis/Objects/bin/BtagEfficiencies_btag_csvivf_0.935.root"); + analysis.addBtagEfficiencies("final_extended_delR0.3_smoothed.root"); analysis.btagEfficienciesAlgo("btag_csvivf"); // only needed above a certain commit where this information should be available in the title of the root file above analysis.btagEfficienciesFlavour("Extended"); // only needed above a certain commit where this information should be available in the title of the root file above // Analysis of events std::cout << "This analysis has " << analysis.size() << " events" << std::endl; - for ( int i = 0 ; i < analysis.size() ; ++i ) - { + + const static int nptbins = 41; + float ptbins[nptbins+1] = {0,5,10,20,40,60,80,100,120,140,160,180,200,220,240,280,320,360,400,430,460,500,520,560,620,680,700,750,850,960,1000,1300,1500,1600,1800,2000,2400,2800,3000,3300,3500,4000}; + const static int netabins = 5; + float etabins[netabins+1] = {0.,0.5,1.0,1.5,2.2,2.4}; + + TH2F * hist1b = new TH2F("hist1b" , "jet_w/o_weight_b", nptbins, ptbins, netabins, etabins); + TH2F * hist1c = new TH2F("hist1_c" , "jet_w/o_weight_c", nptbins, ptbins, netabins, etabins); + TH2F * hist1l = new TH2F("hist1_l" , "jet_w/o_weight_l", nptbins, ptbins, netabins, etabins); + TH2F * hist1bb = new TH2F("hist1_bb" , "jet_w/o_weight_bb", nptbins, ptbins, netabins, etabins); + TH2F * hist1cc = new TH2F("hist1_cc" , "jet_w/o_weight_cc", nptbins, ptbins, netabins, etabins); + //TH2F * hist2 = new TH2F("hist2" , "jet2_w/o weight", nptbins, ptbins, netabins, etabins); + TH2F * hist3b = new TH2F("hist3b" , "jet_weighted_b", nptbins, ptbins, netabins, etabins); + TH2F * hist3c = new TH2F("hist3_c" , "jet_weighted_c", nptbins, ptbins, netabins, etabins); + TH2F * hist3l = new TH2F("hist3_l" , "jet_weighted_l", nptbins, ptbins, netabins, etabins); + TH2F * hist3bb = new TH2F("hist3_bb" , "jet_weighted_bb", nptbins, ptbins, netabins, etabins); + TH2F * hist3cc = new TH2F("hist3_cc" , "jet_weighted_cc", nptbins, ptbins, netabins, etabins); + //TH2F * hist4 = new TH2F("hist4" , "jet2_weighted", nptbins, ptbins, netabins, etabins); + + //TH1F * hist5 = new TH1F("hist5", "mass_w/o_weight",12,0,1200); + //TH1F * hist6 = new TH1F("hist6", "mass_weighted",12,0,1200); + + + TFile * newFile = new TFile("histograms_wo_weight_800_to_1000.root" , "RECREATE"); + + for ( int i = 0 ; i < analysis.size() ; ++i ) + { analysis.event(i); std::cout << "++++++ ENTRY " << i << std::endl; @@ -49,25 +85,123 @@ int main(int argc, char * argv[]) jets->btagAlgo("btag_csvivf"); // Needed to use the extended flavour - jets->associatePartons(particles,0.4,5); + jets->associatePartons(particles,0.3,5); - for ( int j = 0 ; j < jets->size() ; ++j ) - { - Jet jet = jets->at(j); - std::cout << " Jet #" << j << ": "; - std::cout << "pT = " << jet.pt() << ", "; - std::cout << "eta = " << jet.eta() << ", "; - std::cout << "phi = " << jet.phi() << ", "; - std::cout << "id loose = " << jet.idLoose() << ", "; - std::cout << "flavour = " << jet.flavour() << ", "; - std::cout << "extFlavour = " << jet.extendedFlavour() << ", "; - std::cout << "btag = " << jet.btag() << std::endl; - std::cout << "efficiency = " << analysis.btagEfficiency(jet) << std::endl; - - } + //std::ofstream output; + //output.open("output_file.txt"); + + if ( jets->size() < 1 ) continue; + Jet jet1 = jets->at(0); + //Jet jet2 = jets->at(1); + + if ( jet1.pt() < 40. ) continue; + if ( (jet1.eta() > 2.2 || jet1.eta() < -2.2) ) continue; + // if ( ((jet1.eta()- jet2.eta()) > 1.6) || ((jet2.eta()-jet1.eta()) > 1.6) ) continue; + //if (jet1.deltaR(jet2) > 1) continue; + +// cout << jet.pt() << " " << jet.eta() << " " << jet.flavour() << endl; + double efficiency1 = analysis.btagEfficiency(jet1,0); + //double efficiency2 = analysis.btagEfficiency(jet2,0); + + // TLorentzVector p1 = jet1.p4(); + //TLorentzVector p2 = jet2.p4(); + // TLorentzVector p12 = p1+p2; + + // double m = p1.M(); + //double m2 = p2.M(); + //double mtot = m1+m2; + + if ( jet1.extendedFlavour() == "b" ) + hist3b->Fill(jet1.pt(),jet1.eta(),efficiency1); + if ( jet1.extendedFlavour() == "c" ) + hist3c->Fill(jet1.pt(),jet1.eta(),efficiency1); + if ( jet1.extendedFlavour() == "udsg" ) + hist3l->Fill(jet1.pt(),jet1.eta(),efficiency1); + if ( jet1.extendedFlavour() == "bb" ) + hist3bb->Fill(jet1.pt(),jet1.eta(),efficiency1); + if ( jet1.extendedFlavour() == "cc" ) + hist3cc->Fill(jet1.pt(),jet1.eta(),efficiency1); + + //hist4->Fill(jet2.pt(),jet2.eta(),(efficiency1*efficiency2)); + + //hist6->Fill(m,efficiency1); + + + + + if ( jet1.btag() < 0.935) continue; + + + if ( jet1.extendedFlavour() == "b" ) + hist1b->Fill(jet1.pt(),jet1.eta()); + if ( jet1.extendedFlavour() == "c" ) + hist1c->Fill(jet1.pt(),jet1.eta()); + if ( jet1.extendedFlavour() == "udsg" ) + hist1l->Fill(jet1.pt(),jet1.eta()); + if ( jet1.extendedFlavour() == "bb" ) + hist1bb->Fill(jet1.pt(),jet1.eta()); + if ( jet1.extendedFlavour() == "cc" ) + hist1cc->Fill(jet1.pt(),jet1.eta()); + // hist2->Fill(jet2.pt() , jet2.eta()); + + //hist5->Fill(m); + + + + + // for ( int j = 0 ; j < jets->size() ; ++j ) + // { + // Jet jet = jets->at(j); +// cout << " Jet #" << j << ": "; +// cout << "pT = " << jet.pt() << ", "; +// cout << "eta = " << jet.eta() << ", "; +// cout << "phi = " << jet.phi() << ", "; +// cout << "id loose = " << jet.idLoose() << ", "; +// cout << "flavour = " << jet.flavour() << ", "; +// cout << "extFlavour = " << jet.extendedFlavour() << ", "; +// cout << "btag = " << jet.btag()<< std::endl; +// cout << "efficiency = " << analysis.btagEfficiency(jet) << std::endl; + +// } + //cout.close(); + + } - + // hist1 -> Scale(lumiScale); + hist1b -> Write(); + hist1c -> Write(); + hist1l -> Write(); + hist1bb -> Write(); + hist1cc -> Write(); + + //hist2 -> Scale(lumiScale); + //hist2 -> Write(); + // hist5 -> Scale(lumiScale); + // hist5 -> GetXaxis() -> SetRangeUser(0,700); + // hist5 -> GetYaxis() -> SetRangeUser(0,1000000); + //hist5 -> Write(); + newFile -> Close(); + + TFile * newFile2 = new TFile("histograms_with_weight_800_to_1000.root", "RECREATE"); + + // hist3 -> Scale(lumiScale); + hist3b -> Write(); + hist3c -> Write(); + hist3l -> Write(); + hist3bb -> Write(); + hist3cc -> Write(); + + //hist4 -> Scale(lumiScale); + //hist4 -> Write(); + //hist6 -> Scale(lumiScale); + //hist6 -> GetXaxis() -> SetRangeUser(0,700); + // hist6 -> GetYaxis() -> SetRangeUser(0,1000000); + //hist6 -> Write(); + + newFile2 -> Close(); + + // } diff --git a/Analysis/Tools/bin/proj.C b/Analysis/Tools/bin/proj.C new file mode 100644 index 0000000..025a6be --- /dev/null +++ b/Analysis/Tools/bin/proj.C @@ -0,0 +1,397 @@ +#include "TH1F.h" +#include "TH2F.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TFile.h" +#include "TRandom3.h" +#include "TTree.h" +#include "TCanvas.h" + +void proj() +{ +TFile *f1[13], *f2[13]; + +f1[0] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_50_to_80.root" , "READ"); +f2[0] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_50_to_80.root", "READ"); +f1[1] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_80_to_120.root" , "READ"); +f2[1] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_80_to_120.root", "READ"); +f1[2] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_120_to_170.root" , "READ"); +f2[2] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_120_to_170.root", "READ"); +f1[3] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_170_to_300.root" , "READ"); +f2[3] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_170_to_300.root", "READ"); +f1[4] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_300_to_470.root" , "READ"); +f2[4] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_300_to_470.root", "READ"); +f1[5] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_470_to_600.root" , "READ"); +f2[5] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_470_to_600.root", "READ"); +f1[6] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_600_to_800.root" , "READ"); +f2[6] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_600_to_800.root", "READ"); +f1[7] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_800_to_1000.root" , "READ"); +f2[7] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_800_to_1000.root", "READ"); +f1[8] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_1000_to_1400.root" , "READ"); +f2[8] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_1000_to_1400.root", "READ"); +f1[9] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_1400_to_1800.root" , "READ"); +f2[9] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_1400_to_1800.root", "READ"); +f1[10] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_1800_to_2400.root" , "READ"); +f2[10] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_1800_to_2400.root", "READ"); +f1[11] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_2400_to_3200.root" , "READ"); +f2[11] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_2400_to_3200.root", "READ"); +f1[12] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_wo_weight_3200_to_inf.root" , "READ"); +f2[12] = new TFile("/afs/desy.de/user/s/sureshna/cmssw/CMSSW_7_6_5/src/Analysis/Tools/bin/BtagEffoutput/QCD_oldcalib_delR0.3/histograms_with_weight_3200_to_inf.root", "READ"); + + TH2F *hist1 = new TH2F(); + //TH2F *hist2 = new TH2F(); + TH2F *hist3 = new TH2F(); + //TH2F *hist4 = new TH2F(); + //TH1F *hist5 = new TH1F(); + //TH1F *hist6 = new TH1F(); + + + for(int i = 0; i < 13 ; ++i) + { + if ( i == 0) + { + hist1 = (TH2F*)f1[i]->Get("hist1"); + //hist2 = (TH2F*)f1[i]->Get("hist2"); + //hist5 = (TH1F*)f1[i]->Get("hist5"); + hist3 = (TH2F*)f2[i]->Get("hist3"); + //hist4 = (TH2F*)f2[i]->Get("hist4"); + //hist6 = (TH1F*)f2[i]->Get("hist6"); + } +// +else +{ +hist1 -> Add((TH2F*)f1[i]->Get("hist1")); +//hist2 -> Add((TH2F*)f1[i]->Get("hist2")); +//hist5 -> Add((TH1F*)f1[i]->Get("hist5")); +hist3 -> Add((TH2F*)f2[i]->Get("hist3")); +//hist4 -> Add((TH2F*)f2[i]->Get("hist4")); +//hist6 -> Add((TH1F*)f2[i]->Get("hist6")); +} +} + + + +TH1D *pt1 = hist1->ProjectionX(); +TH1D *eta1 = hist1->ProjectionY(); + //TH1D *pt2 = hist2->ProjectionX(); + //TH1D *eta2 = hist2->ProjectionY(); +TH1D *pt3 = hist3->ProjectionX(); +TH1D *eta3 = hist3->ProjectionY(); + //TH1D *pt4 = hist4->ProjectionX(); + //TH1D *eta4 = hist4->ProjectionY(); + +//jet1_pt + TCanvas *c1 = new TCanvas("jet_pt","jet_pt"); + TPad *pad1 = new TPad("pad1","pad1",0,0.3,1,1.0); + pad1->SetBottomMargin(0.1); + pad1->SetGridx(); + pad1->Draw(); + pad1->cd(); + gStyle->SetOptTitle(kFALSE); + pt1->SetStats(0); + pt1->GetXaxis()->SetRangeUser(0,600); + //pt1->GetYaxis()->SetRangeUser(0,30000); + pt1->Draw(); + pt3->SetLineColor(kRed); + pt3->GetXaxis()->SetRangeUser(0,600); + //pt3->GetYaxis()->SetRangeUser(0,30000); + pt3->Draw("same"); + + TLegend *leg1 = new TLegend(0.6,0.6,0.9,0.5); + leg1->AddEntry(pt1, "unweighted"); + leg1->AddEntry(pt3, "weighted"); + leg1->Draw(); + + //pt1->GetYaxis()->SetLabelSize(0.); + //TGaxis *axis1 = new TGaxis(0,0,0,160,20,160,203,""); + //axis1->SetLabelFont(43); + //axis1->SetLabelSize(15); + //axis1->SetLabelOffset(0.025); + //axis1->Draw(); + + c1->cd(); + TPad *pad2 = new TPad("pad2","pad2",0,0.05,1,0.3); + pad2->SetTopMargin(0.1); + pad2->SetBottomMargin(0.1); + pad2->SetGridx(); + pad2->SetGridy(); + pad2->Draw(); + pad2->cd(); + + TH1D *pt1_new = (TH1D*)pt3->Clone("pt1"); + pt1_new->SetLineColor(kBlack); + //pt1_new->SetMinimum(0.001); + //pt1_new->SetMaximum(1.6); + pt1_new->Sumw2(); + pt1_new->SetStats(0); + pt1_new->Divide(pt1); + pt1_new->SetMarkerStyle(21); + pt1_new->Draw("ep"); + + pt1_new->SetTitle(""); + pt1_new->GetYaxis()->SetTitle("ratio weighted/unweighted"); + pt1_new->GetYaxis()->SetTitleSize(10); + pt1_new->GetYaxis()->SetTitleFont(43); + pt1_new->GetYaxis()->SetTitleOffset(1.55); + pt1_new->GetYaxis()->SetRangeUser(0,1.5); + pt1_new->GetYaxis()->SetNdivisions(505); + pt1_new->GetYaxis()->SetLabelFont(43); + pt1_new->GetYaxis()->SetLabelSize(15); + pt1_new->GetXaxis()->SetLabelFont(43); + pt1_new->GetXaxis()->SetLabelSize(15); + + pt1->GetXaxis()->SetTitle("pT(GeV)"); + pt1->GetYaxis()->SetTitle("Entries"); + + c1->Print("jet_pt.pdf"); + +//jet2_pt +// TCanvas *c2 = new TCanvas("jet2_pt","jet2_pt"); +// TPad *pad3 = new TPad("pad3","pad3",0,0.3,1,1.0); +// pad3->SetBottomMargin(0.1); +// pad3->SetGridx(); +// pad3->Draw(); +// pad3->cd(); +// pt2->SetStats(0); +// pt2->GetXaxis()->SetRangeUser(0,1000); +// //pt2->GetYaxis()->SetRangeUser(0,20000); +// pt2->Draw(); +// pt4->SetLineColor(kRed); +// pt4->GetXaxis()->SetRangeUser(0,1000); +// //pt4->GetYaxis()->SetRangeUser(0,20000); +// pt4->Draw("same"); +// +// TLegend *leg2 = new TLegend(0.6,0.6,0.9,0.5); +// leg2->AddEntry(pt2, "unweighted"); +// leg2->AddEntry(pt4, "weighted"); +// leg2->Draw(); +// +// // pt2->GetYaxis()->SetLabelSize(0.); +// // TGaxis *axis2 = new TGaxis(-5,-20,-5,220,20,220,510,""); +// // axis2->SetLabelFont(43); +// // axis2->SetLabelSize(15); +// // axis2->Draw(); +// +// c2->cd(); +// TPad *pad4 = new TPad("pad4","pad4",0,0.05,1,0.3); +// pad4->SetTopMargin(0.1); +// pad4->SetBottomMargin(0.2); +// pad4->SetGridx(); +// pad4->SetGridy(); +// pad4->Draw(); +// pad4->cd(); +// +// TH1D *pt2_new = (TH1D*)pt4->Clone("pt2"); +// pt2_new->SetLineColor(kBlack); +// //pt2_new->SetMinimum(0.5); +// //pt2_new->SetMaximum(2.0); +// pt2_new->Sumw2(); +// pt2_new->SetStats(0); +// pt2_new->Divide(pt2); +// pt2_new->SetMarkerStyle(21); +// pt2_new->Draw("ep"); +// +// pt2_new->SetTitle(""); +// pt2_new->GetYaxis()->SetTitle("ratio weighted/unweighted"); +// pt2_new->GetYaxis()->SetTitleSize(10); +// pt2_new->GetYaxis()->SetTitleFont(43); +// pt2_new->GetYaxis()->SetTitleOffset(1.55); +// pt2_new->GetYaxis()->SetNdivisions(505); +// pt2_new->GetYaxis()->SetLabelFont(43); +// pt2_new->GetYaxis()->SetLabelSize(15); +// pt2_new->GetXaxis()->SetLabelFont(43); +// pt2_new->GetXaxis()->SetLabelSize(15); +// +// pt2->GetXaxis()->SetTitle("pT(GeV)"); +// pt2->GetYaxis()->SetTitle("Entries"); +// +// c2->Print("jet2_pt_hadron.pdf"); + +// jet1_eta + TCanvas *c3 = new TCanvas("jet_eta","jet_eta"); + TPad *pad5 = new TPad("pad5","pad5",0,0.3,1,1.0); + pad5->SetBottomMargin(0.1); + pad5->SetGridx(); + pad5->Draw(); + pad5->cd(); + eta1->SetStats(0); + //eta1->GetYaxis()->SetRangeUser(0,35000); + eta1->Draw(); + eta3->SetLineColor(kRed); + //eta3->GetYaxis()->SetRangeUser(0,35000); + eta3->Draw("same"); + + TLegend *leg3 = new TLegend(0.6,0.6,0.9,0.5); + leg3->AddEntry(eta1, "unweighted"); + leg3->AddEntry(eta3, "weighted"); + leg3->Draw(); + //eta1->GetYaxis()->SetLabelSize(0.); + + // TGaxis *axis3 = new TGaxis(-5,-20,-5,220,20,220,510,""); + // axis3->SetLabelFont(43); + // axis3->SetLabelSize(15); + // axis3->Draw(); + + c3->cd(); + TPad *pad6 = new TPad("pad6","pad6",0,0.05,1,0.3); + pad6->SetTopMargin(0.1); + pad6->SetBottomMargin(0.2); + pad6->SetGridx(); + pad6->SetGridy(); + pad6->Draw(); + pad6->cd(); + + TH1D *eta1_new = (TH1D*)eta3->Clone("eta1"); + eta1_new ->SetLineColor(kBlack); + eta1_new ->SetMinimum(0.); + //eta1_new ->SetMaximum(1.5); + eta1_new ->Sumw2(); + eta1_new ->SetStats(0); + eta1_new ->Divide(eta1); + eta1_new ->SetMarkerStyle(21); + eta1_new ->Draw("ep"); + + eta1_new ->SetTitle(""); + eta1_new->GetYaxis()->SetTitle("ratio weighted/unweighted"); + eta1_new->GetYaxis()->SetTitleSize(10); + eta1_new->GetYaxis()->SetTitleFont(43); + eta1_new->GetYaxis()->SetRangeUser(0,1.5); + eta1_new->GetYaxis()->SetTitleOffset(1.55); + eta1_new ->GetYaxis()->SetNdivisions(303); + eta1_new ->GetYaxis()->SetLabelFont(43); + eta1_new ->GetYaxis()->SetLabelSize(15); + eta1_new ->GetXaxis()->SetLabelFont(43); + eta1_new ->GetXaxis()->SetLabelSize(15); + + eta1->GetXaxis()->SetTitle("abs(eta)"); + eta1->GetYaxis()->SetTitle("Entries"); + + c3->Print("jet_eta.pdf"); + +// jet2_eta +// TCanvas *c4 = new TCanvas("jet2_eta","jet2_eta"); +// TPad *pad7 = new TPad("pad7","pad7",0,0.3,1,1.0); +// pad7->SetBottomMargin(0.1); +// pad7->SetGridx(); +// pad7->Draw(); +// pad7->cd(); +// eta2->SetStats(0); +// //eta2->GetYaxis()->SetRangeUser(0,12000); +// eta2->Draw(); +// eta4->SetLineColor(kRed); +// //eta4->GetYaxis()->SetRangeUser(0,12000); +// eta4->Draw("same"); +// +// TLegend *leg4 = new TLegend(0.6,0.6,0.9,0.5); +// leg4->AddEntry(eta2, "unweighted"); +// leg4->AddEntry(eta4, "weighted"); +// leg4->Draw(); +// +// // eta2->GetYaxis()->SetLabelSize(0.); +// // TGaxis *axis4 = new TGaxis(-5,-20,-5,220,20,220,510,""); +// // axis4->SetLabelFont(43); +// // axis4->SetLabelSize(15); +// // axis4->Draw(); +// +// c4->cd(); +// TPad *pad8 = new TPad("pad8","pad8",0,0.05,1,0.3); +// pad8->SetTopMargin(0.1); +// pad8->SetBottomMargin(0.2); +// pad8->SetGridx(); +// pad8->SetGridy(); +// pad8->Draw(); +// pad8->cd(); +// +// TH1D *eta2_new = (TH1D*)eta4->Clone("eta2"); +// eta2_new ->SetLineColor(kBlack); +// eta2_new ->SetMinimum(0.); +// eta2_new ->SetMaximum(1.5); +// eta2_new ->Sumw2(); +// eta2_new ->SetStats(0); +// eta2_new ->Divide(eta2); +// eta2_new ->SetMarkerStyle(21); +// eta2_new ->Draw("ep"); +// +// eta2_new ->SetTitle(""); +// eta2_new->GetYaxis()->SetTitle("ratio weighted/unweighted"); +// eta2_new->GetYaxis()->SetTitleSize(10); +// eta2_new->GetYaxis()->SetTitleFont(43); +// eta2_new->GetYaxis()->SetTitleOffset(1.55); +// eta2_new ->GetYaxis()->SetNdivisions(303); +// eta2_new ->GetYaxis()->SetLabelFont(43); +// eta2_new ->GetYaxis()->SetLabelSize(15); +// eta2_new ->GetXaxis()->SetLabelFont(43); +// eta2_new ->GetXaxis()->SetLabelSize(15); +// +// eta2->GetXaxis()->SetTitle("abs(eta)"); +// eta2->GetYaxis()->SetTitle("Entries"); +// +// c4->Print("jet2_eta_hadron.pdf"); + +// //mass +// TCanvas *c5 = new TCanvas("masses","masses"); +// TPad *pad9 = new TPad("pad9","pad9",0,0.3,1,1.0); +// pad1->SetBottomMargin(0.1); +// pad1->SetGridx(); +// pad1->Draw(); +// pad1->cd(); +// gStyle->SetOptTitle(kFALSE); +// hist5->SetStats(0); +// //hist5->GetYaxis()->SetRangeUser(0,200000); +// //hist5->GetXaxis()->SetRangeUser(0,700); +// hist5->Draw(); +// hist6->SetLineColor(kRed); +// //hist6->GetYaxis()->SetRangeUser(0,200000); +// //hist6->GetXaxis()->SetRangeUser(0,700); +// hist6->Draw("same"); +// +// TLegend *leg5 = new TLegend(0.6,0.6,0.9,0.5); +// leg5->AddEntry(hist5, "unweighted"); +// leg5->AddEntry(hist6, "weighted"); +// leg5->Draw(); +// +// pt1->GetYaxis()->SetLabelSize(0.); +// TGaxis *axis1 = new TGaxis(0,0,0,160,20,160,203,""); +// axis1->SetLabelFont(43); +// axis1->SetLabelSize(15); +// axis1->SetLabelOffset(0.025); +// axis1->Draw(); +// +// c5->cd(); +// TPad *pad10 = new TPad("pad10","pad10",0,0.05,1,0.3); +// pad10->SetTopMargin(0.1); +// pad10->SetBottomMargin(0.1); +// pad10->SetGridx(); +// pad10->SetGridy(); +// pad10->Draw(); +// pad10->cd(); +// +// TH1F *hist_new = (TH1F*)hist6->Clone("hist5"); +// hist_new->SetLineColor(kBlack); +// //pt1_new->SetMinimum(0.001); +// //pt1_new->SetMaximum(1.5); +// hist_new->Sumw2(); +// hist_new->SetStats(0); +// hist_new->Divide(hist5); +// hist_new->SetMarkerStyle(21); +// hist_new->Draw("ep"); +// +// hist_new->SetTitle(""); +// hist_new->GetYaxis()->SetTitle("ratio weighted/unweighted"); +// hist_new->GetYaxis()->SetTitleSize(10); +// hist_new->GetYaxis()->SetTitleFont(43); +// hist_new->GetYaxis()->SetRangeUser(0,1.5); +// hist_new->GetYaxis()->SetTitleOffset(1.55); +// hist_new->GetYaxis()->SetNdivisions(505); +// hist_new->GetYaxis()->SetLabelFont(43); +// hist_new->GetYaxis()->SetLabelSize(15); +// hist_new->GetXaxis()->SetLabelFont(43); +// hist_new->GetXaxis()->SetLabelSize(15); +// +// //pt1->GetXaxis()->SetTitle("pT(GeV)"); +// //pt1->GetYaxis()->SetTitle("Entries"); +// +// c5->Print("masses.pdf"); + +return; +} \ No newline at end of file diff --git a/Analysis/Tools/bin/proj_flavour.C b/Analysis/Tools/bin/proj_flavour.C new file mode 100644 index 0000000..024be8b --- /dev/null +++ b/Analysis/Tools/bin/proj_flavour.C @@ -0,0 +1,760 @@ +#include "TH1F.h" +#include "TH2F.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TFile.h" +#include "TRandom3.h" +#include "TTree.h" +#include "TCanvas.h" + +void proj_flavour() +{ +TFile *f1[13], *f2[13]; + +//f1 = new TFile("histograms_wo_weight_signal.root", "READ"); +//f2 = new TFile("histograms_with_weight_signal.root","READ"); +f1[0] = new TFile("histograms_wo_weight_50_to_80.root" , "READ"); +f2[0] = new TFile("histograms_with_weight_50_to_80.root", "READ"); +f1[1] = new TFile("histograms_wo_weight_80_to_120.root" , "READ"); +f2[1] = new TFile("histograms_with_weight_80_to_120.root", "READ"); +f1[2] = new TFile("histograms_wo_weight_120_to_170.root" , "READ"); +f2[2] = new TFile("histograms_with_weight_120_to_170.root", "READ"); +f1[3] = new TFile("histograms_wo_weight_170_to_300.root" , "READ"); +f2[3] = new TFile("histograms_with_weight_170_to_300.root", "READ"); +f1[4] = new TFile("histograms_wo_weight_300_to_470.root" , "READ"); +f2[4] = new TFile("histograms_with_weight_300_to_470.root", "READ"); +f1[5] = new TFile("histograms_wo_weight_470_to_600.root" , "READ"); +f2[5] = new TFile("histograms_with_weight_470_to_600.root", "READ"); +f1[6] = new TFile("histograms_wo_weight_600_to_800.root" , "READ"); +f2[6] = new TFile("histograms_with_weight_600_to_800.root", "READ"); +f1[7] = new TFile("histograms_wo_weight_800_to_1000.root" , "READ"); +f2[7] = new TFile("histograms_with_weight_800_to_1000.root", "READ"); +f1[8] = new TFile("histograms_wo_weight_1000_to_1400.root" , "READ"); +f2[8] = new TFile("histograms_with_weight_1000_to_1400.root", "READ"); +f1[9] = new TFile("histograms_wo_weight_1400_to_1800.root" , "READ"); +f2[9] = new TFile("histograms_with_weight_1400_to_1800.root", "READ"); +f1[10] = new TFile("histograms_wo_weight_1800_to_2400.root" , "READ"); +f2[10] = new TFile("histograms_with_weight_1800_to_2400.root", "READ"); +f1[11] = new TFile("histograms_wo_weight_2400_to_3200.root" , "READ"); +f2[11] = new TFile("histograms_with_weight_2400_to_3200.root", "READ"); +f1[12] = new TFile("histograms_wo_weight_3200_to_inf.root" , "READ"); +f2[12] = new TFile("histograms_with_weight_3200_to_inf.root", "READ"); + + TH2F *hist1b = new TH2F(); + TH2F *hist1c = new TH2F(); + TH2F *hist1l = new TH2F(); + TH2F *hist1bb = new TH2F(); + TH2F *hist1cc = new TH2F(); + //TH2F *hist2 = new TH2F(); + TH2F *hist3b = new TH2F(); + TH2F *hist3c = new TH2F(); + TH2F *hist3l = new TH2F(); + TH2F *hist3bb = new TH2F(); + TH2F *hist3cc = new TH2F(); + //TH2F *hist4 = new TH2F(); + TH1F *hist5 = new TH1F(); + TH1F *hist6 = new TH1F(); + + + for(int i = 0; i < 13 ; ++i) + { + if ( i == 0) + { + hist1b = (TH2F*)f1[i]->Get("hist1b"); + hist1c = (TH2F*)f1[i]->Get("hist1_c"); + hist1l = (TH2F*)f1[i]->Get("hist1_l"); + hist1bb = (TH2F*)f1[i]->Get("hist1_bb"); + hist1cc = (TH2F*)f1[i]->Get("hist1_cc"); + + //hist2 = (TH2F*)f1[i]->Get("hist2"); + //hist5 = (TH1F*)f1[i]->Get("hist5"); + hist3b = (TH2F*)f2[i]->Get("hist3b"); + hist3c = (TH2F*)f2[i]->Get("hist3_c"); + hist3l = (TH2F*)f2[i]->Get("hist3_l"); + hist3bb = (TH2F*)f2[i]->Get("hist3_bb"); + hist3cc = (TH2F*)f2[i]->Get("hist3_cc"); + //hist4 = (TH2F*)f2[i]->Get("hist4"); + //hist6 = (TH1F*)f2[i]->Get("hist6"); + } +// + else + { +hist1b -> Add((TH2F*)f1[i]->Get("hist1b")); +hist1c -> Add((TH2F*)f1[i]->Get("hist1_c")); +hist1l -> Add((TH2F*)f1[i]->Get("hist1_l")); +hist1bb -> Add((TH2F*)f1[i]->Get("hist1_bb")); +hist1cc -> Add((TH2F*)f1[i]->Get("hist1_cc")); +//hist2 -> Add((TH2F*)f1[i]->Get("hist2")); +//hist5 -> Add((TH1F*)f1[i]->Get("hist5")); +hist3b -> Add((TH2F*)f2[i]->Get("hist3b")); +hist3c -> Add((TH2F*)f2[i]->Get("hist3_c")); +hist3l -> Add((TH2F*)f2[i]->Get("hist3_l")); +hist3bb -> Add((TH2F*)f2[i]->Get("hist3_bb")); +hist3cc -> Add((TH2F*)f2[i]->Get("hist3_cc")); +//hist4 -> Add((TH2F*)f2[i]->Get("hist4")); +//hist6 -> Add((TH1F*)f2[i]->Get("hist6")); +} +} + + + +TH1D *pt1b = hist1b->ProjectionX(); +TH1D *eta1b = hist1b->ProjectionY(); +TH1D *pt1c = hist1c->ProjectionX(); +TH1D *eta1c = hist1c->ProjectionY(); +TH1D *pt1l = hist1l->ProjectionX(); +TH1D *eta1l = hist1l->ProjectionY(); +TH1D *pt1bb = hist1bb->ProjectionX(); +TH1D *eta1bb = hist1bb->ProjectionY(); +TH1D *pt1cc = hist1cc->ProjectionX(); +TH1D *eta1cc = hist1cc->ProjectionY(); + //TH1D *pt2 = hist2->ProjectionX(); + //TH1D *eta2 = hist2->ProjectionY(); +TH1D *pt3b = hist3b->ProjectionX(); +TH1D *eta3b = hist3b->ProjectionY(); +TH1D *pt3c = hist3c->ProjectionX(); +TH1D *eta3c = hist3c->ProjectionY(); +TH1D *pt3l = hist3l->ProjectionX(); +TH1D *eta3l = hist3l->ProjectionY(); +TH1D *pt3bb = hist3bb->ProjectionX(); +TH1D *eta3bb = hist3bb->ProjectionY(); +TH1D *pt3cc = hist3cc->ProjectionX(); +TH1D *eta3cc = hist3cc->ProjectionY(); + //TH1D *pt4 = hist4->ProjectionX(); + //TH1D *eta4 = hist4->ProjectionY(); + +//jet1_pt + TCanvas *c1b = new TCanvas("jet_pt_flav_b","jet_pt_flav_b"); + TPad *pad1b = new TPad("pad1b","pad1b",0,0.3,1,1.0); + pad1b->SetBottomMargin(0.1); + pad1b->SetGridx(); + pad1b->Draw(); + pad1b->cd(); + gStyle->SetOptTitle(kFALSE); + pt1b->SetStats(0); + pt1b->GetXaxis()->SetRangeUser(0,600); + //pt1->GetYaxis()->SetRangeUser(0,30000); + pt1b->Draw(); + pt3b->SetLineColor(kRed); + pt3b->GetXaxis()->SetRangeUser(0,600); + //pt3->GetYaxis()->SetRangeUser(0,30000); + pt3b->Draw("same"); + + TLegend *leg1b = new TLegend(0.6,0.6,0.9,0.5); + leg1b->AddEntry(pt1b, "unweighted"); + leg1b->AddEntry(pt3b, "weighted"); + leg1b->Draw(); + + //pt1->GetYaxis()->SetLabelSize(0.); + //TGaxis *axis1 = new TGaxis(0,0,0,160,20,160,203,""); + //axis1->SetLabelFont(43); + //axis1->SetLabelSize(15); + //axis1->SetLabelOffset(0.025); + //axis1->Draw(); + + c1b->cd(); + TPad *pad2b = new TPad("pad2b","pad2b",0,0.05,1,0.3); + pad2b->SetTopMargin(0.1); + pad2b->SetBottomMargin(0.1); + pad2b->SetGridx(); + pad2b->SetGridy(); + pad2b->Draw(); + pad2b->cd(); + + TH1D *pt1_new_b = (TH1D*)pt3b->Clone("pt1b"); + pt1_new_b->SetLineColor(kBlack); + //pt1_new->SetMinimum(0.001); + //pt1_new->SetMaximum(1.6); + pt1_new_b->Sumw2(); + pt1_new_b->SetStats(0); + pt1_new_b->Divide(pt1b); + pt1_new_b->SetMarkerStyle(21); + pt1_new_b->Draw("ep"); + + pt1_new_b->SetTitle(""); + pt1_new_b->GetYaxis()->SetTitle("ratio weighted/unweighted"); + pt1_new_b->GetYaxis()->SetTitleSize(10); + pt1_new_b->GetYaxis()->SetTitleFont(43); + pt1_new_b->GetYaxis()->SetTitleOffset(1.55); + pt1_new_b->GetYaxis()->SetRangeUser(0,1.5); + pt1_new_b->GetYaxis()->SetNdivisions(505); + pt1_new_b->GetYaxis()->SetLabelFont(43); + pt1_new_b->GetYaxis()->SetLabelSize(15); + pt1_new_b->GetXaxis()->SetLabelFont(43); + pt1_new_b->GetXaxis()->SetLabelSize(15); + + pt1b->GetXaxis()->SetTitle("pT(GeV)"); + pt1b->GetYaxis()->SetTitle("Entries"); + + c1b->Print("jet_pt_flav_b.pdf"); + +//jet1_pt + TCanvas *c1c = new TCanvas("jet_pt_flav_c","jet_pt_flav_c"); + TPad *pad1c = new TPad("pad1c","pad1c",0,0.3,1,1.0); + pad1c->SetBottomMargin(0.1); + pad1c->SetGridx(); + pad1c->Draw(); + pad1c->cd(); + gStyle->SetOptTitle(kFALSE); + pt1c->SetStats(0); + pt1c->GetXaxis()->SetRangeUser(0,600); + //pt1->GetYaxis()->SetRangeUser(0,30000); + pt1c->Draw(); + pt3c->SetLineColor(kRed); + pt3c->GetXaxis()->SetRangeUser(0,600); + //pt3->GetYaxis()->SetRangeUser(0,30000); + pt3c->Draw("same"); + + TLegend *leg1c = new TLegend(0.6,0.6,0.9,0.5); + leg1c->AddEntry(pt1c, "unweighted"); + leg1c->AddEntry(pt3c, "weighted"); + leg1c->Draw(); + + //pt1->GetYaxis()->SetLabelSize(0.); + //TGaxis *axis1 = new TGaxis(0,0,0,160,20,160,203,""); + //axis1->SetLabelFont(43); + //axis1->SetLabelSize(15); + //axis1->SetLabelOffset(0.025); + //axis1->Draw(); + + c1c->cd(); + TPad *pad2c = new TPad("pad2c","pad2c",0,0.05,1,0.3); + pad2c->SetTopMargin(0.1); + pad2c->SetBottomMargin(0.1); + pad2c->SetGridx(); + pad2c->SetGridy(); + pad2c->Draw(); + pad2c->cd(); + + TH1D *pt1_new_c = (TH1D*)pt3c->Clone("pt1c"); + pt1_new_c->SetLineColor(kBlack); + //pt1_new->SetMinimum(0.001); + //pt1_new->SetMaximum(1.6); + pt1_new_c->Sumw2(); + pt1_new_c->SetStats(0); + pt1_new_c->Divide(pt1c); + pt1_new_c->SetMarkerStyle(21); + pt1_new_c->Draw("ep"); + + pt1_new_c->SetTitle(""); + pt1_new_c->GetYaxis()->SetTitle("ratio weighted/unweighted"); + pt1_new_c->GetYaxis()->SetTitleSize(10); + pt1_new_c->GetYaxis()->SetTitleFont(43); + pt1_new_c->GetYaxis()->SetTitleOffset(1.55); + pt1_new_c->GetYaxis()->SetRangeUser(0,1.5); + pt1_new_c->GetYaxis()->SetNdivisions(505); + pt1_new_c->GetYaxis()->SetLabelFont(43); + pt1_new_c->GetYaxis()->SetLabelSize(15); + pt1_new_c->GetXaxis()->SetLabelFont(43); + pt1_new_c->GetXaxis()->SetLabelSize(15); + + pt1c->GetXaxis()->SetTitle("pT(GeV)"); + pt1c->GetYaxis()->SetTitle("Entries"); + + c1c->Print("jet_pt_flav_c.pdf"); + + +//jet1_pt + TCanvas *c1l = new TCanvas("jet_pt_flav_l","jet_pt_flav_l"); + TPad *pad1l = new TPad("pad1l","pad1l",0,0.3,1,1.0); + pad1l->SetBottomMargin(0.1); + pad1l->SetGridx(); + pad1l->Draw(); + pad1l->cd(); + gStyle->SetOptTitle(kFALSE); + pt1l->SetStats(0); + pt1l->GetXaxis()->SetRangeUser(0,600); + //pt1->GetYaxis()->SetRangeUser(0,30000); + pt1l->Draw(); + pt3l->SetLineColor(kRed); + pt3l->GetXaxis()->SetRangeUser(0,600); + //pt3->GetYaxis()->SetRangeUser(0,30000); + pt3l->Draw("same"); + + TLegend *leg1l = new TLegend(0.6,0.6,0.9,0.5); + leg1l->AddEntry(pt1l, "unweighted"); + leg1l->AddEntry(pt3l, "weighted"); + leg1l->Draw(); + + //pt1->GetYaxis()->SetLabelSize(0.); + //TGaxis *axis1 = new TGaxis(0,0,0,160,20,160,203,""); + //axis1->SetLabelFont(43); + //axis1->SetLabelSize(15); + //axis1->SetLabelOffset(0.025); + //axis1->Draw(); + + c1l->cd(); + TPad *pad2l = new TPad("pad2l","pad2l",0,0.05,1,0.3); + pad2l->SetTopMargin(0.1); + pad2l->SetBottomMargin(0.1); + pad2l->SetGridx(); + pad2l->SetGridy(); + pad2l->Draw(); + pad2l->cd(); + + TH1D *pt1_new_l = (TH1D*)pt3l->Clone("pt1l"); + pt1_new_l->SetLineColor(kBlack); + //pt1_new->SetMinimum(0.001); + //pt1_new->SetMaximum(1.6); + pt1_new_l->Sumw2(); + pt1_new_l->SetStats(0); + pt1_new_l->Divide(pt1l); + pt1_new_l->SetMarkerStyle(21); + pt1_new_l->Draw("ep"); + + pt1_new_l->SetTitle(""); + pt1_new_l->GetYaxis()->SetTitle("ratio weighted/unweighted"); + pt1_new_l->GetYaxis()->SetTitleSize(10); + pt1_new_l->GetYaxis()->SetTitleFont(43); + pt1_new_l->GetYaxis()->SetTitleOffset(1.55); + pt1_new_l->GetYaxis()->SetRangeUser(0,1.5); + pt1_new_l->GetYaxis()->SetNdivisions(505); + pt1_new_l->GetYaxis()->SetLabelFont(43); + pt1_new_l->GetYaxis()->SetLabelSize(15); + pt1_new_l->GetXaxis()->SetLabelFont(43); + pt1_new_l->GetXaxis()->SetLabelSize(15); + + pt1l->GetXaxis()->SetTitle("pT(GeV)"); + pt1l->GetYaxis()->SetTitle("Entries"); + + c1l->Print("jet_pt_flav_l.pdf"); + +//jet1_pt + TCanvas *c1bb = new TCanvas("jet_pt_flav_bb","jet_pt_flav_bb"); + TPad *pad1bb = new TPad("pad1bb","pad1bb",0,0.3,1,1.0); + pad1bb->SetBottomMargin(0.1); + pad1bb->SetGridx(); + pad1bb->Draw(); + pad1bb->cd(); + gStyle->SetOptTitle(kFALSE); + pt1bb->SetStats(0); + pt1bb->GetXaxis()->SetRangeUser(0,600); + //pt1->GetYaxis()->SetRangeUser(0,30000); + pt1bb->Draw(); + pt3bb->SetLineColor(kRed); + pt3bb->GetXaxis()->SetRangeUser(0,600); + //pt3->GetYaxis()->SetRangeUser(0,30000); + pt3bb->Draw("same"); + + TLegend *leg1bb = new TLegend(0.6,0.6,0.9,0.5); + leg1bb->AddEntry(pt1bb, "unweighted"); + leg1bb->AddEntry(pt3bb, "weighted"); + leg1bb->Draw(); + + //pt1->GetYaxis()->SetLabelSize(0.); + //TGaxis *axis1 = new TGaxis(0,0,0,160,20,160,203,""); + //axis1->SetLabelFont(43); + //axis1->SetLabelSize(15); + //axis1->SetLabelOffset(0.025); + //axis1->Draw(); + + c1bb->cd(); + TPad *pad2bb = new TPad("pad2bb","pad2bb",0,0.05,1,0.3); + pad2bb->SetTopMargin(0.1); + pad2bb->SetBottomMargin(0.1); + pad2bb->SetGridx(); + pad2bb->SetGridy(); + pad2bb->Draw(); + pad2bb->cd(); + + TH1D *pt1_new_bb = (TH1D*)pt3bb->Clone("pt1bb"); + pt1_new_bb->SetLineColor(kBlack); + //pt1_new->SetMinimum(0.001); + //pt1_new->SetMaximum(1.6); + pt1_new_bb->Sumw2(); + pt1_new_bb->SetStats(0); + pt1_new_bb->Divide(pt1bb); + pt1_new_bb->SetMarkerStyle(21); + pt1_new_bb->Draw("ep"); + + pt1_new_bb->SetTitle(""); + pt1_new_bb->GetYaxis()->SetTitle("ratio weighted/unweighted"); + pt1_new_bb->GetYaxis()->SetTitleSize(10); + pt1_new_bb->GetYaxis()->SetTitleFont(43); + pt1_new_bb->GetYaxis()->SetTitleOffset(1.55); + pt1_new_bb->GetYaxis()->SetRangeUser(0,1.5); + pt1_new_bb->GetYaxis()->SetNdivisions(505); + pt1_new_bb->GetYaxis()->SetLabelFont(43); + pt1_new_bb->GetYaxis()->SetLabelSize(15); + pt1_new_bb->GetXaxis()->SetLabelFont(43); + pt1_new_bb->GetXaxis()->SetLabelSize(15); + + pt1bb->GetXaxis()->SetTitle("pT(GeV)"); + pt1bb->GetYaxis()->SetTitle("Entries"); + + c1bb->Print("jet_pt_flav_bb.pdf"); + +//jet1_pt + TCanvas *c1cc = new TCanvas("jet_pt_flav_cc","jet_pt_flav_cc"); + TPad *pad1cc = new TPad("pad1cc","pad1cc",0,0.3,1,1.0); + pad1cc->SetBottomMargin(0.1); + pad1cc->SetGridx(); + pad1cc->Draw(); + pad1cc->cd(); + gStyle->SetOptTitle(kFALSE); + pt1cc->SetStats(0); + pt1cc->GetXaxis()->SetRangeUser(0,600); + //pt1->GetYaxis()->SetRangeUser(0,30000); + pt1cc->Draw(); + pt3cc->SetLineColor(kRed); + pt3cc->GetXaxis()->SetRangeUser(0,600); + //pt3->GetYaxis()->SetRangeUser(0,30000); + pt3cc->Draw("same"); + + TLegend *leg1cc = new TLegend(0.6,0.6,0.9,0.5); + leg1cc->AddEntry(pt1cc, "unweighted"); + leg1cc->AddEntry(pt3cc, "weighted"); + leg1cc->Draw(); + + //pt1->GetYaxis()->SetLabelSize(0.); + //TGaxis *axis1 = new TGaxis(0,0,0,160,20,160,203,""); + //axis1->SetLabelFont(43); + //axis1->SetLabelSize(15); + //axis1->SetLabelOffset(0.025); + //axis1->Draw(); + + c1cc->cd(); + TPad *pad2cc = new TPad("pad2cc","pad2cc",0,0.05,1,0.3); + pad2cc->SetTopMargin(0.1); + pad2cc->SetBottomMargin(0.1); + pad2cc->SetGridx(); + pad2cc->SetGridy(); + pad2cc->Draw(); + pad2cc->cd(); + + TH1D *pt1_new_cc = (TH1D*)pt3cc->Clone("pt1cc"); + pt1_new_cc->SetLineColor(kBlack); + //pt1_new->SetMinimum(0.001); + //pt1_new->SetMaximum(1.6); + pt1_new_cc->Sumw2(); + pt1_new_cc->SetStats(0); + pt1_new_cc->Divide(pt1cc); + pt1_new_cc->SetMarkerStyle(21); + pt1_new_cc->Draw("ep"); + + pt1_new_cc->SetTitle(""); + pt1_new_cc->GetYaxis()->SetTitle("ratio weighted/unweighted"); + pt1_new_cc->GetYaxis()->SetTitleSize(10); + pt1_new_cc->GetYaxis()->SetTitleFont(43); + pt1_new_cc->GetYaxis()->SetTitleOffset(1.55); + pt1_new_cc->GetYaxis()->SetRangeUser(0,1.5); + pt1_new_cc->GetYaxis()->SetNdivisions(505); + pt1_new_cc->GetYaxis()->SetLabelFont(43); + pt1_new_cc->GetYaxis()->SetLabelSize(15); + pt1_new_cc->GetXaxis()->SetLabelFont(43); + pt1_new_cc->GetXaxis()->SetLabelSize(15); + + pt1cc->GetXaxis()->SetTitle("pT(GeV)"); + pt1cc->GetYaxis()->SetTitle("Entries"); + + c1cc->Print("jet_pt_flav_cc.pdf"); + + + +// jet1_eta + TCanvas *c3b = new TCanvas("jet_eta_flav_b","jet_eta_flav_b"); + TPad *pad5b = new TPad("pad5b","pad5b",0,0.3,1,1.0); + pad5b->SetBottomMargin(0.1); + pad5b->SetGridx(); + pad5b->Draw(); + pad5b->cd(); + eta1b->SetStats(0); + //eta1->GetYaxis()->SetRangeUser(0,35000); + eta1b->Draw(); + eta3b->SetLineColor(kRed); + //eta3->GetYaxis()->SetRangeUser(0,35000); + eta3b->Draw("same"); + + TLegend *leg3b = new TLegend(0.6,0.6,0.9,0.5); + leg3b->AddEntry(eta1b, "unweighted"); + leg3b->AddEntry(eta3b, "weighted"); + leg3b->Draw(); + //eta1->GetYaxis()->SetLabelSize(0.); + + // TGaxis *axis3 = new TGaxis(-5,-20,-5,220,20,220,510,""); + // axis3->SetLabelFont(43); + // axis3->SetLabelSize(15); + // axis3->Draw(); + + c3b->cd(); + TPad *pad6b = new TPad("pad6b","pad6b",0,0.05,1,0.3); + pad6b->SetTopMargin(0.1); + pad6b->SetBottomMargin(0.2); + pad6b->SetGridx(); + pad6b->SetGridy(); + pad6b->Draw(); + pad6b->cd(); + + TH1D *eta1_new_b = (TH1D*)eta3b->Clone("eta1b"); + eta1_new_b ->SetLineColor(kBlack); + eta1_new_b ->SetMinimum(0.); + //eta1_new ->SetMaximum(1.5); + eta1_new_b->Sumw2(); + eta1_new_b ->SetStats(0); + eta1_new_b ->Divide(eta1b); + eta1_new_b ->SetMarkerStyle(21); + eta1_new_b ->Draw("ep"); + + eta1_new_b ->SetTitle(""); + eta1_new_b->GetYaxis()->SetTitle("ratio weighted/unweighted"); + eta1_new_b->GetYaxis()->SetTitleSize(10); + eta1_new_b->GetYaxis()->SetTitleFont(43); + eta1_new_b->GetYaxis()->SetRangeUser(0,1.5); + eta1_new_b->GetYaxis()->SetTitleOffset(1.55); + eta1_new_b ->GetYaxis()->SetNdivisions(303); + eta1_new_b ->GetYaxis()->SetLabelFont(43); + eta1_new_b ->GetYaxis()->SetLabelSize(15); + eta1_new_b ->GetXaxis()->SetLabelFont(43); + eta1_new_b ->GetXaxis()->SetLabelSize(15); + + eta1b->GetXaxis()->SetTitle("abs(eta)"); + eta1b->GetYaxis()->SetTitle("Entries"); + + c3b->Print("jet_eta_flav_b.pdf"); + +// jet1_eta + TCanvas *c3c = new TCanvas("jet_eta_flav_c","jet_eta_flav_c"); + TPad *pad5c = new TPad("pad5c","pad5c",0,0.3,1,1.0); + pad5c->SetBottomMargin(0.1); + pad5c->SetGridx(); + pad5c->Draw(); + pad5c->cd(); + eta1c->SetStats(0); + //eta1->GetYaxis()->SetRangeUser(0,35000); + eta1c->Draw(); + eta3c->SetLineColor(kRed); + //eta3->GetYaxis()->SetRangeUser(0,35000); + eta3c->Draw("same"); + + TLegend *leg3c = new TLegend(0.6,0.6,0.9,0.5); + leg3c->AddEntry(eta1c, "unweighted"); + leg3c->AddEntry(eta3c, "weighted"); + leg3c->Draw(); + //eta1->GetYaxis()->SetLacelSize(0.); + + // TGaxis *axis3 = new TGaxis(-5,-20,-5,220,20,220,510,""); + // axis3->SetLabelFont(43); + // axis3->SetLabelSize(15); + // axis3->Draw(); + + c3c->cd(); + TPad *pad6c = new TPad("pad6c","pad6c",0,0.05,1,0.3); + pad6c->SetTopMargin(0.1); + pad6c->SetBottomMargin(0.2); + pad6c->SetGridx(); + pad6c->SetGridy(); + pad6c->Draw(); + pad6c->cd(); + + TH1D *eta1_new_c = (TH1D*)eta3c->Clone("eta1c"); + eta1_new_c ->SetLineColor(kBlack); + eta1_new_c ->SetMinimum(0.); + //eta1_new ->SetMaximum(1.5); + eta1_new_c->Sumw2(); + eta1_new_c ->SetStats(0); + eta1_new_c ->Divide(eta1c); + eta1_new_c ->SetMarkerStyle(21); + eta1_new_c ->Draw("ep"); + + eta1_new_c ->SetTitle(""); + eta1_new_c->GetYaxis()->SetTitle("ratio weighted/unweighted"); + eta1_new_c->GetYaxis()->SetTitleSize(10); + eta1_new_c->GetYaxis()->SetTitleFont(43); + eta1_new_c->GetYaxis()->SetRangeUser(0,1.5); + eta1_new_c->GetYaxis()->SetTitleOffset(1.55); + eta1_new_c ->GetYaxis()->SetNdivisions(303); + eta1_new_c ->GetYaxis()->SetLabelFont(43); + eta1_new_c ->GetYaxis()->SetLabelSize(15); + eta1_new_c ->GetXaxis()->SetLabelFont(43); + eta1_new_c ->GetXaxis()->SetLabelSize(15); + + eta1c->GetXaxis()->SetTitle("abs(eta)"); + eta1c->GetYaxis()->SetTitle("Entries"); + + c3c->Print("jet_eta_flav_c.pdf"); + +// jet1_eta + TCanvas *c3l = new TCanvas("jet_eta_flav_l","jet_eta_flav_l"); + TPad *pad5l = new TPad("pad5l","pad5l",0,0.3,1,1.0); + pad5l->SetBottomMargin(0.1); + pad5l->SetGridx(); + pad5l->Draw(); + pad5l->cd(); + eta1l->SetStats(0); + //eta1->GetYaxis()->SetRangeUser(0,35000); + eta1l->Draw(); + eta3l->SetLineColor(kRed); + //eta3->GetYaxis()->SetRangeUser(0,35000); + eta3l->Draw("same"); + + TLegend *leg3l = new TLegend(0.6,0.6,0.9,0.5); + leg3l->AddEntry(eta1l, "unweighted"); + leg3l->AddEntry(eta3l, "weighted"); + leg3l->Draw(); + //eta1->GetYaxis()->SetLabelSize(0.); + + // TGaxis *axis3 = new TGaxis(-5,-20,-5,220,20,220,510,""); + // axis3->SetLabelFont(43); + // axis3->SetLabelSize(15); + // axis3->Draw(); + + c3l->cd(); + TPad *pad6l = new TPad("pad6l","pad6l",0,0.05,1,0.3); + pad6l->SetTopMargin(0.1); + pad6l->SetBottomMargin(0.2); + pad6l->SetGridx(); + pad6l->SetGridy(); + pad6l->Draw(); + pad6l->cd(); + + TH1D *eta1_new_l = (TH1D*)eta3l->Clone("eta1l"); + eta1_new_l ->SetLineColor(kBlack); + eta1_new_l ->SetMinimum(0.); + //eta1_new ->SetMaximum(1.5); + eta1_new_l->Sumw2(); + eta1_new_l ->SetStats(0); + eta1_new_l ->Divide(eta1l); + eta1_new_l ->SetMarkerStyle(21); + eta1_new_l ->Draw("ep"); + + eta1_new_l ->SetTitle(""); + eta1_new_l->GetYaxis()->SetTitle("ratio weighted/unweighted"); + eta1_new_l->GetYaxis()->SetTitleSize(10); + eta1_new_l->GetYaxis()->SetTitleFont(43); + eta1_new_l->GetYaxis()->SetRangeUser(0,1.5); + eta1_new_l->GetYaxis()->SetTitleOffset(1.55); + eta1_new_l ->GetYaxis()->SetNdivisions(303); + eta1_new_l ->GetYaxis()->SetLabelFont(43); + eta1_new_l ->GetYaxis()->SetLabelSize(15); + eta1_new_l ->GetXaxis()->SetLabelFont(43); + eta1_new_l ->GetXaxis()->SetLabelSize(15); + + eta1l->GetXaxis()->SetTitle("abs(eta)"); + eta1l->GetYaxis()->SetTitle("Entries"); + + c3l->Print("jet_eta_flav_l.pdf"); + +// jet1_eta + TCanvas *c3bb = new TCanvas("jet_eta_flav_bb","jet_eta_flav_bb"); + TPad *pad5bb = new TPad("pad5bb","pad5bb",0,0.3,1,1.0); + pad5bb->SetBottomMargin(0.1); + pad5bb->SetGridx(); + pad5bb->Draw(); + pad5bb->cd(); + eta1bb->SetStats(0); + //eta1->GetYaxis()->SetRangeUser(0,35000); + eta1bb->Draw(); + eta3bb->SetLineColor(kRed); + //eta3->GetYaxis()->SetRangeUser(0,35000); + eta3bb->Draw("same"); + + TLegend *leg3bb = new TLegend(0.6,0.6,0.9,0.5); + leg3bb->AddEntry(eta1bb, "unweighted"); + leg3bb->AddEntry(eta3bb, "weighted"); + leg3bb->Draw(); + //eta1->GetYaxis()->SetLabelSize(0.); + + // TGaxis *axis3 = new TGaxis(-5,-20,-5,220,20,220,510,""); + // axis3->SetLabelFont(43); + // axis3->SetLabelSize(15); + // axis3->Draw(); + + c3bb->cd(); + TPad *pad6bb = new TPad("pad6bb","pad6bb",0,0.05,1,0.3); + pad6bb->SetTopMargin(0.1); + pad6bb->SetBottomMargin(0.2); + pad6bb->SetGridx(); + pad6bb->SetGridy(); + pad6bb->Draw(); + pad6bb->cd(); + + TH1D *eta1_new_bb = (TH1D*)eta3bb->Clone("eta1bb"); + eta1_new_bb ->SetLineColor(kBlack); + eta1_new_bb ->SetMinimum(0.); + //eta1_new ->SetMaximum(1.5); + eta1_new_bb->Sumw2(); + eta1_new_bb ->SetStats(0); + eta1_new_bb ->Divide(eta1bb); + eta1_new_bb ->SetMarkerStyle(21); + eta1_new_bb ->Draw("ep"); + + eta1_new_bb ->SetTitle(""); + eta1_new_bb->GetYaxis()->SetTitle("ratio weighted/unweighted"); + eta1_new_bb->GetYaxis()->SetTitleSize(10); + eta1_new_bb->GetYaxis()->SetTitleFont(43); + eta1_new_bb->GetYaxis()->SetRangeUser(0,1.5); + eta1_new_bb->GetYaxis()->SetTitleOffset(1.55); + eta1_new_bb ->GetYaxis()->SetNdivisions(303); + eta1_new_bb ->GetYaxis()->SetLabelFont(43); + eta1_new_bb ->GetYaxis()->SetLabelSize(15); + eta1_new_bb ->GetXaxis()->SetLabelFont(43); + eta1_new_bb ->GetXaxis()->SetLabelSize(15); + + eta1bb->GetXaxis()->SetTitle("abs(eta)"); + eta1bb->GetYaxis()->SetTitle("Entries"); + + c3bb->Print("jet_eta_flav_bb.pdf"); + +// jet1_eta + TCanvas *c3cc = new TCanvas("jet_eta_flav_cc","jet_eta_flav_cc"); + TPad *pad5cc = new TPad("pad5cc","pad5cc",0,0.3,1,1.0); + pad5cc->SetBottomMargin(0.1); + pad5cc->SetGridx(); + pad5cc->Draw(); + pad5cc->cd(); + eta1cc->SetStats(0); + //eta1->GetYaxis()->SetRangeUser(0,35000); + eta1cc->Draw(); + eta3cc->SetLineColor(kRed); + //eta3->GetYaxis()->SetRangeUser(0,35000); + eta3cc->Draw("same"); + + TLegend *leg3cc = new TLegend(0.6,0.6,0.9,0.5); + leg3cc->AddEntry(eta1cc, "unweighted"); + leg3cc->AddEntry(eta3cc, "weighted"); + leg3cc->Draw(); + //eta1->GetYaxis()->SetLaccelSize(0.); + + // TGaxis *axis3 = new TGaxis(-5,-20,-5,220,20,220,510,""); + // axis3->SetLabelFont(43); + // axis3->SetLabelSize(15); + // axis3->Draw(); + + c3cc->cd(); + TPad *pad6cc = new TPad("pad6cc","pad6cc",0,0.05,1,0.3); + pad6cc->SetTopMargin(0.1); + pad6cc->SetBottomMargin(0.2); + pad6cc->SetGridx(); + pad6cc->SetGridy(); + pad6cc->Draw(); + pad6cc->cd(); + + TH1D *eta1_new_cc = (TH1D*)eta3cc->Clone("eta1cc"); + eta1_new_cc ->SetLineColor(kBlack); + eta1_new_cc ->SetMinimum(0.); + //eta1_new ->SetMaximum(1.5); + eta1_new_cc->Sumw2(); + eta1_new_cc ->SetStats(0); + eta1_new_cc ->Divide(eta1cc); + eta1_new_cc ->SetMarkerStyle(21); + eta1_new_cc ->Draw("ep"); + + eta1_new_cc ->SetTitle(""); + eta1_new_cc->GetYaxis()->SetTitle("ratio weighted/unweighted"); + eta1_new_cc->GetYaxis()->SetTitleSize(10); + eta1_new_cc->GetYaxis()->SetTitleFont(43); + eta1_new_cc->GetYaxis()->SetRangeUser(0,1.5); + eta1_new_cc->GetYaxis()->SetTitleOffset(1.55); + eta1_new_cc ->GetYaxis()->SetNdivisions(303); + eta1_new_cc ->GetYaxis()->SetLabelFont(43); + eta1_new_cc ->GetYaxis()->SetLabelSize(15); + eta1_new_cc ->GetXaxis()->SetLabelFont(43); + eta1_new_cc ->GetXaxis()->SetLabelSize(15); + + eta1cc->GetXaxis()->SetTitle("abs(eta)"); + eta1cc->GetYaxis()->SetTitle("Entries"); + + c3cc->Print("jet_eta_flav_cc.pdf"); + +return; +} \ No newline at end of file