Beispiel #1
0
int makeZPhiArrowPlot( TTree* data, const char* name, double zLim, double phiLim, double level, double sublevel, double zMin, double zMax, double rMin, double rMax, double barrelRPhiRescale){
	
	
	TCanvas* OBPCanvas = new TCanvas(name,name,1050,875);
	OBPCanvas->DrawFrame(-zLim, -phiLim, 1.2*zLim, phiLim, ";module position z [cm];module position r*phi [cm]");
	OBPCanvas->SetFillColor(0);
	OBPCanvas->SetFrameBorderMode(0);
	
	TFrame* aFrame = OBPCanvas->GetFrame();
	aFrame->SetFillColor(0);
	
	int passcut = 0;
	for(int entry = 0;entry<data->GetEntries(); entry++)
    {
		data->GetEntry(entry);
			if ((level_ == level)&&(((sublevel_ == sublevel)&&(sublevel != 0))||(sublevel == 0))){
			if ((z_ <= zMax)&&(z_ > zMin)&&(r_ <= rMax)&&(r_ > rMin)){
				TArrow* aArraw = new TArrow( z_, r_*phi_ , z_ + barrelRPhiRescale*dz_, r_*phi_+barrelRPhiRescale*r_*dphi_,0.0075,">");
				aArraw->Draw();
				passcut++;
			}
		}
	}
	DrawRPhiLegend( zLim, phiLim, barrelRPhiRescale );
	
	char sliceLeg[192]; 
	sprintf( sliceLeg, "%s: %f < r <= %f", name, rMin, rMax );
	//Plot10Mu( name, xLim/2, yLim, 0.2*xLim );
	TPaveText* atext = new TPaveText(0.2*zLim,0.85*phiLim,0.66*zLim,0.99*phiLim);
	atext->AddText(sliceLeg);
	atext->SetLineColor(0);
	atext->SetFillColor(0);
	atext->SetTextFont(42);
	atext->SetTextSize(0.04);
	atext->Draw();
	
	
	
	char outfile[192];
	sprintf( outfile, "%s/%s.png", outputDir_, name );
	OBPCanvas->Print( outfile );
	
	return passcut;
}
Beispiel #2
0
// getPdfQcd
//------------------------------------------------------------------------------
void getPdfQcd(TString process)
{
  gInterpreter->ExecuteMacro("PaperStyle.C");

  if (_savefigures) gSystem->mkdir("figures", kTRUE);

  TFile* file = new TFile("../minitrees/check/TTDM/" + process + ".root");

  TH1D* h_weights_gen = (TH1D*)file->Get("list_vectors_weights");


  TTree* tree = (TTree*)file->Get("latino");

  tree -> Draw( "0*LHEweight+Iteration$+0.5 >> myhistogram(200, 0, 200)", "LHEweight[Iteration$]"*selection );

  TH1D* h_weights_rec = (TH1D*) gDirectory->Get( "myhistogram" );

  h_weights_rec -> Draw(); 
	

  // Produce the QCD uncertainties
  //----------------------------------------------------------------------------
  float qcd_gen_mu05 = h_weights_gen->GetBinContent(9) / h_weights_gen->GetBinContent(1);
  float qcd_gen_mu20 = h_weights_gen->GetBinContent(5) / h_weights_gen->GetBinContent(1);

  float qcd_rec_mu05 = h_weights_rec->GetBinContent(9) / h_weights_rec->GetBinContent(1);
  float qcd_rec_mu20 = h_weights_rec->GetBinContent(5) / h_weights_rec->GetBinContent(1);


  // Produce the PDF uncertainties
  //----------------------------------------------------------------------------
  TH1D* h_pdfratio = new TH1D("h_pdfratio", "", 100, 0.965, 1.035);

  float denominator = h_weights_rec->GetBinContent(1) / h_weights_gen->GetBinContent(1);  // Nominal values

  for (int i=10; i<110; i++)
    {
      float numerator = h_weights_rec->GetBinContent(i) / h_weights_gen->GetBinContent(i);

      float ratio = numerator / denominator;

      h_pdfratio->Fill(ratio);
    }


  // Draw the PDF distribution
  //----------------------------------------------------------------------------
  TCanvas* canvas = new TCanvas("canvas", "canvas");

  h_pdfratio->SetFillColor(kRed+1);
  h_pdfratio->SetFillStyle(  1001);
  h_pdfratio->SetLineColor(kRed+1);

  h_pdfratio->Draw("hist");

  h_pdfratio->SetXTitle("#frac{N_{rec}^{PDF} / N_{gen}^{PDF}}{N_{rec}^{nominal} / N_{gen}^{nominal}}");
  h_pdfratio->SetYTitle("entries / bin");

  h_pdfratio->GetXaxis()->SetTitleOffset(2.0);

  canvas->GetFrame()->DrawClone();

  if (_savefigures)
    {
      canvas->SaveAs("figures/pdfacceptance.pdf");
      canvas->SaveAs("figures/pdfacceptance.png");
    }


  // Produce the alpha_s uncertainties
  //----------------------------------------------------------------------------
  float alpha_gen_265000 = h_weights_gen->GetBinContent(110) / h_weights_gen->GetBinContent(1);
  float alpha_gen_266000 = h_weights_gen->GetBinContent(111) / h_weights_gen->GetBinContent(1);

  float alpha_rec_265000 = h_weights_rec->GetBinContent(110) / h_weights_rec->GetBinContent(1);
  float alpha_rec_266000 = h_weights_rec->GetBinContent(111) / h_weights_rec->GetBinContent(1);


  // Prepare the final uncertainties
  //----------------------------------------------------------------------------
  float qcd_mu05 = 1e2 * fabs(1. - qcd_rec_mu05 / qcd_gen_mu05);
  float qcd_mu20 = 1e2 * fabs(1. - qcd_rec_mu20 / qcd_gen_mu20);

  float alpha_265000 = 1e2 * fabs(1. - alpha_rec_265000 / alpha_gen_265000);
  float alpha_266000 = 1e2 * fabs(1. - alpha_rec_266000 / alpha_gen_266000);

  float pdf = 1e2 * h_pdfratio->GetRMS();

  float pdf_alpha = sqrt(pdf*pdf + (alpha_265000*alpha_265000 + alpha_266000*alpha_266000)/2.);


  // Print the final uncertainties
  //----------------------------------------------------------------------------
  printf("\n Acceptance uncertainties for the process: %s \n", process.Data());
  printf("-----------------------------------------\n");
  printf(" nominal acceptance * eff      %4.2f%%\n", 1e2 * h_weights_rec->GetBinContent(1) / h_weights_gen->GetBinContent(1));
  printf(" QCD         mu=0.5 / mu=2.0   %4.2f%% / %4.2f%%\n", qcd_mu05, qcd_mu20);
  //printf(" alpha_s     265000 / 266000   %4.2f%% / %4.2f%%\n", alpha_265000, alpha_266000);
  printf(" PDF                           %4.2f%%\n", pdf);
  //printf(" PDF+alpha_s                   %4.2f%%\n", pdf_alpha);
  printf("\n");
}
Beispiel #3
0
void kees_gen() {
  gROOT->SetStyle("HALLA");
  TCanvas *cn = new TCanvas("cn");
  cn->Draw();
  cn->UseCurrentStyle();
  TH1F *frm = new TH1F("frm","",100,0.,10.);
  frm->GetXaxis()->SetTitle("Q^{2}  [GeV^{2}]");
  frm->GetYaxis()->SetTitle("G_{E}^{n}");
  frm->SetMinimum(-.02);
  frm->SetMaximum(0.1);
  frm->UseCurrentStyle();
  frm->Draw();
  frm->SetAxisRange(0.,5.,"X");

  TF1 *genf = new TF1("genf",genff,1.,10.,1);
  genf->SetLineColor(2);
  genf->SetLineStyle(2);
  genf->SetParameter(0,1.);
  genf->SetParameter(1,.3);
  genf->SetParameter(0,-0.632);
  // match to Madey point just below 1.5
  //  genf->SetParameter(0,.0411/genf->Eval(1.45));
  
  TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}");
  TLegend *legDta = new TLegend(.54,.6,.875,.90,"","brNDC");

  TMultiGraph* wgr = mgrDta;
  TLegend *wlg = legDta;

   // the data
  legDta->SetBorderSize(0); // turn off border
  legDta->SetFillStyle(0);
  
  datafile_t *f = datafiles;
  TGraph* gr=0;
  while ( f && f->filename ) {
    gr=OneGraph(f);
    if (gr) {
      if (f->lnpt) {
	mgrDta->Add(gr,f->lnpt);
	legDta->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	mgrDta->Add(gr,"p");
	legDta->AddEntry(gr,f->label,"p");
      }	
      else {
	mgrDta->Add(gr,"l");
	legDta->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }
    

  mgrDta->Draw("p");
  //  legDta->Draw();   don't draw the data legend
  
  TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}");
  TLegend *legThry = new TLegend(.54,.6,.875,.9,"","brNDC");

  wgr = mgrThry;
  wlg = legThry;

  // the theory
  wlg->SetBorderSize(0); // turn off border
  wlg->SetFillStyle(0);
  
  f = theoryfiles1;
  gr=0;
  while ( f && f->filename ) {
    gr=OneGraph(f);
    if (gr) {
      TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
      if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) {
	gr = toerror_band(egr);
	gr->SetFillStyle(3000+f->style);
      }
      if (f->lnpt) {
	wgr->Add(gr,f->lnpt);
	wlg->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	wgr->Add(gr,"p");
	wlg->AddEntry(gr,f->label,"p");
      }	
      else {
	wgr->Add(gr,"l");
	wlg->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }

  genf->Draw("same");
  mgrThry->Draw("c");
  legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l");
  legThry->Draw();

  // draw a line at 1
  cn->Modified();

  cn->Update();
  cn->SaveAs(Form("%s.eps",psfile));
  cn->SaveAs(Form("%s.root",psfile));
  gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));
  // now an overlay, hopefully matching dimensions

  // remove everything but the graph
  cn->Update();
  TList *clist = cn->GetListOfPrimitives();
  TFrame* frame = cn->GetFrame();
  for (int i=0; i<clist->GetSize(); ) {
    if (clist->At(i) != frame) {
      clist->RemoveAt(i);
    } else i++;
  }
  // draw markers in the corners
  TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX1(),frame->GetY2(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY2(),2);
  mkr->Draw();
  frame->SetLineColor(10);
  cn->Update();

  datafile_t miller = { "figure_input/Miller/lattice.GEn.rtf","Miller",
			"[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" };

  gr = OneGraph(&miller);
  TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
  if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
    gr = toerror_band(egr);
    gr->SetLineStyle(1);
    gr->SetFillColor(gr->GetLineColor());
    gr->SetFillStyle(3000+miller.style);
  }
  
  gr->Draw("F");

  cn->Update();
  cn->SaveAs("gen_Miller_Overlay.eps");
  cn->SaveAs("gen_Miller_Overlay.root");
  
}
void long_Ay_nu_05() {
  gROOT->SetStyle("HALLA");
  TCanvas *cn = new TCanvas("cn","cn",540,360);
  cn->Draw();
  cn->UseCurrentStyle();
  TH1F *frm = new TH1F("frm","",100,0.,10.);
  frm->GetXaxis()->SetTitle("#nu (GeV)");
  frm->GetYaxis()->SetTitle("Ay for Q2=0.456 (GeV/c)2");
  frm->SetMinimum(0);
//  frm->SetMinimum(0);
//  frm->SetMaximum(1.0);
  frm->SetMaximum(0.35);
  frm->UseCurrentStyle();
  frm->Draw();
  frm->SetAxisRange(0.120,0.350,"X");
//  frm->SetAxisRange(0.5,1.1,"X");

//  TF1* galster = new TF1("galster","x/(4.*0.938*.938)*1.91/(1.+x/.71)^2/(1.+5.6*x/(4.*.938*.938))",0.,4.);
//  galster->SetLineColor(6);
//  galster->SetLineStyle(3);
//  galster->SetLineWidth(2);


  TF1 *genf = new TF1("genf",genff,1.,10.,1);
  genf->SetLineColor(2);
  genf->SetLineStyle(2);
  genf->SetParameter(0,1.);
  // match to Madey point just below 1.5
  // genf->SetParameter(0,.0411/genf->Eval(1.45));
  genf->SetParameter(0,-0.558645);

//  TF1 *bbba05 = new TF1("BBBA05",gen_bbba05,0.,10.,0);
//  bbba05->SetLineColor(7);
//  bbba05->SetLineStyle(3);

  
  TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}");
  TLegend *legDta = new TLegend(.54,.6,.875,.90,"","brNDC");

  TMultiGraph* wgr = mgrDta;
  TLegend *wlg = legDta;

   // the data
  legDta->SetBorderSize(0); // turn off border
  legDta->SetFillStyle(0);
  
  datafile_t *f = datafiles;
  TGraph* gr=0;
  while ( f && f->filename ) {
    gr=OneGraph(f);
    if (gr) {
      if (f->lnpt) {
	mgrDta->Add(gr,f->lnpt);
	legDta->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	mgrDta->Add(gr,"p");
	legDta->AddEntry(gr,f->label,"p");
      }	
      else {
	mgrDta->Add(gr,"l");
	legDta->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }
    

  mgrDta->Draw("p");
//  legDta->Draw();
  TF1 *theFit = new TF1("theFit","pol0");
  gr->Fit(theFit);
  theFit->Draw("same");  
  TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}");
  TLegend *legThry = new TLegend(.54,.3,.875,.6,"","brNDC");

  wgr = mgrThry;
  wlg = legThry;

  // the theory
  wlg->SetBorderSize(0); // turn off border
  wlg->SetFillStyle(0);
  
  f = theoryfiles1;
  gr=0;
  while ( f && f->filename ) {
    gr=OneGraph(f);
    if (gr) {
      TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
      if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) {
	gr = toerror_band(egr);
	gr->SetFillStyle(3000+f->style);
      }
      if (f->lnpt) {
	wgr->Add(gr,f->lnpt);
	wlg->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	wgr->Add(gr,"p");
	wlg->AddEntry(gr,f->label,"p");
      }	
      else {
	wgr->Add(gr,"l");
	wlg->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }

//  genf->Draw("same");
  mgrThry->Draw("c");
//  galster->Draw("same");
//  bbba05->Draw("same");
//  legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l");
//  legThry->AddEntry(galster,"Galster fit","l");
//  legThry->AddEntry(bbba05,"BBBA05","l");
//  legThry->Draw();
//  legDta->Draw();
  
  // draw a line at 1
  cn->Modified();

  cn->Update();
  cn->SaveAs(Form("%s.eps",psfile));
  cn->SaveAs(Form("%s.root",psfile));
  gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));

  return;  // LEAVING HERE

  // now an overlay, hopefully matching dimensions

  // remove everything but the graph
  cn->Update();
  TList *clist = cn->GetListOfPrimitives();
  TFrame* frame = cn->GetFrame();
  for (int i=0; i<clist->GetSize(); ) {
    if (clist->At(i) != frame) {
      clist->RemoveAt(i);
    } else i++;
  }
  // draw markers in the corners
  TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX1(),frame->GetY2(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY2(),2);
  mkr->Draw();
  frame->SetLineColor(10);
  cn->Update();

  datafile_t miller = { "figure_input/Miller/lattice.GEn.rtf","Miller",
			"[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" };

  gr = OneGraph(&miller);
  TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
  if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
    gr = toerror_band(egr);
    gr->SetLineStyle(1);
    gr->SetFillColor(gr->GetLineColor());
    gr->SetFillStyle(3000+miller.style);
  }
  
  gr->Draw("F");

  cn->Update();
  cn->SaveAs("gen_Miller_Overlay.eps");
  cn->SaveAs("gen_Miller_Overlay.root");
  
}
//___________________________________________________________________________________
void CalibEI(const Int_t ii, const Int_t opt)
{
  // i - # of the MWPC
  // opt - option to plot
  
  
  TGraphErrors *grMean, *grSigma;
  TCanvas *cnv;
  TH1D *h1;
  TH2D *h2;
  TH3D *h3;
  TLine *lZ = new TLine(-300.,0.,300.,0.);
  lZ->SetLineColor(kBlue);
  lZ->SetLineWidth(2.);
  TLine *lPhi = new TLine(0.,0.,360.,0.);
  lPhi->SetLineColor(kBlue);
  lPhi->SetLineWidth(2.);
  
  //
  TString i;
  stringstream ss;
  ss << ii;
  ss >> i;
  
  //
  switch (opt)
  {
    case 1:
      // dPhiEI
      cnv = new TCanvas("cEI"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DphiEI"+i);
      h1->Draw();
      h1->Fit("gaus","","",-.6,.6);
      //   hEI->Fit("gaus");
      break;
      
    case 2:
      // dPhiEI(Z)
      cnv = new TCanvas("cEIZ"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiEI"+i+"_v_ZInters"+i);
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-1.,1.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("cEIZ_Sigma"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhiEI(Z)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("cEIZ_Mean"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhiEI(Z)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 3:
      // dPhiEI(Phi)
      cnv = new TCanvas("cEIPhi"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiEI"+i+"_v_PhiEI"+i);
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-1.,1.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("cEIPhi_Sigma"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhiEI(Phi)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("cEIPhi_Mean"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhiEI(Phi)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
    
    case 23:
      cnv = new TCanvas("cEIPhi_v_Phi_v_Z"+i);
      h3 = (TH3D*)gDirectory->Get("dPhiEI_PhiEI_Zinters_"+i);
      TF2 *f2 = new TF2("f1", "[0]+x*[1]+y*[2]",0.,360.,-250,250.);
      h3->Fit(f2);
      h3->Draw("same");
      break;
      
    case 4:
      // dPhiEI(CGW)
      cnv = new TCanvas("cEIPhi_v_CGW"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiEI"+i+"_v_CGclW"+i);
      h2->Draw("color");
      lPhi->Draw("same");
      break;
      
    case 5:
      // dPhiEI(CGI)
      cnv = new TCanvas("cEIPhi_v_CGI"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiEI"+i+"_v_CGclI"+i);
      h2->Draw("color");
      lPhi->Draw("same");
      break;
      
    case 6:
      // dPhiEI(CGE)
      cnv = new TCanvas("cEIPhi_v_CGE"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiEI"+i+"_v_CGclE"+i);
      h2->Draw("color");
      lPhi->Draw("same");
      break;
      
    default:
      for (Int_t j=1; j<=6; ++j) CalibEI(i,j);
  }
}
Beispiel #6
0
//------------------------------------------------------------------------------
// DrawIt
//------------------------------------------------------------------------------
void DrawIt(TString filename,
	    TString hname,
	    TString cname,
	    TString title)
{
  TFile* inputfile = TFile::Open("../AuxiliaryFilesWZXS8TeV/" + filename + ".root");

  TH2F* h = (TH2F*)inputfile->Get(hname)->Clone(cname);

  h->SetDirectory(0);

  inputfile->Close();

  TString name = h->GetName();

  TCanvas* canvas = new TCanvas(name, name, 600, 600);

  if (name.Contains("PR")) canvas->SetLogx();
  if (name.Contains("SF")) canvas->SetLogx();

  canvas->SetLeftMargin (0.9 * canvas->GetLeftMargin());
  canvas->SetRightMargin(3.5 * canvas->GetRightMargin());
  canvas->SetTopMargin  (1.2 * canvas->GetTopMargin());

  TH2FAxisFonts(h, "x", "p_{T} [GeV]");
  TH2FAxisFonts(h, "y", "#eta");

  h->Draw("colz");

  h->SetTitle("");

  DrawTLatex(42, 0.940, 0.976, _bigLabelSize, 33, title);

  if (!title.Contains("trigger")) {

    Double_t hmin = h->GetMinimum();
    Double_t hmax = h->GetMaximum();

    for (Int_t i=1; i<=h->GetNbinsX(); i++) {
      for (Int_t j=1; j<=h->GetNbinsY(); j++) {

	Double_t value = h->GetBinContent(i,j);

	Double_t ypos = h->GetYaxis()->GetBinCenter(j);
	Double_t xpos = h->GetXaxis()->GetBinCenter(i);
      
	if (gPad->GetLogx()) xpos = h->GetXaxis()->GetBinCenterLog(i);

	TLatex* latex = new TLatex(xpos, ypos, Form("%.2f", value));

	latex->SetTextAlign(   22);
	latex->SetTextFont (   42);
	latex->SetTextSize (0.027);

	if (value < hmin + 0.3*(hmax - hmin)) latex->SetTextColor(kWhite);
	
	latex->Draw();
      }
    }
  }


  // Set the palette font
  //----------------------------------------------------------------------------
  canvas->Update();

  TPaletteAxis* palette = (TPaletteAxis*)h->GetListOfFunctions()->FindObject("palette");

  palette->SetLabelFont(42);


  // Save the plot
  //----------------------------------------------------------------------------
  canvas->Update();
  
  canvas->Modified();

  canvas->GetFrame()->DrawClone();

  canvas->SaveAs("pdf/scale_factors/" + name + ".pdf");
  canvas->SaveAs("png/scale_factors/" + name + ".png");
}
// Give the macro empty histograms for h->Draw("AXIS");
// Create h after calling setTDRStyle to get all the settings right
// Created by: Mikko Voutilainen (HIP)
TCanvas* tdrDiCanvas(const char* canvName, TMultiGraph *hup, TGraph *hdw,
		   int iPeriod = 2, int iPos = 11) {

  setTDRStyle();

  // Reference canvas size
  // We'll add a subpad that is a fraction (1/3) of the top canvas size,
  // while keeping margins and text sizes as they were for a single pad
  int W_ref = 600;
  int H_ref = 600;

  // Set bottom pad relative height and relative margin
  float F_ref = 1./3.;
  float M_ref = 0.03;

  // Set reference margins
  float T_ref = 0.07;
  float B_ref = 0.13;
  float L = 0.15;
  float R = 0.05;

  // Calculate total canvas size and pad heights
  int W = W_ref;
  int H = H_ref * (1 + (1-T_ref-B_ref)*F_ref+M_ref);
  float Hup = H_ref * (1-B_ref);
  float Hdw = H - Hup;

  // references for T, B, L, R
  float Tup = T_ref * H_ref / Hup;
  float Tdw = M_ref * H_ref / Hdw;
  float Bup = 0.01;
  float Bdw = B_ref * H_ref / Hdw;

  TCanvas *canv = new TCanvas(canvName,canvName,50,50,W,H);
  canv->SetFillColor(0);
  canv->SetBorderMode(0);
  canv->SetFrameFillStyle(0);
  canv->SetFrameBorderMode(0);
  // FOR JEC plots, prefer to keep ticks on both sides
  //canv->SetTickx(0);
  //canv->SetTicky(0);

  canv->SetFrameLineColor(0);
  canv->SetFrameLineWidth(0);
  canv->Divide(1,2);

  canv->cd(1);
  gPad->SetPad(0, Hdw / H, 1, 1);
/*  gPad->SetFillStyle(1001);*/
  /*gPad->SetFillColor(4);*/
  gPad->SetLeftMargin( L );
  gPad->SetRightMargin( R );
  gPad->SetTopMargin( Tup );
  gPad->SetBottomMargin( Bup );

  //assert(hup);
  hup->Draw("A");
  
  // Scale text sizes and margins to match normal size
  hup->GetYaxis()->SetTitleOffset(1.25 * Hup / H_ref);
  //hup->GetYaxis()->SetTitleOffset(1.25 * Hup / H_ref - 0.01);
  hup->GetXaxis()->SetTitleOffset(1.0);
  hup->GetYaxis()->SetTitleSize(hup->GetYaxis()->GetTitleSize() * H_ref / Hup);
  hup->GetYaxis()->SetLabelSize(hup->GetYaxis()->GetLabelSize() * H_ref / Hup);
  hup->GetXaxis()->SetLabelSize(0);

  // Set tick lengths to match original
  hup->GetYaxis()->SetTickLength(hup->GetYaxis()->GetTickLength() * Hup / H_ref);
  hup->GetXaxis()->SetTickLength(hup->GetXaxis()->GetTickLength() * H_ref / Hup);

  hup->Draw("AXIS");

  // writing the lumi information and the CMS "logo"
  CMS_lumi( (TCanvas*)gPad, iPeriod, iPos );

  canv->cd(2);
  gPad->SetPad(0, 0, 1, Hdw / H);
  gPad->SetLeftMargin( L );
  gPad->SetRightMargin( R );
  gPad->SetTopMargin( Tdw );
  gPad->SetBottomMargin( Bdw );

/*  gPad->SetFillStyle(1001);*/
  /*gPad->SetFillColor(5);*/
  //assert(hdw);
  hdw->Draw("A");
  hdw->GetYaxis()->SetTitleOffset(1.25);
  hdw->GetXaxis()->SetTitleOffset(1.0);

  // Scale text sizes and margins to match normal size
  hdw->GetYaxis()->SetTitleOffset(1.25 * Hdw / H_ref);
  //hdw->GetXaxis()->SetTitleOffset(1.0);
  hdw->GetXaxis()->SetTitleOffset(1.0 - 0.1);
  hdw->GetYaxis()->SetTitleSize(hdw->GetYaxis()->GetTitleSize() * H_ref / Hdw);
  hdw->GetYaxis()->SetLabelSize(hdw->GetYaxis()->GetLabelSize() * H_ref / Hdw);
  hdw->GetXaxis()->SetTitleSize(hdw->GetXaxis()->GetTitleSize() * H_ref / Hdw);
  hdw->GetXaxis()->SetLabelSize(hdw->GetXaxis()->GetLabelSize() * H_ref / Hdw);

  // Set tick lengths to match original (these are fractions of axis length)
  hdw->GetYaxis()->SetTickLength(hdw->GetYaxis()->GetTickLength() * H_ref / Hup); //?? ok if 1/3
  hdw->GetXaxis()->SetTickLength(hdw->GetXaxis()->GetTickLength() * H_ref / Hdw);

  // Reduce divisions to match smaller height (default n=510, optim=kTRUE)
  hdw->GetYaxis()->SetNdivisions(504);

  hdw->Draw("AXIS");

  canv->cd(0);

  canv->Update();
  canv->RedrawAxis();
  canv->GetFrame()->Draw();
  
  return canv;
}
Beispiel #8
0
TCanvas* tdrCanvas(const char* canvName, TH1D *h,
  int iPeriod = 2, int iPos = 11,
  bool square = kRectangular) {

  setTDRStyle();
  
  //writeExtraText = true; // if extra text
  //extraText = "Preliminary"; // default extra text is "Preliminary"
  //lumi_8TeV = "19.5 fb^{-1}"; // default is "19.7 fb^{-1}"
  //lumi_7TeV = "5.0 fb^{-1}"; // default is "5.1 fb^{-1}"
  //int iPeriod = 3; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV
  // second parameter in example_plot is iPos, which drives the position of the CMS logo in the plot
  // iPos=11 : top-left, left-aligned
  // iPos=33 : top-right, right-aligned
  // iPos=22 : center, centered
  // iPos=0 : out of frame (in exceptional cases)
  // mode generally :
  // iPos = 10*(alignement 1/2/3) + position (1/2/3 = left/center/right)
  // if( iPos==0 ) relPosX = 0.12;
  
  int W = (square ? 600 : 800);
  int H = (square ? 600 : 600);
  
  //
  // Simple example of macro: plot with CMS name and lumi text
  // (this script does not pretend to work in all configurations)
  // iPeriod = 1*(0/1 7 TeV) + 2*(0/1 8 TeV) + 4*(0/1 13 TeV)
  // For instance:
  // iPeriod = 3 means: 7 TeV + 8 TeV
  // iPeriod = 7 means: 7 TeV + 8 TeV + 13 TeV
  // Initiated by: Gautier Hamel de Monchenault (Saclay)
  //
  
  int W_ref = (square ? 600 : 800);
  int H_ref = (square ? 600 : 600);
  
  // references for T, B, L, R
  
  //float T = (square ? 0.07*H_ref : 0.08*H_ref);
  float T = (square ? 0.07*H_ref : 0.08*H_ref);
  //float B = (square ? 0.13*H_ref : 0.12*H_ref);
  float B = (square ? 0.1*H_ref : 0.12*H_ref);
  //float L = (square ? 0.15*W_ref : 0.12*W_ref);
  float L = (square ? 0.12*W_ref : 0.12*W_ref);
  //float R = (square ? 0.05*W_ref : 0.04*W_ref);
  float R = (square ? 0.17*W_ref : 0.04*W_ref);
  
  TCanvas *canv = new TCanvas(canvName,canvName,50,50,W,H);
  canv->SetFillColor(0);
  canv->SetBorderMode(0);
  canv->SetFrameFillStyle(0);
  canv->SetFrameBorderMode(0);
  canv->SetLeftMargin( L/W );
  canv->SetRightMargin( R/W );
  canv->SetTopMargin( T/H );
  canv->SetBottomMargin( B/H );
 
  // FOR JEC plots, prefer to keep ticks on both sides
  //canv->SetTickx(0);
  //canv->SetTicky(0);
  
  assert(h);
  h->GetYaxis()->SetTitleOffset(square ? 1.25 : 1);
  h->GetXaxis()->SetTitleOffset(square ? 1.0 : 0.9);
  h->Draw("AXIS");
  
  // writing the lumi information and the CMS "logo"
  CMS_lumi( canv, iPeriod, iPos );
  canv->Update();
  canv->RedrawAxis();
  canv->GetFrame()->Draw();
  return canv;
}
Beispiel #9
0
TCanvas* example_plot( int iPeriod, int iPos )
{ 
  //  if( iPos==0 ) relPosX = 0.12;

  int W = 800;
  int H = 600;

  int H_ref = 600; 
  int W_ref = 800; 

  // references for T, B, L, R
  float T = 0.08*H_ref;
  float B = 0.12*H_ref; 
  float L = 0.12*W_ref;
  float R = 0.04*W_ref;

  TString canvName = "FigExample_";
  canvName += W;
  canvName += "-";
  canvName += H;
  canvName += "_";  
  canvName += iPeriod;
  if( writeExtraText ) canvName += "-prelim";
  if( iPos%10==0 ) canvName += "-out";
  else if( iPos%10==1 ) canvName += "-left";
  else if( iPos%10==2 )  canvName += "-center";
  else if( iPos%10==3 )  canvName += "-right";

  TCanvas* canv = new TCanvas(canvName,canvName,50,50,W,H);
  canv->SetFillColor(0);
  canv->SetBorderMode(0);
  canv->SetFrameFillStyle(0);
  canv->SetFrameBorderMode(0);
  canv->SetLeftMargin( L/W );
  canv->SetRightMargin( R/W );
  canv->SetTopMargin( T/H );
  canv->SetBottomMargin( B/H );
  canv->SetTickx(0);
  canv->SetTicky(0);


  int histLineColor = kOrange+7;
  int histFillColor = kOrange-2;
  float markerSize  = 1.0;

  {
    TLatex latex;
				
    int n_ = 2;

    float x1_l = 0.92;
    float y1_l = 0.60;

    float dx_l = 0.30;
    float dy_l = 0.18;
    float x0_l = x1_l-dx_l;
    float y0_l = y1_l-dy_l;

    TPad* legend = new TPad("legend_0","legend_0",x0_l,y0_l,x1_l, y1_l );
    //    legend->SetFillColor( kGray );
    legend->Draw();
    legend->cd();
		
    float ar_l = dy_l/dx_l;
		
    float x_l[1];
    float ex_l[1];
    float y_l[1];
    float ey_l[1];
		
    //    float gap_ = 0.09/ar_l;
    float gap_ = 1./(n_+1);
		
    float bwx_ = 0.12;
    float bwy_ = gap_/1.5;
		
    x_l[0] = 1.2*bwx_;
    //    y_l[0] = 1-(1-0.10)/ar_l;
    y_l[0] = 1-gap_;
    ex_l[0] = 0;
    ey_l[0] = 0.04/ar_l;
		
    TGraph* gr_l = new TGraphErrors(1, x_l, y_l, ex_l, ey_l );
		
    gStyle->SetEndErrorSize(0);
    gr_l->SetMarkerSize(0.9);
    gr_l->Draw("0P");
		
    latex.SetTextFont(42);
    latex.SetTextAngle(0);
    latex.SetTextColor(kBlack);    
    latex.SetTextSize(0.25);    
    latex.SetTextAlign(12); 
		
    TLine line_;
    TBox  box_;
    float xx_ = x_l[0];
    float yy_ = y_l[0];
    latex.DrawLatex(xx_+1.*bwx_,yy_,"Data");
		
    yy_ -= gap_;
    box_.SetLineStyle( kSolid );
    box_.SetLineWidth( 1 );
    //		box_.SetLineColor( kBlack );
    box_.SetLineColor( histLineColor );
    box_.SetFillColor( histFillColor );
    box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 );
    box_.SetFillStyle(0);
    box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 );
    latex.DrawLatex(xx_+1.*bwx_,yy_,"Z #rightarrow e^{+}e^{-} (MC)");

    canv->cd();
  }

  {

   TGraphErrors *gre = new TGraphErrors(12);
   gre->SetName("Graph0");
   gre->SetTitle("");
   gre->SetFillColor(1);

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

   ci = TColor::GetColor("#0000ff");
   gre->SetMarkerColor(ci);
   gre->SetMarkerStyle(21);
   gre->SetPoint(0,0.1428571,0.943962);
   gre->SetPointError(0,0,0.00470259);
   gre->SetPoint(1,0.1714286,0.940484);
   gre->SetPointError(1,0,0.00447348);
   gre->SetPoint(2,0.2,0.935519);
   gre->SetPointError(2,0,0.00484668);
   gre->SetPoint(3,0.2285714,0.928495);
   gre->SetPointError(3,0,0.00504356);
   gre->SetPoint(4,0.2571429,0.931586);
   gre->SetPointError(4,0,0.00551296);
   gre->SetPoint(5,0.2857143,0.924183);
   gre->SetPointError(5,0,0.00521949);
   gre->SetPoint(6,0.3142857,0.925186);
   gre->SetPointError(6,0,0.00541335);
   gre->SetPoint(7,0.3428572,0.918469);
   gre->SetPointError(7,0,0.00520881);
   gre->SetPoint(8,0.3714286,0.926619);
   gre->SetPointError(8,0,0.00524148);
   gre->SetPoint(9,0.4,0.931496);
   gre->SetPointError(9,0,0.00526956);
   gre->SetPoint(10,0.4285714,0.932581);
   gre->SetPointError(10,0,0.00466349);
   gre->SetPoint(11,0.4571429,0.924199);
   gre->SetPointError(11,0,0.00348535);
   
   TH1F *Graph_Graph1 = new TH1F("Graph_Graph1","",100,0.1114286,0.4885714);
   Graph_Graph1->SetMinimum(0);
   Graph_Graph1->SetMaximum(1);
   Graph_Graph1->SetDirectory(0);
   Graph_Graph1->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1->SetLineColor(ci);
   Graph_Graph1->GetXaxis()->SetTitle("Threshold (pC)");
   Graph_Graph1->GetXaxis()->CenterTitle(true);
   Graph_Graph1->GetXaxis()->SetLabelFont(42);
   Graph_Graph1->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1->GetXaxis()->SetTitleSize(0.05);
   Graph_Graph1->GetXaxis()->SetTitleFont(42);
   Graph_Graph1->GetYaxis()->SetTitle("Efficiency");
   Graph_Graph1->GetYaxis()->SetRange(0,1);
   Graph_Graph1->GetYaxis()->CenterTitle(true);
   Graph_Graph1->GetYaxis()->SetLabelFont(42);
   Graph_Graph1->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1->GetYaxis()->SetTitleSize(0.05);
   Graph_Graph1->GetYaxis()->SetTitleFont(42);
   Graph_Graph1->GetZaxis()->SetLabelFont(42);
   Graph_Graph1->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1);
   
   gre->Draw("ap");

  }

  TLegend *leg = new TLegend(0.55,0.35,0.70,0.50);
  leg->SetTextSize(0.035);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(0);
  leg->SetBorderSize(0);
  leg->SetHeader("GIF++ test beams 08.2015");
  leg->AddEntry(gre, "Low Resistivity Glass RPC", "p");
  leg->Draw();

  // writing the lumi information and the CMS "logo"
  CMS_lumi( canv, iPeriod, iPos );

  canv->Update();
  canv->RedrawAxis();
  canv->GetFrame()->Draw();

  canv->Print(canvName+".pdf",".pdf");
  canv->Print(canvName+".png",".png");

  return canv;
}
Beispiel #10
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// drawFigure6
//
//    logy = 0
//    logy = 1
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void drawFigure6(Int_t logy = 0)
{
  gInterpreter->ExecuteMacro("WZPaperStyle.C");

  gSystem->mkdir("pdf", kTRUE);
  gSystem->mkdir("png", kTRUE);


  // Read the input file
  //----------------------------------------------------------------------------
  TString name = "WZ_PtZ_plot_allCh_largeATGC";

  TFile* file = new TFile("rootfiles/" + name + ".root", "read");

  TCanvas* c1 = (TCanvas*)file->Get("c1_allCh");

  TH1F* data     = (TH1F*)c1->FindObject("histo_data_3e");
  TH1F* aTGC_dk  = (TH1F*)c1->FindObject("histo_aTGC_dk_3e");
  TH1F* aTGC_lam = (TH1F*)c1->FindObject("histo_aTGC_lam_3e");
  TH1F* aTGC_dg  = (TH1F*)c1->FindObject("histo_aTGC_dg_3e");
  TH1F* WZ       = (TH1F*)c1->FindObject("histo_SM_3e");
  TH1F* fakes    = (TH1F*)c1->FindObject("fake_0");
  TH1F* ZZ       = (TH1F*)c1->FindObject("total_bkg_rebined_ZZ_0");
  TH1F* Zgamma   = (TH1F*)c1->FindObject("total_bkg_rebined_Zgamma_0");
  TH1F* WV       = (TH1F*)c1->FindObject("total_bkg_rebined_WV_0");
  TH1F* VVV      = (TH1F*)c1->FindObject("total_bkg_rebined_VVV_0");

  WZ->SetFillColor(kOrange-2);
  WZ->SetLineColor(kOrange-2);

  Zgamma->SetFillColor(kRed+1);
  Zgamma->SetLineColor(kRed+1);

  ZZ->SetFillColor(kRed+1);
  ZZ->SetLineColor(kRed+1);

  fakes->SetFillColor(kGray+1);
  fakes->SetLineColor(kGray+1);

  WV->SetFillColor(kRed+1);
  WV->SetLineColor(kRed+1);

  VVV->SetFillColor(kRed+1);
  VVV->SetLineColor(kRed+1);


  // Draw
  //----------------------------------------------------------------------------
  TCanvas* canvas = new TCanvas("canvas", "canvas");

  canvas->SetLogy(logy);

  data->Draw("ep");


  // Axis labels
  //----------------------------------------------------------------------------
  TAxis* xaxis = data->GetXaxis();
  TAxis* yaxis = data->GetYaxis();
  
  xaxis->SetLabelFont  (  42);
  xaxis->SetLabelOffset(0.01);
  xaxis->SetLabelSize  (0.05);
  xaxis->SetNdivisions ( 505);
  xaxis->SetTitleFont  (  42);
  xaxis->SetTitleOffset( 1.2);
  xaxis->SetTitleSize  (0.05);

  yaxis->SetLabelFont  (  42);
  yaxis->SetLabelOffset(0.01);
  yaxis->SetLabelSize  (0.05);
  yaxis->SetNdivisions ( 505);
  yaxis->SetTitleFont  (  42);
  yaxis->SetTitleOffset( 1.6);
  yaxis->SetTitleSize  (0.05);

  xaxis->SetTitle("p_{T}^{Z} (GeV)");
  yaxis->SetTitle(Form("Events /  %.0f GeV", data->GetBinWidth(0)));


  // Adjust scale
  //----------------------------------------------------------------------------
  Float_t theMax   = GetMaximumIncludingErrors(data);
  Float_t theMaxMC = GetMaximumIncludingErrors(aTGC_dk);

  if (theMaxMC > theMax) theMax = theMaxMC;

  if (canvas->GetLogy()) {
    data->SetMaximum(15 * theMax);
    data->SetMinimum(1);
  } else {
    data->SetMaximum(1.2 * theMax);
  }


  // Legend
  //----------------------------------------------------------------------------
  Double_t x0;
  Double_t y0;

  if (logy)
    {
      x0 = 0.630;
      y0 = 0.765;

      DrawTLegend(x0 - 0.37, y0 + 2.*(_yoffset+0.001), data,     " Data",                              "ep");
      DrawTLegend(x0 - 0.37, y0 + 1.*(_yoffset+0.001), aTGC_dk,  " WZ aTGC (#Delta#kappa^{Z} = 0.6)",  "l");
      DrawTLegend(x0 - 0.37, y0,                       aTGC_dg,  " WZ aTGC (#Deltag^{Z}_{1} = -0.06)", "l");
      DrawTLegend(x0 - 0.37, y0 - 1.*(_yoffset+0.001), aTGC_lam, " WZ aTGC (#lambda = 0.04)",          "l");
      DrawTLegend(x0,        y0 + 2.*(_yoffset+0.001), WZ,       " WZ",                                "f");
      DrawTLegend(x0,        y0 + 1.*(_yoffset+0.001), fakes,    " Non-prompt leptons",                "f");
      DrawTLegend(x0,        y0,                       ZZ,       " MC background",                     "f");
    }
  else
    {
      x0 = 0.570;
      y0 = 0.755;

      DrawTLegend(x0, y0 + 2.*(_yoffset+0.001), data,     " Data",                              "ep");
      DrawTLegend(x0, y0 + 1.*(_yoffset+0.001), aTGC_dk,  " WZ aTGC (#Delta#kappa^{Z} = 0.6)",  "l");
      DrawTLegend(x0, y0,                       aTGC_dg,  " WZ aTGC (#Deltag^{Z}_{1} = -0.06)", "l");
      DrawTLegend(x0, y0 - 1.*(_yoffset+0.001), aTGC_lam, " WZ aTGC (#lambda = 0.04)",          "l");
      DrawTLegend(x0, y0 - 2.*(_yoffset+0.001), WZ,       " WZ",                                "f");
      DrawTLegend(x0, y0 - 3.*(_yoffset+0.001), fakes,    " Non-prompt leptons",                "f");
      DrawTLegend(x0, y0 - 4.*(_yoffset+0.001), ZZ,       " MC background",                     "f");
    }


  // Finish it
  //----------------------------------------------------------------------------
  data->SetTitle("");

  if (logy)
    {
      DrawTLatex(_cmsTextFont,   0.190, 0.94, 0.055, 11, "CMS");
      //      DrawTLatex(_extraTextFont, 0.315, 0.94, 0.030, 11, "Preliminary");
    }
  else
    {
      DrawTLatex(_cmsTextFont,   0.215, 0.891, 0.055, 13, "CMS");
      //      DrawTLatex(_extraTextFont, 0.215, 0.837, 0.030, 13, "Preliminary");
    }

  DrawTLatex(_lumiTextFont, 0.940, 0.94, 0.040, 31, "19.6 fb^{-1} (8 TeV)");

  WZ      ->Draw("hist,same");
  aTGC_dk ->Draw("hist,same");
  aTGC_lam->Draw("hist,same");
  aTGC_dg ->Draw("hist,same");
  fakes   ->Draw("hist,same");
  ZZ      ->Draw("hist,same");
  Zgamma  ->Draw("hist,same");
  WV      ->Draw("hist,same");
  VVV     ->Draw("hist,same");
  data    ->Draw("ep,same");

  canvas->GetFrame()->DrawClone();
  canvas->RedrawAxis();
  canvas->Update();
  
  TString cname = name;

  if (logy) cname += "_log_range";

  canvas->SaveAs("pdf/" + cname + ".pdf");
  canvas->SaveAs("png/" + cname + ".png");
}
Beispiel #11
0
//***############## main fitting Fxn ################ *****//
void ZeetimeFitAndPlot( char *Ifile ){
 
/** Plot Options***/	
//gROOT->Reset();
// gROOT->Clear();
gROOT->SetStyle("Plain") ;
gROOT->SetBatch(kFALSE);
gStyle->SetOptTitle(0);
gStyle->SetOptStat(0);
gStyle->SetOptFit(1);
gStyle->SetStatX(.89);
gStyle->SetStatY(.89) ;
gStyle->SetStatBorderSize(0);
//gStyle->SetOptStat(1111111)
gStyle->SetCanvasColor(kWhite);   // background is no longer mouse-dropping white
gStyle->SetPalette(1);        // blue to red false color palette. Use 9 for b/w
gStyle->SetCanvasBorderMode(0);     // turn off canvas borders
gStyle->SetPadBorderMode(0);
gStyle->SetPaintTextFormat("5.2f");  // What precision to put numbers if plotted with "TEXT"

// For publishing:
gStyle->SetLineWidth(2);
gStyle->SetTextSize(1.1);
gStyle->SetLabelSize(0.06,"xy");
gStyle->SetTitleSize(0.08,"xy");
gStyle->SetTitleOffset(1.2,"x");
gStyle->SetTitleOffset(1.0,"y");
gStyle->SetPadTopMargin(0.1);
gStyle->SetPadRightMargin(0.1);
gStyle->SetPadBottomMargin(0.16);
gStyle->SetPadLeftMargin(0.12);
TGaxis::SetMaxDigits(2); // Set Axis to be of the form 0.11 10^N


       TFile *ifile  = new TFile(Ifile);
        
	TF1 *fitFcn  = new TF1("fitFcn", mygaus, FitLowRange, FitHighRange, 3 );
	fitFcn->SetNpx(500);
	fitFcn->SetLineWidth(4);
	fitFcn->SetLineStyle(5);
	fitFcn->SetLineColor(kBlue);
        
	TH1F*h_Seed_TimeEBEB = (TH1F*)ifile->Get("EBEB/seed time");
	TH1F*h_Seed_TimeEEEE = (TH1F*)ifile->Get("EEEE/seed time");
	TH1F*h_TofCor_TimeEBEB = (TH1F*)ifile->Get("EBEB/TOF-corr time difference of seeds");
	TH1F*h_TofCor_TimeEEEE = (TH1F*)ifile->Get("EEEE/TOF-corr time difference of seeds");
	
	if(h_Seed_TimeEBEB == 0){ std::cout  <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
	if(h_Seed_TimeEEEE == 0){ std::cout  <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
	if(h_TofCor_TimeEBEB == 0){ std::cout  <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
	if(h_TofCor_TimeEEEE == 0){ std::cout  <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
	
	
	
	
	h_Seed_TimeEBEB->SetTitle("Seed Time[ns]");   
        h_Seed_TimeEBEB->SetMarkerStyle(20);
        h_Seed_TimeEBEB->SetMarkerSize(0.8);
        h_Seed_TimeEBEB->SetStats(1);
        h_Seed_TimeEBEB->SetTitleSize(0.08, "x");   
        h_Seed_TimeEBEB->SetTitleOffset(1.0, "x");    
        h_Seed_TimeEBEB->SetTitleSize(0.06, "y"); 
        h_Seed_TimeEBEB->SetTitleOffset(0.95, "y");    
        h_Seed_TimeEBEB->SetYTitle("Number of Seeds/0.05ns"); 
        h_Seed_TimeEBEB->SetXTitle("t_{seed}[ns]"); 
        h_Seed_TimeEBEB->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange);   
        h_Seed_TimeEBEB->GetXaxis()->SetNoExponent(kFALSE);
       /** Set parms as parms of Fit Fxn **/
	fitFcn->SetParameters(500, h_Seed_TimeEBEB->GetMean(), h_Seed_TimeEBEB->GetRMS() );
	fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)");
	h_Seed_TimeEBEB->Fit("fitFcn", "LL"); /**Fit with improved LL**/
	std::cout << "Printing Fit Parameters for EBEB ......   " << std::endl;
        printf("Integral of function in EBEB = %g\n", fitFcn->Integral( FitLowRange, FitHighRange));

        //*** retrive fit results***//
        int npar = fitFcn->GetNpar();
        TVirtualFitter *fit = TVirtualFitter::GetFitter();
        fit->PrintResults(2,0.);
        TMatrixD *CovMatrix = new TMatrixD ( npar, npar, fit->GetCovarianceMatrix() );
	CovMatrix->Print();
        TCanvas *cBB = new TCanvas("cBB","EB-EB",200,10,800,900);
     	cBB->SetGridx();
     	cBB->SetGridy();
	cBB->GetFrame()->SetFillColor(21);
	cBB->GetFrame()->SetBorderMode(-1);
	cBB->GetFrame()->SetBorderSize(5);
        /* c1->Divide(2,1);  */
	cBB->cd();
	h_Seed_TimeEBEB->Draw();
	fitFcn->Draw("sames");
        cBB->SetLogy(0);
	//  draw the legend
    	TLegend *leg = new TLegend(0.15,0.72,0.3,0.85);
	leg->Clear();
       	leg->SetTextFont(72);
        leg->SetTextSize(0.04);
        leg->AddEntry(h_Seed_TimeEBEB,"EB","lpe");
        leg->AddEntry(fitFcn,"GAUS","l");
        leg->Draw();
	cBB->SaveAs("Seed_Time_DoubleElectron_Run2012A-EB-EB.png");

        //EE seed
	h_Seed_TimeEEEE->SetTitle("Seed Time[ns]");   
        h_Seed_TimeEEEE->SetMarkerStyle(20);
        h_Seed_TimeEEEE->SetMarkerSize(0.8);
        h_Seed_TimeEEEE->SetStats(1);
        h_Seed_TimeEEEE->SetTitleSize(0.08, "x");   
        h_Seed_TimeEEEE->SetTitleOffset(1.0, "x");    
        h_Seed_TimeEEEE->SetTitleSize(0.06, "y"); 
        h_Seed_TimeEEEE->SetTitleOffset(0.95, "y");    
        h_Seed_TimeEEEE->SetYTitle("Number of Seeds/0.05ns"); 
        h_Seed_TimeEEEE->SetXTitle("t_{seed}[ns]"); 
        h_Seed_TimeEEEE->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange);   
        h_Seed_TimeEEEE->GetXaxis()->SetNoExponent(kFALSE);
       /** Set parms as parms of Fit Fxn **/
	fitFcn->SetParameters(500, h_Seed_TimeEEEE->GetMean(), h_Seed_TimeEEEE->GetRMS() );
	fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)");
	h_Seed_TimeEEEE->Fit("fitFcn", "LL"); /**Fit with improved LL**/
	std::cout << "Printing Fit Parameters for EEEE ......   " << std::endl;
        printf("Integral of function in EEEE = %g\n", fitFcn->Integral( FitLowRange, FitHighRange));

        //*** retrive fit results***//
        int npar2 = fitFcn->GetNpar();
        TVirtualFitter *fit2 = TVirtualFitter::GetFitter();
        fit2->PrintResults(2,0.);
        TMatrixD *CovMatrix2 = new TMatrixD ( npar2, npar2, fit2->GetCovarianceMatrix() );
	CovMatrix2->Print();
        TCanvas *cEE = new TCanvas("cEE","EE-EE",200,10,800,900);
     	cEE->SetGridx();
     	cEE->SetGridy();
	cEE->GetFrame()->SetFillColor(21);
	cEE->GetFrame()->SetBorderMode(-1);
	cEE->GetFrame()->SetBorderSize(5);
        /* c1->Divide(2,1);  */
	cEE->cd();
	h_Seed_TimeEEEE->Draw();
	fitFcn->Draw("sames");
        cEE->SetLogy(0);
	//  draw the legend
    	TLegend *leg1 = new TLegend(0.15,0.72,0.3,0.85);
	leg1->Clear();
       	leg1->SetTextFont(72);
        leg1->SetTextSize(0.04);
        leg1->AddEntry(h_Seed_TimeEEEE,"EE","lpe");
        leg1->AddEntry(fitFcn,"GAUS","l");
        leg1->Draw();
	cEE->SaveAs("Seed_Time_DoubleElectron_Run2012A-EE-EE.png");
        
	//EB TOF-corr seed Diff
	h_TofCor_TimeEBEB->SetTitle("TOF-Corrected(t_{1}-t_{2})[ns]");   
        h_TofCor_TimeEBEB->SetMarkerStyle(20);
        h_TofCor_TimeEBEB->SetMarkerSize(0.8);
        h_TofCor_TimeEBEB->SetStats(1);
        h_TofCor_TimeEBEB->SetTitleSize(0.08, "x");   
        h_TofCor_TimeEBEB->SetTitleOffset(1.0, "x");    
        h_TofCor_TimeEBEB->SetTitleSize(0.06, "y"); 
        h_TofCor_TimeEBEB->SetTitleOffset(0.95, "y");    
        h_TofCor_TimeEBEB->SetYTitle("Number Of Seed Pair/0.05ns"); 
        h_TofCor_TimeEBEB->SetXTitle("(t_{seed1} - t_{seed2})TOF-Corrected[ns]"); 
        h_TofCor_TimeEBEB->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange);   
        h_TofCor_TimeEBEB->GetXaxis()->SetNoExponent(kFALSE);
       /** Set parms as parms of Fit Fxn **/
	fitFcn->SetParameters(500, h_TofCor_TimeEBEB->GetMean(), h_TofCor_TimeEBEB->GetRMS() );
	fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)");
	h_TofCor_TimeEBEB->Fit("fitFcn", "LL"); /**Fit with improved LL**/
	std::cout << "Printing Fit Parameters for EBEB-Tof ......   " << std::endl;
        printf("Integral of function in EBEB Tof = %g\n", fitFcn->Integral( FitLowRange, FitHighRange));

        //*** retrive fit results***//
        int npar3 = fitFcn->GetNpar();
        TVirtualFitter *fit3 = TVirtualFitter::GetFitter();
        fit3->PrintResults(2,0.);
        TMatrixD *CovMatrix3 = new TMatrixD ( npar3, npar3, fit3->GetCovarianceMatrix() );
	CovMatrix3->Print();
        TCanvas *cBB1 = new TCanvas("cBB1","EB-EB TOF-corr",200,10,800,900);
     	cBB1->SetGridx();
     	cBB1->SetGridy();
	cBB1->GetFrame()->SetFillColor(21);
	cBB1->GetFrame()->SetBorderMode(-1);
	cBB1->GetFrame()->SetBorderSize(5);
        /* c1->Divide(2,1);  */
	cBB1->cd();
	h_TofCor_TimeEBEB->Draw();
	fitFcn->Draw("sames");
        cBB1->SetLogy(0);
	//  draw the legend
    	TLegend *leg2 = new TLegend(0.15,0.72,0.3,0.85);
       	leg2->SetTextFont(72);
        leg2->SetTextSize(0.04);
        leg2->AddEntry(h_TofCor_TimeEBEB,"EB","lpe");
        leg2->AddEntry(fitFcn,"GAUS","l");
        leg2->Draw();
	cBB1->SaveAs("TOF-Corrected-Seed_Time_DoubleElectron_Run2012A-EB-EB.png");


	//EE: TOF-corr seed Diff
	h_TofCor_TimeEEEE->SetTitle("TOF-Corrected(t_{1}-t_{2})[ns]");   
        h_TofCor_TimeEEEE->SetMarkerStyle(20);
        h_TofCor_TimeEEEE->SetMarkerSize(0.8);
        h_TofCor_TimeEEEE->SetStats(1);
        h_TofCor_TimeEEEE->SetTitleSize(0.08, "x");   
        h_TofCor_TimeEEEE->SetTitleOffset(1.0, "x");    
        h_TofCor_TimeEEEE->SetTitleSize(0.06, "y"); 
        h_TofCor_TimeEEEE->SetTitleOffset(0.95, "y");    
        h_TofCor_TimeEEEE->SetYTitle("Number Of Seed Pair/0.05ns"); 
        h_TofCor_TimeEEEE->SetXTitle("(t_{seed1} - t_{seed2})TOF-Corrected[ns]"); 
        h_TofCor_TimeEEEE->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange);   
        h_TofCor_TimeEEEE->GetXaxis()->SetNoExponent(kFALSE);
       /** Set parms as parms of Fit Fxn **/
	fitFcn->SetParameters(500, h_TofCor_TimeEEEE->GetMean(), h_TofCor_TimeEEEE->GetRMS() );
	fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)");
	h_TofCor_TimeEEEE->Fit("fitFcn", "LL"); /**Fit with improved LL**/
	std::cout << "Printing Fit Parameters for EEEE-Tof ......   " << std::endl;
        printf("Integral of function in EEEE Tof = %g\n", fitFcn->Integral( FitLowRange, FitHighRange));

        //*** retrive fit results***//
        int npar4 = fitFcn->GetNpar();
        TVirtualFitter *fit4 = TVirtualFitter::GetFitter();
        fit4->PrintResults(2,0.);
        TMatrixD *CovMatrix4 = new TMatrixD ( npar4, npar4, fit4->GetCovarianceMatrix() );
	CovMatrix4->Print();
        TCanvas *cEE1 = new TCanvas("cEE1","EE-EE TOF-corr",200,10,800,900);
     	cEE1->SetGridx();
     	cEE1->SetGridy();
	cEE1->GetFrame()->SetFillColor(21);
	cEE1->GetFrame()->SetBorderMode(-1);
	cEE1->GetFrame()->SetBorderSize(5);
        /* c1->Divide(2,1);  */
	cEE1->cd();
	h_TofCor_TimeEEEE->Draw();
	fitFcn->Draw("sames");
        cEE1->SetLogy(0);
	//  draw the legend
    	TLegend *leg3 = new TLegend(0.15,0.72,0.3,0.85);
       	leg3->SetTextFont(72);
        leg3->SetTextSize(0.04);
        leg3->AddEntry(h_TofCor_TimeEEEE,"EE","lpe");
        leg3->AddEntry(fitFcn,"GAUS","l");
        leg3->Draw();
	cEE1->SaveAs("TOF-Corrected-Seed_Time_DoubleElectron_Run2012A-EE-EE.png");
}       
void q4gmn_jan2009() {
  gROOT->SetStyle("HALLA");
  TCanvas *cn = new TCanvas("cn");
  cn->Draw();
//  TH1F *frm = new TH1F("frm","",100,0.,5.5);
  TH1F *frm = new TH1F("frm","",100,0.,20.);
  frm->GetXaxis()->SetTitle("Q^{2}  [GeV^{2}]");
  frm->GetXaxis()->CenterTitle();
  frm->GetYaxis()->SetTitle("Q^{4} G_{M}^{n}/#mu_{n}");
  frm->GetYaxis()->CenterTitle();
  frm->SetMinimum(0.0);
  frm->SetMaximum(0.6);
  frm->UseCurrentStyle();
  frm->Draw();


  
  TMultiGraph* mgrDta = new TMultiGraph("Data","G_{M}^{n}/#mu_{n}G_{D}");
  TLegend *legDta = new TLegend(0.5029,.2076,.9095,.3877,"","brNDC");

  TMultiGraph* wgr = mgrDta;
  TLegend *wlg = legDta;

   // the data
    legDta->SetBorderSize(0); // turn off border
    legDta->SetFillStyle(0);

    datafile_t *f = datafiles;
    TGraph* gr=0;
    TGraph* ogr=0;
    while ( f && f->filename ) {
      ogr=OneGraph(f);
      if (ogr) {
	      gr = fromGMnGDtoQ4GMn(ogr);
	if (f->lnpt) {
	  mgrDta->Add(gr,f->lnpt);
	  legDta->AddEntry(gr,f->label,f->lnpt);
	}
	else if (gr->GetMarkerStyle()>=20) {
	  mgrDta->Add(gr,"p");
	  legDta->AddEntry(gr,f->label,"p");
	}	
	else {
	  mgrDta->Add(gr,"l");
	  legDta->AddEntry(gr,f->label,"l");
	}
      }
      f++;
    }
    

  mgrDta->Draw("p");
   legDta->Draw();  // don't draw the data legend
  
  TMultiGraph* mgrThry = new TMultiGraph("Theory","");
  TLegend *legThry = new TLegend(0.1868,.1949,.5287,.3432,"","brNDC");

  wgr = mgrThry;
  wlg = legThry;

  // the theory
    wlg->SetBorderSize(0); // turn off border
    wlg->SetFillStyle(0);

    f = theoryfiles1;
    ogr=0;
    while ( f && f->filename ) {
      ogr=OneGraph(f);
      if (ogr) {
	      gr = fromGMnGDtoQ4GMn(ogr);
	TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
	if (egr && egr->GetEYhigh() && egr->GetEYhigh()[0]>0) {
 	  gr = toerror_band(egr);
	  gr->SetFillStyle(3000+f->style);
	}
	gr->SetLineWidth(2);
	if (f->lnpt) {
	  wgr->Add(gr,f->lnpt);
	  wlg->AddEntry(gr,f->label,f->lnpt);
	}
	else if (gr->GetMarkerStyle()>=20) {
	  wgr->Add(gr,"p");
	  wlg->AddEntry(gr,f->label,"p");
	}	
	else {
	  wgr->Add(gr,"l");
	  wlg->AddEntry(gr,f->label,"l");
	}
      }
      f++;
    }
  
  mgrThry->Draw("c");
  legThry->Draw();

  // draw a line at 1
  cn->Modified();
  cn->Update();
  TFrame* frame = gPad->GetFrame();

  TLine *line1 = new TLine(frame->GetX1(),1.,frame->GetX2(),1.);
  line1->SetLineStyle(1);
  line1->Draw();

  cn->Update();
  cn->SaveAs(Form("%s.eps",psfile));
  cn->SaveAs(Form("%s.root",psfile));
  gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));

  return;

  // remove everything but the graph
  cn->Update();
  TList *clist = cn->GetListOfPrimitives();
  frame = cn->GetFrame();
  for (int i=0; i<clist->GetSize(); ) {
    if (clist->At(i) != frame) {
      clist->RemoveAt(i);
    } else i++;
  }
  // draw markers in the corners
  TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX1(),frame->GetY2(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY2(),2);
  mkr->Draw();
  frame->SetLineColor(10);
  cn->Update();

  {
    datafile_t miller = { "figure_input/Miller/lattice.GMn.rtf","Miller",
			  "[0]","[1]/(-1.91)*(1+[0]/.71)*(1+[0]/.71)",
			  "([3]-[1])/(-1.91)*(1+[0]/.71)*(1+[0]/.71)",
			  "([1]-[2])/(-1.91)*(1+[0]/.71)*(1+[0]/.71)",
			  0,0,1,3,"F" };
    
    gr = OneGraph(&miller);
    TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
    if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
      gr = toerror_band(egr);
      gr->SetLineStyle(1);
      gr->SetFillColor(gr->GetLineColor());
      gr->SetFillStyle(3000+miller.style);
    }
    
    gr->Draw("F");
    
    cn->Update();
    cn->SaveAs("gmngd_Miller_Overlay.eps");
    cn->SaveAs("gmngd_Miller_Overlay.root");
    clist->Remove(gr);
  }

  {
    datafile_t miller_spl = { "figure_input/Miller/lattice.GMn.spl3","Miller",
			      "[0]","[1]/(-1.91)*(1+[0]/.71)*(1+[0]/.71)",
			      "([3]-[1])/(-1.91)*(1+[0]/.71)*(1+[0]/.71)",
			      "([1]-[2])/(-1.91)*(1+[0]/.71)*(1+[0]/.71)",
			      0,0,1,3,"F" };
    
    gr = OneGraph(&miller_spl);
    TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
    if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
      gr = toerror_band(egr);
      gr->SetLineStyle(1);
      gr->SetFillColor(gr->GetLineColor());
      gr->SetFillStyle(3000+miller_spl.style);
    }
    
    gr->Draw("F");
    
    cn->Update();
    cn->SaveAs("gmngd_Miller_Overlay_spl.eps");
    cn->SaveAs("gmngd_Miller_Overlay_spl.root");
    clist->Remove(gr);
  }

}
void geugd_riordan() {
	gROOT->SetStyle("HALLA");
	TCanvas *cn = new TCanvas("cn");
	cn->Draw();
	cn->UseCurrentStyle();
	TH1F *frm = new TH1F("frm","",100,0.,12.);
	frm->GetXaxis()->SetTitle("Q^{2}  [GeV^{2}]");
	frm->GetXaxis()->CenterTitle();
	frm->GetYaxis()->SetTitle("G_{E}^{u}/G_{D}");
	frm->GetYaxis()->CenterTitle();
	frm->SetMinimum(.40);
	frm->SetMaximum(2.4);
	//frm->SetMaximum(0.3);
	frm->UseCurrentStyle();
	frm->Draw();
	frm->SetAxisRange(0.10,12.,"X");

	TF1* galster = new TF1("galster",
			"x/(4.*0.938*.938)*1.91/(1.+x/.71)^2/(1.+5.6*x/(4.*.938*.938))",
			0.,4.);
	galster->SetLineColor(kBlack);
	galster->SetLineStyle(kBlack);
	galster->SetLineWidth(2);

	TF1* gen0 = new TF1("gen0", f1dugen0, 0.,12.);
	gen0->SetLineColor(kBlack);
	gen0->SetLineStyle(kBlack);
	gen0->SetLineWidth(1);



	TF1 *genf = new TF1("genf",genff,1.,10.,1);
	genf->SetLineColor(kBlue);
	genf->SetLineStyle(1);
	genf->SetParameter(0,1.);
	// match to Madey point just below 1.5
	// genf->SetParameter(0,.0411/genf->Eval(1.45));
	//  genf->SetParameter(0,-0.558645);
	genf->SetParameter(0,-0.182645);

	TF1 *roberts_curve = new TF1("roberts",roberts_gen,0.035,12.344,1);
	roberts_curve->SetLineColor(kRed);
	roberts_curve->SetLineStyle(9);

	TF1 *ourfit = new TF1("ourfit",gen_ourfit,0.,10.,0);
	ourfit->SetLineColor(kBlue);
	ourfit->SetLineStyle(0);

	/*
	   TF1 *bbba05 = new TF1("BBBA05",gen_bbba05,0.,10.,0);
	   bbba05->SetLineColor(kGreen);
	   bbba05->SetLineStyle(3);
	   */

	//  TF1 *lomon = new TF1("Lomon",Lomon_GEn,0.,10.,0);
	// lomon->SetLineColor(7);
	// lomon->SetLineStyle(4);




	TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}");
	//TLegend *legDta = new TLegend(.3448,.6123,.6810,.9110,"","brNDC");
	TLegend *legDta = new TLegend(.6020,.4004,.9382,.9089,"","brNDC");

	TMultiGraph* wgr = mgrDta;
	TLegend *wlg = legDta;

	// the data
	legDta->SetBorderSize(0); // turn off border
	legDta->SetFillStyle(0);

	datafile_t *f = datafiles;
	TGraph* gr=0;
	TGraph* ogr=0;
	while ( f && f->filename ) {
		ogr=OneGraph(f);
		if (ogr) {
			gr = fromGEntransform(ogr);
			gr->SetLineStyle(0);
			if (f->lnpt) {
				mgrDta->Add(gr,f->lnpt);
				if( f->label[0] != 'x' )
					legDta->AddEntry(gr,f->label,f->lnpt);
			}
			mgrDta->Add(gr,"p");
			if( f->label[0] != 'x' )
				legDta->AddEntry(gr,f->label,"p");

			/*
			   else if (gr->GetMarkerStyle()>=20) {
			   mgrDta->Add(gr,"p");
			   if( f->label[0] != 'x' )
			   legDta->AddEntry(gr,f->label,"p");
			   }	
			   else {
			   mgrDta->Add(gr,"l");
			   if( f->label[0] != 'x' )
			   legDta->AddEntry(gr,f->label,"l");
			   }
			   */
		}
		f++;
	}


	mgrDta->Draw("p");
	legDta->Draw();

	TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}");
	//  TLegend *legThry = new TLegend(.546,.6208,.8822,.9195,"","brNDC");
	//	TLegend *legThry = new TLegend(.2055,.7013,.6020,.8893,"","brNDC");
	TLegend *legThry = new TLegend(.4267,.8453,.6236,.8962,"","brNDC");

	wgr = mgrThry;
	wlg = legThry;

	// the theory
	wlg->SetBorderSize(0); // turn off border
	wlg->SetFillStyle(0);

	f = theoryfiles1;
	gr=0;
	Bool_t isfill;
	while ( f && f->filename ) {
		gr=OneGraph(f);
		gr->SetLineWidth(2);
		isfill = kFALSE;
		if (gr) {
			TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
			if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) {
				gr = toerror_band(egr);
				gr->SetFillStyle(3000+f->style);
				gr->SetFillStyle(1);
				gr->SetFillColor(gr->GetLineColor());
				isfill = kTRUE;
			}
			if (f->lnpt) {
				wgr->Add(gr,f->lnpt);
				if( f->label[0] != 'x' )
					wlg->AddEntry(gr,f->label,f->lnpt);
			}
			else if (gr->GetMarkerStyle()>=20) {
				wgr->Add(gr,"p");
				if( f->label[0] != 'x' )
					wlg->AddEntry(gr,f->label,"p");
			}	
			else {
				if( isfill ){
					gr->SetLineStyle(0);
					wgr->Add(gr,"f");
					//				  wgr->Add( new TGraph(*egr),"l");
					if( f->label[0] != 'x' )
						wlg->AddEntry(gr,f->label,"lf");
				} else {
					wgr->Add(gr,"l");
					if( f->label[0] != 'x' )
						wlg->AddEntry(gr,f->label,"l");
				}
			}

		}
		f++;
	}


	TPaveLabel *prelim = new TPaveLabel( 0.3204, 0.1886, 0.9310, 0.4643, "PRELIMINARY", "NDC" );
	prelim->SetTextAngle(0);
	TColor *pink = new TColor(300, 1.0, 0.7, 0.7, "pink");
	prelim->SetTextColor(300);
	prelim->SetFillStyle(0);
	prelim->SetBorderSize(0);


