Example #1
0
void plotv2vspt_4p_sys(){

const int ntotbin=4;
const int npt24=9;
const double pt[npt24]={0.4,0.7,1.2,1.7,2.2,2.7,3.4,4.4,5.4};
const double v24[5][npt24]={
    {0.0436326,0.0795412,0.117455,0.135615,0.138952,0.137704,0.12716,0.104461,0.102546},
    {0.0441134,0.081454,0.120992,0.142609,0.148646,0.144631,0.13748,0.115206,0.102368},
    {0.0444633,0.0827859,0.124137,0.145269,0.149668,0.150845,0.144292,0.115638,0.127838},
    {0.045803,0.083701,0.127181,0.148425,0.151695,0.152144,0.135538,0.115144,0.0939622}
};
const double v24err[5][npt24]={
    {0.000639539,0.000826055,0.00117583,0.00173971,0.00147411,0.00425427,0.00290752,0.0075635,0.0180777},
    {0.000489939,0.000748004,0.00106544,0.00130725,0.0021476,0.00300211,0.00460689,0.00430641,0.00958347},
    {0.000539929,0.000592858,0.00159546,0.001461,0.00161371,0.00332517,0.00381725,0.00692403,0.0137116},
    {0.000685138,0.0011504,0.00182689,0.00135556,0.00211262,0.00191136,0.00361452,0.00609861,0.0112248}
};
const double v26[5][npt24]={
    {0.0436647,0.0766372,0.115253,0.134962,0.138116,0.132017,0.129223,0.0959764,0.159984},
    {0.0427129,0.07916,0.119421,0.142728,0.147721,0.142104,0.138136,0.111479,0.0930553},
    {0.0439986,0.0812754,0.121722,0.141086,0.144929,0.14576,0.141362,0.103954,0.118998},
    {0.045338,0.081817,0.124592,0.145770,0.148010,0.151483,0.135710,0.115941,0.088239}
};
const double v26err[5][npt24]={
    {0.00117633,0.00172456,0.00243925,0.00331087,0.00340786,0.00552076,0.0053438,0.00634,0.023902},
    {0.000714298,0.00115609,0.00178786,0.00201899,0.00247538,0.0042914,0.00441189,0.00375012,0.00991865},
    {0.0007454,0.00108873,0.00211174,0.00242773,0.002964,0.00406841,0.00325586,0.0105999,0.0164428},
    {0.000950693,0.00149145,0.00207434,0.00228235,0.0025587,0.00320457,0.00459367,0.00899185,0.00916074}
};
const double v28[5][npt24]={
    {0.0413359,0.0745479,0.111287,0.1315,0.13296,0.120331,0.132252,0.105274,0.158618},
    {0.0424299,0.0761756,0.115879,0.137643,0.138677,0.13397,0.125922,0.103297,0.115589},
    {0.0424748,0.079193,0.118646,0.143186,0.147939,0.139611,0.137666,0.118945,0.0998064},
    {0.044857,0.081403,0.122831,0.143983,0.145980,0.150662,0.140130,0.104239,0.101058}
};
const double v28err[5][npt24]={
    {0.00174636,0.00232066,0.00378455,0.00539576,0.00686651,0.0070001,0.00972887,0.0107575,0.0177152},
    {0.0014467,0.00177893,0.00310776,0.00351237,0.00391883,0.00406891,0.00434652,0.00735751,0.0165999},
    {0.000964082,0.00149995,0.00232247,0.00286737,0.00303328,0.00467016,0.00455719,0.00512068,0.00835018},
    {0.000613315,0.00112984,0.0017138,0.00182123,0.00204996,0.0027923,0.00233936,0.00455531,0.00993196}
};


c1 = new TCanvas("c1"," ",1200,350);
makeMultiPanelCanvas(c1,4,1,0,0,0.15,0.15,0.01);
c2 = new TCanvas("c2"," ",1200,350);
makeMultiPanelCanvas(c2,4,1,0,0,0.15,0.15,0.01);
c3 = new TCanvas("c3"," ",1200,350);
makeMultiPanelCanvas(c3,4,1,0,0,0.15,0.15,0.01);
c1_ = new TCanvas("c1_"," ",1200,350);
makeMultiPanelCanvas(c1_,4,1,0,0,0.15,0.15,0.01);
    gStyle->SetOptFit(1);
    gStyle->SetOptStat(0);
    gStyle->SetOptTitle(0);
    gStyle->SetErrorX(0);
    TH1D *hFrame = new TH1D("","",80,-1,7);
    hFrame->SetTitle("");
    hFrame->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    hFrame->GetXaxis()->SetTitleSize(0.06);
    hFrame->GetYaxis()->SetTitleSize(0.06);
    hFrame->GetXaxis()->SetLabelSize(0.06);
    hFrame->GetYaxis()->SetLabelSize(0.06);
    hFrame->GetYaxis()->SetNdivisions(505);
    hFrame->GetXaxis()->CenterTitle();
    hFrame->GetYaxis()->CenterTitle();
    hFrame->GetXaxis()->SetRangeUser(-0.3,6.3);
int shift=2;
for(int i=shift;i<shift+ntotbin;i++){
        int t = ntotbin-(i-shift);
	//TFile *fProderr = TFile::Open(Form("M%d%d/mergedv_Prod2_sub.root",trkpointmax[i],trkpointmin[i]));
	TFile *fProd = TFile::Open(Form("mergedv_Prod2.root"));
	TFile *fProdtc = TFile::Open(Form("../tracktc/PbPb2011MB/mergedv_Prod2.root"));
	TFile *fProdlc = TFile::Open(Form("../tracklc/PbPb2011MB/mergedv_Prod2.root"));
	TFile *fProdzl = TFile::Open(Form("../trackzvtxl/PbPb2011MB/mergedv_Prod2.root"));
	TFile *fProdzs = TFile::Open(Form("../trackzvtxs/PbPb2011MB/mergedv_Prod2.root"));
	TFile *fProdpu = TFile::Open(Form("../PUrej/PbPb2011MB/mergedv_Prod2.root"));
	//TVectorD *vecDv2_Proderr = (TVectorD*)fProderr->Get(Form("D_%d/vmeanmean",ibin));
	//TVectorD *vecDv2err_Proderr = (TVectorD*)fProderr->Get(Form("D_%d/sigmavmeanmean",ibin));
	//TVectorD *vecDavgpt_Proderr = (TVectorD*)fProderr->Get(Form("D_%d/avgavgpt",ibin));
	
	TVectorD *vecDv2_Prod = (TVectorD*)fProd->Get(Form("D_%d/vmean",i));
	TVectorD *vecDv2err_Prod = (TVectorD*)fProd->Get(Form("D_%d/deltavmean",i));
	TVectorD *vecDavgpt_Prod = (TVectorD*)fProd->Get(Form("D_%d/avgpt",i));

	TVectorD *vecDv2_Prodtc = (TVectorD*)fProdtc->Get(Form("D_%d/vmean",i));
	TVectorD *vecDv2err_Prodtc = (TVectorD*)fProdtc->Get(Form("D_%d/deltavmean",i));
	TVectorD *vecDavgpt_Prodtc = (TVectorD*)fProdtc->Get(Form("D_%d/avgpt",i));

	TVectorD *vecDv2_Prodlc = (TVectorD*)fProdlc->Get(Form("D_%d/vmean",i));
	TVectorD *vecDv2err_Prodlc = (TVectorD*)fProdlc->Get(Form("D_%d/deltavmean",i));
	TVectorD *vecDavgpt_Prodlc = (TVectorD*)fProdlc->Get(Form("D_%d/avgpt",i));
	
        TVectorD *vecDv2_Prodzl = (TVectorD*)fProdzl->Get(Form("D_%d/vmean",i));
	TVectorD *vecDv2err_Prodzl = (TVectorD*)fProdzl->Get(Form("D_%d/deltavmean",i));
	TVectorD *vecDavgpt_Prodzl = (TVectorD*)fProdzl->Get(Form("D_%d/avgpt",i));

	TVectorD *vecDv2_Prodzs = (TVectorD*)fProdzs->Get(Form("D_%d/vmean",i));
	TVectorD *vecDv2err_Prodzs = (TVectorD*)fProdzs->Get(Form("D_%d/deltavmean",i));
	TVectorD *vecDavgpt_Prodzs = (TVectorD*)fProdzs->Get(Form("D_%d/avgpt",i));
	
        TVectorD *vecDv2_Prodpu = (TVectorD*)fProdpu->Get(Form("D_%d/vmean",i));
	TVectorD *vecDv2err_Prodpu = (TVectorD*)fProdpu->Get(Form("D_%d/deltavmean",i));
	TVectorD *vecDavgpt_Prodpu = (TVectorD*)fProdpu->Get(Form("D_%d/avgpt",i));

	//double *avgpt_Proderr = vecDavgpt_Proderr->GetMatrixArray();
	//double *v2_Proderr = vecDv2_Proderr->GetMatrixArray();
	//double *v2err_Proderr = vecDv2err_Proderr->GetMatrixArray();

	double *avgpt_Prod = vecDavgpt_Prod->GetMatrixArray();
	double *v2_Prod = vecDv2_Prod->GetMatrixArray();
	double *v2err_Prod = vecDv2err_Prod->GetMatrixArray();
	double *v2_Prodtc = vecDv2_Prodtc->GetMatrixArray();
	double *v2err_Prodtc = vecDv2err_Prodtc->GetMatrixArray();
	double *v2_Prodlc = vecDv2_Prodlc->GetMatrixArray();
	double *v2err_Prodlc = vecDv2err_Prodlc->GetMatrixArray();
	double *v2_Prodzl = vecDv2_Prodzl->GetMatrixArray();
	double *v2err_Prodzl = vecDv2err_Prodzl->GetMatrixArray();
	double *v2_Prodzs = vecDv2_Prodzs->GetMatrixArray();
	double *v2err_Prodzs = vecDv2err_Prodzs->GetMatrixArray();
	double *v2_Prodpu = vecDv2_Prodpu->GetMatrixArray();
	double *v2err_Prodpu = vecDv2err_Prodpu->GetMatrixArray();
	int npt = vecDavgpt_Prod->GetNrows();
        
	//if(i!=ntotbin-1)
	TGraphErrors *grProd=new TGraphErrors(npt,avgpt_Prod,v2_Prod,0,v2err_Prod);
	TGraphErrors *grProdtc=new TGraphErrors(npt,avgpt_Prod,v2_Prodtc,0,v2err_Prodtc);
	TGraphErrors *grProdlc=new TGraphErrors(npt,avgpt_Prod,v2_Prodlc,0,v2err_Prodlc);
	TGraphErrors *grProdzl=new TGraphErrors(npt,avgpt_Prod,v2_Prodzl,0,v2err_Prodzl);
	TGraphErrors *grProdzs=new TGraphErrors(npt,avgpt_Prod,v2_Prodzs,0,v2err_Prodzs);
	TGraphErrors *grProdpu=new TGraphErrors(npt,avgpt_Prod,v2_Prodpu,0,v2err_Prodpu);
	grProd->SetMarkerSize(1.5);
	grProd->SetMarkerStyle(20);
	grProd->SetMarkerColor(1);
	grProd->SetLineColor(1);
	grProdtc->SetMarkerSize(1.5);
	grProdtc->SetMarkerStyle(20);
	grProdtc->SetMarkerColor(2);
	grProdtc->SetLineColor(2);
	grProdlc->SetMarkerSize(1.5);
	grProdlc->SetMarkerStyle(24);
	grProdlc->SetMarkerColor(2);
	grProdlc->SetLineColor(2);
	grProdzl->SetMarkerSize(1.5);
	grProdzl->SetMarkerStyle(34);
	grProdzl->SetMarkerColor(4);
	grProdzl->SetLineColor(4);
	grProdzs->SetMarkerSize(1.5);
	grProdzs->SetMarkerStyle(33);
	grProdzs->SetMarkerColor(4);
	grProdzs->SetLineColor(4);
	grProdpu->SetMarkerSize(1.5);
	grProdpu->SetMarkerStyle(33);
	grProdpu->SetMarkerColor(4);
	grProdpu->SetLineColor(4);

	TGraphErrors *grProdr=(TGraphErrors*)grProd->Clone("grProdr");
	TGraphErrors *grProdtcr=(TGraphErrors*)grProdtc->Clone("grProdtcr");
	TGraphErrors *grProdlcr=(TGraphErrors*)grProdlc->Clone("grProdlcr");
	TGraphErrors *grProdzlr=(TGraphErrors*)grProdzl->Clone("grProdzlr");
	TGraphErrors *grProdzsr=(TGraphErrors*)grProdzs->Clone("grProdzsr");
	TGraphErrors *grProdpur=(TGraphErrors*)grProdpu->Clone("grProdpur");
        for(int j = 0;j<grProd->GetN();j++){
            double x = grProd->GetX()[j];
            double y = grProd->GetY()[j];
            double y_sys = grProdtc->GetY()[j];
            grProdtcr->SetPoint(j,x,y_sys/y);
            grProdtcr->SetPointError(j,0,0);
            double y_sys = grProdlc->GetY()[j];
            grProdlcr->SetPoint(j,x,y_sys/y);
            grProdlcr->SetPointError(j,0,0);
            double y_sys = grProdzl->GetY()[j];
            grProdzlr->SetPoint(j,x,y_sys/y);
            grProdzlr->SetPointError(j,0,0);
            double y_sys = grProdzs->GetY()[j];
            grProdzsr->SetPoint(j,x,y_sys/y);
            grProdzsr->SetPointError(j,0,0);
            double y_sys = grProdpu->GetY()[j];
            grProdpur->SetPoint(j,x,y_sys/y);
            grProdpur->SetPointError(j,0,0);
            grProdr->SetPoint(j,x,1.);
            grProdr->SetPointError(j,0,0);
        }
	c1->cd(t);
        hFrame->SetMaximum(0.35);
        hFrame->SetMinimum(0);
        hFrame->GetYaxis()->SetTitle("v_{2}");	
	hFrame->DrawCopy();
	grProd->Draw("Psame");
	grProdtc->Draw("Psame");
	grProdlc->Draw("Psame");
	TLegend *tl = new TLegend(0.2,0.70,0.4,0.95);
	tl->SetFillColor(0);
	tl->SetBorderSize(0);
	tl->SetTextSize(0.055);
	tl->AddEntry(grProd,"v_{2}{LYZ}","lp");
	tl->AddEntry(grProdtc,"v_{2}{LYZ} loose cut ","lp");
	tl->AddEntry(grProdlc,"v_{2}{LYZ} tight cut","lp");
        TLatex *tlx0 = new TLatex(0.2,0.85,Form("CMS PbPb #sqrt{s_{NN}} = 2.76TeV"));
	tlx0->SetNDC();
	tlx0->SetTextSize(0.065);
	if(t==1)
	tlx0->Draw("same");
	if(t==1) 
		TLatex *tlx2 = new TLatex(0.6,0.2,Form("%d<N_{trk}^{offline}<%d",trkbin[i+1],trkbin[i]));
	else
		TLatex *tlx2 = new TLatex(0.5,0.2,Form("%d<N_{trk}^{offline}<%d",trkbin[i+1],trkbin[i]));
	if(t==2) tl->Draw("same");
	tlx2->SetNDC();
	tlx2->SetTextSize(0.055);
	tlx2->Draw("same");

        c2->cd(t);
        hFrame->SetMaximum(0.35);
        hFrame->SetMinimum(0);
        hFrame->GetYaxis()->SetTitle("v_{2}");	
	hFrame->DrawCopy();
	grProd->Draw("Psame");
	grProdzl->Draw("Psame");
	grProdzs->Draw("Psame");
	TLegend *tl = new TLegend(0.2,0.70,0.4,0.95);
	tl->SetFillColor(0);
	tl->SetBorderSize(0);
	tl->SetTextSize(0.055);
	tl->AddEntry(grProd,"v_{2}{LYZ}","lp");
	tl->AddEntry(grProdzl,"v_{2}{LYZ} 3 < zvertex < 15 ","lp");
	tl->AddEntry(grProdzs,"v_{2}{LYZ} zvertex < 3","lp");
        TLatex *tlx0 = new TLatex(0.2,0.85,Form("CMS PbPb #sqrt{s_{NN}} = 2.76TeV"));
	tlx0->SetNDC();
	tlx0->SetTextSize(0.065);
	if(t==1)
	tlx0->Draw("same");
	if(t==1) 
		TLatex *tlx2 = new TLatex(0.6,0.2,Form("%d<N_{trk}^{offline}<%d",trkbin[i+1],trkbin[i]));
	else
		TLatex *tlx2 = new TLatex(0.5,0.2,Form("%d<N_{trk}^{offline}<%d",trkbin[i+1],trkbin[i]));
	if(t==2) tl->Draw("same");
	tlx2->SetNDC();
	tlx2->SetTextSize(0.055);
	tlx2->Draw("same");

        c3->cd(t);
        hFrame->SetMaximum(0.35);
        hFrame->SetMinimum(0);
        hFrame->GetYaxis()->SetTitle("v_{2}");	
	hFrame->DrawCopy();
	grProd->Draw("Psame");
	grProdpu->Draw("Psame");
	tl->AddEntry(grProdzs,"v_{2}{LYZ} zvertex < 3","lp");
        TLatex *tlx0 = new TLatex(0.2,0.85,Form("CMS PbPb #sqrt{s_{NN}} = 2.76TeV"));
	tlx0->SetNDC();
	tlx0->SetTextSize(0.065);
	if(t==1)
	tlx0->Draw("same");
	if(t==1) 
		TLatex *tlx2 = new TLatex(0.6,0.2,Form("%d<N_{trk}^{offline}<%d",trkbin[i+1],trkbin[i]));
	else
		TLatex *tlx2 = new TLatex(0.5,0.2,Form("%d<N_{trk}^{offline}<%d",trkbin[i+1],trkbin[i]));
	if(t==2) tl->Draw("same");
	tlx2->SetNDC();
	tlx2->SetTextSize(0.055);
	tlx2->Draw("same");

        c1_->cd(t);
        hFrame->SetMaximum(1.2);
        hFrame->SetMinimum(0.8);
        hFrame->GetYaxis()->SetTitle("v_{2} systematics");	
	hFrame->DrawCopy();
	grProdr->Draw("Psame");
	grProdtcr->Draw("Psame");
	grProdlcr->Draw("Psame");
	grProdzlr->Draw("Psame");
	grProdzsr->Draw("Psame");
	if(t==1)
	tlx0->Draw("same");
	if(t==2) tl->Draw("same");
	tlx2->Draw("same");
	fProd->Close();
        }
	c1->Print("v2vspt_4p_sys.png");
	c1->Print("v2vspt_4p_sys.pdf");
	c2->Print("v2vspt_4p_sys.png");
	c2->Print("v2vspt_4p_sys.pdf");
	c3->Print("v2vspt_4p_sys.png");
	c3->Print("v2vspt_4p_sys.pdf");
	c1_->Print("v2vspt_4p_sysr.png");
	c1_->Print("v2vspt_4p_sysr.pdf");
}
Example #2
0
void compare3(
		    std::string var="h_mh_parton", 
		    bool logScale=false,
		    float xmin=-9999.0, float xmax=-9999.0
		    )
{
  
  setTDRStyle();
  gStyle->SetOptStat(0);

  const int NHISTOS=3;
  TH1D* h[NHISTOS];

  TFile *fmc[NHISTOS];
  
  std::string mcfile[NHISTOS]={
    "dijetmass_study_20120913/studymjj_ak5_GluGluToHToZZTo2L2Q_M-300_8TeV-powheg-pythia6.root",
    "dijetmass_study_20120913/studymjj_ak5_GluGluToHToZZTo2L2Q_M-600_8TeV-powheg-pythia6.root",
    "dijetmass_study_20120913/studymjj_ak5_GluGluToHToZZTo2L2Q_M-900_8TeV-powheg-pythia6.root"
  };

  std::string mcName[NHISTOS]={
    "M_{H}=300 GeV",
    "M_{H}=600 GeV",
    "M_{H}=900 GeV"

  };


  for(int i=0; i<NHISTOS; i++){

    fmc[i] = TFile::Open(mcfile[i].data());
    h[i]   = (TH1D*)(fmc[i]->Get(var.data()));
    cout << "Opening " << fmc[i]->GetName() << endl;
  }


  int COLOR[NHISTOS]={4,1, 2};
  int MARKERSTYLE[NHISTOS]={24,21,29};

  for(int i=0; i < NHISTOS; i++){


//     h[i]->SetTitle("");
    h[i]->GetXaxis()->SetNdivisions(5);
    h[i]->GetYaxis()->SetNdivisions(5);
//     h[i]->GetYaxis()->SetDecimals();
    h[i]->SetLineColor(COLOR[i]);
    h[i]->SetMarkerColor(COLOR[i]);
    h[i]->SetMarkerSize(1);
    h[i]->SetMarkerStyle(MARKERSTYLE[i]);
    h[i]->SetTitleOffset(1.0,"Y");

  }

  // if normalizing to the same area, set the scale 

  int binLo = -1;
  int binHi = -1;
  int nbins = h[0]->GetNbinsX();
  if(xmin>-9999.0 && xmax>-9999.0)
    {

      binLo = h[0]->FindBin(xmin);
      binHi = h[0]->FindBin(xmax)-1;

    }

  else
    {
      binLo = 1;
      binHi = nbins;
      xmin = h[0]->GetBinLowEdge(1);
      xmax = h[0]->GetBinLowEdge(nbins+1);
    }


  float scaleFactor[NHISTOS]={1};

  for(int ih=0; ih < NHISTOS; ih++){
    
    float integral = h[ih]->Integral(binLo,binHi);
    scaleFactor[ih] = integral > 0? 1.0/integral: 1;
    h[ih]->Sumw2();
    h[ih]->Scale(scaleFactor[ih]);

  }

  for(int ih=0; ih < NHISTOS; ih++)
    cout << "histogram " << ih << " integral = " << h[ih]->Integral() << endl;

  for(int ih=0; ih < NHISTOS; ih++)
    cout << "histogram " << ih << " integral = " << h[ih]->Integral(binLo, 
								    binHi)
	 << endl;


  vector<float> maxArray;
  maxArray.clear();

  for(int ih=0; ih < NHISTOS; ih++){

    h[ih]->GetXaxis()->SetRangeUser(xmin,xmax);
    float max_this  = h[ih]->GetBinError(h[ih]->GetMaximumBin()) + h[ih]->GetMaximum();
    maxArray.push_back(max_this);

  }


  float max = *max_element(maxArray.begin(),maxArray.end());
  cout << "Max = " << max << endl;

  for(int ih=0; ih < NHISTOS; ih++){

    h[ih]->SetMaximum(1.1*max);

  }

  cout << "here" << endl;
  TCanvas* c1 = new TCanvas("c1","",600,500);  
  if(logScale)
    gPad->SetLogy(1);
  gStyle->SetTitleX(0.1);
  h[0]->Draw("e");
  for(int ih=0; ih < NHISTOS-1; ih++)
    h[ih]->Draw("esame");

  h[NHISTOS-1]->Draw("hesame");

  TLine mLocation(MZ_PDG,0.0,MZ_PDG,h[0]->GetMaximum());
  mLocation.SetLineStyle(2);
  mLocation.SetLineColor(kMagenta-6);
  mLocation.SetLineWidth(3);

  if(var.find("mjj")!=std::string::npos || var.find("mll")!=std::string::npos)
    mLocation.Draw("same");
  
  float x1NDC = 0.669355;
  float y1NDC = 0.708475;
  float x2NDC = 0.889113;
  float y2NDC = 0.925847;

  std::string headertitle = "H^{0}#rightarrow ZZ#rightarrow 2l2q";
  TLegend* leg = new TLegend(x1NDC,y1NDC,x2NDC,y2NDC);
  leg->SetFillColor(0);
  leg->SetFillStyle(0);
  leg->SetTextSize(0.04);
  leg->SetBorderSize(0);
  leg->SetHeader("anti-kt05");
  for(int i=0; i < NHISTOS; i++)
    leg->AddEntry(h[i], mcName[i].data());
  leg->Draw("same");


  string dirName = "20120913_3histograms";
  gSystem->mkdir(dirName.data());

  std::string filename;
  std::string psname = dirName + "/ak5" + var;

  if(logScale)
    psname += "_log";

  filename = psname + ".eps";
  c1->Print(filename.data());
  filename = psname + ".gif";
  c1->Print(filename.data());
  filename = psname + ".pdf";
  c1->Print(filename.data());
  //   c1->Close();
}
Example #3
0
void toy_bootstrap(){

   // random number seed
   GSLr.SetSeed(1);

   // run measurements, fill graphs
   TGraph *g1D = new TGraph();
   TGraphErrors *g2D = new TGraphErrors();
   TGraph *g1DIndPE = new TGraph();
   TGraph *g2DIndPE = new TGraph();
   TGraph *g1DBPE = new TGraph();
   TGraph *g2DBPE = new TGraph();

   TGraph *g1Dm = new TGraph();
   TGraphErrors *g2Dm = new TGraphErrors();
   TGraph *g1DIndPEm = new TGraph();
   TGraph *g2DIndPEm = new TGraph();
   TGraph *g1DBPEm = new TGraph();
   TGraph *g2DBPEm = new TGraph();

   for(int i=0; i < 10; i++){

      rho12 = 1.0*i/10;
      cout << "#################### rho = " << rho12 << " ####################" << endl;

      run_measurement();

      g2D->SetPoint(i, rho12+0.05, X2Drms);
      g2D->SetPointError(i, 0.05, 0.0);

      g1D->SetPoint(i, rho12+0.05, X1Drms);
      g1DIndPE->SetPoint(i, rho12+0.02, XI1Drms);
      g2DIndPE->SetPoint(i, rho12+0.04, XI2Drms);
      g1DBPE->SetPoint(i, rho12+0.06, XB1Drms);
      g2DBPE->SetPoint(i, rho12+0.08, XB2Drms);

      g2Dm->SetPoint(i, rho12+0.05, X2Dmean);
      g2Dm->SetPointError(i, 0.05, 0.0);

      g1Dm->SetPoint(i, rho12+0.05, X1Dmean);
      g1DIndPEm->SetPoint(i, rho12+0.02, XI1Dmean);
      g2DIndPEm->SetPoint(i, rho12+0.04, XI2Dmean);
      g1DBPEm->SetPoint(i, rho12+0.06, XB1Dmean);
      g2DBPEm->SetPoint(i, rho12+0.08, XB2Dmean);

   }

   TCanvas *canvas = new TCanvas("canvas","canvas",800,800);
   canvas->cd();

   g2D->SetMarkerStyle(20);
   g1D->SetLineColor(2);
   g1D->SetMarkerColor(2);
   g1D->SetMarkerStyle(5);
   g1DIndPE->SetLineColor(3);
   g1DIndPE->SetMarkerColor(3);
   g1DIndPE->SetMarkerStyle(20);
   g2DIndPE->SetLineColor(4);
   g2DIndPE->SetMarkerColor(4);
   g2DIndPE->SetMarkerStyle(20);
   g1DBPE->SetLineColor(7);
   g1DBPE->SetMarkerColor(7);
   g1DBPE->SetMarkerStyle(20);
   g2DBPE->SetLineColor(6);
   g2DBPE->SetMarkerColor(6);
   g2DBPE->SetMarkerStyle(20);

   g2D->Draw("APE");
   g1D->Draw("P");
   g1DIndPE->Draw("P");
   g2DIndPE->Draw("P");
   g1DBPE->Draw("P");
   g2DBPE->Draw("P");

   TLegend * legend = new TLegend(0.717,0.650,0.874,0.870);
   legend->AddEntry( g2D, "2D fit MINUIT error", "p" );
   legend->AddEntry( g1D, "1D fit MINUIT error", "p" );
   legend->AddEntry( g2DIndPE, "2D fit, Ind. PE RMS", "p" );
   legend->AddEntry( g1DIndPE, "1D fit, Ind. PE RMS", "p" );
   legend->AddEntry( g2DBPE, "2D fit, Boot PE RMS", "p" );
   legend->AddEntry( g1DBPE, "1D fit, Boot PE RMS", "p" );
   legend->Draw("same");

   canvas->Draw();

   // plot means
   TCanvas *canvasm = new TCanvas("canvasm","canvasm",800,800);
   canvasm->cd();

   g2Dm->SetMarkerStyle(20);
   g1Dm->SetLineColor(2);
   g1Dm->SetMarkerColor(2);
   g1Dm->SetMarkerStyle(5);
   g1DIndPEm->SetLineColor(3);
   g1DIndPEm->SetMarkerColor(3);
   g1DIndPEm->SetMarkerStyle(20);
   g2DIndPEm->SetLineColor(4);
   g2DIndPEm->SetMarkerColor(4);
   g2DIndPEm->SetMarkerStyle(20);
   g1DBPEm->SetLineColor(7);
   g1DBPEm->SetMarkerColor(7);
   g1DBPEm->SetMarkerStyle(20);
   g2DBPEm->SetLineColor(6);
   g2DBPEm->SetMarkerColor(6);
   g2DBPEm->SetMarkerStyle(20);

   g2Dm->Draw("APE");
   g1Dm->Draw("P");
   g1DIndPEm->Draw("P");
   g2DIndPEm->Draw("P");
   g1DBPEm->Draw("P");
   g2DBPEm->Draw("P");

   TLegend * legendm = new TLegend(0.717,0.650,0.874,0.870);
   legendm->AddEntry( g2D, "2D fit MINUIT central value", "p" );
   legendm->AddEntry( g1D, "1D fit MINUIT central value", "p" );
   legendm->AddEntry( g2DIndPE, "2D fit, Ind. PE mean", "p" );
   legendm->AddEntry( g1DIndPE, "1D fit, Ind. PE mean", "p" );
   legendm->AddEntry( g2DBPE, "2D fit, Boot PE mean", "p" );
   legendm->AddEntry( g1DBPE, "1D fit, Boot PE mean", "p" );
   legendm->Draw("same");

   canvasm->Draw();

   return;
}
v723pt_compare()
{
  gROOT->Reset();
  gROOT->SetStyle("MyStyle");
//  gROOT->LoadMacro("v2pt_12cen_MyDef.C");
  // gROOT->LoadMacro("MyDef.C");
  gStyle->SetTextFont(43);
  gStyle->SetLabelFont(43,"x");
  gStyle->SetLabelFont(43,"y");
  gStyle->SetLabelFont(43,"z");
  gStyle->SetTitleFont(43,"x");
  gStyle->SetTitleFont(43,"y");
  gStyle->SetTitleFont(43,"z");
  gStyle->SetEndErrorSize(0);

  double textsize = 19;

//int   mcol[8]={kRed,kMagenta,kBlue,kCyan,kGreen,kYellow,kOrange,kGray};
int   mcol[8]={kRed,kOrange+1,kBlue,kGreen+1,kCyan,kYellow,kOrange,kGray};
int   mcol2[4]={6,2,4,8};

//int   msty[8][2]={{20,20},{25,24},{22,22},{28,26},{29,30},{33,27},{34,28},{20,24}};
int   msty[8][2]={{20,20},{21,24},{22,29},{23,30},{24,30},{25,27},{28,28},{30,24}};


//float msiz[8]={1.11,0.9,1.2,1.24,1.5,1,1,1};
float msiz[8]={1.11,1.0,1.5,1.2,1.2,1.2,1.2,1.6};
float msiz2[4]={1.5,1.5,1.5,1.5};
//
// arrays
//
const int Mfiles=50;
int   ndp[Mfiles];
char *cfn[Mfiles];
char *cft[Mfiles];
const int Mpoints=40;
double xa[Mfiles][Mpoints],xe[Mfiles][Mpoints];
double ya[Mfiles][Mpoints],ye[Mfiles][Mpoints];
double nxa[Mfiles][Mpoints],nxe[Mfiles][Mpoints];
double nya[Mfiles][Mpoints],nye[Mfiles][Mpoints];

double aexl[Mfiles][Mpoints],aexh[Mfiles][Mpoints];
double aeyl[Mfiles][Mpoints],aeyh[Mfiles][Mpoints];



double ra[Mfiles][Mpoints],re[Mfiles][Mpoints];

const int Mpads=14;


char  *htit[Mpads];
char  *atit[Mpads][3];
double ptit[Mpads][2];
double hxmin[Mpads],hxmax[Mpads];
double hymin[Mpads],hymax[Mpads];
double lxmin[Mpads],lxmax[Mpads];
double lymin[Mpads],lymax[Mpads];


 
  //
  // Data input
  //
  char *cjob="v2pt_12cen_4x3";
  int i=-1;


  // histogram parameter
  htit[0]="0-5%";
  htit[1]="5-10%";
  htit[2]="10-15%";
  htit[3]="15-20%";
  htit[4]="20-25%";
  htit[5]="25-30%";
  htit[6]="30-35%";
  htit[7]="35-40%";
  htit[8]="40-50%";
  htit[9]="50-60%";
  htit[10]="60-70%";
  htit[11]="70-80%";
  for (int ip=0;ip<Mpads;ip++)
  {
    //  hxmin[ip]=0.0; hxmax[ip]=11.9;
    hxmin[ip]=0.0001; hxmax[ip]=6.8;
    //hymin[ip]=-0.6001; hymax[ip]=4.099;
    hymin[ip]=0.48; hymax[ip]=1.52;
    lxmin[ip]=0.04; lxmax[ip]=0.15;
    lymin[ip]=0.56; lymax[ip]=0.65;
    //ptit[ip][0]=4.0; ptit[ip][1]=3.308;// position legends 
    ptit[ip][0]=4.0; ptit[ip][1]=1.168;// position legends 
    //atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="#chi_{422}";
    atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="v_{7}{#Psi_{223}} ratio";
  }
  //
  // Read data and create vector files
  //

  double tmp;
  const int nw=12;
  const int npt=15;
  ifstream inEP;
  inEP.open("../outv723_corrFlow.txt");
  for(int i=0; i<nw; i++){
      inEP>>tmp; inEP>>tmp;
    for(int j=0; j<npt+5; j++){
      inEP>>tmp; inEP>>tmp; inEP>>xa[i][j]; inEP>>tmp; inEP>>ya[i][j]; inEP>>ye[i][j];
      if(ye[i][j]<0) ye[i][j]=-ye[i][j];
      xe[i][j]=0.0;
    }
  }
  inEP.close();

  ifstream inSP;
  inSP.open("./Stevedata/mv723m.txt");
  for(int i=0; i<nw; i++){
      //inSP>>tmp; inSP>>tmp;
    for(int j=0; j<npt+3; j++){
      inSP>>nxa[i][j]; inSP>>nya[i][j]; inSP>>nye[i][j];
      nxe[i][j]=0.0;

      nya[i][j]=nya[i][j]/ya[i][j];
      nye[i][j]=ye[i][j]/ya[i][j];
    }
  }
  inSP.close();


  TCanvas *can=new TCanvas("can","can",10,10,1050*0.9,800*0.85);

  can->Divide(4,3,0,0); //sticks the pads with no space inbetween 
  
  TH1D *h1[nw];
  for (int iw=0;iw<nw;iw++)
  {
    can->cd(iw+1);
    if(iw==3||iw==7||iw==11) gPad->SetRightMargin(0.02);
    char ch1[8];
    sprintf(ch1,"h1_%d",iw);
    h1[iw] = new TH1D(ch1,"",500,hxmin[iw],hxmax[iw]);
    h1[iw]->SetMinimum(hymin[iw]); h1[iw]->SetMaximum(hymax[iw]);
    h1[iw]->SetXTitle(atit[iw][0]); h1[iw]->SetYTitle(atit[iw][1]);
    h1[iw]->GetXaxis()->CenterTitle(1);
    h1[iw]->GetYaxis()->CenterTitle(1);

    // futz with the axes
    h1[iw]->GetYaxis()->SetNdivisions(606);
    h1[iw]->GetXaxis()->SetNdivisions(606);

      h1[iw]->GetYaxis()->SetTitleSize(textsize);
      h1[iw]->GetYaxis()->SetTitleOffset(3.0);
      h1[iw]->GetYaxis()->SetLabelSize(textsize);
      h1[iw]->GetXaxis()->SetTitleSize(textsize);
      h1[iw]->GetXaxis()->SetTitleOffset(3.0);
      h1[iw]->GetXaxis()->SetLabelSize(textsize);
     // h1[iw]->GetXaxis()->SetLabelOffset(1.2);

    h1[iw]->Draw();
  }
  //
  // Draw! 
  //
  cout << "Now Draw!" << endl;
  TGraphErrors *ge;
  for (int iw=0;iw<nw-2;iw++)
  {
    can->cd(iw+1);

    //
    if (iw==0)
    {
      tex=new TLatex(1.5,8.08,"CMS PbPb #sqrt{s_{NN}}=2.76TeV");
      tex->SetTextSize(textsize);
      //tex->Draw();
      tex=new TLatex(1.5,7.07,"|#eta|<0.8");
      tex->SetTextSize(textsize);
      tex->Draw();
    }
    if (iw < 4) tex=new TLatex(ptit[iw][0],ptit[iw][1],htit[iw]);
    else tex=new TLatex(ptit[iw][0],ptit[iw][1],htit[iw]);
    if ( iw == 0)   tex->SetTextSize(textsize);
    else if (iw == 8) tex->SetTextSize(textsize);
    else  tex->SetTextSize(textsize);
    tex->Draw();
    //
    // Legend
    //
    TLegend *leg = new TLegend(lxmin[iw]*3.3,lymin[iw]*1.3,lxmax[iw]*2.2,lymax[iw]*1.3);
    leg->SetTextSize(textsize);
    //
    // Read data
    //
    for (int im=0;im<1;im++)
    {
      int j=im*12+iw;
      int col=1;
      //if (ndp[j]==0) continue;
      ge=new TGraphErrors(16,&xa[j][0],&nya[j][0],&xe[j][0],&nye[j][0]);
      ge->SetTitle("");
      ge->SetMarkerStyle(msty[im][1]);
      //      ge->SetMarkerStyle(msty[im]);
      ge->SetMarkerSize(msiz[im]);
      ge->SetMarkerColor(col);
      ge->SetLineWidth(1.2);
      ge->SetLineColor(col);
      ge->Draw("pe");
      leg->AddEntry(ge,"Steve/Shengquan","p");
    }
    if (iw==1) leg->Draw();
    TLine *line = new TLine(0,1,6.8,1);
    line->SetLineStyle(2);
    line->Draw();
/*
    for (int im=0;im<1;im++)
    {
      int j=im*12+iw;
      int col=2;
      //if (ndp[j]==0) continue;
      ge=new TGraphErrors(16,&nxa[j][0],&nya[j][0],&nxe[j][0],&nye[j][0]);
      ge->SetTitle("");
      ge->SetMarkerStyle(25);
      //      ge->SetMarkerStyle(msty[im]);
      ge->SetMarkerSize(msiz[im]);
      ge->SetMarkerColor(col);
      ge->SetLineWidth(1.2);
      ge->SetLineColor(col);
      ge->Draw("pe");
      leg->AddEntry(ge,"Steve","p");
    }
*/
  }
  cout << "end of process" << endl;
  can->cd();
  can->Print("./figures/v723_pt_12cent.png");
  can->Print("./figures/v723_pt_12cent.pdf");
}
void fastEfficiencyNadir(unsigned int iEG, int iECAL1, int iColl1, int iECAL2, int iColl2,
			 TString dirIn, 
			 TString lumi, int nCPU, 
			 int color1, int style1, int color2, int style2,
			 TString probe, TString tag, TString fileIn)
{
  // STYLE //
  gROOT->Reset();
  loadPresentationStyle();  
  gROOT->ForceStyle();

  // EG THRESHOLDS //
  const int nEG = 71;
  double thres[nEG];
  for(int i=0 ; i<nEG ; i++) thres[i]=i;

  TString names[nEG];
  ostringstream ossi;
  for(int i=0;i<(int)nEG;i++) {
    ossi.str("");
    ossi << thres[i] ;
    names[i] = ossi.str();
  }

  // NAMES //
  const int nECAL=2;
  const int nColl=2;

  TString name_leg_ecal[nECAL] = {"Barrel","Endcaps"};
  TString name_leg_coll[nColl] = {"Online","Emulation"};  

  TString name_ecal[nECAL] = {"_EB","_EE"};
  TString name_coll[nColl] = {"_N","_M"};

  TString dirResults = dirIn + "/turnons/EG"+names[iEG]+"/" ;
  TString name_image = 
    dirResults + "eff_EG"+names[iEG]+"_tag"+tag+"_probe"+probe+name_ecal[iECAL1]+name_coll[iColl1]+"_vs"+name_ecal[iECAL2]+name_coll[iColl2] ;

  // Output log //
  ofstream fichier(name_image+".txt", ios::out);


  // BINNING //
  const int nbins[nEG] = {29,29,29,29,21,21,21,22,22,21,22,21,22,18,19,18,18,18,18,20,20,20,20,19,20,20,20,20,21,21,
			  21,21,21,21,21,21,21,21,21,21, //EG30
			  22,22,22,22,22,22,22,22,22,22, //EG40
			  29,29,29,29,29,29,29,29,29,29, //EG50
			  29,29,29,29,29,29,29,29,29,29};//EG60

  Double_t bins_0[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG0
  Double_t bins_1[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG1
  Double_t bins_2[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG2 
  Double_t bins_3[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG3

  Double_t bins_4[21] = {1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 15, 17, 19, 21, 27, 32, 41, 50, 60, 70, 150}; // EG4
  Double_t bins_5[21] = {2, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 31, 40, 50, 60, 70, 150}; // EG5
  Double_t bins_6[21] = {3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 17, 19, 21, 23, 27, 32, 41, 50, 60, 70, 150}; // EG6

  Double_t bins_7[22] = {2, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 31, 40, 50, 60, 70, 150}; // EG7
  Double_t bins_8[22] = {3, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21, 23, 25, 27, 32, 41, 50, 60, 70, 150}; // EG8
  Double_t bins_9[21] = {4, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 31, 40, 50, 60, 70, 150}; // EG9

  Double_t bins_10[22] = {5, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 21, 23, 25, 27, 29, 32, 41, 50, 60, 70, 150}; // EG10
  Double_t bins_11[21] = {6, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 26, 28, 31, 40, 50, 60, 70, 150}; // EG11
  Double_t bins_12[22] = {5, 7, 9, 10, 11, 12, 13, 14, 15, 17, 19, 21, 23, 25, 27, 29, 32, 41, 50, 60, 70, 150}; // EG12

  Double_t bins_13[18] = {5, 7, 9, 11, 12, 13, 14, 15, 17, 19, 22, 25, 29, 37, 50, 60, 70, 150}; // EG13
  Double_t bins_14[19] = {6, 8, 10, 12, 13, 14, 15, 16, 18, 20, 22, 25, 30, 35, 40, 50, 60, 70, 150}; // EG14
  Double_t bins_15[18] = {5, 7, 9, 11, 13, 14, 15, 16, 17, 19, 22, 25, 29, 37, 50, 60, 70, 150}; // EG15

  Double_t bins_16[18] = {8, 10, 12, 14, 16, 17, 18, 19, 20, 22, 25, 30, 35, 40, 50, 60, 70, 150}; // EG16
  Double_t bins_17[18] = {9, 11, 13, 15, 16, 17, 18, 19, 21, 23, 25, 30, 35, 40, 50, 60, 70, 150}; // EG17
  Double_t bins_18[18] = {8, 10, 12, 14, 16, 17, 18, 19, 20, 22, 25, 30, 35, 40, 50, 60, 70, 150}; // EG18

  Double_t bins_19[20] = {9, 11, 13, 15, 17, 18, 19, 20, 21, 23, 25, 27, 30, 35, 40, 45, 50, 60, 70, 150}; // EG19
  Double_t bins_20[20] = {8, 10, 12, 14, 16, 18, 19, 20, 21, 22, 24, 26, 30, 35, 40, 45, 50, 60, 70, 100}; // EG20
  Double_t bins_21[20] = {9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 27, 30, 35, 40, 45, 50, 60, 70, 150}; // EG21

  Double_t bins_22[20] = {10, 12, 14, 16, 18, 20, 21, 22, 23, 24, 26, 28, 30, 35, 40, 45, 50, 60, 70, 150}; // EG22
  Double_t bins_23[19] = {11, 13, 15, 17, 19, 21, 22, 23, 24, 25, 27, 30, 35, 40, 45, 50, 60, 70, 150}; // EG23
  Double_t bins_24[20] = {10, 12, 14, 16, 18, 20, 22, 23, 24, 25, 26, 28, 30, 35, 40, 45, 50, 60, 70, 150}; // EG24

  Double_t bins_25[20] = {11, 13, 15, 17, 19, 21, 23, 24, 25, 26, 27, 29, 30, 35, 40, 45, 50, 60, 70, 150}; // EG25
  Double_t bins_26[20] = {10, 12, 14, 16, 18, 20, 22, 24, 25, 26, 27, 28, 30, 35, 40, 45, 50, 60, 70, 150}; // EG26
  Double_t bins_27[20] = {11, 13, 15, 17, 19, 21, 23, 25, 26, 27, 28, 29, 33, 35, 40, 45, 50, 60, 70, 150}; // EG27

  Double_t bins_28[21] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 27, 28, 29, 30, 32, 35, 40, 45, 50, 60, 70, 150}; // EG28
  Double_t bins_29[21] = {11, 13, 15, 17, 19, 21, 23, 25, 27, 28, 29, 30, 31, 33, 35, 40, 45, 50, 60, 70, 150}; // EG29
  Double_t bins_30[21] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 29, 30, 31, 32, 35, 40, 45, 50, 60, 70, 150}; // EG30

  Double_t bins_40[22] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 38, 39, 40, 42, 45, 50, 60, 70, 150}; // EG40
  Double_t bins_50[29] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 48, 50, 55, 60, 70, 90, 110, 130, 150, 170, 190}; // EG50
  Double_t bins_60[29] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 48, 50, 55, 60, 70, 90, 110, 130, 150, 170, 190}; // EG60

  vector< Double_t* > bins;
  bins.push_back( bins_0 ); bins.push_back( bins_1 ); bins.push_back( bins_2 ); bins.push_back( bins_3 ); bins.push_back( bins_4 ); 
  bins.push_back( bins_5 ); bins.push_back( bins_6 ); bins.push_back( bins_7 ); bins.push_back( bins_8 ); bins.push_back( bins_9 ); 
  bins.push_back( bins_10 ); bins.push_back( bins_11 ); bins.push_back( bins_12 ); bins.push_back( bins_13 ); bins.push_back( bins_14 ); 
  bins.push_back( bins_15 ); bins.push_back( bins_16 ); bins.push_back( bins_17 ); bins.push_back( bins_18 ); bins.push_back( bins_19 ); 
  bins.push_back( bins_20 ); bins.push_back( bins_21 ); bins.push_back( bins_22 ); bins.push_back( bins_23 ); bins.push_back( bins_24 ); 
  bins.push_back( bins_25 ); bins.push_back( bins_26 ); bins.push_back( bins_27 ); bins.push_back( bins_28 ); bins.push_back( bins_29 ); 

  for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_30 );
  for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_40 );
  for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_50 );
  for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_60 );

  RooBinning binning = RooBinning(nbins[iEG]-1, bins[iEG], "binning");


  // INPUT DATA //
  TFile* f1 = TFile::Open(dirIn+"/"+fileIn);

  TTree* treenew;
  TTree* treenew_2;

  treenew = (TTree*) gDirectory->Get( "treenew"+name_ecal[iECAL1]+name_coll[iColl1] ) ;
  treenew_2 = (TTree*) gDirectory->Get( "treenew"+name_ecal[iECAL2]+name_coll[iColl2] ) ;

  TString name_scet[2], name_scdr[2], name_l1bin[2];
  name_scet[0] = "sc_et"+name_ecal[iECAL1]+name_coll[iColl1];
  name_scet[1] = "sc_et"+name_ecal[iECAL2]+name_coll[iColl2];
  name_scdr[0] = "sc_dr"+name_ecal[iECAL1]+name_coll[iColl1];
  name_scdr[1] = "sc_dr"+name_ecal[iECAL2]+name_coll[iColl2];
  
  name_l1bin[0] = "l1_"+names[iEG]+name_ecal[iECAL1]+name_coll[iColl1];
  name_l1bin[1] = "l1_"+names[iEG]+name_ecal[iECAL2]+name_coll[iColl2];

  RooRealVar et_plot(name_scet[0],name_scet[0],0,150) ;
  RooRealVar dr(name_scdr[0],name_scdr[0],0.5,1.5) ; 
  RooRealVar et_plot2(name_scet[1],name_scet[1],0,150) ;
  RooRealVar dr2(name_scdr[1],name_scdr[1],0.5,1.5) ;

  // Acceptance state cut (1 or 0)
  RooCategory cut(name_l1bin[0],name_l1bin[0]) ;
  cut.defineType("accept",1) ;
  cut.defineType("reject",0) ;
  RooCategory cut2(name_l1bin[1],name_l1bin[1]) ;
  cut2.defineType("accept",1) ;
  cut2.defineType("reject",0) ;
  
  // PARAMETRES ROOFIT CRYSTAL BALL
  RooRealVar norm("norm","N",1,0.6,1);
  RooRealVar alpha("alpha","#alpha",0.671034,0.01,8);
  RooRealVar n("n","n",4.07846,1.1,35);
  RooRealVar mean("mean","mean",20.8,0,100);
  //mean.setVal(thres[iEG]);
  RooRealVar sigma("sigma","#sigma",0.972825,0.01,5);
  //RooRealVar pedestal("pedestal","pedestal",0.01,0,0.4);

  RooRealVar norm2("norm2","N",0.999069,0.6,1);
  RooRealVar alpha2("alpha2","#alpha",0.492303,0.01,8);
  RooRealVar n2("n2","n",11.6694,1.1,35);
  RooRealVar mean2("mean2","mean",21.4582,0,100);
  //mean2.setVal(thres[iEG]);
  RooRealVar sigma2("sigma2","#sigma",1.19,0.01,5);
  //RooRealVar pedestal2("pedestal2","pedestal",0.01,0,0.4);

  FuncCB cb("cb","Crystal Ball Integree",et_plot,mean,sigma,alpha,n,norm) ;
  FuncCB cb2("cb2","Crystal Ball Integree",et_plot2,mean2,sigma2,alpha2,n2,norm2) ;
  
  // EFFICIENCY //
  RooEfficiency eff("eff","efficiency",cb,cut,"accept");
  RooEfficiency eff2("eff2","efficiency",cb2,cut2,"accept");

  // DATASETS //
  RooDataSet dataSet("data","data",RooArgSet(et_plot, cut,dr),Import(*treenew)); 
  RooDataSet dataSet2("data2","data2",RooArgSet(et_plot2, cut2,dr2),Import(*treenew_2));

  dataSet.Print();
  dataSet2.Print();
  
  // PLOT //
  RooPlot* frame = et_plot.frame(Bins(18000),Title("Fitted efficiency")) ;
  RooPlot* frame2 = et_plot2.frame(Bins(18000),Title("Fitted efficiency")) ;

  dataSet.plotOn(frame, Binning(binning), Efficiency(cut), MarkerColor(color1), LineColor(color1), MarkerStyle(style1) );
  dataSet2.plotOn(frame2, Binning(binning), Efficiency(cut2), MarkerColor(color2), LineColor(color2), MarkerStyle(style2) );


  /////////////////////// FITTING /////////////////////////////

  double fit_cuts_min = thres[iEG]-1.5 ;
  double fit_cuts_max = 150;

  et_plot.setRange("interesting",fit_cuts_min,fit_cuts_max);
  et_plot2.setRange("interesting",fit_cuts_min,fit_cuts_max);

  RooFitResult* roofitres1 = new RooFitResult("roofitres1","roofitres1");
  RooFitResult* roofitres2 = new RooFitResult("roofitres2","roofitres2");

  fichier << "Fit characteristics :"   << endl ;
  fichier << "EG "     << names[iEG] << endl ;
  fichier << "Fit Range , EB Coll : [" << fit_cuts_min << "," << fit_cuts_max << "]" << endl ;
  fichier << "Fit Range , EE Coll : [" << fit_cuts_min << "," << fit_cuts_max << "]" << endl ;
  fichier << "----------------------"  << endl ;

  // Fit #1 //
  roofitres1 = eff.fitTo(dataSet,ConditionalObservables(et_plot),Range("interesting"),Minos(kTRUE),Warnings(kFALSE),NumCPU(nCPU),Save(kTRUE));
  
  cb.plotOn(frame,LineColor(color1),LineWidth(2));

  double res_norm1  = norm.getVal();
  double err_norm1  = norm.getErrorLo();
  double res_mean1  = mean.getVal();
  double err_mean1  = mean.getError();
  double res_sigma1 = sigma.getVal();
  double err_sigma1 = sigma.getError();
  double res_n1     = n.getVal();
  double err_n1     = n.getError();
  double res_alpha1 = alpha.getVal();
  double err_alpha1 = alpha.getError();

  fichier << "<----------------- EB ----------------->" << endl
	  << "double res_mean="  << res_mean1  << "; "
	  << "double res_sigma=" << res_sigma1 << "; "
          << "double res_alpha=" << res_alpha1 << "; "
          << "double res_n="     << res_n1     << "; "
          << "double res_norm="  << res_norm1  << "; "
	  << endl
	  << "double err_mean="  << err_mean1  << "; "
	  << "double err_sigma=" << err_sigma1 << "; "
          << "double err_alpha=" << err_alpha1 << "; "
          << "double err_n="     << err_n1     << "; "
          << "double err_norm="  << err_norm1  << "; "
	  << endl;

  // Fit #2 //
  roofitres2 = eff2.fitTo(dataSet2,ConditionalObservables(et_plot2),Range("interesting"),Minos(kTRUE),Warnings(kFALSE),NumCPU(nCPU),Save(kTRUE));
 
  cb2.plotOn(frame2,LineColor(color2),LineWidth(2));

  double res_norm2  = norm2.getVal();
  double err_norm2  = norm2.getErrorLo();
  double res_mean2  = mean2.getVal();
  double err_mean2  = mean2.getError();
  double res_sigma2 = sigma2.getVal();
  double err_sigma2 = sigma2.getError();
  double res_n2     = n2.getVal();
  double err_n2     = n2.getError();
  double res_alpha2 = alpha2.getVal();
  double err_alpha2 = alpha2.getError();

  fichier << "<----------------- EE ----------------->" << endl
	  << "double res_mean="  << res_mean2  << "; "
	  << "double res_sigma=" << res_sigma2 << "; "
	  << "double res_alpha=" << res_alpha2 << "; "
	  << "double res_n="     << res_n2     << "; "
	  << "double res_norm="  << res_norm2  << "; "
	  << endl
	  << "double err_mean="  << err_mean2  << "; "
	  << "double err_sigma=" << err_sigma2 << "; "
	  << "double err_alpha=" << err_alpha2 << "; "
	  << "double err_n="     << err_n2     << "; "
	  << "double err_norm="  << err_norm2  << "; "
	  << endl;
    

  ////////////////////////////  DRAWING PLOTS AND LEGENDS /////////////////////////////////
  TCanvas* ca = new TCanvas("ca","Trigger Efficiency") ;

  ca->SetGridx();
  ca->SetGridy();
  ca->cd();
  
  gPad->SetLogx();
  gPad->SetObjectStat(1);

  frame->GetYaxis()->SetRangeUser(0,1.05);
  frame->GetXaxis()->SetRangeUser(1,100.);
  frame->GetYaxis()->SetTitle("Efficiency");
  frame->GetXaxis()->SetTitle("E_{T} [GeV]");
  frame->Draw() ;

  frame2->GetYaxis()->SetRangeUser(0,1.05);
  frame2->GetXaxis()->SetRangeUser(1,100.);
  frame2->GetYaxis()->SetTitle("Efficiency");
  frame2->GetXaxis()->SetTitle("E_{T} [GeV]");
  frame2->Draw("same") ;

  TH1F *SCeta1 = new TH1F("SCeta1","SCeta1",50,-2.5,2.5);
  TH1F *SCeta2 = new TH1F("SCeta2","SCeta2",50,-2.5,2.5);

  SCeta1->SetLineColor(color1) ;
  SCeta1->SetMarkerColor(color1);
  SCeta1->SetMarkerStyle(style1);

  SCeta2->SetLineColor(color2) ;
  SCeta2->SetMarkerColor(color2);
  SCeta2->SetMarkerStyle(style2);

  TLegend *leg = new TLegend(0.246,0.435,0.461,0.560,NULL,"brNDC"); // mid : x=353.5
  leg->SetLineColor(1);
  leg->SetTextColor(1);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);
  leg->SetShadowColor(kWhite);
  leg->SetFillColor(kWhite);
  leg->SetMargin(0.25);
  TLegendEntry *entry=leg->AddEntry("NULL","L1_SingleEG"+names[iEG],"h");
//   leg->AddEntry(SCeta1,name_leg_ecal[iECAL1]+" "+name_leg_coll[iColl1],"p");
//   leg->AddEntry(SCeta2,name_leg_ecal[iECAL2]+" "+name_leg_coll[iColl2],"p");
  leg->AddEntry(SCeta1,name_leg_ecal[iECAL1],"p");
  leg->AddEntry(SCeta2,name_leg_ecal[iECAL2],"p");
  leg->Draw();

  leg = new TLegend(0.16,0.725,0.58,0.905,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextFont(62);
  leg->SetTextSize(0.03);
  leg->SetLineColor(0);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(0);
  leg->SetFillStyle(0);
  leg->AddEntry("NULL","CMS Preliminary 2012 pp  #sqrt{s}=8 TeV","h");
  leg->AddEntry("NULL","#int L dt = "+lumi+"^{-1}","h");
  leg->AddEntry("NULL","Threshold : "+names[iEG]+" GeV","h");
  leg->Draw();

  TPaveText *pt2 = new TPaveText(0.220,0.605,0.487,0.685,"brNDC"); // mid : x=353.5                                          
  pt2->SetLineColor(1);
  pt2->SetTextColor(1);
  pt2->SetTextFont(42);
  pt2->SetTextSize(0.03);
  pt2->SetFillColor(kWhite);
  pt2->SetShadowColor(kWhite);
  pt2->AddText("L1 E/Gamma Trigger");
  pt2->AddText("Electrons from Z");
  pt2->Draw();
  
  //TString name_image="eff_EG20_2012_12fb";

  ca->Print(name_image+".cxx","cxx");
  ca->Print(name_image+".png","png");
  ca->Print(name_image+".gif","gif");
  ca->Print(name_image+".pdf","pdf");
  ca->Print(name_image+".ps","ps");
  ca->Print(name_image+".eps","eps");

  /////////////////////////////
  // SAVE THE ROO FIT RESULT //
  /////////////////////////////

  RooWorkspace *w = new RooWorkspace("workspace","workspace") ;

  w->import(dataSet);
  w->import(dataSet2);
  
  w->import(*roofitres1,"roofitres1");
  w->import(*roofitres2,"roofitres2");

  cout << "CREATES WORKSPACE : " << endl;
  w->Print();
  
  w->writeToFile(name_image+"_fitres.root") ;
  //gDirectory->Add(w) ;

  //f1->Close();
}
Example #6
0
void rpc_time_plots() {
  TFile *data = new TFile("/phenix/spin/phnxsp01/danielj/w_asymmetry_analysis_files/run13/wness_tree/run13_data_total_wness_refrun367593.root");
  TTree *temp_tree = (TTree*)data->Get("wness_tree");
  TTree *data_tree = (TTree*)temp_tree->Clone("data_tree");

  TFile *sim = new TFile("/phenix/spin/phnxsp01/danielj/w_asymmetry_analysis_files/run13/wness_tree/current_wness_tree_sig_sim.root");
  temp_tree = (TTree*)sim->Get("wness_tree");
  TTree *sim_tree = (TTree*)temp_tree->Clone("sim_tree");
  
  TH1F *h_sim[2];
  TH1F *h_data_low[2];
  TH1F *h_data_hi[2];
  
  h_sim[0] = new TH1F("h_sim_rpc1","h_sim_rpc1",44,0,44);
  sim_tree->Project("h_sim_rpc1","Rpc1time","Rpc1time<100");
  h_data_low[0] = new TH1F("h_data_low_rpc1","h_data_low_rpc1",44,0,44);
  data_tree->Project("h_data_low_rpc1","Rpc1time","Rpc1time<100 && Wness<.92");
  h_data_hi[0] = new TH1F("h_data_hi_rpc1","h_data_hi_rpc1",44,0,44);
  data_tree->Project("h_data_hi_rpc1","Rpc1time","Rpc1time<100 && Wness>.92");

  h_sim[1] = new TH1F("h_sim_rpc3","h_sim_rpc3",44,0,44);
  sim_tree->Project("h_sim_rpc3","Rpc3time","Rpc3time<100");
  h_data_low[1] = new TH1F("h_data_low_rpc3","h_data_low_rpc3",44,0,44);
  data_tree->Project("h_data_low_rpc3","Rpc3time","Rpc3time<100 && Wness<.92");
  h_data_hi[1] = new TH1F("h_data_hi_rpc3","h_data_hi_rpc3",44,0,44);
  data_tree->Project("h_data_hi_rpc3","Rpc3time","Rpc3time<100 && Wness>.92");

  TCanvas *c1;
  c1= new TCanvas("Wness","Wness",800,600);
  
  gPad->SetLogy();
  gStyle->SetOptStat(0);
  
  double data_low_integral[2];
  double data_hi_integral[2];
  double sim_integral[2];

  //data_low_integral[0] = h_data_low[0]->Integral("width");
  //data_hi_integral[0] = h_data_hi[0]->Integral("width");
  //sim_integral[0] = h_sim[0]->Integral("width");
  data_low_integral[0] = h_data_low[0]->GetMaximum();
  data_hi_integral[0] = h_data_hi[0]->GetMaximum();
  sim_integral[0] = h_sim[0]->GetMaximum();

  h_data_low[0]->Scale(1.0/data_low_integral[0]);
  h_data_hi[0]->Scale(1.0/data_hi_integral[0]);
  h_sim[0]->Scale(1.0/sim_integral[0]);

  h_data_low[0]->SetLineColor(kRed);
  h_data_hi[0]->SetLineColor(kBlue);
  h_sim[0]->SetLineColor(kBlack);
  h_sim[0]->SetTitle("");

  h_sim[0]->GetXaxis()->SetTitle("RpcTimeBin");
  h_sim[0]->GetXaxis()->SetTitleSize(.06);
  h_sim[0]->GetXaxis()->SetTitleOffset(0.85);
  h_sim[0]->GetXaxis()->SetLabelSize(.05);
  h_sim[0]->GetYaxis()->SetTitle("Normalized Yields");
  h_sim[0]->GetYaxis()->SetTitleSize(.06);
  h_sim[0]->GetYaxis()->SetTitleOffset(0.85);
  h_sim[0]->GetYaxis()->SetLabelSize(.05);
  

  h_sim[0]->SetTitle("RPC1");
  h_sim[0]->Draw();
  h_data_low[0]->Draw("SAME");
  h_data_hi[0]->Draw("SAME");

  TLegend * leg = new TLegend(0.5,0.75,0.9,0.9);
  leg->AddEntry(h_data_low[0],"Data < .92 Wness");
  leg->AddEntry(h_data_hi[0],"Data > .92 Wness");
  leg->AddEntry(h_sim[0],"W->#mu Sim");
  leg->Draw();

  TCanvas *c2;
  c2= new TCanvas("rpc3","rpc3",800,600);
  //data_low_integral[1] = h_data_low[1]->Integral("width");
  //data_hi_integral[1] = h_data_hi[1]->Integral("width");
  //sim_integral[1] = h_sim[1]->Integral("width");
  data_low_integral[1] = h_data_low[1]->GetMaximum();
  data_hi_integral[1] = h_data_hi[1]->GetMaximum();
  sim_integral[1] = h_sim[1]->GetMaximum();

  h_data_low[1]->Scale(1.0/data_low_integral[1]);
  h_data_hi[1]->Scale(1.0/data_hi_integral[1]);
  h_sim[1]->Scale(1.0/sim_integral[1]);

  h_data_low[1]->SetLineColor(kRed);
  h_data_hi[1]->SetLineColor(kBlue);
  h_sim[1]->SetLineColor(kBlack);
  h_sim[1]->SetTitle("");

  h_sim[1]->GetXaxis()->SetTitle("RpcTimeBin");
  h_sim[1]->GetXaxis()->SetTitleSize(.06);
  h_sim[1]->GetXaxis()->SetTitleOffset(0.85);
  h_sim[1]->GetXaxis()->SetLabelSize(.05);
  h_sim[1]->GetYaxis()->SetTitle("Normalized Yields");
  h_sim[1]->GetYaxis()->SetTitleSize(.06);
  h_sim[1]->GetYaxis()->SetTitleOffset(0.85);
  h_sim[1]->GetYaxis()->SetLabelSize(.05);
  

  h_sim[1]->SetTitle("RPC3");
  h_sim[1]->Draw();
  h_data_low[1]->Draw("SAME");
  h_data_hi[1]->Draw("SAME");

  TLegend * leg2 = new TLegend(0.5,0.75,0.9,0.9);
  leg2->AddEntry(h_data_low[1],"Data < .92 Wness");
  leg2->AddEntry(h_data_hi[1],"Data > .92 Wness");
  leg2->AddEntry(h_sim[1],"W->#mu Sim");
  leg2->Draw();

  Int_t
    Run_Number,  Evt_Number,  triggerbit,
    clockcross,  fvtx_cone, fvtx_tracklcone;

  Float_t
    Evt_bbcZ,    Wness,
    charge,      pT,          px,           py,         pz,
    phi,         eta,         DG0,
    DDG0,        DG4,         chi2,
    DCA_z,       DCA_r,       dphi12,       dphi23,
    dw23,        Rpc1dca,     Rpc1time,     Rpc3dca,    Rpc3time,
    Rpc1timewindow,           Rpc3timewindow,
    fvtx_dphi,   fvtx_dr,     fvtx_dtheta,
    fvtx_dr_dtheta, Rpc1x, Rpc1y, Rpc3x, Rpc3y;


  data_tree->SetBranchAddress("Wness",&Wness);
  data_tree->SetBranchAddress("px",&px);
  data_tree->SetBranchAddress("py",&py);
  data_tree->SetBranchAddress("dphi12",&dphi12);
  data_tree->SetBranchAddress("Rpc1time",&Rpc1time);
  data_tree->SetBranchAddress("Rpc1timewindow",&Rpc1timewindow);
  data_tree->SetBranchAddress("Rpc1x",&Rpc1x);
  data_tree->SetBranchAddress("Rpc1y",&Rpc1y);
  data_tree->SetBranchAddress("Rpc3time",&Rpc3time);
  data_tree->SetBranchAddress("Rpc3timewindow",&Rpc3timewindow);
  data_tree->SetBranchAddress("Rpc3x",&Rpc3x);
  data_tree->SetBranchAddress("Rpc3y",&Rpc3y);
  data_tree->SetBranchAddress("Run_Number", &Run_Number);
  data_tree->SetBranchAddress("Evt_Number", &Evt_Number);
  data_tree->SetBranchAddress("triggerbit", &triggerbit);
  data_tree->SetBranchAddress("Evt_bbcZ", &Evt_bbcZ);
  data_tree->SetBranchAddress("clockcross", &clockcross);
  data_tree->SetBranchAddress("data", &data);
  data_tree->SetBranchAddress("charge", &charge);
  data_tree->SetBranchAddress("pT", &pT);
  data_tree->SetBranchAddress("pz", &pz);
  data_tree->SetBranchAddress("phi", &phi);
  data_tree->SetBranchAddress("eta", &eta);
  data_tree->SetBranchAddress("DG0", &DG0);
  data_tree->SetBranchAddress("DDG0", &DDG0);
  data_tree->SetBranchAddress("DG4", &DG4);
  data_tree->SetBranchAddress("chi2", &chi2);
  data_tree->SetBranchAddress("DCA_z", &DCA_z);
  data_tree->SetBranchAddress("DCA_r", &DCA_r);
  data_tree->SetBranchAddress("dphi23", &dphi23);
  data_tree->SetBranchAddress("dw23", &dw23);
  data_tree->SetBranchAddress("Rpc1dca", &Rpc1dca);
  data_tree->SetBranchAddress("Rpc3dca", &Rpc3dca);
  data_tree->SetBranchAddress("fvtx_dphi", &fvtx_dphi);
  data_tree->SetBranchAddress("fvtx_dr", &fvtx_dr);
  data_tree->SetBranchAddress("fvtx_dtheta", &fvtx_dtheta);
  data_tree->SetBranchAddress("fvtx_dr_dtheta", &fvtx_dr_dtheta);
  data_tree->SetBranchAddress("fvtx_cone", &fvtx_cone);
  data_tree->SetBranchAddress("fvtx_tracklcone", &fvtx_tracklcone);


  TFile *outfile = new TFile("rpc_t_diff.root","recreate");

  TH1F *h_rpc_t_diff[2][4][3];
  TH2F *h2_rpc_t_diff[2][3][4];
  TH1F *h_rpc1_t[2][4][3];
  TH1F *h_rpc3_t[2][4][3];

  //TH2F *h_delta_vs_rpcdca[2];
  //h_delta_vs_rpcdca[0] = new TH2F("h_deltat_vs_rpcdca1","h_deltat_vs_rpcdca1",80,0,20,44,-22,22);
  //h_delta_vs_rpcdca[0] = new TH2F("h_deltat_vs_rpcdca3","h_deltat_vs_rpcdca3",80,0,40,44,-22,22);
  char *rpc_cond[4] = {"r1only","r3only","r1and3","rall"};
  char *vs_var[4] = {"DG0","DDG0","chi2","DCA_r"};
  int var_num[4] = {6,7,9,11};
  char *wness_cond[3] = {"wlt92","wgt92","wall"};
  char name[50];
  for(int f=0; f<2; f++) {
    for(int wc=0; wc<3; wc++) {
      for(int rc=0; rc<4; rc++) {
        sprintf(name,"h_%s_rpc_t_diff_%s_%s",(f==0)?"data":"wsim",rpc_cond[rc],wness_cond[wc]);
        h_rpc_t_diff[f][rc][wc] = (TH1F*) new TH1F(name,name,44,-22,22);
        sprintf(name,"h_%s_rpc1_t_%s_%s",(f==0)?"data":"wsim",rpc_cond[rc],wness_cond[wc]);
        h_rpc1_t[f][rc][wc] = (TH1F*) new TH1F(name,name,44,0,44);
        sprintf(name,"h_%s_rpc3_t_%s_%s",(f==0)?"data":"wsim",rpc_cond[rc],wness_cond[wc]);
        h_rpc3_t[f][rc][wc] = (TH1F*) new TH1F(name,name,44,0,44);
        
        sprintf(name,"h2_%s_rpc_t_diff_vs_%s_%s",(f==0)?"data":"wsim",vs_var[rc],wness_cond[wc]);
        h2_rpc_t_diff[f][wc][rc] = (TH2F*) new TH2F(name,name,44,-22,22,distmax[var_num[rc]]*2,distmin[var_num[rc]],distmax[var_num[rc]]);
      }
    }

    int entries = (f==0)?data_tree->GetEntries():sim_tree->GetEntries();
    int percent_done=0;
    int percent_incriment=20;
    int percent_done_previous;

    time_t rawtime;

    cout << "\nNumber of events:  " << entries << endl;
    cout << "Starting Main Event Loop...\n\n";
    time(&rawtime);
    printf("Start time:  %s",ctime(&rawtime));
    for(int i=0; i<entries; i++) { //Main loop
      //loop progress command line output
      percent_done_previous=percent_done;
      percent_done=(int)floor((float)(i+1)/(float)entries*(float)100);
      if(percent_done%percent_incriment==0 && percent_done != percent_done_previous) {
        printf("%3i%% done",percent_done);
        if(percent_done==100) {
          cout << "^_^";
          time( &rawtime );
          printf(" %s",ctime(&rawtime));
        } else {
          cout << "...";
          time( &rawtime );
          printf(" %s",ctime(&rawtime));
        }
      }

      float corrected_rpc1_time;
      float corrected_rpc3_time;

      if(f==0) {
        data_tree->GetEntry(i);

        float rpc1correction,rpc3correction;
        if(Rpc1timewindow<0) {
          rpc1correction = 0;
        } else {
          rpc1correction = rpc1timeshift*Rpc1timewindow;
        }

        if(Rpc3timewindow<0) {
          rpc3correction = 0;
        } else {
          rpc3correction = rpc3timeshift*Rpc3timewindow;
        }

        corrected_rpc1_time = Rpc1time - rpc1correction;
        corrected_rpc3_time = Rpc3time - rpc3correction;
      } else {
        sim_tree->GetEntry(i);

        corrected_rpc1_time = Rpc1time;
        corrected_rpc3_time = Rpc3time-27;
      }

      int rpcdca_condition = -1;
      if((Rpc1dca < 100) && (Rpc3dca < 100)) {
        rpcdca_condition = 2;
      } else if(Rpc1dca < 100) {
        rpcdca_condition = 0;
      } else if(Rpc3dca < 100) {
        rpcdca_condition = 1;
      } else {
        //cout << "continuing" << endl;
        continue;
      }

      int wness_condition = (Wness<.92)?0:1;

      float rpc_t_diff = corrected_rpc3_time - corrected_rpc1_time;
      //if(f==1) cout<< rpc_t_diff << endl;
      h_rpc_t_diff[f][rpcdca_condition][wness_condition]->Fill(rpc_t_diff);
      h_rpc_t_diff[f][3][wness_condition]->Fill(rpc_t_diff);
      h_rpc_t_diff[f][rpcdca_condition][2]->Fill(rpc_t_diff);
      h_rpc_t_diff[f][3][2]->Fill(rpc_t_diff);

      h2_rpc_t_diff[f][wness_condition][0]->Fill(rpc_t_diff,DG0);
      h2_rpc_t_diff[f][2][0]->Fill(rpc_t_diff,DG0);
      h2_rpc_t_diff[f][wness_condition][1]->Fill(rpc_t_diff,DDG0);
      h2_rpc_t_diff[f][2][1]->Fill(rpc_t_diff,DDG0);
      h2_rpc_t_diff[f][wness_condition][2]->Fill(rpc_t_diff,chi2);
      h2_rpc_t_diff[f][2][2]->Fill(rpc_t_diff,chi2);
      h2_rpc_t_diff[f][wness_condition][3]->Fill(rpc_t_diff,DCA_r);
      h2_rpc_t_diff[f][2][3]->Fill(rpc_t_diff,DCA_r);

      h_rpc1_t[f][rpcdca_condition][wness_condition]->Fill(corrected_rpc1_time);
      h_rpc1_t[f][3][wness_condition]->Fill(corrected_rpc1_time);
      h_rpc1_t[f][rpcdca_condition][2]->Fill(corrected_rpc1_time);
      h_rpc1_t[f][3][2]->Fill(corrected_rpc1_time);

      h_rpc3_t[f][rpcdca_condition][wness_condition]->Fill(corrected_rpc3_time);
      h_rpc3_t[f][3][wness_condition]->Fill(corrected_rpc3_time);
      h_rpc3_t[f][rpcdca_condition][2]->Fill(corrected_rpc3_time);
      h_rpc3_t[f][3][2]->Fill(corrected_rpc3_time);

    }
  }

  TCanvas *c3;
  c3 = (TCanvas*) new TCanvas("c3","c3",800,600);
  h_rpc_t_diff[0][2][0]->SetLineColor(kRed);
  h_rpc_t_diff[0][2][0]->DrawCopy();
  h_rpc_t_diff[0][2][1]->SetLineColor(kBlue);
  h_rpc_t_diff[0][2][1]->DrawCopy("same");

  TCanvas *c4 = new TCanvas("c4","c4",800,600);
  h_rpc_t_diff[0][2][0]->SetLineColor(kRed);
  float scale = h_rpc_t_diff[0][2][0]->GetMaximum();
  h_rpc_t_diff[0][2][0]->Scale(1.0/scale);
  h_rpc_t_diff[0][2][0]->DrawCopy();
  h_rpc_t_diff[0][2][1]->SetLineColor(kBlue);
  scale = h_rpc_t_diff[0][2][1]->GetMaximum();
  h_rpc_t_diff[0][2][1]->Scale(1.0/scale);
  h_rpc_t_diff[0][2][1]->DrawCopy("same");

  TCanvas *c5;
  c5 = (TCanvas*) new TCanvas("c5","c5",800,600);
  h_rpc1_t[0][3][0]->SetLineColor(kRed);
  h_rpc1_t[0][3][0]->DrawCopy();
  h_rpc1_t[0][3][1]->SetLineColor(kBlue);
  h_rpc1_t[0][3][1]->DrawCopy("same");
  h_rpc1_t[1][3][2]->SetLineColor(kBlack);
  h_rpc1_t[1][3][2]->DrawCopy("same");
  TLegend * leg3 = new TLegend(0.5,0.75,0.9,0.9);
  leg3->AddEntry(h_rpc1_t[0][3][0],"Data < .92 Wness");
  leg3->AddEntry(h_rpc1_t[0][3][1],"Data > .92 Wness");
  leg3->AddEntry(h_rpc1_t[1][3][2],"W->#mu Sim");
  leg3->Draw();

  TCanvas *c6;
  c6 = (TCanvas*) new TCanvas("c6","c6",800,800);
  c6->Divide(2,2);
  c6->cd(1);
  h2_rpc_t_diff[0][0][0]->DrawCopy();
  h2_rpc_t_diff[0][1][0]->SetMarkerColor(kRed);
  h2_rpc_t_diff[0][1][0]->DrawCopy("same");
  c6->cd(2);
  h2_rpc_t_diff[0][0][1]->DrawCopy();
  h2_rpc_t_diff[0][1][1]->SetMarkerColor(kRed);
  h2_rpc_t_diff[0][1][1]->DrawCopy("same");
  c6->cd(3);
  h2_rpc_t_diff[0][0][2]->DrawCopy();
  h2_rpc_t_diff[0][1][2]->SetMarkerColor(kRed);
  h2_rpc_t_diff[0][1][2]->DrawCopy("same");
  c6->cd(4);
  h2_rpc_t_diff[0][0][3]->DrawCopy();
  h2_rpc_t_diff[0][1][3]->SetMarkerColor(kRed);
  h2_rpc_t_diff[0][1][3]->DrawCopy("same");



  outfile->Write();
  outfile->Close();
  
}
Example #7
0
//*** Main Fitting Fxn *****//
void Hist_Fit(char *Ifile){
	
        TFile *ifile  = new TFile(Ifile);
	IhistEEM = (TH1F*)ifile->Get("BkgEst/my.ALL_EEM_pho_time"); // use EE- to get fit fxn and try in on EE+
	IhistEEP = (TH1F*)ifile->Get("BkgEst/my.ALL_EEP_pho_time"); 
	IhistEB = (TH1F*)ifile->Get("BkgEst/my.g_timeEB"); 
//	gDirectory->GetObject("BkgEst/my.ALL_EEM_pho_time;1", IhistEEM);
//	gDirectory->GetObject("BkgEst/my.ALL_EEP_pho_time;1", IhistEEP);
	 

	if(IhistEEM == 0){ std::cout  <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
	if(IhistEEP == 0){ std::cout  <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
        
//      fitFcn = new TF1("Totalfitfunc", "gaus(0) + gaus(3) + gaus(6) + gaus(9) + gaus(12) + gaus(15) + gaus(18) + gaus(21) + gaus(24)", -5.0 , 25.0,24);

//        fitFcn = new TF1("fitFcn", fitf, -5.0, 25.0, 24);
	fitFcn->SetNpx(500);
	fitFcn->SetLineWidth(4);
	fitFcn->SetLineColor(kBlue);

	// Fit Each fxn and Add it to the List
	IhistEEM->Fit(g0, "R");	
	IhistEEM->Fit(g1, "R+");	
	IhistEEM->Fit(g2, "R+");	
	IhistEEM->Fit(g3, "R+");	
	IhistEEM->Fit(g4, "R+");	
	IhistEEM->Fit(g5, "R+");	
	IhistEEM->Fit(g6, "R+");	
	IhistEEM->Fit(g7, "R+");	
	IhistEEM->Fit(g8, "R+");	

 	// GetParameters from each fit first
	g0->GetParameters(&par[0]);
	g1->GetParameters(&par[3]);
	g2->GetParameters(&par[6]);
	g3->GetParameters(&par[9]);
	g4->GetParameters(&par[12]);
	g5->GetParameters(&par[15]);
	g6->GetParameters(&par[18]);
	g7->GetParameters(&par[21]);
	g8->GetParameters(&par[24]);

	//set parms as parms of Fit Fxn
	fitFcn->SetParameters(par);
	// Now Do the Final Fit to see How it looks on the Histogram
	IhistEEM->Fit(fitFcn, "R+");
	std::cout << "Printing Fit Parameters For EE- ......   " << std::endl;
        fitFcn->GetParameters(par);
        // Gets integral of function between fit limits
        printf("Integral of function in EE-  = %g\n",fitFcn->Integral(-2,2));
 
	IhistEEP->Fit(fitFcn, "R+"); // Try Fit on EE+	
	std::cout << "Printing Fit Parameters For EE- ......   " << std::endl;
        fitFcn->GetParameters(par);
        printf("Integral of function in EE+  = %g\n",fitFcn->Integral(-2,2));

         //test Fit on EB

	IhistEB->Fit(fitFcn, "R+"); // Try Fit on EE+	
	std::cout << "Printing Fit Parameters For EB ......   " << std::endl;
        fitFcn->GetParameters(par);
        printf("Integral of function in EB  = %g\n",fitFcn->Integral(-2,2));
      

	TCanvas *c1 = new TCanvas("c1_fit","Fit Canvas EE-",200,10,800,900);
     	c1->SetGridx();
     	c1->SetGridy();
	c1->GetFrame()->SetFillColor(21);
	c1->GetFrame()->SetBorderMode(-1);
	c1->GetFrame()->SetBorderSize(5);
 //       c1->Divide(2,1);
	
	c1->cd();
	IhistEEM->Draw();
	fitFcn->Draw("sames");

	//  draw the legend
    	TLegend *leg = new TLegend(0.5,0.55,0.78,0.65);
       	leg->SetTextFont(72);
        leg->SetTextSize(0.04);
        leg->AddEntry(IhistEEM,"EE- Data","lpe");
        leg->AddEntry(fitFcn,"Global Fit","l");
        leg->Draw();
                     
	TCanvas *c2 = new TCanvas("c2_fit","Fit Canvas EE+",200,10,800,900);
     	c2->SetGridx();
     	c2->SetGridy();
	c2->GetFrame()->SetFillColor(21);
	c2->GetFrame()->SetBorderMode(-1);
	c2->GetFrame()->SetBorderSize(5);
        c2->cd();
	IhistEEP->Draw();
	fitFcn->Draw("sames");

    	TLegend *leg1 = new TLegend(0.5,0.55,0.78,0.65);
       	leg1->SetTextFont(72);
        leg1->SetTextSize(0.04);
        leg1->AddEntry(IhistEEP,"EE+ Data","lpe");
        leg1->AddEntry(fitFcn,"Global Fit","l");
        leg1->Draw();

	TCanvas *c3 = new TCanvas("EB_fit","Fit Canvas EB",200,10,800,900);
     	c3->SetGridx();
     	c3->SetGridy();
	c3->GetFrame()->SetFillColor(21);
	c3->GetFrame()->SetBorderMode(-1);
	c3->GetFrame()->SetBorderSize(5);
        c3->cd();
	IhistEB->Draw();
	fitFcn->Draw("sames");

    	TLegend *leg2 = new TLegend(0.5,0.55,0.78,0.65);
       	leg2->SetTextFont(72);
        leg2->SetTextSize(0.04);
        leg2->AddEntry(IhistEB,"EB Data","lpe");
        leg2->AddEntry(fitFcn,"Global Fit","l");
        leg2->Draw();
}
Example #8
0
//Assume h3 a ratio
void getEff3(TH1D* h1, TH1D* h2, TH1D* h3, bool isData, TString varType, TString INPUTDIR_PREFIX, double from, double to) { 

   gStyle->SetOptTitle(0);
   gStyle->SetEndErrorSize(2);
   gStyle->SetErrorX(0.5);

   TLegend* leg = MakeLegend();
   TPaveText* pt = MakeTPave();

   TCanvas* c1 = new TCanvas("c1","c1",800,600);
   c1->cd();
   if (varType != "rapidity") c1->SetLogx();
   h1->SetMarkerSize(0);
   h1->SetLineWidth(1.2);
   //range
   if (varType == "pt") h1->GetXaxis()->SetRangeUser(8,180);
   else if (varType == "vtx") h1->GetXaxis()->SetRangeUser(0,20.4);
   else if (varType == "mass") h1->GetXaxis()->SetRangeUser(15, 999);
   h1->GetYaxis()->SetRangeUser(from,to);
   h1->GetXaxis()->SetMoreLogLabels();
   h1->GetYaxis()->SetTitle("#epsilon");
   h1->SetLineColor(kRed);
   h1->SetFillColor(kRed);
   if (!isData) {
     h2->SetLineColor(kBlue);
     h2->SetFillColor(kBlue);
   } else {
     h2->SetMarkerStyle(20);
     h2->SetMarkerSize(1.1);
   }
   h3->SetLineColor(kGreen);
   h3->SetFillColor(kGreen);
   h3->SetFillStyle(3144);

   //if you compare data to data
   h1->Draw("E2");
   h1->GetXaxis()->SetTitle(getTitle(varType, true));
   if (!isData) {
     h2->Draw("E2same");
   } else {
     h2->Draw("samePE");
   }
   h3->Draw("E2same");
   leg->AddEntry(h1,"MC T&P","f");
   //leg->AddEntry(h1,"MC truth","f");
   if (!isData) {
     leg->AddEntry(h2,"MC T&P","f");
   } else {
     leg->AddEntry(h2,"Data T&P","pl");
     //leg->AddEntry(h2,h2->GetName(),"pl");
   }
   leg->AddEntry(h3,"Ratio","f");
   //leg->AddEntry(h3,"T&P correction map","f");
   leg->Draw("same");
   //if (dataOnly && !(varType == "rrr")) pt->Draw("same");
   //if (varType == "pt") c1->SetLogx();

   //Save
   c1->SaveAs(INPUTDIR_PREFIX+"/"+h3->GetName()+varType+".png");
   c1->SaveAs(INPUTDIR_PREFIX+"/"+h3->GetName()+varType+".C");
}
Example #9
0
//Assume heff_mct, htp, htpd, rat
void getEff3Stats(TH1D* h1, TH1D* h2, TH1D* h3, TH1D* h4, bool isData, TString varType, TString INPUTDIR_PREFIX, double from, double to) {

   gStyle->SetOptTitle(0);
   gStyle->SetEndErrorSize(2);
   gStyle->SetErrorX(0.5);

   TLegend* leg = MakeLegend();
   TPaveText* pt = MakeTPave();

   TCanvas* c1 = new TCanvas("c1","c1",800,600);
   c1->cd();
   if (varType != "rapidity") c1->SetLogx();
   h1->SetMarkerSize(0);
   h1->SetLineWidth(1.2);
   //range
   if (varType == "pt") h1->GetXaxis()->SetRangeUser(8,180);
   else if (varType == "vtx") h1->GetXaxis()->SetRangeUser(0,20.4);
   else if (varType == "mass") h1->GetXaxis()->SetRangeUser(15, 999);
   h1->GetYaxis()->SetRangeUser(from,to);
   h1->GetXaxis()->SetMoreLogLabels();
   h1->GetYaxis()->SetTitle("#epsilon");
   h1->SetLineColor(kRed);
   h1->SetFillColor(kRed);
   h2->SetLineColor(kBlue);
   h2->SetFillColor(kBlue);
   h4->SetLineColor(kGreen);
   h4->SetFillColor(kGreen);
   h4->SetFillStyle(3144);

   //if you compare data to data
   h1->Draw("E2");
   h1->GetXaxis()->SetTitle(getTitle(varType, true));
   h2->Draw("E2same");
   h4->Draw("E2same");
   leg->AddEntry(h1,"MC Truth","f");
   leg->AddEntry(h2,"MC T&P","f");
   leg->AddEntry(h4,"Ratio","f");
   leg->Draw("same");
   //if (dataOnly && !(varType == "rrr")) pt->Draw("same");
   //if (varType == "pt") c1->SetLogx();

   gROOT->ProcessLine(".L ../tools/stattools.C");
   //Make TPave
   ostringstream tmpstrm1;
   ostringstream tmpstrm2;
   ostringstream tmpstrm3;

   tmpstrm3 << INPUTDIR_PREFIX << " " << h1->GetName();
   tmpstrm1 << estimatorPerMassHisto1(h2,h3);
   tmpstrm2 << estimatorPerMassHisto2(h2,h3,h1);

   TPaveText *pt = new TPaveText(0.25,0.77,0.40,0.92,"brNDC");
   pt->SetFillColor(0);
//  pt->SetTextFont(72);
   pt->SetTextSize(0.040);
   pt->SetBorderSize(0);
   pt->SetTextAlign(12);
   pt->AddText(TString(tmpstrm3.str().c_str()));
   pt->AddText("Simple estimator: "+TString(tmpstrm1.str().c_str()));
   pt->AddText("Combined estimator: "+TString(tmpstrm2.str().c_str()));
   pt->Draw("same");

   //Save
   c1->SaveAs(INPUTDIR_PREFIX+"/stats"+h1->GetName()+varType+".png");
}
Example #10
0
//void Eff(TString  openfile, TString outfile, TString NAME){
void draw_inLumi(){
	TFile * fMC = new TFile("/afs/cern.ch/user/q/quwang/work/Trigger/CMSSW_7_6_3_patch2/src/MuonAnalysis/TagAndProbe/test/zmumu/tnpZ_Data.root");//../newDoubleMuonTree/tnpZ_theTreeCleanedMC.root");
        TFile * fData = new TFile("/afs/cern.ch/user/q/quwang/work/Trigger/CMSSW_7_6_3_patch2/src/MuonAnalysis/TagAndProbe/test/zmumu/tnpZ_DataCCC.root");
        TFile * fDatano = new TFile("/afs/cern.ch/user/q/quwang/work/Trigger/CMSSW_7_6_3_patch2/src/MuonAnalysis/TagAndProbe/test/zmumu/tnpZ_DatanoCCC.root");
        TTree * treeData = (TTree *)fMC->Get("tpTree/fitter_tree");
        TTree * treeDataCCC = (TTree *)fData->Get("tpTree/fitter_tree");
        TTree * treeDatanoCCC = (TTree *)fDatano->Get("tpTree/fitter_tree");

	//TFile * fopen2 = new TFile("newDoubleMuonTree/TnPtreeDataCCC.root");
	//TTree * tree2 = (TTree *)fopen2->Get("tpTree/fitter_tree");
	/*std::vector< TH1D* > th1fs;
	std::vector< TH1D* > th2fs;
	for ( int ij = 0; ij < 30; ++ij) {
		TString title = "mass_"; title += ij + 1; title += "_eff";
		TString title2 = "mass_dZ_"; title2 += ij + 1; title2 += "_eff";
		th1fs.push_back(new TH1D(title, title, 100, 0., 800.));
		th2fs.push_back(new TH1D(title2, title2, 100, 0., 800.));
	}*/
	Float_t pt, tag_pt, pair_pt;
	UInt_t lumi;
	Float_t tag_instLumi;
	UInt_t run;
	Float_t eta, tag_eta;
	Int_t DoubleIsoMu17Mu8dZ_Mu17leg;
	Int_t DoubleIsoMu17Mu8_IsoMu17leg;
	Float_t pair_newTuneP_mass;
	Float_t mass;

	treeData->SetBranchAddress("pt", &pt);
	treeData->SetBranchAddress("tag_pt", &tag_pt);
	treeData->SetBranchAddress("eta", &eta);
	treeData->SetBranchAddress("tag_eta", &tag_eta);
	treeData->SetBranchAddress("pair_pt", &pair_pt);
	treeData->SetBranchAddress("lumi", &lumi);
	treeData->SetBranchAddress("run", &run);
	treeData->SetBranchAddress("tag_instLumi", &tag_instLumi);
	treeData->SetBranchAddress("DoubleIsoMu17Mu8dZ_Mu17leg", &DoubleIsoMu17Mu8dZ_Mu17leg);
	treeData->SetBranchAddress("DoubleIsoMu17Mu8_IsoMu17leg", &DoubleIsoMu17Mu8_IsoMu17leg);
	treeData->SetBranchAddress("pair_newTuneP_mass", &pair_newTuneP_mass);
	treeData->SetBranchAddress("mass", &mass);
	treeDataCCC->SetBranchAddress("pt", &pt);
	treeDataCCC->SetBranchAddress("tag_pt", &tag_pt);
	treeDataCCC->SetBranchAddress("eta", &eta);
	treeDataCCC->SetBranchAddress("tag_eta", &tag_eta);
	treeDataCCC->SetBranchAddress("pair_pt", &pair_pt);
	treeDataCCC->SetBranchAddress("lumi", &lumi);
	treeDataCCC->SetBranchAddress("run", &run);
	treeDataCCC->SetBranchAddress("tag_instLumi", &tag_instLumi);
	treeDataCCC->SetBranchAddress("DoubleIsoMu17Mu8dZ_Mu17leg", &DoubleIsoMu17Mu8dZ_Mu17leg);
	treeDataCCC->SetBranchAddress("DoubleIsoMu17Mu8_IsoMu17leg", &DoubleIsoMu17Mu8_IsoMu17leg);
	treeDataCCC->SetBranchAddress("pair_newTuneP_mass", &pair_newTuneP_mass);
	treeDataCCC->SetBranchAddress("mass", &mass);
	treeDatanoCCC->SetBranchAddress("pt", &pt);
	treeDatanoCCC->SetBranchAddress("tag_pt", &tag_pt);
	treeDatanoCCC->SetBranchAddress("eta", &eta);
	treeDatanoCCC->SetBranchAddress("tag_eta", &tag_eta);
	treeDatanoCCC->SetBranchAddress("pair_pt", &pair_pt);
	treeDatanoCCC->SetBranchAddress("lumi", &lumi);
	treeDatanoCCC->SetBranchAddress("run", &run);
	treeDatanoCCC->SetBranchAddress("tag_instLumi", &tag_instLumi);
	treeDatanoCCC->SetBranchAddress("DoubleIsoMu17Mu8dZ_Mu17leg", &DoubleIsoMu17Mu8dZ_Mu17leg);
	treeDatanoCCC->SetBranchAddress("DoubleIsoMu17Mu8_IsoMu17leg", &DoubleIsoMu17Mu8_IsoMu17leg);
	treeDatanoCCC->SetBranchAddress("pair_newTuneP_mass", &pair_newTuneP_mass);
	treeDatanoCCC->SetBranchAddress("mass", &mass);
	/*
	   tree2->SetBranchAddress("pt", &pt);
	   tree2->SetBranchAddress("tag_pt", &tag_pt);
	   tree2->SetBranchAddress("eta", &eta);
	   tree2->SetBranchAddress("tag_eta", &tag_eta);
	   tree2->SetBranchAddress("pair_pt", &pair_pt);
	   tree2->SetBranchAddress("DoubleIsoMu17Mu8dZ_Mu17leg", &DoubleIsoMu17Mu8dZ_Mu17leg);
	   tree2->SetBranchAddress("DoubleIsoMu17Mu8_IsoMu17leg", &DoubleIsoMu17Mu8_IsoMu17leg);
	   tree2->SetBranchAddress("pair_newTuneP_mass", &pair_newTuneP_mass);
	   tree2->SetBranchAddress("mass", &mass);
	   */
	TH1F * hmassData = new TH1F("hmassData","hmassData", 20, 81, 101);
	TH1F * hmassDatadZ = new TH1F("hmassDatadZ","hmassDatadZ", 20, 81, 101);
	TH1F * hmass = new TH1F("hmass","hmass", 20, 81, 101);
	//Float_t xbins[31] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 240, 280, 320, 360, 400, 440, 480, 520, 560, 600};
	//Float_t xbins[11] ={0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5};
	TH1F * hbx = new TH1F("hbx","hbx", 18, 0, 3600);
	TH1F * hbx_a = new TH1F("hbx_a","hbx_a", 18, 0, 3600);
	TH1F * hbx_dZ = new TH1F("hbx_dZ","hbx_dZ", 18, 0, 3600);
	TH1F * hbxD = new TH1F("hbxD","hbxD", 18, 0, 3600);
	TH1F * hbxD_a = new TH1F("hbxD_a","hbxD_a", 18, 0, 3600);
	TH1F * hbxD_dZ = new TH1F("hbxD_dZ","hbxD_dZ", 18, 0, 3600);
	TH1F * hbxDno_a = new TH1F("hbxDno_a","hbxDno_a", 18, 0, 3600);
	TH1F * hbxDno_dZ = new TH1F("hbxDno_dZ","hbxDno_dZ", 18, 0, 3600);
	//TH1F * hbx_eff = new TH1F("hbx_eff","hbx_eff", 30, xbins);
	//TH1F * hbx = new TH1F("hbx","hbx", 30, 0, 600);

	//Double_t pt_a[30], pt_dZ[30];
	Int_t num_pt, step, pt_cut;

	//for(Long64_t i=0; i< 10000; i++){
	for(Long64_t i=0; i< treeData->GetEntries(); i++){
		treeData->GetEntry(i);
		if( pt>20 && fabs(eta)<2.4 && tag_pt>20 && fabs(tag_eta)<2.4 && DoubleIsoMu17Mu8_IsoMu17leg>0 && mass> 81 && mass<101){
			hbx_a->Fill(tag_instLumi);
		}
		if( pt>20 && fabs(eta)<2.4 && tag_pt>20 && fabs(tag_eta)<2.4 && DoubleIsoMu17Mu8dZ_Mu17leg>0 && mass> 81 && mass<101){
			hbx_dZ->Fill(tag_instLumi);
		}
	}
	for(Long64_t i=0; i< treeDataCCC->GetEntries(); i++){
		treeDataCCC->GetEntry(i);
		if( pt>20 && fabs(eta)<2.4 && tag_pt>20 && fabs(tag_eta)<2.4 && DoubleIsoMu17Mu8_IsoMu17leg>0 && mass> 81 && mass<101){
			hbxD_a->Fill(tag_instLumi);
		}
		if( pt>20 && fabs(eta)<2.4 && tag_pt>20 && fabs(tag_eta)<2.4 && DoubleIsoMu17Mu8dZ_Mu17leg>0 && mass> 81 && mass<101){
			hbxD_dZ->Fill(tag_instLumi);
		}
	}
	for(Long64_t i=0; i< treeDatanoCCC->GetEntries(); i++){
		treeDatanoCCC->GetEntry(i);
		if( pt>20 && fabs(eta)<2.4 && tag_pt>20 && fabs(tag_eta)<2.4 && DoubleIsoMu17Mu8_IsoMu17leg>0 && mass> 81 && mass<101){
			hbxDno_a->Fill(tag_instLumi);
		}
		if( pt>20 && fabs(eta)<2.4 && tag_pt>20 && fabs(tag_eta)<2.4 && DoubleIsoMu17Mu8dZ_Mu17leg>0 && mass> 81 && mass<101){
			hbxDno_dZ->Fill(tag_instLumi);
		}
	}


        TH1F * hbx_eff = (TH1F*)hbx_dZ->Clone("hbx_eff");
        hbx_eff->Sumw2();
        hbx_eff->SetMinimum(0);
        hbx_eff->Divide(hbx_dZ, hbx_a, 1, 1, "b");
        hbx_eff->SetMaximum(1.05);
        hbx_eff->SetMinimum(0.550);
        hbxD_dZ->SetMarkerColor(2);
        hbxD_dZ->SetLineColor(2);
        TH1F * hbxD_eff = (TH1F*)hbxD_dZ->Clone("hbxD_eff");
        hbxD_eff->Sumw2();
        hbxD_eff->SetMinimum(0);
        hbxD_a->SetMarkerColor(2);
        hbxD_eff->Divide(hbxD_dZ, hbxD_a, 1, 1, "b");
        hbxD_eff->SetMaximum(1.05);
        hbxD_eff->SetMinimum(0.550);
        TH1F * hbxDno_eff = (TH1F*)hbxDno_dZ->Clone("hbxDno_eff");
        hbxDno_eff->Sumw2();
        hbxDno_eff->SetMinimum(0);
        hbxDno_a->SetMarkerColor(1);
        hbxDno_eff->Divide(hbxDno_dZ, hbxDno_a, 1, 1, "b");
        hbxDno_eff->SetMaximum(1.05);
        hbxDno_eff->SetMinimum(0.550);


        TCanvas * C = new TCanvas();
        TPad* fPads1 = NULL;
        TPad* fPads2 = NULL;
        fPads1 = new TPad("pad1","Run2", 0.00, 0.25, 0.99, 0.99);
        fPads2 = new TPad("pad2","", 0.00, 0.05, 0.99, 0.25);
        fPads1->SetFillColor(0);
        fPads1->SetLineColor(0);
        fPads2->SetFillColor(0);
        fPads2->SetFillColor(0);
        fPads1->Draw();
        fPads2->Draw();

        fPads1->cd();
        hbx_eff->SetMarkerStyle(20);
        hbx_eff->SetMarkerColor(4);
        hbx_eff->SetTitle("dZ_eff");
        hbx_eff->GetXaxis()->SetTitle("instLumi");
        hbx_eff->GetYaxis()->SetTitle("eff_dZ");
        hbx_eff->SetStats(0);
        hbx_eff->Draw();
        hbxD_eff->SetMarkerStyle(20);
        hbxD_eff->SetMarkerColor(2);
        hbxD_eff->Draw("same");
        hbxDno_eff->SetMarkerStyle(20);
        hbxDno_eff->SetMarkerColor(1);
        hbxDno_eff->Draw("same");
        TLegend *leg = new TLegend(0.13, 0.18, 0.28, 0.28);
        leg->AddEntry(hbx_eff, "data", "f");
        leg->AddEntry(hbxD_eff, "dataCCC", "f");
        leg->AddEntry(hbxDno_eff, "datanoCCC", "f");
        leg->Draw();

        fPads2->cd();


        TH1F * hbx_DM = (TH1F *)hbxD_eff->Clone("hbx_DM");
        hbx_DM->Sumw2();
        hbx_DM->SetMinimum(0);
        hbx_DM->Divide(hbxD_eff, hbx_eff, 1, 1, "b");
        hbx_DM->SetTitle("");
        hbx_DM->GetXaxis()->SetTitle("");//Z pt /GeV");
        hbx_DM->GetYaxis()->SetTitleSize(0.11);
        hbx_DM->GetYaxis()->SetTitleOffset(0.26);
        hbx_DM->GetYaxis()->SetTitle("eff DataCCC/Data");

        hbx_DM->SetMaximum(1.15);
        hbx_DM->SetMinimum(0.85);
        hbx_DM->SetStats(kFALSE);
	hbx_DM->SetLabelSize(0.09);
	hbx_DM->GetYaxis()->SetLabelSize(0.09);
        hbx_DM->Draw();
        TH1F * hbx_DMno = (TH1F *)hbxDno_eff->Clone("hbx_DMno");
        hbx_DMno->Sumw2();
        hbx_DMno->SetMinimum(0);
        hbx_DMno->Divide(hbxDno_eff, hbx_eff, 1, 1, "b");
	hbx_DMno->Draw("same");
        fPads2->Update();

	TLine * lineAtZero = new TLine(0, 1.0, 3600, 1.0);
	//TLine * lineAtZero = new TLine(hbx_DM->GetXaxis()->GetXmin(), 0, hbx_DM->GetXaxis()->GetXmax(), 0);
	lineAtZero->SetLineColor(2);
	lineAtZero->SetLineStyle(2);
	lineAtZero->Draw();


        C->SaveAs("dZ_bx_check.pdf");

	//C->SaveAs("dZ_eff_MC.png");
	/*
	   TCanvas *Ceff = new TCanvas();
	   Ceff->Draw();
	   Double_t abin, dZbin, eff;
	   for(int ibin=0; ibin<20; ibin++){
	   abin = abin + hmassData->GetBinContent(ibin);
	   dZbin = dZbin + hmassDatadZ->GetBinContent(ibin);
	//eff = bbin/abin;
	//hmass->SetBinContent(ibin,eff);

	}

	hbx->Draw();
	Ceff->SaveAs("dZ_pt.png");
	Ceff->SaveAs("dZ_pt.pdf");
	eff = dZbin/abin;
	cout << "eff " << eff << endl;
	*/
}
Example #11
0
void DrawPerformCompFVTX(){
    gStyle->SetErrorX(0);
    gStyle->SetOptStat(0);
    TFile *fmb = new TFile("merged_AnaMWGppmb.root","ReadOnly");
    TFile *fhmand = new TFile("merged_AnaMWGppfvtxand.root","ReadOnly");
    TFile *fhmor = new TFile("merged_AnaMWGppfvtxor.root","ReadOnly");
 //   TFile *fhmsouth = new TFile("merged_AnaMWGppfvtxsouth.root","ReadOnly");
 //   TFile *fhmnorth = new TFile("merged_AnaMWGppfvtxnorth.root","ReadOnly");
    const int ncav = 2;
    TCanvas *c1[ncav];
    for(int i=0;i<ncav;i++){
        c1[i] = new TCanvas();
    }
    TString histoname = "hnfvtxtrkbbc";//"hntracknmpc";
    TString varname = "nfvtxtrack";
    TString var = "# of fvtx tracks";//"# of central tracks";
    bool xory = 1;
    TH2F* hbbcsbbcn_mb = (TH2F*)fmb->Get(Form("%s",histoname.Data()));
    TH2F* hbbcsbbcn_hmand = (TH2F*)fhmand->Get(Form("%s",histoname.Data()));
    TH2F* hbbcsbbcn_hmor = (TH2F*)fhmor->Get(Form("%s",histoname.Data()));
 //   TH2F* hbbcsbbcn_hmsouth = (TH2F*)fhmsouth->Get(Form("%s",histoname.Data()));
 //   TH2F* hbbcsbbcn_hmnorth = (TH2F*)fhmnorth->Get(Form("%s",histoname.Data()));
if(xory){
    TH1F* hbbc_mb = (TH1F*)hbbcsbbcn_mb->ProjectionX("hbbc_mb",0,-1);
    TH1F* hbbc_hmand = (TH1F*)hbbcsbbcn_hmand->ProjectionX("hbbc_hmand",0,-1);
    TH1F* hbbc_hmor = (TH1F*)hbbcsbbcn_hmor->ProjectionX("hbbc_hmor",0,-1);
 //   TH1F* hbbc_hmsouth = (TH1F*)hbbcsbbcn_hmsouth->ProjectionX("hbbc_hmsouth",0,-1);
 //   TH1F* hbbc_hmnorth = (TH1F*)hbbcsbbcn_hmnorth->ProjectionX("hbbc_hmnorth",0,-1);
}
else{
    TH1F* hbbc_mb = (TH1F*)hbbcsbbcn_mb->ProjectionY("hbbc_mb",0,-1);
    TH1F* hbbc_hmand = (TH1F*)hbbcsbbcn_hmand->ProjectionY("hbbc_hmand",0,-1);
    TH1F* hbbc_hmor = (TH1F*)hbbcsbbcn_hmor->ProjectionY("hbbc_hmor",0,-1);
 //   TH1F* hbbc_hmsouth = (TH1F*)hbbcsbbcn_hmsouth->ProjectionY("hbbc_hmsouth",0,-1);
 //   TH1F* hbbc_hmnorth = (TH1F*)hbbcsbbcn_hmnorth->ProjectionY("hbbc_hmnorth",0,-1);
}
    //hbbc_mb->GetXaxis()->SetLimits(0,200);
    //hbbc_mb->Rebin(3);
    //hbbc_mbcen->Rebin(10);
    //hbbc_hmand->Rebin(3);
    //hbbc_hmor->Rebin(3);
    //hbbc_hmsouth->Rebin(3);
    //hbbc_hmnorth->Rebin(3);
    TH1F *hbbc_hmorScale = (TH1F*)hbbc_hmor->Clone("hbbc_hmorScale");
    hbbc_hmorScale->Scale(0.06);
    //hbbc_hm->Scale(1./hbbc_hm->Integral());
    c1[0]->cd();
    c1[0]->SetLogy();
    hbbc_mb->Draw();
    SetTitle(*hbbc_mb,Form("%s",var.Data()),"# of events","");
    //SetTitle(*hbbc_mb,"nvtx layer 1","# of events","");
    SetXRange(*hbbc_mb,0,30);
    SetYRange(*hbbc_mb,1,5e9);
    SetXRange(*hbbc_hmand,0,30);
    SetXRange(*hbbc_hmor,0,30);
//    SetXRange(*hbbc_hmsouth,0,300);
//    SetXRange(*hbbc_hmnorth,0,300);
    SetStyle(*hbbc_mb,1.0,1,20,0,0);
    SetStyle(*hbbc_hmand,1.0,2,20,0,0);
    SetStyle(*hbbc_hmor,1.0,4,34,0,0);
    SetStyle(*hbbc_hmorScale,1.0,2,34,0,0);
//    SetStyle(*hbbc_hmsouth,0.6,6,29,0,0);
//    SetStyle(*hbbc_hmnorth,0.6,7,32,0,0);
    TLegend *leg = new TLegend(0.6,0.75,0.8,0.90);
    leg->SetBorderSize(0);
    leg->SetFillColor(0);
    leg->SetTextSize(0.045);
    leg->AddEntry(hbbc_mb,"p+p minbias","pl");
   // leg->AddEntry(hbbc_mb_scale,"p+p minbias * 50","pl");
    leg->AddEntry(hbbc_hmor,"p+p FVTX OR","pl");
    leg->AddEntry(hbbc_hmand,"p+p FVTX AND","pl");
   // leg->AddEntry(hbbc_hmorScale,"p+p FVTX OR Scaled * 0.06","pl");
   // leg->AddEntry(hbbc_hmand,"MWGpp high-mult AND","pl");
   // leg->AddEntry(hbbc_hmor,"MWGpp high-mult OR","pl");
  //  leg->AddEntry(hbbc_hmsouth,"MWGpp high-mult south","pl");
  //  leg->AddEntry(hbbc_hmnorth,"MWGpp high-mult north","pl");
    leg->Draw("same");
    hbbc_hmor->Draw("same");
    hbbc_hmand->Draw("same");
  //  hbbc_hmorScale->Draw("same");
    double top5 = 7;
    TLine *l = new TLine(top5,0,top5,4e8);
    l->SetLineStyle(2);
    l->Draw();
  //  hbbc_hmand->Draw("same");
  //  hbbc_hmor->Draw("same");
  //  hbbc_hmsouth->Draw("same");
  //  hbbc_hmnorth->Draw("same");
    TLatex t;
t.SetTextSize(0.04);
    t.SetNDC();
//    hbbc_mb->GetXaxis()->SetRange()
t.DrawLatex(0.13,0.2,Form("MB mean:%.2f",hbbc_mb->GetMean(1)));
t.DrawLatex(0.13,0.25,Form("FVTX OR mean:%.2f",hbbc_hmor->GetMean(1)));
t.DrawLatex(0.13,0.30,Form("FVTX AND mean:%.2f",hbbc_hmand->GetMean(1)));
t.SetNDC(0);
t.DrawLatex(top5-8,5e8,Form("Top 0-5%, fvtx track >= %.1f",top5));
//t.DrawLatex(0.13,0.7,Form("mb mean:%.2f, # of events: %.1fM",hbbc_mb->GetMean(1),hbbcsbbcn_mb->Integral()/1e6));
//t.DrawLatex(0.13,0.75,Form("central mean:%.2f, # of events: %.1fM",hbbc_mbcen->GetMean(1),hbbcsbbcn_mbcen->Integral()/1e6));
//t.DrawLatex(0.13,0.80,Form("hm AND mean:%.2f, # of events: %.1fM",hbbc_hmand->GetMean(1),hbbcsbbcn_hmand->Integral()/1e6));
//t.DrawLatex(0.13,0.85,Form("hm OR mean:%.2f, # of events: %.1fM",hbbc_hmor->GetMean(1),hbbcsbbcn_hmor->Integral()/1e6));
//t.DrawLatex(0.13,0.90,Form("hm south mean:%.2f, # of events: %.1fM",hbbc_hmsouth->GetMean(1),hbbcsbbcn_hmsouth->Integral()/1e6));
//t.DrawLatex(0.13,0.95,Form("hm north mean:%.2f, # of events: %.1fM",hbbc_hmnorth->GetMean(1),hbbcsbbcn_hmnorth->Integral()/1e6));
    c1[0]->Print(Form("fig/h%s_comp.png",varname.Data()));

    c1[1]->cd();
    TH1F* hbbc_ratioand = (TH1F*)hbbc_hmand->Clone("hbbc_ratioand");
    TH1F* hbbc_ratioor = (TH1F*)hbbc_hmor->Clone("hbbc_ratioor");
//    TH1F* hbbc_ratiosouth = (TH1F*)hbbc_hmsouth->Clone("hbbc_ratiosouth");
//    TH1F* hbbc_rationorth = (TH1F*)hbbc_hmnorth->Clone("hbbc_rationorth");
    hbbc_ratioand->Divide(hbbc_mb);
    hbbc_ratioor->Divide(hbbc_mb);
 //   hbbc_ratiosouth->Divide(hbbc_mb);
 //   hbbc_rationorth->Divide(hbbc_mb);
    SetTitle(*hbbc_ratioand,Form("%s",var.Data()),"ratio hm / mb","");
    SetTitle(*hbbc_ratioor,Form("%s",var.Data()),"ratio hm / mb","");
    SetXRange(*hbbc_ratioand,0,25);
    SetYRange(*hbbc_ratioand,0,20);
    hbbc_ratioand->Draw();
    hbbc_ratioor->Draw("same");
 //   hbbc_ratiosouth->Draw("same");
 //   hbbc_rationorth->Draw("same");
    c1[1]->Print(Form("fig/h%s_ratio.png",varname.Data()));

    /*
TH1F* hnvtx = (TH1F*)hbbcnvtx[0]->ProjectionX("hnvtx",0,-1);
TH1F* hnvtx_hm = (TH1F*)hbbcnvtx_hm[0]->ProjectionX("hnvtx_hm",0,-1);
TH1F* hbbc = (TH1F*)hbbcnvtx[0]->ProjectionX("hbbc",0,-1);
TH1F* hbbc_hm = (TH1F*)hbbcnvtx_hm[0]->ProjectionX("hbbc_hm",0,-1);
c1[22]->cd();
c1[22]->SetLogy();
hnvtx->Rebin(4);
hnvtx_hm->Rebin(4);
hnvtx->Scale(1./hnvtx->Integral());
hnvtx_hm->Scale(1./hnvtx_hm->Integral());
SetRange(*hnvtx,0,1e-11,200,10);
SetTitle(*hnvtx,"#hits in cluster layer 1","normalized","");
SetStyle(*hnvtx,1.2,1,20,0,0);
SetStyle(*hnvtx_hm,1.2,2,24,0,0);
hnvtx->Draw("P");
hnvtx_hm->Draw("Psame");
c1[22]->Print("fig/hnvtx.png");
c1[23]->cd();
c1[23]->SetLogy();
SetTitle(*hbbc,"bbc charge sum","normalized","");
hbbc->Rebin(5);
hbbc_hm->Rebin(5);
hbbc->Scale(1./hbbc->Integral());
hbbc_hm->Scale(1./hbbc_hm->Integral());
SetRange(*hbbc,0,1e-11,200,10);
SetStyle(*hbbc,1.2,1,20,0,0);
SetStyle(*hbbc_hm,1.2,2,24,0,0);
hbbc->Draw("P");
hbbc_hm->Draw("Psame");
c1[23]->Print("fig/hbbc.png");
*/


}
Example #12
0
void draw_comp_cent(bool isPrompt=true, bool isPair=true, bool isEmbedded=true, bool isBinomial=true, char *dirName = "drawComprm3step")
{

	gROOT->Macro("./JpsiStyle.C");
	gStyle->SetPaintTextFormat(".3f"); // for text colz

	char* ntuple01 = "default 7_4_0";
	char* ntuple02 = "3 steps removed";
	//char* ntuple02 = "muonSeeded";

	double ymin = 0.85;
	double ymax = 1.15;

	string strPrompt;
	string strEmbd;
	string strPair;
	if(isPrompt){ strPrompt = "prompt"; }
	else { strPrompt = "nonprompt"; }
	if(isEmbedded){ strEmbd = "embd";	}
	else { strEmbd = "nonembd"; }
	if(isPair){ strPair = "Pair"; }
	else { strPair = "Trk"; }
	cout << "strPrompt = " << strPrompt.c_str() << endl;
	cout << "strEmbd = " << strEmbd.c_str() << endl;
	cout << "strPair = " << strPair.c_str() << endl;

	TFile * refFile01;
	TFile * refFile02;

	//refFile01 = new TFile(Form("./eff_74X_setBr_wDetached/Eff_isPtCut0_doWeight0_isEmbedded1_%s_embd_%s.root",strPrompt.c_str(),strPair.c_str()));
	refFile01 = new TFile(Form("./eff_cent_setBr_goni/Eff_%s_embd_%s.root",strPrompt.c_str(),strPair.c_str()));
	refFile02 = new TFile(Form("./eff_cent_setBr_rm3step/Eff_%s_embd_%s.root",strPrompt.c_str(),strPair.c_str()));
	//refFile02 = new TFile(Form("./eff_cent_setBr_muonSeeded/Eff_%s_embd_%s.root",strPrompt.c_str(),strPair.c_str()));

	TH1D * h1D_EffPt_01 = (TH1D*)refFile01->Get("hEffPt");
	TH1D * h1D_EffPt_02 = (TH1D*)refFile02->Get("hEffPt");
	TH1D * h1D_EffRap_01 = (TH1D*)refFile01->Get("hEffRap");
	TH1D * h1D_EffRap_02 = (TH1D*)refFile02->Get("hEffRap");
	TH1D * h1D_EffLxy_01 = (TH1D*)refFile01->Get("hEffLxy");
	TH1D * h1D_EffLxy_02 = (TH1D*)refFile02->Get("hEffLxy");
	TH1D * h1D_EffCent_01 = (TH1D*)refFile01->Get("hEffCent");
	TH1D * h1D_EffCent_02 = (TH1D*)refFile02->Get("hEffCent");
	h1D_EffPt_01->SetName("h1D_EffPt_01");
	h1D_EffPt_02->SetName("h1D_EffPt_02");
	h1D_EffRap_01->SetName("h1D_EffRap_01");
	h1D_EffRap_02->SetName("h1D_EffRap_02");
	h1D_EffLxy_01->SetName("h1D_EffLxy_01");
	h1D_EffLxy_02->SetName("h1D_EffLxy_02");
	h1D_EffCent_01->SetName("h1D_EffCent_01");
	h1D_EffCent_02->SetName("h1D_EffCent_02");

	TH1D* hRatio_EffPt = (TH1D*)h1D_EffPt_02->Clone("hRatio_EffPt");
	if (isBinomial) hRatio_EffPt->Divide(h1D_EffPt_02,h1D_EffPt_01,1,1,"B");
	else hRatio_EffPt->Divide(h1D_EffPt_01);
	TH1D* hRatio_EffRap = (TH1D*)h1D_EffRap_02->Clone("hRatio_EffRap");
	if (isBinomial) hRatio_EffRap->Divide(h1D_EffRap_02,h1D_EffRap_01,1,1,"B");
	else hRatio_EffRap->Divide(h1D_EffRap_01);
	TH1D* hRatio_EffLxy = (TH1D*)h1D_EffLxy_02->Clone("hRatio_EffLxy");
	if (isBinomial) hRatio_EffLxy->Divide(h1D_EffLxy_02,h1D_EffLxy_01,1,1,"B");
	else hRatio_EffLxy->Divide(h1D_EffLxy_01);
	TH1D* hRatio_EffCent = (TH1D*)h1D_EffCent_02->Clone("hRatio_EffCent");
	if (isBinomial) hRatio_EffCent->Divide(h1D_EffCent_02,h1D_EffCent_01,1,1,"B");
	else hRatio_EffCent->Divide(h1D_EffCent_01);

	//latex box for beam, rapidity, pT info
	TLatex* tex = new TLatex();
	tex->SetNDC();
	tex->SetTextAlign(12);
	tex->SetTextSize(0.04);

	//Legend
	TLegend *legUR = new TLegend(0.56,0.68,0.90,0.90,NULL,"brNDC");
	//TLegend *legUL = new TLegend(0.17,0.68,0.51,0.90,NULL,"brNDC");
	TLegend *legUL = new TLegend(0.20,0.71,0.51,0.90,NULL,"brNDC");
	TLegend *legBM = new TLegend(0.40,0.20,0.75,0.35,NULL,"brNDC");
	TLegend *legBR = new TLegend(0.56,0.20,0.90,0.42,NULL,"brNDC");
	SetLegendStyle(legUR);
	SetLegendStyle(legUL);
	SetLegendStyle(legBM);
	SetLegendStyle(legBR);

	//////////////////////////////////////////////////////////////////
	// --- Draw histograms
	TCanvas* c1 = new TCanvas("c1","c1",600,600);
	
	////// 01 Pt
	c1->cd();
	h1D_EffPt_01->GetXaxis()->SetTitle("p_{T} (GeV/c)");
	h1D_EffPt_01->GetXaxis()->CenterTitle();
	h1D_EffPt_01->GetYaxis()->SetTitle("Efficiency");
	//h1D_EffPt_01->GetXaxis()->SetRangeUser(0,16);
	if (isPrompt) h1D_EffPt_01->GetXaxis()->SetRangeUser(0,12);
	else  h1D_EffPt_01->GetXaxis()->SetRangeUser(0,22);
	h1D_EffPt_01->SetMinimum(0);	
	h1D_EffPt_01->SetMaximum(1);	
	SetHistStyle(h1D_EffPt_01,3,0);
	SetHistStyle(h1D_EffPt_02,4,10);
	h1D_EffPt_01->Draw("");
	h1D_EffPt_02->Draw("same");
	if (isPair){
		legUL->SetHeader(strPrompt.c_str());
		legUL->AddEntry(h1D_EffPt_01,ntuple01,"lp");
		legUL->AddEntry(h1D_EffPt_02,ntuple02,"lp");
		legUL->Draw();
	}else{
		legBR->SetHeader(strPrompt.c_str());
		legBR->AddEntry(h1D_EffPt_01,ntuple01,"lp");
		legBR->AddEntry(h1D_EffPt_02,ntuple02,"lp");
		legBR->Draw();
	}
	c1->SaveAs(Form("%s/comp_EffPt_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str()));
//	c1->SaveAs(Form("%s/comp_EffPt_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str()));	
	legUL->Clear();
	legBR->Clear();
	c1->Clear();

	if (isPair) hRatio_EffPt->GetXaxis()->SetTitle("p_{T}^{#mu#mu} (GeV/c)");	
	else hRatio_EffPt->GetXaxis()->SetTitle("p_{T}^{#mu} (GeV/c)");	
	hRatio_EffPt->GetXaxis()->CenterTitle();	
	if (isPrompt) hRatio_EffPt->GetXaxis()->SetRangeUser(0,12);
	else  hRatio_EffPt->GetXaxis()->SetRangeUser(0,22);
	hRatio_EffPt->GetYaxis()->SetTitle(Form("Ratio = [ %s ]/[ %s ]",ntuple02,ntuple01));	
	hRatio_EffPt->SetMinimum(ymin);	
	hRatio_EffPt->SetMaximum(ymax);	
	hRatio_EffPt->Draw();	
	SetHistStyle(hRatio_EffPt,2,0);
	//dashedLine(0.,1.,16.,1.,1,1);
	if (isPrompt) dashedLine(0.,1.,12.,1.,1,1);
	else dashedLine(0.,1.,22.,1.,1,1);
	c1->SaveAs(Form("%s/compRatio_EffPt_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str()));	
//	c1->SaveAs(Form("%s/compRatio_EffPt_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str()));
	c1->Clear();

	////// 02 Y
	c1->cd();
	if (isPair) h1D_EffRap_01->GetXaxis()->SetTitle("y");
	else  h1D_EffRap_01->GetXaxis()->SetTitle("#eta");
	h1D_EffRap_01->GetXaxis()->CenterTitle();
	h1D_EffRap_01->GetYaxis()->SetTitle("Efficiency");
	h1D_EffRap_01->GetXaxis()->SetRangeUser(-2.5,2.5);
	h1D_EffRap_01->SetMinimum(0);	
	h1D_EffRap_01->SetMaximum(1);	
	SetHistStyle(h1D_EffRap_01,3,0);
	SetHistStyle(h1D_EffRap_02,4,10);
	h1D_EffRap_01->Draw("");
	h1D_EffRap_02->Draw("same");
	if (isPair){
		legUL->SetHeader(strPrompt.c_str());
		legUL->AddEntry(h1D_EffPt_01,ntuple01,"lp");
		legUL->AddEntry(h1D_EffPt_02,ntuple02,"lp");
		legUL->Draw();
	}else{
		legBM->SetHeader(strPrompt.c_str());
		legBM->AddEntry(h1D_EffPt_01,ntuple01,"lp");
		legBM->AddEntry(h1D_EffPt_02,ntuple02,"lp");
		legBM->Draw();
	}
	c1->SaveAs(Form("%s/comp_EffRap_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str()));
//	c1->SaveAs(Form("%s/comp_EffRap_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str()));	
	legUL->Clear();
	legBM->Clear();
	c1->Clear();

	if (isPair) hRatio_EffRap->GetXaxis()->SetTitle("y");
	else  hRatio_EffRap->GetXaxis()->SetTitle("#eta");
	hRatio_EffRap->GetXaxis()->CenterTitle();	
	hRatio_EffRap->GetXaxis()->SetRangeUser(-2.5,2.5);
	hRatio_EffRap->GetYaxis()->SetTitle(Form("Ratio = [ %s ]/[ %s ]",ntuple02,ntuple01));	
	hRatio_EffRap->SetMinimum(ymin);	
	hRatio_EffRap->SetMaximum(ymax);	
	hRatio_EffRap->Draw();	
	SetHistStyle(hRatio_EffRap,2,0);
	dashedLine(-2.5,1.,2.5,1.,1,1);
	c1->SaveAs(Form("%s/compRatio_EffRap_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str()));	
//	c1->SaveAs(Form("%s/compRatio_EffRap_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str()));
	c1->Clear();

	////// 03 Lxy
	c1->cd();
	h1D_EffLxy_01->GetXaxis()->SetTitle("L_{xy}");
	h1D_EffLxy_01->GetXaxis()->CenterTitle();
	h1D_EffLxy_01->GetYaxis()->SetTitle("Efficiency");
	h1D_EffLxy_01->GetXaxis()->SetRangeUser(0,1);
	h1D_EffLxy_01->SetMinimum(0);	
	h1D_EffLxy_01->SetMaximum(1);	
	SetHistStyle(h1D_EffLxy_01,3,0);
	SetHistStyle(h1D_EffLxy_02,4,10);
	h1D_EffLxy_01->Draw("");
	h1D_EffLxy_02->Draw("same");
	if (isPair){
		legUL->SetHeader(strPrompt.c_str());
		legUL->AddEntry(h1D_EffPt_01,ntuple01,"lp");
		legUL->AddEntry(h1D_EffPt_02,ntuple02,"lp");
		legUL->Draw();
	}else{
		legBM->SetHeader(strPrompt.c_str());
		legBM->AddEntry(h1D_EffPt_01,ntuple01,"lp");
		legBM->AddEntry(h1D_EffPt_02,ntuple02,"lp");
		legBM->Draw();
	}
	c1->SaveAs(Form("%s/comp_EffLxy_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str()));
//	c1->SaveAs(Form("%s/comp_EffLxy_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str()));	
	legUL->Clear();
	legBM->Clear();
	c1->Clear();

	hRatio_EffLxy->GetXaxis()->SetTitle("L_{xy}");	
	hRatio_EffLxy->GetXaxis()->CenterTitle();	
	hRatio_EffLxy->GetXaxis()->SetRangeUser(0,1);
	hRatio_EffLxy->GetYaxis()->SetTitle(Form("Ratio = [ %s ]/[ %s ]",ntuple02,ntuple01));	
	hRatio_EffLxy->SetMinimum(ymin);	
	hRatio_EffLxy->SetMaximum(ymax);	
	hRatio_EffLxy->Draw();	
	SetHistStyle(hRatio_EffLxy,2,0);
	dashedLine(0.,1.,1.,1.,1,1);
	c1->SaveAs(Form("%s/compRatio_EffLxy_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str()));	
//	c1->SaveAs(Form("%s/compRatio_EffLxy_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str()));
	c1->Clear();

	////// 04 Cent
	c1->cd();
	h1D_EffCent_01->GetXaxis()->SetTitle("Centrality");
	h1D_EffCent_01->GetXaxis()->CenterTitle();
	h1D_EffCent_01->GetYaxis()->SetTitle("Efficiency");
	h1D_EffCent_01->GetXaxis()->SetRangeUser(0,200);
	h1D_EffCent_01->SetMinimum(0);	
	h1D_EffCent_01->SetMaximum(1);	
	SetHistStyle(h1D_EffCent_01,3,0);
	SetHistStyle(h1D_EffCent_02,4,10);
	h1D_EffCent_01->Draw("");
	h1D_EffCent_02->Draw("same");
	if (isPair){
		legUL->SetHeader(strPrompt.c_str());
		legUL->AddEntry(h1D_EffPt_01,ntuple01,"lp");
		legUL->AddEntry(h1D_EffPt_02,ntuple02,"lp");
		legUL->Draw();
	}else{
		legBM->SetHeader(strPrompt.c_str());
		legBM->AddEntry(h1D_EffPt_01,ntuple01,"lp");
		legBM->AddEntry(h1D_EffPt_02,ntuple02,"lp");
		legBM->Draw();
	}
	c1->SaveAs(Form("%s/comp_EffCent_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str()));
//	c1->SaveAs(Form("%s/comp_EffCent_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str()));	
	legUL->Clear();
	legBM->Clear();
	c1->Clear();

	hRatio_EffCent->GetXaxis()->SetTitle("Centrality");	
	hRatio_EffCent->GetXaxis()->CenterTitle();	
	hRatio_EffCent->GetXaxis()->SetRangeUser(0,200);
	hRatio_EffCent->GetYaxis()->SetTitle(Form("Ratio = [ %s ]/[ %s ]",ntuple02,ntuple01));	
	hRatio_EffCent->SetMinimum(ymin);	
	hRatio_EffCent->SetMaximum(ymax);	
	hRatio_EffCent->Draw();	
	SetHistStyle(hRatio_EffCent,2,0);
	dashedLine(0.,1.,200.,1.,1,1);
	c1->SaveAs(Form("%s/compRatio_EffCent_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str()));	
//	c1->SaveAs(Form("%s/compRatio_EffCent_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str()));
	c1->Clear();



	TFile* outFile = new TFile(Form("%s/compRatio_%s_%s.root",dirName,strPrompt.c_str(),strPair.c_str()), "RECREATE");
	outFile->cd();
	hRatio_EffPt->Write();
	hRatio_EffRap->Write();
	hRatio_EffLxy->Write();
	hRatio_EffCent->Write();
	outFile->Close();

	return;

}
Example #13
0
int binfit_ttree_genlvl() {
  gROOT->Reset();
  gErrorIgnoreLevel=kError;
  float scaledps,scalesps,scalenlo,siggg,siggu,sigug;
  float datamass[81]={0};
  int dpsmass[81]={0};
  int spsmass[81]={0};
  float nlomass[81]={0.0};
  int nloggmass[81]={0};
  int nlogumass[81]={0};
  int nlougmass[81]={0};
  //  float datapt[60],datady[20],datay[20];
  TChain dps("Events");
  TChain nlogg("Events");
  TChain sps("Events");

//  dps.Add("Modified_Input_To_Fit_2012DPS_TMTight_3MuL3Match.root");
  dps.Add("genevents/GENEventTree_dps_pu_old_1.root");
  dps.Add("genevents/GENEventTree_dps_pu_old_2.root");
  dps.Add("genevents/GENEventTree_dps_pu_old_3.root");
  nlogg.Add("genevents/GENEventTree_pythia8_PU_OffsetBS_fixp3_1.root");
  nlogg.Add("genevents/GENEventTree_pythia8_PU_OffsetBS_fixp3_2.root");
  nlogg.Add("genevents/GENEventTree_pythia8_PU_OffsetBS_fixp3_3.root");
  nlogg.Add("genevents/GENEventTree_pythia8_PU_OffsetBS_fixp3_4.root");
  nlogg.Add("genevents/GENEventTree_pythia8_PU_OffsetBS_fixp3_5.root");
  nlogg.Add("genevents/GENEventTree_pythia8_PU_OffsetBS_fixp3_6_1.root ");
  nlogg.Add("genevents/GENEventTree_pythia8_PU_OffsetBS_fixp3_6_2.root ");
  sps.Add("genevents/GENEventTree_SPSLO_xl21_1.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl21_2.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl22_1.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl22_2.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl23_1.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl23_2.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl26_1.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl26_2.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl27_1.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl27_2.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl28_1.root");
  sps.Add("genevents/GENEventTree_SPSLO_xl28_2.root");
  

  float massbins[]={6.2,7,9,11,14,18,25,30,60};
  float ptbins[]={0.,7,12,16,20,25,50,80};
  float dybins[]={0.,0.2,0.4,0.6,0.9,1.3,1.8,2.4,4.5};
  //float ybins[]={-2.2,-1.8,-1.6,-1.4,-1.2,-1.0,-0.8,-0.6,-0.4,-0.2,0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.2};
  float ybins[]={0.,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8};
  int nmbins = 8; 
  int nptbins = 7;
  int ndybins = 8;
  int nybins = 9;
  //float massbins[]={0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60};
  //float ptbins[]={0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80};
  //float dybins[]={0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.0,4.1,4.2,4.3,4.4,4.5};
  //float ybins[]={0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8};
  //  int nmbins = 30;
  //  int nptbins = 40;
  //  int ndybins = 45;
  //  int nybins = 18;
  //int nybins = 20;
    int mbinerr = -99;
    int ptbinerr = -99;
    int dybinerr = -99;
    int ybinerr = -99;
  TH1F *mass_data = new TH1F("mass_data","mass_data",nmbins,massbins); 
  TH1F *mass_dps = new TH1F("mass_dps","mass_dps",nmbins,massbins); 
  TH1F *mass_nlogg = new TH1F("mass_nlogg","mass_nlogg",nmbins,massbins); 
  TH1F *mass_nlo = new TH1F("mass_nlo","mass_nlo",nmbins,massbins); 
  TH1F *mass_sps = new TH1F("mass_sps","mass_sps",nmbins,massbins); 
  TH1F *mass_width = new TH1F("mass_width","mass_width",nmbins,massbins); 
  TH1F *pt_data = new TH1F("pt_data","pt_data",nptbins,ptbins); 
  TH1F *pt_dps = new TH1F("pt_dps","pt_dps",nptbins,ptbins); 
  TH1F *pt_nlogg = new TH1F("pt_nlogg","pt_nlogg",nptbins,ptbins); 
  TH1F *pt_nlo = new TH1F("pt_nlo","pt_nlo",nptbins,ptbins); 
  TH1F *pt_sps = new TH1F("pt_sps","pt_sps",nptbins,ptbins); 
  TH1F *pt_width = new TH1F("pt_width","pt_width",nptbins,ptbins); 
  TH1F *dy_data = new TH1F("dy_data","dy_data",ndybins,dybins); 
  TH1F *dy_dps = new TH1F("dy_dps","dy_dps",ndybins,dybins); 
  TH1F *dy_nlogg = new TH1F("dy_nlogg","dy_nlogg",ndybins,dybins); 
  TH1F *dy_nlo = new TH1F("dy_nlo","dy_nlo",ndybins,dybins); 
  TH1F *dy_sps = new TH1F("dy_sps","dy_sps",ndybins,dybins); 
  TH1F *dy_width = new TH1F("dy_width","dy_width",ndybins,dybins); 
  TH1F *y_data = new TH1F("y_data","y_data",nybins,ybins); 
  TH1F *y_dps = new TH1F("y_dps","y_dps",nybins,ybins); 
  TH1F *y_nlogg = new TH1F("y_nlogg","y_nlogg",nybins,ybins); 
  TH1F *y_nlo = new TH1F("y_nlo","y_nlo",nybins,ybins); 
  TH1F *y_sps = new TH1F("y_sps","y_sps",nybins,ybins); 
  TH1F *y_width = new TH1F("y_width","y_width",nybins,ybins); 

  mass_data->SetBinContent(1,47.43199);
  mass_data->SetBinContent(2,22.88957);
  mass_data->SetBinContent(3,10.52912);
  mass_data->SetBinContent(4,7.297879);
  mass_data->SetBinContent(5,4.679995);
  mass_data->SetBinContent(6,2.752399);
  mass_data->SetBinContent(7,2.321633);
  mass_data->SetBinContent(8,0.4013286);
  mass_data->SetBinError(1,6.281534);
  mass_data->SetBinError(2,2.358319);
  mass_data->SetBinError(3,1.509835);
  mass_data->SetBinError(4,1.177612);
  mass_data->SetBinError(5,0.7126356);
  mass_data->SetBinError(6,0.3761612);
  mass_data->SetBinError(7,0.3408355);
  mass_data->SetBinError(8,0.05351048);
  pt_data->SetBinContent(1,5.511632);
  pt_data->SetBinContent(2,5.816723);
  pt_data->SetBinContent(3,9.881093);
  pt_data->SetBinContent(4,9.516933);
  pt_data->SetBinContent(5,5.7525);
  pt_data->SetBinContent(6,0.676141);
  pt_data->SetBinContent(7,0.06380682);
  pt_data->SetBinError(1,0.6928909);
  pt_data->SetBinError(2,0.9048236);
  pt_data->SetBinError(3,1.589567);
  pt_data->SetBinError(4,1.189617);
  pt_data->SetBinError(5,0.607507);
  pt_data->SetBinError(6,0.06388734);
  pt_data->SetBinError(7,0.01890572);
  dy_data->SetBinContent(1,353.6836);
  dy_data->SetBinContent(2,208.9763);
  dy_data->SetBinContent(3,100.067);
  dy_data->SetBinContent(4,59.72152);
  dy_data->SetBinContent(5,39.28412);
  dy_data->SetBinContent(6,23.76292);
  dy_data->SetBinContent(7,22.76975);
  dy_data->SetBinContent(8,10.52381);
  dy_data->SetBinError(1,28.61261);
  dy_data->SetBinError(2,21.71715);
  dy_data->SetBinError(3,14.11659);
  dy_data->SetBinError(4,10.30196);
  dy_data->SetBinError(5,6.846661);
  dy_data->SetBinError(6,5.372485);
  dy_data->SetBinError(7,4.64503);
  dy_data->SetBinError(8,2.287784);
  y_data->SetBinContent(1,96.87107);
  y_data->SetBinContent(2,110.5371);
  y_data->SetBinContent(3,89.27422);
  y_data->SetBinContent(4,101.8527);
  y_data->SetBinContent(5,77.61348);
  y_data->SetBinContent(6,95.7653);
  y_data->SetBinContent(7,137.6607);
  y_data->SetBinContent(8,168.4277);
  y_data->SetBinContent(9,120.5354);
  y_data->SetBinError(1,14.97098);
  y_data->SetBinError(2,15.67618);
  y_data->SetBinError(3,12.3992);
  y_data->SetBinError(4,13.63791);
  y_data->SetBinError(5,10.98304);
  y_data->SetBinError(6,14.26707);
  y_data->SetBinError(7,17.44995);
  y_data->SetBinError(8,23.01054);
  y_data->SetBinError(9,22.7678);

  mass_width->SetBinContent(1,0.8);
  mass_width->SetBinContent(2,2.);
  mass_width->SetBinContent(3,2.);
  mass_width->SetBinContent(4,3.);
  mass_width->SetBinContent(5,4.);
  mass_width->SetBinContent(6,5.);
  mass_width->SetBinContent(7,5.);
  mass_width->SetBinContent(8,30.);
  pt_width->SetBinContent(1,7.);
  pt_width->SetBinContent(2,5.);
  pt_width->SetBinContent(3,4.);
  pt_width->SetBinContent(4,4.);
  pt_width->SetBinContent(5,5.);
  pt_width->SetBinContent(6,25.);
  pt_width->SetBinContent(7,30.);
  dy_width->SetBinContent(1,0.2);
  dy_width->SetBinContent(2,0.2);
  dy_width->SetBinContent(3,0.2);
  dy_width->SetBinContent(4,0.3);
  dy_width->SetBinContent(5,0.4);
  dy_width->SetBinContent(6,0.5);
  dy_width->SetBinContent(7,0.6);
  dy_width->SetBinContent(8,2.1);
  y_width->SetBinContent(1,0.2);
  y_width->SetBinContent(2,0.2);
  y_width->SetBinContent(3,0.2);
  y_width->SetBinContent(4,0.2);
  y_width->SetBinContent(5,0.2);
  y_width->SetBinContent(6,0.2);
  y_width->SetBinContent(7,0.2);
  y_width->SetBinContent(8,0.2);
  y_width->SetBinContent(9,0.2);

  dps.Draw("FourMu_Mass >> mass_dps","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
  nlogg.Draw("FourMu_Mass >> mass_nlogg","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
  sps.Draw("FourMu_Mass >> mass_sps","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
  mass_dps->Divide(mass_width);
  mass_nlogg->Divide(mass_width);
  mass_sps->Divide(mass_width);
  datamass[0]=mass_data->Integral("width");
  std::cout<<datamass[0]<<std::endl;
  dpsmass[0]=mass_dps->Integral("width");
  spsmass[0]=mass_sps->Integral("width");
  nloggmass[0]=mass_nlogg->Integral("width");
  nlomass[0]=nloggmass[0];

  scaledps = datamass[0]/ (float) dpsmass[0];
  scalesps= datamass[0]/ (float) spsmass[0];
  scalenlo= datamass[0]/ (float) nloggmass[0];
  float Chi2=0;
  float minchi2norm=99999999.9;
  float minchi2=9999999.9;
  float mina, minb, minc, minan, minbn, mincn;

  //   Chi2 = Chi2 + pow((datamass[1] - (0.00*scaledps*dpsmass[1] + 0.0*scalesps*spsmass[1] + 0.0*scalenlo*nlomass[1])),2)/sqrt(datamass[1]);
  //  std::cout<<"Scale: " <<datamass[0]<<" " << dpsmass[0]<<" "<<scaledps<<" "<<scalesps<<" "<<scalenlo<<" "<<std::endl;
  for(float a=0.1; a<0.5; a=a+0.01){
        dps.Draw("FourMu_Mass >> mass_dps","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        nlogg.Draw("FourMu_Mass >> mass_nlogg","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        sps.Draw("FourMu_Mass >> mass_sps","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        dps.Draw("FourMu_pT >> pt_dps","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        nlogg.Draw("FourMu_pT >> pt_nlogg","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        sps.Draw("FourMu_pT >> pt_sps","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        dps.Draw("Psi1To2_dY >> dy_dps","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        nlogg.Draw("Psi1To2_dY >> dy_nlogg","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        sps.Draw("Psi1To2_dY >> dy_sps","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        dps.Draw("abs(FourMu_Rapidity)>> y_dps","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        nlogg.Draw("abs(FourMu_Rapidity) >> y_nlogg","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.0)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
        sps.Draw("abs(FourMu_Rapidity) >> y_sps","FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.0)==2&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
  mass_dps->Divide(mass_width);
  mass_nlogg->Divide(mass_width);
  mass_sps->Divide(mass_width);
  pt_dps->Divide(pt_width);
  pt_nlogg->Divide(pt_width);
  pt_sps->Divide(pt_width);
  dy_dps->Divide(dy_width);
  dy_nlogg->Divide(dy_width);
  dy_sps->Divide(dy_width);
  y_dps->Divide(y_width);
  y_nlogg->Divide(y_width);
  y_sps->Divide(y_width);
        for(int mbin=1; mbin<=nmbins; ++mbin){
          Chi2=Chi2 + pow((mass_data->GetBinContent(mbin) - (a*scaledps*mass_dps->GetBinContent(mbin) + (1.-a)*scalenlo*mass_nlogg->GetBinContent(mbin)))/mass_data->GetBinError(mbin),2);
          }
        for(int ptbin=1; ptbin<=nptbins; ++ptbin){
          Chi2=Chi2 + pow((pt_data->GetBinContent(ptbin) - (a*scaledps*pt_dps->GetBinContent(ptbin) + (1.-a)*scalenlo*pt_nlogg->GetBinContent(ptbin)))/pt_data->GetBinError(ptbin),2);
            //         std::cout<<pt_data->GetBinContent(ptbin)<<std::endl;
        }
        for(int dybin=1; dybin<=ndybins; ++dybin){
          Chi2=Chi2 + pow((dy_data->GetBinContent(dybin) - (a*scaledps*dy_dps->GetBinContent(dybin) + (1.-a)*scalenlo*dy_nlogg->GetBinContent(dybin)))/dy_data->GetBinError(dybin),2);
        }
        for(int ybin=1; ybin<=nybins; ++ybin){
          Chi2=Chi2 + pow((y_data->GetBinContent(ybin) - (a*scaledps*y_dps->GetBinContent(ybin) + (1.-a)*scalenlo*y_nlogg->GetBinContent(ybin)))/y_data->GetBinError(ybin),2);
          //           std::cout<<Chi2<<std::endl;
        }
        //        std::cout<<"a, b, c: "<<a<<" "<<b<<" "<<c<<" Chi2: "<<Chi2<<std::endl;
        std::cout<<a<<" "<<Chi2<<std::endl;
        if (Chi2<=minchi2){
          minchi2=Chi2; minan = a; minbn = 0.; mincn=(1.-a); 
        }
        //        std::cout<<a<<" "<<b<<" "<<c<<" "<<Chi2<<std::endl;
        Chi2=0;
    }
    std::cout<<"Min Chi2: "<<minchi2<<" dps, sps, nlo: "<<minan<<" "<<minbn<<" "<<mincn<<std::endl;
    TCanvas* disp = new TCanvas("disp","disp",900,900);
    disp->Divide(2,2);
    TH1F *MassSum = new TH1F("MassSum","MassSum",nmbins,massbins);
    TH1F *MassBest = new TH1F("MassBest","MassBest",nmbins,massbins);
    TH1F *DpsBestM = new TH1F("DpsBestM","DpsBestM",nmbins,massbins);
    TH1F *SpsBestM = new TH1F("SpsBestM","SpsBestM",nmbins,massbins);
    TH1F *NloBestM = new TH1F("NloBestM","NloBestM",nmbins,massbins);
    TH1F *pTBest = new TH1F("pTBest","pTBest",nptbins,ptbins);
    TH1F *pTSum = new TH1F("pTSum","pTSum",nptbins,ptbins);
    TH1F *DpsBestpt = new TH1F("DpsBestpt","DpsBestpt",nptbins,ptbins);
    TH1F *NloBestpt = new TH1F("NloBestpt","NloBestpt",nptbins,ptbins);
    TH1F *SpsBestpt = new TH1F("SpsBestpt","SpsBestpt",nptbins,ptbins);
    TH1F *dyBest = new TH1F("dyBest","dyBest",ndybins,dybins);
    TH1F *dySum = new TH1F("dySum","dySum",ndybins,dybins);
    TH1F *DpsBestdy = new TH1F("DpsBestdy","DpsBestdy",ndybins,dybins);
    TH1F *NloBestdy = new TH1F("NloBestdy","NloBestdy",ndybins,dybins);
    TH1F *SpsBestdy = new TH1F("SpsBestdy","SpsBestdy",ndybins,dybins);
    TH1F *yBest = new TH1F("yBest","yBest",nybins,ybins);
    TH1F *ySum = new TH1F("ySum","ySum",nybins,ybins);
    TH1F *DpsBesty = new TH1F("DpsBesty","DpsBesty",nybins,ybins);
    TH1F *NloBesty = new TH1F("NloBesty","NloBesty",nybins,ybins);
    TH1F *SpsBesty = new TH1F("SpsBesty","SpsBesty",nybins,ybins);
    MassBest->SetMinimum(0);pTBest->SetMinimum(0);dyBest->SetMinimum(0);yBest->SetMinimum(0);
    mass_data->SetMinimum(0);pt_data->SetMinimum(0);dy_data->SetMinimum(0);y_data->SetMinimum(0);
    dps.Draw("FourMu_Mass>>DpsBestM","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    nlogg.Draw("FourMu_Mass>>NloBestM","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    sps.Draw("FourMu_Mass>>SpsBestM","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    dps.Draw("FourMu_pT>>DpsBestpt","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    nlogg.Draw("FourMu_pT>>NloBestpt","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    sps.Draw("FourMu_pT>>SpsBestpt","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    dps.Draw("Psi1To2_dY>>DpsBestdy","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    nlogg.Draw("Psi1To2_dY>>NloBestdy","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    sps.Draw("Psi1To2_dY>>SpsBestdy","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    dps.Draw("abs(FourMu_Rapidity)>>DpsBesty","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    nlogg.Draw("abs(FourMu_Rapidity)>>NloBesty","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
    sps.Draw("abs(FourMu_Rapidity)>>SpsBesty","(FourMu_Mass>=0&&FourMu_Mass<=60&&Sum$(abs(Psi_y)<=0.95&&Psi_pT>8.0||abs(Psi_y)>0.95&&abs(Psi_y)<1.4&&(Psi_pT>-5.55*abs(Psi_y)+13.3)||abs(Psi_y)>=1.4&&abs(Psi_y)<=1.9&&Psi_pT>5.5)==2)&&Sum$(Psi_Mass[]<3.35&&Psi_Mass>2.85)==2","goff");
  DpsBestM->Divide(mass_width);
  NloBestM->Divide(mass_width);
  SpsBestM->Divide(mass_width);
  DpsBestpt->Divide(pt_width);
  NloBestpt->Divide(pt_width);
  SpsBestpt->Divide(pt_width);
  DpsBestdy->Divide(dy_width);
  NloBestdy->Divide(dy_width);
  SpsBestdy->Divide(dy_width);
  DpsBesty->Divide(y_width);
  NloBesty->Divide(y_width);
  SpsBesty->Divide(y_width);
    //MassSum->Add(DpsBest,(float) mina);
    //MassSum->Add(SpsBest,minb);
    //MassSum->Add(NloBest,minc);
    mass_data->SetMinimum(0);
    mass_data->SetXTitle("Four Mu Mass (GeV)");
    pt_data->SetXTitle("Four Mu pT (GeV)");
    dy_data->SetXTitle("|#Delta Y| between J/#psi");
    y_data->SetXTitle("Four Mu Rapidity |Y|");
    mass_data->SetTitle("");
    pt_data->SetTitle("");
    dy_data->SetTitle("");
    y_data->SetTitle("");
    disp->cd(1);
    DpsBestM->SetLineColor(kRed);
    NloBestM->SetLineColor(kGreen);
    SpsBestM->SetLineColor(kBlue);
    DpsBestM->Scale(minan*scaledps);
    NloBestM->Scale(mincn*scalenlo);
    SpsBestM->Scale(minbn*scalesps);
    MassSum->Add(DpsBestM);
    MassSum->Add(NloBestM);
    MassSum->Add(SpsBestM);
    mass_data->Draw("E1");
    MassSum->Draw("same");
    DpsBestM->Draw("same");
    NloBestM->Draw("same");
    SpsBestM->Draw("same");
    TLegend *leg = new TLegend(0.6,0.7,0.90,0.9);
    leg->SetFillStyle(0);
    leg->SetBorderSize(0);
    leg->SetShadowColor(0);
    leg->AddEntry(DpsBestM,"DPS model","l");
    leg->AddEntry(NloBestM,"SPS NLO model","l");
    leg->AddEntry(MassSum,"MC model sum","l");
    leg->AddEntry(MassBest,"Data","lep");
    leg->Draw();
    disp->cd(2);
    DpsBestpt->SetLineColor(kRed);
    NloBestpt->SetLineColor(kGreen);
    SpsBestpt->SetLineColor(kBlue);
    DpsBestpt->Scale(minan*scaledps);
    NloBestpt->Scale(mincn*scalenlo);
    SpsBestpt->Scale(minbn*scalesps);
    pTSum->Add(DpsBestpt);
    pTSum->Add(NloBestpt);
    pTSum->Add(SpsBestpt);
    pt_data->Draw("e1");
    pTSum->Draw("same");
    DpsBestpt->Draw("same");
    NloBestpt->Draw("same");
    SpsBestpt->Draw("same");
    leg->Draw();
    disp->cd(3);
    DpsBestdy->SetLineColor(kRed);
    NloBestdy->SetLineColor(kGreen);
    SpsBestdy->SetLineColor(kBlue);
    DpsBestdy->Scale(minan*scaledps);
    NloBestdy->Scale(mincn*scalenlo);
    SpsBestdy->Scale(minbn*scalesps);
    dySum->Add(DpsBestdy);
    dySum->Add(NloBestdy);
    dySum->Add(SpsBestdy);
    dy_data->Draw("e1");
    dySum->Draw("same");
    DpsBestdy->Draw("same");
    NloBestdy->Draw("same");
    SpsBestdy->Draw("same");
    leg->Draw();
    disp->cd(4);
    DpsBesty->SetLineColor(kRed);
    NloBesty->SetLineColor(kGreen);
    SpsBesty->SetLineColor(kBlue);
    DpsBesty->Scale(minan*scaledps);
    NloBesty->Scale(mincn*scalenlo);
    SpsBesty->Scale(minbn*scalesps);
    ySum->Add(DpsBesty);
    ySum->Add(NloBesty);
    ySum->Add(SpsBesty);
    y_data->Draw("e1");
    ySum->Draw("same");
    DpsBesty->Draw("same");
    NloBesty->Draw("same");
    SpsBesty->Draw("same");
    leg->Draw();
  }
TCanvas* overlay_RecoSmeared_ExclJetBins(const string& folder, 
								const string& htrange, const hist_t& h
								)
{

	TLegend *leg  = new TLegend(0.6,0.65,0.9,0.9);
	leg->SetTextFont(42);
	TCanvas* c1 = new TCanvas("c1");
	gPad->SetLogy();
	gPad->SetTickx();
	gPad->SetTicky();

	vector<string> jetcoll;
	jetcoll.push_back("reco");
	jetcoll.push_back("smeared");

	stringstream title;
	title << htrange << ", L = 10 fb^{-1}" << ";" << h.title ;
	
	vector< vector<TH1* > > HISTS;
	for (unsigned j=0; j< jetcoll.size(); ++j)
	{
		stringstream histname;
		histname << folder << "/" << jetcoll.at(j) << h.name;
		cout << __LINE__ << ": Looking for hist: " << histname.str().c_str() << endl;
		vector<TH1*> hists = GetHist(histname.str());
		HISTS.push_back(hists);
	}

	double ymin=0, ymax = 0;
	GetYRange(HISTS,ymin, ymax); 
	if (ymin==0) ymin = 0.0005;

	for (int j=0; j<jetcoll.size(); ++j)
	{
		stringstream jetc;
		if (j==0) jetc << "RECO"; 
		else if (j==1) jetc << "SMEAR"; 

		for (int bin=0; bin<nBins; ++bin)
		{
			HISTS.at(j).at(bin)->Rebin(h.rebin);
			HISTS.at(j).at(bin)->SetTitle(title.str().c_str());
			HISTS.at(j).at(bin)->SetMarkerStyle(20+j);
			HISTS.at(j).at(bin)->SetStats(0);
			

			if (j==1) //all smeared plots 
			{
				HISTS.at(j).at(bin)->SetLineColor(kRed);
				HISTS.at(j).at(bin)->SetMarkerColor(kRed);
				
			}

			int mstyle = 21+bin;
			HISTS.at(j).at(bin)->SetMarkerStyle(mstyle);
			stringstream legname;
			if (bin==0) legname << "==2 Jets";
			else if (bin==1) legname << "3-5 Jets";
			else if (bin==2) legname << "6-7 Jets";
			else if (bin==3) legname << "#geq 8 Jets";

			if (j==0 && bin==0) 
			{
				HISTS.at(j).at(bin)->GetYaxis()->SetRangeUser(ymin*0.5, ymax*10);
				HISTS.at(j).at(bin)->Draw();
			} else  HISTS.at(j).at(bin)->Draw("same");

			const double sum = HISTS.at(j).at(bin)->Integral(1, HISTS.at(j).at(bin)->GetNbinsX()+1); 
			legname << "[" << jetc.str() << "] (" << sum << ")";
			leg->AddEntry(HISTS.at(j).at(bin), legname.str().c_str());
		}
	}
	leg->Draw();

	
	/*TH1* ratio = dynamic_cast<TH1*> (hists.at(2)->Clone("ratio"));
	ratio->GetYaxis()->SetTitle("Smeared/Reco");
	ratio->SetTitle("");
	ratio->Divide(hists.at(0));
	//ratio->GetYaxis()->SetRangeUser(-0.01,2.01);
	ratio->GetYaxis()->SetRangeUser(0.49,1.51);
	//ratio->SetTickLength (+0.01,"Y");

   //TCanvas *c1 = new TCanvas("c1", "c1",15,60,550,600);
   TCanvas *c1 = new TCanvas("c1");
   c1->Range(0,0,1,1);
   c1->SetBorderSize(2);
   c1->SetFrameFillColor(0);
  
// ------------>Primitives in pad: c1_1
   TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.30,0.99,0.99);
   c1_1->Draw();
   c1_1->cd();
   c1_1->SetBorderSize(2);
   c1_1->SetTickx(1);
   c1_1->SetTicky(1);
   c1_1->SetTopMargin(0.1);
   c1_1->SetBottomMargin(0.0);
   //c1_1->SetFrameFillColor(3);
	c1_1->SetLogy();
   
	hists.at(0)->GetYaxis()->CenterTitle(1);
	hists.at(0)->SetLabelFont(42,"XYZ");
	hists.at(0)->SetTitleFont(42,"XYZ");
	hists.at(0)->GetYaxis()->SetTitleOffset(0.8);
	hists.at(0)->SetLabelSize(0.05,"XYZ");
	hists.at(0)->SetTitleSize(0.06,"XYZ");
   hists.at(0)->Draw("P");
   hists.at(2)->Draw("same P");
	leg->Draw();

   c1_1->Modified();
   c1->cd();
  
// ------------>Primitives in pad: c1_2
   TPad *c1_2 = new TPad("c1_2", "c1_2",0.01,0.01,0.99,0.30);
   c1_2->Draw();
   c1_2->cd();
   c1_2->SetBorderSize(2);
   c1_2->SetTickx(1);
   c1_2->SetTicky(1);
   c1_2->SetTopMargin(0.0);
   c1_2->SetBottomMargin(0.24);
   c1_2->SetFrameFillColor(0);
	c1_2->SetGridx();
	c1_2->SetGridy();
   
	ratio->GetYaxis()->SetTitleOffset(0.4);
	ratio->GetXaxis()->SetTitleOffset(0.9);
	ratio->GetYaxis()->CenterTitle(1);
	ratio->GetXaxis()->CenterTitle(1);
	ratio->SetLabelSize(0.125,"XYZ");
	ratio->SetTitleSize(0.125,"XYZ");
//	ratio->SetLabelFont(labelfont,"XYZ");
//	ratio->SetTitleFont(titlefont,"XYZ");
   ratio->GetXaxis()->SetTickLength(0.07);
   ratio->Draw("");
   
   c1_2->Modified();
   c1->cd();
   //c1->Modified();
   //c1->cd();
   //c1->SetSelected(c1);
	*/
	return c1;
	//return gPad;

}
Example #15
0
void ptBestFit(float BIN_SIZE=5.0,bool BLIND=false,TString MASS,TString NAME)
{
  gROOT->ProcessLine(".x ../../common/styleCMSTDR.C");
  gSystem->Load("libHiggsAnalysisCombinedLimit.so");
  gROOT->ForceStyle();
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  gROOT->SetBatch(1);
  gStyle->SetPadRightMargin(0.04);
  gStyle->SetPadLeftMargin(0.16);
  gStyle->SetPadTopMargin(0.06);
  gStyle->SetPadBottomMargin(0.10);
  gStyle->SetTitleFont(42,"XY");
  gStyle->SetTitleSize(0.0475,"XY");
  gStyle->SetTitleOffset(0.9,"X");
  gStyle->SetTitleOffset(1.5,"Y");
  gStyle->SetLabelSize(0.0375,"XY");

  RooMsgService::instance().setSilentMode(kTRUE);
  for(int i=0;i<2;i++) {
    RooMsgService::instance().setStreamStatus(i,kFALSE);
  }
  float XMIN = 80;
  float XMAX = 200; 

  TFile *f1 = TFile::Open("datacards/datacard_m"+MASS+"_"+NAME+".root");
  TFile *f2 = TFile::Open("combine/mlfit.vbfHbb_"+NAME+"_mH"+MASS+".root");
  TFile *f3 = TFile::Open("root/sig_shapes_workspace_B80-200.root");
  TFile *f4 = TFile::Open("root/data_shapes_workspace_"+NAME+".root");

  RooWorkspace *w = (RooWorkspace*)f1->Get("w");
  //w->Print();
  RooAbsPdf *bkg_model = (RooAbsPdf*)w->pdf("model_s");
  RooFitResult *res_s  = (RooFitResult*)f2->Get("fit_s"); 
  RooFitResult *res_b  = (RooFitResult*)f2->Get("fit_b");
  RooRealVar *rFit     = dynamic_cast<RooRealVar *>(res_s->floatParsFinal()).find("r");
  RooDataSet *data     = (RooDataSet*)w->data("data_obs");
  
  int nparS=0,nparB=0;
  cout << res_s->floatParsFinal().getSize() << endl;
  cout << res_b->floatParsFinal().getSize() << endl;
  nparS = res_s->floatParsFinal().getSize();
  nparB = res_b->floatParsFinal().getSize();  
  float chi2sumS = 0.;
  float chi2sumB = 0.;
  int nparsum = 0;
//  if (BLIND) {
//    res_b->Print();
//  }
//  else {
//    res_s->Print();
//  }
  
  w->allVars().assignValueOnly(res_s->floatParsFinal());
//  w->Print();
//  w->allVars()->Print();

  RooWorkspace *wSig = (RooWorkspace*)f3->Get("w"); 
  RooWorkspace *wDat = (RooWorkspace*)f4->Get("w"); 

  const RooSimultaneous *sim = dynamic_cast<const RooSimultaneous *> (bkg_model);
  const RooAbsCategoryLValue &cat = (RooAbsCategoryLValue &) sim->indexCat();
  TList *datasets = data->split(cat,true);
  TIter next(datasets);
  //int count = 0; 
  for(RooAbsData *ds = (RooAbsData*)next();ds != 0; ds = (RooAbsData*)next()) {
	 //if (count > 0) return 0;
	 //count++;
    RooAbsPdf *pdfi = sim->getPdf(ds->GetName());
    RooArgSet *obs = (RooArgSet*)pdfi->getObservables(ds);
    RooRealVar *x = dynamic_cast<RooRealVar *>(obs->first());

    RooRealVar *yield_vbf = (RooRealVar*)wSig->var("yield_signalVBF_mass"+MASS+"_"+TString(ds->GetName()));
    RooRealVar *yield_gf  = (RooRealVar*)wSig->var("yield_signalGF_mass"+MASS+"_"+TString(ds->GetName()));
    TString ds_name(ds->GetName());
    //----- get the QCD normalization -----------
    RooRealVar *qcd_norm_final = dynamic_cast<RooRealVar *>(res_s->floatParsFinal()).find("CMS_vbfbb_qcd_norm_"+ds_name);
    RooRealVar *qcd_yield      = (RooRealVar*)wDat->var("yield_data_"+ds_name);

    float Nqcd  = exp(log(1.5)*qcd_norm_final->getVal())*qcd_yield->getVal();
    float eNqcd = log(1.5)*qcd_norm_final->getError()*Nqcd;
    cout<<"QCD normalization = "<<Nqcd<<" +/- "<<eNqcd<<endl;
    
    TH1 *hCoarse = (TH1*)ds->createHistogram("coarseHisto_"+ds_name,*x);
    float norm = hCoarse->Integral();
  
	 int rebin = BIN_SIZE/hCoarse->GetBinWidth(1);
    hCoarse->Rebin(rebin);

    float MIN_VAL = TMath::Max(0.9*hCoarse->GetBinContent(hCoarse->GetMinimumBin()),1.0);
    float MAX_VAL = 1.3*hCoarse->GetBinContent(hCoarse->GetMaximumBin());
    RooDataHist ds_coarse("ds_coarse_"+ds_name,"ds_coarse_"+ds_name,*x,hCoarse);

    TH1F *hBlind = (TH1F*)hCoarse->Clone("blindHisto_"+ds_name);
    for(int i=0;i<hBlind->GetNbinsX();i++) {
      double x0 = hBlind->GetBinCenter(i+1);
      if (x0 > 100 && x0 < 150) {
        hBlind->SetBinContent(i+1,0);
        hBlind->SetBinError(i+1,0);
      }
    }
    
    RooDataHist ds_blind("ds_blind_"+ds_name,"ds_blind_"+ds_name,*x,hBlind); 
    
    RooHist *hresid,*hresid0;
    RooPlot *frame1 = x->frame();
    RooPlot *frame2 = x->frame();
    
    if (BLIND) {
		//cout << "Blind case: " << ds_coarse.GetName() << endl;
      ds_coarse.plotOn(frame1,LineColor(0),MarkerColor(0));
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack());
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(3));
      ds_blind.plotOn(frame1);
      hresid = frame1->residHist();
      frame2->addPlotable(hresid,"pE1");
    }
    else {    
		//cout << "Non-blind case: " << ds_coarse.GetName() << endl;
		ds_coarse.plotOn(frame1);
      pdfi->plotOn(frame1);
		//cout << pdfi->getParameters(ds_coarse)->selectByAttrib("Constant",kFALSE)->getSize() << endl;
      cout<<"chi2/ndof (bkg+sig) = "<<frame1->chiSquare()<<endl;
		cout << ds_coarse.numEntries() << endl;
		chi2sumS += frame1->chiSquare()*ds_coarse.numEntries();
		nparsum += ds_coarse.numEntries();
		//hresid0 = frame1->residHist();
      //pdfi->plotOn(frame1,VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack());
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name),LineWidth(2),LineStyle(5),LineColor(kGreen+2));
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(2),LineColor(kBlack)); 
      cout<<"chi2/ndof (bkg) = "<<frame1->chiSquare()<<endl;
		chi2sumB += frame1->chiSquare()*ds_coarse.numEntries();
		pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(2),LineColor(kBlack),VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack()); 
      hresid = frame1->residHist();
      frame2->addPlotable(hresid,"pE1");
    
      float yield_sig = rFit->getValV()*(yield_vbf->getValV()+yield_gf->getValV());
      RooAbsPdf *signal_pdf = (RooAbsPdf*)w->pdf("shapeSig_qqH_"+ds_name);
      signal_pdf->plotOn(frame2,LineWidth(2),LineColor(kRed),Normalization(yield_sig,RooAbsReal::NumEvent),MoveToBack());
    }
//	 hresid0->Print();
//	 hresid->Print();
//	 double x2,y2;
//	 for (int i=0; i<3; ++i) {
//		 hresid0->GetPoint(i,x2,y2);
//		 cout << "BKG+SIG\t" << x2 << "\t" << y2 << endl;
//		 hresid->GetPoint(i,x2,y2);
//		 cout << "BKG\t" << x2 << "\t" << y2 << endl;
//		 ds_coarse.get(i);
//		 cout << ds_coarse.weightError(RooAbsData::SumW2) << endl;
//		 cout << endl;
//	 }

    TCanvas* canFit = new TCanvas("Higgs_fit_"+ds_name,"Higgs_fit_"+ds_name,900,750);
    canFit->cd(1)->SetBottomMargin(0.4);
    frame1->SetMinimum(MIN_VAL);
    frame1->SetMaximum(MAX_VAL);
    frame1->GetYaxis()->SetNdivisions(510);
    frame1->GetXaxis()->SetTitleSize(0);
    frame1->GetXaxis()->SetLabelSize(0);
    frame1->GetYaxis()->SetTitle(TString::Format("Events / %1.1f GeV",BIN_SIZE));
    frame1->Draw();
    gPad->Update();
    
    TList *list = (TList*)gPad->GetListOfPrimitives();
    //list->Print();
    TH1F *hUncH  = new TH1F("hUncH"+ds_name,"hUncH"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUncL  = new TH1F("hUncL"+ds_name,"hUncL"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUnc2H = new TH1F("hUnc2H"+ds_name,"hUnc2H"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUnc2L = new TH1F("hUnc2L"+ds_name,"hUnc2L"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX); 
    TH1F *hUncC  = new TH1F("hUncC"+ds_name,"hUncC"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX); 
    
    RooCurve *errorBand,*gFit,*gQCDFit,*gBkgFit;
    
	//list->Print();
    if (BLIND) {
      errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
      gFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
    }
    else {
      //errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband");
      errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
      gFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]");
    } 
    gQCDFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+"]");  
    gBkgFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
    for(int i=0;i<hUncH->GetNbinsX();i++) {
      double x0 = hUncH->GetBinCenter(i+1);
      double e1 = fabs(errorBand->Eval(x0)-gBkgFit->Eval(x0));
      //double e1 = fabs(errorBand->Eval(x0)-gFit->Eval(x0));
      double e2 = eNqcd/hUncH->GetNbinsX();
      hUncH->SetBinContent(i+1,sqrt(pow(e2,2)+pow(e1,2)));
      hUnc2H->SetBinContent(i+1,2*sqrt(pow(e2,2)+pow(e1,2)));
      hUncL->SetBinContent(i+1,-sqrt(pow(e2,2)+pow(e1,2)));
      hUnc2L->SetBinContent(i+1,-2*sqrt(pow(e2,2)+pow(e1,2)));
		hUncC->SetBinContent(i+1,0.);
    }
   
    TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
    pad->SetTopMargin(0.63);
    pad->SetFillColor(0);
    pad->SetFillStyle(0);
    pad->Draw();
    pad->cd(0);
    hUnc2H->GetXaxis()->SetTitle("m_{bb} (GeV)");
    hUnc2H->GetYaxis()->SetTitle("Data - Bkg");
    //hUnc2H->GetYaxis()->SetTitle("Data - Fit");
    double YMAX = 1.1*frame2->GetMaximum();
    double YMIN = -1.1*frame2->GetMaximum();
    hUnc2H->GetYaxis()->SetRangeUser(YMIN,YMAX);
    hUnc2H->GetYaxis()->SetNdivisions(507);
//    hUnc2H->GetXaxis()->SetTitleOffset(0.9);
//    hUnc2H->GetYaxis()->SetTitleOffset(1.0);
    hUnc2H->GetYaxis()->SetTickLength(0.0);
//    hUnc2H->GetYaxis()->SetTitleSize(0.05);
//    hUnc2H->GetYaxis()->SetLabelSize(0.04);
    hUnc2H->GetYaxis()->CenterTitle(kTRUE);
    hUnc2H->SetFillColor(kGreen);
    hUnc2L->SetFillColor(kGreen);
    hUncH->SetFillColor(kYellow);
    hUncL->SetFillColor(kYellow);
	 hUncC->SetLineColor(kBlack);
	 hUncC->SetLineStyle(7);
    hUnc2H->Draw("HIST");
    hUnc2L->Draw("same HIST");
    hUncH->Draw("same HIST");
    hUncL->Draw("same HIST");
	 hUncC->Draw("same HIST");
	 frame2->GetYaxis()->SetTickLength(0.03/0.4);
    frame2->Draw("same");

    TList *list1 = (TList*)gPad->GetListOfPrimitives();
    //list1->Print();
    RooCurve *gSigFit = (RooCurve*)list1->FindObject("shapeSig_qqH_"+ds_name+"_Norm[mbbReg_"+ds_name+"]");

    TLegend *leg = new TLegend(0.70,0.61,0.94,1.-gStyle->GetPadTopMargin()-0.01);
	 leg->SetTextFont(42);
	 leg->SetFillStyle(-1);
	 //leg->SetHeader(ds_name+" (m_{H}="+MASS+")");
    leg->SetHeader(TString::Format("Category %d",atoi(ds_name(3,1).Data())+1));
    leg->AddEntry(hBlind,"Data","P");
    if (!BLIND) {
      leg->AddEntry(gSigFit,"Fitted signal","L");
    }
	 TLine *gEmpty = new TLine(0.0,0.0,0.0,0.0);
	 gEmpty->SetLineWidth(0);
	 TLegendEntry *l1 = leg->AddEntry(gEmpty,"(m_{H} = "+MASS+" GeV)","");
	 l1->SetTextSize(0.038*0.97*0.85);
    leg->AddEntry(gFit,"Bkg. + signal","L");
    leg->AddEntry(gBkgFit,"Bkg.","L");
    leg->AddEntry(gQCDFit,"QCD","L");
    leg->AddEntry(hUnc2H,"2#sigma bkg. unc.","F");
    leg->AddEntry(hUncH,"1#sigma bkg. unc.","F");
    leg->SetFillColor(0);
    leg->SetBorderSize(0);
    leg->SetTextFont(42);
    leg->SetTextSize(0.038*0.98);
    leg->Draw(); 
	 leg->SetY1(leg->GetY2()-leg->GetNRows()*0.045*0.96);
     
    TPaveText *paveCMS = new TPaveText(gStyle->GetPadLeftMargin()+0.02,0.7,gStyle->GetPadLeftMargin()+0.15,1.-gStyle->GetPadTopMargin()-0.01,"NDC");
	 paveCMS->SetTextFont(62);
	 paveCMS->SetTextSize(gStyle->GetPadTopMargin()*3./4.);
	 paveCMS->SetBorderSize(0);
	 paveCMS->SetFillStyle(-1);
	 paveCMS->SetTextAlign(12);
	 paveCMS->AddText("CMS");
	 paveCMS->Draw();
	 gPad->Update();
	 paveCMS->SetY1NDC(paveCMS->GetY2NDC()-paveCMS->GetListOfLines()->GetSize()*gStyle->GetPadTopMargin());

	 TPaveText *paveLumi = new TPaveText(0.5,1.-gStyle->GetPadTopMargin(),0.98,1.00,"NDC");
	 paveLumi->SetTextFont(42);
	 paveLumi->SetTextSize(gStyle->GetPadTopMargin()*3./4.);
	 paveLumi->SetBorderSize(0);
	 paveLumi->SetFillStyle(-1);
	 paveLumi->SetTextAlign(32);
	 paveLumi->AddText(TString::Format("%.1f fb^{-1} (8TeV)",(atoi(ds_name(3,1).Data())<4 ? 19.8 : 18.3)).Data());//+ 18.2 ;
	 paveLumi->Draw();

	 TString path=".";
	 //TString path="BiasV10_limit_BRN5p4_dX0p1_B80-200_CAT0-6/output/";
	 system(TString::Format("[ ! -d %s/plot ] && mkdir %s/plot",path.Data(),path.Data()).Data());
	 system(TString::Format("[ ! -d %s/plot/fits ] && mkdir %s/plot/fits",path.Data(),path.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s.pdf",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s.png",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s.eps",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 TText *l = (TText*)paveCMS->AddText("Preliminary");
	 l->SetTextFont(52);
	 paveCMS->Draw();
	 gPad->Update();
	 paveCMS->SetY1NDC(paveCMS->GetY2NDC()-paveCMS->GetListOfLines()->GetSize()*gStyle->GetPadTopMargin());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s_prelim.pdf",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s_prelim.png",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s_prelim.eps",path.Data(),MASS.Data(),ds_name.Data()).Data());

    delete ds;
  }

  cout << "chi2sumS: " << chi2sumS << endl;
  cout << "chi2sumB: " << chi2sumB << endl;
  cout << "nparS: " << nparS << endl;
  cout << "nparB: " << nparB << endl;
  cout << "nbinsum: " << nparsum << endl;
  cout << "chi2sumS/(nbinsum - nparS): " << chi2sumS / (float)(nparsum - nparS) << endl;
  cout << "chi2sumB/(nbinsum - nparB): " << chi2sumB / (float)(nparsum - nparB) << endl;
  delete datasets; 
}
Example #16
0
//TString WHICHHIST1, TString WHICHHIST2, assume 2 is data
void getDataMC(TH1D* h1, TH1D* h2, bool isData2, bool drawRatio) {


  gStyle->SetEndErrorSize(2);
  gStyle->SetErrorX(0.5);

  TCanvas* c = new TCanvas();
  c->cd();
  TPad *p1 = new TPad("p1", "",0.0,0.242,1.0,1.0,0,0,0);
  if (drawRatio) {
    p1->Draw();
    p1->cd();
    p1->SetBottomMargin(0.013);
    //p1->SetLogx();
  }

  double max = h1->GetMaximum() > h2->GetMaximum() ? h1->GetMaximum() : h2->GetMaximum(); 

  h1->SetMaximum(1.2*max);
  h1->GetYaxis()->SetTitleSize(0.065);
  h1->GetYaxis()->SetTitle("Events/bin");
  h1->SetLineColor(kOrange+3);
  h1->SetFillColor(kOrange-2);
  h1->SetMarkerSize(0);
  h1->SetLineWidth(1.2);
  h1->Draw("E2");
  h2->SetMarkerSize(1.3);
  h2->SetMarkerStyle(20);
  h2->Draw("EPsame");
  TLegend* leg = MakeLegend();
  leg->AddEntry(h1,"MC based estimation","f");
  leg->AddEntry(h2,"Data-driven prediction","lp");
  leg->Draw("same");

//Draw ratios
  if (drawRatio) {
    gStyle->SetOptTitle(0);
    gStyle->SetPadGridY(false);

    TH1D* ratio = (TH1D*)h1->Clone();
    ratio->Divide(h2,h1);

    TPad *p2 = new TPad("p2", "",0.0,0.0,1.0,0.24,0,0,0);
    c->cd();
    p2->Draw();
    p2->cd();
    //p2->SetLogx();
    p2->SetTopMargin(0.005);
    p2->SetBottomMargin(0.35);
    //p2->SetTickx();
    ratio->GetYaxis()->SetTitle("e#mu/MC");
    ratio->SetStats(kFALSE);
    double ranger = ratio->GetBinError(1) > ratio->GetBinError(ratio->GetXaxis()->GetNbins()-1) ? ratio->GetBinError(1) : ratio->GetBinError(ratio->GetXaxis()->GetNbins()-1);
    ratio->GetYaxis()->SetRangeUser(0.01,1.2*ranger+fabs(ratio->GetMaximum()));
    ratio->GetYaxis()->SetNdivisions(5);
    ratio->GetYaxis()->SetTitleOffset(0.29);
    ratio->GetXaxis()->SetTitle("|Y_{#mu#mu}|");
    ratio->GetXaxis()->SetMoreLogLabels();
    ratio->GetYaxis()->SetTitleSize(0.23);
    ratio->GetXaxis()->SetTitleSize(0.18);
    //control digit sizes
    ratio->GetYaxis()->SetLabelSize(1.2*0.15);
    ratio->GetXaxis()->SetLabelSize(0.15);
    //ratio->SetTickLength(ratio->GetTickLength()*2.);
    ratio->SetFillStyle(3001);
    ratio->SetLineColor(kBlack);
    ratio->SetFillColor(kBlack);
    ratio->SetMarkerSize(0);
    ratio->SetLineWidth(1.2);
    ratio->Draw("E3");
  }

  c->SaveAs(TString(h1->GetName())+".png");

}
void
makeWChargeAsymmetryHist_afterEfficiency(){

  TCanvas *c1 = new TCanvas("c1","W Charge Asymmetry",400,2.5,700,500);    

//  c1->SetFillColor(42);
//  c1->SetGrid();
 
  
  TH1F *hr = c1->DrawFrame(-0.4,0,1.2,12);
  hr->SetXTitle("pseudo-rapidity");
  hr->SetYTitle("Charge Asymmetry");
//  c1->GetFrame()->SetFillCollor(21);
//  c1->GetFrame()->GetBorderSize(12);

  
  
  


  const Int_t n1=11;
  Float_t y1[n1] ={106.9,112.9,112.5,125.5,130.7,144.3,159.5,186.1,191.8,206.9,203.4};
  Float_t x1[n1] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey1[n1] ={1.5,1.7,1.4,1.7,1.8,1.9,2.3,1.9,1.6,1.9,2.4};
  Float_t ex1[n1] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr1 = new TGraphErrors(n1,x1,y1,ex1,ey1);
  gr1->SetTitle("2011 pt>35GeV");
  //gr1->SetLineColor(7);
  gr1->GetXaxis()->SetTitle("pseudo-rapidity") ;
  gr1->GetYaxis()->SetTitle("Charge Asymmetry") ;
  gr1->SetMinimum(40);
  gr1->SetMaximum(280);
  gr1->SetMarkerColor(7);
  gr1->SetMarkerStyle(21);
  gr1->SetMarkerSize(0.5);
  gr1->Draw("AP");
 
  const Int_t n2=11;
  //Float_t y2[n2] ={95.1,94.6,99.2,108,117,125,135,171,186,204,216};
  Float_t y2[n2] ={95.1,94.6,99.2,108,117,125,135,171,186,204,216};
  Float_t x2[n2] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey2[n2] ={};
  Float_t ex2[n2] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr2 = new TGraphErrors(n2,x2,y2,ex2,ey2);
  gr2->SetTitle("2012 MonteCarlo pt>35GeV");
  gr2->SetMarkerColor(4);
  //gr2->SetMarkerStyle(20);
  gr2->SetMarkerStyle(20);
  gr2->SetMarkerSize(0.5);
  gr2->SetLineColor(4);
  gr2->Draw("P");

/*
  const Int_t n3=11;
  Float_t y3[n3] ={116.4,134.3,126.9,172.7,161.6,158,162.6,212.6,250.7,275.9,264.4};
  Float_t x3[n3] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey3[n3] ={2.0,2.0,2.6,2.8,2.7,3.2,3.5,3.3,3.2,4.8,5.6};
  Float_t ex3[n3] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr3 = new TGraphErrors(n3,x3,y3,ex3,ey3);
  gr3->SetTitle("2012 RD total pt>30GeV");
  gr3->SetMarkerColor(5);
  gr3->SetMarkerStyle(20);
  gr3->Draw("P");
*/
  
  const Int_t n4=11;
  //Float_t y4[n4] ={96.76,106.86,100.98,111.31,126.32,124.62,134.62,168.01,194.28,222.09,219.00};
  Float_t y4[n4] ={95.39,98.04,111.44,114.09,117.42,125.41,133.08,166.72,185.15,199.22,207.79};
  Float_t x4[n4] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  //Float_t ey4[n4] ={0.83,1.63,0.92,0.87,1.47,1.68,1.16,2.67,2.49,2.64,3.44};
  Float_t ey4[n4] ={1.4,1.3,2.77,1.32,1.34,1.37,1.22,1.93,1.57,1.94,2.51};
  Float_t ex4[n4] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr4 = new TGraphErrors(n4,x4,y4,ex4,ey4);
  gr4->SetTitle("2012 RD total pt>35GeV uncorrected");
  gr4->SetMarkerColor(2);
  //gr4->SetMarkerStyle(22);
  gr4->SetMarkerStyle(22);
  gr4->SetMarkerSize(0.5);
  gr4->SetLineColor(2);
  gr4->Draw("P");
			  /*
  const Int_t n5=11;
  Float_t y5[n5] ={99.0,101.9,100.5,112.0,125.2,120.3,132.0,170.5,196.5,224.0,220.0};
  Float_t x5[n5] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey5[n5] ={1.6,1.4,1.6,1.0,1.6,0.9,1.0,2.5,2.7,2.5,3.5};
  Float_t ex5[n5] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr5 = new TGraphErrors(n5,x5,y5,ex5,ey5);
  gr5->SetTitle("2012 RD total pt>35GeV corrected");
  gr5->SetMarkerColor(6);
  gr5->SetMarkerStyle(1);
  gr5->SetLineColor(6);
  gr5->Draw("P");
*/
/*
  const Int_t n6=11;
  Float_t y6[n6] ={121,117,123,131,142,150,151,192,212,223,246};
  Float_t x6[n6] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey6[n6] ={2.0,2.0,2.6,2.8,2.7,3.2,3.5,3.3,3.2,4.8,5.6};
  Float_t ex6[n6] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr6 = new TGraphErrors(n6,x6,y6,ex6,ey6);
  gr6->SetTitle("2012 RD A pt>30GeV");
  gr6->SetMarkerColor(5);
  gr6->SetMarkerStyle(20);
  gr6->Draw("P");
*/
  /*
  const Int_t n66=11;
  Float_t y66[n66] ={105.2,100,101.3,110.3,122.2,133.1,129.4,164.1,184.7,205.9,224.7};
  Float_t x66[n66] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey66[n66] ={2.0,2.0,2.6,2.8,2.7,3.2,3.5,3.3,3.2,4.8,5.6};
  Float_t ex66[n66] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr66 = new TGraphErrors(n66,x66,y66,ex66,ey66);
  gr66->SetTitle("2012 RD A pt>35GeV");
  gr66->SetMarkerColor(4);
  gr66->SetMarkerStyle(22);
  gr66->Draw("P");
*/
/*
  const Int_t n7=11;
  Float_t y7[n7] ={104,120,115,144,149,154,159,196,228,236,224};
  Float_t x7[n7] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey7[n7] ={2.0,2.0,2.6,2.8,2.7,3.2,3.5,3.3,3.2,4.8,5.6};
  Float_t ex7[n7] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr7 = new TGraphErrors(n7,x7,y7,ex7,ey7);
  gr7->SetTitle("2012 RD B pt>30GeV");
  gr7->SetMarkerColor(5);
  gr7->SetMarkerStyle(20);
  gr7->Draw("P");
*/
/*
  const Int_t n77=11;
  Float_t y77[n77] ={97,105.6,93.9,124.4,126.4,126.2,135.5,164.8,201.5,216.2,202.9};
  Float_t x77[n77] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey77[n77] ={2.0,2.0,2.6,2.8,2.7,3.2,3.5,3.3,3.2,4.8,5.6};
  Float_t ex77[n77] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr77 = new TGraphErrors(n77,x77,y77,ex77,ey77);
  gr77->SetTitle("2012 RD B pt>35GeV");
  gr77->SetMarkerColor(4);
  gr77->SetMarkerStyle(22);
  gr77->Draw("P");
*/
/*  
  const Int_t n8=11;
  Float_t y8[n8] ={111,121,122,148,150,150,156,196,229,240,242};
  Float_t x8[n8] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey8[n8] ={2.0,2.0,2.6,2.8,2.7,3.2,3.5,3.3,3.2,4.8,5.6};
  Float_t ex8[n8] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr8 = new TGraphErrors(n8,x8,y8,ex8,ey8);
  gr8->SetTitle("2012 RD C pt>30GeV");
  gr8->SetMarkerColor(5);
  gr8->SetMarkerStyle(20);
  gr8->Draw("P");
*/
/*  
  const Int_t n88=11;
  Float_t y88[n88] ={97.5,105.6,105.2,138.9,129.2,123.9,138.9,166.3,196.9,225.7,222.2};
  Float_t x88[n88] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey88[n88] ={2.0,2.0,2.6,2.8,2.7,3.2,3.5,3.3,3.2,4.8,5.6};
  Float_t ex88[n88] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr88 = new TGraphErrors(n88,x88,y88,ex88,ey88);
  gr88->SetTitle("2012 RD C pt>35GeV");
  gr88->SetMarkerColor(4);
  gr88->SetMarkerStyle(22);
  gr88->Draw("P");
*/
/*
  const Int_t n9=11;
  Float_t y9[n9] ={110,123,177,129,143,140,148,193,228,239,243};
  Float_t x9[n9] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey9[n9] ={2.0,2.0,2.6,2.8,2.7,3.2,3.5,3.3,3.2,4.8,5.6};
  Float_t ex9[n9] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr9 = new TGraphErrors(n9,x9,y9,ex9,ey9);
  gr9->SetTitle("2012 RD D pt>30GeV");
  gr9->SetMarkerColor(5);
  gr9->SetMarkerStyle(20);
  gr9->Draw("P");
*/
/*
  const Int_t n99=11;
  Float_t y99[n99] ={42.1,107,158,109.5,124.5,122.2,130.7,165.4,196.5,217.5,223};
  Float_t x99[n99] ={0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.7,1.9,2.1,2.3};
  Float_t ey99[n99] ={2.0,2.0,2.6,2.8,2.7,3.2,3.5,3.3,3.2,4.8,5.6};
  Float_t ex99[n99] ={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
  TGraphErrors *gr99 = new TGraphErrors(n99,x99,y99,ex99,ey99);
  gr99->SetTitle("2012 RD D pt>35GeV");
  gr99->SetMarkerColor(4);
  gr99->SetMarkerStyle(22);
  gr99->Draw("P");
*/





    TLegend * lg = new TLegend(0.15, 0.71, 0.52, 0.89);
    lg->SetTextSize(0.05);
    lg->SetBorderSize(0);
    lg->SetFillColor(0);
	    
    lg->AddEntry(gr1, "2011(7TeV), 0.84/fb", "lep");
    lg->AddEntry(gr2, "2012 MC(8TeV)", "lep");
//    lg->AddEntry(gr3, "2012 RD total pt>30GeV", "lep");
    lg->AddEntry(gr4, "2012 RD(8TeV) uncorrected, 19.619/fb", "lep");
//    lg->AddEntry(gr5, "2012 RD corrected", "lep");
//    lg->AddEntry(gr6, "2012 RD A  pt>30GeV", "lep");
//    lg->AddEntry(gr66, "2012 RD A", "lep");
//    lg->AddEntry(gr7, "2012 RD B  pt>30GeV", "lep");
//    lg->AddEntry(gr77, "2012 RD B", "lep");
//    lg->AddEntry(gr8, "2012 RD C  pt>30GeV", "lep");
//    lg->AddEntry(gr88, "2012 RD C", "lep");
//    lg->AddEntry(gr9, "2012 RD D  pt>30GeV", "lep");
//    lg->AddEntry(gr99, "2012 RD D", "lep");
    lg->Draw();
		  



 // c1->Update();

  c1->SaveAs("ChargeAsymmetry.png");
 
}
Example #18
0
//void VHPlotter(string title="", int plot=0) {
void VHPlotter(string title="", int plot=0,   TCanvas* c1=0 ) {


string subdir="0";
string postfix="";
string dirbSel="";

double norm11 = ((Lumi2016_ele * Xsec_dy_amc1) / Ngen_dy_amc1);
double norm12 = ((Lumi2016_ele * Xsec_dy_amc2) / Ngen_dy_amc2);
double norm13 = ((Lumi2016_ele * Xsec_dy_amc3) / Ngen_dy_amc3);
double norm14 = ((Lumi2016_ele * Xsec_dy_amc4) / Ngen_dy_amc4);

double norm2 = ((Lumi2016_ele * Xsec_tt) / Ngen_tt);
double norm3 = ((Lumi2016_ele * Xsec_zz) / Ngen_zz);
double norm4 = ((Lumi2016_ele * Xsec_wz) / Ngen_wz);
double norm6 = ((Lumi2016_ele * Xsec_ww) / Ngen_ww);
double norm7 = ((Lumi2016_ele * Xsec_zhm) / Ngen_zhm);
double norm8 = ((Lumi2016_ele * Xsec_zhp) / Ngen_zhp);

//if (ilepton==1) Lumi2016 = Lumi2016_ele;

/*double enorm1 = ((Lumi2012 * eXsec_dy) / Ngen_dy);
double enorm1_amc = ((Lumi2012 * eXsec_dy_amc) / Ngen_dy_amc);
double enorm1_1 = ((Lumi2012 * eXsec_dy_1) / Ngen_dy_1);
double enorm1_2=0;
double enorm2 = ((Lumi2012 * eXsec_tt) / Ngen_tt);
double enorm4 = ((Lumi2012 * eXsec_wz) / Ngen_wz);
double enorm5 = ((Lumi2012 * eXsec_qcd) / Ngen_qcd);
double enorm6 = ((Lumi2012 * eXsec_ww) / Ngen_ww);
double enorm7 = ((Lumi2012 * eXsec_wj) / Ngen_wj);
double enorm8 = ((Lumi2012 * eXsec_tS) / Ngen_tS);
double enorm9 = ((Lumi2012 * eXsec_tT) / Ngen_tT);
double enorm10 = ((Lumi2012 * eXsec_tW) / Ngen_tW);
double enorm11 = ((Lumi2012 * eXsec_tSb) / Ngen_tSb);
double enorm12 = ((Lumi2012 * eXsec_tTb) / Ngen_tTb);
double enorm13 = ((Lumi2012 * eXsec_tWb) / Ngen_tWb);
*/

TFile* mc11 = TFile::Open((path + "DYJetsToLL_M-50_HT-100to200_13TeV.root").c_str());
TH1F* h_mc11 = (TH1F*)gDirectory->Get(title.c_str());
TFile* mc12 = TFile::Open((path + "DYJetsToLL_M-50_HT-200to400_13TeV.root").c_str());
TH1F* h_mc12 = (TH1F*)gDirectory->Get(title.c_str());
TFile* mc13 = TFile::Open((path + "DYJetsToLL_M-50_HT-400to600_13TeV.root").c_str());
TH1F* h_mc13 = (TH1F*)gDirectory->Get(title.c_str());
TFile* mc14 = TFile::Open((path + "DYJetsToLL_M-50_HT-600toInf_13TeV.root").c_str());
TH1F* h_mc14 = (TH1F*)gDirectory->Get(title.c_str());
TFile* mc2 = TFile::Open((path + "TT_TuneCUETP8M1_13TeV.root").c_str());
TH1F* h_mc2 = (TH1F*)gDirectory->Get(title.c_str());
TFile* mc3 = TFile::Open((path + "ZZ_TuneCUETP8M1_13TeV.root").c_str());
TH1F* h_mc3 = (TH1F*)gDirectory->Get(title.c_str());
TFile* mc4 = TFile::Open((path + "WZ_TuneCUETP8M1_13TeV.root").c_str());
TH1F* h_mc4 = (TH1F*)gDirectory->Get(title.c_str());
TFile* mc6 = TFile::Open((path + "WW_TuneCUETP8M1_13TeV.root").c_str());
TH1F* h_mc6 = (TH1F*)gDirectory->Get(title.c_str());
TFile* mc7 = TFile::Open((path + "ZH_HToBB_ZToLL_M125_13TeV_amcatnlo.root").c_str());
TH1F* h_mc7 = (TH1F*)gDirectory->Get(title.c_str());
TFile* mc8 = TFile::Open((path + "ZH_HToBB_ZToLL_M125_13TeV_powheg.root").c_str());
TH1F* h_mc8 = (TH1F*)gDirectory->Get(title.c_str());

//TFile* data = TFile::Open((path + "SingleMuon-Run2016B-v2.root").c_str());
//TH1F* h_data = (TH1F*)gDirectory->Get(title.c_str());

TFile* data_runB = TFile::Open((path + "SingleMuon-Run2016B-v2.root").c_str());
TH1F* h_data_runB = (TH1F*)gDirectory->Get(title.c_str());

TFile* data_runC = TFile::Open((path + "SingleMuon-Run2016C-v2.root").c_str());
TH1F* h_data_runC = (TH1F*)gDirectory->Get(title.c_str());

TFile* data_runD = TFile::Open((path + "SingleMuon-Run2016D-v2.root").c_str());
TH1F* h_data_runD = (TH1F*)gDirectory->Get(title.c_str());

TH1F* h_data = (TH1F*)h_data_runB ->Clone("h_data");
h_data->Reset();
h_data->Add( h_data_runB );
h_data->Add( h_data_runC );
h_data->Add( h_data_runD );


h_mc2 -> SetLineColor(kBlack);
h_mc2 -> SetFillColor(kBlue);
//h_mc2 -> SetFillStyle(3004);

h_mc3 -> SetLineColor(kBlack);
h_mc3 -> SetFillColor(kGray+2);
//h_mc3 -> SetFillStyle(3004);

//h_mc4 -> SetLineColor(kBlack);
//h_mc4 -> SetFillColor(kGray+3);
//h_mc4 -> SetFillStyle(3004);

//h_mc6 -> SetLineColor(kBlack);
//h_mc6 -> SetFillColor(kRed+2);
//h_mc6 -> SetFillStyle(3004);

h_mc7 -> SetLineColor(kBlack);
h_mc7 -> SetFillColor(kMagenta);
//h_mc7 -> SetFillStyle(3004);

h_mc8 -> SetLineColor(kGreen);
//h_mc8 -> SetLineColor(kBlack);
//h_mc8 -> SetFillColor(kPink);
//h_mc8 -> SetFillStyle(3004);
h_mc8 ->SetLineWidth(3);

h_mc11->Scale(norm11);
h_mc12->Scale(norm12);
h_mc13->Scale(norm13);
h_mc14->Scale(norm14);
h_mc2->Scale(norm2);
h_mc3->Scale(norm3);
h_mc4->Scale(norm4);
h_mc6->Scale(norm6);
h_mc7->Scale(norm7);
h_mc8->Scale(norm8);

TH1F* h_mcDY = (TH1F*)h_mc11->Clone("h_mcDY");
h_mcDY->Reset();
h_mcDY->Add(h_mc14);
h_mcDY->Add(h_mc13);
h_mcDY->Add(h_mc12);
h_mcDY->Add(h_mc11);

h_mcDY -> SetLineColor(kBlack);
h_mcDY -> SetFillColor(kYellow-4);
//h_mcDY -> SetFillStyle(3004);

TH1F* h_mcDiboson = (TH1F*)h_mc3->Clone("h_mcDiboson");
h_mcDiboson->Reset();
h_mcDiboson->Add(h_mc3);
h_mcDiboson->Add(h_mc4);
h_mcDiboson->Add(h_mc6);

TH1F *ht = (TH1F*)h_mcDY->Clone("ht");
ht->Reset();
//ht->Add(h_mc8);
ht->Add(h_mc7);
//ht->Add(h_mc6);
//ht->Add(h_mc4);
//ht->Add(h_mc3);
ht->Add(h_mcDiboson);
ht->Add(h_mc2);
ht->Add(h_mcDY);

THStack *hs = new THStack("hs","");
//hs->Add(h_mc8); // ZH powheg
hs->Add(h_mc7);   // ZH madgraph
//hs->Add(h_mc6);
//hs->Add(h_mc4);
//hs->Add(h_mc3);
hs->Add(h_mcDiboson);
hs->Add(h_mc2);
hs->Add(h_mcDY);

//TCanvas* c1 = 0;
//c1 = new TCanvas("c","c",10,10,800,600);
c1->cd();

TPad *pad1 = new TPad("pad1","pad1",0.0,0.3,1.0,1.0);
pad1->SetBottomMargin(0.001);
pad1->Draw();
pad1->cd();

if( title=="FATjetSDmass" || title=="FATjetSDmassCorr" || title=="FATjetPRmass" || title=="FATjetPRmassCorr" || title=="FATnSubjet" || title=="ZHmass" )
{pad1->SetLogy();}

hs->Draw("HIST");
hs->GetYaxis()->SetTitle("Events");
hs->GetYaxis()->SetTitleSize(0.05);
hs->GetYaxis()->SetLabelSize(0.045);
hs->GetYaxis()->SetTitleOffset(1.0);// 0.7
//hs->SetMinimum(8);
hs->SetMinimum(0.1);
hs->SetMaximum(1.2*hs->GetMaximum());
if (title=="ZHmass") { hs->GetXaxis()->SetRangeUser(0, 3000); }

h_mc8->Draw("same hist");


h_data->Draw("EPX0SAMES");
h_data->SetMarkerColor(kBlack);
h_data->SetMarkerStyle(20);
h_data->SetMarkerSize (1.0);
h_data->SetStats(0);

TLegend *leg;

if (title=="FATjetTau2dvTau1") { leg = new TLegend(0.15, 0.547, 0.41, 0.88); }
else { leg = new TLegend(0.65, 0.547, 0.91, 0.88);}
//leg = new TLegend(0.65, 0.547, 0.91, 0.88);
leg->SetBorderSize(0);
leg->SetEntrySeparation(0.01);
leg->SetFillColor(0);
leg->SetFillStyle(0);

leg->AddEntry(h_data,"Data","p");
leg->AddEntry(h_mcDY,"DY","f");
leg->AddEntry(h_mc2,"t#bar{t}","f");
//leg->AddEntry(h_mc3,"ZZ","f");
//leg->AddEntry(h_mc4,"WZ","f");
//leg->AddEntry(h_mc6,"WW","f");
leg->AddEntry(h_mcDiboson,"Diboson","f");
leg->AddEntry(h_mc7,"ZH madgraph","f");
leg->AddEntry(h_mc8,"ZH powheg (not in stack)","f");

leg->Draw();

TLatex *lar = new TLatex();
lar->SetNDC(kTRUE);
lar->SetTextSize(0.04);
lar->SetLineWidth(5);
lar->DrawLatex(0.14, 0.94, "CMS #it{#bf{2016}}");
lar->DrawLatex(0.60, 0.94, "L = 12.8 fb^{-1} at #sqrt{s} = 13 TeV");

pad1->Update();
c1->Update();

c1->cd();

TH1F *h_ratio = (TH1F*)h_data->Clone("h_ratio");

TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);// 0.3
pad2->SetTopMargin(0);
pad2->SetBottomMargin(0.3);
pad2->Draw();
pad2->cd();
h_ratio->SetTitle("");
h_ratio->SetStats(0);

if (title=="Zpt") {
  h_ratio->GetXaxis ()->SetTitle("p_{T}(Z) [GeV/c]");
} else if (title=="Zmass") {
  h_ratio->GetXaxis ()->SetTitle("M(Z) [GeV/c^{2}]");// 
} else if (title=="ZRapidity") {
  h_ratio->GetXaxis ()->SetTitle("y(Z)");
} else if (title=="Zeta") {
  h_ratio->GetXaxis ()->SetTitle("#eta(Z)");
} else if (title=="nVtx") {
  h_ratio->GetXaxis ()->SetTitle("Number of Vertices");
}


  else if (title=="leadElePt") {
  h_ratio->GetXaxis ()->SetTitle("Leading Electron p_{T} [GeV/c]");
} else if (title=="subleadElePt") {
  h_ratio->GetXaxis ()->SetTitle("Sub-Leading Electron p_{T} [GeV/c]");
} else if (title=="leadEleEta") {
  h_ratio->GetXaxis ()->SetTitle("Leading Electron #eta");
} else if (title=="subleadEleEta") {
  h_ratio->GetXaxis ()->SetTitle("Sub-Leading Electron #eta");
}

  else if (title=="leadMuPt") {
  h_ratio->GetXaxis ()->SetTitle("Leading Muon p_{T} [GeV/c]");
} else if (title=="subleadMuPt") {
  h_ratio->GetXaxis ()->SetTitle("Sub-Leading Muon p_{T} [GeV/c]");
} else if (title=="leadMuEta") {
  h_ratio->GetXaxis ()->SetTitle("Leading Muon #eta");
} else if (title=="subleadMuEta") {
  h_ratio->GetXaxis ()->SetTitle("Sub-Leading Muon #eta");
}


  else if (title=="FATjetPt") {
  h_ratio->GetXaxis ()->SetTitle("FAT Jet p_{T} [GeV/c]");
} else if (title=="FATjetEta") {
  h_ratio->GetXaxis ()->SetTitle("FAT Jet #eta");
} else if (title=="FATjetCISVV2") {
  h_ratio->GetXaxis ()->SetTitle("FAT Jet CSVv2");
} else if (title=="FATjetSDmass") {
  h_ratio->GetXaxis ()->SetTitle("FAT Jet Soft Drop Mass [GeV/c^{2}]");
} else if (title=="FATjetSDmassCorr") {
  h_ratio->GetXaxis ()->SetTitle("FAT Jet Corrected Soft Drop Mass [GeV/c^{2}]");
}  else if (title=="FATjetPRmass") {
  h_ratio->GetXaxis ()->SetTitle("FAT Jet Pruned Mass [GeV/c^{2}]");
} else if (title=="FATjetPRmassCorr") {
  h_ratio->GetXaxis ()->SetTitle("FAT Jet L2L3 Corrected Pruned Mass [GeV/c^{2}]");
} else if (title=="FATjetTau1") {
  h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{1}");
} else if (title=="FATjetTau2") {
  h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{2}");
} else if (title=="FATjetTau2dvTau1") {
  h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{21}");
} else if (title=="FATnSubjet") {
  h_ratio->GetXaxis ()->SetTitle("Number of Subjets");
} else if (title=="FATsubjetLeadingPt") {
  h_ratio->GetXaxis ()->SetTitle("Leading SubJet p_{T} [GeV/c]");
} else if (title=="FATsubjetLeadingEta") {
  h_ratio->GetXaxis ()->SetTitle("Leading SubJet #eta");
} else if (title=="FATsubjetLeadingSDCSV") {
  h_ratio->GetXaxis ()->SetTitle("Leading SubJet Soft Drop CSV");
} else if (title=="FATsubjetSubLeadingPt") {
  h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet p_{T} [GeV/c]");
} else if (title=="FATsubjetSubLeadingEta") {
  h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet #eta");
} else if (title=="FATsubjetSubLeadingSDCSV") {
  h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet Soft Drop CSV");
} else if (title=="ADDjet_DoubleSV") {
  h_ratio->GetXaxis ()->SetTitle("ADDjet double b-tagger discriminator");
} else if (title=="ZHmass") {
  h_ratio->GetXaxis ()->SetTitle("ZH invariant mass [GeV/c^{2}]");
}

if (title=="ZHmass") { h_ratio->GetXaxis()->SetRangeUser(0, 3000); }
h_ratio->GetXaxis()->SetTitleSize(0.11);
h_ratio->GetXaxis()->SetLabelFont(42);
h_ratio->GetXaxis()->SetLabelSize(0.10);
h_ratio->GetXaxis()->SetTitleFont(42);
h_ratio->GetYaxis()->SetTitle("Data/MC");
h_ratio->GetYaxis()->SetNdivisions(505);
h_ratio->GetYaxis()->SetTitleSize(0.11);
h_ratio->GetYaxis()->SetLabelSize(0.10);
h_ratio->GetYaxis()->SetRangeUser(0.2, 2);
h_ratio->GetYaxis()->SetTitleOffset(0.33);

h_ratio->Divide(ht);
h_ratio->SetMarkerStyle(20);
h_ratio->Draw("E0PX0");

TLine *OLine = new TLine(h_ratio->GetXaxis()->GetXmin(),1.,h_ratio->GetXaxis()->GetXmax(),1.);
OLine->SetLineColor(kRed);
OLine->SetLineWidth(2);
OLine->Draw();

/*
TLatex *lar = new TLatex();
lar->SetNDC(kTRUE);
lar->SetTextSize(0.04);
lar->SetLineWidth(5);
lar->DrawLatex(0.14, 0.94, "CMS #it{#bf{2016}}");
lar->DrawLatex(0.60, 0.94, "L = 4.327 fb^{-1} at #sqrt{s} = 13 TeV");
*/

c1->cd();
//c1->SaveAs((path + title + ".pdf").c_str());

}
Example #19
0
//___________________________________________________________________________
Double_t* IfitBin(TH1F* dataInput, TH1F* sigTemplate, TH1F* bkgTemplate, 
	       int fit_data=1)
{

  cout << "Input files are " << dataInput->GetName() << "\t" << sigTemplate->GetName() << "\t" << bkgTemplate->GetName() << endl;

  TCanvas *c1 = new TCanvas("HF1", "Histos1", 0, 0, 600, 600);
  dataCollBin.clear();
  sigCollBin.clear();
  bkgCollBin.clear();

  Double_t* fitted = new Double_t[8];
  fitted[0] = fitted[1] = fitted[2] = fitted[3] = fitted[4] = fitted[5] = fitted[6] = fitted[7] = 0.0;

  TH1F *hsum = new TH1F();
  float ntemplate = 1.;
  float sigfrac = 0.1;
  TH1F *hsum_norm = new TH1F();
  TH1F *hdata;
  TH1F *hsig  = (TH1F*)sigTemplate->Clone();
  hsig->SetName("hsig");
  hsig->Rebin(6);

  TH1F *hbkg  = (TH1F*)bkgTemplate->Clone();
  hbkg->SetName("hbkg");
  hbkg->Rebin(6);

  float ndata=0;
  if ( fit_data>0 ) {
    hdata = (TH1F*)dataInput->Clone();
    hdata -> SetName("hdata");
    ndata = hdata->Integral();
  }else {
    hsum = (TH1F*)hsig->Clone();
    hsum->Add(hbkg,1);
    cout << "For histogram " << sigTemplate->GetName() << " and " << bkgTemplate->GetName() << " sum = " << 
      hsum->Integral() << endl;

    if (hsum->Integral()>1.) ntemplate = hsum->Integral();
    sigfrac = hsig->Integral()/ntemplate;

    hsum_norm = (TH1F*)hsum->Clone();  
    hsum_norm->Scale(1./hsum->Integral());

    hdata = (TH1F*)hsum_norm->Clone();
    hdata -> SetName("hdata");
    ndata=ntemplate;
    hdata->FillRandom(hsum_norm, ndata);
  }
  if(ndata==0) {
    printf(" ---  no events in the fit \n");
    return fitted;
  }
    
  printf(" --------- before the fit ------------- \n");
  printf("Nsig %2.3f, Nbg %2.3f, Ntemplate %3.3f \n", hsig->Integral(), hbkg->Integral(), ntemplate);
//   printf("Purity %2.3f, init size %4.3f,  test sample size %4d\n", hsig->Integral()/hsum->Integral(), hsum->Integral(), ndata);
  printf(" -------------------------------------- \n");

  hdata->Rebin(6);
  int nbins = hdata->GetNbinsX();

  hsig->Scale(1./hsig->Integral());
  hbkg->Scale(1./hbkg->Integral());  

  for (int ibin=1; ibin<=nbins; ibin++) {
    dataCollBin.push_back(hdata->GetBinContent(ibin));
    sigCollBin.push_back(hsig->GetBinContent(ibin));
    bkgCollBin.push_back(hbkg->GetBinContent(ibin));    
  }
  printf( " -----  Got %d, %d, %d events for fit ----- \n ", dataCollBin.size(),
	  sigCollBin.size(), bkgCollBin.size() );  
  if ( dataCollBin.size() != sigCollBin.size() || sigCollBin.size()!=bkgCollBin.size() ) {
    printf(" error ...  inconsistent hit collection size \n");
    return fitted;
  }

  //--------------------------------------------------
  //init parameters for fit
  Double_t vstart[10] = {1., 1.};
  vstart[0] = sigfrac*ndata;
  vstart[1] = (1-sigfrac)*ndata;
 
  TMinuit *gMinuit = new TMinuit(NPARBIN);  
  gMinuit->Command("SET STR 1");
  gMinuit->SetFCN(fcnBin);
  Double_t arglist[10];
  Int_t ierflg = 0;
  
  arglist[0] = 1;
  gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);
  arglist[0] = 1;
  gMinuit->mnexcm("SET PRINT", arglist ,1,ierflg);

  Double_t step[] = { 0.1, 0.1,};

  gMinuit->mnparm(0,  "Signal yield"  , vstart[0],  step[0], 0., ndata*2.  , ierflg);
  gMinuit->mnparm(1,  "background yield"  , vstart[1],  step[1], 0., ndata*2. , ierflg);
  
  printf(" --------------------------------------------------------- \n");
  printf(" Now ready for minimization step \n --------------------------------------------------------- \n");
  
  arglist[0] = 2000; // number of iteration
  arglist[1] = 1.;
  gMinuit->mnexcm("MIGRAD", arglist ,2,ierflg);
  printf (" -------------------------------------------- \n");
  printf("Finished.  ierr = %d \n", ierflg);

  infoBin.clear();
  infoBin_err.clear();

  double para[NPARBIN+1],errpara[NPARBIN+1];
  if ( ierflg == 0 ) 
    {
      for(int j=0; j<=NPARBIN-1;j++) {
        gMinuit->GetParameter(j, para[j],errpara[j]);
        para[NPARBIN] = dataCollBin.size();
        infoBin.push_back(para[j]);
        infoBin_err.push_back(errpara[j]);
        printf("Parameter (yeild) %d = %f +- %f\n",j,para[j],errpara[j]);
	
      }
      printf(" fitted yield %2.3f \n", (para[0]+para[1])/ndata );
      infoBin.push_back(sigCollBin.size());

    }
  else {
    printf(" *********** Fit failed! ************\n");
    gMinuit->GetParameter(0, para[0],errpara[0]);
    gMinuit->GetParameter(1, para[1],errpara[1]);
    para[0]=0.; errpara[0]=0.;
  }

  
  // Print results
  Double_t amin,edm,errdef;
  Int_t nvpar,nparx,icstat;
  gMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
  gMinuit->mnprin(1,amin);  
  gMinuit->mnmatu(1);
  printf(" ========= happy ending !? =========================== \n");
  
  printf("FCN =  %3.3f \n", amin);

  double yerr[20];
  for(int i=0;i<20;i++){
    yerr[i] = 0.;
  }

  hsig->Scale(para[0]);
  hbkg->Scale(para[1]);
  TH1F *hfit = (TH1F*)hsig->Clone();
  hfit->Add(hbkg);


  hsig->SetLineColor(1);
  hsig->SetFillColor(5);
  hsig->SetFillStyle(3001);

  hbkg->SetLineWidth(2);
  // plot
  c1->Draw();  
  //gPad->SetLogy();
  hdata->SetLineColor(1);
  hdata->SetNdivisions(505,"XY");
  hdata->SetXTitle("Iso_{ECAL}+Iso_{HCAL}+Iso_{TRK} (GeV)");
  hdata->SetYTitle("Entries");
  hdata->SetTitle("");
  hdata->SetMarkerStyle(8);
  hdata->SetMinimum(0.);
  hdata->SetMaximum(hdata->GetMaximum()*1.5);
  hdata->Draw("p e");
  hsig->Draw("hist same");
  hbkg->SetMarkerStyle(0);
  hbkg->SetFillColor(8);
  hbkg->SetLineWidth(1);
  hbkg->SetFillStyle(3013);
  hbkg->SetError(yerr);
  hbkg->Draw("hist same");
  hfit->SetMarkerStyle(0);
  hfit->SetLineColor(1);
  hfit->SetLineWidth(2);
  hfit->SetError(yerr);
  hfit->Draw("hist same");

  double chi2ForThisBin=0;
  int nbinForThisBin=0;
  chi2NbinsHisto(hfit, hdata, chi2ForThisBin, nbinForThisBin);
  TPaveText *pavetex = new TPaveText(0.43, 0.87, 0.90, 0.92,"NDCBR");
  pavetex->SetBorderSize(0);
  pavetex->SetFillColor(0);
  pavetex->SetFillStyle(0);
  pavetex->SetLineWidth(3);
  pavetex->SetTextAlign(12);
  pavetex->SetTextSize(0.03);
  pavetex->AddText(Form("#chi^{2}/NDF=%.1f/%d",chi2ForThisBin, nbinForThisBin));
  pavetex->Draw();


  char text[1000];
  TLegend *tleg = new TLegend(0.43, 0.60, 0.90, 0.87);
  tleg->SetHeader(dataInput->GetTitle());

  tleg->SetTextSize(0.03);
  tleg->SetFillColor(0);
  tleg->SetShadowColor(0);
  tleg->SetBorderSize(0);
  sprintf(text,"Data %5.1f events",hdata->Integral());
  tleg->AddEntry(hdata,text,"pl");
  sprintf(text,"Fitted %5.1f events",hfit->Integral());
  tleg->AddEntry(hfit,text,"l");
  sprintf(text,"SIG %5.1f #pm %5.1f events",para[0], errpara[0]);
  tleg->AddEntry(hsig,text,"f");
  sprintf(text,"BKG %5.1f #pm %5.1f events",para[1], errpara[1]);
  tleg->AddEntry(hbkg,text,"f");
  tleg->Draw();

  gPad->RedrawAxis();


  cout << dataInput->GetName() << endl;
  char fname[300];
  sprintf(fname,"plots/Ifit_%s.eps",dataInput->GetName());
  c1->SaveAs(fname);
  sprintf(fname,"plots/Ifit_%s.gif",dataInput->GetName());
  c1->SaveAs(fname);

  printf("----- fit results with signal projection   ----------- \n");

  //   ftemplate->Close();
  
  int purityMaxBin = hsig->FindBin(5.0)-1;
  Double_t scale_signal = hsig->Integral(1,purityMaxBin)/hsig->Integral();
  Double_t scale_background = hbkg->Integral(1,purityMaxBin)/hbkg->Integral();
  
  fitted[0] = para[0];
  fitted[1] = errpara[0];
  fitted[2] = para[1];
  fitted[3] = errpara[1];

  // for integral up to 5 GeV
  fitted[4] = para[0]*scale_signal;
  fitted[5] = errpara[0]*scale_signal;
  fitted[6] = para[1]*scale_background;
  fitted[7] = errpara[1]*scale_background;

  return fitted;
}
void SamMacroMod(){
  TCanvas *c1 = new TCanvas("c1", "c1",1000,700);
  TPad* spectrumPad=0;
  TPad* ratioPad=0;
  //c1->Divide(1,2);
  //gStyle->SetOptStat(111111);
  gStyle->SetOptFit(kFALSE);
  gStyle->SetOptStat(kFALSE);
  gStyle->SetStatX(0.457589);
  gStyle->SetStatY(0.312937);
  gStyle->SetStatW(0.29241/2+0.0185);
  gStyle->SetStatH(0.169580+0.05);
  gStyle->SetStatFontSize(0.0402098);
  gStyle->SetStatFont(0.02);
  gStyle->SetFitFormat("5.2g");
  gStyle->SetStatBorderSize(0);
  gStyle->SetStatFontSize(0.040209);
  gStyle->SetStatFontSize(0.035209);
  c1->Range(1.592761,-5.173913,3.533814,6.006211);
  c1->SetFillColor(0);
  c1->SetBorderMode(0);
  c1->SetBorderSize(2);
  c1->SetLogx(1);
  c1->SetLogy(1);
  c1->SetTickx(1);
  c1->SetTicky(1);
  c1->SetLeftMargin(0.13);
  c1->SetRightMargin(0.07);
  c1->SetFrameBorderMode(0);
  c1->SetFrameBorderMode(0);
  c1->SetTopMargin(0.085);
  c1->SetBottomMargin(0.11);
  // Upper plot will be in pad1
  TPad *pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0);
  pad1->SetBottomMargin(0.002); // Upper and lower plot are joined
  pad1->SetTickx(1);
  pad1->SetTicky(1);
  pad1->SetLogx(1);
  pad1->SetLogy(1);
  pad1->SetGridx(0);
  pad1->SetGridy(0);
  pad1->Draw();             // Draw the upper pad: pad1
  pad1->cd();               // pad1 becomes the current pad
  //========================================================== 
  //                                                              
  //               Get the histograms                                  
  //==========================================================
  TFile *file1 = new TFile("plots/h_ZprimeRecomass_DY_OF.root","READ");
  TH1* zeeHist = (TH1*) file1->Get("ZprimeRecomassBinWidthwtOverFlow");

  TFile *file2 = new TFile("plots/h_ZprimeRecomass_Tlike_OF.root","READ");
  TH1* ttbarHist = (TH1*) file2->Get("ZprimeRecomassBinWidthwtOverFlow");

  TFile *file3 = new TFile("plots/h_ZprimeRecomass_DiBoson_OF.root","READ");
  TH1* dibosonsBkgHist = (TH1*) file3->Get("ZprimeRecomassBinWidthwtOverFlow");

  TFile *file4 = new TFile("plots/h_ZprimeRecomass_data_OF.root","READ");
  TH1* dataHistTempbar = (TH1*) file4->Get("ZprimeRecomassBinWidthwtOverFlow");

  //TFile *file3 = new TFile("Wjets-25nsMC-OS-allbins-2673pb.root","READ");
  TFile *file5 = new TFile("plots/FR-Wjets-25nsMC-OS-BinWidth-2673pb_OF.root","READ");
  TH1* WjetsBkgHist = (TH1*) file5->Get("WjetsHistowtOverFlow");
  std::cout<<"nb.Wjets(MC)  = "<<WjetsBkgHist->Integral()<<endl;

  //TFile *file4 = new TFile("DiJets-Data-OS-2673pb-FR.root","READ");
  TFile *file6 = new TFile("plots/FR-DiJets-Data-OS-BinWidth-2673pb_OF.root","READ");
  TH1* jetBkgHist   = (TH1*) file6->Get("DataSubwtOverFlow");
  std::cout<<"nbQCD(dijets,Data)  = "<<jetBkgHist->Integral()<<endl;

  /*
  zeeHist->Rebin(20);
  ttbarHist->Rebin(20);
  dibosonsBkgHist->Rebin(20);
  dataHistTempbar->Rebin(20);
  WjetsBkgHist->Rebin(20);
  jetBkgHist->Rebin(20);
  */

  float binWidthNorm=-1;
  int zeeColour    =  TColor::GetColor("#99ccff");
  int jetBkgColour = TColor::GetColor("#ffff66"); 
  int ttbarColour  = TColor::GetColor("#ff6666");
  int bosonColour  = TColor::GetColorDark(3);
  int WjetsColour  = TColor::GetColorDark(5);
  int font = 42;
  //float xAxisMin = 60; //72
  //float xAxisMax = 1000.0;
  //float yAxisMin = 1e-4;
  //float yAxisMax = 1e3; 
  
  TGraphAsymmErrors* dataHist = makeDataGraph(dataHistTempbar,binWidthNorm,0);
  normHistToBinWidth(zeeHist,binWidthNorm);
  normHistToBinWidth(ttbarHist,binWidthNorm);
  normHistToBinWidth(dibosonsBkgHist,binWidthNorm);
  normHistToBinWidth(jetBkgHist,binWidthNorm);
  normHistToBinWidth(WjetsBkgHist,binWidthNorm);
  
  

  //gStyle->SetOptStat(111111);
  //PaintOverflow(zeeHist);
  //PaintOverflow(ttbarHist);
  //PaintOverflow(dibosonsBkgHist);
  //PaintOverflow(dataHistTempbar);
  //PaintOverflow(jetBkgHist);
  //PaintOverflow(WjetsBkgHist);
  

  THStack *axisHist = new THStack("axisHist","");

  zeeHist->SetFillColor(zeeColour);
  zeeHist->SetLineWidth(2);
  zeeHist->SetLineColor(1);
  zeeHist->SetTitle("");
  
  
  ttbarHist->SetFillColor(ttbarColour);
  ttbarHist->SetLineWidth(2); 
  ttbarHist->SetLineColor(1);
  
  dibosonsBkgHist->SetFillColor(bosonColour);
  dibosonsBkgHist->SetLineWidth(2); 
  dibosonsBkgHist->SetLineColor(1);
  
  WjetsBkgHist->SetFillColor(WjetsColour);
  //WjetsBkgHist->SetFillColor(jetBkgColour);
  WjetsBkgHist->SetLineWidth(2);
  WjetsBkgHist->SetLineColor(1);

  jetBkgHist->SetFillColor(jetBkgColour);
  jetBkgHist->SetLineWidth(2);
  jetBkgHist->SetLineColor(1);

  
  axisHist->Add(jetBkgHist,"histo");
  axisHist->Add(WjetsBkgHist,"histo");
  axisHist->Add(ttbarHist);
  axisHist->Add(dibosonsBkgHist);
  axisHist->Add(zeeHist);
  axisHist->Draw("histo");
  

  //axisHist->GetXaxis()->SetTitle("M(#mu^{+}#mu^{-}) [GeV]");
  //axisHist->GetYaxis()->SetTitle("Events / 20 GeV");
  axisHist->GetYaxis()->SetTitle("Events/GeV");
  //axisHist->GetXaxis()->SetTitleOffset(1.1);
  //axisHist->GetYaxis()->SetTitleOffset(1.1);
  axisHist->GetXaxis()->SetTitleSize(0.047);
  axisHist->GetYaxis()->SetTitleSize(0.047);
  //axisHist->GetXaxis()->SetLabelSize(0.040);
  axisHist->GetYaxis()->SetLabelSize(0.040);
  //axisHist->GetXaxis()->SetMoreLogLabels();
  //axisHist->GetXaxis()->SetNoExponent();
  axisHist->GetXaxis()->SetRangeUser(60.0,3000.0);
  axisHist->SetMinimum(0.01);
  axisHist->SetMaximum(20000.0);
  //axisHist->SetMaximum(2000.0);
  dataHist->SetMarkerStyle(20);
  dataHist->SetMarkerSize(0.9);
  dataHist->GetXaxis()->SetRange(5,83);
  dataHist->GetXaxis()->SetTitleSize(0.047);
  dataHist->GetXaxis()->SetTitleOffset(0.9);
  dataHist->GetYaxis()->SetTitleSize(0.047);
  dataHist->GetYaxis()->SetTitleOffset(1.2);
  dataHist->Draw("PZ");
  

  //==========================================================
  TLegend *leg = new TLegend(0.56741,0.48671,0.820536,0.83664,NULL,"brNDC"); //for lumi in plot
  leg->AddEntry(dataHist,"Data","PE");
  leg->AddEntry(zeeHist,"#gamma^{*}/Z#rightarrow#mu^{+}#mu^{-}","F");
  leg->AddEntry(ttbarHist,"t#bar{t}, Single Top","F");
  //leg->AddEntry(dibosonsBkgHist,"WW, WZ, ZZ","F");
  leg->AddEntry(dibosonsBkgHist,"Diboson, #tau#tau","F");
  leg->AddEntry(WjetsBkgHist,"W+jets (FR)","F");
  leg->AddEntry(jetBkgHist,"Di-Jets (data)","F");
  //leg->AddEntry(jetBkgHist,"Jets (FR)","F");
  leg->SetBorderSize(0);
  //leg->SetTextFont(62);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(19);
  leg->SetFillStyle(0);
  leg->SetTextFont(font);
  leg->SetTextSize(0.04);
  leg->Draw();
  //==========================================================
  TPaveText* tText1 = new TPaveText(0.75, 0.92, 0.87, 0.98, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("2.673 fb^{-1} (13 TeV)");
  tText1->SetTextSize(0.04);
  tText1->Draw(); 
  //==========================================================
  TPaveText* tText2 = new TPaveText(0.85, 0.86, 0.88, 0.87, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t2 = tText2->AddText("CMS");
  t2 = tText2->AddText("CMS");
  tText2->SetTextSize(0.04);
  tText2->Draw(); 
  //==========================================================
  TPaveText* tText3 = new TPaveText(0.80, 0.81, 0.85, 0.83, "brNDC");
  tText3->SetBorderSize(0);
  tText3->SetFillColor(0);
  tText3->SetFillStyle(0);
  TText *t3 = tText3->AddText("#it{Preliminary}");
  tText3->SetTextSize(0.04);
  tText3->Draw(); 

  //---------------------------------------------------------------------
  //---------------------------------------------------------------------
  c1->cd();          // Go back to the main canvas before defining pad2
  TPad *pad2 = new TPad("pad2", "pad2", 0, 0.05, 1, 0.3);
  pad2->SetTopMargin(0.05);
  pad2->SetBottomMargin(0.3);
  pad2->SetTickx(1);
  pad2->SetTicky(1);
  pad2->SetLogx(1);
  pad2->SetLogy(1);
  pad2->SetGridx(1);
  pad2->SetGridy(1);
  pad2->Draw();
  pad2->cd();       // pad2 becomes the current pad
  //========================================================== 
  //                                                              
  //               Get the histograms                                  
  //==========================================================
  
  TFile *file1000 = new TFile("plots/h_ZprimeRecomass_Total_OF.root","READ");   
  TH1F* totalMC = (TH1*) file1000->Get("ZprimeRecomassBinWidthwtOverFlow");
  TH1F* totaldijet= (TH1*) file1000->Get("DataSubwtOverFlow");
  TH1F* totalwjet= (TH1*) file1000->Get("WjetsHistowtOverFlow");

  /*
  TH1F *total;
  total->Add(totalMC);
  total->Add(totaldijet);
  total->Add(totalwjet);
  */

  TFile *file2000 = new TFile("plots/h_ZprimeRecomass_data_OF.root","READ");
  TH1* dataHistTempbar  = (TH1*) file2000->Get("ZprimeRecomassBinWidthwtOverFlow");

  //dataHistTempbar->Divide(total);
  //dataHistTempbar->Draw();
 
  //TFile *file = new TFile("Data-DY-Dibosons-TTbarandTTbarLike-Wjets-Dijets-MC-OS-2673pb.root","READ");
  //TH1* dataHistTempbar = (TH1*) file1->Get("htotalHistoRatiowtOverFlow");
  
  float binWidthNorm=-1;
  int singletopColour    =  TColor::GetColor("#99ccff");
  int jetBkgColour = TColor::GetColor("#ffff66"); 
  int ttbarColour  = TColor::GetColor("#ff6666");
  int bosonColour  = TColor::GetColorDark(3);
  int wjetsColour  = TColor::GetColorDark(5);
  int DYtautauColour  = TColor::GetColorDark(4);
  int font = 42;
  //TGraphAsymmErrors* dataHist = makeDataGraph(dataHistTempbar,binWidthNorm,0);
  //normHistToBinWidth(singletopHist,binWidthNorm);
  dataHistTempbar->SetMarkerStyle(20);
  dataHistTempbar->SetMarkerColor(1);
  dataHistTempbar->SetMarkerSize(0.9);
  //dataHistTempbar->GetXaxis()->SetRange(5,83);

  dataHistTempbar->GetXaxis()->SetTitleOffset(1.1);
  dataHistTempbar->GetYaxis()->SetTitleOffset(0.4);
 
  dataHistTempbar->GetXaxis()->SetTitleSize(0.14);
  dataHistTempbar->GetYaxis()->SetTitleSize(0.12);
  
  dataHistTempbar->GetXaxis()->SetLabelSize(0.12);
  dataHistTempbar->GetYaxis()->SetLabelSize(0.08);  

  dataHistTempbar->GetXaxis()->SetTitle("M(#mu^{+}#mu^{-}) [GeV]");
  //dataHistTempbar->GetXaxis()->SetTitle("M(e#mu) [GeV]");
  dataHistTempbar->GetYaxis()->SetTitle("Data / MC");
  dataHistTempbar->GetXaxis()->SetMoreLogLabels();
  dataHistTempbar->GetXaxis()->SetNoExponent();
  dataHistTempbar->GetXaxis()->SetRangeUser(60.0,2500.0);
  dataHistTempbar->GetYaxis()->SetRangeUser(-1.0,3.0);
  dataHistTempbar->SetMarkerStyle(20);
  dataHistTempbar->SetMarkerSize(0.9);
  dataHistTempbar->Draw("");

  
  TF1* fn1 = new TF1("fn1","pol0",60,1300);
  fn1->SetLineColor(2);
  dataHistTempbar->Fit("fn1","R,smaes");
  //==========================================================
  TPaveText* tText10 = new TPaveText(0.70, 0.40, 0.88, 0.90, "brNDC");
  tText10->SetBorderSize(0);
  tText10->SetFillColor(0);
  tText10->SetFillStyle(0);
  TText *t1 = tText10->AddText("#chi^{2} / n.d.f = 53.91/54");
  TText *t2 = tText10->AddText("Prob = 0.478");
  TText *t3 = tText10->AddText("p0 = 1.009 #pm 0.005");
  tText10->SetTextSize(0.10);
  tText10->Draw(); 

  
  //=================================================================================== 
  c1->Print("Stack-DY-Spring15MCs-Data2015-mass-spectrum-MuMu-OS-2673pb.png","png");
  //c1->Print("Stack-DY-Spring15MCs-Data2015-mass-spectrum-MuMu-OS-2673pb.pdf","pdf");
  //=========================================================================
  //=========================================================================
  //=========================================================================
  //=========================================================================
  //=========================================================================
  //=========================================================================
  TCanvas *c2 = new TCanvas("c2", "c2",1000,600);
  TPad* spectrumPad=0;
  TPad* ratioPad=0;
  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  gStyle->SetStatX(0.457589);
  gStyle->SetStatY(0.312937);
  gStyle->SetStatW(0.29241/2+0.0185);
  gStyle->SetStatH(0.169580+0.05);
  gStyle->SetStatFontSize(0.0402098);
  gStyle->SetStatFont(0.03);
  gStyle->SetFitFormat("5.2g");
  gStyle->SetStatBorderSize(0);
  gStyle->SetStatFontSize(0.040209);
  gStyle->SetStatFontSize(0.035209);
  c2->Range(1.592761,-5.173913,3.533814,6.006211);
  c2->SetFillColor(0);
  c2->SetBorderMode(0);
  c2->SetBorderSize(2);
  c2->SetLogx(1);
  c2->SetLogy(1);
  c2->SetTickx(1);
  c2->SetTicky(1);
  c2->SetLeftMargin(0.13);
  c2->SetRightMargin(0.07);
  c2->SetFrameBorderMode(0);
  c2->SetFrameBorderMode(0);
  c2->SetTopMargin(0.085);
  c2->SetBottomMargin(0.11);

  TFile *file1 = new TFile("plots/htotal_root_ZprimeRecomass_OF.root","READ");
  TH1* zeeHist = (TH1*) file1->Get("hfourlepbestmass_4l_afterSel_new_DYwtOverFlow");
 
  //TFile *file2 = new TFile("Data-Dibosons-TTbarandTTbarLike-MC-OS-2673pb.root","READ");
  TH1* ttbarHist = (TH1*) file1->Get("hfourlepbestmass_4l_afterSel_new_TlikewtOverFlow");
  TH1* dibosonsBkgHist = (TH1*) file1->Get("hfourlepbestmass_4l_afterSel_new_diBosonwtOverFlow");
  TH1* dataHistTempbar = (TH1*) file1->Get("htotaldatawtOverFlow");

  //TFile *file3 = new TFile("Wjets-25nsMC-OS-allbins-2673pb.root","READ");
  TH1* WjetsBkgHist = (TH1*) file1->Get("hfourlepbestmass_4l_afterSel_WJetsFromFakeRateFromMCwtOverFlow");
  std::cout<<"nb.Wjets(MC)  = "<<WjetsBkgHist->Integral()<<endl;

  //TFile *file4 = new TFile("DiJets-Data-OS-2673pb-FR.root","READ");
  TH1* jetBkgHist   = (TH1*) file1->Get("hfourlepbestmass_4l_afterSel_DiJetsFromFakeRateFromDatawtOverFlow");
  std::cout<<"nbQCD(dijets,Data)  = "<<jetBkgHist->Integral()<<endl;

  /*
  zeeHist->Rebin(20);
  ttbarHist->Rebin(20);
  dibosonsBkgHist->Rebin(20);
  dataHistTempbar->Rebin(20);
  WjetsBkgHist->Rebin(20);
  jetBkgHist->Rebin(20);
  */

  float binWidthNorm2=-1;
  int zeeColour    =  TColor::GetColor("#99ccff");
  int jetBkgColour = TColor::GetColor("#ffff66"); 
  int ttbarColour  = TColor::GetColor("#ff6666");
  int bosonColour  = TColor::GetColorDark(3);
  int WjetsColour  = TColor::GetColorDark(5);
  int font = 42;
  float xAxisMin = 60; //72
  float xAxisMax = 3000.0;
  float yAxisMin = 1e-4;
  float yAxisMax = 1e4; 

  

  dataHistTempbar = makeIntHist(dataHistTempbar);
  zeeHist         = makeIntHist(zeeHist);
  ttbarHist       = makeIntHist(ttbarHist);
  dibosonsBkgHist = makeIntHist(dibosonsBkgHist);
  jetBkgHist      = makeIntHist(jetBkgHist);
  WjetsBkgHist    = makeIntHist(WjetsBkgHist);
  TGraphAsymmErrors* dataHist = makeDataGraph(dataHistTempbar,binWidthNorm2,0);
  THStack *axisHist2 = new THStack("axisHist2","");
  zeeHist->SetFillColor(zeeColour);
  zeeHist->SetLineWidth(2);
  zeeHist->SetLineColor(1);
  zeeHist->SetTitle("");
    
  ttbarHist->SetFillColor(ttbarColour);
  ttbarHist->SetLineWidth(2); 
  ttbarHist->SetLineColor(1);
    
  dibosonsBkgHist->SetFillColor(bosonColour);
  dibosonsBkgHist->SetLineWidth(2); 
  dibosonsBkgHist->SetLineColor(1);
   
  jetBkgHist->SetFillColor(jetBkgColour);
  jetBkgHist->SetLineWidth(2);
  jetBkgHist->SetLineColor(1);

  WjetsBkgHist->SetFillColor(WjetsColour);
  WjetsBkgHist->SetLineWidth(2);
  WjetsBkgHist->SetLineColor(1);
  
  
  axisHist2->Add(jetBkgHist,"histo");
  axisHist2->Add(WjetsBkgHist,"histo");
  axisHist2->Add(dibosonsBkgHist,"histo");
  axisHist2->Add(ttbarHist,"histo");
  axisHist2->Add(zeeHist,"histo");
  axisHist2->Draw();
  axisHist2->GetXaxis()->SetTitle("M(#mu^{+}#mu^{-}) [GeV]");
  axisHist2->GetYaxis()->SetTitle("Events #geq M(#mu^{+}#mu^{-}) [GeV]");
  axisHist2->GetXaxis()->SetTitleOffset(1.1);
  axisHist2->GetYaxis()->SetTitleOffset(1.1);
  axisHist2->GetXaxis()->SetTitleSize(0.047);
  axisHist2->GetYaxis()->SetTitleSize(0.047);
  axisHist2->GetXaxis()->SetLabelSize(0.040);
  axisHist2->GetYaxis()->SetLabelSize(0.040);
  axisHist2->GetXaxis()->SetMoreLogLabels();
  axisHist2->GetXaxis()->SetNoExponent();
  axisHist2->GetXaxis()->SetRangeUser(60.0,2500.0);
  axisHist2->SetMinimum(0.01);
  axisHist2->SetMaximum(60000.0);
  
  dataHist->SetMarkerStyle(20);
  dataHist->SetMarkerSize(0.9);
  dataHist->Draw("PZsames");
  //==========================================================
  TLegend *leg = new TLegend(0.56741,0.58671,0.820536,0.83664,NULL,"brNDC");
  leg->AddEntry(dataHist,"Data","PE");
  leg->AddEntry(zeeHist,"#gamma^{*}/Z#rightarrow#mu^{+}#mu^{-}","F");
  leg->AddEntry(ttbarHist,"t#bar{t}, Single Top","F");
  //leg->AddEntry(dibosonsBkgHist,"WW, WZ, ZZ","F");
  leg->AddEntry(dibosonsBkgHist,"Diboson, #tau#tau","F");
  leg->AddEntry(WjetsBkgHist,"W+jets (FR)","F");
  leg->AddEntry(jetBkgHist,"Di-Jets (data)","F");
  //leg->AddEntry(jetBkgHist,"Jets (FR)","F");
  leg->SetBorderSize(0);
  //leg->SetTextFont(62);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(19);
  leg->SetFillStyle(0);
  leg->SetTextFont(font);
  leg->SetTextSize(0.04);
  leg->Draw();
  //==========================================================
  TPaveText* tText1 = new TPaveText(0.75, 0.92, 0.87, 0.98, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("2.673 fb^{-1} (13 TeV)");
  tText1->SetTextSize(0.04);
  tText1->Draw(); 
  //==========================================================
  TPaveText* tText2 = new TPaveText(0.85, 0.86, 0.88, 0.87, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t1 = tText2->AddText("CMS");
  tText2->SetTextSize(0.04);
  tText2->Draw(); 
  //==========================================================
  TPaveText* tText3 = new TPaveText(0.80, 0.81, 0.85, 0.83, "brNDC");
  tText3->SetBorderSize(0);
  tText3->SetFillColor(0);
  tText3->SetFillStyle(0);
  TText *t1 = tText3->AddText("#it{Preliminary}");
  tText3->SetTextSize(0.04);
  tText3->Draw(); 
  //=================================================================================== 
  c2->Print("Stack-DY-Spring15MCs-Data2015-cumulative-spectrum-MuMu-OS-2673pb.png","png");
  //c2->Print("Stack-DY-Spring15MCs-Data2015-cumulative-spectrum-MuMu-OS-2673pb.pdf","pdf");

  

}
void postFitPlotsCOMBINEINSERT(TString name="collMass",TString fileDataMuHad0Jet="asdf", TString fileDataMuHad1Jet = "asdf", TString fileDataMuHad2Jet = "asdf", TString fileDataMuEle0Jet = "asdf", TString fileDataMuEle1Jet = "asdf", TString fileDataMuEle2Jet = "asdf", TString file="fit2_signalV5_collMass_type1.root", TString dirInternal="filesBoosted", TString Xaxis="M_{#mu,#tau}_{coll} [GeV]", TString Yaxis="Events / 20 GeV", double xmin=200, double xmax=300, double ymin=-2, double ymax=2, bool setLogY=false, double legx1=0.6, double legy1=0.9, double legx2=0.9, double legy2=0.5, double MAX=-1, double MIN=-1, bool mutau0=true, bool mutau1=true, bool mutau2=true, bool muele0=true, bool muele1=true, bool muele2=true, bool REBIN=true, bool weightSOverSB=true,TString channelName="#mu#tau", double minsubs=-1, double maxsubs=-1){


	gROOT->LoadMacro("tdrstyle.C");
	setTDRStyle();
	double kForPlotting=1;
	double branchingratioTauTau=0.063;
	double branchingratioTauMu=0.1;
	double Lumi=19717;

	gROOT->LoadMacro("CMS_lumi.C");
	writeExtraText = false;
	int iPeriod = 2;
	// second parameter in example_plot is iPos, which drives the position of the CMS logo in the plot
	int iPos=11;// : top-left, left-aligned
	// iPos=33 : top-right, right-aligned
	// iPos=22 : center, centered
	// mode generally :
	//   iPos = 10*(alignement 1/2/3) + position (1/2/3 = left/center/right)
	//  example_plot( iPeriod, 11 );  // left-aligned
	//  example_plot( iPeriod, 33 );  // right-aligned
	//  example_plot( iPeriod, 0 );   // out of frame (in exceptional cases)
	//  example_plot( iPeriod, 11 );  // default: left-aligned
	//  example_plot( iPeriod, 22 );  // centered
	//  example_plot( iPeriod, 33 );  // right-aligned


	bool muonchannels[3]={mutau0,mutau1,mutau2};
	bool elechannels[3]={muele0,muele1,muele2};

	int NBins=30; 
	if(mutau2 || muele2 || REBIN) { REBIN=true; NBins=15;}

	TFile *_fileMC= new TFile("CombinedPlots20PAS/"+file);
	TFile *_fileDataMuHad0Jet= new TFile("CombinedPlots20PAS/"+fileDataMuHad0Jet);
        TFile *_fileDataMuHad1Jet= new TFile("CombinedPlots20PAS/"+fileDataMuHad1Jet);
        TFile *_fileDataMuHad2Jet= new TFile("CombinedPlots20PAS/"+fileDataMuHad2Jet);
        TFile *_fileDataMuEle0Jet= new TFile("CombinedPlots20PAS/"+fileDataMuEle0Jet);
        TFile *_fileDataMuEle1Jet= new TFile("CombinedPlots20PAS/"+fileDataMuEle1Jet);
        TFile *_fileDataMuEle2Jet= new TFile("CombinedPlots20PAS/"+fileDataMuEle2Jet);


	//TString dirInternalAllMU[3]={dirInternal+"/datacard_gg0_pfMetFixOldjesNewFakeShape",dirInternal+"/datacard_gg1_pfMetFixOldjesNewFakeShape", dirInternal+"/datacard_vbf20_pfMetFixOldjesNewFakeShape"};
        TString dirInternalAllMU[3]={dirInternal+"/datacard_MuTau_0Jet_new",dirInternal+"/datacard_MuTau_1Jet_new", dirInternal+"/datacard_vbf_PAS20"};
	TString dirInternalAllELE[3]={dirInternal+"/datacard_MuEle_0Jet",dirInternal+"/datacard_MuEle_1Jet", dirInternal+"/datacard_MuEle_2Jet"};

	TString dirInternalSignal="shapes_prefit";

	TH1F* hdata_obs = new TH1F("hdata_obs","",NBins,0,300);
	TH1F* hFAKES = new TH1F("hFAKES","",NBins,0,300);
	TH1F* hFAKESLEPTON = new TH1F("hFAKESLEPTON","",NBins,0,300);
	TH1F* hDY = new TH1F("hDY","",NBins,0,300);
	TH1F* hWW = new TH1F("hWW","",NBins,0,300);
	TH1F* hTOP = new TH1F("hTOP","",NBins,0,300);
	TH1F* hTT = new TH1F("hTT","",NBins,0,300);
	TH1F* hZTauTau = new TH1F("hZTauTau","",NBins,0,300);
	TH1F* hLFVVBF126 = new TH1F("hLFVVBF126","",NBins,0,300);
	TH1F* hSMVBF126 = new TH1F("hSMVBF126","",NBins,0,300);
	TH1F* hSMHWWVBF126 = new TH1F("hSMHWWVBF126","",NBins,0,300);
	TH1F* hLFVGG126 = new TH1F("hLFVGG126","",NBins,0,300);
	TH1F* hSMGG126 = new TH1F("hSMGG126","",NBins,0,300);
	TH1F* hSMHWWGG126 = new TH1F("hSMHWWGG126","",NBins,0,300);
	TH1F* hWGamma = new TH1F("hWGamma","",NBins,0,300);
	TH1F* hWGammaStar = new TH1F("hWGammaStar","",NBins,0,300);

	double weightMuTau[3]={1,1,1};
	double weightMuEle[3]={1,1,1};

	int binA=hdata_obs->FindBin(100);
	int binB=hdata_obs->FindBin(150);

	for (int i=0; i<3; i++){
		cout << "starting" << i <<endl;
		if(muonchannels[i]!=true) continue;
		TH1F *hFAKES_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+"/fakes");hFAKES_2->SetName("fakesHisto");
		TString Extra="/zjetsother";
		if(i==2) Extra="/fakes"; // in the postfit directory the DY for VBF is not saved, since it has 0 events
		TH1F *hDY_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+Extra); hDY_2->SetName("dyHisto");
		TH1F *hWW_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+"/ww");
		TH1F *hTOP_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+"/singlet");
		TH1F *hTT_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+"/ttbar");
		TH1F *hZTauTau_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+"/ztautau");
		TH1F *hLFVVBF126_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+"/LFVVBF");
		TH1F *hLFVGG126_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+"/LFVGG");
		TH1F *hSMGG126_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+"/SMGG126");
		TH1F *hSMVBF126_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+"/SMVBF126");
		Extra="/fakes";
		if(i!=0) Extra="/WWGG126";
		TH1F *hSMHWWGG126_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+Extra); hSMHWWGG126_2->SetName("smwwgg");
		if(i==0) hSMHWWGG126_2->Scale(0);
		TH1F *hSMHWWVBF126_2=(TH1F*)_fileMC->Get(dirInternalAllMU[i]+"/WWVBF126"); hSMHWWVBF126_2->SetName("wwsm");
		cout << "got histos" << endl;
		if(i!=2 && (REBIN)) {
			hFAKES_2->Rebin(2); hDY_2->Rebin(2); hWW_2->Rebin(2); hTOP_2->Rebin(2); hTT_2->Rebin(2); hZTauTau_2->Rebin(2);
			hLFVVBF126_2->Rebin(2); hLFVGG126_2->Rebin(2); hSMGG126_2->Rebin(2); hSMVBF126_2->Rebin(2);
			hSMHWWVBF126_2->Rebin(2);
			if(i!=0) hSMHWWGG126_2->Rebin(2);
		}

		// WEIGHT	
		double bckg=hWW_2->Integral(binA,binB)+hFAKES_2->Integral(binA,binB) + hTOP_2->Integral(binA,binB) + hTT_2->Integral(binA,binB) + hZTauTau_2->Integral(binA,binB);
		bckg+=hSMVBF126_2->Integral(binA,binB)+hSMGG126_2->Integral(binA,binB)+hSMHWWVBF126_2->Integral(binA,binB);
		if(i!=2) bckg+=hDY_2->Integral(binA,binB);
		else hDY_2->Scale(0);
		if(i!=0) bckg+=hSMHWWGG126_2->Integral(binA,binB);
		else hSMHWWGG126_2->Scale(0);

		double signal=hLFVGG126_2->Integral(binA,binB)+hLFVVBF126_2->Integral(binA,binB);

		weightMuTau[i]=signal/(signal+bckg);
		cout<<"Weighting MuTau Channel  "<<i<<" --> "<<weightMuTau[i]<<endl;

		if(weightSOverSB){
			hFAKES_2->Scale(weightMuTau[i]);
			hDY_2->Scale(weightMuTau[i]);
			hWW_2->Scale(weightMuTau[i]);
			hTOP_2->Scale(weightMuTau[i]);
			hTT_2->Scale(weightMuTau[i]);
			hZTauTau_2->Scale(weightMuTau[i]);
			hLFVVBF126_2->Scale(weightMuTau[i]);
			hLFVGG126_2->Scale(weightMuTau[i]);
			hSMVBF126_2->Scale(weightMuTau[i]);
			hSMGG126_2->Scale(weightMuTau[i]);
			hSMHWWVBF126_2->Scale(weightMuTau[i]);
			hSMHWWGG126_2->Scale(weightMuTau[i]);
		}

		// MERGE

		fillNewHisto(hFAKES,hFAKES_2);
		if(i!=2) fillNewHisto(hDY,hDY_2);
		fillNewHisto(hWW,hWW_2);
		fillNewHisto(hTOP,hTOP_2);
		fillNewHisto(hTT,hTT_2);
		fillNewHisto(hZTauTau,hZTauTau_2);
		fillNewHisto(hLFVVBF126,hLFVVBF126_2);
		fillNewHisto(hLFVGG126,hLFVGG126_2);
		fillNewHisto(hSMVBF126,hSMVBF126_2);
		fillNewHisto(hSMGG126,hSMGG126_2);
		fillNewHisto(hSMHWWVBF126,hSMHWWVBF126_2);
		if(i!=0) fillNewHisto(hSMHWWGG126,hSMHWWGG126_2);

	}

	for (int i=0; i<3; i++){
		if(elechannels[i]!=true) continue;

		TH1F *hFAKESLEPTON_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/Fakes"); hFAKESLEPTON_2->SetName("hFAKESLEPTON_2");
		TString Extra="/DYnoTauTau";
		if(i==2) Extra="/Fakes"; // in the postfit directory the DY for VBF is not saved, since it has 0 events
		TH1F *hDY_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+Extra);
		TH1F *hWW_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/WW");
		Extra="/WG";
		if(i!=1) Extra="/Fakes";
		TH1F *hWGamma_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+Extra); hWGamma_2->SetName("hWGamma_2");
		Extra="/WGStar";
		if(i==2) Extra="/Fakes";
		TH1F *hWGammaStar_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+Extra); hWGammaStar_2->SetName("hWGammaStar_2");
		TH1F *hTOP_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/TOP");
		TH1F *hTT_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/TT");
		TH1F *hZTauTau_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/ZTauTau");
		TH1F *hLFVVBF126_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/LFVVBF");
		TH1F *hLFVGG126_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/LFVGG");
		TH1F *hSMGG126_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/ggHTauTau");
		TH1F *hSMVBF126_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/vbfHTauTau");
		TH1F *hSMHWWGG126_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/ggHWW");
		TH1F *hSMHWWVBF126_2=(TH1F*)_fileMC->Get(dirInternalAllELE[i]+"/vbfHWW");

		if(i!=2 && (REBIN)) {
			hFAKESLEPTON_2->Rebin(2); hDY_2->Rebin(2); hWW_2->Rebin(2); hTOP_2->Rebin(2); hTT_2->Rebin(2); hZTauTau_2->Rebin(2);
			hLFVVBF126_2->Rebin(2); hLFVGG126_2->Rebin(2); hSMGG126_2->Rebin(2); hSMVBF126_2->Rebin(2);
			hSMHWWGG126_2->Rebin(2); hSMHWWVBF126_2->Rebin(2);
			hWGamma_2->Rebin(2); hWGammaStar_2->Rebin(2);
		}


		// WEIGHT       
		double bckg=hWW_2->Integral(binA,binB)+hFAKESLEPTON_2->Integral(binA,binB) + hTOP_2->Integral(binA,binB) + hTT_2->Integral(binA,binB) + hZTauTau_2->Integral(binA,binB);
		bckg+=hSMVBF126_2->Integral(binA,binB)+hSMGG126_2->Integral(binA,binB)+hSMHWWVBF126_2->Integral(binA,binB)+hSMHWWGG126_2->Integral(binA,binB);
		if(i!=2) {bckg+=hDY_2->Integral(binA,binB)+hWGammaStar_2->Integral(binA,binB);}
		else {hDY_2->Scale(0); hWGammaStar_2->Scale(0);}
		if (i==1) bckg+=hWGamma_2->Integral();
		else hWGamma_2->Scale(0);

		double signal=hLFVGG126_2->Integral()+hLFVVBF126_2->Integral();

		weightMuEle[i]=signal/(signal+bckg);
		cout<<"Weighting MuEle Channel  "<<i<<" --> "<<weightMuEle[i]<<endl;

		if(weightSOverSB){
			hFAKESLEPTON_2->Scale(weightMuEle[i]);
			hDY_2->Scale(weightMuEle[i]);
			hWW_2->Scale(weightMuEle[i]);
			hTOP_2->Scale(weightMuEle[i]);
			hTT_2->Scale(weightMuEle[i]);
			hZTauTau_2->Scale(weightMuEle[i]);
			hWGamma_2->Scale(weightMuEle[i]);
			hWGammaStar_2->Scale(weightMuEle[i]);
			hLFVVBF126_2->Scale(weightMuEle[i]);
			hLFVGG126_2->Scale(weightMuEle[i]);
			hSMVBF126_2->Scale(weightMuEle[i]);
			hSMGG126_2->Scale(weightMuEle[i]);
			hSMHWWVBF126_2->Scale(weightMuEle[i]);
			hSMHWWGG126_2->Scale(weightMuEle[i]);
		}

		fillNewHisto(hFAKESLEPTON,hFAKESLEPTON_2);
		if(i!=2) fillNewHisto(hDY,hDY_2);
		fillNewHisto(hWW,hWW_2);
		if(i!=2) fillNewHisto(hWGammaStar,hWGammaStar_2);
		if(i==1) fillNewHisto(hWGamma,hWGamma_2);
		fillNewHisto(hTOP,hTOP_2);
		fillNewHisto(hTT,hTT_2);
		fillNewHisto(hZTauTau,hZTauTau_2);
		fillNewHisto(hLFVVBF126,hLFVVBF126_2);
		fillNewHisto(hLFVGG126,hLFVGG126_2);
		fillNewHisto(hSMVBF126,hSMVBF126_2);
		fillNewHisto(hSMGG126,hSMGG126_2);
		fillNewHisto(hSMHWWVBF126,hSMHWWVBF126_2);
		fillNewHisto(hSMHWWGG126,hSMHWWGG126_2);



	}



	TString dirInternalDataAllMU[3]={"gg0mutau","boostmutau","vbfmutau"};

	for (int i=0; i<3; i++){
		cout << "starting data" <<endl;
		if(muonchannels[i]!=true) continue;
		if(i == 0){
                  TH1F *hdata_obs_2=(TH1F*)_fileDataMuHad0Jet->Get(dirInternalDataAllMU[i]+"/data_obs");
		}
		else if (i  == 1){
		  TH1F *hdata_obs_2=(TH1F*)_fileDataMuHad1Jet->Get(dirInternalDataAllMU[i]+"/data_obs");
		}
		else if (i == 2){
                  TH1F *hdata_obs_2=(TH1F*)_fileDataMuHad2Jet->Get(dirInternalDataAllMU[i]+"/data_obs");
                }
		cout << "declared histos" << endl;
		//TH1F *hdata_obs_2=(TH1F*)_fileData->Get(dirInternalDataAllMU[i]+"/data_obs");
		hdata_obs_2->SetName("hdata_obs_2");
		if(weightSOverSB) hdata_obs_2->Scale(weightMuTau[i]);
		if(i!=2 && (REBIN)) hdata_obs_2->Rebin(2);
		cout << "filling data histo" << endl;
		fillNewHisto(hdata_obs,hdata_obs_2);
	}

	TString dirInternalDataAllELE[3]={"GGF","Boost","VBF"};

	for (int i=0; i<3; i++){
		if(elechannels[i]!=true) continue;
                if(i == 0){
                  TH1F *hdata_obs_2=(TH1F*)_fileDataMuEle0Jet->Get(dirInternalDataAllELE[i]+"/data_obs");
                }
                else if (i  == 1){
                  TH1F *hdata_obs_2=(TH1F*)_fileDataMuEle1Jet->Get(dirInternalDataAllELE[i]+"/data_obs");
                }
                else if (i == 2){
                  TH1F *hdata_obs_2=(TH1F*)_fileDataMuEle2Jet->Get(dirInternalDataAllELE[i]+"/data_obs");
                }

		//TH1F *hdata_obs_2=(TH1F*)_fileData->Get(dirInternalDataAllELE[i]+"/data_obs");
		hdata_obs_2->SetName("hdata_obs_2");
		if(weightSOverSB) hdata_obs_2->Scale(weightMuEle[i]);
		if(i!=2 && (REBIN) ) hdata_obs_2->Rebin(2);
		fillNewHisto(hdata_obs,hdata_obs_2);
	}



	TH1F *hSMHIGGS=(TH1F*) hSMVBF126->Clone();hSMHIGGS->SetName("hSMHIGGS");
	hSMHIGGS->Add(hSMGG126);
	TH1F *hSMHWWHIGGS=(TH1F*) hSMHWWVBF126->Clone();hSMHWWHIGGS->SetName("hSMHWWHIGGS");
	hSMHWWHIGGS->Add(hSMHWWGG126);

	hWGamma->Add(hWGammaStar);

	hFAKES->Add(hFAKESLEPTON);
	hFAKES->SetFillColor(kMagenta-10); hFAKES->SetLineColor(kMagenta+3); hFAKES->SetLineWidth(1);
	hFAKESLEPTON->SetFillColor(kMagenta-9); hFAKESLEPTON->SetLineColor(kMagenta+4); hFAKESLEPTON->SetLineWidth(1);

	hZTauTau->SetFillColor(kOrange-4); hZTauTau->SetLineColor(kOrange+4); hZTauTau->SetLineWidth(1);

        hDY->SetFillColor(kAzure+3); hDY->SetLineColor(kAzure+4); hDY->SetLineWidth(1);
        hWW->SetFillColor(kAzure+3); hWW->SetLineColor(kAzure+3); hWW->SetLineWidth(1);
        hWGamma->SetFillColor(kAzure+3); hWGamma->SetLineColor(kAzure+3); hWGamma->SetLineWidth(1);

        hTOP->SetFillColor(kGreen-2); hTOP->SetLineColor(kGreen+4); hTOP->SetLineWidth(1);
        hTT->SetFillColor(kGreen-2); hTT->SetLineColor(kGreen-2); hTT->SetLineWidth(1);



	hSMHIGGS->SetFillColor(kMagenta); hSMHIGGS->SetLineColor(kMagenta+1); hSMHIGGS->SetLineWidth(1);
	hSMHWWHIGGS->SetFillColor(kMagenta); hSMHWWHIGGS->SetLineColor(kMagenta+1); hSMHWWHIGGS->SetLineWidth(1);

	hLFVGG126->SetLineColor(kBlue);  hLFVGG126->SetLineWidth(3);
	hLFVVBF126->SetLineColor(kBlue); hLFVVBF126->SetLineWidth(3); hLFVVBF126->SetLineStyle(kDashed);
	hSMHIGGS->SetLineColor(kMagenta); hSMHIGGS->SetLineWidth(3);
	hSMHWWHIGGS->SetLineColor(kMagenta); hSMHWWHIGGS->SetLineWidth(3);



	hdata_obs->SetMarkerSize(1); // Closer to Daniel's

	// PLOT

	TCanvas *c1 = new TCanvas("canvas_"+name);
	TPad *Pad1= new TPad("pad1","",0,0.2,1,1); Pad1->Draw(); Pad1->cd();;
	Pad1->SetLeftMargin(0.2147651);
	Pad1->SetRightMargin(0.06543624);
	Pad1->SetTopMargin(0.07);
	Pad1->SetBottomMargin(0.04);

	TH1F* fullMC2=hFAKES->Clone();  fullMC2->Add(hZTauTau); fullMC2->Add(hTT); fullMC2->Add(hWW); fullMC2->Add(hWGamma);
	fullMC2->Add(hDY); fullMC2->Add(hTOP); fullMC2->Add(hSMHIGGS);  fullMC2->Add(hSMHWWHIGGS);
	fullMC2->SetFillColor(kGray+2); fullMC2->SetFillStyle(3002); fullMC2->SetMarkerSize(0); fullMC2->SetLineWidth(2);
	fullMC2->Draw("hist");

	fullMC2->GetXaxis()->SetTitle("");
	fullMC2->GetYaxis()->SetTitle(Yaxis);
	fullMC2->GetXaxis()->SetRangeUser(xmin,xmax);
	fullMC2->GetYaxis()->SetTitleOffset(1.2);
	fullMC2->GetYaxis()->SetTitleSize(0.05);
	fullMC2->GetXaxis()->SetNdivisions(0);
	fullMC2->GetYaxis()->SetLabelSize(0.04);


	TH1F* hSignal=hLFVGG126->Clone(); hSignal->SetName("hSignal");
	hSignal->Add(hLFVVBF126);

        hSignal->SetLineColor(kBlue);  hSignal->SetLineWidth(3);
	hSignal->SetLineStyle(2);

	THStack* stack = new THStack("stack","");
	stack->Add(hFAKES);
	stack->Add(hWW);
	stack->Add(hWGamma);
        stack->Add(hDY);
	stack->Add(hTT);
	stack->Add(hTOP);
	stack->Add(hZTauTau);
	stack->Add(hSMHIGGS);;
	stack->Add(hSMHWWHIGGS);
	stack->Add(hSignal);

	int bins=hdata_obs->GetNbinsX()+1;

	/*
	   cout<<"Yields  "<<endl;
	   cout<<"DATA	    \t" <<hdata_obs->Integral()+hdata_obs->GetBinContent(bins)<<endl;
	   cout<<"VV           \t" <<hWW->Integral()+hWW->GetBinContent(bins)<<endl;
	   cout<<"TOP          \t" <<hTOP->Integral()+hTOP->GetBinContent(bins)<<endl;
	   cout<<"TT           \t" <<hTT->Integral()+hTT->GetBinContent(bins)<<endl;
	   cout<<"DY           \t" <<hDY->Integral()+hDY->GetBinContent(bins)<<endl;
	   cout<<"ZTauTau      \t" <<hZTauTau->Integral()+hZTauTau->GetBinContent(bins)<<endl;
	   cout<<"FAKES        \t" <<hFAKES->Integral()+hFAKES->GetBinContent(bins)<<endl;
	   cout<<"hFAKESLEPTON \t" <<hFAKESLEPTON->Integral()+hFAKESLEPTON->GetBinContent(bins)<<endl;
	   cout<<"hSMHIGGS     \t" <<hSMHIGGS->Integral()+hSMHWWHIGGS->Integral()+hSMHIGGS->GetBinContent(bins)+hSMHWWHIGGS->GetBinContent(bins)<<endl;
	   cout<<"LFVGG126     \t" <<hLFVGG126->Integral()+hLFVGG126->GetBinContent(bins)<<endl;
	   cout<<"LFVVBF126    \t" <<hLFVVBF126->Integral()+hLFVVBF126->GetBinContent(bins)<<endl;
	 */
	stack->Draw("samehist");
	fullMC2->Draw("sames,E2");

//	hSignal->Draw("sameshist");

	double maxData=hdata_obs->GetMaximum();
	double maxMC=stack->GetMaximum()*1.2;
	double maxLFV=hSignal->GetMaximum();
	double minMC=stack->GetMinimum();

	if(maxData>maxMC) {maxMC=1.2*maxData;}
	if(maxLFV>maxMC) {maxMC=1.2*maxLFV;}
	if(MAX!=-1) {maxMC=MAX;}
	if(minMC<1) minMC=0;

	stack->SetMaximum(maxMC);
	stack->GetYaxis()->SetRangeUser(minMC,maxMC);
	fullMC2->SetMaximum(maxMC);
	fullMC2->GetYaxis()->SetRangeUser(minMC,maxMC);

	hdata_obs->Draw("sames");


	TLegend *leg = new TLegend(legx1,legy1,legx2,legy2,NULL,"brNDC");
	leg->SetFillColor(0);
	leg->SetBorderSize(0);
	leg->SetFillStyle(0);
	TLegendEntry *entry;
	entry=leg->AddEntry(hdata_obs,"Data","p");
	entry=leg->AddEntry(fullMC2,"Bkgd. uncertainty","f");
	//entry=leg->AddEntry(hSMHWWHIGGS,"SM HWW","f");
	entry=leg->AddEntry(hSMHIGGS,"SM H","f");
	entry=leg->AddEntry(hZTauTau,"Z#rightarrow#tau#tau","f");
        entry=leg->AddEntry(hDY,"Other","f");
        entry=leg->AddEntry(hTOP,"t#bar{t}, t, #bar{t}","f");
	entry=leg->AddEntry(hFAKES,"MisID'd #tau, e, #mu","f");
	entry=leg->AddEntry(hSignal,"LFV Higgs, (B=0.9%)","l");
	//        entry=leg->AddEntry("NULL","Br(h#rightarrow#mu#tau)=1%","");
	//        entry=leg->AddEntry("NULL","Br(h#rightarrow#tau#tau)=6%","");
	leg->Draw();


	/*
	   TLegend *leg = new TLegend(legx1,legy1,legx2,legy2,NULL,"brNDC");
	   leg->SetFillColor(0);
	   leg->SetBorderSize(0);
	   leg->SetFillStyle(0);
	   TLegendEntry *entry;
	   entry=leg->AddEntry(hdata_obs,"observed","p");
	   entry=leg->AddEntry(fullMC2,"bckg. uncertainty","fl");
	//entry=leg->AddEntry(hSMHWWHIGGS,"SM HWW","f");
	entry=leg->AddEntry(hSMHIGGS,"SM H","f");
	eblindBy=leg->AddEntry(hZTauTau,"Z+#tau#tau (embedd.)","f");
	eblindBy=leg->AddEntry(hDY,"EWK","f");
	entry=leg->AddEntry(hFAKES,"Fakes","f");
	entry=leg->AddEntry(hSignal,"LFV Higgs, (B=0.9%)","l");
	//        entry=leg->AddEntry("NULL","Br(h#rightarrow#mu#tau)=1%","");
	//        entry=leg->AddEntry("NULL","Br(h#rightarrow#tau#tau)=6%","");
	 */


	leg->Draw();

	CMS_lumi( Pad1, iPeriod, iPos );
	//cmsPrelim(Lumi);

	Pad1->SetLogy(setLogY);



	c1->cd(); TPad *Pad2= new TPad("pad2","",0,0,1,0.23); Pad2->Draw(); Pad2->cd();  Pad2->SetGridy();
	Pad2->SetLeftMargin(0.2147651);
	Pad2->SetRightMargin(0.06543624);
	Pad2->SetTopMargin(0.0);
	Pad2->SetBottomMargin(0.38);
	Pad2->SetFillStyle(0);

	TH1F * Ratio=hdata_obs->Clone(); Ratio->SetName("Ratio");
	Ratio->Add(fullMC2,-1);
	double dataRatio[16];
	double mcRatio[16];
	double errordataUpRatio[16];
	double errordataDownRatio[16];
	double xbinsRatio[16];
	double xerrorbinsRatio[16];
	Ratio->Divide(fullMC2);

	TH1F* RatioError = Ratio->Clone(); RatioError->SetName("RatioError");

	for (int i=0; i<RatioError->GetNbinsX()+1; i++){
		double error=fullMC2->GetBinError(i)*hdata_obs->GetBinContent(i)/fullMC2->GetBinContent(i)/fullMC2->GetBinContent(i);
		//double error=fullMC2->GetBinError(i)/fullMC2->GetBinContent(i);
		RatioError->SetBinContent(i,0);
		RatioError->SetBinError(i,error);
	}


	for (int j=0; j<16; j++){
		xbinsRatio[j]=300./15*(j-1)+10;
		xerrorbinsRatio[j]=10;
		dataRatio[j]=hdata_obs->GetBinContent(j);
		errordataUpRatio[j]=hdata_obs->GetBinError(j);
		errordataDownRatio[j]=hdata_obs->GetBinError(j);
		if(dataRatio[j]==0) {errordataUpRatio[j]=1.7; errordataDownRatio[j]=0;}
		mcRatio[j]=fullMC2->GetBinContent(j);
		dataRatio[j]-=mcRatio[j];
		if(mcRatio[j]!=0) {
			dataRatio[j]=dataRatio[j]/mcRatio[j];
			errordataUpRatio[j]=errordataUpRatio[j]/mcRatio[j];
			errordataDownRatio[j]=errordataDownRatio[j]/mcRatio[j];
		}else{
			dataRatio[j]=0;
			errordataUpRatio[j]=0;
			errordataDownRatio[j]=0;
		}
		double error=0;
		if(fullMC2->GetBinContent(j)!=0) error=fullMC2->GetBinError(j)*hdata_obs->GetBinContent(j)/fullMC2->GetBinContent(j)/fullMC2->GetBinContent(j);

		cout<<hdata_obs->GetBinContent(j)<<" "<<mcRatio[j]<<"  "<<hdata_obs->GetBinError(j)<<" "<<fullMC2->GetBinError(j)<<"  "<<dataRatio[j]<<"  "<<errordataUpRatio[j]<<"  "<<error<<"  "<<Ratio->GetBinError(j)<<"   "<<sqrt(error*error+errordataUpRatio[j]*errordataUpRatio[j])<<endl;

	}

	TGraphAsymmErrors* dataGraphRatio=new TGraphAsymmErrors(16, xbinsRatio, dataRatio,xerrorbinsRatio,xerrorbinsRatio,errordataDownRatio,errordataUpRatio);

	Ratio->Draw("");

	Ratio->GetXaxis()->SetLabelFont(42);
	Ratio->GetXaxis()->SetTitleFont(42);
	Ratio->GetYaxis()->SetNdivisions(505);
	Ratio->GetYaxis()->SetLabelFont(42);
	Ratio->GetYaxis()->SetLabelSize(0.122);
	Ratio->GetYaxis()->SetRangeUser(ymin,ymax);
	Ratio->GetXaxis()->SetRangeUser(xmin,xmax);
	Ratio->GetXaxis()->SetLabelSize(0.12);
	Ratio->GetXaxis()->SetLabelFont(42);
	Ratio->SetYTitle("#frac{Data-Bkgd (fit)  }{Bkgd (fit)}");
	Ratio->SetXTitle(Xaxis);
	Ratio->GetXaxis()->SetNdivisions(505);
	Ratio->GetYaxis()->CenterTitle(true);
	Ratio->GetYaxis()->SetTitleOffset(0.4);
	Ratio->GetYaxis()->SetTitleSize(0.11);
	Ratio->GetXaxis()->SetTitleOffset(0.8);
	Ratio->GetXaxis()->SetTitleSize(0.20);
	Ratio->SetMarkerSize(1.);


	RatioError->Draw("sames,E2"); RatioError->SetFillStyle(3002); RatioError->SetFillColor(kGray+2); RatioError->SetMarkerSize(0);

	//	dataGraphRatio->Draw("sames,p");

	TCanvas *c2 = new TCanvas("canvas_"+name+"_2","canvas_"+name+"_2");
	TH1F* SUBTRACTEDMCERROR=fullMC2->Clone(); SUBTRACTEDMCERROR->SetName("SUBTRACTEDMCERROR");
	for (int i=0; i<SUBTRACTEDMCERROR->GetNbinsX()+1; i++) SUBTRACTEDMCERROR->SetBinContent(i,0);
	SUBTRACTEDMCERROR->SetFillColor(kYellow+4);
	SUBTRACTEDMCERROR->SetFillStyle(3004);
	SUBTRACTEDMCERROR->SetLineWidth(2);
	TH1F* SUBTRACTED=hdata_obs->Clone(); SUBTRACTED->SetName("SUBTRACTED");

	//	const int entriesD=(const)SUBTRACTEDMCERROR->GetNbinsX();
	double data[16];
	double mc[16];
	double errordataUp[16];
	double errordataDown[16];
	double xbins[16];
	double xerrorbins[16];

	for (int j=0; j<16; j++){
		xbins[j]=300./15*(j-1)+10;
		xerrorbins[j]=10;
		data[j]=SUBTRACTED->GetBinContent(j);
		errordataUp[j]=SUBTRACTED->GetBinError(j);
		errordataDown[j]=SUBTRACTED->GetBinError(j);
		if(data[j]==0) {errordataUp[j]=1.7; errordataDown[j]=0;}
		mc[j]=fullMC2->GetBinContent(j);
		data[j]-=mc[j];
	}

	TGraphAsymmErrors* dataGraph=new TGraphAsymmErrors(16, xbins, data,xerrorbins,xerrorbins,errordataDown,errordataUp);
	//dataGraph->SetMarkerColor(kRed);	

	SUBTRACTED->Add(fullMC2,-1);
	for (int i=0; i<SUBTRACTED->GetNbinsX()+1; i++) SUBTRACTED->SetBinError(i,hdata_obs->GetBinError(i));
	TH1F *hSignalFill=hSignal->Clone(); hSignalFill->SetName("hSignalFill");
	hSignalFill->SetFillColor(kBlue-10);
	hSignalFill->SetFillStyle(1001);
	hSignalFill->SetLineWidth(2);
	hSignalFill->Draw("hist");
        hSignalFill->SetLineStyle(1);

	hSignalFill->SetXTitle(Xaxis);
	SUBTRACTED->SetXTitle(Xaxis);
	SUBTRACTED->SetYTitle(Yaxis);
	hSignalFill->SetYTitle(Yaxis);

	hSignalFill->GetXaxis()->SetRangeUser(xmin,xmax);
	SUBTRACTED->GetXaxis()->SetRangeUser(xmin,xmax);
	SUBTRACTEDMCERROR->GetXaxis()->SetRangeUser(xmin,xmax);
	SUBTRACTEDMCERROR->SetXTitle(Xaxis);
	SUBTRACTEDMCERROR->SetYTitle(Yaxis);
	//hSignalFill->SetYTitle(Yaxis);
	SUBTRACTEDMCERROR->Draw("sames,E2");
	//SUBTRACTED->Draw("sames");
	dataGraph->Draw("sames,p");
	SUBTRACTEDMCERROR->GetXaxis()->SetNdivisions(505);
	SUBTRACTED->GetXaxis()->SetNdivisions(505);
	hSignalFill->GetXaxis()->SetNdivisions(505);
	SUBTRACTEDMCERROR->GetXaxis()->SetLabelSize(0.04);
	SUBTRACTED->GetXaxis()->SetLabelSize(0.04);
	hSignalFill->GetXaxis()->SetLabelSize(0.04);
	SUBTRACTEDMCERROR->GetYaxis()->SetLabelSize(0.04);
	SUBTRACTED->GetYaxis()->SetLabelSize(0.04);
	hSignalFill->GetYaxis()->SetLabelSize(0.04);
	SUBTRACTEDMCERROR->GetYaxis()->SetTitleSize(0.05);
	SUBTRACTED->GetYaxis()->SetTitleSize(0.05);
	hSignalFill->GetYaxis()->SetTitleSize(0.05);

	if(minsubs==-1)
		minsubs=TMath::Min(hSignalFill->GetMinimum(),SUBTRACTED->GetMinimum())*2.5;
	if(maxsubs==-1)
		maxsubs=TMath::Max(hSignalFill->GetMaximum(),SUBTRACTED->GetMaximum())*1.2;
	hSignalFill->SetMaximum(maxsubs);
	hSignalFill->SetMinimum(minsubs);

	if(minsubs==-1)
		minsubs=TMath::Min(SUBTRACTEDMCERROR->GetMinimum(),SUBTRACTED->GetMinimum())*2.5;
	if(maxsubs==-1)
		maxsubs=TMath::Max(SUBTRACTEDMCERROR->GetMaximum(),SUBTRACTED->GetMaximum())*1.2;
	SUBTRACTEDMCERROR->SetMaximum(maxsubs);
	SUBTRACTEDMCERROR->SetMinimum(minsubs);
	SUBTRACTED->SetMaximum(maxsubs);
	SUBTRACTED->SetMinimum(minsubs);




	TLegend *leg2 = new TLegend(0.55,0.93,0.99,0.7,NULL,"brNDC");
	leg2->SetFillColor(0);
	leg2->SetBorderSize(0);
	leg2->SetFillStyle(0);
	TLegendEntry *entry;
	//	entry=leg2->AddEntry("NULL",channelName,"");
	entry=leg2->AddEntry(hSignalFill,"LFV H#rightarrow#mu#tau signal (B=0.9%)","f");
	entry=leg2->AddEntry(SUBTRACTEDMCERROR,"Bkgd. uncertainty","f");
	entry=leg2->AddEntry(SUBTRACTED,"Data-Bkgd","pl");

	leg2->Draw();

        CMS_lumi( c2, iPeriod, iPos );

	c2->SaveAs(name+"_Subtracted.png");
	c2->SaveAs(name+"_Subtracted.pdf");

	if(!setLogY){
		c1->SaveAs(name+".png");
		c1->SaveAs(name+".pdf");
	}
	else {
		c1->SaveAs(name+"_log.png");
		c1->SaveAs(name+"_log.pdf");
	}

}
void EfficiencyByEta_vs_Lz()
{
//=========Macro generated from canvas: eta_lz/eta_lz
//=========  (Tue Apr  5 07:29:20 2016) by ROOT version6.02/05
   TCanvas *eta_lz = new TCanvas("eta_lz", "eta_lz",0,0,700,500);
   eta_lz->Range(-6.5625,-0.125,41.5625,1.125);
   eta_lz->SetFillColor(0);
   eta_lz->SetBorderMode(0);
   eta_lz->SetBorderSize(2);
   eta_lz->SetFrameBorderMode(0);
   eta_lz->SetFrameBorderMode(0);
   
   TMultiGraph *multigraph = new TMultiGraph();
   multigraph->SetName("");
   multigraph->SetTitle("");
   
   Double_t divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_fx3001[10] = {
   1,
   3,
   5,
   7,
   9,
   11,
   14,
   17,
   19,
   22.5};
   Double_t divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_fy3001[10] = {
   0.9255811,
   0.887184,
   0.8789174,
   0.8852085,
   0.8950226,
   0.8479381,
   0.7993119,
   0.7869822,
   0.7105263,
   0.5384615};
   Double_t divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_felx3001[10] = {
   1,
   1,
   1,
   1,
   1,
   1,
   2,
   1,
   1,
   2.5};
   Double_t divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_fely3001[10] = {
   0.001480903,
   0.00433367,
   0.006472957,
   0.00813138,
   0.01004846,
   0.01400104,
   0.0144885,
   0.03622352,
   0.06131092,
   0.1720041};
   Double_t divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_fehx3001[10] = {
   1,
   1,
   1,
   1,
   1,
   1,
   2,
   1,
   1,
   2.5};
   Double_t divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_fehy3001[10] = {
   0.001454562,
   0.00419584,
   0.006195321,
   0.007675046,
   0.009298784,
   0.01306018,
   0.01377348,
   0.03252222,
   0.05512412,
   0.1648473};
   TGraphAsymmErrors *grae = new TGraphAsymmErrors(10,divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_fx3001,divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_fy3001,divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_felx3001,divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_fehx3001,divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_fely3001,divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ_fehy3001);
   grae->SetName("divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ");
   grae->SetTitle("num_LEp8_1D_A0_LZ");

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#ff0000");
   grae->SetLineColor(ci);

   ci = TColor::GetColor("#ff0000");
   grae->SetMarkerColor(ci);
   grae->SetMarkerStyle(2);
   
   TH1F *Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001 = new TH1F("Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001","num_LEp8_1D_A0_LZ",100,0,27.5);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->SetMinimum(0.3103996);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->SetMaximum(0.9830935);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->SetDirectory(0);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->SetLineColor(ci);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetXaxis()->SetLabelFont(42);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetXaxis()->SetLabelSize(0.035);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetXaxis()->SetTitleSize(0.035);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetXaxis()->SetTitleFont(42);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetYaxis()->SetLabelFont(42);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetYaxis()->SetLabelSize(0.035);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetYaxis()->SetTitleSize(0.035);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetYaxis()->SetTitleFont(42);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetZaxis()->SetLabelFont(42);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetZaxis()->SetLabelSize(0.035);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetZaxis()->SetTitleSize(0.035);
   Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_divide_num_LEp8_1D_A0_LZ_by_den_LEp8_1D_A0_LZ3001);
   
   multigraph->Add(grae,"");
   
   Double_t divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_fx3002[12] = {
   1,
   3,
   5,
   7,
   9,
   11,
   14,
   17,
   19,
   22.5,
   27.5,
   32.5};
   Double_t divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_fy3002[12] = {
   0.9399291,
   0.9001285,
   0.8902202,
   0.8792473,
   0.8573519,
   0.8445122,
   0.8166895,
   0.7649485,
   0.7375,
   0.7456576,
   0.6967871,
   0.7176871};
   Double_t divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_felx3002[12] = {
   1,
   1,
   1,
   1,
   1,
   1,
   2,
   1,
   1,
   2.5,
   2.5,
   2.5};
   Double_t divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_fely3002[12] = {
   0.001405873,
   0.004229466,
   0.005917511,
   0.007916015,
   0.01009448,
   0.01242246,
   0.01068294,
   0.02084312,
   0.0238508,
   0.01626845,
   0.02199496,
   0.02869559};
   Double_t divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_fehx3002[12] = {
   1,
   1,
   1,
   1,
   1,
   1,
   2,
   1,
   1,
   2.5,
   2.5,
   2.5};
   Double_t divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_fehy3002[12] = {
   0.001376087,
   0.004079244,
   0.005657549,
   0.007505729,
   0.00955166,
   0.01169187,
   0.01023525,
   0.01969351,
   0.02259777,
   0.01563471,
   0.02116716,
   0.02712215};
   grae = new TGraphAsymmErrors(12,divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_fx3002,divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_fy3002,divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_felx3002,divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_fehx3002,divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_fely3002,divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ_fehy3002);
   grae->SetName("divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ");
   grae->SetTitle("num_LEp8_1D_A1_LZ");
   grae->SetMarkerStyle(2);
   
   TH1F *Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002 = new TH1F("Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002","num_LEp8_1D_A1_LZ",100,0,38.5);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->SetMinimum(0.6481409);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->SetMaximum(0.9679565);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->SetDirectory(0);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->SetLineColor(ci);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetXaxis()->SetLabelFont(42);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetXaxis()->SetLabelSize(0.035);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetXaxis()->SetTitleSize(0.035);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetXaxis()->SetTitleFont(42);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetYaxis()->SetLabelFont(42);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetYaxis()->SetLabelSize(0.035);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetYaxis()->SetTitleSize(0.035);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetYaxis()->SetTitleFont(42);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetZaxis()->SetLabelFont(42);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetZaxis()->SetLabelSize(0.035);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetZaxis()->SetTitleSize(0.035);
   Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_divide_num_LEp8_1D_A1_LZ_by_den_LEp8_1D_A1_LZ3002);
   
   multigraph->Add(grae,"");
   
   Double_t divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_fx3003[12] = {
   1,
   3,
   5,
   7,
   9,
   11,
   14,
   17,
   19,
   22.5,
   27.5,
   32.5};
   Double_t divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_fy3003[12] = {
   0.9226259,
   0.8929907,
   0.878169,
   0.835122,
   0.8467742,
   0.8478632,
   0.8158954,
   0.7928389,
   0.7811634,
   0.735119,
   0.7272727,
   0.6801802};
   Double_t divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_felx3003[12] = {
   1,
   1,
   1,
   1,
   1,
   1,
   2,
   1,
   1,
   2.5,
   2.5,
   2.5};
   Double_t divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_fely3003[12] = {
   0.003328733,
   0.007105987,
   0.009308612,
   0.01241554,
   0.01436289,
   0.0163258,
   0.01312262,
   0.02254821,
   0.02394814,
   0.01811984,
   0.0258094,
   0.03434908};
   Double_t divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_fehx3003[12] = {
   1,
   1,
   1,
   1,
   1,
   1,
   2,
   1,
   1,
   2.5,
   2.5,
   2.5};
   Double_t divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_fehy3003[12] = {
   0.003205148,
   0.006725961,
   0.008754592,
   0.01173451,
   0.01338404,
   0.01506936,
   0.0124614,
   0.02095935,
   0.02229414,
   0.01739016,
   0.02444323,
   0.032614};
   grae = new TGraphAsymmErrors(12,divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_fx3003,divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_fy3003,divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_felx3003,divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_fehx3003,divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_fely3003,divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ_fehy3003);
   grae->SetName("divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ");
   grae->SetTitle("num_Gp8_1D_A0_LZ");

   ci = TColor::GetColor("#ff0000");
   grae->SetLineColor(ci);
   grae->SetLineStyle(2);

   ci = TColor::GetColor("#ff0000");
   grae->SetMarkerColor(ci);
   grae->SetMarkerStyle(2);
   
   TH1F *Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003 = new TH1F("Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003","num_Gp8_1D_A0_LZ",100,0,38.5);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->SetMinimum(0.6178311);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->SetMaximum(0.953831);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->SetDirectory(0);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->SetLineColor(ci);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetXaxis()->SetLabelFont(42);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetXaxis()->SetLabelSize(0.035);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetXaxis()->SetTitleSize(0.035);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetXaxis()->SetTitleFont(42);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetYaxis()->SetLabelFont(42);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetYaxis()->SetLabelSize(0.035);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetYaxis()->SetTitleSize(0.035);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetYaxis()->SetTitleFont(42);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetZaxis()->SetLabelFont(42);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetZaxis()->SetLabelSize(0.035);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetZaxis()->SetTitleSize(0.035);
   Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_divide_num_Gp8_1D_A0_LZ_by_den_Gp8_1D_A0_LZ3003);
   
   multigraph->Add(grae,"");
   
   Double_t divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_fx3004[12] = {
   1,
   3,
   5,
   7,
   9,
   11,
   14,
   17,
   19,
   22.5,
   27.5,
   32.5};
   Double_t divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_fy3004[12] = {
   0.9385068,
   0.9029813,
   0.8920233,
   0.8859935,
   0.8653061,
   0.8677419,
   0.8693467,
   0.7536232,
   0.7717391,
   0.7142857,
   0.7833333,
   0.7941176};
   Double_t divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_felx3004[12] = {
   1,
   1,
   1,
   1,
   1,
   1,
   2,
   1,
   1,
   2.5,
   2.5,
   2.5};
   Double_t divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_fely3004[12] = {
   0.002317847,
   0.007117628,
   0.01056605,
   0.01430681,
   0.01723106,
   0.02212471,
   0.0191375,
   0.0421842,
   0.05225554,
   0.0459041,
   0.06646625,
   0.09317978};
   Double_t divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_fehx3004[12] = {
   1,
   1,
   1,
   1,
   1,
   1,
   2,
   1,
   1,
   2.5,
   2.5,
   2.5};
   Double_t divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_fehy3004[12] = {
   0.002240421,
   0.00669502,
   0.009765471,
   0.01297094,
   0.0156433,
   0.01955835,
   0.01714648,
   0.03816421,
   0.04566168,
   0.04218646,
   0.05566409,
   0.07263947};
   grae = new TGraphAsymmErrors(12,divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_fx3004,divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_fy3004,divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_felx3004,divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_fehx3004,divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_fely3004,divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ_fehy3004);
   grae->SetName("divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ");
   grae->SetTitle("num_Gp8_1D_A1_LZ");
   grae->SetLineStyle(2);
   grae->SetMarkerStyle(2);
   
   TH1F *Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004 = new TH1F("Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004","num_Gp8_1D_A1_LZ",100,0,38.5);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->SetMinimum(0.6411451);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->SetMaximum(0.9679838);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->SetDirectory(0);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->SetLineColor(ci);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetXaxis()->SetLabelFont(42);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetXaxis()->SetLabelSize(0.035);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetXaxis()->SetTitleSize(0.035);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetXaxis()->SetTitleFont(42);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetYaxis()->SetLabelFont(42);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetYaxis()->SetLabelSize(0.035);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetYaxis()->SetTitleSize(0.035);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetYaxis()->SetTitleFont(42);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetZaxis()->SetLabelFont(42);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetZaxis()->SetLabelSize(0.035);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetZaxis()->SetTitleSize(0.035);
   Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_divide_num_Gp8_1D_A1_LZ_by_den_Gp8_1D_A1_LZ3004);
   
   multigraph->Add(grae,"");
   multigraph->Draw("ALP");
   multigraph->GetXaxis()->SetTitle("L_{Z} [cm]");
   multigraph->GetXaxis()->SetLabelFont(42);
   multigraph->GetXaxis()->SetLabelSize(0.035);
   multigraph->GetXaxis()->SetTitleSize(0.035);
   multigraph->GetXaxis()->SetTitleFont(42);
   multigraph->GetYaxis()->SetTitle("Efficiency");
   multigraph->GetYaxis()->SetLabelFont(42);
   multigraph->GetYaxis()->SetLabelSize(0.035);
   multigraph->GetYaxis()->SetTitleSize(0.035);
   multigraph->GetYaxis()->SetTitleFont(42);
   TLine *line = new TLine(34.5,0,34.5,1);

   ci = TColor::GetColor("#0000ff");
   line->SetLineColor(ci);
   line->SetLineStyle(2);
   line->Draw();
   line = new TLine(46.5,0,46.5,1);

   ci = TColor::GetColor("#0000ff");
   line->SetLineColor(ci);
   line->SetLineStyle(2);
   line->Draw();
   
   TLegend *leg = new TLegend(0.6982759,0.6701903,0.8979885,0.8794926,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.03171247);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("divide_num_LEp8_1D_A0_LXY_by_den_LEp8_1D_A0_LXY","|#eta_{#gamma D}| #leq 0.8 A0","L");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("divide_num_Gp8_1D_A0_LXY_by_den_Gp8_1D_A0_LXY","|#eta_{#gamma D}| > 0.8 A0","L");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(2);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("divide_num_LEp8_1D_A1_LXY_by_den_LEp8_1D_A1_LXY","|#eta_{#gamma D}| #leq 0.8 A1","L");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("divide_num_Gp8_1D_A1_LXY_by_den_Gp8_1D_A1_LXY","|#eta_{#gamma D}| > 0.8 A1","L");
   entry->SetLineColor(1);
   entry->SetLineStyle(2);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   eta_lz->Modified();
   eta_lz->cd();
   eta_lz->SetSelected(eta_lz);
}
Example #23
0
void DrawQCDClosure(TString VAR,int NBINS,float XMIN,float XMAX,TString XTITLE)
{
  gROOT->ForceStyle();
  
  const int N = 11;
  float XSEC[N] = {471100.,117276.,7823.,648.2,186.9,32.293,9.4183,0.84265,0.114943,0.00682981,0.000165445};

  TString SAMPLE[N] = {
    "QCD_Pt_120to170",
    "QCD_Pt_170to300",
    "QCD_Pt_300to470",
    "QCD_Pt_470to600",
    "QCD_Pt_600to800",
    "QCD_Pt_800to1000",
    "QCD_Pt_1000to1400",
    "QCD_Pt_1400to1800",
    "QCD_Pt_1800to2400",
    "QCD_Pt_2400to3200",
    "QCD_Pt_3200toInf" 
  }; 

  TFile *inf[N];
  TTree *tr0[N],*tr1[N],*tr2[N];
  TH1F  *h0[N],*h1[N],*h2[N];

  TCanvas *can = new TCanvas("can_QCDClosure_"+VAR,"can_QCDClosure_"+VAR,900,600);
  can->cd(1);
  can->SetBottomMargin(0.3);
  can->SetRightMargin(0.15);

  for(int i=0;i<N;i++) {
    inf[i] = TFile::Open("flatTree_"+SAMPLE[i]+".root");
    tr0[i] = (TTree*)inf[i]->Get("hadtopNoBtag/events");
    tr1[i] = (TTree*)inf[i]->Get("hadtopOneBtag/events");
    tr2[i] = (TTree*)inf[i]->Get("hadtop/events");
    TH1F *hpu = (TH1F*)inf[i]->Get("hadtop/pileup");
    h0[i]  = new TH1F("h0_"+SAMPLE[i],"h0_"+SAMPLE[i],NBINS,XMIN,XMAX);
    h1[i]  = new TH1F("h1_"+SAMPLE[i],"h1_"+SAMPLE[i],NBINS,XMIN,XMAX);
    h2[i]  = new TH1F("h2_"+SAMPLE[i],"h2_"+SAMPLE[i],NBINS,XMIN,XMAX);
    h0[i]->Sumw2();
    h1[i]->Sumw2();
    h2[i]->Sumw2();
    tr0[i]->Draw(VAR+">>"+"h0_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets==0 && dRbbTop>2");
    tr1[i]->Draw(VAR+">>"+"h1_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets==1 && dRbbTop>2");
    tr2[i]->Draw(VAR+">>"+"h2_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets>1 && dRbbTop>2");
    h0[i]->Scale(XSEC[i]/hpu->GetEntries());
    h1[i]->Scale(XSEC[i]/hpu->GetEntries());
    h2[i]->Scale(XSEC[i]/hpu->GetEntries()); 
    cout<<SAMPLE[i]<<" "<<hpu->GetEntries()<<" "<<h0[i]->GetEntries()<<" "<<h1[i]->GetEntries()<<" "<<h2[i]->GetEntries()<<endl;
  }

  TH1F *hQCD0 = (TH1F*)h0[0]->Clone("hQCD0");
  TH1F *hQCD1 = (TH1F*)h1[0]->Clone("hQCD1");
  TH1F *hQCD2 = (TH1F*)h2[0]->Clone("hQCD2");

  for(int i=1;i<N;i++) {
    hQCD0->Add(h0[1]);
    hQCD1->Add(h1[1]);
    hQCD2->Add(h2[1]);
  }  
   
  hQCD0->SetFillColor(kGray);
  hQCD1->SetLineColor(kBlack);
  hQCD1->SetMarkerColor(kBlack);
  hQCD1->SetMarkerStyle(21);
  hQCD2->SetLineColor(kRed);
  hQCD2->SetMarkerColor(kRed);
  hQCD2->SetMarkerStyle(20);

  hQCD0->Scale(1./hQCD0->Integral());
  hQCD1->Scale(1./hQCD1->Integral());
  hQCD2->Scale(1./hQCD2->Integral());

  hQCD0->GetXaxis()->SetLabelSize(0.0);
  double max = 1.1*TMath::Max(hQCD0->GetBinContent(hQCD0->GetMaximumBin()),hQCD2->GetBinContent(hQCD2->GetMaximumBin()));
  hQCD0->SetMinimum(1e-5);
  hQCD0->SetMaximum(max);
  hQCD0->Draw("hist");
  hQCD1->Draw("sameE");
  hQCD2->Draw("sameE");
  gPad->RedrawAxis();

  TLegend *leg = new TLegend(0.86,0.65,0.99,0.9);
  leg->SetFillColor(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);
  leg->AddEntry(hQCD0,"Zero btag","F");
  leg->AddEntry(hQCD1,"One btag","LP");
  leg->AddEntry(hQCD2,"Two btag","LP");
  leg->Draw();

  TH1F *hRatio0 = (TH1F*)hQCD2->Clone("Ratio0");
  hRatio0->Divide(hQCD0);
  TH1F *hRatio1 = (TH1F*)hQCD2->Clone("Ratio1");
  hRatio1->Divide(hQCD1);

  hRatio0->SetLineColor(kBlack);
  hRatio0->SetMarkerColor(kBlack);

  TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
  pad->SetTopMargin(0.7);
  pad->SetRightMargin(0.15);
  pad->SetFillColor(0);
  pad->SetFillStyle(0);
  pad->Draw();
  pad->cd(0);
  gPad->SetGridy();
  hRatio0->GetXaxis()->SetTitle(XTITLE);
  hRatio0->GetYaxis()->SetNdivisions(505);
  hRatio0->GetYaxis()->SetRangeUser(0,2);
  hRatio0->GetYaxis()->SetLabelSize(0.04);
  hRatio0->Draw();
  hRatio1->Draw("same");
}
TCanvas* overlay_Merged_RecoSmeared(const vector<string>& folders, 
								const hist_t& h, const string njets =""
								)
{

	TLegend *leg  = new TLegend(0.6,0.65,0.9,0.9);
	leg->SetTextFont(42);
	vector<TH1*> hists;
	
	vector<string> jetcoll;
	jetcoll.push_back("reco");
	jetcoll.push_back("gen");
	jetcoll.push_back("smeared");

	stringstream title;
	//const string njets("3-5");
	//const string eta("2.5");
	const string eta("2.5");
	title << njets
			<< "#geq 3 Jets, HT>0 GeV, MHT>0 GeV" << ", L = 10 fb^{-1}" << ";" << h.title ;

	for (unsigned j=0; j< jetcoll.size(); ++j)
	{
		TH1* Hist = 0;
		for (unsigned i = 0; i < folders.size(); ++i)
		{
			stringstream histname;
			histname << folders.at(i) << "/" << jetcoll.at(j) << h.name;
			cout << __LINE__ << ": Looking for hist: " << histname.str().c_str() << endl;
			TH1* htemp = GetHist(histname.str());
			
			if (Hist == 0) Hist = htemp;
			else Hist->Add(htemp);
		}
		
		Hist->Rebin(h.rebin);
		Hist->SetTitle(title.str().c_str());
		Hist->SetMarkerStyle(20+j);
		Hist->SetLineWidth(2);
		Hist->SetStats(0);

		stringstream legname;
		if (j==0) 
		{
			legname << "Reco"; 
		} else if (j==1) 
		{
			legname << "Gen"; 
			Hist->SetLineColor(kBlue);
			Hist->SetMarkerColor(kBlue);
		} else if (j==2)
		{
			legname << "Smeared"; 
			Hist->SetLineColor(kRed);
			Hist->SetMarkerColor(kRed);
		}

		const double sum = Hist->Integral(); 
		legname << " (" << sum << ")";
		if (j!=1) leg->AddEntry(Hist, legname.str().c_str());

		hists.push_back(Hist);

	} //end jetcoll
	
	TH1* ratio = dynamic_cast<TH1*> (hists.at(2)->Clone("ratio"));
	ratio->GetYaxis()->SetTitle("Smeared/Reco");
	ratio->SetTitle("");
	ratio->Add(hists.at(0),-1);
	ratio->Divide(hists.at(0));
	ratio->GetYaxis()->SetRangeUser(-0.99,0.99);
	//ratio->SetTickLength (+0.01,"Y");

   //TCanvas *c1 = new TCanvas("c1", "c1",15,60,550,600);
   TCanvas *c1 = new TCanvas("c1");
   c1->Range(0,0,1,1);
   c1->SetBorderSize(2);
   c1->SetFrameFillColor(0);
  
// ------------>Primitives in pad: c1_1
   TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.30,0.99,0.99);
   c1_1->Draw();
   c1_1->cd();
   c1_1->SetBorderSize(2);
   c1_1->SetTickx(1);
   c1_1->SetTicky(1);
   c1_1->SetTopMargin(0.1);
   c1_1->SetBottomMargin(0.0);
   //c1_1->SetFrameFillColor(3);
	c1_1->SetLogy();
   
	hists.at(0)->GetYaxis()->CenterTitle(1);
	hists.at(0)->SetLabelFont(42,"XYZ");
	hists.at(0)->SetTitleFont(42,"XYZ");
	hists.at(0)->GetYaxis()->SetTitleOffset(0.8);
	hists.at(0)->SetLabelSize(0.05,"XYZ");
	hists.at(0)->SetTitleSize(0.06,"XYZ");
   hists.at(0)->Draw("P");
   hists.at(2)->Draw("same P");
	leg->Draw();

   c1_1->Modified();
   c1->cd();
  
// ------------>Primitives in pad: c1_2
   TPad *c1_2 = new TPad("c1_2", "c1_2",0.01,0.01,0.99,0.30);
   c1_2->Draw();
   c1_2->cd();
   c1_2->SetBorderSize(2);
   c1_2->SetTickx(1);
   c1_2->SetTicky(1);
   c1_2->SetTopMargin(0.0);
   c1_2->SetBottomMargin(0.24);
   c1_2->SetFrameFillColor(0);
	c1_2->SetGridx();
	c1_2->SetGridy();
   
	ratio->GetYaxis()->SetTitleOffset(0.4);
	ratio->GetXaxis()->SetTitleOffset(0.9);
	ratio->GetYaxis()->CenterTitle(1);
	ratio->GetXaxis()->CenterTitle(1);
	ratio->SetLabelSize(0.125,"XYZ");
	ratio->SetTitleSize(0.125,"XYZ");
//	ratio->SetLabelFont(labelfont,"XYZ");
//	ratio->SetTitleFont(titlefont,"XYZ");
   ratio->GetXaxis()->SetTickLength(0.07);
   ratio->Draw("");
   
   c1_2->Modified();
   c1->cd();
   //c1->Modified();
   //c1->cd();
   //c1->SetSelected(c1);
	return c1;

}
Example #25
0
TLegend *getLegend( vector<TChain*> chmc , vector<char*> labels , bool overlayData, float x1, float y1, float x2, float y2){

  //int colors[]={6,2,7,4,5,8,9,15,12};
  int colors[]={kBlue-6,kRed+2,7,5,5,8,9,15,12};
  
  TLegend *leg = new TLegend(x1,y1,x2,y2);

  TH1F*    datahist = new TH1F("datahist","datahist",1,0,1);
  datahist->Sumw2();

  if( overlayData ) leg->AddEntry(datahist,"data");

  const int nmc = chmc.size();
  TH1F*    mchist[nmc];

  //-----------------
  // SM samples
  //-----------------

  //for( unsigned int imc = 0 ; imc < nmc ; imc++ ){
  for( int imc = nmc - 1 ; imc >= 0 ; imc-- ){

    char* t = labels.at(imc);

    if( TString(t).Contains("LM") )   continue;
    if( TString(t).Contains("T2tt") ) continue;

    mchist[imc] = new TH1F(Form("mc_%i",imc),Form("mc_%i",imc),1,0,1);

    if( TString( labels.at(imc) ).Contains("LM") || TString( labels.at(imc) ).Contains("LM") ){
      mchist[imc]->SetFillColor( 0 );
      mchist[imc]->SetLineStyle(2);
    }else{
      mchist[imc]->SetFillColor( colors[imc] );
    }

    if( strcmp("tt",t)      == 0 ) t = "t#bar{t}";
    if( strcmp("ttll",t)    == 0 ) t = "t#bar{t} #rightarrow ll";
    if( strcmp("tttau",t)   == 0 ) t = "t#bar{t} #rightarrow l#tau/#tau#tau";
    if( strcmp("ttfake",t)  == 0 ) t = "t#bar{t} #rightarrow fake";
    if( strcmp("t",t)       == 0 ) t = "single top";
    if( strcmp("wjets",t)   == 0 ) t = "W+jets";
    if( strcmp("zjets",t)   == 0 ) t = "Z+jets";
    if( strcmp("ww",t)      == 0 ) t = "W^{+}W^{-}";
    if( strcmp("wz",t)      == 0 ) t = "W^{#pm}Z^{0}";
    if( strcmp("zz",t)      == 0 ) t = "Z^{0}Z^{0}";

    //leg->AddEntry(mchist[imc],labels.at(imc),"f");
    leg->AddEntry(mchist[imc],t,"f");
    
  }

  //-----------------
  // LM samples
  //-----------------

  //for( unsigned int imc = 0 ; imc < nmc ; imc++ ){
  for( int imc = nmc - 1 ; imc >= 0 ; imc-- ){

    char* t = labels.at(imc);

    if( ! (TString(t).Contains("LM")||TString(t).Contains("T2tt")) )   continue;

    mchist[imc] = new TH1F(Form("mc_%i",imc),Form("mc_%i",imc),1,0,1);

    if( TString( labels.at(imc) ).Contains("LM") || TString( labels.at(imc) ).Contains("T2tt") ){
      mchist[imc]->SetFillColor( 0 );
      mchist[imc]->SetLineStyle(2);
    }else{
      mchist[imc]->SetFillColor( colors[imc] );
    }

    if( strcmp("ttall",t) == 0 ) t = "t#bar{t}";
    if( strcmp("t",t)     == 0 ) t = "single top";
    if( strcmp("wjets",t) == 0 ) t = "W+jets";
    if( strcmp("WW",t)    == 0 ) t = "W^{+}W^{-}";
    if( strcmp("WZ",t)    == 0 ) t = "W^{#pm}Z^{0}";
    if( strcmp("ZZ",t)    == 0 ) t = "Z^{0}Z^{0}";

    //leg->AddEntry(mchist[imc],labels.at(imc),"f");
    leg->AddEntry(mchist[imc],t,"f");
    
  }

  leg->SetFillColor(0);
  leg->SetBorderSize(0);
  
  return leg;

}
Example #26
0
void CombineDiffcheckBump(Display_t dis = kJet)
{

  

    if(dis==kTrack){
        double etaMin = -1.0;
        double etaMax = 1.0 ;
    }
    else {
        double etaMin = -1.0;
        double etaMax = 1.0 ;
    }
  double etaMinRev = -etaMax;
  double etaMaxRev = -etaMin;
  
   TString algo ="akPu3PF"; //"AkPu3PF" ;
//   TString residual = "NoResidual"; //"NoResidual" ;
//   TString shiftType = "hong_2minus_";
TString JetID="";
    const int Nfile = 6 ;
    TFile * f[Nfile] ;
    
    TString plotsdir = "/afs/cern.ch/user/h/honi/CMSSW_5_3_8_HI_patch2/RpA/EnergyScale/merge";
    const char * kHomeDir = "/home/xuq7/CMSSW_6_2_3_patch1/src/jetRpA/RpA/output/JetTrig/JetID/NoResidual";

  f[0] =  TFile::Open(Form("%s/DATAPPb_MB%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_mergedMB_pPb_SingleTrack_Full_UsingKKForest_v1.root", kHomeDir,algo.Data()), "readonly");
  f[1] =  TFile::Open(Form("%s/DATAPPb_Jet20%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_mergedJet20_pPb_Jet20_Full_UsingKKForest_v1.root", kHomeDir, algo.Data()), "readonly");
  f[2] =  TFile::Open(Form("%s/DATAPPb_Jet40%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_mergedJet40Jet60_pPb_Jet40Jet60_Full_UsingKKForest_v1.root", kHomeDir, algo.Data()), "readonly");
  f[3] =  TFile::Open(Form("%s/DATAPPb_Jet60%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_mergedJet40Jet60_pPb_Jet40Jet60_Full_UsingKKForest_v1.root", kHomeDir, algo.Data()), "readonly");
  f[4] =  TFile::Open(Form("%s/DATAPPb_Jet80%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_PA2013_HiForest_PromptReco_JSonPPb_forestv77.root", kHomeDir, algo.Data()), "readonly");
  f[5] =  TFile::Open(Form("%s/DATAPPb_Jet100%scheckBump30TrkEffHIN12017v5TrkCorr2DCut0EtaBin7_HFsumEta4Bin1_PA2013_HiForest_PromptReco_JSonPPb_forestv77.root", kHomeDir, algo.Data()), "readonly");

//  f[3] =  TFile::Open(Form("%s/%sDATAPPb_Jet60%sJet2013HistIterTrkCorrtest0EtaCut10_mergedJet40Jet60_KK.root", kHomeDir,shiftType.Data(), algo.Data()), "readonly");

 //  f[4] =  TFile::Open(Form("%s/%sDATAPPb_Jet80%sJet2013HistIterTrkCorrtest0EtaCut10_PA2013_HiForest_PromptReco_JSonPPb_forestv77.root", kHomeDir,shiftType.Data(), algo.Data()), "readonly");
    
 //  f[5] =  TFile::Open(Form("%s/%sDATAPPb_Jet100%sJet2013HistIterTrkCorrtest0EtaCut10_PA2013_HiForest_PromptReco_JSonPPb_forestv77.root", kHomeDir,shiftType.Data(), algo.Data()), "readonly");

  // array goes as 0=MB, 1=Trk12, 2=Trk20, 3=Trk30
        TH1D * hnevt[6];
        TH1D * hnevtNorm[5];
        
        hnevt[0] = (TH1D *) f[0]->Get("Nevents_0-100%");
        hnevt[1] = (TH1D *) f[1]->Get("NeventsWithJetAbove40_0-100%");
        hnevt[2] = (TH1D *) f[2]->Get("NeventsWithJetAbove60_0-100%");
        hnevt[3] = (TH1D *) f[3]->Get("NeventsWithJetAbove75_0-100%");
        hnevt[4] = (TH1D *) f[4]->Get("NeventsWithJetAbove95_0-100%");
        hnevt[5] = (TH1D *) f[5]->Get("NeventsWithJetAbove120_0-100%");
        
        hnevtNorm[0] = (TH1D *) f[0]->Get("NeventsWithJetAbove40_0-100%");
        hnevtNorm[1] = (TH1D *) f[1]->Get("NeventsWithJetAbove60_0-100%");
        hnevtNorm[2] = (TH1D *) f[2]->Get("NeventsWithJetAbove75_0-100%");
        hnevtNorm[3] = (TH1D *) f[3]->Get("NeventsWithJetAbove95_0-100%");
        hnevtNorm[4] = (TH1D *) f[4]->Get("NeventsWithJetAbove120_0-100%");
    
    // Calculate Nevt for each sample
    
    double nevt[6];
    
    // Adding the nevent histogram
    nevt[0] = hnevt[0]->Integral();
    nevt[1] = nevt[0] * hnevt[1]->Integral()/hnevtNorm[0]->Integral();
    nevt[2] = nevt[1] * hnevt[2]->Integral()/hnevtNorm[1]->Integral();
    nevt[3] = nevt[2] * hnevt[3]->Integral()/hnevtNorm[2]->Integral();
    nevt[4] = nevt[3] * hnevt[4]->Integral()/hnevtNorm[3]->Integral();
    nevt[5] = nevt[4] * hnevt[5]->Integral()/hnevtNorm[4]->Integral();

for(int ifile=0;ifile<Nfile;ifile++){
if(ifile!=Nfile-1){
cout<<ifile<<":"<<hnevt[ifile]->Integral()<<'\t'<<hnevtNorm[ifile]->Integral()<<'\t'<<nevt[ifile]<<endl;
cout<<ifile<<":"<<hnevt[ifile]->GetEntries()<<'\t'<<hnevtNorm[ifile]->GetEntries()<<'\t'<<nevt[ifile]<<endl;
}
else{
cout<<ifile<<":"<<hnevt[ifile]->Integral()<<'\t'<<nevt[ifile]<<endl;
cout<<ifile<<":"<<hnevt[ifile]->GetEntries()<<'\t'<<nevt[ifile]<<endl;
}
}


    TList * list[Nfile] ;
    int N ;
   for(int ifile=0; ifile<Nfile; ifile++){
        
        list[ifile] =(TList*)f[ifile]->GetListOfKeys();
        if(ifile==0){
            N = list[ifile]->GetEntries();
        }
    }
    const int Nhist = N ;
    TH1 * h[Nfile][Nhist];
    TH1 * htot[Nhist];
    for(int ifile=0; ifile<Nfile; ifile++){
        for(int ihist = 0 ; ihist < Nhist ; ihist++){
            h[ifile][ihist] = (TH1*)f[ifile]->Get(list[ifile]->At(ihist)->GetName()) ;
            //  h[ifile][ihist]->Sumw2();
            h[ifile][ihist]->Scale(1./nevt[ifile]);
        }
    }
    
    TString outname ;

    outname =Form("%sCombinedJetTrig%scheckBump.root",JetID.Data(), algo.Data());
    
    TFile * outf = new TFile(Form("%s/%s", kHomeDir, outname.Data()), "RECREATE");
   
    for(int ihist = 0 ; ihist < Nhist ; ihist++){
        
        for(int ifile=0; ifile<Nfile; ifile++){
            if(ifile==0)
                htot[ihist] = (TH1*)h[ifile][ihist]->Clone(Form("%s",list[ifile]->At(ihist)->GetName()));
            else
                htot[ihist]->Add(h[ifile][ihist]);
            
        }
        
        if(htot[ihist]->GetEntries()>0){
            htot[ihist]->Write();
        }
    }
    outf->Close() ;
    

    
  TH1F *hTrk[6];
    switch(dis){
        case kJet:
            if(TMath::Abs(etaMin)==1.){
                hTrk[0] = (TH1F*)f[0]->Get("jetpt_0-100%");
                hTrk[1] = (TH1F*)f[1]->Get("jetpt_0-100%");
                hTrk[2] = (TH1F*)f[2]->Get("jetpt_0-100%");
                hTrk[3] = (TH1F*)f[3]->Get("jetpt_0-100%");
                hTrk[4] = (TH1F*)f[4]->Get("jetpt_0-100%");
                hTrk[5] = (TH1F*)f[5]->Get("jetpt_0-100%");
            }
            else {
                hTrk[0] = (TH1F*)f[0]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
                hTrk[1] = (TH1F*)f[1]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
                hTrk[2] = (TH1F*)f[2]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
                hTrk[3] = (TH1F*)f[3]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
                hTrk[4] = (TH1F*)f[4]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
                hTrk[5] = (TH1F*)f[5]->Get(Form("jetptEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
            }
            
            break;
        case kTrack :
            if(TMath::Abs(etaMin)==TMath::Abs(etaMax)){
                hTrk[0] = (TH1F*)f[0]->Get("inclusivetrackptInEtaM1P1_0-100%");
                hTrk[1] = (TH1F*)f[1]->Get("inclusivetrackptInEtaM1P1_0-100%");
                hTrk[2] = (TH1F*)f[2]->Get("inclusivetrackptInEtaM1P1_0-100%");
                hTrk[3] = (TH1F*)f[3]->Get("inclusivetrackptInEtaM1P1_0-100%");
                hTrk[4] = (TH1F*)f[4]->Get("inclusivetrackptInEtaM1P1_0-100%");
                hTrk[5] = (TH1F*)f[5]->Get("inclusivetrackptInEtaM1P1_0-100%");
            }
            else {
                hTrk[0] = (TH1F*)f[0]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
                hTrk[1] = (TH1F*)f[1]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
                hTrk[2] = (TH1F*)f[2]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
                hTrk[3] = (TH1F*)f[3]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
                hTrk[4] = (TH1F*)f[4]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
                hTrk[5] = (TH1F*)f[5]->Get(Form("IncTrkEtaBin%.f_%.f_Cen0-100%%", etaMin*10, etaMax*10));
            }
            break ;
    }
 
  
    
    for( int i = 0; i<6; i++){
     normalizeByBinWidth(hTrk[i]);
//        hTrk[i]->Scale(1./(etaMax-etaMin));
    }
/////////////////////////////////////////////////////////////////////////////
    
  // Select Jet-Et Range


  // create 1D histos
  TH1F * hTrkPt[6];

  for( int i = 0; i<6; i++)
  {
     hTrkPt[i] = (TH1F*)hTrk[i]->Clone(Form("jetPt%d_%dInEtaBin%.f_%.f",trigRes[i],trigRes[i+1], etaMin*10, etaMax*10));
  //    hTrkPt[i]->Scale(1./nevt[i]);
  }
 
    // add together spectra
    TH1F * hCombined ;
    for( int i = 0; i<6; i++)
    {
       if(i==0) hCombined = (TH1F*)hTrkPt[i]->Clone(Form("CombinedSpectraInEtaBin%.f_%.f", etaMin*10, etaMax*10));
       else hCombined->Add(hTrkPt[i]);
    }
//    hCombined->Scale(2.);//
//    convertToInvYield(hCombined);//
  ////////////////////////////////////////////////////////////
    
  hCombined->SetMarkerStyle(20);

   TCanvas *c1 = new TCanvas("c1a", "c1",0,0,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);

   c1->Range(0,0,1,1);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   //c1->SetLogy();
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.13);
   c1->SetRightMargin(0.06);
   c1->SetTopMargin(0.05);
   c1->SetBottomMargin(0.16);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);

   //c1->Divide(1,2,0,0);
   c1->cd();
   c1->SetLogy();
  if(dis==kTrack) c1->SetLogx();
  // c1->SetLogy();
  // c1->SetLogx();

   if(dis==kTrack) TH1F * hDum = new TH1F("hhdum","",10,1.,210.);
    else TH1F * hDum = new TH1F("hhdum","",10,20.,320.);
    if(dis==kTrack) {
        hDum->SetMinimum(1e-12);
       hDum->SetMaximum(100);
    }
    else {
        hDum->SetMinimum(1e-11);
       hDum->SetMaximum(1.);
    }
   hDum->GetXaxis()->SetTitle("p_{T} [GeV/c]");
   hDum->GetXaxis()->SetTitleSize(0.035);
   hDum->GetXaxis()->SetTitleOffset(1.5);
   hDum->GetXaxis()->SetLabelSize(0.035);
    hDum->GetYaxis()->SetTitle("1/N_{evt} dN_{ch}/dp_{T}");//just normalize by binwidth
//   hDum->GetYaxis()->SetTitle("1/N_{evt} d^{2}N_{ch}/d_p{T}d#eta");
//    hhdum->GetYaxis()->SetTitle("1/N_{ev} 1/(2#pip_{T}) d^{2}N/dp_{T}d#eta");//invariant yield
   hDum->GetYaxis()->SetTitleSize(0.035);
   hDum->GetYaxis()->SetLabelSize(0.035);
   hDum->GetYaxis()->SetTitleOffset(1.5);
    hhdum->GetXaxis()->CenterTitle();
    hhdum->GetYaxis()->CenterTitle();

  hDum->Draw();
    hCombined->SetMarkerStyle(24);
    hCombined->SetMarkerColor(1);
    hCombined->SetMarkerSize(1.5);
    hCombined->SetLineColor(1);
  
  hCombined->DrawCopy("same");
    for( int i = 0; i<6; i++){
        hTrkPt[i]->SetMarkerStyle(20);//29 set by yaxian
        hTrkPt[i]->SetMarkerColor(1+i);
        hTrkPt[i]->SetLineColor(1+i);
        hTrkPt[i]->DrawCopy("same");
        }
/*
//---do interplate check------
  TFile checkfile("CombinedJetTrigAkPu3PFJetAllHist.root");
  TH1F *hcheck = (TH1F*)checkfile.Get("jetpt_0-100%;1"); 
  hcheck->SetMarkerStyle(29);
  hcheck->SetMarkerSize(2);
  hcheck->SetMarkerColor(kRed);
  hcheck->Scale(1./10);
  hcheck->DrawCopy("same"); 
//--------------------------------
*/  

    

    
    if(TMath::Abs(etaMin)==TMath::Abs(etaMax))
      TLatex * tex = new TLatex(60.5,1.0e-9,Form("| #eta_{CM} | < %.1f", etaMax));
    else
        TLatex * tex = new TLatex(60.5,1.0e-9,Form("%.1f < #eta_{CM} < %.1f", etaMin, etaMax));
 //   TLatex * tex = new TLatex(1.5,1.0e-7,Form("| #eta_{lab} |< 1.0"));
  //TLatex * tex = new TLatex(2.6,1.05,Form(|#eta_{COM}| < 1.0");
  tex->SetTextSize(0.04);
  tex->Draw();


  TLegend * leg = new TLegend(0.5,0.63,0.9,0.9);
    leg->SetBorderSize(0);
    leg->AddEntry(hCombined,"pPb Combined","lp");
//  leg->AddEntry(hCombined_CombpPbPbp_TrackTriggered_EtaCM_P13_P18_copy1,"12-017","lp");
   leg->AddEntry(hTrkPt[0],"Minimum Bias","lp");
   for( int i = 1; i<6; i++) leg->AddEntry(hTrkPt[i],Form("Jet%d",trigThres[i-1]),"lp");
 // leg->AddEntry(hTrkPtRev[0],"Corrected Tracks Pbp","lp");
  leg->SetFillColor(kWhite);
  leg->Draw();

    if(SavePlot)c1->Print(Form("%s/%sCombinedJetTrig%sJetPt.gif",plotsdir.Data(),shiftType.Data(),algo.Data()));
    
//----------do the ratio for interplate check-------
/*
TCanvas *c2 = new TCanvas("c2a", "c2",0,0,600,600);
c2->cd();
hCombined->Clone("hratio");
hratio->Divide(hcheck);
hratio->DrawCopy();
*/



}
void PlotJetVetoEfficiencySystematics(string inputFile = "" ) {
  PrintJetBinFractions();
  return;


  TFile *EffFile = new TFile("JetVetoEfficiencySystematics.root", "UPDATE");

  vector<TH1D*> HwwJetVetoEfficiencyHists;
  vector<TH1D*> ZeeJetVetoEfficiencyHists;


//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_default_PowhegToMCAtNLOReweighted"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_default_PowhegToMCAtNLOReweighted"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleUp_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleDown_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_default_PowhegToMCAtNLOReweighted"));


//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_MCAtNLO_default"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_MCAtNLO_default"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleUp_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleDown_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_MCAtNLO_default"));


//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_default"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_fscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_fscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_default"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_fscaleUp_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_fscaleDown_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_default"));

//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_default"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_fscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_fscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_fscaleDown_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_fscaleUp_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_fscaleDown_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_reweighted_ggHww160_fscaleUp_rscaleUp"));

//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_MCAtNLO_default"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_MCAtNLO_fscaleUp_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleUp_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleDown_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_MCAtNLO_fscaleDown_rscaleDown"));


  HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_default"));
  HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleUp"));
  HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleDown"));
  HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_rscaleUp"));
  HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_rscaleDown"));
  HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleUp_rscaleUp"));
  HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleUp_rscaleDown"));
  HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleDown_rscaleUp"));
  HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww160_fscaleDown_rscaleDown"));

//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww200_default"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww200_fscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww200_fscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww200_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww200_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww200_fscaleUp_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww200_fscaleUp_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww200_fscaleDown_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww200_fscaleDown_rscaleDown"));

//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww250_default"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww250_fscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww250_fscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww250_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww250_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww250_fscaleUp_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww250_fscaleUp_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww250_fscaleDown_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww250_fscaleDown_rscaleDown"));

//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww400_default"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww400_fscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww400_fscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww400_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww400_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww400_fscaleUp_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww400_fscaleUp_rscaleDown"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww400_fscaleDown_rscaleUp"));
//   HwwJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_ggHww400_fscaleDown_rscaleDown"));
   
  ZeeJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_Zee_default"));
  ZeeJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_Zee_fscaleUp"));
  ZeeJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_Zee_fscaleDown"));
  ZeeJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_Zee_rscaleUp"));
  ZeeJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_Zee_rscaleDown"));
  ZeeJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_Zee_fscaleUp_rscaleUp"));
  ZeeJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_Zee_fscaleUp_rscaleDown"));
  ZeeJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_Zee_fscaleDown_rscaleUp"));
  ZeeJetVetoEfficiencyHists.push_back((TH1D*)EffFile->Get("jetVetoEfficiency_Zee_fscaleDown_rscaleDown"));
  
  assert(HwwJetVetoEfficiencyHists.size() == ZeeJetVetoEfficiencyHists.size());
  for (int i=0; i<HwwJetVetoEfficiencyHists.size(); ++i) {
    cout << "Hww: " << i << endl;
    assert(HwwJetVetoEfficiencyHists[i]);
    cout << "zee: " << i << endl;
    assert(ZeeJetVetoEfficiencyHists[i]);
  }
  
  Double_t HwwXSDefault = 49.739376991;
  Double_t HwwXSScaleUp = 54.553365096;
  Double_t HwwXSScaleDown = 45.6830791089;


  //Construct Hww-Zee Jet Veto Efficiency Scale Factor
  TH1D* JetVetoEfficiencyScaleFactor = (TH1D*)HwwJetVetoEfficiencyHists[0]->Clone("HwwZllJetVetoEfficiencyScaleFactor");

  for (int i=1; i<JetVetoEfficiencyScaleFactor->GetXaxis()->GetNbins()+1; ++i) {

    Double_t scaleFactor = HwwJetVetoEfficiencyHists[0]->GetBinContent(i)/ZeeJetVetoEfficiencyHists[0]->GetBinContent(i);
    Double_t statError = scaleFactor * TMath::Sqrt(pow(HwwJetVetoEfficiencyHists[0]->GetBinError(i)/HwwJetVetoEfficiencyHists[0]->GetBinContent(i),2) + 
                                                   pow(ZeeJetVetoEfficiencyHists[0]->GetBinError(i)/ZeeJetVetoEfficiencyHists[0]->GetBinContent(i),2));
    Double_t sysErrorBand = 0;
    cout << "bin " << i << " " << scaleFactor << " : " ;
    for (int j=0; j < HwwJetVetoEfficiencyHists.size(); ++j) {
      for (int k=0; k < ZeeJetVetoEfficiencyHists.size(); ++k) {      
        Double_t tmp = HwwJetVetoEfficiencyHists[j]->GetBinContent(i)/ZeeJetVetoEfficiencyHists[k]->GetBinContent(i);
        if (sysErrorBand < fabs(tmp - scaleFactor)) {
          sysErrorBand = fabs(tmp - scaleFactor);
        }
        cout << j << " " << k << " " << HwwJetVetoEfficiencyHists[j]->GetBinContent(i) << "/" << ZeeJetVetoEfficiencyHists[k]->GetBinContent(i) << "=" << tmp << " \n";
      }
    }
    cout << endl;

    Double_t totalError = TMath::Sqrt(pow(statError,2) + pow(sysErrorBand,2));
    JetVetoEfficiencyScaleFactor->SetBinContent(i,scaleFactor);
    JetVetoEfficiencyScaleFactor->SetBinError(i,totalError);


    cout << "bin : " << i << " : " << scaleFactor << " " << statError << " " << sysErrorBand << " " << totalError << endl;

  }


  TH1D* HwwJetVetoCrossSection = (TH1D*)HwwJetVetoEfficiencyHists[0]->Clone("HwwJetVetoCrossSection");
  HwwJetVetoCrossSection->GetYaxis()->SetTitle("Cross Section (Jet Veto) [pb]");
  for (int i=1; i<JetVetoEfficiencyScaleFactor->GetXaxis()->GetNbins()+1; ++i) {

    Double_t XSDefault = HwwJetVetoEfficiencyHists[0]->GetBinContent(i) * HwwXSDefault;
    Double_t XSScaleUp = HwwJetVetoEfficiencyHists[5]->GetBinContent(i) * HwwXSScaleUp;
    Double_t XSScaleDown = HwwJetVetoEfficiencyHists[8]->GetBinContent(i) * HwwXSScaleDown;

    Double_t error = fabs(XSDefault - XSScaleDown);
    if (fabs(XSDefault - XSScaleUp) > error) error = fabs(XSDefault - XSScaleUp);

    HwwJetVetoCrossSection->SetBinContent(i,XSDefault);
    HwwJetVetoCrossSection->SetBinError(i,error);

    cout << i << " " << HwwJetVetoEfficiencyHists[0]->GetXaxis()->GetBinLowEdge(i) << " : " << HwwJetVetoEfficiencyHists[0]->GetBinContent(i) << " " << HwwJetVetoEfficiencyHists[5]->GetBinContent(i) << " " << HwwJetVetoEfficiencyHists[8]->GetBinContent(i) << endl;

  }





  TCanvas *cv = new TCanvas("cv","cv", 800,600);

  TLegend *tmpLegend = new TLegend(0.73,0.25,0.93,0.40);   
  tmpLegend->SetTextSize(0.03);
  tmpLegend->SetBorderSize(1);
  tmpLegend->AddEntry(ZeeJetVetoEfficiencyHists[0], "Default", "LP");   
  tmpLegend->AddEntry(ZeeJetVetoEfficiencyHists[5], "ScaleUp", "LP");   
  tmpLegend->AddEntry(ZeeJetVetoEfficiencyHists[7], "ScaleDown", "LP");   
  tmpLegend->Draw();

  ZeeJetVetoEfficiencyHists[0]->Draw("E");
  ZeeJetVetoEfficiencyHists[5]->SetLineColor(kRed);
  ZeeJetVetoEfficiencyHists[5]->Draw("Esame");
  ZeeJetVetoEfficiencyHists[7]->SetLineColor(kBlue);
  ZeeJetVetoEfficiencyHists[7]->Draw("Esame");

  cv->SaveAs("ZeeJetVetoEfficiencyScaleFactor.gif");


  tmpLegend->Clear();
  tmpLegend->AddEntry(HwwJetVetoEfficiencyHists[0], "Default", "LP");   
  tmpLegend->AddEntry(HwwJetVetoEfficiencyHists[5], "ScaleUp", "LP");   
  tmpLegend->AddEntry(HwwJetVetoEfficiencyHists[7], "ScaleDown", "LP");   
  tmpLegend->Draw();

  HwwJetVetoEfficiencyHists[0]->Draw("E");
  HwwJetVetoEfficiencyHists[5]->SetLineColor(kRed);
  HwwJetVetoEfficiencyHists[5]->Draw("Esame");
  HwwJetVetoEfficiencyHists[7]->SetLineColor(kBlue);
  HwwJetVetoEfficiencyHists[7]->Draw("Esame");

  cv->SaveAs("HwwJetVetoEfficiencyScaleFactor.gif");


  JetVetoEfficiencyScaleFactor->Draw("E3");
  JetVetoEfficiencyScaleFactor->SetMarkerSize(0);
  JetVetoEfficiencyScaleFactor->SetFillColor(kBlue);
  JetVetoEfficiencyScaleFactor->SetFillStyle(3001);
  JetVetoEfficiencyScaleFactor->GetYaxis()->SetTitleOffset(1.3);
  JetVetoEfficiencyScaleFactor->GetYaxis()->SetTitle("Jet Veto Efficiency Ratio");
  JetVetoEfficiencyScaleFactor->GetYaxis()->SetRangeUser(0.5, 0.8);
  JetVetoEfficiencyScaleFactor->GetXaxis()->SetRangeUser(20,50);  
  cv->SaveAs("jetVetoEfficiencySF_ScaleVariation_HWW160.gif");
  cv->SaveAs("jetVetoEfficiencySF_ScaleVariation_HWW160.pdf");


  HwwJetVetoCrossSection->Draw("E3");
  HwwJetVetoCrossSection->SetMaximum(60);
  HwwJetVetoCrossSection->SetMinimum(10);
  HwwJetVetoCrossSection->SetMarkerSize(0.0);
  HwwJetVetoCrossSection->SetFillColor(kBlue);
  HwwJetVetoCrossSection->SetFillStyle(3001);
  HwwJetVetoCrossSection->GetYaxis()->SetTitleOffset(1.3);
  HwwJetVetoCrossSection->GetYaxis()->SetTitle("Cross Section (after Jet Veto) [pb]");
  HwwJetVetoCrossSection->GetXaxis()->SetTitleOffset(1.05);
  HwwJetVetoCrossSection->GetXaxis()->SetTitle("GenJet Veto Threshold [GeV/c]");
  HwwJetVetoCrossSection->GetXaxis()->SetRangeUser(10,90);  
  TGraph *HwwJetVetoCrossSectionNNLO =  (TGraph*)EffFile->Get("HWWJetVetoCrossSection");
  HwwJetVetoCrossSectionNNLO->SetLineColor(kRed);
  HwwJetVetoCrossSectionNNLO->SetLineWidth(2);
  HwwJetVetoCrossSectionNNLO->Draw("L,same");

  tmpLegend = new TLegend(0.53,0.25,0.93,0.40);   
  tmpLegend->Clear();
  tmpLegend->SetTextSize(0.03);
  tmpLegend->SetBorderSize(0);
  tmpLegend->AddEntry(HwwJetVetoCrossSection, "Powheg Band", "F");   
  tmpLegend->AddEntry(HwwJetVetoCrossSectionNNLO, "NNLO Band", "L");   
  tmpLegend->Draw();


  cv->SaveAs("HwwJetVetoCrossSection.gif");




//   EffFile->Close();

}
void LCTsigma_2016B_June22all_sameYrange()
{
//=========Macro generated from canvas: LCTsigma/LCTsigma
//=========  (Fri Aug  5 08:12:17 2016) by ROOT version6.06/01
   TCanvas *LCTsigma = new TCanvas("LCTsigma", "LCTsigma",0,0,500,500);
   gStyle->SetOptStat(0);
   LCTsigma->SetHighLightColor(2);
   LCTsigma->Range(-5,-2.848556,45,2.626708);
   LCTsigma->SetFillColor(0);
   LCTsigma->SetBorderMode(0);
   LCTsigma->SetBorderSize(2);
   LCTsigma->SetLogy();
   LCTsigma->SetFrameBorderMode(0);
   LCTsigma->SetFrameBorderMode(0);
   
   TH1D *LCTsigma_1__61 = new TH1D("LCTsigma_1__61","LCTsigma",100,0,40);
   LCTsigma_1__61->SetBinContent(1,0.2671004);
   LCTsigma_1__61->SetBinContent(2,0.7179271);
   LCTsigma_1__61->SetBinContent(3,82.27739);
   LCTsigma_1__61->SetBinContent(4,1.049605);
   LCTsigma_1__61->SetBinContent(5,1.020196);
   LCTsigma_1__61->SetBinContent(6,0.9397023);
   LCTsigma_1__61->SetBinContent(7,0.8736094);
   LCTsigma_1__61->SetBinContent(8,0.8270714);
   LCTsigma_1__61->SetBinContent(9,0.7708318);
   LCTsigma_1__61->SetBinContent(10,0.7038293);
   LCTsigma_1__61->SetBinContent(11,0.648196);
   LCTsigma_1__61->SetBinContent(12,0.6174234);
   LCTsigma_1__61->SetBinContent(13,0.5702791);
   LCTsigma_1__61->SetBinContent(14,0.5160101);
   LCTsigma_1__61->SetBinContent(15,0.4749294);
   LCTsigma_1__61->SetBinContent(16,0.4242986);
   LCTsigma_1__61->SetBinContent(17,0.4070174);
   LCTsigma_1__61->SetBinContent(18,0.3483523);
   LCTsigma_1__61->SetBinContent(19,0.3169733);
   LCTsigma_1__61->SetBinContent(20,0.2802887);
   LCTsigma_1__61->SetBinContent(21,0.2570955);
   LCTsigma_1__61->SetBinContent(22,0.2293547);
   LCTsigma_1__61->SetBinContent(23,0.2028265);
   LCTsigma_1__61->SetBinContent(24,0.1869097);
   LCTsigma_1__61->SetBinContent(25,0.1802397);
   LCTsigma_1__61->SetBinContent(26,0.1635649);
   LCTsigma_1__61->SetBinContent(27,0.1508314);
   LCTsigma_1__61->SetBinContent(28,0.1462837);
   LCTsigma_1__61->SetBinContent(29,0.1315795);
   LCTsigma_1__61->SetBinContent(30,0.1312764);
   LCTsigma_1__61->SetBinContent(31,0.124758);
   LCTsigma_1__61->SetBinContent(32,0.1168754);
   LCTsigma_1__61->SetBinContent(33,0.1152079);
   LCTsigma_1__61->SetBinContent(34,0.1083864);
   LCTsigma_1__61->SetBinContent(35,0.1139952);
   LCTsigma_1__61->SetBinContent(36,0.09428857);
   LCTsigma_1__61->SetBinContent(37,0.100049);
   LCTsigma_1__61->SetBinContent(38,0.096714);
   LCTsigma_1__61->SetBinContent(39,0.1030808);
   LCTsigma_1__61->SetBinContent(40,0.09353062);
   LCTsigma_1__61->SetBinContent(41,0.09610764);
   LCTsigma_1__61->SetBinContent(42,0.09155996);
   LCTsigma_1__61->SetBinContent(43,0.08943771);
   LCTsigma_1__61->SetBinContent(44,0.08928612);
   LCTsigma_1__61->SetBinContent(45,0.08200983);
   LCTsigma_1__61->SetBinContent(46,0.0867091);
   LCTsigma_1__61->SetBinContent(47,0.08170665);
   LCTsigma_1__61->SetBinContent(48,0.07761374);
   LCTsigma_1__61->SetBinContent(49,0.08489003);
   LCTsigma_1__61->SetBinContent(50,0.0811003);
   LCTsigma_1__61->SetBinContent(51,0.0739756);
   LCTsigma_1__61->SetBinContent(52,0.07079222);
   LCTsigma_1__61->SetBinContent(53,0.07352083);
   LCTsigma_1__61->SetBinContent(54,0.06988269);
   LCTsigma_1__61->SetBinContent(55,0.07094381);
   LCTsigma_1__61->SetBinContent(56,0.06776043);
   LCTsigma_1__61->SetBinContent(57,0.06503183);
   LCTsigma_1__61->SetBinContent(58,0.05699759);
   LCTsigma_1__61->SetBinContent(59,0.06002938);
   LCTsigma_1__61->SetBinContent(60,0.06169686);
   LCTsigma_1__61->SetBinContent(61,0.05533011);
   LCTsigma_1__61->SetBinContent(62,0.05927143);
   LCTsigma_1__61->SetBinContent(63,0.0554817);
   LCTsigma_1__61->SetBinContent(64,0.05623964);
   LCTsigma_1__61->SetBinContent(65,0.05320786);
   LCTsigma_1__61->SetBinContent(66,0.05290468);
   LCTsigma_1__61->SetBinContent(67,0.04593157);
   LCTsigma_1__61->SetBinContent(68,0.05351104);
   LCTsigma_1__61->SetBinContent(69,0.04987289);
   LCTsigma_1__61->SetBinContent(70,0.0539658);
   LCTsigma_1__61->SetBinContent(71,0.04699269);
   LCTsigma_1__61->SetBinContent(72,0.04593157);
   LCTsigma_1__61->SetBinContent(73,0.04365773);
   LCTsigma_1__61->SetBinContent(74,0.04532521);
   LCTsigma_1__61->SetBinContent(75,0.04062594);
   LCTsigma_1__61->SetBinContent(76,0.04380932);
   LCTsigma_1__61->SetBinContent(77,0.04001959);
   LCTsigma_1__61->SetBinContent(78,0.039868);
   LCTsigma_1__61->SetBinContent(79,0.03926164);
   LCTsigma_1__61->SetBinContent(80,0.04017117);
   LCTsigma_1__61->SetBinContent(81,0.03683621);
   LCTsigma_1__61->SetBinContent(82,0.03607826);
   LCTsigma_1__61->SetBinContent(83,0.03350124);
   LCTsigma_1__61->SetBinContent(84,0.03228853);
   LCTsigma_1__61->SetBinContent(85,0.03683621);
   LCTsigma_1__61->SetBinContent(86,0.03259171);
   LCTsigma_1__61->SetBinContent(87,0.03213694);
   LCTsigma_1__61->SetBinContent(88,0.03107581);
   LCTsigma_1__61->SetBinContent(89,0.03153058);
   LCTsigma_1__61->SetBinContent(90,0.02895356);
   LCTsigma_1__61->SetBinContent(91,0.03153058);
   LCTsigma_1__61->SetBinContent(92,0.03244012);
   LCTsigma_1__61->SetBinContent(93,0.02743767);
   LCTsigma_1__61->SetBinContent(94,0.03077264);
   LCTsigma_1__61->SetBinContent(95,0.02592178);
   LCTsigma_1__61->SetBinContent(96,0.0284988);
   LCTsigma_1__61->SetBinContent(97,0.02713449);
   LCTsigma_1__61->SetBinContent(98,0.02592178);
   LCTsigma_1__61->SetBinContent(99,0.02789244);
   LCTsigma_1__61->SetBinContent(100,0.02031297);
   LCTsigma_1__61->SetBinContent(101,2.444378);
   LCTsigma_1__61->SetMinimum(0.005);
   LCTsigma_1__61->SetMaximum(120);
   LCTsigma_1__61->SetEntries(675802);
   LCTsigma_1__61->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#ff00ff");
   LCTsigma_1__61->SetLineColor(ci);

   ci = TColor::GetColor("#ff00ff");
   LCTsigma_1__61->SetMarkerColor(ci);
   LCTsigma_1__61->GetXaxis()->SetTitle("cm");
   LCTsigma_1__61->GetYaxis()->SetTitle("scaled number of entries");
   LCTsigma_1__61->Draw("H");
   
   TLegend *leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("LCTsigma_1","ME11A: mean:2.4cm;RMS:4.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_2","ME11B: mean:2.1cm;RMS:4.0cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_3","ME12+13: mean:1.5cm;RMS:2.4cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_4","ME2: mean:1.4cm;RMS:2.2cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_5","ME3: mean:1.3cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_6","ME4: mean:1.3cm;RMS:1.3cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TH1D *LCTsigma_2__62 = new TH1D("LCTsigma_2__62","LCTsigma",100,0,40);
   LCTsigma_2__62->SetBinContent(1,0.6415878);
   LCTsigma_2__62->SetBinContent(2,1.663795);
   LCTsigma_2__62->SetBinContent(3,76.94018);
   LCTsigma_2__62->SetBinContent(4,2.312834);
   LCTsigma_2__62->SetBinContent(5,2.146591);
   LCTsigma_2__62->SetBinContent(6,1.90712);
   LCTsigma_2__62->SetBinContent(7,1.670475);
   LCTsigma_2__62->SetBinContent(8,1.464321);
   LCTsigma_2__62->SetBinContent(9,1.276495);
   LCTsigma_2__62->SetBinContent(10,1.093637);
   LCTsigma_2__62->SetBinContent(11,0.9240544);
   LCTsigma_2__62->SetBinContent(12,0.801578);
   LCTsigma_2__62->SetBinContent(13,0.6547776);
   LCTsigma_2__62->SetBinContent(14,0.5377827);
   LCTsigma_2__62->SetBinContent(15,0.4390307);
   LCTsigma_2__62->SetBinContent(16,0.3703412);
   LCTsigma_2__62->SetBinContent(17,0.3101308);
   LCTsigma_2__62->SetBinContent(18,0.2571148);
   LCTsigma_2__62->SetBinContent(19,0.2253394);
   LCTsigma_2__62->SetBinContent(20,0.1915085);
   LCTsigma_2__62->SetBinContent(21,0.1732655);
   LCTsigma_2__62->SetBinContent(22,0.1490272);
   LCTsigma_2__62->SetBinContent(23,0.1475712);
   LCTsigma_2__62->SetBinContent(24,0.134724);
   LCTsigma_2__62->SetBinContent(25,0.121363);
   LCTsigma_2__62->SetBinContent(26,0.1187079);
   LCTsigma_2__62->SetBinContent(27,0.1096292);
   LCTsigma_2__62->SetBinContent(28,0.1087727);
   LCTsigma_2__62->SetBinContent(29,0.09858064);
   LCTsigma_2__62->SetBinContent(30,0.09840935);
   LCTsigma_2__62->SetBinContent(31,0.09858064);
   LCTsigma_2__62->SetBinContent(32,0.08796031);
   LCTsigma_2__62->SetBinContent(33,0.08504829);
   LCTsigma_2__62->SetBinContent(34,0.08230756);
   LCTsigma_2__62->SetBinContent(35,0.07956683);
   LCTsigma_2__62->SetBinContent(36,0.08033766);
   LCTsigma_2__62->SetBinContent(37,0.07691175);
   LCTsigma_2__62->SetBinContent(38,0.07408537);
   LCTsigma_2__62->SetBinContent(39,0.06749048);
   LCTsigma_2__62->SetBinContent(40,0.06517799);
   LCTsigma_2__62->SetBinContent(41,0.06654836);
   LCTsigma_2__62->SetBinContent(42,0.0689465);
   LCTsigma_2__62->SetBinContent(43,0.06671965);
   LCTsigma_2__62->SetBinContent(44,0.06166643);
   LCTsigma_2__62->SetBinContent(45,0.0608956);
   LCTsigma_2__62->SetBinContent(46,0.05601368);
   LCTsigma_2__62->SetBinContent(47,0.05661321);
   LCTsigma_2__62->SetBinContent(48,0.05635627);
   LCTsigma_2__62->SetBinContent(49,0.05395813);
   LCTsigma_2__62->SetBinContent(50,0.05130305);
   LCTsigma_2__62->SetBinContent(51,0.04659242);
   LCTsigma_2__62->SetBinContent(52,0.04753454);
   LCTsigma_2__62->SetBinContent(53,0.05147434);
   LCTsigma_2__62->SetBinContent(54,0.0451364);
   LCTsigma_2__62->SetBinContent(55,0.04719195);
   LCTsigma_2__62->SetBinContent(56,0.04650677);
   LCTsigma_2__62->SetBinContent(57,0.04410863);
   LCTsigma_2__62->SetBinContent(58,0.04231002);
   LCTsigma_2__62->SetBinContent(59,0.03837022);
   LCTsigma_2__62->SetBinContent(60,0.04273826);
   LCTsigma_2__62->SetBinContent(61,0.03699986);
   LCTsigma_2__62->SetBinContent(62,0.03614338);
   LCTsigma_2__62->SetBinContent(63,0.03485866);
   LCTsigma_2__62->SetBinContent(64,0.03400219);
   LCTsigma_2__62->SetBinContent(65,0.03657162);
   LCTsigma_2__62->SetBinContent(66,0.03811328);
   LCTsigma_2__62->SetBinContent(67,0.03263182);
   LCTsigma_2__62->SetBinContent(68,0.03263182);
   LCTsigma_2__62->SetBinContent(69,0.03425913);
   LCTsigma_2__62->SetBinContent(70,0.03023368);
   LCTsigma_2__62->SetBinContent(71,0.03246052);
   LCTsigma_2__62->SetBinContent(72,0.02971979);
   LCTsigma_2__62->SetBinContent(73,0.03091886);
   LCTsigma_2__62->SetBinContent(74,0.03186099);
   LCTsigma_2__62->SetBinContent(75,0.02749295);
   LCTsigma_2__62->SetBinContent(76,0.02774989);
   LCTsigma_2__62->SetBinContent(77,0.02800684);
   LCTsigma_2__62->SetBinContent(78,0.02612259);
   LCTsigma_2__62->SetBinContent(79,0.02620823);
   LCTsigma_2__62->SetBinContent(80,0.02792119);
   LCTsigma_2__62->SetBinContent(81,0.02663647);
   LCTsigma_2__62->SetBinContent(82,0.02415269);
   LCTsigma_2__62->SetBinContent(83,0.02381009);
   LCTsigma_2__62->SetBinContent(84,0.02637953);
   LCTsigma_2__62->SetBinContent(85,0.02415269);
   LCTsigma_2__62->SetBinContent(86,0.02329621);
   LCTsigma_2__62->SetBinContent(87,0.02201149);
   LCTsigma_2__62->SetBinContent(88,0.02286797);
   LCTsigma_2__62->SetBinContent(89,0.01901382);
   LCTsigma_2__62->SetBinContent(90,0.02201149);
   LCTsigma_2__62->SetBinContent(91,0.02312491);
   LCTsigma_2__62->SetBinContent(92,0.01901382);
   LCTsigma_2__62->SetBinContent(93,0.01858558);
   LCTsigma_2__62->SetBinContent(94,0.01807169);
   LCTsigma_2__62->SetBinContent(95,0.02192584);
   LCTsigma_2__62->SetBinContent(96,0.02004159);
   LCTsigma_2__62->SetBinContent(97,0.01721521);
   LCTsigma_2__62->SetBinContent(98,0.01867123);
   LCTsigma_2__62->SetBinContent(99,0.01841428);
   LCTsigma_2__62->SetBinContent(100,0.01849993);
   LCTsigma_2__62->SetBinContent(101,1.521876);
   LCTsigma_2__62->SetEntries(1185341);
   LCTsigma_2__62->SetStats(0);

   ci = TColor::GetColor("#ff9999");
   LCTsigma_2__62->SetLineColor(ci);

   ci = TColor::GetColor("#ff9999");
   LCTsigma_2__62->SetMarkerColor(ci);
   LCTsigma_2__62->GetXaxis()->SetTitle("cm");
   LCTsigma_2__62->GetYaxis()->SetTitle("scaled number of entries");
   LCTsigma_2__62->Draw("H,same");
   
   leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("LCTsigma_1","ME11A: mean:2.4cm;RMS:4.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_2","ME11B: mean:2.1cm;RMS:4.0cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_3","ME12+13: mean:1.5cm;RMS:2.4cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_4","ME2: mean:1.4cm;RMS:2.2cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_5","ME3: mean:1.3cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_6","ME4: mean:1.3cm;RMS:1.3cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TH1D *LCTsigma_3__63 = new TH1D("LCTsigma_3__63","LCTsigma",100,0,40);
   LCTsigma_3__63->SetBinContent(1,3.18335);
   LCTsigma_3__63->SetBinContent(2,8.110099);
   LCTsigma_3__63->SetBinContent(3,55.60834);
   LCTsigma_3__63->SetBinContent(4,9.726071);
   LCTsigma_3__63->SetBinContent(5,7.599615);
   LCTsigma_3__63->SetBinContent(6,5.331);
   LCTsigma_3__63->SetBinContent(7,3.482403);
   LCTsigma_3__63->SetBinContent(8,2.167811);
   LCTsigma_3__63->SetBinContent(9,1.28797);
   LCTsigma_3__63->SetBinContent(10,0.7526726);
   LCTsigma_3__63->SetBinContent(11,0.4709373);
   LCTsigma_3__63->SetBinContent(12,0.3124935);
   LCTsigma_3__63->SetBinContent(13,0.2109138);
   LCTsigma_3__63->SetBinContent(14,0.146554);
   LCTsigma_3__63->SetBinContent(15,0.1157958);
   LCTsigma_3__63->SetBinContent(16,0.085296);
   LCTsigma_3__63->SetBinContent(17,0.06927069);
   LCTsigma_3__63->SetBinContent(18,0.05841484);
   LCTsigma_3__63->SetBinContent(19,0.05712247);
   LCTsigma_3__63->SetBinContent(20,0.04471578);
   LCTsigma_3__63->SetBinContent(21,0.03515229);
   LCTsigma_3__63->SetBinContent(22,0.03618618);
   LCTsigma_3__63->SetBinContent(23,0.03515229);
   LCTsigma_3__63->SetBinContent(24,0.03153367);
   LCTsigma_3__63->SetBinContent(25,0.02817353);
   LCTsigma_3__63->SetBinContent(26,0.0341184);
   LCTsigma_3__63->SetBinContent(27,0.02481338);
   LCTsigma_3__63->SetBinContent(28,0.02197018);
   LCTsigma_3__63->SetBinContent(29,0.02739811);
   LCTsigma_3__63->SetBinContent(30,0.01964393);
   LCTsigma_3__63->SetBinContent(31,0.02429644);
   LCTsigma_3__63->SetBinContent(32,0.01938546);
   LCTsigma_3__63->SetBinContent(33,0.02041935);
   LCTsigma_3__63->SetBinContent(34,0.01783462);
   LCTsigma_3__63->SetBinContent(35,0.02067782);
   LCTsigma_3__63->SetBinContent(36,0.01861004);
   LCTsigma_3__63->SetBinContent(37,0.01938546);
   LCTsigma_3__63->SetBinContent(38,0.01524989);
   LCTsigma_3__63->SetBinContent(39,0.01886851);
   LCTsigma_3__63->SetBinContent(40,0.01783462);
   LCTsigma_3__63->SetBinContent(41,0.01757615);
   LCTsigma_3__63->SetBinContent(42,0.01938546);
   LCTsigma_3__63->SetBinContent(43,0.01524989);
   LCTsigma_3__63->SetBinContent(44,0.01757615);
   LCTsigma_3__63->SetBinContent(45,0.01731767);
   LCTsigma_3__63->SetBinContent(46,0.01731767);
   LCTsigma_3__63->SetBinContent(47,0.01964393);
   LCTsigma_3__63->SetBinContent(48,0.01628378);
   LCTsigma_3__63->SetBinContent(49,0.01550836);
   LCTsigma_3__63->SetBinContent(50,0.01524989);
   LCTsigma_3__63->SetBinContent(51,0.01524989);
   LCTsigma_3__63->SetBinContent(52,0.01395753);
   LCTsigma_3__63->SetBinContent(53,0.01369906);
   LCTsigma_3__63->SetBinContent(54,0.01628378);
   LCTsigma_3__63->SetBinContent(55,0.01059738);
   LCTsigma_3__63->SetBinContent(56,0.01163127);
   LCTsigma_3__63->SetBinContent(57,0.009563491);
   LCTsigma_3__63->SetBinContent(58,0.01033891);
   LCTsigma_3__63->SetBinContent(59,0.01369906);
   LCTsigma_3__63->SetBinContent(60,0.01395753);
   LCTsigma_3__63->SetBinContent(61,0.009046546);
   LCTsigma_3__63->SetBinContent(62,0.01292364);
   LCTsigma_3__63->SetBinContent(63,0.009305019);
   LCTsigma_3__63->SetBinContent(64,0.01085585);
   LCTsigma_3__63->SetBinContent(65,0.01188975);
   LCTsigma_3__63->SetBinContent(66,0.01008044);
   LCTsigma_3__63->SetBinContent(67,0.01344058);
   LCTsigma_3__63->SetBinContent(68,0.01292364);
   LCTsigma_3__63->SetBinContent(69,0.0113728);
   LCTsigma_3__63->SetBinContent(70,0.01163127);
   LCTsigma_3__63->SetBinContent(71,0.01033891);
   LCTsigma_3__63->SetBinContent(72,0.0113728);
   LCTsigma_3__63->SetBinContent(73,0.0113728);
   LCTsigma_3__63->SetBinContent(74,0.009821964);
   LCTsigma_3__63->SetBinContent(75,0.0113728);
   LCTsigma_3__63->SetBinContent(76,0.01240669);
   LCTsigma_3__63->SetBinContent(77,0.01214822);
   LCTsigma_3__63->SetBinContent(78,0.01111433);
   LCTsigma_3__63->SetBinContent(79,0.008788073);
   LCTsigma_3__63->SetBinContent(80,0.01008044);
   LCTsigma_3__63->SetBinContent(81,0.006978764);
   LCTsigma_3__63->SetBinContent(82,0.007754182);
   LCTsigma_3__63->SetBinContent(83,0.01344058);
   LCTsigma_3__63->SetBinContent(84,0.009305019);
   LCTsigma_3__63->SetBinContent(85,0.01008044);
   LCTsigma_3__63->SetBinContent(86,0.01085585);
   LCTsigma_3__63->SetBinContent(87,0.009046546);
   LCTsigma_3__63->SetBinContent(88,0.008271128);
   LCTsigma_3__63->SetBinContent(89,0.009305019);
   LCTsigma_3__63->SetBinContent(90,0.0085296);
   LCTsigma_3__63->SetBinContent(91,0.009821964);
   LCTsigma_3__63->SetBinContent(92,0.009821964);
   LCTsigma_3__63->SetBinContent(93,0.009046546);
   LCTsigma_3__63->SetBinContent(94,0.008788073);
   LCTsigma_3__63->SetBinContent(95,0.007237237);
   LCTsigma_3__63->SetBinContent(96,0.008271128);
   LCTsigma_3__63->SetBinContent(97,0.006203346);
   LCTsigma_3__63->SetBinContent(98,0.006203346);
   LCTsigma_3__63->SetBinContent(99,0.005944873);
   LCTsigma_3__63->SetBinContent(100,0.005169455);
   LCTsigma_3__63->SetBinContent(101,0.6999442);
   LCTsigma_3__63->SetEntries(389596);
   LCTsigma_3__63->SetStats(0);
   LCTsigma_3__63->GetXaxis()->SetTitle("cm");
   LCTsigma_3__63->GetYaxis()->SetTitle("scaled number of entries");
   LCTsigma_3__63->Draw("H,same");
   
   leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("LCTsigma_1","ME11A: mean:2.4cm;RMS:4.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_2","ME11B: mean:2.1cm;RMS:4.0cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_3","ME12+13: mean:1.5cm;RMS:2.4cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_4","ME2: mean:1.4cm;RMS:2.2cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_5","ME3: mean:1.3cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_6","ME4: mean:1.3cm;RMS:1.3cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TH1D *LCTsigma_4__64 = new TH1D("LCTsigma_4__64","LCTsigma",100,0,40);
   LCTsigma_4__64->SetBinContent(1,1.8811);
   LCTsigma_4__64->SetBinContent(2,4.878654);
   LCTsigma_4__64->SetBinContent(3,73.17773);
   LCTsigma_4__64->SetBinContent(4,5.69795);
   LCTsigma_4__64->SetBinContent(5,4.447017);
   LCTsigma_4__64->SetBinContent(6,3.067821);
   LCTsigma_4__64->SetBinContent(7,1.963316);
   LCTsigma_4__64->SetBinContent(8,1.222624);
   LCTsigma_4__64->SetBinContent(9,0.7509952);
   LCTsigma_4__64->SetBinContent(10,0.4758781);
   LCTsigma_4__64->SetBinContent(11,0.3264227);
   LCTsigma_4__64->SetBinContent(12,0.2169601);
   LCTsigma_4__64->SetBinContent(13,0.1604495);
   LCTsigma_4__64->SetBinContent(14,0.1189164);
   LCTsigma_4__64->SetBinContent(15,0.09953076);
   LCTsigma_4__64->SetBinContent(16,0.07902976);
   LCTsigma_4__64->SetBinContent(17,0.06771703);
   LCTsigma_4__64->SetBinContent(18,0.06442413);
   LCTsigma_4__64->SetBinContent(19,0.05651053);
   LCTsigma_4__64->SetBinContent(20,0.05146495);
   LCTsigma_4__64->SetBinContent(21,0.04641936);
   LCTsigma_4__64->SetBinContent(22,0.04243601);
   LCTsigma_4__64->SetBinContent(23,0.04254223);
   LCTsigma_4__64->SetBinContent(24,0.03739042);
   LCTsigma_4__64->SetBinContent(25,0.03627509);
   LCTsigma_4__64->SetBinContent(26,0.03627509);
   LCTsigma_4__64->SetBinContent(27,0.03324774);
   LCTsigma_4__64->SetBinContent(28,0.03197306);
   LCTsigma_4__64->SetBinContent(29,0.03069839);
   LCTsigma_4__64->SetBinContent(30,0.02883949);
   LCTsigma_4__64->SetBinContent(31,0.02894571);
   LCTsigma_4__64->SetBinContent(32,0.02761793);
   LCTsigma_4__64->SetBinContent(33,0.02474991);
   LCTsigma_4__64->SetBinContent(34,0.02453747);
   LCTsigma_4__64->SetBinContent(35,0.0260777);
   LCTsigma_4__64->SetBinContent(36,0.02103211);
   LCTsigma_4__64->SetBinContent(37,0.02342213);
   LCTsigma_4__64->SetBinContent(38,0.02012922);
   LCTsigma_4__64->SetBinContent(39,0.01949188);
   LCTsigma_4__64->SetBinContent(40,0.01896077);
   LCTsigma_4__64->SetBinContent(41,0.0172612);
   LCTsigma_4__64->SetBinContent(42,0.01890766);
   LCTsigma_4__64->SetBinContent(43,0.01827032);
   LCTsigma_4__64->SetBinContent(44,0.01710187);
   LCTsigma_4__64->SetBinContent(45,0.01683631);
   LCTsigma_4__64->SetBinContent(46,0.01742054);
   LCTsigma_4__64->SetBinContent(47,0.01646453);
   LCTsigma_4__64->SetBinContent(48,0.01503053);
   LCTsigma_4__64->SetBinContent(49,0.01455252);
   LCTsigma_4__64->SetBinContent(50,0.01487119);
   LCTsigma_4__64->SetBinContent(51,0.0139683);
   LCTsigma_4__64->SetBinContent(52,0.01439319);
   LCTsigma_4__64->SetBinContent(53,0.01311852);
   LCTsigma_4__64->SetBinContent(54,0.01455252);
   LCTsigma_4__64->SetBinContent(55,0.01248118);
   LCTsigma_4__64->SetBinContent(56,0.0121094);
   LCTsigma_4__64->SetBinContent(57,0.0134903);
   LCTsigma_4__64->SetBinContent(58,0.01333096);
   LCTsigma_4__64->SetBinContent(59,0.01131273);
   LCTsigma_4__64->SetBinContent(60,0.01009117);
   LCTsigma_4__64->SetBinContent(61,0.01019739);
   LCTsigma_4__64->SetBinContent(62,0.01062228);
   LCTsigma_4__64->SetBinContent(63,0.01120651);
   LCTsigma_4__64->SetBinContent(64,0.01003805);
   LCTsigma_4__64->SetBinContent(65,0.009931832);
   LCTsigma_4__64->SetBinContent(66,0.01009117);
   LCTsigma_4__64->SetBinContent(67,0.01014428);
   LCTsigma_4__64->SetBinContent(68,0.009028938);
   LCTsigma_4__64->SetBinContent(69,0.009188272);
   LCTsigma_4__64->SetBinContent(70,0.008763381);
   LCTsigma_4__64->SetBinContent(71,0.009028938);
   LCTsigma_4__64->SetBinContent(72,0.00796671);
   LCTsigma_4__64->SetBinContent(73,0.007648041);
   LCTsigma_4__64->SetBinContent(74,0.007754264);
   LCTsigma_4__64->SetBinContent(75,0.008126044);
   LCTsigma_4__64->SetBinContent(76,0.008126044);
   LCTsigma_4__64->SetBinContent(77,0.008550935);
   LCTsigma_4__64->SetBinContent(78,0.007701153);
   LCTsigma_4__64->SetBinContent(79,0.00833849);
   LCTsigma_4__64->SetBinContent(80,0.008444712);
   LCTsigma_4__64->SetBinContent(81,0.007541819);
   LCTsigma_4__64->SetBinContent(82,0.007488707);
   LCTsigma_4__64->SetBinContent(83,0.006479591);
   LCTsigma_4__64->SetBinContent(84,0.006054699);
   LCTsigma_4__64->SetBinContent(85,0.006585813);
   LCTsigma_4__64->SetBinContent(86,0.006320256);
   LCTsigma_4__64->SetBinContent(87,0.005948477);
   LCTsigma_4__64->SetBinContent(88,0.005842254);
   LCTsigma_4__64->SetBinContent(89,0.005470474);
   LCTsigma_4__64->SetBinContent(90,0.005576697);
   LCTsigma_4__64->SetBinContent(91,0.006160922);
   LCTsigma_4__64->SetBinContent(92,0.005523585);
   LCTsigma_4__64->SetBinContent(93,0.006001588);
   LCTsigma_4__64->SetBinContent(94,0.006214034);
   LCTsigma_4__64->SetBinContent(95,0.005736031);
   LCTsigma_4__64->SetBinContent(96,0.00493936);
   LCTsigma_4__64->SetBinContent(97,0.004620692);
   LCTsigma_4__64->SetBinContent(98,0.004886249);
   LCTsigma_4__64->SetBinContent(99,0.00531114);
   LCTsigma_4__64->SetBinContent(100,0.005258028);
   LCTsigma_4__64->SetBinContent(101,0.4179867);
   LCTsigma_4__64->SetEntries(1890705);
   LCTsigma_4__64->SetStats(0);

   ci = TColor::GetColor("#ff0000");
   LCTsigma_4__64->SetLineColor(ci);

   ci = TColor::GetColor("#ff0000");
   LCTsigma_4__64->SetMarkerColor(ci);
   LCTsigma_4__64->GetXaxis()->SetTitle("cm");
   LCTsigma_4__64->GetYaxis()->SetTitle("scaled number of entries");
   LCTsigma_4__64->Draw("H,same");
   
   leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("LCTsigma_1","ME11A: mean:2.4cm;RMS:4.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_2","ME11B: mean:2.1cm;RMS:4.0cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_3","ME12+13: mean:1.5cm;RMS:2.4cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_4","ME2: mean:1.4cm;RMS:2.2cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_5","ME3: mean:1.3cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_6","ME4: mean:1.3cm;RMS:1.3cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TH1D *LCTsigma_5__65 = new TH1D("LCTsigma_5__65","LCTsigma",100,0,40);
   LCTsigma_5__65->SetBinContent(1,2.360931);
   LCTsigma_5__65->SetBinContent(2,6.15692);
   LCTsigma_5__65->SetBinContent(3,68.89588);
   LCTsigma_5__65->SetBinContent(4,7.000274);
   LCTsigma_5__65->SetBinContent(5,5.379208);
   LCTsigma_5__65->SetBinContent(6,3.591525);
   LCTsigma_5__65->SetBinContent(7,2.210401);
   LCTsigma_5__65->SetBinContent(8,1.300472);
   LCTsigma_5__65->SetBinContent(9,0.7853251);
   LCTsigma_5__65->SetBinContent(10,0.4762223);
   LCTsigma_5__65->SetBinContent(11,0.3008438);
   LCTsigma_5__65->SetBinContent(12,0.2038183);
   LCTsigma_5__65->SetBinContent(13,0.155485);
   LCTsigma_5__65->SetBinContent(14,0.1113172);
   LCTsigma_5__65->SetBinContent(15,0.08804834);
   LCTsigma_5__65->SetBinContent(16,0.07706025);
   LCTsigma_5__65->SetBinContent(17,0.06657488);
   LCTsigma_5__65->SetBinContent(18,0.0543659);
   LCTsigma_5__65->SetBinContent(19,0.04675324);
   LCTsigma_5__65->SetBinContent(20,0.0400742);
   LCTsigma_5__65->SetBinContent(21,0.03777604);
   LCTsigma_5__65->SetBinContent(22,0.0343288);
   LCTsigma_5__65->SetBinContent(23,0.03224609);
   LCTsigma_5__65->SetBinContent(24,0.02930157);
   LCTsigma_5__65->SetBinContent(25,0.02556705);
   LCTsigma_5__65->SetBinContent(26,0.02420252);
   LCTsigma_5__65->SetBinContent(27,0.01989347);
   LCTsigma_5__65->SetBinContent(28,0.0216889);
   LCTsigma_5__65->SetBinContent(29,0.01824166);
   LCTsigma_5__65->SetBinContent(30,0.01831348);
   LCTsigma_5__65->SetBinContent(31,0.01522532);
   LCTsigma_5__65->SetBinContent(32,0.01500987);
   LCTsigma_5__65->SetBinContent(33,0.01386079);
   LCTsigma_5__65->SetBinContent(34,0.01601532);
   LCTsigma_5__65->SetBinContent(35,0.01421988);
   LCTsigma_5__65->SetBinContent(36,0.01292716);
   LCTsigma_5__65->SetBinContent(37,0.01278353);
   LCTsigma_5__65->SetBinContent(38,0.01364534);
   LCTsigma_5__65->SetBinContent(39,0.01235262);
   LCTsigma_5__65->SetBinContent(40,0.01041355);
   LCTsigma_5__65->SetBinContent(41,0.01070082);
   LCTsigma_5__65->SetBinContent(42,0.010629);
   LCTsigma_5__65->SetBinContent(43,0.01005446);
   LCTsigma_5__65->SetBinContent(44,0.009839007);
   LCTsigma_5__65->SetBinContent(45,0.01026991);
   LCTsigma_5__65->SetBinContent(46,0.008761743);
   LCTsigma_5__65->SetBinContent(47,0.00768448);
   LCTsigma_5__65->SetBinContent(48,0.007540844);
   LCTsigma_5__65->SetBinContent(49,0.006966304);
   LCTsigma_5__65->SetBinContent(50,0.008330838);
   LCTsigma_5__65->SetBinContent(51,0.007756297);
   LCTsigma_5__65->SetBinContent(52,0.007325392);
   LCTsigma_5__65->SetBinContent(53,0.007325392);
   LCTsigma_5__65->SetBinContent(54,0.007469027);
   LCTsigma_5__65->SetBinContent(55,0.006822669);
   LCTsigma_5__65->SetBinContent(56,0.006966304);
   LCTsigma_5__65->SetBinContent(57,0.007397209);
   LCTsigma_5__65->SetBinContent(58,0.00560177);
   LCTsigma_5__65->SetBinContent(59,0.005745405);
   LCTsigma_5__65->SetBinContent(60,0.00588904);
   LCTsigma_5__65->SetBinContent(61,0.005960858);
   LCTsigma_5__65->SetBinContent(62,0.006966304);
   LCTsigma_5__65->SetBinContent(63,0.004955412);
   LCTsigma_5__65->SetBinContent(64,0.006319946);
   LCTsigma_5__65->SetBinContent(65,0.005960858);
   LCTsigma_5__65->SetBinContent(66,0.006319946);
   LCTsigma_5__65->SetBinContent(67,0.003519061);
   LCTsigma_5__65->SetBinContent(68,0.004668142);
   LCTsigma_5__65->SetBinContent(69,0.003878149);
   LCTsigma_5__65->SetBinContent(70,0.003734513);
   LCTsigma_5__65->SetBinContent(71,0.003806331);
   LCTsigma_5__65->SetBinContent(72,0.004596324);
   LCTsigma_5__65->SetBinContent(73,0.003949966);
   LCTsigma_5__65->SetBinContent(74,0.004380872);
   LCTsigma_5__65->SetBinContent(75,0.004165419);
   LCTsigma_5__65->SetBinContent(76,0.004668142);
   LCTsigma_5__65->SetBinContent(77,0.003088155);
   LCTsigma_5__65->SetBinContent(78,0.003016338);
   LCTsigma_5__65->SetBinContent(79,0.003159973);
   LCTsigma_5__65->SetBinContent(80,0.003519061);
   LCTsigma_5__65->SetBinContent(81,0.003303608);
   LCTsigma_5__65->SetBinContent(82,0.003016338);
   LCTsigma_5__65->SetBinContent(83,0.00265725);
   LCTsigma_5__65->SetBinContent(84,0.004021784);
   LCTsigma_5__65->SetBinContent(85,0.003088155);
   LCTsigma_5__65->SetBinContent(86,0.003375426);
   LCTsigma_5__65->SetBinContent(87,0.002872703);
   LCTsigma_5__65->SetBinContent(88,0.002226345);
   LCTsigma_5__65->SetBinContent(89,0.002800885);
   LCTsigma_5__65->SetBinContent(90,0.002082709);
   LCTsigma_5__65->SetBinContent(91,0.002298162);
   LCTsigma_5__65->SetBinContent(92,0.00265725);
   LCTsigma_5__65->SetBinContent(93,0.002298162);
   LCTsigma_5__65->SetBinContent(94,0.001436351);
   LCTsigma_5__65->SetBinContent(95,0.002154527);
   LCTsigma_5__65->SetBinContent(96,0.00236998);
   LCTsigma_5__65->SetBinContent(97,0.00323179);
   LCTsigma_5__65->SetBinContent(98,0.001579986);
   LCTsigma_5__65->SetBinContent(99,0.002082709);
   LCTsigma_5__65->SetBinContent(100,0.001220899);
   LCTsigma_5__65->SetBinContent(101,0.1642468);
   LCTsigma_5__65->SetEntries(1394704);
   LCTsigma_5__65->SetStats(0);

   ci = TColor::GetColor("#00ff00");
   LCTsigma_5__65->SetLineColor(ci);

   ci = TColor::GetColor("#00ff00");
   LCTsigma_5__65->SetMarkerColor(ci);
   LCTsigma_5__65->GetXaxis()->SetTitle("cm");
   LCTsigma_5__65->GetYaxis()->SetTitle("scaled number of entries");
   LCTsigma_5__65->Draw("H,same");
   
   leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("LCTsigma_1","ME11A: mean:2.4cm;RMS:4.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_2","ME11B: mean:2.1cm;RMS:4.0cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_3","ME12+13: mean:1.5cm;RMS:2.4cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_4","ME2: mean:1.4cm;RMS:2.2cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_5","ME3: mean:1.3cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_6","ME4: mean:1.3cm;RMS:1.3cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TH1D *LCTsigma_6__66 = new TH1D("LCTsigma_6__66","LCTsigma",100,0,40);
   LCTsigma_6__66->SetBinContent(1,2.735295);
   LCTsigma_6__66->SetBinContent(2,7.040362);
   LCTsigma_6__66->SetBinContent(3,65.03355);
   LCTsigma_6__66->SetBinContent(4,8.19953);
   LCTsigma_6__66->SetBinContent(5,6.22415);
   LCTsigma_6__66->SetBinContent(6,4.127459);
   LCTsigma_6__66->SetBinContent(7,2.484321);
   LCTsigma_6__66->SetBinContent(8,1.427667);
   LCTsigma_6__66->SetBinContent(9,0.797961);
   LCTsigma_6__66->SetBinContent(10,0.467717);
   LCTsigma_6__66->SetBinContent(11,0.2812113);
   LCTsigma_6__66->SetBinContent(12,0.1845988);
   LCTsigma_6__66->SetBinContent(13,0.1348398);
   LCTsigma_6__66->SetBinContent(14,0.1036042);
   LCTsigma_6__66->SetBinContent(15,0.08035906);
   LCTsigma_6__66->SetBinContent(16,0.06601247);
   LCTsigma_6__66->SetBinContent(17,0.05965639);
   LCTsigma_6__66->SetBinContent(18,0.04467419);
   LCTsigma_6__66->SetBinContent(19,0.04113294);
   LCTsigma_6__66->SetBinContent(20,0.03641128);
   LCTsigma_6__66->SetBinContent(21,0.02878398);
   LCTsigma_6__66->SetBinContent(22,0.02887478);
   LCTsigma_6__66->SetBinContent(23,0.02351751);
   LCTsigma_6__66->SetBinContent(24,0.02106588);
   LCTsigma_6__66->SetBinContent(25,0.01870505);
   LCTsigma_6__66->SetBinContent(26,0.01616261);
   LCTsigma_6__66->SetBinContent(27,0.01634422);
   LCTsigma_6__66->SetBinContent(28,0.01398339);
   LCTsigma_6__66->SetBinContent(29,0.01262137);
   LCTsigma_6__66->SetBinContent(30,0.01116855);
   LCTsigma_6__66->SetBinContent(31,0.009534126);
   LCTsigma_6__66->SetBinContent(32,0.006719289);
   LCTsigma_6__66->SetBinContent(33,0.01026054);
   LCTsigma_6__66->SetBinContent(34,0.009261723);
   LCTsigma_6__66->SetBinContent(35,0.007718102);
   LCTsigma_6__66->SetBinContent(36,0.007173295);
   LCTsigma_6__66->SetBinContent(37,0.007264096);
   LCTsigma_6__66->SetBinContent(38,0.007173295);
   LCTsigma_6__66->SetBinContent(39,0.005992879);
   LCTsigma_6__66->SetBinContent(40,0.005720476);
   LCTsigma_6__66->SetBinContent(41,0.004358458);
   LCTsigma_6__66->SetBinContent(42,0.005902078);
   LCTsigma_6__66->SetBinContent(43,0.005992879);
   LCTsigma_6__66->SetBinContent(44,0.006265283);
   LCTsigma_6__66->SetBinContent(45,0.005992879);
   LCTsigma_6__66->SetBinContent(46,0.005448072);
   LCTsigma_6__66->SetBinContent(47,0.003813651);
   LCTsigma_6__66->SetBinContent(48,0.004358458);
   LCTsigma_6__66->SetBinContent(49,0.003087241);
   LCTsigma_6__66->SetBinContent(50,0.004994066);
   LCTsigma_6__66->SetBinContent(51,0.005629675);
   LCTsigma_6__66->SetBinContent(52,0.004086054);
   LCTsigma_6__66->SetBinContent(53,0.002814837);
   LCTsigma_6__66->SetBinContent(54,0.003632048);
   LCTsigma_6__66->SetBinContent(55,0.003632048);
   LCTsigma_6__66->SetBinContent(56,0.003995253);
   LCTsigma_6__66->SetBinContent(57,0.004086054);
   LCTsigma_6__66->SetBinContent(58,0.00299644);
   LCTsigma_6__66->SetBinContent(59,0.003541247);
   LCTsigma_6__66->SetBinContent(60,0.003087241);
   LCTsigma_6__66->SetBinContent(61,0.003722849);
   LCTsigma_6__66->SetBinContent(62,0.003087241);
   LCTsigma_6__66->SetBinContent(63,0.002905638);
   LCTsigma_6__66->SetBinContent(64,0.002451632);
   LCTsigma_6__66->SetBinContent(65,0.00227003);
   LCTsigma_6__66->SetBinContent(66,0.002451632);
   LCTsigma_6__66->SetBinContent(67,0.002179229);
   LCTsigma_6__66->SetBinContent(68,0.002451632);
   LCTsigma_6__66->SetBinContent(69,0.002088428);
   LCTsigma_6__66->SetBinContent(70,0.002451632);
   LCTsigma_6__66->SetBinContent(71,0.002905638);
   LCTsigma_6__66->SetBinContent(72,0.002542434);
   LCTsigma_6__66->SetBinContent(73,0.001634422);
   LCTsigma_6__66->SetBinContent(74,0.001816024);
   LCTsigma_6__66->SetBinContent(75,0.00227003);
   LCTsigma_6__66->SetBinContent(76,0.002088428);
   LCTsigma_6__66->SetBinContent(77,0.00154362);
   LCTsigma_6__66->SetBinContent(78,0.001906825);
   LCTsigma_6__66->SetBinContent(79,0.001634422);
   LCTsigma_6__66->SetBinContent(80,0.001725223);
   LCTsigma_6__66->SetBinContent(81,0.001997626);
   LCTsigma_6__66->SetBinContent(82,0.001271217);
   LCTsigma_6__66->SetBinContent(83,0.001906825);
   LCTsigma_6__66->SetBinContent(84,0.001362018);
   LCTsigma_6__66->SetBinContent(85,0.00154362);
   LCTsigma_6__66->SetBinContent(86,0.000908012);
   LCTsigma_6__66->SetBinContent(87,0.001816024);
   LCTsigma_6__66->SetBinContent(88,0.001725223);
   LCTsigma_6__66->SetBinContent(89,0.0009988132);
   LCTsigma_6__66->SetBinContent(90,0.001816024);
   LCTsigma_6__66->SetBinContent(91,0.001089614);
   LCTsigma_6__66->SetBinContent(92,0.0009988132);
   LCTsigma_6__66->SetBinContent(93,0.001997626);
   LCTsigma_6__66->SetBinContent(94,0.000908012);
   LCTsigma_6__66->SetBinContent(95,0.0009988132);
   LCTsigma_6__66->SetBinContent(96,0.000908012);
   LCTsigma_6__66->SetBinContent(97,0.001180416);
   LCTsigma_6__66->SetBinContent(98,0.001089614);
   LCTsigma_6__66->SetBinContent(99,0.00154362);
   LCTsigma_6__66->SetBinContent(100,0.00154362);
   LCTsigma_6__66->SetBinContent(101,0.08925758);
   LCTsigma_6__66->SetEntries(1102290);
   LCTsigma_6__66->SetStats(0);

   ci = TColor::GetColor("#0000ff");
   LCTsigma_6__66->SetLineColor(ci);

   ci = TColor::GetColor("#0000ff");
   LCTsigma_6__66->SetMarkerColor(ci);
   LCTsigma_6__66->GetXaxis()->SetTitle("cm");
   LCTsigma_6__66->GetYaxis()->SetTitle("scaled number of entries");
   LCTsigma_6__66->Draw("H,same");
   
   leg = new TLegend(0.5,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextFont(62);
   leg->SetTextSize(0.02);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("LCTsigma_1","ME11A: mean:2.4cm;RMS:4.7cm","l");

   ci = TColor::GetColor("#ff00ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_2","ME11B: mean:2.1cm;RMS:4.0cm","l");

   ci = TColor::GetColor("#ff9999");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_3","ME12+13: mean:1.5cm;RMS:2.4cm","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_4","ME2: mean:1.4cm;RMS:2.2cm","l");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_5","ME3: mean:1.3cm;RMS:1.6cm","l");

   ci = TColor::GetColor("#00ff00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("LCTsigma_6","ME4: mean:1.3cm;RMS:1.3cm","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(0.01,0.9390678,0.2437097,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(1);
   pt->SetFillColor(0);
   TText *AText = pt->AddText("LCTsigma");
   pt->Draw();
   LCTsigma->Modified();
   LCTsigma->cd();
   LCTsigma->SetSelected(LCTsigma);
}
Example #29
0
////////////////////////////////////////////////////////////
//
// Plot a page with several histograms
//
void PlotNHistograms(const TString& pdfFile,
		     TDirectory* rdir, TDirectory* sdir,
		     const TString& rcollname, const TString& scollname,
		     const char* canvasName, const char* canvasTitle,
		     const TString& refLabel, const TString& newLabel,
 		     unsigned int nhistos, const TString* hnames,
		     const TString* htitles, const char** drawopt,
 		     bool* logy = 0,  bool* logx = 0, bool* doKolmo = 0, Double_t* norm = 0,
		     Double_t* minx = 0, Double_t* maxx = 0,
		     Double_t* miny = 0, Double_t* maxy = 0) {

  if (DEBUGP) {
    cout << "   + Plotting histograms for " << canvasTitle << endl;
    cerr << "   + Plotting histograms for " << canvasTitle << endl;
  }

  TH1* rh_raw   = 0;
  TH1* rh       = 0;
  TH1* sh_raw   = 0;
  TH1* sh       = 0;

  TCanvas* canvas =  0;
  if (nhistos >4)
    canvas = new TCanvas(canvasName, canvasTitle, 1000, 1400);
  else
    canvas = new TCanvas(canvasName, canvasTitle, 1000, 1050);

  canvas->Draw();
  canvas->Divide(2,(nhistos+1)/2); //This way we print in 2 columns

  for (unsigned int i = 0; i < nhistos; i++) {

    if (DEBUGP) cout << " [" << i << "] histogram name: " << flush << hnames[i] << endl;

    //draw option for the new histogram
    TString drawoption = drawopt[i]; 

    // Skip histogram if no name is provided
    if (hnames[i] == "") continue;
    
    // Get Histograms
    // + Reference release
    rdir->cd(rcollname);
    
    if (DEBUGP) cout << " Getting object for reference sample " << (rcollname + "/" + hnames[i]) << endl;

    rdir->GetObject(rcollname + "/" + hnames[i], rh_raw);
    if (! rh_raw) {
      cout << "WARNING: Could not find a reference histogram or profile named " << hnames[i]
	   << " in " << rdir->GetName() << endl;
      cout << "         Skipping" << endl;
      continue;
    }

    //If it is a 2D project it in Y... is this what we always want?
    if (TString(rh_raw->IsA()->GetName()) == "TH2F") {

      if (DEBUGP) cout << " It is a TH2F object... project in Y!" << endl;

      TH1* proj = ((TH2F*) rh_raw)->ProjectionY();
      rh_raw = proj;
    }

    // + New release    
    sdir->cd(scollname);

    if (DEBUGP) cout << " Getting object for target sample " << (scollname + "/" + hnames[i]) << endl;

    sdir->GetObject(scollname + "/" + hnames[i], sh_raw);
    if (! sh_raw) {
      cout << "WARNING: Could not find a signal histogram or profile named " << hnames[i] 
	   << " in " << sdir->GetName() << endl;
      cout << "         Skipping" << endl;
      continue;
    }

    //If it is a 2D project it in Y... is this what we always want?
    if (TString(sh_raw->IsA()->GetName()) == "TH2F") {

      if (DEBUGP) cout << hnames[i] << " is a TH2F object... project in Y!" << endl;

      TH1* proj = ((TH2F*) sh_raw)->ProjectionY();
      sh_raw = proj;
    }

    rh = AddOverflow(rh_raw);
    sh = AddOverflow(sh_raw);

    // Set styles

    if (DEBUGP) cout << " Setting style..." << endl;

    SetHistogramStyle(rh, 21, 4);
    SetHistogramStyle(sh, 20, 2);

    //Change titles
    if (htitles) {
      rh->SetTitle(htitles[i]);
      sh->SetTitle(htitles[i]);
      rh->GetYaxis()->SetTitle(htitles[i]);
      sh->GetYaxis()->SetTitle(htitles[i]);
    }

    // SET X AXIS RANGE in plots
    Bool_t ChangeXRange = false ;
    Double_t Xleft = rh->GetXaxis()->GetXmin();
    Double_t Xright = rh->GetXaxis()->GetXmax(); 

    if (DEBUGP) cout << "ref histo Xleft, Xright = "<< Xleft << ", "<< Xright  << endl;
   
    if (sh->GetXaxis()->GetXmin() < rh->GetXaxis()->GetXmin()) {
      Xleft = sh->GetXaxis()->GetXmin();
      ChangeXRange = true;
      if (DEBUGP) cout << "automatic reset MIN (new < ref) Xleft = "<< Xleft << endl;
    }
    if (sh->GetXaxis()->GetXmax() > rh->GetXaxis()->GetXmax()) {
      Xright = sh->GetXaxis()->GetXmax();
      ChangeXRange = true;
      if (DEBUGP) cout << "automatic reset MAX (new > ref) Xright = "<< Xright << endl;
    }

    if (minx[i]!=0) {
      ChangeXRange = true ;
      Xleft = minx[i];
      if (DEBUGP) cout << "user reset Xleft = "<< Xleft << endl;
    }
    
    if (maxx[i]!=0) {
      ChangeXRange = true ;
      Xright = maxx[i];
      if (DEBUGP) cout << "user reset Xright = "<< Xleft << endl;
    }
        
    if (ChangeXRange) {
      if (DEBUGP) {
	cout << "Ref histo Xmin, Xmax = "<< rh->GetXaxis()->GetXmin()  << ", " << rh->GetXaxis()->GetXmax() <<endl;
	cout << "New histo Xmin, Xmax = "<< sh->GetXaxis()->GetXmin()  << ", " << sh->GetXaxis()->GetXmax() <<endl;
      }
      
      rh->GetXaxis()->SetRangeUser(Xleft,Xright);
      sh->GetXaxis()->SetRangeUser(Xleft,Xright);      

      if (DEBUGP) {
	cout << "reset Ref histo Xmin, Xmax = "<< rh->GetXaxis()->GetXmin()  << ", " << rh->GetXaxis()->GetXmax() <<endl;
	cout << "reset New histo Xmin, Xmax = "<< sh->GetXaxis()->GetXmin()  << ", " << sh->GetXaxis()->GetXmax() <<endl;
	cout << "resetting Ref and New histo Xleft, Xright = "<< Xleft << ", " << Xright <<endl;
      }
    }

    // ===============================================================================================
    // Normalize
    if (norm[i] < 0.) ; 
      // Default: do not normalize at all !
    else if (norm[i] == 0.)
      NormalizeHistogramsToFirst(rh,sh);
    else if (norm[i] == 1.)
      NormalizeHistogramsToOne(rh,sh);
    else if (norm[i] == 2.)
      NormalizeHistogramsAsDensity(rh,sh);
    // ===============================================================================================

    // ===============================================================================================
    // SET Y AXIS RANGE in plots
    //
    // MINIMUM
    //
    Double_t Ybottom;

    // if user-defined range force it !
    if (miny[i]!=0) {
      Ybottom = miny[i];
      if (DEBUGP) cout << "setting Minimum Y to user defined value: "<< miny[i] << endl;
    }
    else if (logy[i]) {
      // automatic setting for log scale
      Double_t yminr = rh->GetMinimum(0.); // min value larger than zero
      Double_t ymins = sh->GetMinimum(0.);
      Ybottom = yminr < ymins ? yminr*0.5 : ymins*0.5;
      if (DEBUGP) cout << "LOG scale, yminr, ymins: "<<yminr<<", "<<ymins <<"  ==>> Ybottom = "<<Ybottom<< endl;
    }
    else {
      // automatic setting for linear scale
      Double_t yminr = rh->GetMinimum(); // min value larger than zero
      Double_t ymins = sh->GetMinimum();
      Ybottom = yminr < ymins ? yminr-0.1*abs(yminr) : ymins-0.1*abs(ymins) ;
      // limit the scale to -1,+1 for relative pt bias to avoid failing fits
      if ((hnames[i] == "ptres_vs_eta_Mean") && (Ybottom <-1.)) Ybottom = -1.;
      if ((hnames[i] == "ptres_vs_pt_Mean") && (Ybottom <-1.)) Ybottom = -1.;
      if (DEBUGP) cout << "LIN scale, yminr, ymins: "<<yminr<<", "<<ymins <<"  ==>> Ybottom = "<<Ybottom<< endl;    
    }

    ///////////////////
    // MAXIMUM
    //
    Double_t Ytop;

    // if user-defined range force it !
    if (maxy[i]!=0) {
      Ytop = maxy[i];
      if (DEBUGP) cout << "setting Maximum Y to user defined value: "<< maxy[i] << endl;
    }
    else {
      Double_t ymaxr = rh->GetMaximum(); // max value
      Double_t ymaxs = sh->GetMaximum();
      Ytop = ymaxr > ymaxs ? ymaxr : ymaxs ;
      // automatic setting for log scale
      if (logy[i]) {
	Ytop = Ytop*2;
	if (DEBUGP) cout << "LOG scale, ymaxr, ymaxs: "<<ymaxr<<", "<<ymaxs <<"  ==>> Ytop = "<<Ytop<< endl;
      }
      else {
	Ytop = Ytop+0.1*abs(Ytop);
	// limit the scale to -1,+1 for relative pt bias to avoid failing fits
	if ((hnames[i] == "ptres_vs_eta_Mean") && (Ytop >1.)) Ytop = 1.;
	if ((hnames[i] == "ptres_vs_pt_Mean") && (Ytop >1.)) Ytop = 1.;
	if (DEBUGP) cout << "LIN scale, ymaxr, ymaxs: "<<ymaxr<<", "<<ymaxs <<"  ==>> Ytop = "<<Ytop<< endl;     
      }
    }

    // +++++++++++++++++++++++++++++++++++++++++
    rh->GetYaxis()->SetRangeUser(Ybottom,Ytop);
    sh->GetYaxis()->SetRangeUser(Ybottom,Ytop); 
    // +++++++++++++++++++++++++++++++++++++++++     

    // Move to subpad
    canvas->cd(i+1);
    
    TPad* pad1 = NULL;
    TPad* pad2 = NULL;

    pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0);
    pad2 = new TPad("pad2", "pad2", 0, 0.0, 1, 0.3);

    pad1->SetTopMargin   (0.08);
    pad1->SetBottomMargin(0.01);
    pad1->Draw();

    pad2->SetTopMargin   (0.05);
    pad2->SetBottomMargin(0.45);
    pad2->Draw();// Set stat boxes                                                                      
    pad1->cd();

    // Check Logy                                                                                       
    if (logy[i]) gPad->SetLogy();
    if (logx[i]) {gPad->SetLogx(); pad2->SetLogx();}

    // Set stat boxes

    if (DEBUGP) cout << " Setting statistics..." << endl;
    setStats(sh, rh, -1, 0, false);
   
    // /////////// DRAW  histograms //////////////////////////////////////
    //
    // FIRST plot: reference (blue)   SECOND plot: new (red)
    if (DEBUGP) cout << " Drawing histograms..." << endl;

    if (ChangeXRange) {
      sh->Draw(drawoption);
      rh->Draw("same"+drawoption);
      sh->Draw("same"+drawoption);
    }
    else {
      rh->Draw(drawoption);
      sh->Draw("same"+drawoption);
    }

    // Perform Kolmogorov test if needed
    if (doKolmo) {
      if (doKolmo[i]) {
	if (DEBUGP) cout << " Performing Kolmogorov test..." << endl;
	//	TPad* c1_1 = canvas->GetPad(i+1);
	double kstest = KolmogorovTest(sh,rh);
	if(kstest<0.7)
	  gPad->SetFillColor(kBlue-10);
      }
    }
 
    pad2->cd();

    TH1* ratioplot = PlotRatiosHistograms(rh, sh);
    SetHistogramStyle(ratioplot, 21, 4);
    ratioplot->Draw("ep");
 } // End loop
  
   // Draw Legend

  if (DEBUGP) cout << " Drawing legend..." << endl;

  canvas->cd();
  
  TLegend* l = 0;
  if (nhistos > 4)
    l = new TLegend(0.20,0.665,0.80,0.685);
  else
    l = new TLegend(0.20,0.50,0.80,0.53);

  l->SetTextSize(0.011);
  l->SetLineColor(1);
  l->SetLineWidth(1);
  l->SetLineStyle(1);
  l->SetFillColor(0);
  l->SetBorderSize(2);
  l->AddEntry(rh,refLabel,"LPF");
  l->AddEntry(sh,newLabel,"LPF");
  l->Draw();
  
  // Print Canvas
  canvas->SaveAs(pdfFile+".pdf");
  canvas->SaveAs(pdfFile+".png");

  // Clean memory
  // delete l;
  delete canvas;
  if (DEBUGP) cout << "     ... plotted histograms for " << canvasTitle << endl;
}
Example #30
0
// const char* infilePairStd="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoPairType1.root",
// 		    const char* infilePairRegit="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoPairType2.root",
// 		    const char* infileTrkStd="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoTrkType1.root",
// 		    const char* infileTrkRegit="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoTrkType2.root",
//____________________________________________________________________________________
void makeEfficiency(const char* pTuplePairStd="mcmatchanalysis/pnSimRecoPairType1",
		    const char* pTuplePairRegit="mcmatchanalysis/pnSimRecoPairType2",
		    const char* pTupleTrkStd="mcmatchanalysis/pnSimRecoTrkType1",
		    const char* pTupleTrkRegit="mcmatchanalysis/pnSimRecoTrkType2",
		    const char* pOutFilePath="outputfigs",
		    const char* pOutFileName="effs_bjpsi",
		    Bool_t bSavePlots=true)
{
  gROOT->Macro("/afs/cern.ch/user/m/mironov/utilities/setStyle.C+");
  gStyle->SetPalette(1);
  const char* aInFileLocation[4] = {"",
				    // "/tmp/camelia/tuple_jpsi_v11_minbias"
				    "/afs/cern.ch/user/e/echapon/workspace/private/jpsi_PbPb_5_3_17/CMSSW_5_3_17/src/RegitStudy/McAnalyzer/test/ntuples_bjpsi/ntuples_pp",
				    "/afs/cern.ch/user/e/echapon/workspace/private/jpsi_PbPb_5_3_17/CMSSW_5_3_17/src/RegitStudy/McAnalyzer/test/ntuples_bjpsi/ntuples_regit",
				    "/afs/cern.ch/user/e/echapon/workspace/private/jpsi_PbPb_5_3_17/CMSSW_5_3_17/src/RegitStudy/McAnalyzer/test/ntuples_bjpsi/ntuples_regit_3LastRegitStepsAsPp"
				   };
  const int nPtBins = 2;
  const char* aPtSignalBins[nPtBins] = {"",
               ""
					//	"_ptSignal03_",
					//	"_ptSignal36_",
               // "_ptSignal69_",
					//"_ptSignal1215_",
					//	"_ptSignal1530_"
  };
  bool bDoSinglePlots =  true;
  bool bDo2D          = true;
  bool bDoPairPlots   =  true;
  float ptPairMin = 0;
  float ptPairMax = 20;
  int nPtPairBins = 10;

  float ptTrkMin = 0;
  float ptTrkMax = 20;
  int nPtTrkBins = 10;

  TCut pairGenSelection("smuacc(pt1,eta1)&&smuacc(pt2,eta2) &&npixelhits1>2&&npixelhits2>2 &&nmuonhits1>0&&nmuonhits2>0");
  TCut pairRecoSelection("smuacc(ptreco1,etareco1)&&smuacc(ptreco2,etareco2) &&nvalidpixelhitsreco1>2&&nvalidpixelhitsreco2>2 &&nvalidmuonhitsreco1>0&&nvalidmuonhitsreco2>0 &&minvreco>2.6&&minvreco<3.5&&chi2ndofreco1<4&&chi2ndofreco2<4");

  TCut trkGenSelection("TMath::Abs(eta)<2.4&&(abs(idparent)<550&&abs(idparent)>442) &&npixelhits>2&&nmuonhits>0");
  TCut trkRecoSelection("TMath::Abs(eta)<2.4&&(abs(idparent)<550&&abs(idparent)>442) &&nvalidpixelhitsreco>2&&nvalidmuonhitsreco>0 &&nmatch>0&&chi2ndofreco<4");

  // TCut pairGenSelection("TMath::Abs(eta1)<2.4&&TMath::Abs(eta2)<2.4&&npixelhits1>1&&npixelhits2>1&&nmuonhits1>0&&nmuonhits2>0");
//   TCut pairRecoSelection("nmuonhits1>0&&nmuonhits2>0&&minvreco>2.6&&minvreco<3.5");
//   TCut trkGenSelection("TMath::Abs(eta)<2.4&&idparent==443&&npixelhits>1&&nmuonhits>0");
//   TCut trkRecoSelection("nvalidmuonhitsreco>0");
  
  // axis pair
  TH1F *phPtTmp = new TH1F("phPtTmp",";p_{T}^{#mu#mu}[GeV/c];Efficiency",1,ptPairMin,ptPairMax);
  TH1F *phYTmp  = new TH1F("phYTmp",";y^{#mu#mu};Efficiency",1,-2.4,2.4);
  phPtTmp->SetMinimum(0.005);
  phYTmp->SetMinimum(0.005);
  phPtTmp->SetMaximum(1.);
  phYTmp->SetMaximum(1.);
  TH2F *phPtYTmp = new TH2F("phPtYTmp",";y;p_{T}^{#mu#mu}[GeV/c]",1,-2.4,2.4,1,ptPairMin,ptPairMax);
 

  // axis single
  TH1F *phPtTmp2 = new TH1F("phPtTmp2",";p_{T}^{#mu}[GeV/c];Efficiency",1,ptTrkMin,ptTrkMax);
  phPtTmp2->SetMinimum(0.005);
  phPtTmp2->SetMaximum(1.);
    
  TH1F *phEtaTmp  = new TH1F("phEtaTmp",";#eta^{#mu};Efficiency",1,-2.4,2.4);
  phEtaTmp->SetMinimum(0.005);
  phEtaTmp->SetMaximum(1.);
  TH2F *phPtEtaTmp = new TH2F("phPtEtaTmp",";#eta;p_{T}^{#mu}[GeV/c]",1,-2.4,2.4,1,ptTrkMin,ptTrkMax);
  // TH2F *phPtEtaTmp = new TH2F("phPtEtaTmp",";#eta;p_{T}^{#mu}[GeV/c]",1,-2.4,2.4,1,ptTrkMin,5);

  if(bDoPairPlots)
    {
      TChain *ptPairPp   = new TChain(Form("%s",pTuplePairStd));
      TChain *ptPairStd   = new TChain(Form("%s",pTuplePairStd));
      TChain *ptPairRegit = new TChain(Form("%s",pTuplePairRegit));
      for(int iptbin=1; iptbin<nPtBins; iptbin++)
	{
	  const char* infilePairPp   = Form("%s%s.root",aInFileLocation[1],aPtSignalBins[iptbin]);
	  ptPairPp->Add(infilePairPp);
	  const char* infilePairStd = Form("%s%s.root",aInFileLocation[2],aPtSignalBins[iptbin]);
	  ptPairStd->Add(infilePairStd);
	  const char* infilePairRegit = Form("%s%s.root",aInFileLocation[3],aPtSignalBins[iptbin]);
	  ptPairRegit->Add(infilePairRegit);
	}
   
  
      // ########## pair plots!!!
      TH1D *phPtGenRecoPair_pp = new TH1D("phPtGenRecoPair_pp","phPtGenRecoPair_pp",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phPtGenPair_pp     = new TH1D("phPtGenPair_pp","phPtGenPair_pp",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phYGenRecoPair_pp  = new TH1D("phYGenRecoPair_pp","phYGenRecoPair_pp",12,-2.4,2.4);
      TH1D *phYGenPair_pp      = new TH1D("phYGenPair_pp","phYGenPair_pp",12,-2.4,2.4);

      phPtGenRecoPair_pp->Sumw2();
      phPtGenPair_pp->Sumw2();
      phYGenRecoPair_pp->Sumw2();
      phYGenPair_pp->Sumw2();
      
      TH1D *phPtGenRecoPair_std = new TH1D("phPtGenRecoPair_std","phPtGenRecoPair_std",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phPtGenPair_std     = new TH1D("phPtGenPair_std","phPtGenPair_std",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phYGenRecoPair_std  = new TH1D("phYGenRecoPair_std","phYGenRecoPair_std",12,-2.4,2.4);
      TH1D *phYGenPair_std      = new TH1D("phYGenPair_std","phYGenPair_std",12,-2.4,2.4);

      phPtGenRecoPair_std->Sumw2();
      phPtGenPair_std->Sumw2();
      phYGenRecoPair_std->Sumw2();
      phYGenPair_std->Sumw2();
      
      TH1D *phPtGenRecoPair_regit = new TH1D("phPtGenRecoPair_regit","phPtGenRecoPair_regit",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phPtGenPair_regit     = new TH1D("phPtGenPair_regit","phPtGenPair_regit",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phYGenRecoPair_regit  = new TH1D("phYGenRecoPair_regit","phYGenRecoPair_regit",12,-2.4,2.4);
      TH1D *phYGenPair_regit      = new TH1D("phYGenPair_regit","phYGenPair_regit",12,-2.4,2.4);
      phPtGenRecoPair_regit->Sumw2();
      phPtGenPair_regit->Sumw2();
      phYGenRecoPair_regit->Sumw2();
      phYGenPair_regit->Sumw2();
      
      // 2d histos
      TH2F *phPtYGenRecoPair_pp  = new TH2F("phPtYGenRecoPair_pp",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2F *phPtYGenPair_pp      = new TH2F("phPtYGenPair_pp",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2F *phPtYGenRecoPair_std  = new TH2F("phPtYGenRecoPair_std",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2F *phPtYGenPair_std      = new TH2F("phPtYGenPair_std",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2F *phPtYGenRecoPair_regit = new TH2F("phPtYGenRecoPair_regit",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2F *phPtYGenPair_regit     = new TH2F("phPtYGenPair_regit",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      
      TCanvas *pcTemp = new TCanvas("pcTemp","pcTemp", 900, 400);
      pcTemp->Divide(3,1);
      pcTemp->cd(1);
      ptPairPp->Draw("pt>>phPtGenPair_pp","","E");
      ptPairPp->Draw("pt>>phPtGenPair_pp",pairGenSelection,"E");
      ptPairPp->Draw("ptreco>>phPtGenRecoPair_pp",pairRecoSelection,"Esame");
   
      pcTemp->cd(2);
      ptPairPp->Draw("y>>phYGenPair_pp",pairGenSelection,"E");
      ptPairPp->Draw("yreco>>phYGenRecoPair_pp",pairRecoSelection,"Esame");
      
      pcTemp->cd(1);
      ptPairStd->Draw("pt>>phPtGenPair_std",pairGenSelection,"Esame");
      ptPairStd->Draw("ptreco>>phPtGenRecoPair_std",pairRecoSelection,"Esame");
   
      pcTemp->cd(2);
      ptPairStd->Draw("y>>phYGenPair_std",pairGenSelection,"Esame");
      ptPairStd->Draw("yreco>>phYGenRecoPair_std",pairRecoSelection,"Esame");
      
      pcTemp->cd(1);
      ptPairRegit->Draw("pt>>phPtGenPair_regit",pairGenSelection,"Esame");
      ptPairRegit->Draw("ptreco>>phPtGenRecoPair_regit",pairRecoSelection,"Esame");
      pcTemp->cd(2);
      ptPairRegit->Draw("y>>phYGenPair_regit",pairGenSelection,"Esame");
      ptPairRegit->Draw("yreco>>phYGenRecoPair_regit",pairRecoSelection,"Esame");
      
      ptPairPp->Draw("pt:y>>phPtYGenPair_pp",pairGenSelection,"colz");
      ptPairPp->Draw("ptreco:yreco>>phPtYGenRecoPair_pp",pairRecoSelection,"colz");
      ptPairStd->Draw("pt:y>>phPtYGenPair_std",pairGenSelection,"colz");
      ptPairStd->Draw("ptreco:yreco>>phPtYGenRecoPair_std",pairRecoSelection,"colz");
      ptPairRegit->Draw("pt:y>>phPtYGenPair_regit",pairGenSelection,"colz");
      ptPairRegit->Draw("ptreco:yreco>>phPtYGenRecoPair_regit",pairRecoSelection,"colz");
      
      TH1D *pgPtEff_pp = new TH1D("pgPtEff_pp","pgPtEff_pp",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *pgYEff_pp  = new TH1D("pgYEff_pp","pgYEff_pp",12,-2.4,2.4);
      pgPtEff_pp->Sumw2();
      pgYEff_pp->Sumw2();
      TH1D *pgPtEff_std = new TH1D("pgPtEff_std","pgPtEff_std",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *pgYEff_std  = new TH1D("pgYEff_std","pgYEff_std",12,-2.4,2.4);
      pgPtEff_std->Sumw2();
      pgYEff_std->Sumw2();
      TH1D *pgPtEff_regit =  new TH1D("pgPtEff_regit","pgPtEff_regit",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *pgYEff_regit  =  new TH1D("pgYEff_regit","pgYEff_regit",12,-2.4,2.4);
      pgPtEff_regit->Sumw2();
      pgYEff_regit->Sumw2();

      pgPtEff_pp->Divide(phPtGenRecoPair_pp,phPtGenPair_pp,1,1,"b");
      pgYEff_pp->Divide(phYGenRecoPair_pp,phYGenPair_pp,1,1,"b");
      pgPtEff_std->Divide(phPtGenRecoPair_std,phPtGenPair_std,1,1,"b");
      pgYEff_std->Divide(phYGenRecoPair_std,phYGenPair_std,1,1,"b");
      pgPtEff_regit->Divide(phPtGenRecoPair_regit,phPtGenPair_regit,1,1,"b");
      pgYEff_regit->Divide(phYGenRecoPair_regit,phYGenPair_regit,1,1,"b");

      // 2d histos
      TH2D *pgPtYEff_pp   = new TH2D("pgPtYEff_pp","pgPtYEff_pp",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2D *pgPtYEff_std   = new TH2D("pgPtYEff_std","pgPtYEff_std",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2D *pgPtYEff_regit = new TH2D("pgPtYEff_regit","pgPtYEff_regit",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      pgPtYEff_pp->Divide(phPtYGenRecoPair_pp,phPtYGenPair_pp,1,1,"b");
      pgPtYEff_std->Divide(phPtYGenRecoPair_std,phPtYGenPair_std,1,1,"b");
      pgPtYEff_regit->Divide(phPtYGenRecoPair_regit,phPtYGenPair_regit,1,1,"b");

      // drawing
      pgPtEff_pp->SetLineColor(3);
      pgPtEff_pp->SetMarkerColor(3);
      pgPtEff_pp->SetMarkerStyle(3);
      
      pgYEff_pp->SetLineColor(3);
      pgYEff_pp->SetMarkerColor(3);
      pgYEff_pp->SetMarkerStyle(3);
      
      pgPtEff_std->SetLineColor(4);
      pgPtEff_std->SetMarkerColor(4);
      pgPtEff_std->SetMarkerStyle(4);
      
      pgYEff_std->SetLineColor(4);
      pgYEff_std->SetMarkerColor(4);
      pgYEff_std->SetMarkerStyle(4);
      
      pgPtEff_regit->SetLineColor(2);
      pgPtEff_regit->SetMarkerColor(2);
      pgPtEff_regit->SetMarkerStyle(25);
      
      pgYEff_regit->SetLineColor(2);
      pgYEff_regit->SetMarkerColor(2);
      pgYEff_regit->SetMarkerStyle(25);
      
      TCanvas *pcPairEff = new TCanvas("pcPairEff","pcPairEff",900,500);
      pcPairEff->Divide(2,1);
      pcPairEff->cd(1);// gPad->SetLogy();
      phPtTmp->Draw();
      pgPtEff_pp->Draw("pl same");
      pgPtEff_std->Draw("pl same");
      pgPtEff_regit->Draw("pl same");
      
      pcPairEff->cd(2); //gPad->SetLogy();
      phYTmp->Draw();
      pgYEff_pp->Draw("pl same");
      pgYEff_std->Draw("pl same");
      pgYEff_regit->Draw("pl same");
      
      TLegend *t = new TLegend(0.34,0.78,0.94,0.91);
      t->SetBorderSize(0);
      t->SetFillStyle(0);
      t->AddEntry(pgPtEff_pp,"Pp_reco","pl");
      t->AddEntry(pgPtEff_std,"Std_reco","pl");
      t->AddEntry(pgPtEff_regit,"Regit_reco","pl");
      t->Draw();

      //2D histo
      if(bDo2D)
	{
	  TLatex lx;
	  TCanvas *pcPtYPairEff = new TCanvas("pcPtYPairEff","pcPtYPairEff",1500,600);
	  pcPtYPairEff->Divide(3,1);
	  pcPtYPairEff->cd(1);      
	  pcPtYPairEff->GetPad(1)->SetLeftMargin(0.16);
	  pcPtYPairEff->GetPad(1)->SetRightMargin(0.15);
	  phPtYTmp->Draw();
	  pgPtYEff_pp->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtYEff_pp->Draw("colz same");
	  lx.DrawLatex(0.,2.,"Pp_reco");
	  gPad->Update();

	  pcPtYPairEff->cd(2);      
	  pcPtYPairEff->GetPad(2)->SetLeftMargin(0.16);
	  pcPtYPairEff->GetPad(2)->SetRightMargin(0.15);
	  phPtYTmp->Draw();
	  pgPtYEff_std->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtYEff_std->Draw("colz same");
	  lx.DrawLatex(0.,2.,"Std_reco");
	  gPad->Update();
	  
	  pcPtYPairEff->cd(3);  
	  pcPtYPairEff->GetPad(3)->SetLeftMargin(0.16);
	  pcPtYPairEff->GetPad(3)->SetRightMargin(0.15);    
	  phPtYTmp->Draw();
	  pgPtYEff_regit->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtYEff_regit->Draw("colz same");
	  lx.DrawLatex(0.,2,"Regit_reco");

	  if(bSavePlots)
	    {
	      TString outFileBase1(Form("%s/%s_%s",pOutFilePath,pcPtYPairEff->GetTitle(),pOutFileName));
	      TString outFileGif1 = outFileBase1+".gif";
	      pcPtYPairEff->Print(outFileGif1.Data(),"gifLandscape");
	      TString outFilePdf1 = outFileBase1+".pdf";
	      pcPtYPairEff->SaveAs(outFilePdf1.Data());
	      
	    }
	  
	}

      if(bSavePlots)
	{
	  TString outFileBase(Form("%s/%s_%s",pOutFilePath,pcPairEff->GetTitle(),pOutFileName));
	  TString outFileGif = outFileBase+".gif";
	  pcPairEff->Print(outFileGif.Data(),"gifLandscape");
	  TString outFilePdf = outFileBase+".pdf";
	  pcPairEff->SaveAs(outFilePdf.Data());
	  
	}
    }
  
  // ##########--------------------- single plots!!!
  if(bDoSinglePlots)
    {
      TChain *ptTrkPp   = new TChain(Form("%s",pTupleTrkStd));
      TChain *ptTrkStd   = new TChain(Form("%s",pTupleTrkStd));
      TChain *ptTrkRegit = new TChain(Form("%s",pTupleTrkRegit));
      //nPtBins
      for(int iptbin=1; iptbin<nPtBins; iptbin++)
	{
	  const char* infileTrkPp   = Form("%s%s.root",aInFileLocation[1],aPtSignalBins[iptbin]);
	  ptTrkPp->Add(infileTrkPp);
	  const char* infileTrkStd = Form("%s%s.root",aInFileLocation[2],aPtSignalBins[iptbin]);
	  ptTrkStd->Add(infileTrkStd);
	  const char* infileTrkRegit = Form("%s%s.root",aInFileLocation[3],aPtSignalBins[iptbin]);
	  ptTrkRegit->Add(infileTrkRegit);
	}
      
     
      TH1D *phPtGenRecoTrk_pp   = new TH1D("phPtGenRecoTrk_pp","phPtGenRecoTrk_pp",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phPtGenTrk_pp       = new TH1D("phPtGenTrk_pp","phPtGenTrk_pp",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phEtaGenRecoTrk_pp  = new TH1D("phEtaGenRecoTrk_pp","phEtaGenRecoTrk_pp",12,-2.4,2.4);
      TH1D *phEtaGenTrk_pp      = new TH1D("phEtaGenTrk_pp","phEtaGenTrk_pp",12,-2.4,2.4);
      phPtGenRecoTrk_pp->Sumw2();
      phPtGenTrk_pp->Sumw2();
      phEtaGenRecoTrk_pp->Sumw2();
      phEtaGenTrk_pp->Sumw2();
     
      TH1D *phPtGenRecoTrk_std   = new TH1D("phPtGenRecoTrk_std","phPtGenRecoTrk_std",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phPtGenTrk_std       = new TH1D("phPtGenTrk_std","phPtGenTrk_std",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phEtaGenRecoTrk_std  = new TH1D("phEtaGenRecoTrk_std","phEtaGenRecoTrk_std",12,-2.4,2.4);
      TH1D *phEtaGenTrk_std      = new TH1D("phEtaGenTrk_std","phEtaGenTrk_std",12,-2.4,2.4);
      phPtGenRecoTrk_std->Sumw2();
      phPtGenTrk_std->Sumw2();
      phEtaGenRecoTrk_std->Sumw2();
      phEtaGenTrk_std->Sumw2();

      TH1D *phPtGenRecoTrk_regit = new TH1D("phPtGenRecoTrk_regit","phPtGenRecoTrk_regit",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phPtGenTrk_regit     = new TH1D("phPtGenTrk_regit","phPtGenTrk_regit",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phEtaGenRecoTrk_regit= new TH1D("phEtaGenRecoTrk_regit","phEtaGenRecoTrk_regit",12,-2.4,2.4);
      TH1D *phEtaGenTrk_regit    = new TH1D("phEtaGenTrk_regit","phEtaGenTrk_regit",12,-2.4,2.4);
      phPtGenRecoTrk_regit->Sumw2();
      phPtGenTrk_regit->Sumw2();
      phEtaGenRecoTrk_regit->Sumw2();
      phEtaGenTrk_regit->Sumw2();
  
      TCanvas *pcTemp2 = new TCanvas("pcTemp2","pcTemp2", 900, 400);
      pcTemp2->Divide(2,1);
      pcTemp2->cd(1);
      pcTemp2->cd(1);
      ptTrkPp->Draw("pt>>phPtGenTrk_pp",trkGenSelection,"E");
      ptTrkPp->Draw("ptreco>>phPtGenRecoTrk_pp",trkRecoSelection,"Esame");
      pcTemp2->cd(2);
      ptTrkPp->Draw("eta>>phEtaGenTrk_pp",trkGenSelection,"E");
      ptTrkPp->Draw("etareco>>phEtaGenRecoTrk_pp",trkRecoSelection,"Esame");
      
      ptTrkStd->Draw("pt>>phPtGenTrk_std",trkGenSelection,"Esame");
      ptTrkStd->Draw("ptreco>>phPtGenRecoTrk_std",trkRecoSelection,"Esame");
      pcTemp2->cd(2);
      ptTrkStd->Draw("eta>>phEtaGenTrk_std",trkGenSelection,"Esame");
      ptTrkStd->Draw("etareco>>phEtaGenRecoTrk_std",trkRecoSelection,"Esame");
      
      pcTemp2->cd(1);
      ptTrkRegit->Draw("pt>>phPtGenTrk_regit",trkGenSelection,"Esame");
      ptTrkRegit->Draw("ptreco>>phPtGenRecoTrk_regit",trkRecoSelection,"Esame");
      pcTemp2->cd(2);
      ptTrkRegit->Draw("eta>>phEtaGenTrk_regit",trkGenSelection,"Esame");
      ptTrkRegit->Draw("etareco>>phEtaGenRecoTrk_regit",trkRecoSelection,"Esame");

      TH1D *pgPtTrkEff_pp = new TH1D("pgPtTrkEff_pp","pgPtTrkEff_pp",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *pgEtaTrkEff_pp  = new TH1D("pgEtaTrkEff_pp","pgEtaTrkEff_pp",12,-2.4,2.4);
      pgPtTrkEff_pp->Sumw2();
      pgEtaTrkEff_pp->Sumw2();
      TH1D *pgPtTrkEff_std = new TH1D("pgPtTrkEff_std","pgPtTrkEff_std",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *pgEtaTrkEff_std  = new TH1D("pgEtaTrkEff_std","pgEtaTrkEff_std",12,-2.4,2.4);
      pgPtTrkEff_std->Sumw2();
      pgEtaTrkEff_std->Sumw2();
      TH1D *pgPtTrkEff_regit =  new TH1D("pgPtTrkEff_regit","pgPtTrkEff_regit",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *pgEtaTrkEff_regit  =  new TH1D("pgEtaTrkEff_regit","pgEtaTrkEff_regit",12,-2.4,2.4);
      pgPtTrkEff_regit->Sumw2();
      pgEtaTrkEff_regit->Sumw2();

      pgPtTrkEff_pp->Divide(phPtGenRecoTrk_pp,phPtGenTrk_pp,1,1,"b");
      pgEtaTrkEff_pp->Divide(phEtaGenRecoTrk_pp,phEtaGenTrk_pp,1,1,"b");
      pgPtTrkEff_std->Divide(phPtGenRecoTrk_std,phPtGenTrk_std,1,1,"b");
      pgEtaTrkEff_std->Divide(phEtaGenRecoTrk_std,phEtaGenTrk_std,1,1,"b");
      pgPtTrkEff_regit->Divide(phPtGenRecoTrk_regit,phPtGenTrk_regit,1,1,"b");
      pgEtaTrkEff_regit->Divide(phEtaGenRecoTrk_regit,phEtaGenTrk_regit,1,1,"b");
  
      // 2D stuff
      TH2F *phPtEtaGenRecoTrk_pp  = new TH2F("phPtEtaGenRecoTrk_pp",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      TH2F *phPtEtaGenTrk_pp      = new TH2F("phPtEtaGenTrk_pp",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      ptTrkPp->Draw("pt:eta>>phPtEtaGenTrk_pp",trkGenSelection,"colz");
      ptTrkPp->Draw("ptreco:etareco>>phPtEtaGenRecoTrk_pp",trkRecoSelection,"colz");
      TH2F *phPtEtaGenRecoTrk_std  = new TH2F("phPtEtaGenRecoTrk_std",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      TH2F *phPtEtaGenTrk_std      = new TH2F("phPtEtaGenTrk_std",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      ptTrkStd->Draw("pt:eta>>phPtEtaGenTrk_std",trkGenSelection,"colz");
      ptTrkStd->Draw("ptreco:etareco>>phPtEtaGenRecoTrk_std",trkRecoSelection,"colz");
      TH2F *phPtEtaGenRecoTrk_regit= new TH2F("phPtEtaGenRecoTrk_regit",";#eta;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      TH2F *phPtEtaGenTrk_regit    = new TH2F("phPtEtaGenTrk_regit",";#eta;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      ptTrkRegit->Draw("pt:eta>>phPtEtaGenTrk_regit",trkGenSelection,"colz");
      ptTrkRegit->Draw("ptreco:etareco>>phPtEtaGenRecoTrk_regit",trkRecoSelection,"colz");

      TH2D *pgPtEtaEff_pp   = new TH2D("pgPtEtaEff_pp",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      TH2D *pgPtEtaEff_std   = new TH2D("pgPtEtaEff_std",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      TH2D *pgPtEtaEff_regit = new TH2D("pgPtEtaEff_regit",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      pgPtEtaEff_pp->Divide(phPtEtaGenRecoTrk_pp,phPtEtaGenTrk_pp,1,1,"b");
      pgPtEtaEff_std->Divide(phPtEtaGenRecoTrk_std,phPtEtaGenTrk_std,1,1,"b");
      pgPtEtaEff_regit->Divide(phPtEtaGenRecoTrk_regit,phPtEtaGenTrk_regit,1,1,"b");


      // drawing
      pgPtTrkEff_pp->SetLineColor(3);
      pgPtTrkEff_pp->SetMarkerColor(3);
      pgPtTrkEff_pp->SetMarkerStyle(3);
      
      pgEtaTrkEff_pp->SetLineColor(3);
      pgEtaTrkEff_pp->SetMarkerColor(3);
      pgEtaTrkEff_pp->SetMarkerStyle(3);
      
      pgPtTrkEff_std->SetLineColor(4);
      pgPtTrkEff_std->SetMarkerColor(4);
      pgPtTrkEff_std->SetMarkerStyle(4);
      
      pgEtaTrkEff_std->SetLineColor(4);
      pgEtaTrkEff_std->SetMarkerColor(4);
      pgEtaTrkEff_std->SetMarkerStyle(4);
      
      pgPtTrkEff_regit->SetLineColor(2);
      pgPtTrkEff_regit->SetMarkerColor(2);
      pgPtTrkEff_regit->SetMarkerStyle(25);
      
      pgEtaTrkEff_regit->SetLineColor(2);
      pgEtaTrkEff_regit->SetMarkerColor(2);
      pgEtaTrkEff_regit->SetMarkerStyle(25);
      
      TCanvas *pcTrkEff = new TCanvas("pcTrkEff","pcTrkEff",1000,600);
      pcTrkEff->Divide(2,1);
      pcTrkEff->cd(1); //gPad->SetLogy();
      phPtTmp2->Draw();
      pgPtTrkEff_pp->Draw("pl same");
      pgPtTrkEff_std->Draw("pl same");
      pgPtTrkEff_regit->Draw("pl same");
      
      pcTrkEff->cd(2); //gPad->SetLogy();
      phEtaTmp->Draw();
      pgEtaTrkEff_pp->Draw("pl same");
      pgEtaTrkEff_std->Draw("pl same");
      pgEtaTrkEff_regit->Draw("pl same");
      
      TLegend *t2 = new TLegend(0.34,0.78,0.94,0.91);
      t2->SetBorderSize(0);
      t2->SetFillStyle(0);
      t2->AddEntry(pgPtTrkEff_pp,"Pp_reco","pl");
      t2->AddEntry(pgPtTrkEff_std,"Std_reco","pl");
      t2->AddEntry(pgPtTrkEff_regit,"Regit_reco","pl");
      t2->Draw();
      
      // 2d plots
      //2D histo
      if(bDo2D)
	{
	  TLatex lx2;
	  TCanvas *pcPtEtaTrkEff = new TCanvas("pcPtEtaTrkEff","pcPtEtaTrkEff",1300,500);
	  pcPtEtaTrkEff->Divide(3,1);
	  pcPtEtaTrkEff->cd(1);      
	  pcPtEtaTrkEff->GetPad(1)->SetLeftMargin(0.16);
	  pcPtEtaTrkEff->GetPad(1)->SetRightMargin(0.15); 
	  phPtEtaTmp->Draw();
	  pgPtEtaEff_pp->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtEtaEff_pp->Draw("COLZ same");
	  lx2.DrawLatex(-0.2,2,"Pp_reco");
	  
	  
	  pcPtEtaTrkEff->cd(2);      
	  pcPtEtaTrkEff->GetPad(2)->SetLeftMargin(0.16);
	  pcPtEtaTrkEff->GetPad(2)->SetRightMargin(0.15); 
	  phPtEtaTmp->Draw();
	  pgPtEtaEff_std->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtEtaEff_std->Draw("COLZ same");
	  lx2.DrawLatex(-0.2,2,"Std_reco");
	  
	  pcPtEtaTrkEff->cd(3);
	  pcPtEtaTrkEff->GetPad(3)->SetLeftMargin(0.16);
	  pcPtEtaTrkEff->GetPad(3)->SetRightMargin(0.15);       
	  phPtEtaTmp->Draw();
	  pgPtEtaEff_regit->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtEtaEff_regit->Draw("colz same");
	  lx2.DrawLatex(-0.2,2,"Regit_reco");

     if(bSavePlots)
     {
        TString outFileBase2(Form("%s/%s_%s",pOutFilePath,pcPtEtaTrkEff->GetTitle(),pOutFileName));
        TString outFileGif2 = outFileBase2+".gif";
        pcPtEtaTrkEff->Print(outFileGif2.Data(),"gifLandscape");
        TString outFilePdf2 = outFileBase2+".pdf";
        pcPtEtaTrkEff->SaveAs(outFilePdf2.Data());
     }

   }
      if(bSavePlots)
      {
         TString outFileBase(Form("%s/%s_%s",pOutFilePath,pcTrkEff->GetTitle(),pOutFileName));
         TString outFileGif = outFileBase+".gif";
         pcTrkEff->Print(outFileGif.Data(),"gifLandscape");
         TString outFilePdf2 = outFileBase+".pdf";
         pcTrkEff->SaveAs(outFilePdf2.Data());
      }
    }


}