#ifdef FAKE_SCHIAVILLA
	TGraph *schiagraph = draw_schiavilla();
	schiagraph->Draw("F");
	schiagraph = draw_schiavilla(1);
	schiagraph->Draw("C");
	legThry->AddEntry(schiagraph, "d(e,e'd) T_{20} - Schiavilla & Sick", "LF");
#endif

#ifdef PRELIMINARY
	prelim->Draw("same");
#endif

	TPaveLabel *nofsilab = new TPaveLabel( 0.4569, 0.1674, 0.7514, 0.2415, "No FSI Corrections", "NDC" );
	nofsilab->SetFillStyle(0);
	nofsilab->SetBorderSize(0);
	nofsilab->SetTextColor(kRed);

#ifdef NOFSI
	//  nofsilab->Draw("same");
#endif

#ifdef PQCD
	genf->Draw("same");
#endif
	mgrThry->Draw("c");
#ifdef GALSTER
	galster->Draw("same");
#endif
//	gen0->Draw("same");

#ifdef NEW_ROBERTS
	roberts_curve->Draw("same");
#endif
	//  ourfit->Draw("same");
	//  bbba05->Draw("same");
	//lomon->Draw("same");
	// bandi->Draw("same");
#ifdef PQCD  
	legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l");
#endif
#ifdef GALSTER
	legThry->AddEntry(galster,"Galster fit (1971)","l");
#endif
//	legThry->AddEntry(gen0,"G_{E}^{n} = 0","l");
#ifdef NEW_ROBERTS
	legThry->AddEntry(roberts_curve,"q(qq) Faddeev -  I. Cloet, ANL","l");
#endif
	//  legThry->AddEntry(bbba05,"BBBA05","l");
	//  legThry->AddEntry(lomon, "Lomon", "l");
	// legThry->AddEntry(ourfit, "Our Fit", "l");
	legThry->Draw();
	legDta->Draw();

	mgrDta->Draw("p");
	legDta->Draw();

	TEllipse *cir1 = new TEllipse(1.31, 0.0, 0.17, 0.0065);
	TEllipse *cir2 = new TEllipse(2.4, 0.0, 0.17, 0.0065);
	cir1->SetFillStyle(0);
	cir2->SetFillStyle(0);

#ifdef PLOTKIN1
	cir1->Draw("same");
	//  cir2->Draw("same");

	//  TPaveLabel *exacc = new TPaveLabel( 0.3779, 0.2691, 0.5963, 0.3114, "Expected Accuracy", "NDC");
	TPaveLabel *exacc = new TPaveLabel( 0.2716, 0.2733, 0.4899, 0.3136, "Expected Accuracy", "NDC");
	exacc->SetFillStyle(0);
	exacc->SetBorderSize(0);
	exacc->Draw("same");
#endif


	// draw a line at 1
	cn->Modified();

	cn->Update();
	cn->SaveAs(Form("%s.pdf",psfile));
	cn->SaveAs(Form("%s.eps",psfile));
	//  cn->SaveAs(Form("%s.root",psfile));
	//  gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));

	//  cn->SaveAs("bogdan_gen.eps");
	return;  // LEAVING HERE

	// now an overlay, hopefully matching dimensions

	// remove everything but the graph
	cn->Update();
	TList *clist = cn->GetListOfPrimitives();
	TFrame* frame = cn->GetFrame();
	for (int i=0; i<clist->GetSize(); ) {
		if (clist->At(i) != frame) {
			clist->RemoveAt(i);
		} else i++;
	}
	// draw markers in the corners
	TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2);
	mkr->Draw();
	mkr = new TMarker(frame->GetX2(),frame->GetY1(),2);
	mkr->Draw();
	mkr = new TMarker(frame->GetX1(),frame->GetY2(),2);
	mkr->Draw();
	mkr = new TMarker(frame->GetX2(),frame->GetY2(),2);
	mkr->Draw();
	frame->SetLineColor(10);
	cn->Update();

	datafile_t miller = { "figure_input/Miller/lattice.GEn.rtf","Miller",
		"[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" };

	gr = OneGraph(&miller);
	TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
	if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
		gr = toerror_band(egr);
		gr->SetLineStyle(1);
		gr->SetFillColor(gr->GetLineColor());
		gr->SetFillStyle(3000+miller.style);
	}

	gr->Draw("F");

	cn->Update();
	cn->SaveAs("gen_Miller_Overlay.pdf");
	cn->SaveAs("gen_Miller_Overlay.root");

}
Beispiel #14
0
void 
Unfolded  (
     bool drawRatio = 1,
     int differential = 0,
     int nsel = 0,
     int ReBin = 1,
     TString XTitle = "p_{T,max}^{l} (GeV)",
     TString units = "", 
     TString plotName = "data/XSLeadingPt_AN.root", 
     TString outputName = "WW_LeadingPt_final",
     bool isLogY = false,
     double lumi = 19.5
 )
{  
 
 gInterpreter->ExecuteMacro("GoodStyle.C");
 
 std::cout << "reading " << plotName << std::endl ;
 TFile* file = new TFile(plotName, "read");
 
 //---- prepare the object that is making the plots
 //---- ---- ---- ---- ---- ---- ---- ---- ---- ----
 
 std::cout << "setting up the plot object " << std::endl ;

 
 TH1F* xsValue = (TH1F*) xsValue->Clone();
 TH1F* xsValue_Powheg =  (TH1F*) xsValue_Powheg->Clone();
 TH1F* xsValue_Madgraph = (TH1F*) xsValue_Madgraph->Clone();
 TH1F* xsValue_MCnlo = (TH1F*) xsValue_MCnlo->Clone();
 TH1F* systHisto = (TH1F*) systHisto->Clone();
 
 
 TCanvas* canvas ;
 TPad *pad1, *pad2, *pad3, *pad4;
 
 if (drawRatio) {
  canvas = new TCanvas("wwxs", "wwxs", 600, 850);
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  canvas->SetHighLightColor(2);
  canvas->Range(0,0,1,1);
  canvas->SetFillColor(0);
  canvas->SetBorderMode(0);
  canvas->SetBorderSize(2);
  canvas->SetTickx(1);
  canvas->SetTicky(1);
  canvas->SetLeftMargin(0.16);
  canvas->SetRightMargin(0.02);
  canvas->SetTopMargin(0.05);
  canvas->SetBottomMargin(0.13);
  canvas->SetFrameFillStyle(0);
  canvas->SetFrameBorderMode(0);
  
  
  
  pad1 = new TPad("pad1", "pad1",0.01,0.55,0.99,0.99);
  pad1->Draw();
  pad1->cd();
  pad1->Range(-147.2973,-5.811723,960.8108,2.535539);
  pad1->SetFillColor(0);
  pad1->SetBorderMode(0);
  pad1->SetBorderSize(2);
  pad1->SetLogy();
  pad1->SetTickx(1);
  pad1->SetTicky(1);
  pad1->SetLeftMargin(0.16);
  pad1->SetBottomMargin(0);
  pad1->SetFrameFillStyle(0);
  pad1->SetFrameBorderMode(0);
  pad1->SetFrameFillStyle(0);
  pad1->SetFrameBorderMode(0);
   
 }
 else { 
  canvas = new TCanvas("wwxs", "wwxs", 550, 550);
 }
 
 if (drawRatio) pad1->cd();
 
 std::cout << " now plot " << std::endl;
 
 //Plot Data
 xsValue->SetLineWidth(1);
 xsValue->SetMarkerSize(1.0);
 
 int NBins = xsValue->GetNbinsX();
 
 for(int i=1; i <NBins; i++) {
  
  float err_stat = xsValue->GetBinError(i);
  float err_syst = systHisto->GetBinError(i);
  float err_total = sqrt(err_stat*err_stat + err_syst*err_syst);
  
  xsValue->SetBinError(i, err_total);
 }
 
 
 //-- Plot Powheg
 
 TH1F *hpowError  = (TH1F*) xsValue_Powheg->Clone();
 
 xsValue_Powheg->SetMarkerColor(kGreen+2);
 xsValue_Powheg->SetLineWidth(1);
 xsValue_Powheg->SetLineColor(kGreen+2);
 xsValue_Powheg->SetMarkerStyle(22);
 xsValue_Powheg->SetMarkerSize(1.2);
 
 
 hpowError->SetLineWidth(0);
 hpowError->SetMarkerSize (      0);  
 hpowError->SetFillColor  (kGreen-7);
 
 
 //-- Plot Madgraph
 
 TH1F *hmadError  = (TH1F*) xsValue_Madgraph->Clone();
 
 xsValue_Madgraph->SetMarkerColor(kMagenta);
 xsValue_Madgraph->SetLineWidth(1);
 xsValue_Madgraph->SetLineStyle(1);
 xsValue_Madgraph->SetMarkerStyle(21);
 xsValue_Madgraph->SetMarkerSize(1.0);
 
 hmadError->SetLineWidth(0);
 hmadError->SetMarkerSize (      0); 
 hmadError->SetFillColor  (kMagenta-10);
 
 
 //-- Plot MCNLO
 
 TH1F *hmcError  = (TH1F*) xsValue_MCnlo->Clone();
 
 xsValue_MCnlo->SetMarkerColor(kRed);
 xsValue_MCnlo->SetLineColor(kRed);
 xsValue_MCnlo->SetLineWidth(1);
 xsValue_MCnlo->SetLineStyle(1);
 xsValue_MCnlo->SetMarkerStyle(24);
 xsValue_MCnlo->SetMarkerSize(1.0);
 
 hmcError->SetLineWidth(0);
 hmcError->SetMarkerSize (      0); 
 hmcError->SetFillColor  (kOrange);
 
 
 
 
 //-- Plot Data
 
 xsValue->SetMarkerStyle(kFullCircle);
 
 if (differential == 0) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} d#sigma(WW#rightarrow#mu#nue#nu + < 1 jet)/dp_{T,max}^{l}");
 if (differential == 1) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} d#sigma(WW#rightarrow#mu#nue#nu + < 1 jet)/dp_{T}(ll)}");
 if (differential == 2) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} d#sigma(WW#rightarrow#mu#nue#nu + < 1 jet)/dm_{#font[12]{ll}}");
 if (differential == 3) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} d#sigma(WW#rightarrow#mu#nue#nu + < 1 jet)/d#Delta#phi_{ll}");

 
//  if (differential == 0) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dp_{T,max}^{l}}");
//  if (differential == 1) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dp_{T}(ll)}");
//  if (differential == 2) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dm_{#font[12]{ll}}}");
//  if (differential == 3) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{d#Delta#phi_{ll}}");

 AxisFonts (xsValue->GetXaxis(), XTitle);
 
 
 
 xsValue->Draw("p");
 hmadError->Draw("e2,same"); 
 xsValue_Madgraph->Draw("pe1,same");
 hmcError->Draw("e2,same");
 xsValue_MCnlo->Draw("pe1,same");
 hpowError->Draw("e2,same");
 xsValue_Powheg->Draw("pe1,same");
 //systHisto->Draw("e2, same");
 xsValue->Draw("pe1,same");
 
 // Legend
 //----------------------------------------------------------------------------
 
 DrawLegend (0.65, 0.85, xsValue, "Data", "P");
 DrawLegend (0.65, 0.80, hpowError,   "", "F");
 DrawLegend (0.65, 0.80, xsValue_Madgraph,   "Madgraph", "PL");  
 DrawLegend (0.65, 0.75, hmadError,   "", "F");
 DrawLegend (0.65, 0.75, xsValue_MCnlo,   "MCNLO", "LP");
 DrawLegend (0.65, 0.70, hmcError,   "", "F");
 DrawLegend (0.65, 0.70, xsValue_Powheg,   "Powheg", "PL");
 
 canvas->GetFrame()->DrawClone();
 
 
 
 // Draw text 
 //----------------------------------------------------------------------------
 TLatex *   tex = new TLatex(0.17,0.96,"CMS             #sqrt{s} = 8 TeV             19.4 fb^{-1}");
 tex->SetNDC();
 tex->SetTextAlign(12);
 tex->SetTextFont(42);
 tex->SetTextSize(0.07);
 tex->SetLineWidth(2);
 tex->Draw();
 
//  TLatex * CMSLabel = new TLatex (0.18, 0.96, "#bf{CMS}");
//  CMSLabel->SetNDC ();
//  CMSLabel->SetTextAlign (10);
//  CMSLabel->SetTextFont (42);
//  CMSLabel->SetTextSize (_tsize);
//  CMSLabel->Draw ("same") ;
//  
//  
//  TLatex * _lumiLabel = new TLatex (0.95, 0.96, "19.4fb#lower[0.3]{^{-1}} (8 TeV)");
//  _lumiLabel->SetNDC ();
//  _lumiLabel->SetTextAlign (30);
//  _lumiLabel->SetTextFont (42);
//  _lumiLabel->SetTextSize (_tsize);
//  _lumiLabel->Draw ("same") ;
 
 
 // Draw also ratio
 //----------------------------------------------------------------------------
 if (drawRatio) {
  
  //---- prepare the distributions

  TH1F* ratio_pow       = xsValue_Powheg->Clone("ratio");
  TH1F* ratio_mad       = xsValue_Madgraph->Clone("ratio");
  TH1F* ratio_mcnlo     = xsValue_MCnlo->Clone("ratio");
  TH1F* hratio_pow      = xsValue_Powheg->Clone("ratio");
  TH1F* hratio_mad      = xsValue_Madgraph->Clone("ratio");
  TH1F* hratio_mcnlo    = xsValue_MCnlo->Clone("ratio");
  TH1F* ratioErr        = xsValue->Clone("ratio");
  
  
  for (UInt_t ibin=1; ibin<=ratio->GetNbinsX(); ibin++) {
   
   Double_t powValue = xsValue_Powheg->GetBinContent(ibin);
   Double_t powError = xsValue_Powheg->GetBinError  (ibin);
   
   Double_t madValue = xsValue_Madgraph->GetBinContent(ibin);
   Double_t madError = xsValue_Madgraph->GetBinError  (ibin);
   
   Double_t mcnloValue = xsValue_MCnlo->GetBinContent(ibin);
   Double_t mcnloError = xsValue_MCnlo->GetBinError  (ibin);
   
   Double_t dataValue = xsValue->GetBinContent(ibin);
   Double_t statError = xsValue->GetBinError  (ibin);
   Double_t systError = systHisto->GetBinError(ibin);
   
   Double_t dataError = systError;
   
   Double_t ratioValue_pow           = (powValue > 0) ? powValue/dataValue : 0.0;
   Double_t ratioError_pow           = (powValue > 0) ? powError / dataValue : 0.0;
   
   Double_t ratioValue_mad           = (madValue > 0) ? madValue/dataValue : 0.0;
   Double_t ratioError_mad           = (madValue > 0) ? madError/dataValue : 0.0;
   
   Double_t ratioValue_mcnlo         = (mcnloValue > 0) ? mcnloValue/dataValue : 0.0;
   Double_t ratioError_mcnlo         = (mcnloValue > 0) ? mcnloError/dataValue : 0.0;
   
   Double_t uncertaintyError         = (dataValue > 0) ? dataError/dataValue : 0.0;
   
   
   //dataError/dataValue 
   ratio_pow->SetBinContent(ibin, ratioValue_pow);
   hratio_pow->SetBinContent(ibin, ratioValue_pow);
   hratio_pow->SetBinError  (ibin, ratioError_pow);
   
   ratio_mad->SetBinContent(ibin, ratioValue_mad);
   hratio_mad->SetBinContent(ibin, ratioValue_mad);
   hratio_mad->SetBinError  (ibin, ratioError_mad);
   
   ratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo);
   hratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo);
   hratio_mcnlo->SetBinError  (ibin, ratioError_mcnlo);
   
   ratioErr->SetBinContent(ibin, 1.0);
   ratioErr->SetBinError  (ibin, uncertaintyError);
  }
  
  ratioErr->SetTitle("");

  ratioErr->SetFillColor  (kGray+2);
  ratioErr->SetFillStyle  (   3004);
//   ratioErr->SetFillStyle  (   3345);
  ratioErr->SetLineColor  (kGray+2);
  ratioErr->SetMarkerColor(kGray+2);
  ratioErr->SetMarkerSize (      0);
  
  
  
  //---- now draw
  
  canvas->cd();
  pad2 = new TPad("pad2", "pad2",0.01,0.39,0.99,0.55);
  pad2->Draw();
  pad2->cd();
  pad2->Range(-147.2973,0.2,960.8108,1.8);
  pad2->SetFillColor(0);
  pad2->SetBorderMode(0);
  pad2->SetBorderSize(2);
  pad2->SetTickx(1);
  pad2->SetTicky(1);
  pad2->SetLeftMargin(0.16);
  pad2->SetTopMargin(0);
  pad2->SetBottomMargin(0);
  pad2->SetFrameFillStyle(0);
  pad2->SetFrameBorderMode(0);
  pad2->SetFrameFillStyle(0);
  pad2->SetFrameBorderMode(0);
  
  
  ratioErr  ->Draw("e2");
  ratio_mad      ->SetLineColor(kMagenta);
  ratio_mad      ->SetMarkerSize(1.0);
  ratio_mad      ->SetLineWidth(1);
  ratio_mad      ->SetMarkerStyle(21);
  hratio_mad     ->SetLineWidth(0);
  hratio_mad     ->SetMarkerSize (      0);  
  hratio_mad     ->SetFillColor  (kMagenta-10);
  hratio_mad     ->SetFillStyle  (1001);
  hratio_mad     ->Draw("e2,same");
  ratio_mad      ->Draw("e1p,same");
  AxisFontsRatio (ratioErr->GetYaxis(), "y", "Theory/data");
  AxisFontsRatio (ratioErr->GetXaxis(), "x", XTitle);
  ratioErr->Draw("sameaxis");
  ratioErr->GetYaxis()->SetRangeUser(0.4, 1.6);  
  pad2->Modified();
  
  TLatex* tex_mad = new TLatex(0.2,0.1,"Madgraph+Pythia, normalized to #sigma_{NNLO}");
  tex_mad->SetNDC();
  tex_mad->SetTextAlign(12);
  tex_mad->SetTextFont(42);
  tex_mad->SetTextSize(0.1);
  tex_mad->SetLineWidth(2);
  tex_mad->Draw();
  
  
  
  canvas->cd();
  pad3 = new TPad("pad3", "pad3",0.01,0.23,0.99,0.39);
  pad3->Draw();
  pad3->cd();
  pad3->Range(-147.2973,0.2,960.8108,1.8);
  pad3->SetFillColor(0);
  pad3->SetBorderMode(0);
  pad3->SetBorderSize(2);
  pad3->SetTickx(1);
  pad3->SetTicky(1);
  pad3->SetLeftMargin(0.16);
  pad3->SetTopMargin(0);
  pad3->SetBottomMargin(0);
  pad3->SetFrameFillStyle(0);
  pad3->SetFrameBorderMode(0);
  pad3->SetFrameFillStyle(0);
  pad3->SetFrameBorderMode(0);
  
  ratioErr  ->Draw("e2");
  ratio_mcnlo     ->SetLineColor(kRed);
  ratio_mcnlo     ->SetMarkerSize(1.0);
  ratio_mcnlo      ->SetLineWidth(1);
  ratio_mcnlo     ->SetMarkerStyle(24);
  hratio_mcnlo    ->SetLineWidth(0);
  hratio_mcnlo    ->SetMarkerSize (      0);  
  hratio_mcnlo    ->SetFillColor  (kOrange);
  hratio_mcnlo     ->SetFillStyle  (1001);
  hratio_mcnlo    ->Draw("e2,same");
  ratio_mcnlo     ->Draw("ep,same");
//   AxisFontsRatio (ratioErr->GetYaxis(), "y", "Theory/data");
//   AxisFontsRatio (ratioErr->GetXaxis(), "x", XTitle);
  ratioErr->Draw("sameaxis");
  ratioErr->GetYaxis()->SetRangeUser(0.4, 1.6);  
  pad3->Modified();
  
  TLatex* tex_mcnlo = new TLatex(0.2,0.1,"MC@NLO+Herwig, normalized to #sigma_{NNLO}");
  tex_mcnlo->SetNDC();
  tex_mcnlo->SetTextAlign(12);
  tex_mcnlo->SetTextFont(42);
  tex_mcnlo->SetTextSize(0.1);
  tex_mcnlo->SetLineWidth(2);
  tex_mcnlo->Draw();
  
  
  
  
  canvas->cd();
  pad4 = new TPad("pad4", "pad4",0.01,0.01,0.99,0.23);
  pad4->Draw();
  pad4->cd();
  pad4->Range(-147.2973,-0.4857143,960.8108,1.8);
  pad4->SetFillColor(0);
  pad4->SetBorderMode(0);
  pad4->SetBorderSize(2);
  pad4->SetTickx(1);
  pad4->SetTicky(1);
  pad4->SetLeftMargin(0.16);
  pad4->SetTopMargin(0);
  pad4->SetBottomMargin(0.3);
  pad4->SetFrameFillStyle(0);
  pad4->SetFrameBorderMode(0);
  pad4->SetFrameFillStyle(0);
  pad4->SetFrameBorderMode(0);
  
  ratioErr  ->Draw("e2");
  ratio_pow      ->SetLineColor(kGreen+2);
  ratio_pow      ->SetMarkerSize(1.2);
  ratio_pow      ->SetLineWidth(1);
  ratio_pow      ->SetMarkerStyle(22);
  hratio_pow     ->SetLineWidth(0);
  hratio_pow     ->SetMarkerSize (      0);  
  hratio_pow     ->SetFillColor  (kGreen-7);
  hratio_pow     ->SetFillStyle  (1001);
  hratio_pow     ->Draw("e2,same");
  ratio_pow      ->Draw("e1p,same");
//   AxisFontsRatio (ratioErr->GetYaxis(), "y", "Theory/data", 1);
//   AxisFontsRatio (ratioErr->GetXaxis(), "x", XTitle);
  ratioErr->Draw("sameaxis");
  ratioErr->GetYaxis()->SetRangeUser(0.4, 1.6);  
  pad4->Modified();
  
  TLatex* tex_pow = new TLatex(0.2,0.39,"Powheg+Pythia, normalized to #sigma_{NNLO}");
  tex_pow->SetNDC();
  tex_pow->SetTextAlign(12);
  tex_pow->SetTextFont(42);
  tex_pow->SetTextSize(0.1);
  tex_pow->SetLineWidth(2);
  tex_pow->Draw();
  
  canvas->cd();
  
  
 }
 
 
}
void q4gep_jan2009() {
  gROOT->SetStyle("HALLA");
  TCanvas *cn = new TCanvas("cn");
  cn->Draw();
  TH1F *frm = new TH1F("frm","",100,0.,15.);
#ifndef DIFF_LAB
  frm->GetXaxis()->SetTitle("Q^{2}  [GeV^{2}]");
#endif
#ifdef DIFF_LAB
  frm->GetXaxis()->SetTitle("Q^{2} in GeV^{2}");
#endif

  frm->GetXaxis()->CenterTitle();
#ifndef DIFF_LAB
  frm->GetYaxis()->SetTitle("Q^{4} G_{E}^{p}");
#endif
#ifdef DIFF_LAB
  frm->GetYaxis()->SetTitle("#muG_{Ep}/G_{Mp}");
#endif
  frm->GetYaxis()->CenterTitle();
  frm->SetMinimum(-0.1);
  frm->SetMaximum(0.4);
  frm->UseCurrentStyle();
  frm->Draw();

  TF1 *ff = new TF1("ff",fff,1.,10.,1.);
  ff->SetLineColor(2);
  ff->SetLineStyle(2);
  ff->SetParameter(0,1.);
  ff->SetParameter(1,.3);
  // match to Gayou point at 5.54 GeV^2
  ff->SetParameter(0,.1035);

  
  TMultiGraph* mgrDta = new TMultiGraph("Data","#frac{#mu_{p}G_{E}^{p}}{G_{M}^{p}}");
  //TLegend *legDta = new TLegend(.58,.565,.875,.9,"","brNDC");
  TLegend *legDta = new TLegend(.648,.682,.945,.900,"","brNDC");

  TMultiGraph* wgr = mgrDta;
  TLegend *wlg = legDta;

   // the data
  legDta->SetBorderSize(0); // turn off border
  legDta->SetFillStyle(0);
  
  datafile_t *f = datafiles;
  TGraph* gr=0;
  TGraph* ogr=0;
  while ( f && f->filename ) {
    ogr=OneGraph(f);
    if (ogr) {
	    gr = fromGEpGMptoQ4GEp(ogr);
 	gr->SetLineWidth(2);
      if (f->lnpt) {
	mgrDta->Add(gr,f->lnpt);
	legDta->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	mgrDta->Add(gr,"p");
	legDta->AddEntry(gr,f->label,"p");
      }	
      else {
	mgrDta->Add(gr,"l");
	legDta->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }
  

  mgrDta->Draw("p");
   legDta->Draw();//   don't draw the data legend
  
  TMultiGraph* mgrThry = new TMultiGraph("Theory","#frac{#mu_{p}G_{E}^{p}}{G_{M}^{p}}");
//  TLegend *legThry = new TLegend(.585,.6,.9,.9,"","brNDC");
  TLegend *legThry = new TLegend(.335,.689,.649,.911,"","brNDC");

  wgr = mgrThry;
  wlg = legThry;

  // the theory
  wlg->SetBorderSize(0); // turn off border
  wlg->SetFillStyle(0);
  
  f = theoryfiles1;
  ogr=0;
  while ( f && f->filename ) {
    ogr=OneGraph(f);
    if (ogr) {
	    gr = fromGEpGMptoQ4GEp(ogr);
      TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
      if (egr && egr->GetEYhigh() && egr->GetEYhigh()[0]>0) {
	gr = toerror_band(egr);
	gr->SetFillStyle(3000+f->style);
      }
      gr->SetLineWidth(2);
      if (f->lnpt) {
		      wgr->Add(gr,f->lnpt);
	      if( f->label[0] != 'x' ){
		      wlg->AddEntry(gr,f->label,f->lnpt);
	      }
      }
      else if (gr->GetMarkerStyle()>=20) {
		      wgr->Add(gr,"p");
	      if( f->label[0] != 'x' ){
		      wlg->AddEntry(gr,f->label,"p");
	      }
      }	
      else {
		      wgr->Add(gr,"l");
	      if( f->label[0] != 'x' ){
		      wlg->AddEntry(gr,f->label,"l");
	      }
      }
    }
    f++;
  }

  mgrThry->Draw("c");
#ifdef PQCD
  ff->Draw("same");
  legThry->AddEntry(ff,"F2/F1 #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l");
#endif// PQCD
  legThry->Draw();



  cn->Modified();
  cn->Update();
  TFrame* frame = gPad->GetFrame();

  // draw a line at 1
  TLine *line1 = new TLine(frame->GetX1(),1.,frame->GetX2(),1.);
  line1->SetLineStyle(1);
  line1->Draw();

  return;
  cn->Update();
  cn->SaveAs(Form("%s.eps",psfile));
  cn->SaveAs(Form("%s.root",psfile));
  gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));

  // now an overlay, hopefully matching dimensions
  // remove everything except the frame
  cn->Update();
  TList *clist = cn->GetListOfPrimitives();
  frame = cn->GetFrame();
  for (int i=0; i<clist->GetSize(); ) {
	  if (clist->At(i) != frame) {
		  clist->RemoveAt(i);
	  } else i++;
  }
  // draw markers in the corners
  TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX1(),frame->GetY2(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY2(),2);
  mkr->Draw();
  frame->SetLineColor(10);


  {
	  datafile_t goeckeler = { "figure_input/Goeckeler/goeckeler.dat","Goeckeler",
		  "[0]","[1]","[1]-[2]","[3]-[1]",0,0,1,4,"F" };

	  gr = OneGraph(&goeckeler);
	  TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
	  if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
		  gr = toerror_band(egr);
		  gr->SetLineStyle(1);
		  gr->SetFillColor(gr->GetLineColor());
		  gr->SetFillStyle(3000+goeckeler.style);
	  }

	  gr->Draw("F");
	  cn->Update();
	  cn->SaveAs("mup_gep_gmp_goeckeler_Overlay.eps");
	  cn->SaveAs("mup_gep_gmp_goeckeler_Overlay.root");

	  // remove Goeckeler curve from plot
	  clist->Remove(gr);
  }

  {
	  datafile_t miller = { "figure_input/Miller/lattice.GEp_GMp.rtf","Miller",
		  "[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" };

	  gr = OneGraph(&miller);
	  TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
	  if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
		  gr = toerror_band(egr);
		  gr->SetLineStyle(1);
		  gr->SetFillColor(gr->GetLineColor());
		  gr->SetFillStyle(3000+miller.style);
	  }

	  gr->Draw("F");
	  cn->Update();
	  cn->SaveAs("mup_gep_gmp_Miller_Overlay.eps");
	  cn->SaveAs("mup_gep_gmp_Miller_Overlay.root");
	  clist->Remove(gr);
  }
  {
	  datafile_t zanotti = { "figure_input/Zanotti/zanotti_gepgmp.dat","Zanotti",
		  "[0]","[1]","[1]-[2]","[3]-[1]",0,0,1,6,"F" };

	  gr = OneGraph(&zanotti);
	  TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
	  if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
		  gr = toerror_band(egr);
		  gr->SetLineStyle(1);
		  gr->SetFillColor(gr->GetLineColor());
		  gr->SetFillStyle(3000+zanotti.style);
	  }

	  gr->Draw("F");
	  cn->Update();
	  cn->SaveAs("mup_gep_gmp_Zanotti_Overlay.eps");
	  cn->SaveAs("mup_gep_gmp_Zanotti_Overlay.root");
	  clist->Remove(gr);
  }

}
Beispiel #16
0
TCanvas* example_plot( int iPeriod, int iPos, bool t, int nt,double miPt, double maPt,string c,string hname, string lbl1, string lbl2,string lbl3 )
{ 
  //  if( iPos==0 ) relPosX = 0.12;

  int W = 800;
  int H = 600;

  int H_ref = 600; 
  int W_ref = 800; 

  // references for T, B, L, R
  float T = 0.08*H_ref;
  float B = 0.12*H_ref; 
  float L = 0.12*W_ref;
  float R = 0.04*W_ref;

  TString canvName = "FigMass_";
  canvName += W;
  canvName += "_";
  canvName += H;
  canvName += "_";  
  canvName += iPeriod;
  if( writeExtraText ) canvName += "_prelim";
  if( iPos%10==0 ) canvName += "_out";
  else if( iPos%10==1 ) canvName += "_left";
  else if( iPos%10==2 )  canvName += "_center";
  else if( iPos%10==3 )  canvName += "_right";

  TCanvas* canv = new TCanvas(canvName,canvName,50,50,W,H);
  canv->SetFillColor(0);
  canv->SetBorderMode(0);
  canv->SetFrameFillStyle(0);
  canv->SetFrameBorderMode(0);
  canv->SetLeftMargin( L/W );
  canv->SetRightMargin( R/W );
  canv->SetTopMargin( T/H );
  canv->SetBottomMargin( B/H );
  canv->SetTickx(0);
  canv->SetTicky(0);
 
  fit(4,t,nt,miPt,maPt,c);
//  fit(4,1,32,"Mass>8.6 && Mass<11.0 && TMath::Abs(EtaMuP)<1.2 && TMath::Abs(EtaMuM)<1.2 && Rapidity<1.2 ");
  
    {
    TLatex latex;

    int n_ = 3;
    float x1_l = 0.95;
    float y1_l = 0.70;

    float dx_l = 0.37;
    float dy_l = 0.23;
    float x0_l = x1_l-dx_l;
    float y0_l = y1_l-dy_l;

    TPad* legend = new TPad("legend_0","legend_0",x0_l,y0_l,x1_l, y1_l );
    //    legend->SetFillColor( kGray );
    legend->Draw();
    legend->cd();
    float gap_ = 1./(n_+1);
    float bwx_ = 0.12;

    x_l[0] = 1.2*bwx_;
    y_l[0] = 1-gap_;

    latex.SetTextFont(42);
    latex.SetTextAngle(0);
    latex.SetTextColor(kBlack);
    latex.SetTextSize(0.20);
    latex.SetTextAlign(12);

    float xx_ = x_l[0];
    float yy_ = y_l[0];
    //latex.DrawLatex(xx_+1.*bwx_,yy_,"#sigma = 26.5 #pm 2.2 MeV");
    //latex.DrawLatex(xx_+1.*bwx_,yy_,"#sigma = 13 MeV");
//    latex.DrawLatex(xx_+0.5*bwx_,yy_,"#sqrt{f_{1}#sigma_{1}^{2}+f_{2}#sigma_{2}^{2}} = 110 MeV");
   latex.DrawLatex(xx_+0.5*bwx_,yy_,lbl1.c_str());
    yy_ -= gap_;
//    latex.DrawLatex(xx_+0.5*bwx_,yy_,"p_{T}^{#mu^{+}#mu^{-}} > 13 GeV");
    latex.DrawLatex(xx_+0.5*bwx_,yy_,lbl2.c_str());
    yy_ -= gap_;
    latex.DrawLatex(xx_+0.5*bwx_,yy_,lbl3.c_str());
   // latex.DrawLatex(xx_+1.*bwx_,yy_,"|#eta_{#mu}| < 0.5");

    canv->cd();
  }
  // writing the lumi information and the CMS "logo"
  CMS_lumi( canv, iPeriod, iPos );

  canv->Update();
  canv->RedrawAxis();
  canv->GetFrame()->Draw();

  string hn="Plots/"+hname+".pdf";
  string hnpng ="Plots/"+hname+".png";
  canv->SaveAs(hn.c_str());
  canv->SaveAs(hnpng.c_str());
//  canv->Print(hname+".png",".png");

  return canv;
}
void triggerEfficiency()
{
  //=== General CMS Style ===

  gROOT->ForceStyle();

  //gROOT->LoadMacro("tdrstyle.C");
  setTDRStyle();

  //gROOT->LoadMacro("CMS_lumi.C");
  extraText  = "Preliminary";  // default extra text is "Preliminary"
  writeExtraText = true;       // remove or keep "Preliminary"

  lumi_13TeV  = "2015";  // for trigger
  //lumi_13TeV  = "65 pb^{-1}, 50ns";  // for trigger
  //lumi_13TeV  = "15.5 pb^{-1}, 25ns";  // for trigger

  //lumi_13TeV  = "65 pb^{-1}";  // default is ""
  //lumi_8TeV  = "19.1 fb^{-1}"; // default is "19.7 fb^{-1}"
  //lumi_7TeV  = "4.9 fb^{-1}";  // default is "5.1 fb^{-1}"
  lumi_sqrtS = "13 TeV";       // used with iPeriod = 0, e.g. for simulation-only plots (default is an empty string)

  int iPeriod = 4;    // 1=7TeV, 2=8TeV, 3=7+8TeV, 4=13TeV, 7=7+8+13TeV, 0=free form (uses lumi_sqrtS)
  int iPos = 11;     // 0=out , 11=left, 22=center, 33=right


  //====================================================================================
  // Style

  int W = 600;
  int H = 600;

  // 
  // Simple example of macro: plot with CMS name and lumi text
  //  (this script does not pretend to work in all configurations)
  // iPeriod = 1*(0/1 7 TeV) + 2*(0/1 8 TeV)  + 4*(0/1 13 TeV) 
  // For instance: 
  //               iPeriod = 3 means: 7 TeV + 8 TeV
  //               iPeriod = 7 means: 7 TeV + 8 TeV + 13 TeV 
  // Initiated by: Gautier Hamel de Monchenault (Saclay)
  // Updated by:   Dinko Ferencek (Rutgers)
  //
  int H_ref = 600; 
  int W_ref = 600; 

  // references for T, B, L, R
  float T = 0.08*H_ref;
  float B = 0.12*H_ref; 
  float L = 0.15*W_ref;
  float R = 0.04*W_ref;

  TString canvName = "trigger";
  canvName += W;
  canvName += "-";
  canvName += H;
  canvName += "_";  
  canvName += iPeriod;
  if( writeExtraText ) canvName += "-prelim";
  if( iPos%10==0 ) canvName += "-out";
  else if( iPos%10==1 ) canvName += "-left";
  else if( iPos%10==2 )  canvName += "-center";
  else if( iPos%10==3 )  canvName += "-right";

  TCanvas* canv = new TCanvas(canvName,canvName,50,50,W,H);
  canv->SetFillColor(0);
  canv->SetBorderMode(0);
  canv->SetFrameFillStyle(0);
  canv->SetFrameBorderMode(0);
  canv->SetLeftMargin( L/W );
  canv->SetRightMargin( R/W );
  canv->SetTopMargin( T/H );
  canv->SetBottomMargin( B/H );
  canv->SetTickx(0);
  canv->SetTicky(0);

  canv->SetGridx(true);
  canv->SetGridy(true);

  //====================================================================================
  // Efficiency

  TFile *fileInput = TFile::Open(myinputFile);

  fileInput->ls();

  TEfficiency* h_efficiency = 0;

  TH1F *h_denominator;
  TH1F *h_numerator;
  if(histoFromFile==1)
    {
      //== taking histo from file       
      h_denominator = (TH1F*)fileInput->Get(mydenominator);
      h_numerator   = (TH1F*)fileInput->Get(mynumerator);
    }
  else
    {
      //== creating histo from tree   
      TTree *thistree = (TTree*)fileInput->Get("rootTupleTree/tree");
      thistree->Print();
      TH1F *h_denominator_tmp = (TH1F*)fileInput->Get(mydenominator);
      h_denominator = (TH1F*)h_denominator_tmp->Clone();
      h_numerator = (TH1F*)h_denominator_tmp->Clone();
      h_denominator->Reset();
      h_numerator->Reset();
      h_denominator->SetName("h_denominator");
      h_numerator->SetName("h_numerator");
      //fill histograms
      //--
      //thistree->Draw("mjj >> h_denominator","fabs(deltaETAjj)<1.3 && passHLT_PFHT475==1"); //signal region
      //thistree->Draw("mjj >> h_denominator","fabs(deltaETAjj)<1.3 && passHLT_Mu45==1"); //signal region
      thistree->Draw("mjj >> h_denominator","fabs(deltaETAjj)>1.3 && fabs(deltaETAjj)<2.6 && passHLT_Mu45==1"); //control region
      //--
      //thistree->Draw("mjj >> h_numerator","fabs(deltaETAjj)<1.3 && passHLT_PFHT475==1 && passHLT_PFHT800==1");
      //thistree->Draw("mjj >> h_numerator","fabs(deltaETAjj)<1.3 && passHLT_Mu45==1 && passHLT_PFHT800==1");
      //thistree->Draw("mjj >> h_numerator","fabs(deltaETAjj)<1.3 && passHLT_Mu45==1 && (passHLT_PFHT800==1 || passHLT_PFJET500==1)");
      thistree->Draw("mjj >> h_numerator","fabs(deltaETAjj)>1.3 && fabs(deltaETAjj)<2.6 && passHLT_Mu45==1 && (passHLT_PFHT800==1 || passHLT_PFJET500==1)");
      //thistree->Draw("mjj >> h_numerator","fabs(deltaETAjj)>1.3 && fabs(deltaETAjj)<2.6 && passHLT_Mu45==1 && (passHLT_PFHT800==1 || passHLT_PFJET500==1 || passHLT_PFHT650MJJ950==1 || passHLT_PFHT650MJJ900==1 || passHLT_AK8DiPFJet280200TrimMass30Btag==1 || passHLT_AK8PFHT600TriMass50Btag==1 || passHLT_AK8PFHT700TriMass50==1 || passHLT_AK8PFJet360TrimMass50==1 || passHLT_CaloJet500NoJetID==1 || passHLT_DiPFJetAve300HFJEC==1 || passHLT_DiPFJetAve500==1 || passHLT_PFHT400SixJet30Btag==1 || passHLT_PFHT450SixJet40Btag==1 || passHLT_PFHT750FourJetPt50==1 || passHLT_QuadPFJetVBF==1 || passHLT_PFHT650==1 || passHLT_PFHT475==1 || passHLT_PFHT200==1 || passHLT_PFJET450==1)");
      //-- option placeholder 
      //thistree->Draw("mjj >> h_denominator","fabs(deltaETAjj)<1.3 && passHLT_Mu45==1","",10000);
      //--  
    }

  //==========================

  if(TEfficiency::CheckConsistency(*h_numerator,*h_denominator))
    {
      h_efficiency = new TEfficiency(*h_numerator,*h_denominator);    
      //stat option, see https://root.cern.ch/root/html/TEfficiency.html#TEfficiency:SetStatisticOption
      h_efficiency->SetStatisticOption(TEfficiency::kFWilson);  
      //h_efficiency->SetStatisticOption(TEfficiency::kFCP); //default  
      h_efficiency->SetTitle(mytitle);
      h_efficiency->Draw();
      gPad->Update();
      h_efficiency->GetPaintedGraph()->GetXaxis()->SetRangeUser(xmin,xmax);
      h_efficiency->GetPaintedGraph()->GetXaxis()->SetNdivisions(505);
      h_efficiency->GetPaintedGraph()->GetYaxis()->SetRangeUser(ymin,ymax);
      //h_efficiency->GetPaintedGraph()->GetYaxis()->SetTitleOffset(0.9);
      // h_efficiency->GetPaintedGraph()->GetYaxis()->SetLabelSize(0.04);

      for (int bin=0;bin<h_efficiency->GetPaintedGraph()->GetN();bin++)
	{
	  double x=-1; 
	  double y=-1;
	  double eyh=-1;
	  double eyl=-1;

	  h_efficiency->GetPaintedGraph()->GetPoint(bin,x,y);
	  eyh = h_efficiency->GetPaintedGraph()->GetErrorYhigh(bin);
	  eyl = h_efficiency->GetPaintedGraph()->GetErrorYlow(bin);
	  cout << "bin = " << bin << ": x= " << x << " , y = " << y << " + " << eyh << " - " << eyl << endl;       
	}

      // draw the legend
      TLegend *legend=new TLegend(0.35,0.22,0.89,0.32);
      //legend->SetTextFont(72);
      //legend->SetTextSize(0.04);
      legend->SetFillStyle(0);
      legend->SetLineColor(0);
      legend->SetShadowColor(0);
      legend->AddEntry(h_efficiency,mytitlelegend,"lpe");
      legend->Draw();
    }

  //====================================================================================
  //Draw

  //## Trigger Efficiency plot ##
  // writing the lumi information and the CMS "logo"
  CMS_lumi( canv, iPeriod, iPos ); 
  canv->Update();
  canv->RedrawAxis();
  canv->GetFrame()->Draw();
  gPad->SetTickx(1);
  gPad->SetTicky(1);
  canv->Print(myoutputfilename+".pdf",".pdf");
  canv->Print(myoutputfilename+".png",".png");
  canv->Print(myoutputfilename+".root",".root");
  
  //## Trigger Efficiency plot (zoom) ## 
  h_efficiency->GetPaintedGraph()->GetXaxis()->SetRangeUser(xminZoom,xmaxZoom);
  h_efficiency->GetPaintedGraph()->GetYaxis()->SetRangeUser(yminZoom,ymaxZoom);

  CMS_lumi( canv, iPeriod, iPos ); 
  canv->Update();
  canv->RedrawAxis();
  canv->GetFrame()->Draw();
  gPad->SetTickx(1);
  gPad->SetTicky(1);
  canv->Print(myoutputfilename+"_zoom.pdf",".pdf");
  canv->Print(myoutputfilename+"_zoom.png",".png");
  
  //Integral above threshold
  int totalNev =  h_denominator->Integral(h_denominator->FindFixBin(threshold),h_denominator->GetNbinsX());
  int passedNev =  h_numerator->Integral(h_numerator->FindFixBin(threshold),h_numerator->GetNbinsX());
  //int totalNev =  h_denominator->Integral(h_denominator->FindFixBin(threshold),h_denominator->FindFixBin(threshold));
  //int passedNev =  h_numerator->Integral(h_numerator->FindFixBin(threshold),h_numerator->FindFixBin(threshold));
  float effIntegrated = float(passedNev)/float(totalNev);
  cout << "totalNev = " << totalNev <<  " , passedNev=" << passedNev << " , efficiency=" << effIntegrated << endl;       
  TEfficiency* pEff = 0;
  float effIntegrated_errUp = pEff->Wilson(totalNev,passedNev,0.683,true) - effIntegrated;
  float effIntegrated_errDown = pEff->Wilson(totalNev,passedNev,0.683,false) - effIntegrated;
  cout << "efficiency integrated above threshold of "<< threshold <<" = " << effIntegrated << " + " << effIntegrated_errUp << " - " << effIntegrated_errDown << endl;


  //## Mjj Spectra ##
  canv->SetGridx(false);
  canv->SetGridy(false);
  canv->SetLogy(true);
  h_denominator->UseCurrentStyle();  
  h_denominator->SetLineColor(2);
  h_numerator->SetLineColor(1);
  h_denominator->Draw();
  h_numerator->Draw("same");
  h_denominator->GetXaxis()->SetRangeUser(xmin,xmax);
  h_denominator->GetXaxis()->SetTitle(xAxisTitle);
  h_denominator->GetYaxis()->SetTitle(yAxisTitle);
  h_denominator->GetYaxis()->SetTitleOffset(1.3);

  CMS_lumi( canv, iPeriod, iPos ); 
  canv->Update();
  canv->RedrawAxis();
  canv->GetFrame()->Draw();
  gPad->SetTickx(1);
  gPad->SetTicky(1);

  // draw the legend
  TLegend *legend1=new TLegend(0.4,0.65,0.91,0.83);
  //legend->SetTextFont(72);
  //legend->SetTextSize(0.06);
  legend1->SetFillStyle(0);
  legend1->SetLineColor(0);
  legend1->SetShadowColor(0);
  legend1->AddEntry(h_denominator,mytitlelegendDen,"l");
  legend1->AddEntry(h_numerator,mytitlelegendNum,"l");
  legend1->Draw();

  canv->Print(myoutputfilename+"_histo.pdf",".pdf");
  canv->Print(myoutputfilename+"_histo.png",".png");
  



  //-----------------------------------------------------------------------------

}
//___________________________________________________________________________________
void CalibMwpc(const Int_t opt, TH1D &*h1, TH2D &*h2, TGraphErrors &*grMean, TGraphErrors &*grSigma)
{
  // General style
//   gROOT->ProcessLine(".x Style_Default_2.C");
//   gROOT->SetStyle("Default_2");
//   gROOT->ForceStyle();
  
  //
  TCanvas *cnv;
  TLine *lZ = new TLine(-300.,0.,300.,0.);
  lZ->SetLineColor(kBlue);
  lZ->SetLineWidth(2.);
  TLine *lTheta = new TLine(0.,0.,180.,0.);
  lTheta->SetLineColor(kBlue);
  lTheta->SetLineWidth(2.);
  TLine *lPhi = new TLine(0.,0.,360.,0.);
  lPhi->SetLineColor(kBlue);
  lPhi->SetLineWidth(2.);
  
  //
  switch (opt)
  {
    case 1:
      // dPhi MWPC1 - MWPC0
      cnv = new TCanvas("dPhi");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DphiMwpc21");
      h1->Draw();
      h1->Fit("gaus","","",-1.,1.);
      // dPhi(Z)
      cnv = new TCanvas("dPhi_VS_Z");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiMwpc21_v_Z0Mwpc21");
      h2->Draw("color");
      lZ->Draw("same");
      break;
      
    case 2:
      // dX
      cnv = new TCanvas("dX");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DxMwpc21");
      h1->Draw();
      h1->Fit("gaus","","",-2.,2.);
      // dX(Z)
      cnv = new TCanvas("dX_VS_Z");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxMwpc21_v_Z0Mwpc21");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDx_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,5.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dX(Z)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDx_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,-3.,300.,3.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(Z)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 3:
      // dY
      cnv = new TCanvas("dY");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DyMwpc21");
      h1->Draw();
      h1->Fit("gaus","","",-10.,10.);
      // dY(Z)
      cnv = new TCanvas("dY_VS_Z");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyMwpc21_v_Z0Mwpc21");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDy_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,15.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dY(Z)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDy_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,-5.,300.,5.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(Z)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 4:
      // dZ
      cnv = new TCanvas("dZ");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DzMwpc21");
      h1->Draw();
      h1->Fit("gaus","","",-3.,3.);
      // dZ(Z)
      cnv = new TCanvas("dZ_VS_Z");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzMwpc21_v_Z0Mwpc21");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDz_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,5.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(Z)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDz_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,-3.,300.,3.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(Z)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      // dZ(Theta)
      cnv = new TCanvas("dZ_VS_Theta");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzMwpc21_v_ThetaTracks");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDz_vs_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,5.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(Theta)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDz_vs_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,-3.,180.,3.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("Theta, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(Theta)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 5:
      // dPhi tracks
      cnv = new TCanvas("dPhiTracks");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DPhiTracks");
      h1->Draw();
      h1->Fit("gaus","","",-10.,10.);
      // dPhi tracks (Theta)
      cnv = new TCanvas("dPhiTracks_v_Theta");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DPhiTracks_v_ThetaTracks");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDphiTracks_v_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("Standard deviation of #Delta#Phi as a function #theta");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDphiTracks_v_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("#Delta#Phi(#theta)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 6:
      // dTheta tracks
      cnv = new TCanvas("dTetTracks");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DTetTracks");
      h1->Draw();
      h1->Fit("gaus","","",-7.,7.);
      // dTheta tracks (Theta)
      cnv = new TCanvas("dTetTracks_v_Theta");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DTetTracks_v_ThetaTracks");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDthetaTracks_v_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("Standard deviation of #Delta#theta as a function of #theta");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDthetaTracks_v_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("#Delta#theta(#theta)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
    
    case 66:
      // dTheta2 tracks2
      cnv = new TCanvas("dTetTracks2");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DTetTracks2");
      h1->Draw();
      h1->Fit("gaus","","",-7.,7.);
      // dTheta tracks (Theta)
      cnv = new TCanvas("dTetTracks2_v_Theta2");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DTetTracks2_v_ThetaTracks2");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDthetaTracks2_v_Theta2");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("Standard deviation of #Delta#theta as a function of #theta");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDthetaTracks2_v_Theta2");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("#Delta#theta(#theta)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 7:
      // dPsi tracks
      cnv = new TCanvas("dPsiTracks");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DPsiTracks");
      h1->Draw();
      break;
      
    case 8:
      // dZ vs Zinter
      cnv = new TCanvas("DzInterMwpc1");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DzInterMwpc1");
      h1->Draw();
      h1->Fit("gaus","","",-3.,3.);
      //
      cnv = new TCanvas("Dz_vs_Zinter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzInterMwpc1_v_ZinterMwpc1");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDz_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(Zinter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDz_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(Zinter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 9:
      // dX vs Zinter
      cnv = new TCanvas("DxInterMwpc1");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DxInterMwpc1");
      h1->Draw();
      h1->Fit("gaus","","",-2.5,2.5);
      //
      cnv = new TCanvas("Dx_vs_Zinter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxInterMwpc1_v_ZinterMwpc1");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDx_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dX(Zinter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDx_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(Zinter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 10:
      // dY vs Zinter
      cnv = new TCanvas("DyInterMwpc1");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DyInterMwpc1");
      h1->Draw();
      h1->Fit("gaus","","",-.2,.2);
      //
      cnv = new TCanvas("Dy_vs_Zinter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyInterMwpc1_v_ZinterMwpc1");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDy_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dY(Zinter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDy_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(Zinter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 11:
      // dZ vs PhiInter
      cnv = new TCanvas("Dz_vs_PhiInter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzInterMwpc1_v_PhiInterMwpc1");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDz_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(PhiInter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDz_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(PhiInter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 12:
      // dX vs PhiInter
      cnv = new TCanvas("Dx_vs_PhiInter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxInterMwpc1_v_PhiInterMwpc1");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDx_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dX(PhiInter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDx_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(PhiInter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 13:
      // dY vs PhiInter
      cnv = new TCanvas("Dy_vs_PhiInter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyInterMwpc1_v_PhiInterMwpc1");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDy_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dY(PhiInter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDy_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(PhiInter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 14:
      // dPhi vs PhiInter
      cnv = new TCanvas("dPhiInter");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DphiInterMwpc1");
      h1->Draw();
      h1->Fit("gaus","","",-1.,1.);
      //
      cnv = new TCanvas("Dphi_vs_PhiInter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiInterMwpc1_v_PhiInterMwpc1");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDphi_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhi(PhiInter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDphi_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhi(PhiInter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 15:
      // dPhi vs Zinter
      cnv = new TCanvas("Dphi_vs_Zinter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiInterMwpc1_v_ZinterMwpc1");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDphi_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhi(Zinter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDphi_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhi(Zinter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    default:
      // Plot all
      for (Int_t i=1; i<=20; ++i) CalibMwpc(i,0,0,0,0);
  }
  
}
Beispiel #19
0
void finalPlot(bool drawRatio = 1, int differential = 0, int nsel = 0, int ReBin = 1, TString XTitle = "p_{T,max}^{l} (GeV)", TString units = "", TString plotName = "XSLeadingPt_AN.root", TString outputName = "WW_LeadingPt_final", bool isLogY = false,  double lumi = 19.5) {

  gInterpreter->ExecuteMacro("GoodStyle.C");

  TFile* file = new TFile(plotName.Data(), "read");
 
  TH1F* xsValue = (TH1F*) xsValue->Clone();
  TH1F* xsValue_Powheg =  (TH1F*) xsValue_Powheg->Clone();
  TH1F* xsValue_Madgraph = (TH1F*) xsValue_Madgraph->Clone();
  TH1F* xsValue_MCnlo = (TH1F*) xsValue_MCnlo->Clone();
  TH1F* systHisto = (TH1F*) systHisto->Clone();

 
  TCanvas* canvas ;
  TPad *pad1, *pad2;
 
   if (drawRatio) {
    canvas = new TCanvas("wwxs", "wwxs", 550, 1.2*600);
    
    pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1);
    pad1->SetTopMargin   (0.05);
    pad1->SetBottomMargin(0.02);
    pad1->Draw();
    
    pad2 = new TPad("pad2", "pad2", 0, 0, 1, 0.31); 
    pad2->SetTopMargin   (0.08);
    pad2->SetBottomMargin(0.35);
    pad2->Draw();
  
  }       else { 
    canvas = new TCanvas("wwxs", "wwxs", 550, 550);
    }

   if (drawRatio) pad1->cd();


   //Plot Data
   xsValue->SetLineWidth(1);
   xsValue->SetMarkerSize(1.0);

   int NBins = xsValue->GetNbinsX();

   for(int i=1; i <NBins; i++) {

     float err_stat = xsValue->GetBinError(i);
     float err_syst = systHisto->GetBinError(i);
     float err_total = sqrt(err_stat*err_stat + err_syst*err_syst);

     xsValue->SetBinError(i, err_total);
   }


  //-- Plot Powheg

   TH1F *hpowError  = (TH1F*) xsValue_Powheg->Clone();

   xsValue_Powheg->SetMarkerColor(kAzure-3);
   xsValue_Powheg->SetLineWidth(1);
   xsValue_Powheg->SetLineColor(kBlue+2);
   xsValue_Powheg->SetMarkerStyle(22);
   xsValue_Powheg->SetMarkerSize(1.2);
  

   hpowError->SetLineWidth(0);
   hpowError->SetMarkerSize (      0);  
   hpowError->SetFillColor  (kAzure-9);


  //-- Plot Madgraph

  TH1F *hmadError  = (TH1F*) xsValue_Madgraph->Clone();

  xsValue_Madgraph->SetMarkerColor(kPink-9);
  xsValue_Madgraph->SetLineWidth(1);
  xsValue_Madgraph->SetLineStyle(1);
  xsValue_Madgraph->SetMarkerStyle(21);
  xsValue_Madgraph->SetMarkerSize(1.0);

  hmadError->SetLineWidth(0);
  hmadError->SetMarkerSize (      0); 
  hmadError->SetFillColor  (kPink+1);


  //-- Plot MCNLO

  TH1F *hmcError  = (TH1F*) xsValue_MCnlo->Clone();

  xsValue_MCnlo->SetMarkerColor(kRed);
  xsValue_MCnlo->SetLineColor(kRed);
  xsValue_MCnlo->SetLineWidth(1);
  xsValue_MCnlo->SetLineStyle(1);
  xsValue_MCnlo->SetMarkerStyle(24);
  xsValue_MCnlo->SetMarkerSize(1.0);

  hmcError->SetLineWidth(0);
  hmcError->SetMarkerSize (      0); 
  hmcError->SetFillColor  (kOrange);
 



  //-- Plot Data

  xsValue->SetMarkerStyle(kFullCircle);
      
  if (differential == 0) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dp_{T,max}^{l}}");
  if (differential == 1) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dp_{T}(ll)}");
  if (differential == 2) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dm_{#font[12]{ll}}}");
  if (differential == 3) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{d#Delta#phi_{ll}}");

  AxisFonts (xsValue->GetXaxis(), XTitle);
 



  xsValue->Draw("p");
  hmadError->Draw("e2,same"); 
  xsValue_Madgraph->Draw("pe1,same");
  hmcError->Draw("e2,same");
  xsValue_MCnlo->Draw("pe1,same");
  hpowError->Draw("e2,same");
  xsValue_Powheg->Draw("pe1,same");
  //systHisto->Draw("e2, same");
  xsValue->Draw("pe1,same");
      
  // Legend
  //----------------------------------------------------------------------------
  
  DrawLegend (0.65, 0.85, xsValue, "Data", "P");
  DrawLegend (0.65, 0.80, hpowError,   "", "F");
  DrawLegend (0.65, 0.80, xsValue_Powheg,   "Powheg", "PL");
  DrawLegend (0.65, 0.75, hmadError,   "", "F");
  DrawLegend (0.65, 0.75, xsValue_Madgraph,   "Madgraph", "PL");  
  DrawLegend (0.65, 0.70, hmcError,   "", "F");
  DrawLegend (0.65, 0.70, xsValue_MCnlo,   "MCNLO", "LP");

  canvas->GetFrame()->DrawClone();



  // Draw text 
  //----------------------------------------------------------------------------
  TLatex * CMSLabel = new TLatex (0.18, 0.96, "#bf{CMS}");
  CMSLabel->SetNDC ();
  CMSLabel->SetTextAlign (10);
  CMSLabel->SetTextFont (42);
  CMSLabel->SetTextSize (_tsize);
  CMSLabel->Draw ("same") ;


  TLatex * _lumiLabel = new TLatex (0.95, 0.96, "19.4fb#lower[0.3]{^{-1}} (8 TeV)");
  _lumiLabel->SetNDC ();
  _lumiLabel->SetTextAlign (30);
  _lumiLabel->SetTextFont (42);
  _lumiLabel->SetTextSize (_tsize);
  _lumiLabel->Draw ("same") ;


  // Draw also ratio
  //----------------------------------------------------------------------------
  if (drawRatio) {

     pad2->cd();
	
    TH1F* ratio_pow       = xsValue_Powheg->Clone("ratio");
    TH1F* ratio_mad       = xsValue_Madgraph->Clone("ratio");
    TH1F* ratio_mcnlo     = xsValue_MCnlo->Clone("ratio");
    TH1F* hratio_pow       = xsValue_Powheg->Clone("ratio");
    TH1F* hratio_mad       = xsValue_Madgraph->Clone("ratio");
    TH1F* hratio_mcnlo     = xsValue_MCnlo->Clone("ratio");
    TH1F* ratioErr        = xsValue->Clone("ratio");
    

    for (UInt_t ibin=1; ibin<=ratio->GetNbinsX(); ibin++) {

      Double_t powValue = xsValue_Powheg->GetBinContent(ibin);
      Double_t powError = xsValue_Powheg->GetBinError  (ibin);
      
      Double_t madValue = xsValue_Madgraph->GetBinContent(ibin);
      Double_t madError = xsValue_Madgraph->GetBinError  (ibin);
      
      Double_t mcnloValue = xsValue_MCnlo->GetBinContent(ibin);
      Double_t mcnloError = xsValue_MCnlo->GetBinError  (ibin);
      
      Double_t dataValue = xsValue->GetBinContent(ibin);
      Double_t statError = xsValue->GetBinError  (ibin);
      Double_t systError = systHisto->GetBinError(ibin);
      
      Double_t dataError = systError;
      
      Double_t ratioValue_pow           = (powValue > 0) ? powValue/dataValue : 0.0;
      Double_t ratioError_pow           = (powValue > 0) ? powError / dataValue : 0.0;
      
      Double_t ratioValue_mad           = (madValue > 0) ? madValue/dataValue : 0.0;
      Double_t ratioError_mad           = (madValue > 0) ? madError/dataValue : 0.0;
      
      Double_t ratioValue_mcnlo         = (mcnloValue > 0) ? mcnloValue/dataValue : 0.0;
      Double_t ratioError_mcnlo         = (mcnloValue > 0) ? mcnloError/dataValue : 0.0;
      
      Double_t uncertaintyError         = (dataValue > 0) ? dataError/dataValue : 0.0;
      

      //dataError/dataValue 
      ratio_pow->SetBinContent(ibin, ratioValue_pow);
      hratio_pow->SetBinContent(ibin, ratioValue_pow);
      hratio_pow->SetBinError  (ibin, ratioError_pow);
      
      ratio_mad->SetBinContent(ibin, ratioValue_mad);
      hratio_mad->SetBinContent(ibin, ratioValue_mad);
      hratio_mad->SetBinError  (ibin, ratioError_mad);
      
      ratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo);
      hratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo);
      hratio_mcnlo->SetBinError  (ibin, ratioError_mcnlo);
      
      ratioErr->SetBinContent(ibin, 1.0);
      ratioErr->SetBinError  (ibin, uncertaintyError);
    }

    ratioErr->SetTitle("");
    ratioErr  ->Draw("e2");
    
   
    
    ratio_mad      ->SetLineColor(kPink-9);
    ratio_mad      ->SetMarkerSize(1.0);
    ratio_mad      ->SetLineWidth(1);
    ratio_mad      ->SetMarkerStyle(21);
    hratio_mad     ->SetLineWidth(0);
    hratio_mad     ->SetMarkerSize (      0);  
    hratio_mad     ->SetFillColor  (kPink+1);
    hratio_mad     ->SetFillStyle  (1001);
    hratio_mad     ->Draw("e2,same");
    ratio_mad      ->Draw("e1p,same");
    
    
    ratio_mcnlo     ->SetLineColor(kRed);
    ratio_mcnlo     ->SetMarkerSize(1.0);
    ratio_mcnlo      ->SetLineWidth(1);
    ratio_mcnlo     ->SetMarkerStyle(24);
    hratio_mcnlo    ->SetLineWidth(0);
    hratio_mcnlo    ->SetMarkerSize (      0);  
    hratio_mcnlo    ->SetFillColor  (kOrange);
    hratio_mcnlo     ->SetFillStyle  (1001);
    hratio_mcnlo    ->Draw("e2,same");
    ratio_mcnlo     ->Draw("ep,same");

    ratio_pow      ->SetLineColor(kAzure-3);
    ratio_pow      ->SetMarkerSize(1.2);
    ratio_pow      ->SetLineWidth(1);
    ratio_pow      ->SetMarkerStyle(22);
    hratio_pow     ->SetLineWidth(0);
    hratio_pow     ->SetMarkerSize (      0);  
    hratio_pow     ->SetFillColor  (kAzure-9);
    hratio_pow     ->SetFillStyle  (1001);
    hratio_pow     ->Draw("e2,same");
    ratio_pow      ->Draw("e1p,same");
    
  
    
    ratioErr->SetFillColor  (kGray+2);
    ratioErr->SetFillStyle  (   3345);
    ratioErr->SetLineColor  (kGray+2);
    ratioErr->SetMarkerColor(kGray+2);
    ratioErr->SetMarkerSize (      0);

    ratioErr->Draw("sameaxis");

    ratioErr->GetYaxis()->SetRangeUser(0.4, 1.6);

   
    AxisFontsRatio (ratioErr->GetYaxis(), "y", "MC/data");
    AxisFontsRatio (ratioErr->GetXaxis(), "x", XTitle);

  }
      

}
//___________________________________________________________________________________
void CalibMwpcNaI(const Int_t ii, const Int_t opt, TH1D &*h1, TH2D &*h2, TGraphErrors &*grMean, TGraphErrors &*grSigma)
{
  // General style
//   gROOT->ProcessLine(".x Style_Default_2.C");
//   gROOT->SetStyle("Default_2");
//   gROOT->ForceStyle();
  
  //
  TGraphErrors *grMean, *grSigma;
  TCanvas *cnv;
  TH1D *h1;
  TH2D *h2;
  TLine *lZ = new TLine(-300.,0.,300.,0.);
  lZ->SetLineColor(kBlue);
  lZ->SetLineWidth(2.);
  TLine *lTheta = new TLine(0.,0.,180.,0.);
  lTheta->SetLineColor(kBlue);
  lTheta->SetLineWidth(2.);
  TLine *lPhi = new TLine(0.,0.,360.,0.);
  lPhi->SetLineColor(kBlue);
  lPhi->SetLineWidth(2.);
  
  //
  TString i;
  stringstream ss;
  ss << ii;
  ss >> i;
  
  //
  switch (opt)
  {
    case 1:
      // dPhi Mwpc-NaI
      cnv = new TCanvas("dPhi"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DphiMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-1.8,1.8);
      //   hDphi->Fit("gaus");
      // dPhi(Z)
      cnv = new TCanvas("dPhi_VS_Z"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiMwpc"+i+"NaI_v_Z0Mwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("dPhi_Sigma_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma_{#Delta#varphi}, degrees");
      h1->SetTitle("dPhi(Z), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("dPhi_Mean_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhi(Z), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 2:
      // dX
      cnv = new TCanvas("dX"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DxMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-20.,20.);
      // dX(Z)
      cnv = new TCanvas("dX_VS_Z"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxMwpc"+i+"NaI_v_Z0Mwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("dX_Sigma_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma_{#DeltaX}, mm");
      h1->SetTitle("dX(Z), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("dX_Mean_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(Z), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 3:
      // dY
      cnv = new TCanvas("dY"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DyMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-60.,60.);
      // dY(Z)
      cnv = new TCanvas("dY_VS_Z"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyMwpc"+i+"NaI_v_Z0Mwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-70.,70.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("dY_Sigma_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,40.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma_{#DeltaY}, mm");
      h1->SetTitle("dY(Z), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("dY_Mean_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(Z), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 4:
      // dZ
      cnv = new TCanvas("dZ"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DzMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-10.,10.);
      // dZ(Z)
      cnv = new TCanvas("dZ_VS_Z"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzMwpc"+i+"NaI_v_Z0Mwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("dZ_Sigma_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma_{#DeltaZ}, mm");
      h1->SetTitle("dZ(Z), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("dZ_Mean_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(Z), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      // dZ(Theta)
      cnv = new TCanvas("dZ_VS_Theta"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzMwpc"+i+"NaI_v_ThetaTracksMwpc"+i+"NaI");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("dZ_Sigma_vs_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(#theta), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("dZ_Mean_vs_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-30.,180.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(#theta), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 5:
      // dPhi tracks
      cnv = new TCanvas("dPhiTracks"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DPhiTracksMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-5.,5.);
      // dPhi tracks (Theta)
      cnv = new TCanvas("dPhiTracks_v_Theta"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DPhiTracksMwpc"+i+"NaI_v_ThetaTracksMwpc"+i+"NaI");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("Sigma_dPhiTracks_v_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("Standard deviation of #Delta#Phi as a function of #theta, MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("Mean_dPhi_vs_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-30.,180.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("#Delta#Phi(#theta), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 6:
      // dTheta tracks
      cnv = new TCanvas("dTetTracks"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DTetTracksMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-3.,3.);
      // dTheta tracks (Theta)
      cnv = new TCanvas("dTetTracks_v_Theta"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DTetTracksMwpc"+i+"NaI_v_ThetaTracksMwpc"+i+"NaI");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("Sigma_dThetaTracks_v_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("Standard deviation of #Delta#theta as a function #theta, MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("Mean_dTheta_vs_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-30.,180.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("#Delta#theta(#theta), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 7:
      // dPsi tracks
      cnv = new TCanvas("dPsiTracks"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DPsiTracksMwpc"+i+"NaI");
      h1->Draw();
      break;
      
    case 8:
      // dZ vs Zinter
      cnv = new TCanvas("Dz_vs_Zinter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzInterMwpc"+i+"NaI_v_ZinterMwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("Sigma_dZ_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("Dz(Zinter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("Mean_dZ_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("Dz(Zinter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1","","",-280.,280.);
      grMean->Draw("P");
      break;
      
    case 9:
      // dX vs Zinter
      cnv = new TCanvas("Dx_vs_Zinter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxInterMwpc"+i+"NaI_v_ZinterMwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-40.,40.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDx_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dX(Zinter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDx_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(Zinter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 10:
      // dY vs Zinter
      cnv = new TCanvas("Dy_vs_Zinter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyInterMwpc"+i+"NaI_v_ZinterMwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDy_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dY(Zinter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDy_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(Zinter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 11:
      // dZ vs PhiInter
      cnv = new TCanvas("Dz_vs_PhiInter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzInterMwpc"+i+"NaI_v_PhiInterMwpc"+i+"NaI");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-40.,40.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDz_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,40.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(PhiInter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDz_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(PhiInter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 12:
      // dX vs PhiInter
      cnv = new TCanvas("Dx_vs_PhiInter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxInterMwpc"+i+"NaI_v_PhiInterMwpc"+i+"NaI");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-40.,40.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDx_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dX(PhiInter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDx_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(PhiInter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 13:
      // dY vs PhiInter
      cnv = new TCanvas("Dy_vs_PhiInter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyInterMwpc"+i+"NaI_v_PhiInterMwpc"+i+"NaI");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDy_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dY(PhiInter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDy_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-20.,360.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(PhiInter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 14:
      // dPhi vs PhiInter
      cnv = new TCanvas("Dphi_vs_PhiInter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiInterMwpc"+i+"NaI_v_PhiInterMwpc"+i+"NaI");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDphi_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhi(PhiInter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDphi_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhi(PhiInter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 15:
      // dPhi vs Zinter
      cnv = new TCanvas("Dphi_vs_Zinter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiInterMwpc"+i+"NaI_v_ZinterMwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDphi_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhi(Zinter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDphi_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhi(Zinter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    default:
      for (Int_t j=1; j<=20; ++j) CalibMwpcNaI(i,j,0,0,0,0);
  }
}
Beispiel #21
0
//------------------------------------------------------------------------------
// DrawZPeak
//------------------------------------------------------------------------------
void DrawZPeak(TString energy)
{
  if (energy.Contains("7TeV"))
    {
      _lumiText = "4.9 fb^{-1} (7 TeV)";
    }
  else
    {
      _lumiText = "19.6 fb^{-1} (8 TeV)";
    }


  // Read the input file
  //----------------------------------------------------------------------------
  TString name = "invMass2Lep_";

  TFile* file = new TFile("rootfiles/" + name + energy + ".root", "read");

  TH1F* data;
  TH1F* WZ;
  TH1F* fakes;
  TH1F* ZZ;
  TH1F* Zgamma;
  TH1F* WV;
  TH1F* VVV;
  TH1F* allmc;

  if (energy.Contains("7TeV"))
    {
      data   = (TH1F*)file->Get("hZMass_Sel_datahist_COMB");
      WZ     = (TH1F*)file->Get("hZMass_Sel_wz_COMB");
      fakes  = (TH1F*)file->Get("hZMass_Sel_datadriven_COMB");
      ZZ     = (TH1F*)file->Get("hZMass_Sel_zz_COMB");
      Zgamma = (TH1F*)file->Get("hZMass_Sel_zg_COMB");
      WV     = (TH1F*)file->Get("hZMass_Sel_wz_COMB");
      VVV    = (TH1F*)file->Get("hZMass_Sel_wz_COMB");
      allmc  = (TH1F*)file->Get("all_estimates_with_error_COMB");
    }
  else if (energy.Contains("8TeV"))
    {
      data   = (TH1F*)file->Get("h_data");
      WZ     = (TH1F*)file->Get("h_WZ");
      fakes  = (TH1F*)file->Get("h_Fakes");
      ZZ     = (TH1F*)file->Get("h_ZZ");
      Zgamma = (TH1F*)file->Get("h_ZGamma");
      WV     = (TH1F*)file->Get("h_WV");
      VVV    = (TH1F*)file->Get("h_VVV");
      allmc  = (TH1F*)file->Get("h_All");
    }

  WZ->SetFillColor(kOrange-2);
  WZ->SetLineColor(kOrange-2);

  Zgamma->SetFillColor(kRed+1);  // kRed+2
  Zgamma->SetLineColor(kRed+1);  // kRed+2

  ZZ->SetFillColor(kRed+1);
  ZZ->SetLineColor(kRed+1);

  fakes->SetFillColor(kGray+1);
  fakes->SetLineColor(kGray+1);
  
  data->SetMarkerStyle(kFullCircle);

  allmc->SetFillColor  (kBlack);
  allmc->SetFillStyle  (3345);
  allmc->SetLineColor  (kWhite);
  allmc->SetLineWidth  (0);
  allmc->SetMarkerColor(kOrange-2);
  allmc->SetMarkerSize (0);

  THStack* hs = new THStack();

  if (energy.Contains("8TeV"))
    {
      WV->SetFillColor(kRed+1);  // kAzure
      WV->SetLineColor(kRed+1);  // kAzure

      VVV->SetFillColor(kRed+1);  // kBlack
      VVV->SetLineColor(kRed+1);  // kBlack

      hs->Add(VVV);
      hs->Add(WV);
    }

  hs->Add(Zgamma);
  hs->Add(ZZ);
  hs->Add(fakes);
  hs->Add(WZ);


  // Draw
  //----------------------------------------------------------------------------
  TCanvas* canvas = new TCanvas(energy, energy);

  data->Draw("ep");


  // Axis labels
  //----------------------------------------------------------------------------
  TAxis* xaxis = data->GetXaxis();
  TAxis* yaxis = data->GetYaxis();
  
  xaxis->SetLabelFont  (  42);
  xaxis->SetLabelOffset(0.01);
  xaxis->SetLabelSize  (0.05);
  xaxis->SetNdivisions ( 505);
  xaxis->SetTitleFont  (  42);
  xaxis->SetTitleOffset( 1.3);
  xaxis->SetTitleSize  (0.05);

  yaxis->SetLabelFont  (  42);
  yaxis->SetLabelOffset(0.01);
  yaxis->SetLabelSize  (0.05);
  yaxis->SetNdivisions ( 505);
  yaxis->SetTitleFont  (  42);
  yaxis->SetTitleOffset( 1.6);
  yaxis->SetTitleSize  (0.05);

  xaxis->SetRangeUser(68, 112);
  xaxis->SetTitle("m_{#font[12]{ll}} (GeV)");
  yaxis->SetTitle(Form("Events /  %.0f GeV", data->GetBinWidth(0)));


  // Adjust scale
  //----------------------------------------------------------------------------
  Float_t theMax   = GetMaximumIncludingErrors(data);
  Float_t theMaxMC = GetMaximumIncludingErrors(allmc);

  if (theMaxMC > theMax) theMax = theMaxMC;

  data->SetMaximum(1.15 * theMax);


  // Legend
  //----------------------------------------------------------------------------
  Double_t x0 = 0.635;
  Double_t y0 = 0.770;

  DrawTLegend(x0, y0 + 2.*(_yoffset+0.001), data,  " Data",               "ep");
  DrawTLegend(x0, y0 + 1.*(_yoffset+0.001), WZ,    " WZ",                 "f");
  DrawTLegend(x0, y0,                       fakes, " Non-prompt leptons", "f");
  DrawTLegend(x0, y0 - 1.*(_yoffset+0.001), ZZ,    " MC background",      "f");
  DrawTLegend(x0, y0 - 2.*(_yoffset+0.001), allmc, " stat. #oplus syst.", "f");


  // Finish it
  //----------------------------------------------------------------------------
  data->SetTitle("");

  DrawTLatex(_cmsTextFont,   0.215, 0.880, 0.055, 13, "CMS");
  //  DrawTLatex(_extraTextFont, 0.215, 0.826, 0.030, 13, "Preliminary");
  DrawTLatex(_lumiTextFont,  0.940, 0.940, 0.040, 31, _lumiText);

  hs   ->Draw("hist,same");
  allmc->Draw("e2,same");
  data ->Draw("ep,same");

  canvas->GetFrame()->DrawClone();
  canvas->RedrawAxis();
  canvas->Update();
  
  canvas->SaveAs("pdf/" + name + energy + ".pdf");
  canvas->SaveAs("png/" + name + energy + ".png");
}
Beispiel #22
0
TCanvas* example_plot( int iPeriod, int iPos )
{ 
  //  if( iPos==0 ) relPosX = 0.12;

  int W = 800;
  int H = 600;

  // 
  // Simple example of macro: plot with CMS name and lumi text
  //  (this script does not pretend to work in all configurations)
  // iPeriod = 1*(0/1 7 TeV) + 2*(0/1 8 TeV)  + 4*(0/1 13 TeV) 
  // For instance: 
  //               iPeriod = 3 means: 7 TeV + 8 TeV
  //               iPeriod = 7 means: 7 TeV + 8 TeV + 13 TeV 
  // Initiated by: Gautier Hamel de Monchenault (Saclay)
  // Updated by:   Dinko Ferencek (Rutgers)
  //
  int H_ref = 600; 
  int W_ref = 800; 

  // references for T, B, L, R
  float T = 0.08*H_ref;
  float B = 0.12*H_ref; 
  float L = 0.12*W_ref;
  float R = 0.04*W_ref;

  TString canvName = "FigExample_";
  canvName += W;
  canvName += "-";
  canvName += H;
  canvName += "_";  
  canvName += iPeriod;
  if( writeExtraText ) canvName += "-prelim";
  if( iPos%10==0 ) canvName += "-out";
  else if( iPos%10==1 ) canvName += "-left";
  else if( iPos%10==2 )  canvName += "-center";
  else if( iPos%10==3 )  canvName += "-right";

  TCanvas* canv = new TCanvas(canvName,canvName,50,50,W,H);
  canv->SetFillColor(0);
  canv->SetBorderMode(0);
  canv->SetFrameFillStyle(0);
  canv->SetFrameBorderMode(0);
  canv->SetLeftMargin( L/W );
  canv->SetRightMargin( R/W );
  canv->SetTopMargin( T/H );
  canv->SetBottomMargin( B/H );
  canv->SetTickx(0);
  canv->SetTicky(0);

  TH1* h = new TH1F("h","h",40,70,110);
  h->GetXaxis()->SetNdivisions(6,5,0);
  h->GetXaxis()->SetTitle("m_{e^{+}e^{-}} (GeV)");  
  h->GetYaxis()->SetNdivisions(6,5,0);
  h->GetYaxis()->SetTitleOffset(1);
  h->GetYaxis()->SetTitle("Events / 0.5 GeV");  

  h->SetMaximum( 260 );
  if( iPos==1 ) h->SetMaximum( 300 );
  h->Draw();

  int histLineColor = kOrange+7;
  int histFillColor = kOrange-2;
  float markerSize  = 1.0;

  {
    TLatex latex;
				
    int n_ = 2;

    float x1_l = 0.92;
    float y1_l = 0.60;

    float dx_l = 0.30;
    float dy_l = 0.18;
    float x0_l = x1_l-dx_l;
    float y0_l = y1_l-dy_l;

    TPad* legend = new TPad("legend_0","legend_0",x0_l,y0_l,x1_l, y1_l );
    //    legend->SetFillColor( kGray );
    legend->Draw();
    legend->cd();
		
    float ar_l = dy_l/dx_l;
		
    float x_l[1];
    float ex_l[1];
    float y_l[1];
    float ey_l[1];
		
    //    float gap_ = 0.09/ar_l;
    float gap_ = 1./(n_+1);
		
    float bwx_ = 0.12;
    float bwy_ = gap_/1.5;
		
    x_l[0] = 1.2*bwx_;
    //    y_l[0] = 1-(1-0.10)/ar_l;
    y_l[0] = 1-gap_;
    ex_l[0] = 0;
    ey_l[0] = 0.04/ar_l;
		
    TGraph* gr_l = new TGraphErrors(1, x_l, y_l, ex_l, ey_l );
		
    gStyle->SetEndErrorSize(0);
    gr_l->SetMarkerSize(0.9);
    gr_l->Draw("0P");
		
    latex.SetTextFont(42);
    latex.SetTextAngle(0);
    latex.SetTextColor(kBlack);    
    latex.SetTextSize(0.25);    
    latex.SetTextAlign(12); 
		
    TLine line_;
    TBox  box_;
    float xx_ = x_l[0];
    float yy_ = y_l[0];
    latex.DrawLatex(xx_+1.*bwx_,yy_,"Data");
		
    yy_ -= gap_;
    box_.SetLineStyle( kSolid );
    box_.SetLineWidth( 1 );
    //		box_.SetLineColor( kBlack );
    box_.SetLineColor( histLineColor );
    box_.SetFillColor( histFillColor );
    box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 );
    box_.SetFillStyle(0);
    box_.DrawBox( xx_-bwx_/2, yy_-bwy_/2, xx_+bwx_/2, yy_+bwy_/2 );
    latex.DrawLatex(xx_+1.*bwx_,yy_,"Z #rightarrow e^{+}e^{-} (MC)");

    canv->cd();
  }

  {
    // Observed data
    TFile file_("histo.root","READ");

    TH1F *data = static_cast<TH1F*>(file_.Get("data")->Clone());
    data->SetDirectory(0);
    data->SetMarkerStyle(20);
    data->SetMarkerSize(markerSize);

    TH1F *MC   = static_cast<TH1F*>(file_.Get("MC")->Clone());
    MC->SetDirectory(0);
    MC->SetLineColor(histLineColor);
    MC->SetFillColor(histFillColor);

    MC->Draw("histsame");
    data->Draw("esamex0");

    file_.Close();
  }

  // writing the lumi information and the CMS "logo"
  CMS_lumi( canv, iPeriod, iPos );

  canv->Update();
  canv->RedrawAxis();
  canv->GetFrame()->Draw();

  canv->Print(canvName+".pdf",".pdf");
  canv->Print(canvName+".png",".png");

  return canv;
}
Beispiel #23
0
//------------------------------------------------------------------------------
//
// drawXS
//
//------------------------------------------------------------------------------
void drawXS(UInt_t theCharge = WInclusive)
{
  gStyle->SetEndErrorSize(5);


  // 7 TeV inclusive
  //----------------------------------------------------------------------------
  xs_value[WInclusive][EEE] = 23.00;
  xs_value[WInclusive][EEM] = 19.67;
  xs_value[WInclusive][MME] = 19.81;
  xs_value[WInclusive][MMM] = 21.02;
  xs_value[WInclusive][all] = 20.76;
  
  xs_stat[WInclusive][EEE] = 3.10;
  xs_stat[WInclusive][EEM] = 2.73;
  xs_stat[WInclusive][MME] = 2.60;
  xs_stat[WInclusive][MMM] = 2.30;
  xs_stat[WInclusive][all] = 1.32;
  
  xs_syst[WInclusive][EEE] = 1.39;
  xs_syst[WInclusive][EEM] = 1.50;
  xs_syst[WInclusive][MME] = 1.55;
  xs_syst[WInclusive][MMM] = 1.47;
  xs_syst[WInclusive][all] = 1.13;
  
  xs_lumi[WInclusive][EEE] = 0.51;
  xs_lumi[WInclusive][EEM] = 0.43;
  xs_lumi[WInclusive][MME] = 0.44;
  xs_lumi[WInclusive][MMM] = 0.46;
  xs_lumi[WInclusive][all] = 0.46;
  
  
  // 7 TeV W+
  //----------------------------------------------------------------------------
  xs_value[WPlus][EEE] = 13.39;
  xs_value[WPlus][EEM] = 13.18;
  xs_value[WPlus][MME] = 14.14;
  xs_value[WPlus][MMM] = 11.43;
  xs_value[WPlus][all] = 12.73;
  
  xs_stat[WPlus][EEE] = 2.39;
  xs_stat[WPlus][EEM] = 2.24;
  xs_stat[WPlus][MME] = 2.19;
  xs_stat[WPlus][MMM] = 1.71;
  xs_stat[WPlus][all] = 1.04;
  
  xs_syst[WPlus][EEE] = 0.75;
  xs_syst[WPlus][EEM] = 0.64;
  xs_syst[WPlus][MME] = 0.74;
  xs_syst[WPlus][MMM] = 0.53;
  xs_syst[WPlus][all] = 0.59;
  
  xs_lumi[WPlus][EEE] = 0.29;
  xs_lumi[WPlus][EEM] = 0.29;
  xs_lumi[WPlus][MME] = 0.31;
  xs_lumi[WPlus][MMM] = 0.25;
  xs_lumi[WPlus][all] = 0.28;
  
  
  // 7 TeV W-
  //----------------------------------------------------------------------------
  xs_value[WMinus][EEE] = 9.49;
  xs_value[WMinus][EEM] = 6.51;
  xs_value[WMinus][MME] = 5.73;
  xs_value[WMinus][MMM] = 9.48;
  xs_value[WMinus][all] = 7.46;
  
  xs_stat[WMinus][EEE] = 1.95;
  xs_stat[WMinus][EEM] = 1.58;
  xs_stat[WMinus][MME] = 1.40;
  xs_stat[WMinus][MMM] = 1.52;
  xs_stat[WMinus][all] = 0.79;
  
  xs_syst[WMinus][EEE] = 0.60;
  xs_syst[WMinus][EEM] = 0.37;
  xs_syst[WMinus][MME] = 0.37;
  xs_syst[WMinus][MMM] = 0.50;
  xs_syst[WMinus][all] = 0.40;
  
  xs_lumi[WMinus][EEE] = 0.21;
  xs_lumi[WMinus][EEM] = 0.14;
  xs_lumi[WMinus][MME] = 0.13;
  xs_lumi[WMinus][MMM] = 0.21;
  xs_lumi[WMinus][all] = 0.16;


  // Do the work
  //----------------------------------------------------------------------------
  TGraphErrors* gStat = new TGraphErrors(nChannel);
  TGraphErrors* gSyst = new TGraphErrors(nChannel);
  TGraphErrors* gLumi = new TGraphErrors(nChannel);

  for (UInt_t i=0; i<nChannel; i++)
    {
      Double_t errorSquared = (xs_stat[theCharge][i] * xs_stat[theCharge][i]);

      gStat->SetPointError(i, sqrt(errorSquared) / xs_nlo[theCharge], 0.0);
      
      errorSquared += (xs_syst[theCharge][i] * xs_syst[theCharge][i]);

      gSyst->SetPointError(i, sqrt(errorSquared) / xs_nlo[theCharge], 0.0);

      errorSquared += (xs_lumi[theCharge][i] * xs_lumi[theCharge][i]);

      gLumi->SetPointError(i, sqrt(errorSquared) / xs_nlo[theCharge], 0.0);

      gStat->SetPoint(i, xs_value[theCharge][i] / xs_nlo[theCharge], nChannel-i-1);
      gSyst->SetPoint(i, xs_value[theCharge][i] / xs_nlo[theCharge], nChannel-i-1);
      gLumi->SetPoint(i, xs_value[theCharge][i] / xs_nlo[theCharge], nChannel-i-1);
    }


  // Cosmetics
  //----------------------------------------------------------------------------
  gStat->SetLineWidth  (2);
  gStat->SetMarkerSize (1.3);
  gStat->SetMarkerStyle(kFullCircle);

  gSyst->SetLineColor  (kRed);
  gSyst->SetLineWidth  (2);
  gSyst->SetMarkerSize (1.3);
  gSyst->SetMarkerStyle(kFullCircle);

  gLumi->SetLineColor  (kBlue);
  gLumi->SetLineWidth  (2);
  gLumi->SetMarkerSize (1.3);
  gLumi->SetMarkerStyle(kFullCircle);


  // Draw
  //----------------------------------------------------------------------------
  TString suffix = "7TeV_" + sCharge[theCharge];

  TCanvas* canvas = new TCanvas("ratioNLO_" + suffix, "ratioNLO_" + suffix);

  canvas->SetLeftMargin(canvas->GetRightMargin());

  Double_t xmin    =  0.0;
  Double_t xmax    =  2.0;
  Double_t ylegend =  1.2;
  Double_t ymin    = -0.6;
  Double_t ymax    = nChannel + ymin + ylegend;
  
  TH2F* h2 = new TH2F("h2_" + suffix, "", 100, xmin, xmax, 100, ymin, ymax);

  h2->Draw();
  
  
  // NLO WZ cross-section
  //----------------------------------------------------------------------------
  TBox* nlo = new TBox(1. - xs_nlo_left [theCharge] / xs_nlo[theCharge], ymin,
		       1. + xs_nlo_right[theCharge] / xs_nlo[theCharge], ymax - ylegend);

  nlo->SetLineColor(0);
  nlo->SetFillColor(kGray);
  nlo->SetFillStyle(1001);

  nlo->Draw("e2,same");

  TLine* line = new TLine(1., ymin, 1., ymax - ylegend);

  line->SetLineColor(kGray+1);
  line->SetLineWidth(2);

  line->Draw("same");


  // Cross sections
  //----------------------------------------------------------------------------
  gLumi->Draw("p,same");
  gSyst->Draw("p,same");
  gStat->Draw("p,same");


  // Labels
  //----------------------------------------------------------------------------
  for (UInt_t i=0; i<nChannel; i++) {

    Double_t x = gStat->GetX()[i];
    Double_t y = gStat->GetY()[i];

    Double_t gStatError = gStat->GetErrorX(i);
    Double_t gSystError = gSyst->GetErrorX(i);
    Double_t gLumiError = gLumi->GetErrorX(i);

    DrawTLatex(42, xmin+0.06, y+0.15, 0.035, 12,
	       Form("%s %.2f #pm %.2f",
		    lChannel[i].Data(), x, gLumiError), 0);

    gLumiError = sqrt(gLumiError*gLumiError - gSystError*gSystError);
    gSystError = sqrt(gSystError*gSystError - gStatError*gStatError);

    DrawTLatex(42, xmin+0.06, y-0.15, 0.025, 12,
	       Form("%.2f #pm %.2f #pm %.2f #pm %.2f",
		    x, gStatError, gSystError, gLumiError), 0);
  }

  DrawTLatex(42, 0.050, 0.975, _bigLabelSize, 13, "CMS Preliminary");

  DrawTLatex(42, 0.940, 0.983, _bigLabelSize, 33, 
	     Form("#sqrt{s} = 7 TeV, L = %.1f fb^{-1}", luminosity/1e3));

  TString swz = "";

  if      (theCharge == WPlus)  swz = "W^{+}Z";
  else if (theCharge == WMinus) swz = "W^{-}Z";
  else                          swz = "W^{#pm}Z";
  
  h2->GetXaxis()->CenterTitle();
  h2->GetXaxis()->SetTitleOffset(1.4);
  h2->GetXaxis()->SetTitle(Form("#sigma_{%s}^{exp} / #sigma_{%s}^{theory}",
				   swz.Data(),
				   swz.Data()));

  h2->GetYaxis()->SetTitle("");


  // Remove y-axis labels
  //----------------------------------------------------------------------------
  TAxis* yaxis = h2->GetYaxis();
  
  for (Int_t j=1; j<yaxis->GetNbins(); j++) yaxis->SetBinLabel(j, "");


  // Additional legend
  //----------------------------------------------------------------------------
  DrawLegend(0.645, 0.840, gStat, " stat.",  "lp");
  DrawLegend(0.645, 0.795, nlo,   " theory", "f");
  DrawLegend(0.800, 0.840, gSyst, " syst.",  "l");
  DrawLegend(0.800, 0.795, gLumi, " lumi.",  "l");


  // Save
  //----------------------------------------------------------------------------
  canvas->Update();
  canvas->GetFrame()->DrawClone();
  canvas->RedrawAxis();

  canvas->SaveAs(Form("pdf/ratioNLO_%s.pdf", suffix.Data()));
  canvas->SaveAs(Form("png/ratioNLO_%s.png", suffix.Data()));
}
//===============================
void DrawFit(Double_t nSigma, Int_t iRapBin, Int_t iPTBin){

  gStyle->SetFillColor(0);

  Char_t name[100];
  gStyle->SetFrameBorderMode(0);

  //prepare the drawing of the individual components:
  fBG->SetFillColor(colour[BG]);
  fBG->SetLineColor(colour[BG]);
  fBG->SetFillStyle(1001);
  fBG->SetNpx(1000);
  TH1 *hBG = fBG->GetHistogram();

  fUps1S->SetNpx(1000);
  fUps1S->SetFillColor(colour[UPS1S]);
  fUps1S->SetLineColor(colour[UPS1S]);
  fUps1S->SetFillStyle(1001);

  fUps2S->SetNpx(1000);
  fUps2S->SetFillColor(colour[UPS2S]);
  fUps2S->SetLineColor(colour[UPS2S]);
  fUps2S->SetFillStyle(1001);

  fUps3S->SetNpx(1000);
  fUps3S->SetFillColor(colour[UPS3S]);
  fUps3S->SetLineColor(colour[UPS3S]);
  fUps3S->SetFillStyle(1001);

  TH1 *hUps1S = fUps1S->GetHistogram();
  TH1 *hUps2S = fUps2S->GetHistogram();
  TH1 *hUps3S = fUps3S->GetHistogram();
  
  THStack *hStack = new THStack("hMass_Stack", "");
  hStack->Add(hBG);
  hStack->Add(hUps3S);
  hStack->Add(hUps2S);
  hStack->Add(hUps1S);
  if(!PlotSimplistic) hStack->Draw("same");

  hMass->Draw("same");
  if(!PlotSimplistic) fRECO->Draw("same");

  TLine *line[3];
  Double_t max[3] = {1., 0.5, 0.3};
  for(int iL = 0; iL < 3; iL++){
    line[iL]= new TLine(massMin[iL], 0.1, massMin[iL], max[iL]*hUps1S->GetMaximum()); 
    line[iL]->SetLineStyle(2); line[iL]->SetLineColor(colour[iL]);
    line[iL]->SetLineWidth(2);
    if(!PlotSimplistic) line[iL]->Draw();
    if(!PlotSimplistic) line[iL]->DrawLine(massMax[iL], 0.1, massMax[iL], max[iL]*hUps1S->GetMaximum());
  }


/*  double MassScan[13]={8.6,8.95,9.3,9.45,9.6,9.85,10.0125,10.175,10.3425,10.51,10.8,11.1,11.4};
  TLine *line[13];
  for(int iL = 0; iL < 13; iL++){
    line[iL]= new TLine(MassScan[iL], 0.1, MassScan[iL], 1.1*hUps1S->GetMaximum());
    line[iL]->SetLineStyle(2); line[iL]->SetLineColor(kWhite);
    line[iL]->SetLineWidth(2);
    line[iL]->Draw();
  }

  TLatex *texMassScan[13];
  char MassScanName[200];
  for(int iL = 0; iL < 13; iL++){
	  sprintf(MassScanName,"%d",iL+1);
	  texMassScan[iL] = new TLatex((MassScan[iL]+MassScan[iL+1])/2., 0.015*hStack->GetMaximum(), MassScanName);
	  texMassScan[iL]->SetTextSize(0.03);
	  texMassScan[iL]->SetTextColor(kWhite);
	  texMassScan[iL]->Draw();
  }
*/
  if(iRapBin == 0) sprintf(name, "|y| < %1.1f", onia::rapYPS);
  else if(iRapBin == 1) sprintf(name, "|y| < %1.1f", onia::rapForPTRange[iRapBin]);
  else if(iRapBin > 1)  sprintf(name, "%1.1f < |y| < %1.1f", onia::rapForPTRange[iRapBin-1], onia::rapForPTRange[iRapBin]);
  double xText=10.25;
  TLatex *tex = new TLatex(xText, hStack->GetMaximum(), name);
  tex->SetTextSize(0.04);
  if(!PlotSimplistic) tex->Draw();
  if(iPTBin == 0) sprintf(name, "all p_{T}");
  //  else if(iPTBin == 1) sprintf(name, "p_{T} < %1.1f GeV", onia::pTRange[iRapBin][iPTBin]);
  else sprintf(name, "%1.1f < p_{T} < %1.1f", onia::pTRange[iRapBin][iPTBin-1], onia::pTRange[iRapBin][iPTBin]);
  if(!PlotSimplistic)  tex->DrawLatex(xText, 0.94*hStack->GetMaximum(), name);

  sprintf(name, "frac(BG) in #pm %1.1f#sigma:", nSigma);
  if(!PlotSimplistic)  tex->DrawLatex(xText, 0.86*hStack->GetMaximum(), name);
  sprintf(name, "%1.2f, %1.2f, %1.2f", fracBG[0], fracBG[1], fracBG[2]);
  if(!PlotSimplistic) tex->DrawLatex(xText, 0.80*hStack->GetMaximum(), name);

  sprintf(name, "Figures/massFit_rap%d_pT%d.pdf", iRapBin, iPTBin);
//  gPad->SetLogy(kTRUE);
  gPad->Print(name);



  if(iPTBin>-1&&iRapBin>-10){


/// produce pedagogical plot

  	  cout<<"Plot pedagogical"<<endl;

      double mean1S_draw = fUps1S->GetParameter(1);
      double sigma1S_draw = fUps1S->GetParameter(2);

      double nSigmaMin=0;
      double nSigmaMax=2.5;
      int nIntegrals=100;

      double nSigmaCenter[nIntegrals];
      double lSig[nIntegrals];
      double lBkg[nIntegrals];
      double lSig_[nIntegrals];
      double lBkg_[nIntegrals];
      double lSigOVERBkg[nIntegrals];

	  double maxSig=2.5;


	  int whichBinIsAtOne=1/(nSigmaMax-nSigmaMin)*nIntegrals;
	  cout<<"whichBinIsAtOne "<<whichBinIsAtOne<<endl;

      for(int nIter=0;nIter<nIntegrals;nIter++){
          nSigmaCenter[nIter]= (nSigmaMax-nSigmaMin)/double(nIntegrals)*double(nIter+1);
          lSig_[nIter]= fUps1S->Integral(mean1S_draw-nSigmaCenter[nIter]*sigma1S_draw, mean1S_draw+nSigmaCenter[nIter]*sigma1S_draw);
          lBkg_[nIter]= fBG->Integral(mean1S_draw-nSigmaCenter[nIter]*sigma1S_draw, mean1S_draw+nSigmaCenter[nIter]*sigma1S_draw);

      }

      for(int nIter=0;nIter<nIntegrals;nIter++){
          nSigmaCenter[nIter]= (nSigmaMax-nSigmaMin)/double(nIntegrals)*double(nIter+1);
          lSig[nIter]= fUps1S->Integral(mean1S_draw-nSigmaCenter[nIter]*sigma1S_draw, mean1S_draw+nSigmaCenter[nIter]*sigma1S_draw)/lSig_[whichBinIsAtOne-1];
          lBkg[nIter]= fBG->Integral(mean1S_draw-nSigmaCenter[nIter]*sigma1S_draw, mean1S_draw+nSigmaCenter[nIter]*sigma1S_draw)/lBkg_[whichBinIsAtOne-1];
      }

      for(int nIter=0;nIter<nIntegrals;nIter++){
          lSigOVERBkg[nIter]= lSig[nIter]/lBkg[nIter];
    	  cout<<"lSigOVERBkg[nIter] "<<lSigOVERBkg[nIter]<<endl;

      }

	  TGraphErrors *nSigma_Sig = new TGraphErrors(nIntegrals,nSigmaCenter,lSig,0,0);
	  TGraphErrors *nSigma_Bkg = new TGraphErrors(nIntegrals,nSigmaCenter,lBkg,0,0);
	  TGraphErrors *nSigma_SigOVERBkg = new TGraphErrors(nIntegrals,nSigmaCenter,lSigOVERBkg,0,0);


		TCanvas *SystCanvas = new TCanvas("SystCanvas","SystCanvas",1000,800);
//	  	  gStyle->SetPalette(1);
//	  	  gPad->SetFillColor(kWhite);
//	      gPad->SetLeftMargin(0.15);

		SystCanvas->SetFillColor(kWhite);
		SystCanvas->SetGrid();
		SystCanvas->GetFrame()->SetFillColor(kWhite);
		SystCanvas->GetFrame()->SetBorderSize(0);
		SystCanvas->SetRightMargin(0.05) ;


		TLegend* plotLegend=new TLegend(0.1,0.7,0.45,0.9);
		plotLegend->SetFillColor(kWhite);
		plotLegend->SetTextFont(72);
		plotLegend->SetTextSize(0.03);
		plotLegend->SetBorderSize(1);
		char legendentry[200];

		double lineWidth=3;
		char drawGraphStyle[200];
		sprintf(drawGraphStyle,"LX");


		TH1F *SystHisto = new TH1F;
		SystHisto = SystCanvas->DrawFrame(nSigmaMin,0,nSigmaMax,maxSig);
		SystHisto->SetXTitle("n_{#sigma}");
		SystHisto->GetYaxis()->SetTitleOffset(1.5);

		nSigma_Sig->SetLineColor(kGreen-2);
		nSigma_Sig->SetLineWidth(lineWidth);
		nSigma_Sig->Draw(drawGraphStyle);
		sprintf(legendentry,"Signal yield");
		plotLegend->AddEntry(nSigma_Sig,legendentry,"l");

		nSigma_Bkg->SetLineColor(kBlue);
		nSigma_Bkg->SetLineWidth(lineWidth);
		nSigma_Bkg->Draw(drawGraphStyle);
		sprintf(legendentry,"Background yield");
		plotLegend->AddEntry(nSigma_Bkg,legendentry,"l");

		nSigma_SigOVERBkg->SetLineColor(kRed);
		nSigma_SigOVERBkg->SetLineWidth(lineWidth);
		nSigma_SigOVERBkg->Draw(drawGraphStyle);
		sprintf(legendentry,"S/B ratio");
		plotLegend->AddEntry(nSigma_SigOVERBkg,legendentry,"l");

		plotLegend->Draw();

  	  sprintf(name,"Figures/pedagogical_rap%d_pT%d.pdf",iRapBin,iPTBin);
  	  SystCanvas->SaveAs(name);


  }


}
Beispiel #25
0
void fitcorr(){

   setTDRStyle();

   TFile *f = new TFile("rootfiles/fitresults_2D_data.root");
   TTree *t = (TTree*)f->Get("FitResults");

   double mt=0, jsf=0, mcmass=0;
   t->SetBranchAddress("mt", &mt);
   t->SetBranchAddress("jesfactor", &jsf);
   t->SetBranchAddress("mcmass", &mcmass);

   TH2D *h2D = new TH2D("h2D",";M_{t} [GeV];JSF", 20, 170, 173, 20, 0.99, 1.04 );
   TGraph *g = new TGraph();
   for( int i=0; i < t->GetEntries(); i++ ){
      t->GetEntry(i);
      //if( mcmass != 172.5 ) continue;

      h2D->Fill(mt, jsf);
      g->SetPoint(g->GetN(), mt, jsf);

   }

   // uncertainty contour
   double mean_mt = g->GetMean(1);
   double mean_jsf = g->GetMean(2);
   double sigma_mt = g->GetRMS(1);
   double sigma_jsf = g->GetRMS(2);
   double rho = g->GetCorrelationFactor();
   std::cout << "Mean Mt = " << mean_mt << " +- " << sigma_mt << std::endl;
   std::cout << "Mean JSF = " << mean_jsf << " +- " << sigma_jsf << std::endl;
   std::cout << "Correlation = " << rho << std::endl;

   TMatrixDSym m(2);
   m(0,0) = sigma_mt*sigma_mt;
   m(1,1) = sigma_jsf*sigma_jsf;
   m(0,1) = rho*sigma_mt*sigma_jsf;
   m(1,0) = rho*sigma_mt*sigma_jsf;
   TMatrixDSymEigen eigen(m);
   TVectorD eigenval = eigen.GetEigenValues();
   std::cout << eigenval[0] << " " << eigenval[1] << endl;

   // convert to ellipse tilt and radius
   //double phi = 0.5*TMath::ATan( (3/0.03)*(2*rho*sigma_mt*sigma_jsf)/(sigma_mt*sigma_mt-sigma_jsf*sigma_jsf) );
   double phi = (180.0/TMath::Pi())*0.5*TMath::ATan( (2*rho*sigma_mt*sigma_jsf)/(sigma_mt*sigma_mt-sigma_jsf*sigma_jsf) );
   std::cout << "phi = " << phi << std::endl;

   TEllipse *el = new TEllipse(mean_mt, mean_jsf, sqrt(eigenval[0]), sqrt(eigenval[1]), 0, 360, phi);
   TEllipse *el2 = new TEllipse(mean_mt, mean_jsf, 2*sqrt(eigenval[0]), 2*sqrt(eigenval[1]), 0, 360, phi);
   
   /*
   TF2* fell = new TF2("fell","pow((x-[1])*cos([0])+(y-[2])*sin([0]),2)/[3] + pow((x-[1])*sin([0])-(y-[2])*cos([0]),2)/[4]",171,174,0.985,1.015);
   fell->SetParameter(0,phi);
   fell->SetParameter(1,mean_mt);
   fell->SetParameter(2,mean_jsf);
   fell->SetParameter(3,eigenval[0]);
   fell->SetParameter(4,eigenval[1]);

   double cont[1] = {1};
   fell->SetContour(1, cont);
   */
   
   const Int_t Number = 2;
   Double_t Red[Number]    = { 0.90, 0.10};
   Double_t Green[Number]  = { 0.90, 0.10};
   Double_t Blue[Number]   = { 0.90, 0.10};
   Double_t Stops [Number] = {0, 1};
   Double_t Length [Number] = {0, 1};
   Int_t nb=50;
   TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);

   gStyle->SetPadRightMargin(0.16);
   gStyle->SetPadTopMargin(0.08);

   TCanvas *c = new TCanvas("c","c",800,600);
   h2D->Draw("colzC");
   el->SetFillStyle(0);
   el->SetLineColor(2);
   el->SetLineWidth(3);
   el->Draw();
   el2->SetFillStyle(0);
   el2->SetLineColor(2);
   el2->SetLineWidth(3);
   el2->Draw();

   int iPeriod = 2;
   int iPos = 33;
   lumi_sqrtS = "8 TeV";
   writeExtraText = false;
   CMS_lumi( c, iPeriod, iPos );

   c->Update();
   c->RedrawAxis();
   c->GetFrame()->Draw();

   TLatex latex;
   latex.SetNDC();
   latex.SetTextSize(0.06);
   latex.SetTextFont(42);
   latex.DrawLatex(0.2, 0.84, "2D fit");

   c->Print("pdfplots/fitcorr.pdf");

   //delete c;


   return;
}