コード例 #1
0
ファイル: SOBPlot.cpp プロジェクト: joaopela/ICHiggsTauTau
void SetSignalStyle(TH1F & ele, unsigned color) {
  ele.SetFillStyle(1001);
  ele.SetLineStyle(11);
  ele.SetFillColor(0);
  ele.SetLineColor(color);
  ele.SetLineWidth(2);
  return;
}
コード例 #2
0
ファイル: plot.C プロジェクト: Hosein47/usercode
TCanvas * plot (TH1F* histoDataIn, TString legendData, TH1F* histoSimulationIn, TString legendSimulation,
                TString & canvasName, Float_t maximum = 0.15, TString xAxisTitle = "#eta",
                TString yAxisTitle = "Number of Clusters", TString error = "", bool useLegend = true,
                TString text = "", Float_t textX = 0.7, Float_t textY = 0.4, Float_t rebin = 0 ) {

  TH1F * histoData = (TH1F*)histoDataIn->Clone();
  TH1F * histoSimulation = (TH1F*)histoSimulationIn->Clone();

  // histoData->Sumw2();
  histoData->Scale(1/(histoData->Integral()));
  histoSimulation->Scale(1/(histoSimulation->Integral()));

  // Create also the legend and add the histograms
  TLegend * legend = new TLegend( 0.55, 0.65, 0.76, 0.82 );
  legend->AddEntry( histoData, xAxisTitle );
  legend->AddEntry( histoSimulation, yAxisTitle, "F" );

  cout << "histoData = " << histoData << endl;
  cout << "histoSimulation = " << histoSimulation << endl;

  TCanvas * c = new TCanvas( canvasName, canvasName, 1000, 800 );
  c->Draw();

  histoSimulation->SetMaximum(maximum);

  histoSimulation->SetFillColor(kRed);
  // histoSimulation->SetLineWidth(0);
  histoSimulation->SetLineColor(kRed);
  histoSimulation->SetXTitle(xAxisTitle);
  histoSimulation->SetYTitle(yAxisTitle);
  histoSimulation->SetTitleOffset(1.6,"Y");
  histoSimulation->SetTitle();

  histoData->SetLineStyle(1);
  histoData->SetLineWidth(2.5);

  histoSimulation->Draw();
  histoData->Draw("same");

  legend->SetFillColor(kWhite);
  if (useLegend) legend->Draw("same");

  if ( text != "" ) {
    TPaveText * pt = new TPaveText(textX, textY, textX+0.2, textY+0.17, "NDC" ); // "NDC" option sets coords relative to pad dimensions
    pt->SetFillColor(0); // text is black on white
    pt->SetTextSize(0.08); 
    pt->SetBorderSize(0);
    pt->SetTextAlign(12);
    pt->AddText(text);
    pt->Draw("same");       //to draw your text object
  }

  return c;
};
コード例 #3
0
void performClosure(RooRealVar *mass, RooAbsPdf *pdf, RooDataSet *data, string closurename, double wmin=110., double wmax=130., double slow=110., double shigh=130., double step=0.002) {
  
  // plot to perform closure test
  cout << "Performing closure test..." << endl; 
  double nbins = (wmax-wmin)/step;
  TH1F *h = new TH1F("h","h",int(floor(nbins+0.5)),wmin,wmax);
  if (data){
    pdf->fillHistogram(h,RooArgList(*mass),data->sumEntries());
    h->Scale(2*h->GetNbinsX()/double(binning_));
  }
  else {
    pdf->fillHistogram(h,RooArgList(*mass));
  }
  int binLow = h->FindBin(slow);
  int binHigh = h->FindBin(shigh)-1;
  TH1F *copy = new TH1F("copy","c",binHigh-binLow,h->GetBinLowEdge(binLow),h->GetBinLowEdge(binHigh+1));
  for (int b=0; b<copy->GetNbinsX(); b++) copy->SetBinContent(b+1,h->GetBinContent(b+1+binLow));
  double areaCov = 100*h->Integral(binLow,binHigh)/h->Integral();
 
  // style
  h->SetLineColor(kBlue);
  h->SetLineWidth(3);
  h->SetLineStyle(7);
  copy->SetLineWidth(3);
  copy->SetFillColor(kGray);
  
  TCanvas *c = new TCanvas();
  if (data){
    RooPlot *plot = mass->frame(Bins(binning_),Range("higgsRange"));
    plot->addTH1(h,"hist");
    plot->addTH1(copy,"same f");
    if (data) data->plotOn(plot);
    pdf->plotOn(plot,Normalization(h->Integral(),RooAbsReal::NumEvent),NormRange("higgsRange"),Range("higgsRange"),LineWidth(1),LineColor(kRed),LineStyle(kDashed));
    plot->Draw();
    c->Print(closurename.c_str());
  }
  else {
    RooPlot *plot = mass->frame(Bins(binning_),Range("higgsRange"));
    h->Scale(plot->getFitRangeBinW()/h->GetBinWidth(1));
    copy->Scale(plot->getFitRangeBinW()/h->GetBinWidth(1));
    pdf->plotOn(plot,LineColor(kRed),LineWidth(3));
    plot->Draw();
    h->Draw("hist same");
    copy->Draw("same f");
    c->Print(closurename.c_str());
  }
  cout << "IntH: [" << h->GetBinLowEdge(binLow) << "-" << h->GetBinLowEdge(binHigh+1) << "] Area = " << areaCov << endl;
  delete c;
  delete copy;
  delete h;
}
コード例 #4
0
///
/// Make a plot out of a 1D histogram holding a 1-CL curve.
/// This is a fall back function that does no fancy stuff.
///
/// \param s The scanner to plot.
/// \param first Set this to true for the first plotted scanner.
///
void OneMinusClPlot::scan1dPlotSimple(MethodAbsScan* s, bool first, int CLsType)
{
	if ( arg->debug ){
		cout << "OneMinusClPlot::scan1dPlotSimple() : plotting ";
		cout << s->getName() << " (" << s->getMethodName() << ")" << endl;
	}
	m_mainCanvas->cd();

	TH1F *hCL = (TH1F*)s->getHCL()->Clone(getUniqueRootName());
	if (CLsType==1) hCL = (TH1F*)s->getHCLs()->Clone(getUniqueRootName());
  else if (CLsType==2) hCL = (TH1F*)s->getHCLsFreq()->Clone(getUniqueRootName());

	// get rid of nan and inf
	for ( int i=1; i<=hCL->GetNbinsX(); i++ ){
	if ( hCL->GetBinContent(i)!=hCL->GetBinContent(i)
				|| std::isinf(hCL->GetBinContent(i)) ) hCL->SetBinContent(i, 0.0);
	}

	int color = s->getLineColor();
	if(CLsType==1) color = color + 2 ;
	hCL->SetStats(0);
	hCL->SetLineColor(color);
	hCL->SetMarkerColor(color);
	hCL->SetLineWidth(2);
	hCL->SetLineStyle(s->getLineStyle());
	hCL->SetMarkerColor(color);
	hCL->SetMarkerStyle(8);
	hCL->SetMarkerSize(0.6);
	hCL->GetYaxis()->SetNdivisions(407, true);
	hCL->GetXaxis()->SetTitle(s->getScanVar1()->GetTitle());
	hCL->GetYaxis()->SetTitle("1-CL");
	hCL->GetXaxis()->SetLabelFont(font);
	hCL->GetYaxis()->SetLabelFont(font);
	hCL->GetXaxis()->SetTitleFont(font);
	hCL->GetYaxis()->SetTitleFont(font);
	hCL->GetXaxis()->SetTitleOffset(0.9);
	hCL->GetYaxis()->SetTitleOffset(0.85);
	hCL->GetXaxis()->SetLabelSize(labelsize);
	hCL->GetYaxis()->SetLabelSize(labelsize);
	hCL->GetXaxis()->SetTitleSize(titlesize);
	hCL->GetYaxis()->SetTitleSize(titlesize);
	if ( plotLegend && !arg->isQuickhack(22) ){
		if ( arg->plotlog ) hCL->GetYaxis()->SetRangeUser(1e-3,10);
		else                hCL->GetYaxis()->SetRangeUser(0.0,1.3);
	}
	else{
		if ( arg->plotlog ) hCL->GetYaxis()->SetRangeUser(1e-3,1);
		else                hCL->GetYaxis()->SetRangeUser(0.0,1.0);
	}
	hCL->Draw(first?"":"same");
}
コード例 #5
0
ファイル: mkplots_13tev.C プロジェクト: dburns7/Research
TH1F * GetSigHist(TFile *f, const char * name, const char * tag, int color, int lstyle, TLegend * leg, const char * legtag){
   char full_name[200];

   sprintf(full_name, "%s_%s", name, tag);
   TH1F * h = (TH1F *)f->Get(full_name);

   h->SetFillStyle(0);
   h->SetFillColor(color);
   h->SetLineColor(color);   
   h->SetLineStyle(lstyle);   
   if (leg) { leg->AddEntry(h, legtag, "l"); }  

   return h;
}
コード例 #6
0
/*--------------------------------------------------------------------*/
TH1F* DrawZero(TH1F *hist,Int_t nbins,Double_t lowedge,Double_t highedge)
/*--------------------------------------------------------------------*/
{ 

  TH1F *hzero = new TH1F(Form("hzero_%s",hist->GetName()),"hzero",nbins,lowedge,highedge);
  for (Int_t i=0;i<hzero->GetNbinsX();i++){
    hzero->SetBinContent(i,0.);
    hzero->SetBinError(i,0.);
  }
  hzero->SetLineWidth(2);
  hzero->SetLineStyle(9);
  hzero->SetLineColor(kRed);
  
  return hzero;
}
コード例 #7
0
ファイル: DYNJ.C プロジェクト: anikiten/Nikitenko
void Draw()
{

   /*
   TLatex *t = new TLatex();
   t->SetTextSize(0.042);
   t->DrawLatex(1.5,0.80,"CMSSW_1_6_12, |#eta|< 1.3");
   t->DrawLatex(1.5,0.75,"no ZSP in HCAL");
   t->DrawLatex(1.5,0.70,"no SR in ECAL");
   */

  /*
   setTDRStyle(0,1);
   TCanvas* c0 = new TCanvas("X","Y",1);
   // data
   TFile* file = new TFile("DYDataA_29Feb.root");
   hnvtx0->GetXaxis()->SetTitle("N reco vertices");
   hnvtx0->GetYaxis()->SetTitle("");
   hnvtx0->SetLineStyle(1);
   hnvtx0->SetLineWidth(3);
   hnvtx0->SetMarkerStyle(24);
   hnvtx0->SetMarkerSize(1.0);
   hnvtx0->SetMaximum(200000.);
   hnvtx0->SetMinimum(0.5);
   hnvtx0->Draw("PE");
   TLegend *leg = new TLegend(0.35,0.75,0.9,0.85,NULL,"brNDC");
   leg->SetFillColor(10);
   leg->AddEntry(hnvtx0,"data: p_{T}^{#mu}> 20 GeV, |#eta|<2.4","P");
   // MC
   TFile* file = new TFile("DYMC18novPUW.root");
   hnvtx0->SetLineStyle(1);
   hnvtx0->SetLineWidth(3);
   hnvtx0->Draw("same");
   leg->AddEntry(hnvtx0,"MC, DY#rightarrowll","L");
   leg->Draw();
   c0->SaveAs("nvtx0.png");
  */

  // normalization
  //
  Double_t xsection=3048.;
  Double_t luminosity=5061;
  Double_t nmcevents=15000000.;
  Double_t datamcratio=2925.44;
  Double_t normalization=(xsection*luminosity)/(nmcevents*datamcratio);

  setTDRStyle(0,1);
  // data
  TFile* file = new TFile("DataAB.root");
  cout <<" ============= Data =============================" << endl;
  cout <<" ===> Zmumu = " << hZY->Integral() << endl;
  cout <<" ===> 2jets = " << hZY2J->Integral() << endl;
  cout <<" ===> y*    = " << hZY2JY->Integral() << endl;
  cout <<" ===> Mjj   = " << hZY2JYMjj->Integral() << endl;
  TCanvas* c1 = new TCanvas("X","Y",1);
  TH1F *hNjetsData = (TH1F*)hNjets->Clone();
  // MC events
  TFile* file = new TFile("DYMCAB.root");
  cout <<" ============= MC =============================" << endl;
  cout <<" ===> Zmumu = " << hZY->Integral()*normalization << endl;
  cout <<" ===> 2jets = " << hZY2J->Integral()*normalization << endl;
  cout <<" ===> y*    = " << hZY2JY->Integral()*normalization << endl;
  cout <<" ===> Mjj   = " << hZY2JYMjj->Integral()*normalization << endl;
  TH1F *hNjetsMC = (TH1F*)hNjets->Clone();
  TH1F *hNjetsRatio = (TH1F*)hNjets->Clone();
  TH1F *hNjetsRatio_JESUP = (TH1F*)hNjets->Clone();
  TH1F *hNjetsRatio_JESDN = (TH1F*)hNjets->Clone();
  //
  // MC events JESUP
  TFile* file = new TFile("DYMCAB_JESUP.root");
  TH1F *hNjetsMC_JESUP = (TH1F*)hNjets->Clone();
  // MC events JESDN
  TFile* file = new TFile("DYMCAB_JESDN.root");
  TH1F *hNjetsMC_JESDN = (TH1F*)hNjets->Clone();
  //
  hNjetsData->GetXaxis()->SetTitle("N jets");
  hNjetsData->GetYaxis()->SetTitle("N events");
  hNjetsData->SetMaximum(5000000.);
  hNjetsData->SetMinimum(100.);
  hNjetsData->SetLineStyle(1.);
  hNjetsData->SetLineWidth(2);
  hNjetsData->SetMarkerStyle(24);
  hNjetsData->SetMarkerSize(0.7);
  hNjetsData->Draw("PE");
  //  Double_t mcevents= hNjetsMC->Integral();
  //  Double_t dataevents=hNjetsData->Integral();
  //  Double_t expected=mcevents*normalization;
  hNjetsMC->Scale(normalization);
  hNjetsMC_JESUP->Scale(normalization);
  hNjetsMC_JESDN->Scale(normalization);
  hNjetsMC->SetLineStyle(1);
  hNjetsMC->SetLineWidth(2);
  hNjetsMC->Draw("same");

  TLegend *leg = new TLegend(0.5,0.8,0.9,0.9,NULL,"brNDC");
  leg->SetFillColor(10);
  leg->AddEntry(hNjetsData,"Data 2011, L=5.06 fb^{-1} ","P");
  leg->AddEntry(hNjetsMC,"Z+jets MC","L");
  leg->Draw();

  TLatex *t = new TLatex();
  t->SetTextSize(0.042);
  t->DrawLatex(3.0,200000,"Z#rightarrow#mu#mu + jets");
  t->DrawLatex(3.0,80000,"p_{T}^{j}>50 GeV, |#eta|<2.5");
  c1->SaveAs("dy_njets.png");

  setTDRStyle(0,0);
  TCanvas* c2 = new TCanvas("X","Y",1);
  hNjetsData->Sumw2();
  Int_t nbins = hNjetsMC->GetNbinsX();
  for (Int_t ib = 1; ib <= nbins; ib++) {
    hNjetsMC->SetBinError(ib,0.1);
    hNjetsMC->SetBinError(ib,0.1);
  }
  hNjetsRatio->Divide(hNjetsData,hNjetsMC,1.,1.,"");
  hNjetsRatio->GetXaxis()->SetTitle("N jets");
  hNjetsRatio->GetYaxis()->SetTitle("Data / MC");
  hNjetsRatio->SetMaximum(1.3);
  hNjetsRatio->SetMinimum(0.7);
  hNjetsRatio->SetLineStyle(1.);
  hNjetsRatio->SetLineWidth(2);
  hNjetsRatio->SetMarkerStyle(24);
  hNjetsRatio->SetMarkerSize(1.0);
  hNjetsRatio->SetAxisRange(0,3,"X");
  hNjetsRatio->Draw("PE");
  hNjetsRatio_JESUP->Divide(hNjetsMC_JESUP,hNjetsMC,1.,1.,"");
  hNjetsRatio_JESUP->SetLineStyle(2);
  hNjetsRatio_JESUP->SetLineWidth(2);
  hNjetsRatio_JESUP->Draw("histsame");
  hNjetsRatio_JESDN->Divide(hNjetsMC_JESDN,hNjetsMC,1.,1.,"");
  hNjetsRatio_JESDN->SetLineStyle(3);
  hNjetsRatio_JESDN->SetLineWidth(2);
  hNjetsRatio_JESDN->Draw("histsame");
  TLatex *t = new TLatex();
  t->SetTextSize(0.042);
  t->DrawLatex(1.0,1.20,"Z#rightarrow#mu#mu + jets");
  t->DrawLatex(1.0,1.14,"p_{T}^{j}>50 GeV, |#eta|<2.5");

  TLegend *leg = new TLegend(0.2,0.2,0.6,0.35,NULL,"brNDC");
  leg->SetFillColor(10);
  leg->AddEntry(hNjetsRatio,"Data 2011, L=5.06 fb^{-1} ","P");
  leg->AddEntry(hNjetsRatio_JESUP,"Z+jets MC, JES +1#sigma","L");
  leg->AddEntry(hNjetsRatio_JESDN,"Z+jets MC, JES -1#sigma","L");
  leg->Draw();

  c2->SaveAs("dy_ratio_njets_jes.png");
}
コード例 #8
0
ファイル: makeGMSBPlot.C プロジェクト: hooberman/UserCode
void makeGMSBPlot( bool printplots = false ){

  //getUncertainties();
  /*
  // VZ+MET exclusion
  TFile *f       = TFile::Open("/tas/benhoob/home/LandS/VZMet_LandS/fullShapeAnalysis/cards/V00-02-08/observed_limit.root");
  TGraph* gul    = (TGraph*) f->Get("grobs");
  TGraph* gulexp = (TGraph*) f->Get("grexp");

  // Rutgers exclusion
  //TFile *frutgers = TFile::Open("20120411_UCSD_GMSB_datacard/observed_limit.root ");
  //TFile *frutgers = TFile::Open("20120419_UCSD_GMSB_datacard/observed_limit.root ");
  TFile *frutgers = TFile::Open("/tas/benhoob/home/LandS/VZMet_LandS/fullShapeAnalysis/cards/20120420_UCSD_GMSB_datacard/observed_limit.root ");
  TGraph* gul2    = (TGraph*) frutgers->Get("grobs");
  TGraph* gul2exp = (TGraph*) frutgers->Get("grexp");
*/

  // VZ+MET exclusion
  TFile *fc       = TFile::Open("/tas/benhoob/home/LandS_t3-06-00/VZMet_LandS_2012/fullShapeAnalysis/cards/V00-00-03/observed_limit.root");

  TGraph* gulc      = (TGraph*) fc->Get("grobs");
  TGraph* gulcexp   = (TGraph*) fc->Get("grexp");
  TGraph* gulcexpp1 = (TGraph*) fc->Get("grexpp1");
  TGraph* gulcexpm1 = (TGraph*) fc->Get("grexpm1");
  TGraph* gulcband  = uncertaintyBand( gulcexpp1 , gulcexpm1 );

  /*
  Double_t xp;
  Double_t yp;

  Double_t xp2;
  Double_t yp2;

  Double_t xpc;
  Double_t ypc;

  cout << setw(15) << "mass"        << setw(4) << "&"
       << setw(15) << "\\wzzmet"    << setw(4) << "&"
       << setw(15) << "mult-lepton" << setw(4) << "&"
       << setw(15) << "combined"    << setw(4) << "&"
       << setw(15) << "asdf"        << setw(4) << "\\\\" << endl;

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

    gulexp->GetPoint ((Int_t) i,xp,yp);
    gul2exp->GetPoint((Int_t) i,xp2,yp2);
    gulcexp->GetPoint((Int_t) i,xpc,ypc);
    float exp = 1.0 / sqrt( 1.0/(yp*yp) + 1.0/(yp2*yp2) ); 

    // gul->GetPoint ((Int_t) i,xp,yp);
    // gul2->GetPoint((Int_t) i,xp2,yp2);
    // gulc->GetPoint((Int_t) i,xpc,ypc);
    // float exp = 1.0 / sqrt( 1.0/(yp*yp) + 1.0/(yp2*yp2) ); 


    // gul->GetPoint ((Int_t) i,xp,yp);
    // gul2->GetPoint((Int_t) i,xp2,yp2);
    // gulc->GetPoint((Int_t) i,xpc,ypc);

    cout << setw(15) << xp               << setw(4) << "&"
	 << setw(15) << Form("%.0f",yp)  << setw(4) << "&"
	 << setw(15) << Form("%.0f",yp2) << setw(4) << "&"
	 << setw(15) << Form("%.0f",ypc) << setw(4) << "&"
	 << setw(15) << Form("%.0f",exp) << setw(4) << "\\\\" << endl;
    

    // cout << "mass    " << Form("%.0f",xp) << endl;
    // cout << "VZ+MET  " << Form("%.0f",yp) << endl;
    // cout << "4l      " << Form("%.0f",yp2) << endl;
    // cout << "combo   " << Form("%.0f",ypc) << endl;
    // cout << "exp     " << Form("%.0f",exp) << endl << endl;    
  }
  */

  const unsigned int n = 15;
  float x[n];
  float y[n];
  float yup[n];
  float ydn[n];

  float xerr[n];
  float yerr[n];

  float xband[30];
  float yband[30];

  float systerr = 0.06;

  x[0]  = 130;   y[0]  = 3.7640;   yerr[0]  = systerr * y[0];
  x[1]  = 150;   y[1]  = 2.1410;   yerr[1]  = systerr * y[1];
  x[2]  = 170;   y[2]  = 1.3040;   yerr[2]  = systerr * y[2];
  x[3]  = 190;   y[3]  = 0.8370;   yerr[3]  = systerr * y[3];
  x[4]  = 210;   y[4]  = 0.5580;   yerr[4]  = systerr * y[4];
  x[5]  = 230;   y[5]  = 0.3820;   yerr[5]  = systerr * y[5];
  x[6]  = 250;   y[6]  = 0.2710;   yerr[6]  = systerr * y[6];
  x[7]  = 270;   y[7]  = 0.1950;   yerr[7]  = systerr * y[7];
  x[8]  = 290;   y[8]  = 0.1420;   yerr[8]  = systerr * y[8];
  x[9]  = 310;   y[9]  = 0.1060;   yerr[9]  = systerr * y[9];
  x[10] = 330;   y[10] = 0.0798;   yerr[10] = systerr * y[10];
  x[11] = 350;   y[11] = 0.0608;   yerr[11] = systerr * y[11];   
  x[12] = 370;   y[12] = 0.0468;   yerr[12] = systerr * y[12];   
  x[13] = 390;   y[13] = 0.0366;   yerr[13] = systerr * y[13];   
  x[14] = 410;   y[14] = 0.0287;   yerr[14] = systerr * y[14];   

  for( int i = 0 ; i < 15; ++i ){
    xerr[i] = 0.0;
    yup[i]  = y[i] + yerr[i];
    ydn[i]  = y[i] - yerr[i];
  }

  for( int i = 0 ; i < 15; ++i ){
    xband[i] = x[i];
    yband[i] = y[i] + yerr[i];
  }

  for( int i = 0 ; i < 15; ++i ){
    xband[i+15] = x[14-i];
    yband[i+15] = y[14-i] - yerr[14-i];
  }
  
  // cout << endl << endl;
  // for( int i = 0 ; i < 30 ; ++i ){
  //   cout << xband[i] << " " << yband[i] << endl;
  // }
  // cout << endl << endl;

  TGraph* g     = new TGraph(n,x,y);
  TGraph* gup   = new TGraph(n,x,yup);
  TGraph* gdn   = new TGraph(n,x,ydn);
  TGraph* gband = new TGraph(30,xband,yband);

  // UP:   248
  // DOWN: 148

  //TGraphErrors* g  = new TGraphErrors(n,x,y,xerr,yerr);

  TCanvas *c1 = new TCanvas("c1","",600,600);
  gPad->SetTopMargin(0.1);
  gPad->SetRightMargin(0.05);
  //gPad->SetGridx();
  //gPad->SetGridy();

  float ymin = 0;
  if( logplot ) ymin = 0.03;

  //TH2F* hdummy = new TH2F("hdummy","",100,130,300,100,ymin,3000);
  TH2F* hdummy = new TH2F("hdummy","",100,130,400,100,ymin,5);
  hdummy->Draw();

  c1->cd();
  if( logplot ) gPad->SetLogy();

  g->SetLineColor(2);
  g->SetLineWidth(3);
  g->SetFillColor(5);
  gup->SetLineColor(2);
  gdn->SetLineColor(2);
  gup->SetLineStyle(2);
  gdn->SetLineStyle(2);
  gband->SetFillColor(5);

  /*
  //2l2j observed
  gul->SetLineColor(6);
  gul->SetLineWidth(3);
  gul->SetLineStyle(4);

  //2l2j expected
  gulexp->SetLineColor(2);
  gulexp->SetLineWidth(3);
  gulexp->SetLineStyle(2);

  //4l observed
  gul2->SetLineWidth(3);
  gul2->SetLineStyle(4);
  gul2->SetLineColor(kGreen+2);

  //4l expected
  gul2exp->SetLineWidth(3);
  gul2exp->SetLineStyle(2);
  */

  //combined observed
  gulc->SetLineWidth(5);
  gulc->SetLineColor(1);

  //combined expected
  gulcexp->SetLineWidth(5);
  gulcexp->SetLineColor(4);
  gulcexp->SetLineStyle(2);

  //clone TGraphs, with more points
  TGraph* gulc_line       = getGraph(gulc,10);
  TGraph* gulcexp_line    = getGraph(gulcexp,20);
  //TGraph* gul_line        = getGraph(gul,20);
  //TGraph* gul2_line       = getGraph(gul2,20);
  TGraph* gulcexpp1_line  = getGraph(gulcexpp1,20);
  TGraph* gulcexpm1_line  = getGraph(gulcexpm1,20);
  //TGraph* g_line          = getGraph(g,20);
  TGraph* gulcband_line   = uncertaintyBand( gulcexpp1_line , gulcexpm1_line );

  // gulexp->SetLineWidth(2);
  // gulexp->SetLineStyle(2);
  // gulexp->SetLineColor(2);  
  // gul2exp->SetLineWidth(2);
  // gul2exp->SetLineStyle(2);


  hdummy->GetXaxis()->SetTitle("#mu [GeV]");
  hdummy->GetYaxis()->SetTitle("#sigma [pb]");
  hdummy->GetYaxis()->SetLabelSize(0.04);
  hdummy->GetXaxis()->SetLabelSize(0.04);
  hdummy->GetYaxis()->SetTitleSize(0.05);
  hdummy->GetXaxis()->SetTitleSize(0.05);
  hdummy->GetXaxis()->SetTitleOffset(1.12);
  hdummy->GetYaxis()->SetTitleOffset(1.5);

  /*
  TBox* box = new TBox();
  //box->SetBorderStyle(2);
  //box->SetBorderSize(1);
  //box->SetFillColor(5);
  //box->SetFillStyle(3002);
  box->DrawBox(169,0,230,5000);
  TLine line;
  line.DrawLine(169,0,169,5000);
  line.DrawLine(230,0,230,5000);
  hdummy->Draw("axissame");
  */

  gband->Draw("samef");
  g->Draw("samel");

  // gulcband->SetFillStyle(3002);
  // gulcband->Draw("samef");

  gulcband_line->SetFillStyle(3002);
  gulcband_line->Draw("samef");

  gband->Draw("samef");
  g->Draw("samel");

  if( plotObserved ){
    if( !logInterpolate ){
      //gul->Draw("samel");
      //gul2->Draw("samel");
      gulc->Draw("samel");
      gulcexp->Draw("samel");
      //gulcexpp1->Draw("samel");
      //gulcexpm1->Draw("samel");
    }

    else{
      //gul_line->Draw("samel");
      //gul2_line->Draw("samel");
      gulc_line->Draw("samel");
      gulcexp_line->Draw("samel");
      //gulcexpp1_line->Draw("samel");
      //gulcexpm1_line->Draw("samel");
    }
  }

  // gulc_line->SetLineColor(2);
  // gulc_line->SetLineWidth(1);
  // gulc_line->SetMarkerColor(2);
  // gulc_line->Draw("samelp");

  if( plotExpected ){
    //gulexp->Draw("samel");
    //gul2exp->Draw("samel");
    gulcexp->Draw("samel");
  }




  //gband->Draw("samef");
  //g->Draw("samel");
  //gup->Draw("samel");
  //gdn->Draw("samel");

  //gulexp->Draw("samel");
  //gul2exp->Draw("samel");

  // g1->SetMinimum(0);
  // g1->SetMaximum(5000);
  // g1->Draw("samel");
  // g2->Draw("samel");

  //g1->Draw("Al");
  //g2->Draw("samel");
  
  float xmin = 165;
  float xmax = 239;

  TBox* box = new TBox();
  //box->SetBorderStyle(2);
  //box->SetBorderSize(1);
  //box->SetFillColor(5);
  //box->SetFillStyle(3002);
  //box->DrawBox(xmin,0,xmax,5000);

  TLine line;
  //line.DrawLine(xmin,0,xmin,5000);
  //line.DrawLine(xmax,0,xmax,5000);

  hdummy->Draw("axissame");
  // g->SetMinimum(0);
  // g->SetMaximum(3000);
  // g->Draw("samec");
  // gul->Draw("samel");
  // gul2->Draw("samel");

  //TLegend *leg = new TLegend(0.4,0.6,0.9,0.8);

  TH1F* hgexp = new TH1F("hgexp","",1,0,1);
  hgexp->SetLineColor(4);
  hgexp->SetLineWidth(5);
  hgexp->SetLineStyle(2);
  hgexp->SetFillColor(7);
  hgexp->SetFillStyle(3002);



  TLegend *leg = new TLegend(0.45,0.7,0.9,0.88);
  if( plotObserved ){
    leg->AddEntry(gulc    ,"Observed UL","l");
    //leg->AddEntry(gulc    ,"Combined observed UL","l");
    //leg->AddEntry(gulcexp ,"combined median expected UL","l");
    leg->AddEntry(hgexp   ,"Median expected UL (#pm1#sigma)","lf");
    //leg->AddEntry(gul     ,"2#font[12]{l}2j observed UL","l");
    //leg->AddEntry(gul2    ,"4#font[12]{l} observed UL","l");

  }
  if( plotExpected ){
    //leg->AddEntry(gulexp  ,"expected UL (VZ+E_{T}^{miss})","l");
    //leg->AddEntry(gul2exp ,"expected UL (multi-lepton)","l");
    //leg->AddEntry(gulcexp ,"expected UL (combined)","l");
    //leg->AddEntry(gulcexp ,"Expected UL","l");
  }



  TH1F* hg = new TH1F("h","",1,0,1);
  hg->SetLineColor(2);
  hg->SetLineWidth(3);
  hg->SetFillColor(5);

  //leg->AddEntry(g,  "theory","l");
  leg->AddEntry(hg,  "#sigma^{NLO} theory (#pm1#sigma)","lf");

  //leg->AddEntry(box,"excluded region","f");
  leg->SetBorderSize(0);
  leg->SetFillColor(0);
  leg->SetTextSize(0.03);
  leg->Draw();

  TLatex *t = new TLatex();
  t->SetNDC();								
  t->SetTextSize(0.04);
  //t->DrawLatex(0.18,0.92,"CMS Preliminary       #sqrt{s} = 7 TeV, #scale[0.6]{#int}Ldt = 4.98 fb^{-1}");
  //t->DrawLatex(0.18,0.93,"CMS Preliminary,  #sqrt{s}=7 TeV,  L_{int}=4.98 fb^{-1}");
  cmsPrelim(9.2,isPreliminary);
  t->SetTextSize(0.04);
  //t->DrawLatex(0.47,0.45,"");
  t->DrawLatex(0.57,0.63,"GMSB  ZZ + E_{T}^{miss}");

  t->DrawLatex(0.2,0.25,"tan #beta = 2");
  t->DrawLatex(0.2,0.2,"M_{1} = M_{2} = 1 TeV");

  if( printplots ){
    if( isPreliminary) c1->Print("GMSB_Fig12_prelim.pdf");
    else               c1->Print("GMSB_Fig12.pdf");

    c1->Print("Figure11.pdf");
    c1->Print("Figure11.png");

    // c1->Print("GMSB.png");
    // c1->Print("GMSB.eps");
    // gROOT->ProcessLine(".! ps2pdf GMSB.eps GMSB_ppt.pdf");
  }	   
}
コード例 #9
0
void plotSystFracs(TList* HistList, TH1F* compT, std::string name){

  gROOT->SetBatch();
  system("mkdir -p plots/ada/systs");
  system("mkdir -p plots/grad/systs");

  std::string bdt;
  TString str = compT->GetName();
  if (str.Contains("ada")) bdt="ada";
  if (str.Contains("grad")) bdt="grad";

  int nHists=HistList->GetEntries();
  TH1F *comp = linearBin(compT);
  
  gROOT->SetStyle("Plain");
  gROOT->ForceStyle();
  gStyle->SetOptStat(0);
  TCanvas *canv = new TCanvas("","",700,700);
  
  TLegend *leg = new TLegend(0.6,0.6,0.88,0.88);
  leg->SetLineColor(0);
  leg->SetFillColor(0);
  
  TF1 *line = new TF1("line","0.0",0.,comp->GetBinLowEdge(comp->GetNbinsX()+1));
  line->SetLineColor(kBlack);
  TF1 *line1 = new TF1("line","10.0",0.,comp->GetBinLowEdge(comp->GetNbinsX()+1));
  line1->SetLineColor(kGray+2);
  line1->SetLineStyle(2);
  TF1 *line2 = new TF1("line","-10.0",0.,comp->GetBinLowEdge(comp->GetNbinsX()+1));
  line2->SetLineColor(kGray+2);
  line2->SetLineStyle(2);
  
  int colors[10] = {kBlue,kMagenta,kGreen,kCyan,kRed,kBlue+3,kOrange+1,kSpring-1,kMagenta+3,kGreen+3};
  int color=0;
  for (int i=0; i<nHists; i++){
    TH1F *systHist = linearBin((TH1F*)HistList->At(i));
    systHist->Add(comp,-1);
    systHist->Divide(comp);
    systHist->Scale(100.);
    std::string systStr = systHist->GetName();
    int ind = systStr.rfind("cat0");
    std::string systName = systStr.substr(ind+5,systStr.size());
    systHist->SetLineColor(colors[color]);
    systHist->SetTitle(Form("%s",name.c_str()));
    systHist->GetYaxis()->SetTitle("Difference over nominal %");
    systHist->GetYaxis()->SetTitleOffset(1.4);
    systHist->GetXaxis()->SetTitle("BDT output");
    systHist->GetYaxis()->SetRangeUser(-100.,250);
    if (int(systName.find("Up"))>0){
      systHist->SetLineStyle(1);
      systName = systName.substr(0,systName.rfind("Up"));
      leg->AddEntry(systHist,systName.c_str(),"l");
      color++;
    }
    else if (int(systName.find("Down"))>0){
      systHist->SetLineStyle(2);
      systName = systName.substr(0,systName.rfind("Down"));
    }
    if (i==0) systHist->DrawCopy("hist");
    else systHist->DrawCopy("same hist");
  }
  leg->Draw("same");
  line->Draw("same");
  line1->Draw("same");
  line2->Draw("same");
  canv->Print(("plots/"+bdt+"/systs/"+name+".png").c_str(),"png");
  
  delete canv;
  
  systCalls++;
  
}
コード例 #10
0
void plotCutFlowNotStaggered(  FileList fileList , float Lumi_ = 30, 
		   float pt1_ = 20., float pt2_ = 15, float DEta_ = 1.0, float Mjj_ = 300. , float jetVeto_ = 15,
		   float signalScale_ = 1.0) {
  
  for(int i = 0; i<fileList.size(); i++){
    (fileList[i].first)->Close();
    delete (fileList[i].first);
  }

  TFile* fVBF115 = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_VBFH115.root","READ");
  TFile* fVBF135 = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_VBFH135.root","READ");
  TFile* fDYJets = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_DYJets-madgraph-50-PU.root","READ");
  TFile* fTT     = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_TT-madgraph-PU.root","READ");
  TFile* fWJets  = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_WJets-madgraph-PU.root","READ");
  TFile* fT      = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_TToBLNu-tW-madhraph-PU.root","READ");
  TFile* fQCD    = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_QCD-pythia-PU.root","READ");

  FileList fileList_;
  fileList_.push_back( make_pair(fT,      make_pair("tW",        10.6      )  ));
  fileList_.push_back( make_pair(fTT,     make_pair("ttbar",    157.5      )  ));
  fileList_.push_back( make_pair(fDYJets, make_pair("Zjets",   3048.0      )  ));
  fileList_.push_back( make_pair(fWJets,  make_pair("Wjets",  31314.0      )  ));
  fileList_.push_back( make_pair(fQCD,    make_pair("QCD",   349988.0      )  ));
  fileList_.push_back( make_pair(fVBF115, make_pair("qqH115",       0.1012 )  ));
  fileList_.push_back( make_pair(fVBF135, make_pair("qqH135",       0.05049)  ));
 

  TCanvas *c1 = new TCanvas("c1CutFlowNotStaggeredMass","",5,30,650,600);
  c1->SetGrid(0,0);
  c1->SetFillStyle(4000);
  c1->SetFillColor(10);
  c1->SetTicky();
  c1->SetObjectStat(0);
  c1->SetLogy(1);


  TPad* pad1 = new TPad("pad1CutFlowNotStaggeredMass","",0.05,0.27,0.96,0.97);
  TPad* pad2 = new TPad("pad2CutFlowNotStaggeredMass","",0.05,0.02,0.96,0.26);
  pad1->SetFillColor(0);
  pad2->SetFillColor(0);
  pad1->Draw();
  pad2->Draw();

  pad1->cd();
  pad1->SetLogy(1);

  TLegend* leg = new TLegend(0.60,0.47,0.90,0.85,NULL,"brNDC");
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(0.04);
  leg->SetHeader( "Cut Flow" );
  
  vector<TH1F*> histos;
  histos.clear();

  TH1F* hqqH115 = new TH1F();
  TH1F* hqqH135 = new TH1F();
  TH1F* hSiml   = new TH1F();

  vector< pair<string,string> > cutList;
  cutList.push_back(make_pair("vertexScarpingFilter/totalEvents","good vertex"));
  cutList.push_back(make_pair("oneMuonFilter/totalEvents","one gl. muon p_{T}>15 GeV"));
  cutList.push_back(make_pair("noElecFilter/totalEvents","electron veto"));
  cutList.push_back(make_pair("muonLegFilter/totalEvents","#mu cuts"));
  cutList.push_back(make_pair("tauLegFilter/totalEvents","#tau cuts"));
  cutList.push_back(make_pair("atLeastOneDiTauFilter/totalEvents","OS + m_{T} cut"));
  vector<float> cutFlow; 

  float signalScale = 1;

  for(unsigned int i = 0 ; i < fileList_.size() ; i++){

    signalScale = 1;

    TFile* currentFile = (TFile*)fileList_[i].first ;
    if( currentFile->IsZombie() ) continue;
    TH1F* allEvents = (TH1F*)currentFile->Get("allEventsFilter/totalEvents");
    float totalEvents = allEvents->GetBinContent(1);

    cutFlow.clear();
    for(int m = 0; m<cutList.size(); m++){
      TH1F* tmph1 =  (TH1F*)currentFile->Get( (cutList[m].first).c_str() );
      if(tmph1!=0){
	cutFlow.push_back( tmph1->GetBinContent(1) );
	//cout << tmph1->GetBinContent(1) << endl;
      }
    }

    TTree* currentTree = (TTree*)currentFile->Get("muTauStreamAnalyzer/tree");
    string h1Name = "h1_"+(fileList_[i].second).first;
    TH1F* h1 = new TH1F( h1Name.c_str() ,"", (int)(cutFlow.size()+3) ,0 , cutFlow.size()+3);

    if( ((fileList_[i].second).first).find("Zjets")!=string::npos ) {
      h1->SetLineColor(kRed);
      leg->AddEntry(h1,"MadGraph Z+jets","F");
    }
    if( ((fileList_[i].second).first).find("ttbar")!=string::npos ) {
      h1->SetLineColor(kBlue);
      leg->AddEntry(h1,"MadGraph t#bar{t}+jets","F");
    }
    if( ((fileList_[i].second).first).find("Wjets")!=string::npos ) {
      h1->SetLineColor(kGreen);
      leg->AddEntry(h1,"MadGraph W+jets","F");
    }
    if( ((fileList_[i].second).first).find("tW")!=string::npos ){
      h1->SetLineColor( 44 );
      leg->AddEntry(h1,"MadGraph single-top","F");
    }
    if( ((fileList_[i].second).first).find("QCD")!=string::npos ) {
      h1->SetLineColor(11);
      leg->AddEntry(h1,"Pythia QCD","F");
    }
    if( ((fileList_[i].second).first).find("qqH115")!=string::npos ) {
      h1->SetLineColor(kBlack);
      h1->SetLineStyle(kDashed);
      h1->SetLineWidth(3.0);
      signalScale = signalScale_;
      leg->AddEntry(h1,Form("VBF H(115)#rightarrow#tau#tau X %.0f",signalScale),"l");
    }
    if( ((fileList_[i].second).first).find("qqH135")!=string::npos ) {
      h1->SetLineColor(kBlack);
      h1->SetLineStyle(kDotted);
      h1->SetLineWidth(3.0);
      signalScale = signalScale_;
      leg->AddEntry(h1,Form("VBF H(135)#rightarrow#tau#tau X %.0f",signalScale),"l");
    }

    h1->SetBinContent(1,totalEvents);
    h1->GetXaxis()->SetBinLabel(1,"#sigma*BR*#int L");  
    for(int m = 0; m<cutFlow.size(); m++){
      h1->SetBinContent(m+2,cutFlow[m]);
      h1->GetXaxis()->SetBinLabel(m+2, (cutList[m].second).c_str() ); 
    }
    h1->GetXaxis()->SetBinLabel(cutFlow.size()+2,"VBF 1%");
    h1->GetXaxis()->SetBinLabel(cutFlow.size()+3,"CJV (15 GeV)");
   
    int nEntries = currentTree->GetEntries() ;    
    
    std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >* diTauSVfit3;
    std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >* jets;
    
    currentTree->SetBranchAddress("diTauSVfit3P4",&diTauSVfit3);
    currentTree->SetBranchAddress("jetsIDP4",&jets);
    
    for (int n = 0; n < nEntries ; n++) {
      
      currentTree->GetEntry(n);
   

      if( diTauSVfit3->size() < 1) continue;
      bool vbfCut = false;
      bool jetVeto = false;
      if( jets->size()>1 && 
	  (*jets)[0].Et()>pt1_ && (*jets)[1].Et()>pt2_ && 
	  abs((*jets)[0].Eta()-(*jets)[1].Eta())>DEta_ && 
	  ((*jets)[0]+(*jets)[1]).M()>Mjj_ ) vbfCut = true;
      for(unsigned k=0; k < jets->size(); k++){
	if(k>1 && 
	   (  ((*jets)[k].Eta()>(*jets)[1].Eta()+0.5 &&  (*jets)[k].Eta()<(*jets)[0].Eta()-0.5) || 
	      ((*jets)[k].Eta()>(*jets)[0].Eta()+0.5 &&  (*jets)[k].Eta()<(*jets)[1].Eta()-0.5) ) &&
	   (*jets)[k].Et()>jetVeto_ ) jetVeto=true;  
      }
      
      if(vbfCut)  h1->Fill( cutFlow.size()+1.5 ) ;      
      if(vbfCut && !jetVeto)  h1->Fill( cutFlow.size()+2.5 ) ;      
    
    }
   

    h1->Scale( Lumi_ / (totalEvents/((fileList_[i].second).second * signalScale)) );

    if(((fileList_[i].second).first).find("qqH115")!=string::npos){
      hqqH115=(TH1F*)h1->Clone("hqqH115");
      hqqH115 = h1;
      hqqH115->Sumw2();
      continue;
    }
    if(((fileList_[i].second).first).find("qqH135")!=string::npos){
      hqqH135=(TH1F*)h1->Clone("hqqH135");
      hqqH135 = h1;
      hqqH135->Sumw2();
      continue;
    }

    if(i==0) hSiml=(TH1F*)h1->Clone("hSiml");
    else hSiml->Add(h1);

    histos.push_back(h1);

  }

  //float numData = hData->GetEntries();
  //float numSiml = hSiml->Integral();
  //float dataToSimlRatio = numData/numSiml;
  //cout << "data " << numData << "  ---  simul " << numSiml << endl;  

  hqqH115->SetTitle(Form("CMS Preliminary 2010    #sqrt{s}=7 TeV L=%.0f pb^{-1}",Lumi_));
  hqqH115->SetXTitle("");
  hqqH115->SetYTitle("Number of events");
  hqqH115->SetTitleSize(0.05,"X");
  hqqH115->SetTitleSize(0.05,"Y");
  hqqH115->SetTitleOffset(0.75,"Y");
  hqqH115->SetAxisRange(0.1,hSiml->GetMaximum()*1.2,"Y");

  hqqH115->Draw("HIST");
  hqqH135->Draw("HISTSAME");
  for(int p = 0; p<histos.size(); p++){
    histos[p]->Draw("HISTSAME");
  }


  leg->Draw();

  pad2->cd();
  TH1F* hRatio = new TH1F("hRatio", " ; ; purity",
			  hqqH115->GetNbinsX(), 
			  hqqH115->GetXaxis()->GetXmin(), hqqH115->GetXaxis()->GetXmax());
  hRatio->SetLineStyle(kDashed);
  hRatio->SetLineWidth(1.0);
  hRatio->SetLabelSize(0.12,"X");
  hRatio->SetLabelSize(0.10,"Y");
  hRatio->SetTitleSize(0.12,"Y");
  hRatio->SetTitleOffset(0.36,"Y");
  TH1F* hqqH115Clone = (TH1F*)hqqH115->Clone("hqqH115Clone");
  TH1F* hqqH135Clone = (TH1F*)hqqH135->Clone("hqqH135Clone");
  hqqH115Clone->Divide( hqqH115 ,hSiml,1./signalScale,1.0);
  hqqH135Clone->Divide( hqqH135 ,hSiml,1./signalScale,1.0);
  hRatio->SetAxisRange(0.,0.1,"Y");

  hRatio->Draw();
  hqqH115Clone->Draw("HISTSAME");
  hqqH135Clone->Draw("HISTSAME");

  if(SAVE) c1->SaveAs("Zmm_CutFlowNotStaggeredMass.png");

}
コード例 #11
0
void compare_ATLAS_pp_fitBoth_TH1F(Int_t nfit=6, Int_t FitStart=50, Int_t FitEnd=450){
     TH1::SetDefaultSumw2();
   gStyle->SetOptFit(1);     
   gStyle->SetOptStat(0);
   
//=========Macro generated from canvas: cATLAS_pp/
//=========  (Wed Jul 22 23:01:26 2015) by ROOT version5.32/00

   TF1 *fitppATLAS = new TF1("fitppATLAS","[0]*pow(x+[2],[1])"); //create function
   fitppATLAS->SetParameters(1e10,-5,0);
   fitppATLAS->SetLineColor(kRed);   
   TF1 *fitppCMS = new TF1("fitppCMS","[0]*pow(x+[2],[1])"); //create function
   fitppCMS->SetParameters(1e10,-5,0);
   fitppCMS->SetLineColor(kBlue);   
   TF1 *fitppATLASHist = new TF1("fitppATLASHist","[0]*pow(x+[2],[1])"); //create function
   fitppATLASHist->SetParameters(1e10,-5,0);
   fitppATLASHist->SetLineColor(kGreen+1);   
      
   TGraphAsymmErrors *grae = new TGraphAsymmErrors(12);
   grae->SetName("/HepData/8719/d2x1y1");
   grae->SetTitle(" ");
   grae->SetFillColor(1);
   grae->SetMarkerStyle(33);
   grae->SetPoint(0,35,180);
   grae->SetPointError(0,4,4,29.95905,29.95905);
   grae->SetPoint(1,44.5,55.7);
   grae->SetPointError(1,5.5,5.5,7.828377,7.828377);
   grae->SetPoint(2,56.5,16.9);
   grae->SetPointError(2,6.5,6.5,2.625436,2.625436);
   grae->SetPoint(3,71,4.85);
   grae->SetPointError(3,8,8,0.6276957,0.6276957);
   grae->SetPoint(4,89.5,1.42);
   grae->SetPointError(4,10.5,10.5,0.1878054,0.1878054);
   grae->SetPoint(5,112.5,0.364);
   grae->SetPointError(5,12.5,12.5,0.04772427,0.04772427);
   grae->SetPoint(6,141.5,0.0882);
   grae->SetPointError(6,16.5,16.5,0.01103805,0.01103805);
   grae->SetPoint(7,178.5,0.0197);
   grae->SetPointError(7,20.5,20.5,0.002292152,0.002292152);
   grae->SetPoint(8,225,0.00406);
   grae->SetPointError(8,26,26,0.0004822521,0.0004822521);
   grae->SetPoint(9,283.5,0.000735);
   grae->SetPointError(9,32.5,32.5,8.981748e-05,8.981748e-05);
   grae->SetPoint(10,357,0.000114);
   grae->SetPointError(10,41,41,1.442494e-05,1.442494e-05);
   grae->SetPoint(11,449.5,1.41e-05);
   grae->SetPointError(11,51.5,51.5,1.98855e-06,1.98855e-06);
   
   TH1F *hATLASpp = new TH1F("hATLASpp"," ",100,50,450);
   hATLASpp->SetMinimum(1.090031e-05);
   hATLASpp->SetMaximum(230.955);
   hATLASpp->SetDirectory(0);
   hATLASpp->SetStats(0);

   Int_t ci;   // for color index setting
   ci = TColor::GetColor("#000099");
   hATLASpp->SetLineColor(ci);
   hATLASpp->GetXaxis()->SetTitle("ak R=0.4 Jet p_{T} (GeV/c)");
   hATLASpp->GetXaxis()->SetLabelFont(42);
   hATLASpp->GetXaxis()->SetLabelSize(0.035);
   hATLASpp->GetXaxis()->SetTitleSize(0.035);
   hATLASpp->GetXaxis()->SetTitleFont(42);
   hATLASpp->GetYaxis()->SetTitle("#frac{d^{2}#sigma}{dp_{T} d#eta} nb");
   hATLASpp->GetYaxis()->SetLabelFont(42);
   hATLASpp->GetYaxis()->SetLabelSize(0.035);
   hATLASpp->GetYaxis()->SetTitleSize(0.035);
   hATLASpp->GetYaxis()->SetTitleFont(42);
   hATLASpp->GetZaxis()->SetLabelFont(42);
   hATLASpp->GetZaxis()->SetLabelSize(0.035);
   hATLASpp->GetZaxis()->SetTitleSize(0.035);
   hATLASpp->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(hATLASpp);


Double_t xAxisATLASpp[13] = {31,39,50,63,79,100,125,158,199,251,316,398,501}; 
   TH1F *hATLASppHist = new TH1F("hATLASppHist"," ",12,xAxisATLASpp);
   hATLASppHist->SetMinimum(1.090031e-05);
   hATLASppHist->SetMaximum(230.955);
   hATLASppHist->SetDirectory(0);
   hATLASppHist->SetStats(0);
   hATLASppHist->SetBinContent(1,180);
   hATLASppHist->SetBinError(1,29.95905);
   hATLASppHist->SetBinContent(2,55.7);
   hATLASppHist->SetBinError(2,7.828377);
   hATLASppHist->SetBinContent(3,16.9);
   hATLASppHist->SetBinError(3,2.625436);
   hATLASppHist->SetBinContent(4,4.85);
   hATLASppHist->SetBinError(4,0.6276957);
   hATLASppHist->SetBinContent(5,1.42);
   hATLASppHist->SetBinError(5,0.1878054);
   hATLASppHist->SetBinContent(6,0.364);
   hATLASppHist->SetBinError(6,0.04772427);
   hATLASppHist->SetBinContent(7,0.0882);
   hATLASppHist->SetBinError(7,0.01103805);
   hATLASppHist->SetBinContent(8,0.0197);
   hATLASppHist->SetBinError(8,0.002292152);
   hATLASppHist->SetBinContent(9,0.00406);
   hATLASppHist->SetBinError(9,0.0004822521);
   hATLASppHist->SetBinContent(10,0.000735);
   hATLASppHist->SetBinError(10,8.981748e-05);
   hATLASppHist->SetBinContent(11,0.000114);
   hATLASppHist->SetBinError(11,1.442494e-05);
   hATLASppHist->SetBinContent(12,1.41e-05);
   hATLASppHist->SetBinError(12,1.98855e-06);
//    c1=new TCanvas();
// //   c1.cd();
//    hATLASppHist->Draw();
  // was grae
   for(int i=0; i<nfit; ++i){
     grae->Fit("fitppATLAS","","",FitStart,FitEnd); //fit function
   } 
   cout<<"now to fit hATLASppHist"<<endl;
   for(int ib=0; ib<nfit; ++ib){
     hATLASppHist->Fit("fitppATLASHist","IL","",FitStart,FitEnd); //fit function
   } 

   TCanvas *cATLAS_ppHist = new TCanvas("cATLAS_ppHist", "",0,0,1200,1000);
   cATLAS_ppHist->Range(-3.725291e-06,-5.878322,500,3.279288);
   cATLAS_ppHist->SetFillColor(0);
   cATLAS_ppHist->SetBorderMode(0);
   cATLAS_ppHist->SetBorderSize(2);
   cATLAS_ppHist->SetLogy();
   cATLAS_ppHist->SetFrameBorderMode(0);
   cATLAS_ppHist->SetFrameBorderMode(0);

//   grae->SetHistogram(hATLASpp);

   TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.04);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(10);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("NULL","","h");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("hATLASppHist","ATLAS pp histogram","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(kGreen);
   entry->SetMarkerStyle(22);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("grae","ATLAS pp TGraphAsymErrors","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(33);
   entry->SetMarkerSize(1);
   
   leg->Draw();
   hATLASppHist->SetMarkerColor(kGreen);
   hATLASppHist->SetMarkerStyle(22);
   grae->SetMarkerStyle(21);
   grae->SetMarkerColor(1);
   hATLASpp->Draw();
   grae->Draw("ap,same");
//   uPP_R4_SVD->Draw("same E1");
   hATLASppHist->Draw("ap,same");
   
   TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *text = pt->AddText(" ");
   pt->Draw();
   cATLAS_ppHist->Modified();
   cATLAS_ppHist->cd();
   cATLAS_ppHist->SetSelected(cATLAS_ppHist);
   
//     for(int ic=0; ic<nfit; ic++){
//       uPP_R4_SVD->Fit("fitppCMS","IL","",60,FitEnd); //fit function    
// //      uPP_R4_SVD->Fit("fitppCMS","IL","",50,300); //fit function
//     } 
   
//     hATLASpp->Draw();
//    grae->Draw("ap,same");
//    uPP_R4_SVD->Draw("same E1");
//    hATLASppHist->Draw("same E1");
   leg->Draw();
   cATLAS_ppHist->SaveAs("Plots/ATLASHistfit_spectra_pp.pdf");
   
   
   Double_t xAxis2086[101] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000}; 
   
   TH1F *uPP_R4_SVD = new TH1F("uPP_R4_SVD","Unfold Matrix refpt jtpt from trigger addition R4 20_eta_20 ",100, xAxis2086);
   uPP_R4_SVD->SetBinContent(1,15.44572);
   uPP_R4_SVD->SetBinContent(2,81.73347);
   uPP_R4_SVD->SetBinContent(3,85.49986);
   uPP_R4_SVD->SetBinContent(4,90.07588);
   uPP_R4_SVD->SetBinContent(5,47.67952);
   uPP_R4_SVD->SetBinContent(6,18.31659);
   uPP_R4_SVD->SetBinContent(7,7.348095);
   uPP_R4_SVD->SetBinContent(8,3.295203);
   uPP_R4_SVD->SetBinContent(9,1.60486);
   uPP_R4_SVD->SetBinContent(10,0.8393627);
   uPP_R4_SVD->SetBinContent(11,0.4622419);
   uPP_R4_SVD->SetBinContent(12,0.265131);
   uPP_R4_SVD->SetBinContent(13,0.1587068);
   uPP_R4_SVD->SetBinContent(14,0.09774788);
   uPP_R4_SVD->SetBinContent(15,0.06153403);
   uPP_R4_SVD->SetBinContent(16,0.03981187);
   uPP_R4_SVD->SetBinContent(17,0.02620752);
   uPP_R4_SVD->SetBinContent(18,0.01766706);
   uPP_R4_SVD->SetBinContent(19,0.01206758);
   uPP_R4_SVD->SetBinContent(20,0.008403017);
   uPP_R4_SVD->SetBinContent(21,0.005956108);
   uPP_R4_SVD->SetBinContent(22,0.004267026);
   uPP_R4_SVD->SetBinContent(23,0.003102345);
   uPP_R4_SVD->SetBinContent(24,0.002273482);
   uPP_R4_SVD->SetBinContent(25,0.001699103);
   uPP_R4_SVD->SetBinContent(26,0.001281323);
   uPP_R4_SVD->SetBinContent(27,0.000971557);
   uPP_R4_SVD->SetBinContent(28,0.0007444665);
   uPP_R4_SVD->SetBinContent(29,0.0005746992);
   uPP_R4_SVD->SetBinContent(30,0.0004462709);
   uPP_R4_SVD->SetBinContent(31,0.0003483805);
   uPP_R4_SVD->SetBinContent(32,0.0002725941);
   uPP_R4_SVD->SetBinContent(33,0.0002141152);
   uPP_R4_SVD->SetBinContent(34,0.0001705039);
   uPP_R4_SVD->SetBinContent(35,0.0001352845);
   uPP_R4_SVD->SetBinContent(36,0.0001073623);
   uPP_R4_SVD->SetBinContent(37,8.559958e-05);
   uPP_R4_SVD->SetBinContent(38,6.847693e-05);
   uPP_R4_SVD->SetBinContent(39,5.506579e-05);
   uPP_R4_SVD->SetBinContent(40,4.404838e-05);
   uPP_R4_SVD->SetBinContent(41,3.566817e-05);
   uPP_R4_SVD->SetBinContent(42,2.88001e-05);
   uPP_R4_SVD->SetBinContent(43,2.33088e-05);
   uPP_R4_SVD->SetBinContent(44,1.897322e-05);
   uPP_R4_SVD->SetBinContent(45,1.546483e-05);
   uPP_R4_SVD->SetBinContent(46,1.251424e-05);
   uPP_R4_SVD->SetBinContent(47,1.020799e-05);
   uPP_R4_SVD->SetBinContent(48,8.267746e-06);
   uPP_R4_SVD->SetBinContent(49,6.760333e-06);
   uPP_R4_SVD->SetBinContent(50,5.504337e-06);
   uPP_R4_SVD->SetBinContent(51,4.514429e-06);
   uPP_R4_SVD->SetBinContent(52,3.665816e-06);
   uPP_R4_SVD->SetBinContent(53,3.010496e-06);
   uPP_R4_SVD->SetBinContent(54,2.463812e-06);
   uPP_R4_SVD->SetBinContent(55,2.01082e-06);
   uPP_R4_SVD->SetBinContent(56,1.624154e-06);
   uPP_R4_SVD->SetBinContent(57,1.334625e-06);
   uPP_R4_SVD->SetBinContent(58,1.088798e-06);
   uPP_R4_SVD->SetBinContent(59,8.896167e-07);
   uPP_R4_SVD->SetBinContent(60,7.305952e-07);
   uPP_R4_SVD->SetBinContent(61,5.930196e-07);
   uPP_R4_SVD->SetBinContent(62,4.863888e-07);
   uPP_R4_SVD->SetBinContent(63,3.941485e-07);
   uPP_R4_SVD->SetBinContent(64,3.221651e-07);
   uPP_R4_SVD->SetBinContent(65,2.636797e-07);
   uPP_R4_SVD->SetBinContent(66,2.146457e-07);
   uPP_R4_SVD->SetBinContent(67,1.742243e-07);
   uPP_R4_SVD->SetBinContent(68,1.409108e-07);
   uPP_R4_SVD->SetBinContent(69,1.142703e-07);
   uPP_R4_SVD->SetBinContent(70,9.293402e-08);
   uPP_R4_SVD->SetBinContent(71,7.511816e-08);
   uPP_R4_SVD->SetBinContent(72,6.013509e-08);
   uPP_R4_SVD->SetBinContent(73,4.927971e-08);
   uPP_R4_SVD->SetBinContent(74,3.992714e-08);
   uPP_R4_SVD->SetBinContent(75,3.176246e-08);
   uPP_R4_SVD->SetBinContent(76,2.560933e-08);
   uPP_R4_SVD->SetBinContent(77,2.039975e-08);
   uPP_R4_SVD->SetBinContent(78,1.627726e-08);
   uPP_R4_SVD->SetBinContent(79,1.272043e-08);
   uPP_R4_SVD->SetBinContent(80,1.022684e-08);
   uPP_R4_SVD->SetBinContent(81,8.172451e-09);
   uPP_R4_SVD->SetBinContent(82,6.570082e-09);
   uPP_R4_SVD->SetBinContent(83,5.205766e-09);
   uPP_R4_SVD->SetBinContent(84,4.075393e-09);
   uPP_R4_SVD->SetBinContent(85,3.265506e-09);
   uPP_R4_SVD->SetBinContent(86,2.62088e-09);
   uPP_R4_SVD->SetBinContent(87,2.003114e-09);
   uPP_R4_SVD->SetBinContent(88,1.535628e-09);
   uPP_R4_SVD->SetBinContent(89,1.063791e-09);
   uPP_R4_SVD->SetBinContent(90,9.092138e-10);
   uPP_R4_SVD->SetBinContent(91,6.803265e-10);
   uPP_R4_SVD->SetBinContent(92,4.778346e-10);
   uPP_R4_SVD->SetBinContent(93,3.988072e-10);
   uPP_R4_SVD->SetBinContent(94,2.474126e-10);
   uPP_R4_SVD->SetBinContent(95,2.140924e-10);
   uPP_R4_SVD->SetBinContent(96,1.623732e-10);
   uPP_R4_SVD->SetBinContent(97,1.45067e-10);
   uPP_R4_SVD->SetBinContent(98,9.186947e-11);
   uPP_R4_SVD->SetBinContent(99,6.040857e-11);
   uPP_R4_SVD->SetBinContent(100,6.157141e-11);
   uPP_R4_SVD->SetBinError(1,0.1237595);
   uPP_R4_SVD->SetBinError(2,0.6234048);
   uPP_R4_SVD->SetBinError(3,0.586929);
   uPP_R4_SVD->SetBinError(4,0.5173901);
   uPP_R4_SVD->SetBinError(5,0.2055361);
   uPP_R4_SVD->SetBinError(6,0.04990473);
   uPP_R4_SVD->SetBinError(7,0.01308245);
   uPP_R4_SVD->SetBinError(8,0.006804987);
   uPP_R4_SVD->SetBinError(9,0.003260532);
   uPP_R4_SVD->SetBinError(10,0.001534405);
   uPP_R4_SVD->SetBinError(11,0.001026545);
   uPP_R4_SVD->SetBinError(12,0.000705749);
   uPP_R4_SVD->SetBinError(13,0.0004784051);
   uPP_R4_SVD->SetBinError(14,0.0003483983);
   uPP_R4_SVD->SetBinError(15,0.0002598719);
   uPP_R4_SVD->SetBinError(16,0.0001903908);
   uPP_R4_SVD->SetBinError(17,0.0001387089);
   uPP_R4_SVD->SetBinError(18,0.0001040173);
   uPP_R4_SVD->SetBinError(19,7.981541e-05);
   uPP_R4_SVD->SetBinError(20,6.24475e-05);
   uPP_R4_SVD->SetBinError(21,4.937991e-05);
   uPP_R4_SVD->SetBinError(22,3.947987e-05);
   uPP_R4_SVD->SetBinError(23,3.254473e-05);
   uPP_R4_SVD->SetBinError(24,2.764293e-05);
   uPP_R4_SVD->SetBinError(25,2.429597e-05);
   uPP_R4_SVD->SetBinError(26,2.159774e-05);
   uPP_R4_SVD->SetBinError(27,1.917051e-05);
   uPP_R4_SVD->SetBinError(28,1.6997e-05);
   uPP_R4_SVD->SetBinError(29,1.498669e-05);
   uPP_R4_SVD->SetBinError(30,1.312744e-05);
   uPP_R4_SVD->SetBinError(31,1.142902e-05);
   uPP_R4_SVD->SetBinError(32,9.871913e-06);
   uPP_R4_SVD->SetBinError(33,8.480939e-06);
   uPP_R4_SVD->SetBinError(34,7.324674e-06);
   uPP_R4_SVD->SetBinError(35,6.255272e-06);
   uPP_R4_SVD->SetBinError(36,5.306614e-06);
   uPP_R4_SVD->SetBinError(37,4.495288e-06);
   uPP_R4_SVD->SetBinError(38,3.800242e-06);
   uPP_R4_SVD->SetBinError(39,3.214166e-06);
   uPP_R4_SVD->SetBinError(40,2.692884e-06);
   uPP_R4_SVD->SetBinError(41,2.275421e-06);
   uPP_R4_SVD->SetBinError(42,1.910914e-06);
   uPP_R4_SVD->SetBinError(43,1.60384e-06);
   uPP_R4_SVD->SetBinError(44,1.350324e-06);
   uPP_R4_SVD->SetBinError(45,1.135728e-06);
   uPP_R4_SVD->SetBinError(46,9.463317e-07);
   uPP_R4_SVD->SetBinError(47,7.933288e-07);
   uPP_R4_SVD->SetBinError(48,6.591956e-07);
   uPP_R4_SVD->SetBinError(49,5.520988e-07);
   uPP_R4_SVD->SetBinError(50,4.597711e-07);
   uPP_R4_SVD->SetBinError(51,3.851643e-07);
   uPP_R4_SVD->SetBinError(52,3.190695e-07);
   uPP_R4_SVD->SetBinError(53,2.670117e-07);
   uPP_R4_SVD->SetBinError(54,2.22444e-07);
   uPP_R4_SVD->SetBinError(55,1.84622e-07);
   uPP_R4_SVD->SetBinError(56,1.515098e-07);
   uPP_R4_SVD->SetBinError(57,1.263889e-07);
   uPP_R4_SVD->SetBinError(58,1.045901e-07);
   uPP_R4_SVD->SetBinError(59,8.662012e-08);
   uPP_R4_SVD->SetBinError(60,7.20551e-08);
   uPP_R4_SVD->SetBinError(61,5.920339e-08);
   uPP_R4_SVD->SetBinError(62,4.912298e-08);
   uPP_R4_SVD->SetBinError(63,4.024705e-08);
   uPP_R4_SVD->SetBinError(64,3.324212e-08);
   uPP_R4_SVD->SetBinError(65,2.747888e-08);
   uPP_R4_SVD->SetBinError(66,2.258106e-08);
   uPP_R4_SVD->SetBinError(67,1.849393e-08);
   uPP_R4_SVD->SetBinError(68,1.50859e-08);
   uPP_R4_SVD->SetBinError(69,1.233344e-08);
   uPP_R4_SVD->SetBinError(70,1.010825e-08);
   uPP_R4_SVD->SetBinError(71,8.230567e-09);
   uPP_R4_SVD->SetBinError(72,6.634947e-09);
   uPP_R4_SVD->SetBinError(73,5.473309e-09);
   uPP_R4_SVD->SetBinError(74,4.462479e-09);
   uPP_R4_SVD->SetBinError(75,3.571148e-09);
   uPP_R4_SVD->SetBinError(76,2.895626e-09);
   uPP_R4_SVD->SetBinError(77,2.318939e-09);
   uPP_R4_SVD->SetBinError(78,1.859689e-09);
   uPP_R4_SVD->SetBinError(79,1.460273e-09);
   uPP_R4_SVD->SetBinError(80,1.179314e-09);
   uPP_R4_SVD->SetBinError(81,9.46416e-10);
   uPP_R4_SVD->SetBinError(82,7.638915e-10);
   uPP_R4_SVD->SetBinError(83,6.075323e-10);
   uPP_R4_SVD->SetBinError(84,4.772801e-10);
   uPP_R4_SVD->SetBinError(85,3.836821e-10);
   uPP_R4_SVD->SetBinError(86,3.088773e-10);
   uPP_R4_SVD->SetBinError(87,2.367363e-10);
   uPP_R4_SVD->SetBinError(88,1.819577e-10);
   uPP_R4_SVD->SetBinError(89,1.263493e-10);
   uPP_R4_SVD->SetBinError(90,1.082238e-10);
   uPP_R4_SVD->SetBinError(91,8.113796e-11);
   uPP_R4_SVD->SetBinError(92,5.70881e-11);
   uPP_R4_SVD->SetBinError(93,4.772047e-11);
   uPP_R4_SVD->SetBinError(94,2.964495e-11);
   uPP_R4_SVD->SetBinError(95,2.568217e-11);
   uPP_R4_SVD->SetBinError(96,1.949672e-11);
   uPP_R4_SVD->SetBinError(97,1.743206e-11);
   uPP_R4_SVD->SetBinError(98,1.104588e-11);
   uPP_R4_SVD->SetBinError(99,7.265969e-12);
   uPP_R4_SVD->SetBinError(100,7.407249e-12);
   uPP_R4_SVD->SetEntries(100);
   uPP_R4_SVD->SetStats(0);

   ci = TColor::GetColor("#000099");
   uPP_R4_SVD->SetLineColor(ci);

//    ci = TColor::GetColor("#0000ff");
//    uPP_R4_SVD->SetMarkerColor(ci);
//    uPP_R4_SVD->SetMarkerStyle(24);
//    uPP_R4_SVD->GetXaxis()->CenterTitle(true);
//    uPP_R4_SVD->GetXaxis()->SetLabelFont(42);
//    uPP_R4_SVD->GetXaxis()->SetLabelSize(0.035);
//    uPP_R4_SVD->GetXaxis()->SetTitleSize(0.035);
//    uPP_R4_SVD->GetXaxis()->SetTitleFont(42);
//    uPP_R4_SVD->GetYaxis()->CenterTitle(true);
//    uPP_R4_SVD->GetYaxis()->SetLabelFont(42);
//    uPP_R4_SVD->GetYaxis()->SetLabelSize(0.035);
//    uPP_R4_SVD->GetYaxis()->SetTitleSize(0.035);
//    uPP_R4_SVD->GetYaxis()->SetTitleFont(42);
//    uPP_R4_SVD->GetZaxis()->SetLabelFont(42);
//    uPP_R4_SVD->GetZaxis()->SetLabelSize(0.035);
//    uPP_R4_SVD->GetZaxis()->SetTitleSize(0.035);
//    uPP_R4_SVD->GetZaxis()->SetTitleFont(42);
//    uPP_R4_SVD->Draw("same E1");
//    TBox *box = new TBox(60,7.108492,70,7.587699);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(70,3.186674,80,3.403731);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(80,1.551541,90,1.658179);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(90,0.8111346,100,0.8675909);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(100,0.4464541,110,0.4780297);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(110,0.2045159,130,0.2193219);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(130,0.07677678,150,0.08250514);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(150,0.03180206,170,0.03421734);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(170,0.01431415,190,0.01542048);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(190,0.006909775,210,0.007449351);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(210,0.003092187,240,0.003336382);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(240,0.001266417,270,0.001368238);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(270,0.00056544,300,0.0006115177);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
   TCanvas *cATLAS_pp = new TCanvas("cATLAS_pp", "",0,0,1200,1000);
   cATLAS_pp->Range(-3.725291e-06,-5.878322,500,3.279288);
   cATLAS_pp->SetFillColor(0);
   cATLAS_pp->SetBorderMode(0);
   cATLAS_pp->SetBorderSize(2);
   cATLAS_pp->SetLogy();
   cATLAS_pp->SetFrameBorderMode(0);
   cATLAS_pp->SetFrameBorderMode(0);
   grae->SetHistogram(hATLASpp);
   hATLASpp->Draw();
   grae->Draw("ap,same");   
         
   TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.04);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(10);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("NULL","","h");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("/HepData/8719/d2x1y1","ATLAS pp","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(33);
   entry->SetMarkerSize(1);
   entry=leg->AddEntry("uPP_R4_SVD","CMS pp","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#0000ff");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(24);
   entry->SetMarkerSize(1);
   leg->Draw();


   
   TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *text = pt->AddText(" ");
   pt->Draw();
   cATLAS_pp->Modified();
   cATLAS_pp->cd();
   cATLAS_pp->SetSelected(cATLAS_pp);
   
    for(int ic=0; ic<nfit; ic++){
      uPP_R4_SVD->Fit("fitppCMS","IL","",60,FitEnd); //fit function    
//      uPP_R4_SVD->Fit("fitppCMS","IL","",50,300); //fit function
    } 
   
    hATLASpp->Draw();
   grae->Draw("ap,same");
   uPP_R4_SVD->Draw("same E1");
   leg->Draw();
   cATLAS_pp->SaveAs("Plots/CMSfit_ATLASfit_spectra_pp.pdf");
   
   
   TCanvas *cCMS_pp = new TCanvas("cCMS_pp", "",0,0,1200,1000);
   cCMS_pp->Range(-3.725291e-06,-5.878322,500,3.279288);
   cCMS_pp->SetFillColor(0);
   cCMS_pp->SetBorderMode(0);
   cCMS_pp->SetBorderSize(2);
   cCMS_pp->SetLogy();
   cCMS_pp->SetLogx();
   cCMS_pp->SetFrameBorderMode(0);
   cCMS_pp->SetFrameBorderMode(0);
   uPP_R4_SVD->GetXaxis()->SetTitle("ak R=0.4 Jet p_{T} (GeV/c)");
   uPP_R4_SVD->GetXaxis()->SetLabelFont(42);
   uPP_R4_SVD->GetXaxis()->SetLabelSize(0.035);
   uPP_R4_SVD->GetXaxis()->SetTitleSize(0.035);
   uPP_R4_SVD->GetXaxis()->SetTitleFont(42);
   uPP_R4_SVD->GetXaxis()->SetRangeUser(50,450);
   uPP_R4_SVD->GetYaxis()->SetTitle("#frac{d^{2}#sigma}{dp_{T} d#eta} nb");
   uPP_R4_SVD->GetYaxis()->SetLabelFont(42);
   uPP_R4_SVD->GetYaxis()->SetLabelSize(0.035);
   uPP_R4_SVD->GetYaxis()->SetTitleSize(0.035);
   uPP_R4_SVD->GetYaxis()->SetTitleFont(42);
   uPP_R4_SVD->GetZaxis()->SetLabelFont(42);
   uPP_R4_SVD->GetZaxis()->SetLabelSize(0.035);
   uPP_R4_SVD->GetZaxis()->SetTitleSize(0.035);
   uPP_R4_SVD->GetZaxis()->SetTitleFont(42);
      
   uPP_R4_SVD->Draw();
      
   TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.04);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(10);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("NULL","","h");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(33);
   entry->SetMarkerSize(1);
   entry=leg->AddEntry("uPP_R4_SVD","CMS pp","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#0000ff");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(24);
   entry->SetMarkerSize(1);
   leg->Draw();   

   TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *text = pt->AddText(" ");
   pt->Draw();
   cCMS_pp->Modified();
   cCMS_pp->cd();
   cCMS_pp->SetSelected(cCMS_pp);
   cCMS_pp->SaveAs("Plots/CMSfit_spectra_pp.pdf"); 

   TCanvas *cATLAS_lin_pp = new TCanvas("cATLAS_lin_pp", "",0,0,1200,1000);
   cATLAS_lin_pp->Range(-3.725291e-06,-5.878322,500,3.279288);
   cATLAS_lin_pp->SetFillColor(0);
   cATLAS_lin_pp->SetBorderMode(0);
   cATLAS_lin_pp->SetBorderSize(2);
   cATLAS_lin_pp->SetFrameBorderMode(0);
   cATLAS_lin_pp->SetFrameBorderMode(0);
   cATLAS_lin_pp->SetLogy();
   cATLAS_lin_pp->SetLogx();
   hATLASpp->Draw();
   grae->Draw("ap,same");
   TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.04);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(10);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("NULL","","h");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("/HepData/8719/d2x1y1","ATLAS pp","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(33);
   entry->SetMarkerSize(1);
   entry=leg->AddEntry("uPP_R4_SVD","CMS pp","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#0000ff");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(24);
   entry->SetMarkerSize(1);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *text = pt->AddText(" ");
   pt->Draw();
   cATLAS_lin_pp->Modified();
   cATLAS_lin_pp->cd();
   cATLAS_lin_pp->SetSelected(cATLAS_lin_pp);
   
//     for(int ic=0; ic<nfit; ic++){
//       uPP_R4_SVD->Fit("fitppCMS","IL","",60,FitEnd); //fit function    
// //      uPP_R4_SVD->Fit("fitppCMS","IL","",50,300); //fit function
//     } 
   
    hATLASpp->Draw();
   grae->Draw("ap,same");
   uPP_R4_SVD->Draw("same E1");
   leg->Draw();
   cATLAS_lin_pp->SaveAs("Plots/CMSfit_ATLASfit_spectra_loglog_pp.pdf");  

   fitppCMS->SetBit(TF1::kNotDraw);
   fitppCMS->SetLineColor(0);
   uPP_R4_SVD->SetBit(TF1::kNotDraw);




   TH1F *hFitRatioATLAS = (TH1F*)functionHist(fitppCMS,uPP_R4_SVD,"hFitRatioATLAS"); //clone fitRatioATLAS from fitppCMS
//   hFitRatioATLAS->SetLineColor(0);
   TH1F *hRatioATLAS = (TH1F*)uPP_R4_SVD->Clone("hRatioATLAS"); //clone histogram hRatio from h

   TH1F *hfunctionATLAS = (TH1F*)functionHist(fitppATLAS,uPP_R4_SVD,"hfunctionATLAS");
   hFitRatioATLAS->Divide(hfunctionATLAS);
   hFitRatioATLAS->SetMarkerColor(kRed); 
   hFitRatioATLAS->SetMarkerStyle(21);
   hFitRatioATLAS->SetMarkerSize(1.2);
   hFitRatioATLAS->SetLineColor(0);  

   TH1F *hfunctionATLASHist = (TH1F*)functionHist(fitppATLASHist,uPP_R4_SVD,"hfunctionATLASHist");
   TH1F *hRatioATLASHist = (TH1F*)uPP_R4_SVD->Clone("hRatioATLASHist"); //clone histogram hRatio from h
   hRatioATLASHist->Divide(hfunctionATLASHist);
   hRatioATLASHist->SetMarkerColor(kGreen+1); 
   hRatioATLASHist->SetMarkerStyle(22);
   hRatioATLASHist->SetMarkerSize(1.2);
   hRatioATLASHist->SetLineColor(0); 
      
//   hfunctionATLAS->Draw();
//   hATLASpp->Draw();
   hRatioATLAS->Divide(hfunctionATLAS);
   TCanvas *cRatio_pp = new TCanvas("cRatio_pp", "",0,0,1200,1000);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   cRatio_pp->Range(-50.00001,-6.302699,538.2353,2.631555);
   cRatio_pp->SetFillColor(0);
   cRatio_pp->SetBorderMode(0);
   cRatio_pp->SetBorderSize(0);
   cRatio_pp->SetTickx(1);
   cRatio_pp->SetTicky(1);
   cRatio_pp->SetLeftMargin(0.17);
   cRatio_pp->SetRightMargin(0.15);
   cRatio_pp->SetTopMargin(0.03);
   cRatio_pp->SetBottomMargin(0.15);
   cRatio_pp->SetFrameLineColor(0);
   cRatio_pp->SetFrameBorderMode(0);
   cRatio_pp->SetFrameLineColor(0);
   cRatio_pp->SetFrameBorderMode(0);   
   TH1F *hRatioBlank = new TH1F("hRatioBlank"," ",100,50,300);
   hRatioBlank->SetMinimum(0);
   hRatioBlank->SetMaximum(1.2);
   hRatioBlank->SetDirectory(0);
   hRatioBlank->SetStats(0);
   hRatioBlank->SetFillColor(1);
   hRatioBlank->SetFillStyle(0);
   hRatioBlank->SetLineStyle(0);
   hRatioBlank->SetMarkerStyle(20);
   hRatioBlank->SetMarkerSize(1.2);
   hRatioBlank->GetXaxis()->SetTitle("ak R=0.4 Jet p_{T} (GeV/c)");
   hRatioBlank->GetXaxis()->SetLabelFont(42);
   hRatioBlank->GetXaxis()->SetLabelOffset(0.01);
   hRatioBlank->GetXaxis()->SetLabelSize(0.045);
   hRatioBlank->GetXaxis()->SetTitleSize(0.055);
   hRatioBlank->GetXaxis()->SetTitleFont(42);
   hRatioBlank->GetYaxis()->SetTitle("CMS/ATLAS #frac{d^{2}#sigma}{dp_{T} d#eta} nb");
   hRatioBlank->GetYaxis()->SetLabelFont(42);
   hRatioBlank->GetYaxis()->SetLabelOffset(0.01);
   hRatioBlank->GetYaxis()->SetLabelSize(0.045);
   hRatioBlank->GetYaxis()->SetTitleSize(0.055);
   hRatioBlank->GetYaxis()->SetTitleOffset(1.5);
   hRatioBlank->GetYaxis()->SetTitleFont(42);
   hRatioBlank->GetZaxis()->SetLabelFont(42);
   hRatioBlank->GetZaxis()->SetLabelSize(0.045);
   hRatioBlank->GetZaxis()->SetTitleSize(0.035);
   hRatioBlank->GetZaxis()->SetTitleFont(42);
   hRatioBlank->Draw();   
//   hRatioATLAS->Scale(5.3/4);
//   hFitRatioATLAS->Scale(5.3/4);
   hFitRatioATLAS->Draw("ap,same");
   hRatioATLAS->Draw("ap,same");
   hRatioATLASHist->Draw("ap,same");
   
   cRatio_pp->SaveAs("Plots/CMSfit_ATLASfit_ratio_pp.pdf");
   

   
}
コード例 #12
0
ファイル: shapehist.C プロジェクト: kmcdermo/AnalysisCode
void shapehist() {
    bool makeplot  = true;

    double bins[] = {250., 266, 285., 305., 330., 360., 400., 450., 500., 550., 1000.};
    int nbins = 10;

    TH1F* hisdt = new TH1F("data_obs"                 , "", nbins, bins);
    TH1F* hisdm = new TH1F("DM"                       , "", nbins, bins);
    TH1F* hiszj = new TH1F("ZJets"                    , "", nbins, bins);
    TH1F* hisdi = new TH1F("Dibosons"                 , "", nbins, bins);
    TH1F* histt = new TH1F("ttbar"                    , "", nbins, bins);
    TH1F* hisst = new TH1F("singletop"                , "", nbins, bins);
    TH1F* hisqc = new TH1F("QCD"                      , "", nbins, bins);
    TH1F* hiswj = new TH1F("WJets"                    , "", nbins, bins);
    TH1F* hiszn = new TH1F("Znunu"                    , "", nbins, bins);
    TH1F* hist1 = new TH1F("hist1"                    , "", nbins, bins);
    TH1F* hist2 = new TH1F("hist2"                    , "", nbins, bins);
    TH1F* hiswu = new TH1F("WJets_Stat_WJETSUp"       , "", nbins, bins);
    TH1F* hiswd = new TH1F("WJets_Stat_WJETSDown"     , "", nbins, bins);
    TH1F* hiszu = new TH1F("Znunu_Stat_ZNUNUUp"       , "", nbins, bins);
    TH1F* hiszd = new TH1F("Znunu_Stat_ZNUNUDown"     , "", nbins, bins);

    hisdt->Sumw2();
    hisdm->Sumw2();
    hiszn->Sumw2();
    hiswj->Sumw2();
    hiszj->Sumw2();
    hisdi->Sumw2();
    histt->Sumw2();
    hisst->Sumw2();
    hisqc->Sumw2();
    hiszu->Sumw2();
    hiszd->Sumw2();
    hiswu->Sumw2();
    hiswd->Sumw2();
    hist1->Sumw2();
    hist2->Sumw2();

    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/met/ztree.root",    "tree/tree", 1, 1.0 , hiszn);
    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/bkgz/ztree.root",   "tree/tree", 1, 19.7, hist1);
    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/bkgnowz/ztree.root","tree/tree", 1, 19.7, hist1);

    hiszn->Add(hist1, -1.0);

    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/met/wtree.root",    "tree/tree", 2, 1.0 , hiswj);
    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/bkgw/wtree.root",   "tree/tree", 2, 19.7, hist2);
    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/bkgnowz/wtree.root","tree/tree", 2, 19.7, hist2);

    hiswj->Add(hist2, -1.0);

    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/dmVM100/reducedtree.root"  ,  "tree/tree", 0, 19.7     , hisdm);
    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/met/reducedtree.root"      ,  "tree/tree", 0, 1.0      , hisdt);
    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/zjets/reducedtree.root"    ,  "tree/tree", 0, 19.7     , hiszj);
    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/dibosons/reducedtree.root" ,  "tree/tree", 0, 19.7     , hisdi);
    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/ttbar/reducedtree.root"    ,  "tree/tree", 0, 19.7     , histt);
    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/singletop/reducedtree.root",  "tree/tree", 0, 19.7     , hisst);
    fillhist("/home/avartak/CMS/MonoX/CMSSW_5_3_12/src/MonoXAnalysis/AnalysisStep/trees/qcd/reducedtree.root"      ,  "tree/tree", 0, 19.7*1.3 , hisqc);

    for (int i = 1; i <= nbins; i++) {
        hiszu->SetBinContent(i, hiszn->GetBinContent(i) + hiszn->GetBinError(i));
        hiszd->SetBinContent(i, hiszn->GetBinContent(i) - hiszn->GetBinError(i));
        hiswu->SetBinContent(i, hiswj->GetBinContent(i) + hiswj->GetBinError(i));
        hiswd->SetBinContent(i, hiswj->GetBinContent(i) - hiswj->GetBinError(i));
    }

    for (int i = 1; i <= nbins; i++) {
        if (hiszj->GetBinContent(i) == 0) hiszj->SetBinContent(i, 0.001);
        if (hisdi->GetBinContent(i) == 0) hisdi->SetBinContent(i, 0.001);
        if (histt->GetBinContent(i) == 0) histt->SetBinContent(i, 0.001);
        if (hisst->GetBinContent(i) == 0) hisst->SetBinContent(i, 0.001);
        if (hisqc->GetBinContent(i) == 0) hisqc->SetBinContent(i, 0.001);

        hiszj->SetBinError(i, 0.5*hiszj->GetBinContent(i));
        hisdi->SetBinError(i, 0.5*hisdi->GetBinContent(i));
        histt->SetBinError(i, 0.5*histt->GetBinContent(i));
        hisst->SetBinError(i, 0.5*hisst->GetBinContent(i));
        hisqc->SetBinError(i, 0.5*hisqc->GetBinContent(i));
    }


    std::cout << "data_obs  : " << hisdt->Integral() << std::endl;
    std::cout << "DM        : " << hisdm->Integral() << std::endl;
    std::cout << "Znunu     : " << hiszn->Integral() << std::endl;
    std::cout << "WJets     : " << hiswj->Integral() << std::endl;
    std::cout << "ZJets     : " << hiszj->Integral() << std::endl;
    std::cout << "Dibosons  : " << hisdi->Integral() << std::endl;
    std::cout << "ttbar     : " << histt->Integral() << std::endl;
    std::cout << "singletop : " << hisst->Integral() << std::endl;
    std::cout << "QCD       : " << hisqc->Integral() << std::endl;

    if (makeplot) {
    hiszj->Add(hisdi);
    hiszj->Add(histt);
    hiszj->Add(hisst);
    hiszj->Add(hisqc);

    hiswj->Add(hiszj);
    hiszn->Add(hiswj);
    hiszu->Add(hiswj);
    hiszd->Add(hiswj);

    hiszj->SetLineColor(kGreen+2);
    hiswj->SetLineColor(kRed);
    hiszn->SetLineColor(kBlue);
    hiszj->SetLineWidth(2);
    hiswj->SetLineWidth(2);
    hiszn->SetLineWidth(2);

    hiszu->SetMarkerSize(0);
    hiszu->SetMarkerColor(0);
    hiszu->SetLineColor(kOrange);
    hiszu->SetFillColor(kOrange);

    hiszd->SetMarkerSize(0);
    hiszd->SetMarkerColor(0);
    hiszd->SetLineColor(10);
    hiszd->SetFillColor(10);

    hiszj->SetMarkerSize(0);
    hiswj->SetMarkerSize(0);
    hiszn->SetMarkerSize(0);

    hisdm->SetMarkerSize(0);
    hisdm->SetLineStyle(7);
    hisdm->SetLineWidth(2);

    TCanvas* canvas = new TCanvas("canvas", "canvas", 500, 500);
    canvas->SetRightMargin(0.075);
    canvas->SetTopMargin(0.075);
    TH1* frame = canvas->DrawFrame(250., 2.0, 1000., 100000.0, "");
    frame->GetXaxis()->SetTitle("E_{T}^{miss} [GeV]");
    frame->GetXaxis()->SetLabelSize(0.9*frame->GetXaxis()->GetLabelSize());
    frame->GetYaxis()->SetLabelSize(0.9*frame->GetYaxis()->GetLabelSize());
    canvas->SetLogy();
    frame->Draw();
    hiszu->Draw("HIST SAME");
    hiszd->Draw("HIST SAME");
    hiszn->Draw("HIST SAME");
    hiswj->Draw("HIST SAME");
    hiszj->Draw("HIST SAME");
    hisdm->Draw("HIST SAME");
    hisdt->Draw("PE SAME");

    canvas->RedrawAxis();
    }

    else {
    TFile* outfile = new TFile("monojet_8TeV_shape_histogram.root", "RECREATE");
    hisdt->Write();
    hisdm->Write();
    hiszn->Write();
    hiswj->Write();
    hiszj->Write();
    hisdi->Write();
    histt->Write();
    hisst->Write();
    hisqc->Write();
    hiszu->Write();
    hiszd->Write();
    hiswu->Write();
    hiswd->Write();
    outfile->Close();
    }
}
コード例 #13
0
ファイル: SignificanceT2tt.C プロジェクト: haweber/OneLepStop
void SignfificanceT2tt(bool pval, int exp=0){


    TFile *f = TFile::Open("Significances2DHistograms_T2tt.root");
    TH2F *h;
    if(pval){
        if(exp==0) h = (TH2F*)f->Get("hpObs");
        else if(exp==1) h = (TH2F*)f->Get("hpExpPosteriori");
        else if(exp==2) h = (TH2F*)f->Get("hpExpPriori");
    }
    else {
        if(exp==0) h = (TH2F*)f->Get("hObs");
        else if(exp==1) h = (TH2F*)f->Get("hExpPosteriori");
        else if(exp==2) h = (TH2F*)f->Get("hExpPriori");
    }
    h->GetXaxis()->SetTitle("m_{#tilde{t}} [GeV]");
    h->GetXaxis()->SetLabelFont(42);
    h->GetXaxis()->SetLabelSize(0.035);
    h->GetXaxis()->SetTitleSize(0.05);
    h->GetXaxis()->SetTitleOffset(1.2);
    h->GetXaxis()->SetTitleFont(42);
    h->GetYaxis()->SetTitle("m_{#tilde{#chi}_{1}^{0}} [GeV]");
    h->GetYaxis()->SetLabelFont(42);
    h->GetYaxis()->SetLabelSize(0.035);
    h->GetYaxis()->SetTitleSize(0.05);
    h->GetYaxis()->SetTitleOffset(1.35);
    h->GetYaxis()->SetTitleFont(42);
    double maximum = h->GetMaximum();
    double minimum = h->GetMinimum();
    double sigmin = 99; int sigminx=-1; int sigminy=-1; if(pval) sigmin = -99;
    h->GetZaxis()->SetRangeUser(minimum,maximum);
    for(int x = 1; x<=h->GetNbinsX();++x){
        for(int y = 1; y<=h->GetNbinsX();++y){
            if(!pval&&h->GetBinContent(x,y)<sigmin){ sigmin =h->GetBinContent(x,y); sigminx = x; sigminy = y; }
            if( pval&&h->GetBinContent(x,y)>sigmin){ sigmin =h->GetBinContent(x,y); sigminx = x; sigminy = y; }
            if(!pval&&h->GetXaxis()->GetBinLowEdge(x)<h->GetYaxis()->GetBinLowEdge(y)+75) h->SetBinContent(x,y,-999);
            if(h->GetXaxis()->GetBinLowEdge(x)<374) continue;
            if(h->GetXaxis()->GetBinLowEdge(x)>424) continue;
            if(h->GetYaxis()->GetBinLowEdge(y)<199) continue;
            if(h->GetYaxis()->GetBinLowEdge(y)>249) continue;
            if(!pval&&h->GetBinContent(x,y)>0.3) h->SetBinContent(x,y,0.05);
        }
    }
    h->GetZaxis()->SetRangeUser(minimum,maximum);
    if(!pval) cout << "minimal significance " << sigmin << " at " << h->GetXaxis()->GetBinLowEdge(sigminx) << "-" << h->GetYaxis()->GetBinLowEdge(sigminy) << endl;
    else cout << "maximal p- value " << sigmin << " at " << h->GetXaxis()->GetBinLowEdge(sigminx) << "-" << h->GetYaxis()->GetBinLowEdge(sigminy) << endl;
    
   TCanvas *c1 = new TCanvas("c1", "c1",50,50,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   gStyle->SetErrorX(0.5); 
   //c1->Range(-6.311689,-1.891383,28.75325,4.56342);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   //c1->SetLogy();
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.15);
//   c1->SetRightMargin(0.05);
    c1->SetRightMargin(0.15);
   c1->SetTopMargin(0.07);
   c1->SetBottomMargin(0.15);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   gStyle->SetHatchesLineWidth(0);

   TH1F *hSum = new TH1F("hSum","",10,100,900);
   hSum->SetMinimum(0.);
   hSum->SetMaximum(550);
   hSum->SetDirectory(0);
   hSum->SetStats(0);
    hSum->Draw();
    hSum->GetYaxis()->SetRangeUser(0,500);
    hSum->GetXaxis()->SetRangeUser(100,900);

   Int_t ci;   // for color index setting
   ci = TColor::GetColor("#000099");
   hSum->SetLineColor(ci);
   hSum->SetLineStyle(0);
   hSum->SetMarkerStyle(20);
   hSum->GetXaxis()->SetTitle("m_{#tilde{t}} [GeV]");
   //hSum->GetXaxis()->SetBit(TAxis::kLabelsVert);
   hSum->GetXaxis()->SetLabelFont(42);
   //hSum->GetXaxis()->SetLabelOffset(0.005);
   hSum->GetXaxis()->SetLabelSize(0.035);
   hSum->GetXaxis()->SetTitleSize(0.06);
   hSum->GetXaxis()->SetTitleOffset(1.2);
   hSum->GetXaxis()->SetTitleFont(42);
   hSum->GetYaxis()->SetTitle("m_{#tilde{#chi}}_{1}^{0} [GeV]");
   hSum->GetYaxis()->SetLabelFont(42);
   //hSum->GetYaxis()->SetLabelOffset(0.007);
   hSum->GetYaxis()->SetLabelSize(0.035);
   hSum->GetYaxis()->SetTitleSize(0.05);
   hSum->GetYaxis()->SetTitleOffset(1.3);
   hSum->GetYaxis()->SetTitleFont(42);
    
   /*
    TLegend *legO = new TLegend(0.175,0.675,0.50,0.855,NULL,"brNDC");
    //legO-> SetNColumns(2);
    legO->SetBorderSize(0);
    legO->SetTextSize(0.04);
    legO->SetTextFont(42);
    legO->SetLineColor(1);
    legO->SetLineStyle(1);
    legO->SetLineWidth(2);
    legO->SetFillColor(0);
    legO->SetFillStyle(1001);
    legO->SetHeader("Observed");
    legO->AddEntry(gObs, "unpolarized","l");
    legO->AddEntry(gObsR, "right-handed","l");
    legO->AddEntry(gObsL, "left-handed","l");
    */
    
    TGraph* graphWhite = new TGraph(5);
    graphWhite->SetName("white");
    graphWhite->SetTitle("white");
    graphWhite->SetFillColor(kWhite);
    graphWhite->SetFillStyle(1001);
    graphWhite->SetLineColor(kBlack);
    graphWhite->SetLineStyle(1);
    graphWhite->SetLineWidth(3);
    graphWhite->SetPoint(0,100, 500);
    graphWhite->SetPoint(1,900, 500);
    graphWhite->SetPoint(2,900, 500*0.75);
    graphWhite->SetPoint(3,100, 500*0.75);
    graphWhite->SetPoint(4,100, 500);
    
    Float_t diagX[4] = {175.+25.,175.+25.+5000,175.-25.+5000,175.-25.};
    Float_t diagY[4] = {0,5000,5000,0};
    TGraph *gdiagonal = new TGraph(4, diagX, diagY);
    gdiagonal->SetName("MtopDiagonal");
    gdiagonal->SetFillColor(kWhite);
    //#gdiagonal->SetFillColor(18);
    TLine* ldiagonal = new TLine(175,0.,650-25.,450);
    //TLine* ldiagonal = new TLine(175.,25,175+500,500);
    ldiagonal->SetLineColor(kGray);
    ldiagonal->SetLineStyle(2);
    TLatex* tdiagonal = new TLatex(400-2.5, 400-172.5,"m_{#tilde{t}} = m_{t} + m_{#tilde{#chi}_{1}^{0}}");
    //tdiagonal->SetTextAngle(TMath::RadToDeg()*TMath::ATan(float(800)/float(500)));
    tdiagonal->SetTextAngle(56.31);
    tdiagonal->SetTextColor(kGray+2);
    tdiagonal->SetTextAlign(11);
    tdiagonal->SetTextSize(0.025);

    TLine* l2 = new TLine(150,75,585,500);
    l2->SetLineColor(kGray);
    l2->SetLineStyle(2);
//    if(killlowdiag){
//        l2->SetX1(200); l2->SetY1(0); l2->SetX2(600); l2->SetY2(400);
//    }
    TLatex *t2 = new TLatex(300, 300-72.5,"m_{#tilde{t}} = m_{W} + m_{#tilde{#chi}_{1}^{0}}");
    //t2->SetTextAngle(TMath::RadToDeg()*TMath::ATan(float(800)/float(500)));
    t2->SetTextAngle(56.31);
    t2->SetTextColor(kGray+2);
    t2->SetTextAlign(11);
    t2->SetTextSize(0.025);
    
    


    hSum->Draw("axis");
    h->Draw("COLZsame");

    gdiagonal->Draw("FSAME");
    ldiagonal->Draw("LSAME");
    l2->Draw();
//    if(!killlowdiag) t2->Draw();
    tdiagonal->Draw("SAME");
    graphWhite->Draw("FSAME");
    graphWhite->Draw("LSAME");

    string textstring = "observed";
    if(exp!=0) textstring = "expected";
    TLatex* textOE= new TLatex(0.175,0.715,textstring.c_str() );
    textOE->SetNDC();
    textOE->SetTextAlign(13);
    textOE->SetTextFont(42);
    textOE->SetTextSize(0.042);
    textOE->Draw();
    

    TLatex* textModelLabel= new TLatex(0.175,0.92,"pp #rightarrow #tilde{t} #tilde{t}*, #tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}");
    //TLatex* textModelLabel= new TLatex(0.175,0.92,"pp #rightarrow #tilde{t} #tilde{t}*, #tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}");
    //TLatex* textModelLabel= new TLatex(0.175,0.92,"#tilde{#chi} ");
    textModelLabel->SetNDC();
    textModelLabel->SetTextAlign(13);
    textModelLabel->SetTextFont(42);
    textModelLabel->SetTextSize(0.042);
    textModelLabel->Draw();
    TLatex* textlLabel= new TLatex(0.175,0.85,"NLO+NLL significance");
    textlLabel->SetNDC();
    textlLabel->SetTextAlign(13);
    textlLabel->SetTextFont(42);
    textlLabel->SetTextSize(0.042);
    textlLabel->Draw();
    
    string psig = "significance [#sigma]";
    if(pval) psig = "p-value";
    TLatex * ztex = new TLatex(0.985,0.92,psig.c_str() );
    ztex->SetNDC();
    ztex->SetTextAlign(31);
    ztex->SetTextFont(42);
    ztex->SetTextSize(0.045);
    ztex->SetTextAngle(90);
    ztex->SetLineWidth(2);
    ztex->Draw();
    
    //final CMS style
    TLatex *tLumi = new TLatex(0.81,0.944,"2.3 fb^{-1} (13 TeV)");
    tLumi->SetNDC();
    tLumi->SetTextAlign(31);
    tLumi->SetTextFont(42);
    tLumi->SetTextSize(0.042);
    tLumi->SetLineWidth(2);
    tLumi->Draw();
    TLatex *tCMS = new TLatex(0.152,0.944,"CMS");
    tCMS->SetNDC();
    tCMS->SetTextAlign(11);
    tCMS->SetTextFont(61);
    tCMS->SetTextSize(0.0525);
    tCMS->SetLineWidth(2);
    tCMS->Draw();
    TLatex *tPrel = new TLatex(0.265,0.944,"Preliminary");
    tPrel->SetNDC();
    tPrel->SetTextAlign(11);
    tPrel->SetTextFont(52);
    tPrel->SetTextSize(0.042);
    tPrel->SetLineWidth(2);
    tPrel->Draw();
    
   c1->Modified();
   c1->cd();
    c1->Update();
   c1->SetSelected(c1);

}
コード例 #14
0
ファイル: Polarization.C プロジェクト: haweber/OneLepStop
void Polarization(){

    TGraph *gObs;
    TGraph *gExp;
    TGraph *gObsL;
    TGraph *gExpL;
    TGraph *gObsR;
    TGraph *gExpR;
    
    TFile *fc = TFile::Open("Limits2DHistograms_T2tt_postfit.root");
    TFile *fl = TFile::Open("Limits2DHistograms_T2tt_lefthanded_postfit.root");
    TFile *fr = TFile::Open("Limits2DHistograms_T2tt_righthanded_postfit.root");
    
    TGraph *g;
    fc->cd();
    g = (TGraph*)fc->Get("gObs");
    gObs = (TGraph*)g->Clone("Obs");
    g = (TGraph*)fc->Get("gExp");
    gExp = (TGraph*)g->Clone("Exp");
    fl->cd();
    g = (TGraph*)fl->Get("gObs_2");
    gObsL = (TGraph*)g->Clone("ObsL");
    g = (TGraph*)fl->Get("gExp_2");
    gExpL = (TGraph*)g->Clone("ExpL");
    fr->cd();
    g = (TGraph*)fr->Get("gObs");
    gObsR = (TGraph*)g->Clone("ObsR");
    g = (TGraph*)fr->Get("gExp");
    gExpR = (TGraph*)g->Clone("ExpR");
    
    gObs->SetLineWidth(4);
    gExp->SetLineWidth(4);
    gObsL->SetLineWidth(2);
    gExpL->SetLineWidth(2);
    gObsR->SetLineWidth(2);
    gExpR->SetLineWidth(2);
    gObs->SetLineStyle(1);
    gExp->SetLineStyle(7);
    gObsL->SetLineStyle(1);
    gExpL->SetLineStyle(7);
    gObsR->SetLineStyle(1);
    gExpR->SetLineStyle(7);
    gObs->SetLineColor(kBlack);
    gExp->SetLineColor(kBlack);
    gObsL->SetLineColor(kBlue);
    gExpL->SetLineColor(kBlue);
    gObsR->SetLineColor(kRed);
    gExpR->SetLineColor(kRed);
    if(killlowdiag){
    for( int i = gObs->GetN()-1; i>=0;--i){
        double x,y;
        gObs->GetPoint(i,x,y);
        if(x-y<172.5) gObs->RemovePoint(i);
    }
    for( int i = gExp->GetN()-1; i>=0;--i){
        double x,y;
        gExp->GetPoint(i,x,y);
        if(x-y<172.5) gExp->RemovePoint(i);
    }
    }
    for( int i = gObsL->GetN()-1; i>=0;--i){
        double x,y;
        gObsL->GetPoint(i,x,y);
        if(x-y<172.5) gObsL->RemovePoint(i);
    }
    for( int i = gObsR->GetN()-1; i>=0;--i){
        double x,y;
        gObsR->GetPoint(i,x,y);
        if(x-y<172.5) gObsR->RemovePoint(i);
    }
    for( int i = gExpL->GetN()-1; i>=0;--i){
        double x,y;
        gExpL->GetPoint(i,x,y);
        if(x-y<172.5) gExpL->RemovePoint(i);
    }
    for( int i = gExpR->GetN()-1; i>=0;--i){
        double x,y;
        gExpR->GetPoint(i,x,y);
        if(x-y<172.5) gExpR->RemovePoint(i);
    }

    
   TCanvas *c1 = new TCanvas("c1", "c1",50,50,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   gStyle->SetErrorX(0.5); 
   //c1->Range(-6.311689,-1.891383,28.75325,4.56342);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   //c1->SetLogy();
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.15);
   c1->SetRightMargin(0.05);
   c1->SetTopMargin(0.07);
   c1->SetBottomMargin(0.15);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
   gStyle->SetHatchesLineWidth(0);

   TH1F *hSum = new TH1F("hSum","",10,150,950);
   hSum->SetMinimum(0.);
   hSum->SetMaximum(550);
   hSum->SetDirectory(0);
   hSum->SetStats(0);
    hSum->Draw();
    hSum->GetYaxis()->SetRangeUser(0,500);
    hSum->GetXaxis()->SetRangeUser(150,950);

   Int_t ci;   // for color index setting
   ci = TColor::GetColor("#000099");
   hSum->SetLineColor(ci);
   hSum->SetLineStyle(0);
   hSum->SetMarkerStyle(20);
   hSum->GetXaxis()->SetTitle("m_{#tilde{t}} [GeV]");
   //hSum->GetXaxis()->SetBit(TAxis::kLabelsVert);
   hSum->GetXaxis()->SetLabelFont(42);
   //hSum->GetXaxis()->SetLabelOffset(0.005);
   hSum->GetXaxis()->SetLabelSize(0.035);
   hSum->GetXaxis()->SetTitleSize(0.06);
   hSum->GetXaxis()->SetTitleOffset(1.2);
   hSum->GetXaxis()->SetTitleFont(42);
   hSum->GetYaxis()->SetTitle("m_{#tilde{#chi}}_{1}^{0} [GeV]");
   hSum->GetYaxis()->SetLabelFont(42);
   //hSum->GetYaxis()->SetLabelOffset(0.007);
   hSum->GetYaxis()->SetLabelSize(0.035);
   hSum->GetYaxis()->SetTitleSize(0.05);
   hSum->GetYaxis()->SetTitleOffset(1.3);
   hSum->GetYaxis()->SetTitleFont(42);
    
    //TLegend *leg = new TLegend(0.4992416,0.4811189,0.898906,0.7503497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.4992416,0.4811189,0.698906,0.7503497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.6992416,0.2811189,0.898906,0.4503497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.6992416,0.3311189,0.898906,0.7903497,NULL,"brNDC");
    //TLegend *leg = new TLegend(0.7582416,0.4211189,0.912,0.8043497,NULL,"brNDC");
    TLegend *legE = new TLegend(0.51,0.675,0.81,0.855,NULL,"brNDC");
    //leg-> SetNColumns(2);
    legE->SetBorderSize(0);
    legE->SetTextSize(0.04);
    legE->SetTextFont(42);
    legE->SetLineColor(1);
    legE->SetLineStyle(1);
    legE->SetLineWidth(2);
    legE->SetFillColor(0);
    legE->SetFillStyle(1001);
    legE->SetHeader("Expected");
    legE->AddEntry(gExp, "unpolarized","l");
    legE->AddEntry(gExpR, "right-handed","l");
    legE->AddEntry(gExpL, "left-handed","l");
    
    TLegend *legO = new TLegend(0.175,0.675,0.50,0.855,NULL,"brNDC");
    //legO-> SetNColumns(2);
    legO->SetBorderSize(0);
    legO->SetTextSize(0.04);
    legO->SetTextFont(42);
    legO->SetLineColor(1);
    legO->SetLineStyle(1);
    legO->SetLineWidth(2);
    legO->SetFillColor(0);
    legO->SetFillStyle(1001);
    legO->SetHeader("Observed");
    legO->AddEntry(gObs, "unpolarized","l");
    legO->AddEntry(gObsR, "right-handed","l");
    legO->AddEntry(gObsL, "left-handed","l");
    
    
    TGraph* graphWhite = new TGraph(5);
    graphWhite->SetName("white");
    graphWhite->SetTitle("white");
    graphWhite->SetFillColor(kWhite);
    graphWhite->SetFillStyle(1001);
    graphWhite->SetLineColor(kBlack);
    graphWhite->SetLineStyle(1);
    graphWhite->SetLineWidth(3);
    graphWhite->SetPoint(0,150, 500);
    graphWhite->SetPoint(1,950, 500);
    graphWhite->SetPoint(2,950, 500*0.6666666667);
    graphWhite->SetPoint(3,150, 500*0.6666666667);
    graphWhite->SetPoint(4,150, 500);
    
    Float_t diagX[4] = {175.+25.,175.+25.+5000,175.-25.+5000,175.-25.};
    Float_t diagY[4] = {0,5000,5000,0};
    TGraph *gdiagonal = new TGraph(4, diagX, diagY);
    gdiagonal->SetName("MtopDiagonal");
    gdiagonal->SetFillColor(kWhite);
    //#gdiagonal->SetFillColor(18);
    TLine* ldiagonal = new TLine(175,0.,650-25.,450);
    //TLine* ldiagonal = new TLine(175.,25,175+500,500);
    ldiagonal->SetLineColor(kGray);
    ldiagonal->SetLineStyle(2);
    TLatex* tdiagonal = new TLatex(400-2.5, 400-172.5,"m_{#tilde{t}} = m_{t} + m_{#tilde{#chi}_{1}^{0}}");
    //tdiagonal->SetTextAngle(TMath::RadToDeg()*TMath::ATan(float(800)/float(500)));
    tdiagonal->SetTextAngle(56.31);
    tdiagonal->SetTextColor(kGray+2);
    tdiagonal->SetTextAlign(11);
    tdiagonal->SetTextSize(0.025);

    TLine* l2 = new TLine(150,75,585,500);
    l2->SetLineColor(kGray);
    l2->SetLineStyle(2);
    if(killlowdiag){
        l2->SetX1(200); l2->SetY1(0); l2->SetX2(600); l2->SetY2(400);
    }
    TLatex *t2 = new TLatex(300, 300-72.5,"m_{#tilde{t}} = m_{W} + m_{#tilde{#chi}_{1}^{0}}");
    //t2->SetTextAngle(TMath::RadToDeg()*TMath::ATan(float(800)/float(500)));
    t2->SetTextAngle(56.31);
    t2->SetTextColor(kGray+2);
    t2->SetTextAlign(11);
    t2->SetTextSize(0.025);

    hSum->Draw("axis");
    
    gExpR->Draw("c");
    gExpL->Draw("c");
    gExp->Draw("c");
    gObsR->Draw("c");
    gObsL->Draw("c");
    gObs->Draw("c");

    gdiagonal->Draw("FSAME");
    ldiagonal->Draw("LSAME");
    l2->Draw();
    if(!killlowdiag) t2->Draw();
    tdiagonal->Draw("SAME");
    graphWhite->Draw("FSAME");
    graphWhite->Draw("LSAME");

    legE->Draw();
    legO->Draw();
    
    TLatex* textModelLabel= new TLatex(0.175,0.92,"pp #rightarrow #tilde{t} #tilde{t}*, #tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}  NLO+NLL exclusion");
    //TLatex* textModelLabel= new TLatex(0.175,0.92,"pp #rightarrow #tilde{t} #tilde{t}*, #tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}");
    //TLatex* textModelLabel= new TLatex(0.175,0.92,"#tilde{#chi} ");
    textModelLabel->SetNDC();
    textModelLabel->SetTextAlign(13);
    textModelLabel->SetTextFont(42);
    textModelLabel->SetTextSize(0.042);
    textModelLabel->Draw();
    
    //final CMS style
    TLatex *tLumi = new TLatex(0.95,0.944,"2.3 fb^{-1} (13 TeV)");
    tLumi->SetNDC();
    tLumi->SetTextAlign(31);
    tLumi->SetTextFont(42);
    tLumi->SetTextSize(0.042);
    tLumi->SetLineWidth(2);
    tLumi->Draw();
    TLatex *tCMS = new TLatex(0.152,0.944,"CMS");
    tCMS->SetNDC();
    tCMS->SetTextAlign(11);
    tCMS->SetTextFont(61);
    tCMS->SetTextSize(0.0525);
    tCMS->SetLineWidth(2);
    tCMS->Draw();
    TLatex *tPrel = new TLatex(0.265,0.944,"Preliminary");
    tPrel->SetNDC();
    tPrel->SetTextAlign(11);
    tPrel->SetTextFont(52);
    tPrel->SetTextSize(0.042);
    tPrel->SetLineWidth(2);
    tPrel->Draw();
    
   c1->Modified();
   c1->cd();
    c1->Update();
   c1->SetSelected(c1);

}
コード例 #15
0
ファイル: ExclusionPlot.C プロジェクト: hooberman/UserCode
void CommandMSUGRA(TString plotName_,Int_t tanBeta_, Bool_t plotLO_){
  
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetPalette(1); 
  gStyle->SetTextFont(42);
  
  //convert tanb value to string
  std::stringstream tmp;
  tmp << tanBeta_;
  TString tanb( tmp.str() );
  
  // Output file
  cout << " create " << plotName_ << endl;
  TFile* output = new TFile( plotName_, "RECREATE" );
  if ( !output || output->IsZombie() ) { std::cout << " zombie alarm output is a zombie " << std::endl; }
  
  //-----------------------------------
  //set old exclusion Limits
  //-----------------------------------

  TGraph* LEP_ch = set_lep_ch(tanBeta_);
  TGraph* LEP_sl = set_lep_sl(tanBeta_);             //slepton curve
  TGraph* TEV_sg_cdf = set_tev_sg_cdf(tanBeta_);     //squark gluino cdf
  TGraph* TEV_sg_d0 = set_tev_sg_d0(tanBeta_);       //squark gluino d0
  //TGraph* TEV_tlp_cdf = set_tev_tlp_cdf(tanBeta_); //trilepton cdf
  //TGraph* TEV_tlp_d0 = set_tev_tlp_d0(tanBeta_);   //trilepton d0
  TGraph* stau = set_tev_stau(tanBeta_);             //stau 
  //TGraph* NoEWSB = set_NoEWSB(tanBeta_); 

  TGraph* TEV_sn_d0_1 = set_sneutrino_d0_1(tanBeta_);
  TGraph* TEV_sn_d0_2 = set_sneutrino_d0_2(tanBeta_);

  //-----------------------------------
  // constant sqquark and gluino lines
  //-----------------------------------

  const unsigned int nlines = 4;

  TF1* lnsq[nlines];
  TF1* lngl[nlines];
  
  TLatex* sq_text[nlines];
  TLatex* gl_text[nlines];

  for(unsigned int i = 0; i < nlines; i++){
    lnsq[i]    = constant_squark(tanBeta_,i);
    sq_text[i] = constant_squark_text(i,*lnsq[i],tanBeta_);
    lngl[i]    = constant_gluino(tanBeta_,i);
    gl_text[i] = constant_gluino_text(i,*lngl[i]);
  }

  //-----------------------------------
  // Legends
  //-----------------------------------

  TLegend* legst     = makeStauLegend(0.05,tanBeta_);
  TLegend* legexp    = makeExpLegend( *TEV_sg_cdf,*TEV_sg_d0,*LEP_ch,*LEP_sl,*TEV_sn_d0_1,0.035,tanBeta_);
  //TLegend* legNoEWSB = makeNoEWSBLegend(0.05,tanBeta_);

  //-----------------------------------
  // make Canvas
  //-----------------------------------

  TCanvas* cvsSys = new TCanvas("cvsnm","cvsnm",0,0,800,600);
  gStyle->SetOptTitle(0);
  cvsSys->SetFillColor(0);
  cvsSys->GetPad(0)->SetRightMargin(0.07);
  cvsSys->Range(-120.5298,26.16437,736.0927,500);
  //cvsSys->Range(-50.5298,26.16437,736.0927,500);
  cvsSys->SetFillColor(0);
  cvsSys->SetBorderMode(0);
  cvsSys->GetPad(0)->SetBorderSize(2);
  cvsSys->GetPad(0)->SetLeftMargin(0.1407035);
  cvsSys->GetPad(0)->SetTopMargin(0.08);
  cvsSys->GetPad(0)->SetBottomMargin(0.13);
  cvsSys->SetTitle("tan#beta="+tanb);
 
  output->cd();
  
  //and now
  //the exclusion limits
  TGraphErrors* First ;
  //TGraphErrors* FirstDummy ;
  TGraphErrors* Second;
  TGraphErrors* Third;
  TGraphErrors* Second_up;
  TGraphErrors* Second_low;
  TGraphErrors* expband;
  TGraphErrors* obs2010;

  if (tanBeta_		== 3) {
    //First		= getObserved_NLOunc();
    //FirstDummy	= getObserved_NLOunc();
  } else {
    //First		= getNLOobsTanbeta10();
    //First		= getNLOobsTanbeta10_smooth();
    //First		= getNLOobsTanbeta10_funky();
    First		= getNLOobsTanbeta10();
    //FirstDummy	= getObserved_NLOunc();
    //Second		= getNLOexpTanbeta10();
    Second		= getNLOexpTanbeta10();
    Second_up		= getNLOexpUpTanbeta10();
    Second_low		= getNLOexpDownTanbeta10();
    Third		= getNLOexpTanbeta10();
    expband		= getNLOexpTanbeta10_band();
    obs2010		= getNLOobsTanbeta10_2010();
    //Second_up		= getExpected_NLO_tanBeta3_up();
    //Second_low	= getExpected_NLO_tanBeta3_low();
  }
  //Third		= getExpected_NLOunc();//getLO_jetMultis();
  //Second		= getLO_signalCont();

  TGraph *grObserved3p5_shape = getObserved3p5_shape();
  TGraph *grExpected3p5_shape = getExpected3p5_shape();

//   First->SetMarkerColor(kWhite);
//   First->GetXaxis()->SetRangeUser(2.,500.);
//   First->GetYaxis()->SetRangeUser(80,500);
//   if(tanBeta_ == 50) First->GetXaxis()->SetRangeUser(200,500);
//   First->GetXaxis()->SetTitle("m_{0} (GeV)");
//   First->GetYaxis()->SetTitle("m_{1/2} (GeV)");
//   First->GetYaxis()->SetTitleOffset(0.8);

  double m0min = 0;
  if (tanBeta_ == 50) m0min=200;
  TH2D* hist = new TH2D("h","h",100,m0min,m0max,100,120,m12max);
  hist->Draw();  
  hist->GetXaxis()->SetTitle("m_{0} (GeV/c^{2})");
  hist->GetYaxis()->SetTitle("m_{1/2} (GeV/c^{2})");
  hist->GetYaxis()->SetTitleOffset(1.);
  hist->GetXaxis()->SetNdivisions(506);
  //  if (tanBeta_ == 50)  hist->GetXaxis()->SetNdivisions(504);
  hist->GetYaxis()->SetNdivisions(506);

  //int col[]={2,3,4};

  
  //TFile *f = TFile::Open("exclusion_Spring11_CLs.root");        
  //TFile *f = TFile::Open("exclusion_Fall10_tcmet_JPT.root"); 
  //TFile *f = TFile::Open("exclusion_Fall10_pfmet_pfjets.root"); 
  //TFile *f = new TFile("exclusion_Fall10_pfmet_pfjets_CLs.root");
  
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_obs");
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_exp");
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_expp1");
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_expm1");

  //h->SetMaximum(3);
  //h->Draw("samecolz");
  
  TSpline3 *sFirst = new TSpline3("sFirst",First);
  sFirst->SetLineColor(kRed);
  sFirst->SetLineWidth(3);
  First->SetLineColor(kRed);
  First->SetLineWidth(3);

  TSpline3 *sSecond = new TSpline3("sSecond",Second);
  sSecond->SetLineColor(kBlue);
  sSecond->SetLineStyle(2);
  sSecond->SetLineWidth(3);
  Second->SetLineColor(kBlue);
  Second->SetLineStyle(2);
  Second->SetLineWidth(3);

  TSpline3 *sSecond_up = new TSpline3("sSecond_up",Second_up);
  sSecond_up->SetLineColor(kCyan);
  sSecond_up->SetLineStyle(1);
  sSecond_up->SetLineWidth(3);
  Second_up->SetLineColor(kBlue);
  //Second_up->SetLineColor(1);
  Second_up->SetLineWidth(2);

  TSpline3 *sSecond_low = new TSpline3("sSecond_low",Second_low);
  sSecond_low->SetLineColor(kCyan);
  sSecond_low->SetLineStyle(1);
  sSecond_low->SetLineWidth(3);
  Second_low->SetLineColor(kBlue);
  //Second_low->SetLineColor(1);
  Second_low->SetLineWidth(2);

  Third->SetLineColor(kCyan);
  Third->SetLineWidth(30);

  
  // TSpline3 *sThird = new TSpline3("sThird",Third);
  // sThird->SetLineColor(kGreen+2);
  // sThird->SetLineStyle(4);
  // sThird->SetLineWidth(3);
  // Third->SetLineColor(kGreen+2);
  // Third->SetLineStyle(4);
  // Third->SetLineWidth(3);

  //  First->Draw("AP");
  
  /*
 for(vector<TH1F*>::iterator at = exclusionPlots.begin();at != exclusionPlots.end();++at){
      (*at)->SetContour(2);
      if(n == 0){
      	(*at)->DrawCopy();
	(*at)->SetTitle("tan#beta="+tanBeta_);
      }
      cout << " n " << n << endl;
     (*at)->DrawCopy("same");
      //  (*it)->Write();
      cout << " here " << endl;
      n++;
      }*/

  
  TLegend* myleg;

  if( plotLO_ ) myleg = new TLegend(0.3,0.75,0.54,0.9,NULL,"brNDC");
  else          myleg = new TLegend(0.25,0.75,0.54,0.9,NULL,"brNDC");



  myleg->SetFillColor(0); 
  myleg->SetShadowColor(0);
  myleg->SetTextSize(0.03);
  myleg->SetBorderSize(0);
  
  TH1F* hdummy = new TH1F();
  hdummy->SetLineColor(4);
  hdummy->SetFillColor(4);
  hdummy->SetFillStyle(3002);
  hdummy->SetLineWidth(2);
  hdummy->SetLineStyle(2);

  //  myleg->AddEntry(sSecond,"NLO Expected Limit","L");
  if (tanBeta_ == 3 && plotLO_) {
    myleg->AddEntry(sSecond,"LO Observed Limit","L");
    myleg->AddEntry(sFirst,"NLO Observed Limit","L"); 
  } else {
    //myleg->AddEntry(sFirst,"CMS OS Dilepton Limit","L"); 
    myleg->AddEntry(sFirst,"NLO observed limit","L"); 
    //myleg->AddEntry(hdummy,"NLO expected limit","LF"); 
    myleg->AddEntry(hdummy,"NLO expected limit","L"); 
    //myleg->AddEntry(sSecond,"NLO expected limit","L"); 
    //myleg->AddEntry(sSecond_up,"NLO expected limit (+/-1#sigma)","L"); 
    myleg->AddEntry(obs2010,"2010 NLO observed limit","L"); 
  }
  
  //sSecond_up->Draw("h same");
  //sSecond_low->Draw("h same");
      
 
  //constant squark and gluino mass contours
  for (unsigned int it=1;it<nlines;it++) {   
    lngl[it]->Draw("same");   
    lnsq[it]->Draw("same");
    sq_text[it]->Draw();
    gl_text[it]->Draw();
  }

  sSecond_up->SetFillStyle(4010);
  sSecond_up->SetFillColor(kCyan-10);

  sSecond_low->SetFillStyle(1001);
  sSecond_low->SetFillColor(10);

  //expected and observed (LO & NLO) contours
  //sFirst->Draw("same");    
  //sSecond->Draw("same");   
  //sThird->Draw("same");
  //Third->Draw("samec");

  //expband->Draw("samecf"); // summer11 expected band
  //First->Draw("samec");    // summer11 observed exclusion
  
  //First->SetMarkerColor(1);
  //First->Draw("samep");
  //Second->Draw("samec");   // summer11 expected limit
  obs2010->Draw("samec");
  //Second_up->Draw("samec");
  //Second_low->Draw("samec");

  grObserved3p5_shape->SetLineColor(2);
  grExpected3p5_shape->SetLineColor(4);
  grExpected3p5_shape->SetLineStyle(2);
  grObserved3p5_shape->Draw("same");
  grExpected3p5_shape->Draw("same");

  // if (tanBeta_ == 3) Third->Draw("samec");
  //if (tanBeta_ == 3 && plotLO_) Second->Draw("samec");

   
    
  //exclusion limits previous experiments
  if(tanBeta_ == 3){
    TEV_sn_d0_1->Draw("fsame");
    TEV_sn_d0_2->Draw("fsame");
  }
  LEP_ch->Draw("fsame");
  if (tanBeta_ != 50) LEP_sl->Draw("fsame");

  //remove CDF/D0 excluded regions
  TEV_sg_cdf->Draw("fsame");
  TEV_sg_d0->Draw("same");  
  TEV_sg_d0->Draw("fsame");


  //other labels
  Double_t xpos = 0;
  Double_t xposi = 0;
  Double_t ypos = 0;
  if(tanBeta_ == 50) xposi = 100;
  if(tanBeta_ == 50) xpos = 200;
  if(tanBeta_ == 50) ypos = -10;
  
  //TLatex* lumilabel = new TLatex(135.+xposi,510.,"L_{int} = 34 pb^{-1}, #sqrt{s} = 7 TeV");
  //TLatex* lumilabel = new TLatex(305.+xposi + 100,510.,"L_{int} = 976 pb^{-1}, #sqrt{s} = 7 TeV");
  TLatex* lumilabel = new TLatex(490,m12max+15,"#sqrt{s} = 7 TeV, #scale[0.6]{#int} L dt = 3.5 fb^{-1}");

  lumilabel->SetTextSize(0.05);
  lumilabel->Draw("same");

  TLatex* cmslabel = new TLatex(10.,m12max+15,"CMS Preliminary");
  cmslabel->SetTextSize(0.05);
  cmslabel->Draw("same");

  TString text_tanBeta;
  //text_tanBeta =  "tan#beta = "+tanb+", A_{0} = 0, sign(#mu) > 0";
  text_tanBeta =  "tan#beta = "+tanb+",  A_{0} = 0,  #mu > 0";
  //TLatex* cmssmpars = new TLatex(70.+xpos,340.+ypos,text_tanBeta);
 
  TLatex* cmssmpars = new TLatex(120,540,text_tanBeta);
  //TLatex* cmssmpars = new TLatex(200,370,text_tanBeta);
  cmssmpars->SetTextSize(0.045);

  cmssmpars->Draw("same");

  //LM points
  TMarker* LM0 = new TMarker(200.,160.,20);
  TMarker* LM1 = new TMarker(60.,250.,20);
  TMarker* LM3 = new TMarker(330.,240.,20);
  TMarker* LM6 = new TMarker(80.,400.,20);
    
  LM0->SetMarkerSize(1.2);
  LM1->SetMarkerSize(1.2);
    
  TLatex* tLM0 = new TLatex(205.,160.," LM0");
  tLM0->SetTextSize(0.035);
    
  TLatex* tLM1 = new TLatex(80.,245.,"LM1");
  tLM1->SetTextSize(0.035);
  
  //TLatex* tLM3 = new TLatex(350.,235.,"LM3 (tan#beta=20)");
  TLatex* tLM3 = new TLatex(350.,235.,"LM3");
  tLM3->SetTextSize(0.035);
  
  TLatex* tLM6 = new TLatex(100.,395.,"LM6");
  tLM6->SetTextSize(0.035);
  
  //  if (tanBeta_ != 50){
  //  LM0->Draw("same");   
  //  tLM0->Draw("same");
  //  LM1->Draw("same");   
  //  tLM1->Draw("same");
  // }
  if (tanBeta_ == 10){ 
    LM1->Draw("same");
    tLM1->Draw("same");
    LM3->Draw("same");
    tLM3->Draw("same");
    LM6->Draw("same");
    tLM6->Draw("same");
  }

    /*
   Int_t n = 0;
    for(vector<TH1F*>::iterator at = exclusionPlots.begin();at != exclusionPlots.end();++at){
      (*at)->SetContour(2);
      if(n == 0){
      	(*at)->DrawCopy("same");
	(*at)->SetTitle("tan#beta=3");
      }
      cout << " n " << n << endl;
     (*at)->DrawCopy("same");
      //  (*it)->Write();
      cout << " here " << endl;
      n++;
      }
  
    */



  //stau=LSP contour
  stau->Draw("fsame");
  //NoEWSB->Draw("fsame");

  //legends
  legexp->Draw();
  legst->Draw();
  myleg->Draw();
  //legNoEWSB->Draw();

  //First->Draw("samec");
  // if (tanBeta_ == 3) Third->Draw("samec");
  //if (tanBeta_ == 3 && plotLO_) Second->Draw("samec");
  
  hist->Draw("sameaxis");
  cvsSys->RedrawAxis();
  cvsSys->Update();
  cvsSys->Write();
  
  if( plotLO_ ){
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+"_LO.pdf");
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+"_LO.png");
  }else{
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+".eps");
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+".pdf");
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+".png");
  }
  
  output->Write();
  //output->Close();
  //delete output; 
  
}
コード例 #16
0
ファイル: Merged.C プロジェクト: yenjie/usercode
void Merged()
{
   TH1F *hTracklet = new TH1F("hTracklet","",12,-3,3);

   hTracklet->SetBinContent(2,6.251);
   hTracklet->SetBinContent(11,6.251);
   hTracklet->SetBinContent(3,6.314);
   hTracklet->SetBinContent(10,6.314);
   hTracklet->SetBinContent(4,6.222);
   hTracklet->SetBinContent(9,6.222);
   hTracklet->SetBinContent(5,5.976);
   hTracklet->SetBinContent(8,5.976);
   hTracklet->SetBinContent(6,5.75);
   hTracklet->SetBinContent(7,5.75);
   hTracklet->SetAxisRange(0,8,"Y");
   hTracklet->SetXTitle("#eta");
   hTracklet->SetYTitle("dN/d#eta");

   TH1F *hCluster = new TH1F("hCluster","",12,-3,3);

   hCluster->SetBinContent(3,6.53);
   hCluster->SetBinContent(4,6.25);
   hCluster->SetBinContent(5,6.09);
   hCluster->SetBinContent(6,5.73);
   hCluster->SetBinContent(7,5.73);
   hCluster->SetBinContent(8,6.11);
   hCluster->SetBinContent(9,6.29);
   hCluster->SetBinContent(10,6.55);
   hCluster->SetMarkerStyle(4);

   TH1F *h = new TH1F("h","",40,-10,10);
   h->SetBinContent(0,0.07195663);
   h->SetBinContent(1,0.1089206);
   h->SetBinContent(2,0.2419911);
   h->SetBinContent(3,0.4864465);
   h->SetBinContent(4,0.8314441);
   h->SetBinContent(5,1.224248);
   h->SetBinContent(6,1.54066);
   h->SetBinContent(7,1.773287);
   h->SetBinContent(8,2.302119);
   h->SetBinContent(9,2.786102);
   h->SetBinContent(10,3.409561);
   h->SetBinContent(11,3.827994);
   h->SetBinContent(12,4.253327);
   h->SetBinContent(13,4.371119);
   h->SetBinContent(14,4.529325);
   h->SetBinContent(15,4.641202);
   h->SetBinContent(16,4.679152);
   h->SetBinContent(17,4.618039);
   h->SetBinContent(18,4.389847);
   h->SetBinContent(19,4.233613);
   h->SetBinContent(20,4.05175);
   h->SetBinContent(21,4.100049);
   h->SetBinContent(22,4.364712);
   h->SetBinContent(23,4.435683);
   h->SetBinContent(24,4.593889);
   h->SetBinContent(25,4.614588);
   h->SetBinContent(26,4.524396);
   h->SetBinContent(27,4.514539);
   h->SetBinContent(28,4.350912);
   h->SetBinContent(29,4.185806);
   h->SetBinContent(30,3.950222);
   h->SetBinContent(31,3.432725);
   h->SetBinContent(32,2.915722);
   h->SetBinContent(33,2.364712);
   h->SetBinContent(34,1.825037);
   h->SetBinContent(35,1.494332);
   h->SetBinContent(36,1.25382);
   h->SetBinContent(37,0.8669295);
   h->SetBinContent(38,0.501725);
   h->SetBinContent(39,0.2138985);
   h->SetBinContent(40,0.1059635);
   h->SetBinContent(41,0.07343519);
   h->SetBinError(0,0.005955173);
   h->SetBinError(1,0.007326796);
   h->SetBinError(2,0.01092091);
   h->SetBinError(3,0.01548376);
   h->SetBinError(4,0.02024303);
   h->SetBinError(5,0.0245637);
   h->SetBinError(6,0.02755576);
   h->SetBinError(7,0.029563);
   h->SetBinError(8,0.03368394);
   h->SetBinError(9,0.03705591);
   h->SetBinError(10,0.04099286);
   h->SetBinError(11,0.04343548);
   h->SetBinError(12,0.04578501);
   h->SetBinError(13,0.04641467);
   h->SetBinError(14,0.04724716);
   h->SetBinError(15,0.04782712);
   h->SetBinError(16,0.04802226);
   h->SetBinError(17,0.04770762);
   h->SetBinError(18,0.046514);
   h->SetBinError(19,0.04567878);
   h->SetBinError(20,0.04468691);
   h->SetBinError(21,0.04495247);
   h->SetBinError(22,0.04638064);
   h->SetBinError(23,0.0467562);
   h->SetBinError(24,0.04758271);
   h->SetBinError(25,0.0476898);
   h->SetBinError(26,0.04722145);
   h->SetBinError(27,0.04716998);
   h->SetBinError(28,0.04630726);
   h->SetBinError(29,0.04542014);
   h->SetBinError(30,0.04412348);
   h->SetBinError(31,0.04113188);
   h->SetBinError(32,0.0379081);
   h->SetBinError(33,0.03413879);
   h->SetBinError(34,0.02999127);
   h->SetBinError(35,0.02713829);
   h->SetBinError(36,0.02485859);
   h->SetBinError(37,0.02067049);
   h->SetBinError(38,0.01572504);
   h->SetBinError(39,0.01026746);
   h->SetBinError(40,0.007226653);
   h->SetBinError(41,0.006016045);
   h->SetEntries(237505);
   h->SetFillColor(1);
   h->SetFillStyle(0);
   h->SetLineStyle(0);
   h->SetMarkerStyle(21);
   h->SetMarkerColor(4);
   h->SetMarkerSize(1.25);
   h->GetXaxis()->SetTitle("#eta");
   h->GetXaxis()->SetLabelFont(42);
   h->GetXaxis()->SetLabelOffset(0.01);
   h->GetXaxis()->SetLabelSize(0.045);
   h->GetXaxis()->SetTitleSize(0.055);
   h->GetXaxis()->SetTitleFont(42);
   h->GetYaxis()->SetTitle("dN/d#eta");
   h->GetYaxis()->SetLabelFont(42);
   h->GetYaxis()->SetLabelOffset(0.01);
   h->GetYaxis()->SetLabelSize(0.045);
   h->GetYaxis()->SetTitleSize(0.055);
   h->GetYaxis()->SetTitleOffset(1.3);
   h->GetYaxis()->SetTitleFont(42);
   h->GetZaxis()->SetLabelFont(42);
   h->GetZaxis()->SetLabelSize(0.045);
   h->GetZaxis()->SetTitleFont(42);


   TH1F *hATLAS = new TH1F("hATLAS","",40,-10,10);
   hATLAS->SetBinContent(0,0.08524267);
   hATLAS->SetBinContent(1,0.1512688);
   hATLAS->SetBinContent(2,0.3321015);
   hATLAS->SetBinContent(3,0.6415373);
   hATLAS->SetBinContent(4,0.9425967);
   hATLAS->SetBinContent(5,1.193397);
   hATLAS->SetBinContent(6,1.452082);
   hATLAS->SetBinContent(7,1.836413);
   hATLAS->SetBinContent(8,2.275437);
   hATLAS->SetBinContent(9,2.840108);
   hATLAS->SetBinContent(10,3.400838);
   hATLAS->SetBinContent(11,4.043853);
   hATLAS->SetBinContent(12,4.521803);
   hATLAS->SetBinContent(13,5.043114);
   hATLAS->SetBinContent(14,5.39591);
   hATLAS->SetBinContent(15,5.757083);
   hATLAS->SetBinContent(16,6.010347);
   hATLAS->SetBinContent(17,6.007884);
   hATLAS->SetBinContent(18,5.883715);
   hATLAS->SetBinContent(19,5.838877);
   hATLAS->SetBinContent(20,5.451097);
   hATLAS->SetBinContent(21,5.490022);
   hATLAS->SetBinContent(22,5.663464);
   hATLAS->SetBinContent(23,5.971914);
   hATLAS->SetBinContent(24,6.058635);
   hATLAS->SetBinContent(25,5.969944);
   hATLAS->SetBinContent(26,5.797487);
   hATLAS->SetBinContent(27,5.353043);
   hATLAS->SetBinContent(28,4.894802);
   hATLAS->SetBinContent(29,4.5085);
   hATLAS->SetBinContent(30,4.00542);
   hATLAS->SetBinContent(31,3.448633);
   hATLAS->SetBinContent(32,2.883469);
   hATLAS->SetBinContent(33,2.337029);
   hATLAS->SetBinContent(34,1.805863);
   hATLAS->SetBinContent(35,1.42104);
   hATLAS->SetBinContent(36,1.205223);
   hATLAS->SetBinContent(37,0.9795516);
   hATLAS->SetBinContent(38,0.6228135);
   hATLAS->SetBinContent(39,0.3261887);
   hATLAS->SetBinContent(40,0.1547179);
   hATLAS->SetBinContent(41,0.09608278);
   hATLAS->SetBinError(0,0.00648088);
   hATLAS->SetBinError(1,0.008633366);
   hATLAS->SetBinError(2,0.01279207);
   hATLAS->SetBinError(3,0.01777937);
   hATLAS->SetBinError(4,0.02155105);
   hATLAS->SetBinError(5,0.02424923);
   hATLAS->SetBinError(6,0.0267486);
   hATLAS->SetBinError(7,0.03008089);
   hATLAS->SetBinError(8,0.03348404);
   hATLAS->SetBinError(9,0.03740873);
   hATLAS->SetBinError(10,0.04093534);
   hATLAS->SetBinError(11,0.04463784);
   hATLAS->SetBinError(12,0.0472021);
   hATLAS->SetBinError(13,0.04984882);
   hATLAS->SetBinError(14,0.05156296);
   hATLAS->SetBinError(15,0.05326068);
   hATLAS->SetBinError(16,0.05441959);
   hATLAS->SetBinError(17,0.05440843);
   hATLAS->SetBinError(18,0.05384325);
   hATLAS->SetBinError(19,0.0536377);
   hATLAS->SetBinError(20,0.05182597);
   hATLAS->SetBinError(21,0.05201068);
   hATLAS->SetBinError(22,0.05282586);
   hATLAS->SetBinError(23,0.05424532);
   hATLAS->SetBinError(24,0.05463776);
   hATLAS->SetBinError(25,0.05423637);
   hATLAS->SetBinError(26,0.05344725);
   hATLAS->SetBinError(27,0.05135773);
   hATLAS->SetBinError(28,0.04911035);
   hATLAS->SetBinError(29,0.04713261);
   hATLAS->SetBinError(30,0.04442521);
   hATLAS->SetBinError(31,0.04122199);
   hATLAS->SetBinError(32,0.03769321);
   hATLAS->SetBinError(33,0.03393419);
   hATLAS->SetBinError(34,0.02982963);
   hATLAS->SetBinError(35,0.02646114);
   hATLAS->SetBinError(36,0.02436908);
   hATLAS->SetBinError(37,0.02196945);
   hATLAS->SetBinError(38,0.017518);
   hATLAS->SetBinError(39,0.01267768);
   hATLAS->SetBinError(40,0.008731237);
   hATLAS->SetBinError(41,0.006880631);
   hATLAS->SetEntries(280271);
   hATLAS->SetFillColor(1);
   hATLAS->SetFillStyle(0);
   hATLAS->SetLineStyle(0);
   hATLAS->SetMarkerStyle(22);
   hATLAS->SetMarkerColor(4);
   hATLAS->SetMarkerSize(1.25);
   hATLAS->GetXaxis()->SetTitle("#eta");
   hATLAS->GetXaxis()->SetLabelFont(42);
   hATLAS->GetXaxis()->SetLabelOffset(0.01);
   hATLAS->GetXaxis()->SetLabelSize(0.045);
   hATLAS->GetXaxis()->SetTitleSize(0.055);
   hATLAS->GetXaxis()->SetTitleFont(42);
   hATLAS->GetYaxis()->SetTitle("dN/d#eta");
   hATLAS->GetYaxis()->SetLabelFont(42);
   hATLAS->GetYaxis()->SetLabelOffset(0.01);
   hATLAS->GetYaxis()->SetLabelSize(0.045);
   hATLAS->GetYaxis()->SetTitleSize(0.055);
   hATLAS->GetYaxis()->SetTitleOffset(1.3);
   hATLAS->GetYaxis()->SetTitleFont(42);
   hATLAS->GetZaxis()->SetLabelFont(42);
   hATLAS->GetZaxis()->SetLabelSize(0.045);
   hATLAS->GetZaxis()->SetTitleFont(42);
   
   TCanvas *MyCanvas = new TCanvas("MyCanvas", "Final result",1,360,550,600);

   hTracklet->Draw("p");
   hCluster->Draw("p same");
   hATLAS->Draw("same");
   h->Draw("same");
   Float_t ywidth = 0.25;
   //TLegend *leg2 = new TLegend(0.38,0.27,0.81,0.27+ywidth2,"","brNDC");
   TLegend *leg2 = new TLegend(0.39,0.21,0.82,0.21+ywidth,NULL,"brNDC");

   leg2->SetMargin(0.5);
   leg2->SetBorderSize(0);
   leg2->SetTextFont(62);
   leg2->SetLineColor(1);
   leg2->SetLineStyle(1);
   leg2->SetLineWidth(1);
   leg2->SetFillColor(0);
   //leg->SetFillStyle(1001);
   leg2->SetFillStyle(0);
   leg2->SetTextSize(0.033);
   leg2->SetHeader("     7.0 TeV");
   leg2->AddEntry(hTracklet,"CMS Preliminary Tracklet","p");
   leg2->AddEntry(hCluster,"CMS Preliminary Cluster","p");
   leg2->AddEntry(hATLAS,"ATLAS Tune","p");
   leg2->AddEntry(h,"D6T Tune","p");


   leg2->Draw();
}
コード例 #17
0
void plotInclusiveMass(  FileList fileList  , float Lumi_ = 30) {

  for(int i = 0; i<fileList.size(); i++){
    (fileList[i].first)->Close();
    delete (fileList[i].first);
  }

  TFile* fVBF115 = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_VBFH115.root","READ");
  TFile* fVBF135 = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_VBFH135.root","READ");
  TFile* fDYJets = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_DYJets-madgraph-50-PU.root","READ");
  TFile* fTT     = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_TT-madgraph-PU.root","READ");
  TFile* fWJets  = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_WJets-madgraph-PU.root","READ");
  TFile* fT      = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_TToBLNu-tW-madhraph-PU.root","READ");
  TFile* fQCD    = new TFile("/data_CMS/cms/lbianchini/MuTauStream/treeMuTauStream_QCD-pythia-PU.root","READ");

  FileList fileList_;
  fileList_.push_back( make_pair(fT,      make_pair("tW",        10.6      )  ));
  fileList_.push_back( make_pair(fQCD,    make_pair("QCD",   349988.0      )  ));
  fileList_.push_back( make_pair(fWJets,  make_pair("Wjets",  31314.0      )  ));
  fileList_.push_back( make_pair(fTT,     make_pair("ttbar",    157.5      )  ));
  fileList_.push_back( make_pair(fDYJets, make_pair("Zjets",   3048.0      )  ));
  fileList_.push_back( make_pair(fVBF115, make_pair("qqH115",       0.1012 )  ));
  fileList_.push_back( make_pair(fVBF135, make_pair("qqH135",       0.05049)  ));
 

  TCanvas *c1 = new TCanvas("c1InclusiveMass","",5,30,650,600);
  c1->SetGrid(0,0);
  c1->SetFillStyle(4000);
  c1->SetFillColor(10);
  c1->SetTicky();
  c1->SetObjectStat(0);
  c1->SetLogy(1);


  TPad* pad1 = new TPad("pad1InclusiveMass","",0.05,0.27,0.96,0.97);
  TPad* pad2 = new TPad("pad2InclusiveMass","",0.05,0.02,0.96,0.26);
  pad1->SetFillColor(0);
  pad2->SetFillColor(0);
  pad1->Draw();
  pad2->Draw();

  pad1->cd();
  pad1->SetLogy(1);

  TLegend* leg = new TLegend(0.60,0.47,0.90,0.85,NULL,"brNDC");
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(0.04);
  leg->SetHeader( "#mu+#tau Inclusive" );
  
  THStack* aStack = new THStack("aStack",Form("CMS Preliminary 2010    #sqrt{s}=7 TeV L=%.0f pb^{-1}",Lumi_));
  TH1F* hqqH115 = new TH1F();
  TH1F* hqqH135 = new TH1F();
  TH1F* hSiml   = new TH1F();

  float signalScale = 1;

  for(unsigned int i = 0 ; i < fileList_.size() ; i++){

    TFile* currentFile = (TFile*)fileList_[i].first ;
    if( currentFile->IsZombie() ) continue;
    TH1F* allEvents = (TH1F*)currentFile->Get("allEventsFilter/totalEvents");
    float totalEvents = allEvents->GetBinContent(1);

    TTree* currentTree = (TTree*)currentFile->Get("muTauStreamAnalyzer/tree");
    string h1Name = "h1_"+(fileList_[i].second).first;
    TH1F* h1 = new TH1F( h1Name.c_str() ,"", 28 , 20, 300);

    if( ((fileList_[i].second).first).find("Zjets")!=string::npos ) {
      h1->SetFillColor(kRed);
      leg->AddEntry(h1,"MadGraph Z+jets","F");
    }
    if( ((fileList_[i].second).first).find("ttbar")!=string::npos ) {
      h1->SetFillColor(kBlue);
      leg->AddEntry(h1,"MadGraph t#bar{t}+jets","F");
    }
    if( ((fileList_[i].second).first).find("Wjets")!=string::npos ) {
      h1->SetFillColor(kGreen);
      leg->AddEntry(h1,"MadGraph W+jets","F");
    }
    if( ((fileList_[i].second).first).find("tW")!=string::npos ){
      h1->SetFillColor( 44 );
      leg->AddEntry(h1,"MadGraph single-top","F");
    }
    if( ((fileList_[i].second).first).find("QCD")!=string::npos ) {
      h1->SetFillColor(11);
      leg->AddEntry(h1,"Pythia QCD","F");
    }
    if( ((fileList_[i].second).first).find("qqH115")!=string::npos ) {
      h1->SetLineColor(kBlack);
      h1->SetLineStyle(kDashed);
      h1->SetLineWidth(3.0);
      leg->AddEntry(h1,"VBF H(115)#rightarrow#tau#tau X 100","l");
      signalScale = 100;
    }
    if( ((fileList_[i].second).first).find("qqH135")!=string::npos ) {
      h1->SetLineColor(kBlack);
      h1->SetLineStyle(kDotted);
      h1->SetLineWidth(3.0);
      leg->AddEntry(h1,"VBF H(135)#rightarrow#tau#tau X 100","l");
      signalScale = 100;
    }

    int nEntries = currentTree->GetEntries() ;
    
    std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >* diTauSVfit3;
    currentTree->SetBranchAddress("diTauSVfit3P4",&diTauSVfit3);

    for (int n = 0; n < nEntries ; n++) {
      currentTree->GetEntry(n);
      if( diTauSVfit3->size() < 1) continue;
      h1->Fill( (*diTauSVfit3)[0].M() ) ;
    }

    h1->Scale( Lumi_ / (totalEvents/((fileList_[i].second).second * signalScale)) );

    if(((fileList_[i].second).first).find("qqH115")!=string::npos){
      hqqH115=(TH1F*)h1->Clone("hqqH115");
      hqqH115 = h1;
      hqqH115->Sumw2();
      continue;
    }
    if(((fileList_[i].second).first).find("qqH135")!=string::npos){
      hqqH135=(TH1F*)h1->Clone("hqqH135");
      hqqH135 = h1;
      hqqH135->Sumw2();
      continue;
    }

    if(i==0) hSiml=(TH1F*)h1->Clone("hSiml");
    else hSiml->Add(h1);

    aStack->Add(h1);

  }

  //float numData = hData->GetEntries();
  //float numSiml = hSiml->Integral();
  //float dataToSimlRatio = numData/numSiml;
  //cout << "data " << numData << "  ---  simul " << numSiml << endl;  

  aStack->Draw("HIST");
  hqqH115->Draw("HISTSAME");
  hqqH135->Draw("HISTSAME");
  TH1F* hStack = (TH1F*)aStack->GetHistogram();
  hStack->SetXTitle("SVfit #tau#tau mass");
  hStack->SetYTitle(Form("Number of events/%.0f GeV",hStack->GetBinWidth(1)));
  hStack->SetTitleSize(0.05,"X");
  hStack->SetTitleSize(0.05,"Y");
  hStack->SetTitleOffset(0.75,"Y");
  leg->Draw();

  pad2->cd();
  TH1F* hRatio = new TH1F("hRatio", " ; ; purity",
			  hStack->GetNbinsX(), 
			  hStack->GetXaxis()->GetXmin(), hStack->GetXaxis()->GetXmax());
  hRatio->SetLineStyle(kDashed);
  hRatio->SetLineWidth(1.0);
  hRatio->SetLabelSize(0.12,"X");
  hRatio->SetLabelSize(0.10,"Y");
  hRatio->SetTitleSize(0.12,"Y");
  hRatio->SetTitleOffset(0.36,"Y");
  TH1F* hqqH115Clone = (TH1F*)hqqH115->Clone("hqqH115Clone");
  TH1F* hqqH135Clone = (TH1F*)hqqH135->Clone("hqqH135Clone");
  hqqH115Clone->Divide( hqqH115 ,hSiml,1./signalScale,1.0);
  hqqH135Clone->Divide( hqqH135 ,hSiml,1./signalScale,1.0);
  hRatio->SetAxisRange(0.,0.001,"Y");

  hRatio->Draw();
  hqqH115Clone->Draw("HISTSAME");
  hqqH135Clone->Draw("HISTSAME");

  if(SAVE) c1->SaveAs("Zmm_InclusiveMass.png");

}
コード例 #18
0
ファイル: combineMt.C プロジェクト: aashaqshah/cmssw-1
void plot(int mass) {
  double myQCDRelUncert = 0.038;
  double myEWKRelUncert = 0.131;
  double myFakesRelUncert = 0.238;
  double delta = 1.4;
  double br = 0.05;
  bool debug = false;
  bool log = false;
  double ymin = 0.001;
  double ymax = 48;
  
  static bool bMessage = false;
  if (!bMessage) {
    cout << "Values used as relative uncertainty (please check):" << endl;
    cout << "  QCD: " << myQCDRelUncert << endl;
    cout << "  EWK genuine tau: " << myEWKRelUncert << endl;
    cout << "  EWK fake tau: " << myFakesRelUncert << endl << endl;
    bMessage = true;
  }
  cout << "Processing mass point: " << mass << " GeV/c2" << endl;
  
  gStyle->SetOptFit(1);
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  gStyle->SetTitleFont(43, "xyz");
  gStyle->SetTitleSize(33, "xyz");
  gStyle->SetLabelFont(43, "xyz");
  gStyle->SetLabelSize(27, "xyz");
  
  //std::string infile = "EPS_data_nodeltaphi/hplus_100.root";
  //std::string infile = "EPS_data_deltaphi160/hplus_100.root";
  std::stringstream s;
  s << "lands_histograms_hplushadronic_m" << mass << ".root";

  std::string infile = s.str();
  
 // Canvas
  TCanvas *myCanvas = new TCanvas("myCanvas", "",0,0,600,600);
  myCanvas->SetHighLightColor(2);
  myCanvas->Range(0,0,1,1);
  myCanvas->SetFillColor(0);
  myCanvas->SetBorderMode(0);
  myCanvas->SetBorderSize(2);
  if (log)
    myCanvas->SetLogy();
  myCanvas->SetTickx(1);
  myCanvas->SetTicky(1);
  myCanvas->SetLeftMargin(0.16);
  myCanvas->SetRightMargin(0.05);
  myCanvas->SetTopMargin(0.05);
  myCanvas->SetBottomMargin(0.08);
  myCanvas->SetFrameFillStyle(0);
  myCanvas->SetFrameBorderMode(0);
  myCanvas->SetFrameFillStyle(0);
  myCanvas->SetFrameBorderMode(0);
  myCanvas->cd();

  Int_t ci;

  TFile* f = TFile::Open(infile.c_str());
  s.str("");
  s << "HW" << mass << "_1";
  TH1* hw = (TH1*)f->Get(s.str().c_str());
  s.str("");
  s << "HH" << mass << "_1";
  TH1* hh = (TH1*)f->Get(s.str().c_str());
  TH1* data = (TH1*)f->Get("data_obs");
  data->SetLineWidth(2);
  data->SetMarkerStyle(20);
  data->SetMarkerSize(1.2);

  TH1* ewktau = (TH1*)f->Get("EWK_Tau");
  ci = TColor::GetColor("#993399");
  ewktau->SetFillColor(ci);
  ewktau->SetLineWidth(0);
  TH1* ewkDY = (TH1*)f->Get("EWK_DYx");
  TH1* ewkVV = (TH1*)f->Get("EWK_VVx");
  ewktau->Add(ewkDY);
  ewktau->Add(ewkVV);
  
  //TH1* qcd = (TH1*)f->Get("QCDInv");
  TH1* qcd = (TH1*)f->Get("QCD");
  ci = TColor::GetColor("#ffcc33");
  qcd->SetFillColor(ci);
  qcd->SetLineWidth(0);
  TH1* fakett = (TH1*)f->Get("fake_tt");
  ci = TColor::GetColor("#669900");
  fakett->SetFillColor(ci);
  fakett->SetLineWidth(0);
  TH1* fakeW = (TH1*)f->Get("fake_W");
  ci = TColor::GetColor("#cc3300");
  fakeW->SetFillColor(ci);
  fakeW->SetLineWidth(0);
  TH1* faket = (TH1*)f->Get("fake_t");

  TH1F *hFrame = new TH1F("hFrame","",20,0,400);
  hFrame->SetMinimum(ymin);
  if (log)
    hFrame->SetMaximum(ymax*1.5);
  else
    hFrame->SetMaximum(ymax);
  hFrame->SetDirectory(0);
  hFrame->SetStats(0);
  hFrame->SetLineStyle(0);
  hFrame->SetMarkerStyle(20);
  hFrame->SetXTitle("Transverse mass (#tau jet, E_{T}^{miss}), (GeV/c^{2})");
  if (paperStatus)
    hFrame->SetXTitle("Transverse mass (#tau_{h}, E_{T}^{miss}), (GeV/c^{2})");
  hFrame->SetYTitle("Events / 20 GeV/c^{2}");
  hFrame->GetXaxis()->SetTitleSize(0);
  hFrame->GetXaxis()->SetLabelSize(0);
  hFrame->GetYaxis()->SetTitleFont(43);
  hFrame->GetYaxis()->SetTitleSize(27);
  hFrame->GetYaxis()->SetTitleOffset(1.3);
  

  // signal
  hh->Scale(br*br);
  hw->Scale(2*br*(1.0-br));
  TH1* signal = (TH1*)hh->Clone();
  signal->Add(hw);

  ci = TColor::GetColor("#ff3399");
  signal->SetLineColor(ci);
  signal->SetLineStyle(2);
  signal->SetLineWidth(2);

  // Fakes
  TH1* fakes = (TH1*)(fakett->Clone());
  fakes->Add(fakeW);
  fakes->Add(faket);

  // stacked backgrounds
  THStack *exp = new THStack();
  exp->SetName("exp");
  exp->SetTitle("exp");
  exp->Add(fakes);
  exp->Add(ewktau);
  exp->Add(qcd);
  exp->Add(signal);
  
  TH1* hExpBkg = (TH1*)fakes->Clone();
  hExpBkg->Add(ewktau);
  hExpBkg->Add(qcd);
  
  // uncertainty
  TH1* uncert = (TH1*)fakeW->Clone();
  uncert->Add(fakett);
  uncert->Add(ewktau);
  uncert->Add(qcd);
  uncert->SetFillColor(1);
  uncert->SetFillStyle(3344);
  uncert->SetLineColor(0);
  uncert->SetLineStyle(0);
  uncert->SetLineWidth(0);

  TH1* hExpBkgTotalUncert = (TH1*)uncert->Clone();
  hExpBkgTotalUncert->SetFillStyle(3354);

  TH1* hAgreement = (TH1*)data->Clone();
  hAgreement->Divide(hExpBkg);
  TGraphErrors* hAgreementRelUncert = new TGraphErrors(hAgreement->GetNbinsX());
  hAgreementRelUncert->SetLineWidth(2);
  hAgreementRelUncert->SetLineColor(kBlack);
  for (int i = 1; i <= hFrame->GetNbinsX(); ++i) {
    double myQCDTotalUncert = TMath::Power(qcd->GetBinError(i), 2)
      + TMath::Power(qcd->GetBinContent(i)*myQCDRelUncert, 2);
    double myEWKTotalUncert = TMath::Power(ewktau->GetBinError(i), 2)
      + TMath::Power(ewktau->GetBinContent(i)*myEWKRelUncert, 2);
    double myFakesTotalUncert = TMath::Power(fakes->GetBinError(i), 2)
      + TMath::Power(fakes->GetBinContent(i)*myFakesRelUncert, 2);
    hExpBkgTotalUncert->SetBinError(i, TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert));

    if (hExpBkg->GetBinContent(i) > 0) {
      hAgreementRelUncert->SetPoint(i-1, hExpBkg->GetBinCenter(i), data->GetBinContent(i) / hExpBkg->GetBinContent(i));
      double myUncertData = 0;
      if (data->GetBinContent(i) > 0)
        myUncertData = TMath::Power(data->GetBinError(i) / data->GetBinContent(i), 2);
      double myUncertBkg = (myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) / TMath::Power(hExpBkg->GetBinContent(i), 2);
      hAgreementRelUncert->SetPointError(i-1, 0,  data->GetBinContent(i) / hExpBkg->GetBinContent(i) * TMath::Sqrt(myUncertData + myUncertBkg));
    } else {
      hAgreementRelUncert->SetPoint(i-1, hExpBkg->GetBinCenter(i), 0);
      hAgreementRelUncert->SetPointError(i-1, 0, 0);
    }
    if (debug) {
      cout << "Point: " << hAgreementRelUncert->GetX()[i-1]-10 << "-" << hAgreementRelUncert->GetX()[i-1]+10
          << " GeV/c2, agreement: " << hAgreementRelUncert->GetY()[i-1] << ", uncert: " << hAgreement->GetBinError(i) << ", " << hAgreementRelUncert->GetErrorY(i-1) << endl;
      cout << "  bkg. stat. uncert. " << hExpBkg->GetBinError(i) << " (i.e. " << hExpBkg->GetBinError(i) / hExpBkg->GetBinContent(i) * 100.0 << " %)"
          << ", stat+syst uncert. " << TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) 
          << " (i.e. " << TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) / hExpBkg->GetBinContent(i) * 100.0 << " %)" << endl;
    }
  }

  // Agreement pad
  TPad* pad = new TPad("ratiopad","ratiopad",0.,0.,1.,.3);
  pad->Draw();
  pad->cd();
  pad->Range(0,0,1,1);
  pad->SetFillColor(0);
  pad->SetFillStyle(4000);
  pad->SetBorderMode(0);
  pad->SetBorderSize(2);
  pad->SetTickx(1);
  pad->SetTicky(1);
  pad->SetLeftMargin(0.16);
  pad->SetRightMargin(0.05);
  pad->SetTopMargin(0);
  pad->SetBottomMargin(0.34);
  pad->SetFrameFillStyle(0);
  pad->SetFrameBorderMode(0);
  // Plot here ratio
  if (1.0-delta > 0)
    hAgreement->SetMinimum(1.0-delta);
  else
    hAgreement->SetMinimum(0.);
  hAgreement->SetMaximum(1.0+delta);
  hAgreement->GetXaxis()->SetLabelOffset(0.007);
  hAgreement->GetXaxis()->SetLabelFont(43);
  hAgreement->GetXaxis()->SetLabelSize(27);
  hAgreement->GetYaxis()->SetLabelFont(43);
  hAgreement->GetYaxis()->SetLabelSize(27);
  hAgreement->GetYaxis()->SetLabelOffset(0.007);
  hAgreement->GetYaxis()->SetNdivisions(505);
  hAgreement->GetXaxis()->SetTitleFont(43);
  hAgreement->GetYaxis()->SetTitleFont(43);
  hAgreement->GetXaxis()->SetTitleSize(33);
  hAgreement->GetYaxis()->SetTitleSize(33);
  hAgreement->SetTitleSize(27, "xyz");
  hAgreement->GetXaxis()->SetTitleOffset(3.2);
  hAgreement->GetYaxis()->SetTitleOffset(1.3);
  hAgreement->SetXTitle(hFrame->GetXaxis()->GetTitle());
  hAgreement->SetYTitle("Data/#Sigmabkg");
  hAgreement->Draw("e2");
  // Plot line at zero
  TH1* hAgreementLine = dynamic_cast<TH1*>(hAgreement->Clone());
  for (int i = 1; i <= hAgreementLine->GetNbinsX(); ++i) {
    hAgreementLine->SetBinContent(i,1.0);
    hAgreementLine->SetBinError(i,0.0);
  }
  hAgreementLine->SetLineColor(kRed);
  hAgreementLine->SetLineWidth(2);
  hAgreementLine->SetLineStyle(3);
  hAgreementLine->Draw("hist same");
  hAgreement->Draw("same");
  hAgreementRelUncert->Draw("[]");
  pad->RedrawAxis();

  myCanvas->cd();
  
  TPad* plotpad = new TPad("plotpad", "plotpad",0,0.3,1.,1.);
  plotpad->Draw();
  plotpad->cd();
  plotpad->Range(0,0,1,1);
  plotpad->SetFillColor(0);
  plotpad->SetFillStyle(4000);
  plotpad->SetBorderMode(0);
  plotpad->SetBorderSize(2);
  //if (logy)
  //  plotpad->SetLogy();
  plotpad->SetTickx(1);
  plotpad->SetTicky(1);
  plotpad->SetLeftMargin(0.16);
  plotpad->SetRightMargin(0.05);
  plotpad->SetTopMargin(0.065);
  plotpad->SetBottomMargin(0.0);
  plotpad->SetFrameFillStyle(0);
  plotpad->SetFrameBorderMode(0);
  
  hFrame->GetXaxis()->SetTitleSize(0);
  hFrame->GetXaxis()->SetLabelSize(0);
  hFrame->GetYaxis()->SetTitleFont(43);
  hFrame->GetYaxis()->SetTitleSize(33);
  hFrame->GetYaxis()->SetTitleOffset(1.3);
  
  // Draw objects
  hFrame->Draw();
  exp->Draw("hist same");
  uncert->Draw("E2 same");
  hExpBkgTotalUncert->Draw("E2 same");
  // Data
  data->Draw("same");
  
  //signal->Draw("same");
  TLegend *leg = new TLegend(0.53,0.6,0.87,0.91,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextFont(63);
  leg->SetTextSize(18);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(kWhite);
  //leg->SetFillStyle(4000); // enabling this will cause the plot to be erased from the pad
  TLegendEntry* entry = leg->AddEntry(data, "Data", "P");
  s.str("");
  s << "with H^{#pm}#rightarrow#tau^{#pm}#nu";
  entry = leg->AddEntry(signal, s.str().c_str(), "L");
  entry = leg->AddEntry(qcd, "QCD (meas.)", "F");
  entry = leg->AddEntry(ewktau, "EWK genuine #tau (meas.)", "F");
  entry = leg->AddEntry(fakes, "EWK fake #tau (MC)", "F");
  entry = leg->AddEntry(uncert, "stat. uncert.", "F");
  entry = leg->AddEntry(hExpBkgTotalUncert, "stat. #oplus syst. uncert.", "F");
  leg->Draw();
  
  string myTitle = "CMS Preliminary";
  if (paperStatus)
    myTitle = "CMS";

  TLatex *tex = new TLatex(0.62,0.945,myTitle.c_str());
  tex->SetNDC();
  tex->SetTextFont(43);
  tex->SetTextSize(27);
  tex->SetLineWidth(2);
  tex->Draw();
  tex = new TLatex(0.2,0.945,"#sqrt{s} = 7 TeV");
  tex->SetNDC();
  tex->SetTextFont(43);
  tex->SetTextSize(27);
  tex->SetLineWidth(2);
  tex->Draw();
  tex = new TLatex(0.43,0.945,"2.2 fb^{-1}");
  tex->SetNDC();
  tex->SetTextFont(43);
  tex->SetTextSize(27);
  tex->SetLineWidth(2);
  tex->Draw();

  s.str("");
  s << "m_{H^{#pm}} = " << mass << " GeV/c^{2}";
  tex = new TLatex(0.28,0.865,s.str().c_str());
  tex->SetNDC();
  tex->SetTextFont(63);
  tex->SetTextSize(20);
  tex->SetLineWidth(2);
  tex->Draw();
  s.str("");
  s << "BR(t#rightarrowbH^{#pm})=" << setprecision(2) << br;
  tex = new TLatex(0.28,0.805,s.str().c_str());
  tex->SetNDC();
  tex->SetTextFont(63);
  tex->SetTextSize(20);
  tex->SetLineWidth(2);
  tex->Draw();

  
  plotpad->RedrawAxis();
  plotpad->Modified();

  s.str("");
  s << "mT_datadriven_m" << mass << ".png";
  myCanvas->Print(s.str().c_str());
  s.str("");
  s << "mT_datadriven_m" << mass << ".C";
  myCanvas->Print(s.str().c_str());
  s.str("");
  s << "mT_datadriven_m" << mass << ".eps";
  myCanvas->Print(s.str().c_str());
   

}
コード例 #19
0
void  PlotAlignmentValidation::plotDMR(const std::string variable, Int_t minHits )
{
 setNiceStyle(); 
 gStyle->SetOptStat(0);

 // TList treeList=getTreeList();

 TCanvas *c = new TCanvas("canv", "canv", 600, 600);
 setCanvasStyle( *c );
 //loop over sub-detectors 
 for (int i=1;i<7;++i){
 
   int histo_Counter=1;
   TLegend *leg_hist = new TLegend(0.17,0.8,0.85,0.88);
   setLegendStyle(*leg_hist);
   //loop over file list
   //TTree *tree= (TTree*)treeList.First();
   //binning
   int nbinsX=100;
   double xmin=0;
   double xmax=0;
   float maxY=0;
   bool isHisto = false;
   std::string plotVar=variable;
   THStack *hstack=new THStack("hstack","hstack");

   for(std::vector<TkOfflineVariables*>::iterator it = sourceList.begin();
       it != sourceList.end(); ++it){
      
     //while ( tree ){
     plotVar=variable;
     TString subdet = "entries>=";
     subdet+=minHits; 
     subdet+=" && subDetId==";
     subdet+=i;
      
     char binning [50]="";
     sprintf (binning, ">>myhisto(%d,  %f , %f)", nbinsX, xmin, xmax);
     TH1F *h = 0;
     
     if (histo_Counter==1&&plotVar=="meanX")(*it)->getTree()->Draw( (plotVar+=">>myhisto(50,-0.005,0.005)").c_str(),subdet,"goff");
     else if (histo_Counter==1&&plotVar=="meanY")(*it)->getTree()->Draw( (plotVar+=">>myhisto(50,-0.005,0.005)").c_str(),subdet,"goff");
     else if (histo_Counter==1&&plotVar=="medianX")(*it)->getTree()->Draw( (plotVar+=">>myhisto(50,-0.005,0.005)").c_str(),subdet,"goff");
     else if (histo_Counter==1&&plotVar=="meanNormX")(*it)->getTree()->Draw( (plotVar+=">>myhisto(100,-2,2)").c_str(),subdet,"goff");
     else if (histo_Counter==1&&plotVar=="rmsX")(*it)->getTree()->Draw( (plotVar+=">>myhisto(100,0.,0.1)").c_str(),subdet,"goff");
     else if (histo_Counter!=1)(*it)->getTree()->Draw( (plotVar+=binning).c_str(),subdet,"goff");

     if (gDirectory) gDirectory->GetObject("myhisto", h);
     std::pair<float,float> fitResults(9999., 9999.);
     if (h){
       if (h->GetEntries()>0) {
	 isHisto = true;
	 h->SetDirectory(0);
	 //general draw options
	 h->SetLineWidth(2);
	 //first histo only, setting optStat...
	 if (histo_Counter==1)
	   setHistStyle(*h,plotVar.c_str() ,"#modules", 1 ); //set color later

	 h->SetLineColor( (*it)->getLineColor() );
	 h->SetLineStyle( (*it)->getLineStyle() );
	   //h->SetMarkerStyle(20+file_Counter);
      
	 //draw options
	 
	 if (maxY<h->GetMaximum()){
	   maxY=h->GetMaximum();
	 }
      
	 //fit histogram for median and mean
	 if (variable=="medianX"||variable =="meanX")fitResults=fitGauss(h, (*it)->getLineColor() );

	 if (histo_Counter==1){
	   //get mean and sigma from fit: gauss for 2sigma range
	   hstack->Add(h);
	   nbinsX=h->GetXaxis()->GetNbins();
	   xmin=h->GetXaxis()->GetXmin();
	   xmax=h->GetXaxis()->GetXmax();
	  
	 }else if (histo_Counter!=1 &&  h->GetEntries()>0)hstack->Add(h);
     
	 char legend [50]="";
	 std::string legEntry = (*it)->getName();
	 if (variable=="medianX"||variable =="meanX")sprintf (legend, "%s: #mu = %4.2f#mum, #sigma = %4.2f#mum ",legEntry.c_str(),fitResults.first ,fitResults.second);
	 else sprintf (legend, "%s ",legEntry.c_str());
	 if(h)
	   leg_hist->AddEntry(h,legend,"l");
	 else
	   std::cerr<< "histogram did not exist!";
       }
     }
     //     tree= (TTree*)treeList.After( tree );
     //     file_Counter++;
     histo_Counter++;
        
   }
    
   if (isHisto){
     hstack->Draw("nostack");
     hstack->SetMaximum(maxY*1.3);
     setTitleStyle(*hstack,plotVar.c_str() ,"#modules",i);
     setHistStyle(*hstack->GetHistogram(),plotVar.c_str() ,"#modules", 1 );
     leg_hist->Draw(); 

     std::string histName="D";
     if (variable=="medianX") histName+="medianR_";
     else if (variable=="meanX") histName+="meanR_";
     else if (variable=="meanY") histName+="meanYR_";
     else if (variable=="rmsX") histName+="rmsR_";
     std::string subDetector ="";
     switch (i){
     case 1 : subDetector+="TPB";break;
     case 2 : subDetector+="TPE";break;
     case 3 : subDetector+="TIB";break;
     case 4 : subDetector+="TID";break;
     case 5 : subDetector+="TOB";break;
     case 6 : subDetector+="TEC";break;
     }
 
     char PlotName[100];
     sprintf( PlotName, "%s/%s%s.eps",outputDir.c_str(), histName.c_str(), subDetector.c_str() );
     c->Update(); 
     c->Print(PlotName);
     //c->Update();
     //c->Close();
    
   }
   delete hstack;
   hstack=0; 
  
 }
 
 delete c;
 c=0;
}
コード例 #20
0
ファイル: gyieldsp.C プロジェクト: echapon/HIN-13-007
void gyieldsp()
{
//=========Macro generated from canvas: c1/c1
//=========  (Fri Jul 31 19:31:43 2015) by ROOT version6.05/01
   TCanvas *c1 = new TCanvas("c1", "c1",0,23,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   c1->Range(0,0,1,1);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.16);
   c1->SetRightMargin(0.04);
   c1->SetTopMargin(0.08);
   c1->SetBottomMargin(0.12);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: pad1
   TPad *pad1 = new TPad("pad1", "pad1",0,0.26,1,1);
   pad1->Draw();
   pad1->cd();
   pad1->Range(-3.5,-6.621622,2.75,158.9189);
   pad1->SetFillColor(0);
   pad1->SetBorderMode(0);
   pad1->SetBorderSize(2);
   pad1->SetTickx(1);
   pad1->SetTicky(1);
   pad1->SetLeftMargin(0.16);
   pad1->SetRightMargin(0.04);
   pad1->SetTopMargin(0.1142857);
   pad1->SetBottomMargin(0.04);
   pad1->SetFrameFillStyle(0);
   pad1->SetFrameBorderMode(0);
   pad1->SetFrameFillStyle(0);
   pad1->SetFrameBorderMode(0);
   
   Double_t Graph0_fx3021[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph0_fy3021[10] = {
   103.56,
   105.744,
   103.4081,
   100.0093,
   97.03688,
   94.36609,
   90.5471,
   82.43278,
   65.82142,
   43.43165};
   Double_t Graph0_felx3021[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph0_fely3021[10] = {
   7.299733,
   7.206486,
   6.824632,
   6.594841,
   6.406375,
   6.079494,
   5.746822,
   5.225105,
   4.165823,
   2.787035};
   Double_t Graph0_fehx3021[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph0_fehy3021[10] = {
   5.988963,
   6.218694,
   6.307709,
   6.368316,
   5.847823,
   5.655323,
   5.083818,
   4.561256,
   3.722445,
   2.542957};
   TGraphAsymmErrors *grae = new TGraphAsymmErrors(10,Graph0_fx3021,Graph0_fy3021,Graph0_felx3021,Graph0_fehx3021,Graph0_fely3021,Graph0_fehy3021);
   grae->SetName("Graph0");
   grae->SetTitle("Graph");

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

   ci = TColor::GetColor("#ff0000");
   grae->SetLineColor(ci);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   grae->SetMarkerSize(0);
   
   TH1F *Graph_Graph3021 = new TH1F("Graph_Graph3021","Graph",100,-2.5,2.5);
   Graph_Graph3021->SetMinimum(0);
   Graph_Graph3021->SetMaximum(140);
   Graph_Graph3021->SetDirectory(0);
   Graph_Graph3021->SetStats(0);
   Graph_Graph3021->SetLineStyle(0);
   Graph_Graph3021->SetMarkerStyle(20);
   Graph_Graph3021->GetXaxis()->SetNdivisions(505);
   Graph_Graph3021->GetXaxis()->SetLabelFont(42);
   Graph_Graph3021->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph3021->GetXaxis()->SetLabelSize(0);
   Graph_Graph3021->GetXaxis()->SetTitleSize(0.07142857);
   Graph_Graph3021->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph3021->GetXaxis()->SetTitleFont(42);
   Graph_Graph3021->GetYaxis()->SetTitle("d#sigma (W^{+}#rightarrow#font[12]{l}^{+}#nu) / d#eta_{lab} [nb]");
   Graph_Graph3021->GetYaxis()->SetLabelFont(42);
   Graph_Graph3021->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph3021->GetYaxis()->SetLabelSize(0.07142857);
   Graph_Graph3021->GetYaxis()->SetTitleSize(0.07142857);
   Graph_Graph3021->GetYaxis()->SetTitleOffset(1.05);
   Graph_Graph3021->GetYaxis()->SetTitleFont(42);
   Graph_Graph3021->GetZaxis()->SetLabelFont(42);
   Graph_Graph3021->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph3021->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph3021->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph3021->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3021);
   
   grae->Draw("a2");
   
   Double_t Graph1_fx3022[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph1_fy3022[10] = {
   103.56,
   105.744,
   103.4081,
   100.0093,
   97.03688,
   94.36609,
   90.5471,
   82.43278,
   65.82142,
   43.43165};
   Double_t Graph1_felx3022[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph1_fely3022[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph1_fehx3022[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph1_fehy3022[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   grae = new TGraphAsymmErrors(10,Graph1_fx3022,Graph1_fy3022,Graph1_felx3022,Graph1_fehx3022,Graph1_fely3022,Graph1_fehy3022);
   grae->SetName("Graph1");
   grae->SetTitle("Graph");

   ci = TColor::GetColor("#ffff00");
   grae->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   grae->SetLineColor(ci);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   grae->SetMarkerSize(0);
   grae->Draw("z");
   
   Double_t Graph2_fx3023[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph2_fy3023[10] = {
   91.59545,
   95.26883,
   95.65156,
   95.47892,
   95.94693,
   96.02597,
   93.3635,
   84.56484,
   65.95871,
   42.11706};
   Double_t Graph2_felx3023[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph2_fely3023[10] = {
   8.336985,
   8.261181,
   7.634488,
   6.438496,
   6.661149,
   6.164321,
   6.1019,
   4.954787,
   4.773841,
   2.599375};
   Double_t Graph2_fehx3023[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph2_fehy3023[10] = {
   8.262572,
   7.14746,
   6.62492,
   6.725295,
   5.946212,
   5.838684,
   5.077774,
   5.257491,
   3.443198,
   2.602454};
   grae = new TGraphAsymmErrors(10,Graph2_fx3023,Graph2_fy3023,Graph2_felx3023,Graph2_fehx3023,Graph2_fely3023,Graph2_fehy3023);
   grae->SetName("Graph2");
   grae->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   grae->SetFillColor(ci);
   grae->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   grae->SetLineColor(ci);
   grae->SetLineStyle(7);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   
   TH1F *Graph_Graph3023 = new TH1F("Graph_Graph3023","Graph",100,-2.88,2.88);
   Graph_Graph3023->SetMinimum(33.22782);
   Graph_Graph3023->SetMaximum(108.7062);
   Graph_Graph3023->SetDirectory(0);
   Graph_Graph3023->SetStats(0);
   Graph_Graph3023->SetLineStyle(0);
   Graph_Graph3023->SetMarkerStyle(20);
   Graph_Graph3023->GetXaxis()->SetLabelFont(42);
   Graph_Graph3023->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph3023->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph3023->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph3023->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph3023->GetXaxis()->SetTitleFont(42);
   Graph_Graph3023->GetYaxis()->SetLabelFont(42);
   Graph_Graph3023->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph3023->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph3023->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph3023->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph3023->GetYaxis()->SetTitleFont(42);
   Graph_Graph3023->GetZaxis()->SetLabelFont(42);
   Graph_Graph3023->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph3023->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph3023->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph3023->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3023);
   
   grae->Draw("2");
   
   Double_t Graph3_fx3024[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph3_fy3024[10] = {
   91.59545,
   95.26883,
   95.65156,
   95.47892,
   95.94693,
   96.02597,
   93.3635,
   84.56484,
   65.95871,
   42.11706};
   Double_t Graph3_felx3024[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph3_fely3024[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph3_fehx3024[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph3_fehy3024[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   grae = new TGraphAsymmErrors(10,Graph3_fx3024,Graph3_fy3024,Graph3_felx3024,Graph3_fehx3024,Graph3_fely3024,Graph3_fehy3024);
   grae->SetName("Graph3");
   grae->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   grae->SetFillColor(ci);
   grae->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   grae->SetLineColor(ci);
   grae->SetLineStyle(7);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   grae->Draw("z");
   
   Double_t Graph4_fx1011[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph4_fy1011[10] = {
   108.0732,
   102.2597,
   100.2246,
   101.796,
   105.3416,
   99.73788,
   98.62062,
   85.94448,
   62.90271,
   44.47931};
   Double_t Graph4_fex1011[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph4_fey1011[10] = {
   6.667786,
   4.792637,
   3.765295,
   3.224798,
   3.479167,
   3.377478,
   3.07273,
   3.40604,
   2.800731,
   2.87761};
   TGraphErrors *gre = new TGraphErrors(10,Graph4_fx1011,Graph4_fy1011,Graph4_fex1011,Graph4_fey1011);
   gre->SetName("Graph4");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetFillStyle(0);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   gre->Draw("||");
   
   Double_t gyieldsp_exp_statonly_1_fx1012[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t gyieldsp_exp_statonly_1_fy1012[10] = {
   108.0732,
   102.2597,
   100.2246,
   101.796,
   105.3416,
   99.73788,
   98.62062,
   85.94448,
   62.90271,
   44.47931};
   Double_t gyieldsp_exp_statonly_1_fex1012[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t gyieldsp_exp_statonly_1_fey1012[10] = {
   2.814265,
   2.293805,
   2.181326,
   2.056934,
   2.054972,
   2.059018,
   2.050204,
   2.01317,
   1.754638,
   1.667829};
   gre = new TGraphErrors(10,gyieldsp_exp_statonly_1_fx1012,gyieldsp_exp_statonly_1_fy1012,gyieldsp_exp_statonly_1_fex1012,gyieldsp_exp_statonly_1_fey1012);
   gre->SetName("gyieldsp_exp_statonly_1");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(1.2);
   
   TH1F *Graph_gyieldsp_exp_statonly_11012 = new TH1F("Graph_gyieldsp_exp_statonly_11012","Graph",100,-2.64,2.64);
   Graph_gyieldsp_exp_statonly_11012->SetMinimum(36.00388);
   Graph_gyieldsp_exp_statonly_11012->SetMaximum(117.6951);
   Graph_gyieldsp_exp_statonly_11012->SetDirectory(0);
   Graph_gyieldsp_exp_statonly_11012->SetStats(0);
   Graph_gyieldsp_exp_statonly_11012->SetLineStyle(0);
   Graph_gyieldsp_exp_statonly_11012->SetMarkerStyle(20);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelOffset(0.007);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelSize(0.05);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleSize(0.06);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleOffset(1.1);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelOffset(0.007);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelSize(0.05);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleSize(0.06);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleOffset(1.5);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelOffset(0.007);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelSize(0.05);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetTitleSize(0.06);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_gyieldsp_exp_statonly_11012);
   
   gre->Draw("pz");
   
   TLegend *leg = new TLegend(0.6,0.1,0.9,0.3142857,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.05714286);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("Graph4","Data","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph0","CT10","lf");

   ci = TColor::GetColor("#ffff00");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(4);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph2","CT10+EPS09","lf");

   ci = TColor::GetColor("#009900");
   entry->SetFillColor(ci);
   entry->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   entry->SetLineColor(ci);
   entry->SetLineStyle(7);
   entry->SetLineWidth(4);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(-2.35,125,-0.35,140,"br");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(13);
   pt->SetTextFont(42);
   pt->SetTextSize(0.05714286);
   TText *AText = pt->AddText("Luminosity uncertainty: 3.5%");
   pt->Draw();
   
   pt = new TPaveText(0.27,0.2,0.5,0.3428571,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(13);
   pt->SetTextFont(42);
   pt->SetTextSize(0.05714286);
   AText = pt->AddText("W^{+} #rightarrow #font[12]{l}^{+} + #nu");
   AText = pt->AddText("p_{T}^{#font[12]{l}} > 25 GeV/c");
   pt->Draw();
      tex = new TLatex(0.96,0.9177143," #sqrt{s_{NN}} = 5.02 TeV");
tex->SetNDC();
   tex->SetTextAlign(31);
   tex->SetTextFont(42);
   tex->SetTextSize(0.05714286);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.16,0.9177143,"pPb 34.6 nb^{-1}");
tex->SetNDC();
   tex->SetTextFont(42);
   tex->SetTextSize(0.05714286);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.924,0.8476571,"CMS");
tex->SetNDC();
   tex->SetTextAlign(33);
   tex->SetTextFont(61);
   tex->SetTextSize(0.06857143);
   tex->SetLineWidth(2);
   tex->Draw();
   
   TH1F *Graph_copy = new TH1F("Graph_copy","Graph",100,-2.5,2.5);
   Graph_copy->SetMinimum(0);
   Graph_copy->SetMaximum(140);
   Graph_copy->SetDirectory(0);
   Graph_copy->SetStats(0);
   Graph_copy->SetLineStyle(0);
   Graph_copy->SetMarkerStyle(20);
   Graph_copy->GetXaxis()->SetNdivisions(505);
   Graph_copy->GetXaxis()->SetLabelFont(42);
   Graph_copy->GetXaxis()->SetLabelOffset(0.007);
   Graph_copy->GetXaxis()->SetLabelSize(0);
   Graph_copy->GetXaxis()->SetTitleSize(0.07142857);
   Graph_copy->GetXaxis()->SetTitleOffset(1.1);
   Graph_copy->GetXaxis()->SetTitleFont(42);
   Graph_copy->GetYaxis()->SetTitle("d#sigma (W^{+}#rightarrow#font[12]{l}^{+}#nu) / d#eta_{lab} [nb]");
   Graph_copy->GetYaxis()->SetLabelFont(42);
   Graph_copy->GetYaxis()->SetLabelOffset(0.007);
   Graph_copy->GetYaxis()->SetLabelSize(0.07142857);
   Graph_copy->GetYaxis()->SetTitleSize(0.07142857);
   Graph_copy->GetYaxis()->SetTitleOffset(1.05);
   Graph_copy->GetYaxis()->SetTitleFont(42);
   Graph_copy->GetZaxis()->SetLabelFont(42);
   Graph_copy->GetZaxis()->SetLabelOffset(0.007);
   Graph_copy->GetZaxis()->SetLabelSize(0.05);
   Graph_copy->GetZaxis()->SetTitleSize(0.06);
   Graph_copy->GetZaxis()->SetTitleFont(42);
   Graph_copy->Draw("sameaxis");
   pad1->Modified();
   c1->cd();
  
// ------------>Primitives in pad: pad2
   TPad *pad2 = new TPad("pad2", "pad2",0,0,1,0.288);
   pad2->Draw();
   pad2->cd();
   pad2->Range(-3.5,0.35,2.75,1.35);
   pad2->SetFillColor(0);
   pad2->SetFillStyle(4000);
   pad2->SetBorderMode(0);
   pad2->SetBorderSize(2);
   pad2->SetTickx(1);
   pad2->SetTicky(1);
   pad2->SetLeftMargin(0.16);
   pad2->SetRightMargin(0.04);
   pad2->SetTopMargin(0);
   pad2->SetBottomMargin(0.4);
   pad2->SetFrameFillStyle(4000);
   pad2->SetFrameBorderMode(0);
   pad2->SetFrameFillStyle(4000);
   pad2->SetFrameBorderMode(0);
   
   TH1F *Graph = new TH1F("Graph","Graph",100,-2.5,2.5);
   Graph->SetMinimum(0.75);
   Graph->SetMaximum(1.35);
   Graph->SetDirectory(0);
   Graph->SetStats(0);
   Graph->SetLineStyle(0);
   Graph->SetMarkerStyle(20);
   Graph->GetXaxis()->SetTitle("#eta_{lab}");
   Graph->GetXaxis()->SetNdivisions(505);
   Graph->GetXaxis()->SetLabelFont(42);
   Graph->GetXaxis()->SetLabelOffset(0.007);
   Graph->GetXaxis()->SetLabelSize(0.1666667);
   Graph->GetXaxis()->SetTitleSize(0.1666667);
   Graph->GetXaxis()->SetTitleOffset(1.1);
   Graph->GetXaxis()->SetTitleFont(42);
   Graph->GetYaxis()->SetTitle("Ratio ");
   Graph->GetYaxis()->SetNdivisions(503);
   Graph->GetYaxis()->SetLabelFont(42);
   Graph->GetYaxis()->SetLabelOffset(0.007);
   Graph->GetYaxis()->SetLabelSize(0.1666667);
   Graph->GetYaxis()->SetTitleSize(0.1666667);
   Graph->GetYaxis()->SetTitleOffset(0.45);
   Graph->GetYaxis()->SetTitleFont(42);
   Graph->GetZaxis()->SetLabelFont(42);
   Graph->GetZaxis()->SetLabelOffset(0.007);
   Graph->GetZaxis()->SetLabelSize(0.05);
   Graph->GetZaxis()->SetTitleSize(0.06);
   Graph->GetZaxis()->SetTitleFont(42);
   Graph->Draw("");
   
   Double_t Graph0_fx1013[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph0_fy1013[10] = {
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1};
   Double_t Graph0_fex1013[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph0_fey1013[10] = {
   0.0644708,
   0.06365122,
   0.06354681,
   0.06481966,
   0.06320752,
   0.0622177,
   0.05991862,
   0.05949606,
   0.06001632,
   0.06142499};
   gre = new TGraphErrors(10,Graph0_fx1013,Graph0_fy1013,Graph0_fex1013,Graph0_fey1013);
   gre->SetName("Graph0");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#ffff00");
   gre->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   gre->SetLineColor(ci);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(0);
   
   TH1F *Graph_Graph1013 = new TH1F("Graph_Graph1013","Graph",100,-2.88,2.88);
   Graph_Graph1013->SetMinimum(0.9222164);
   Graph_Graph1013->SetMaximum(1.077784);
   Graph_Graph1013->SetDirectory(0);
   Graph_Graph1013->SetStats(0);
   Graph_Graph1013->SetLineStyle(0);
   Graph_Graph1013->SetMarkerStyle(20);
   Graph_Graph1013->GetXaxis()->SetLabelFont(42);
   Graph_Graph1013->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph1013->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1013->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph1013->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph1013->GetXaxis()->SetTitleFont(42);
   Graph_Graph1013->GetYaxis()->SetLabelFont(42);
   Graph_Graph1013->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1013->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1013->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph1013->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph1013->GetYaxis()->SetTitleFont(42);
   Graph_Graph1013->GetZaxis()->SetLabelFont(42);
   Graph_Graph1013->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1013->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph1013->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph1013->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1013);
   
   gre->Draw("2");
   
   Double_t Graph1_fx1014[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph1_fy1014[10] = {
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1};
   Double_t Graph1_fex1014[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph1_fey1014[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   gre = new TGraphErrors(10,Graph1_fx1014,Graph1_fy1014,Graph1_fex1014,Graph1_fey1014);
   gre->SetName("Graph1");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#ffff00");
   gre->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   gre->SetLineColor(ci);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(0);
   gre->Draw("z");
   
   Double_t Graph2_fx1015[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph2_fy1015[10] = {
   0.8844678,
   0.9009383,
   0.9249909,
   0.9547005,
   0.9887677,
   1.01759,
   1.031104,
   1.025864,
   1.002086,
   0.9697318};
   Double_t Graph2_fex1015[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph2_fey1015[10] = {
   0.05296218,
   0.042007,
   0.03326947,
   0.02116912,
   0.0170915,
   0.01890429,
   0.01672622,
   0.01681633,
   0.01541551,
   0.01597539};
   gre = new TGraphErrors(10,Graph2_fx1015,Graph2_fy1015,Graph2_fex1015,Graph2_fey1015);
   gre->SetName("Graph2");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   gre->SetFillColor(ci);
   gre->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   gre->SetLineColor(ci);
   gre->SetLineStyle(7);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   
   TH1F *Graph_Graph1015 = new TH1F("Graph_Graph1015","Graph",100,-2.88,2.88);
   Graph_Graph1015->SetMinimum(0.8098732);
   Graph_Graph1015->SetMaximum(1.069463);
   Graph_Graph1015->SetDirectory(0);
   Graph_Graph1015->SetStats(0);
   Graph_Graph1015->SetLineStyle(0);
   Graph_Graph1015->SetMarkerStyle(20);
   Graph_Graph1015->GetXaxis()->SetLabelFont(42);
   Graph_Graph1015->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph1015->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1015->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph1015->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph1015->GetXaxis()->SetTitleFont(42);
   Graph_Graph1015->GetYaxis()->SetLabelFont(42);
   Graph_Graph1015->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1015->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1015->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph1015->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph1015->GetYaxis()->SetTitleFont(42);
   Graph_Graph1015->GetZaxis()->SetLabelFont(42);
   Graph_Graph1015->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1015->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph1015->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph1015->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1015);
   
   gre->Draw("2");
   
   Double_t Graph3_fx1016[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph3_fy1016[10] = {
   0.8844678,
   0.9009383,
   0.9249909,
   0.9547005,
   0.9887677,
   1.01759,
   1.031104,
   1.025864,
   1.002086,
   0.9697318};
   Double_t Graph3_fex1016[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph3_fey1016[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   gre = new TGraphErrors(10,Graph3_fx1016,Graph3_fy1016,Graph3_fex1016,Graph3_fey1016);
   gre->SetName("Graph3");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   gre->SetFillColor(ci);
   gre->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   gre->SetLineColor(ci);
   gre->SetLineStyle(7);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   gre->Draw("z");
   
   Double_t Graph4_fx1017[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph4_fy1017[10] = {
   1.043581,
   0.9670498,
   0.9692137,
   1.017865,
   1.085583,
   1.056925,
   1.089164,
   1.042601,
   0.9556571,
   1.024122};
   Double_t Graph4_fex1017[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph4_fey1017[10] = {
   0.06438575,
   0.04532301,
   0.03641199,
   0.03224499,
   0.03585407,
   0.03579123,
   0.03393516,
   0.041319,
   0.04255045,
   0.06625605};
   gre = new TGraphErrors(10,Graph4_fx1017,Graph4_fy1017,Graph4_fex1017,Graph4_fey1017);
   gre->SetName("Graph4");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetFillStyle(0);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   gre->Draw("||");
   
   Double_t Graph5_fx1018[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph5_fy1018[10] = {
   1.043581,
   0.9670498,
   0.9692137,
   1.017865,
   1.085583,
   1.056925,
   1.089164,
   1.042601,
   0.9556571,
   1.024122};
   Double_t Graph5_fex1018[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph5_fey1018[10] = {
   0.02717523,
   0.02169205,
   0.02109434,
   0.02056743,
   0.02117723,
   0.02181947,
   0.02264241,
   0.02442196,
   0.02665755,
   0.03840124};
   gre = new TGraphErrors(10,Graph5_fx1018,Graph5_fy1018,Graph5_fex1018,Graph5_fey1018);
   gre->SetName("Graph5");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   
   TH1F *Graph_Graph1018 = new TH1F("Graph_Graph1018","Graph",100,-2.64,2.64);
   Graph_Graph1018->SetMinimum(0.9107189);
   Graph_Graph1018->SetMaximum(1.130087);
   Graph_Graph1018->SetDirectory(0);
   Graph_Graph1018->SetStats(0);
   Graph_Graph1018->SetLineStyle(0);
   Graph_Graph1018->SetMarkerStyle(20);
   Graph_Graph1018->GetXaxis()->SetLabelFont(42);
   Graph_Graph1018->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph1018->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1018->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph1018->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph1018->GetXaxis()->SetTitleFont(42);
   Graph_Graph1018->GetYaxis()->SetLabelFont(42);
   Graph_Graph1018->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1018->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1018->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph1018->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph1018->GetYaxis()->SetTitleFont(42);
   Graph_Graph1018->GetZaxis()->SetLabelFont(42);
   Graph_Graph1018->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1018->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph1018->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph1018->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1018);
   
   gre->Draw("pz");
   
   TH1F *Graph_copy = new TH1F("Graph_copy","Graph",100,-2.5,2.5);
   Graph_copy->SetMinimum(0.75);
   Graph_copy->SetMaximum(1.35);
   Graph_copy->SetDirectory(0);
   Graph_copy->SetStats(0);
   Graph_copy->SetLineStyle(0);
   Graph_copy->SetMarkerStyle(20);
   Graph_copy->GetXaxis()->SetTitle("#eta_{lab}");
   Graph_copy->GetXaxis()->SetNdivisions(505);
   Graph_copy->GetXaxis()->SetLabelFont(42);
   Graph_copy->GetXaxis()->SetLabelOffset(0.007);
   Graph_copy->GetXaxis()->SetLabelSize(0.1666667);
   Graph_copy->GetXaxis()->SetTitleSize(0.1666667);
   Graph_copy->GetXaxis()->SetTitleOffset(1.1);
   Graph_copy->GetXaxis()->SetTitleFont(42);
   Graph_copy->GetYaxis()->SetTitle("Ratio ");
   Graph_copy->GetYaxis()->SetNdivisions(503);
   Graph_copy->GetYaxis()->SetLabelFont(42);
   Graph_copy->GetYaxis()->SetLabelOffset(0.007);
   Graph_copy->GetYaxis()->SetLabelSize(0.1666667);
   Graph_copy->GetYaxis()->SetTitleSize(0.1666667);
   Graph_copy->GetYaxis()->SetTitleOffset(0.45);
   Graph_copy->GetYaxis()->SetTitleFont(42);
   Graph_copy->GetZaxis()->SetLabelFont(42);
   Graph_copy->GetZaxis()->SetLabelOffset(0.007);
   Graph_copy->GetZaxis()->SetLabelSize(0.05);
   Graph_copy->GetZaxis()->SetTitleSize(0.06);
   Graph_copy->GetZaxis()->SetTitleFont(42);
   Graph_copy->Draw("sameaxis");
   pad2->Modified();
   c1->cd();
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
}
コード例 #21
0
void bug() {

  gStyle->SetOptStat(0);

  TFile *fD = TFile::Open("esim_trunk/default/output_ana.root");
  TFile *fP = TFile::Open("esim_trunk/patch1/output_ana.root");

  TLegend *tlD = new TLegend(0.1,0.89,0.9,1.0); //0.15,0.8,0.8,0);
  tlD->SetHeader("trunk 26841");
  tlD->SetTextSize(0.08);
  TH1F *hDall = (TH1F*)fD->Get("eth_all");
  hDall->SetLineColor(2);
  hDall->SetLineWidth(2);
  hDall->SetTitle(";#theta_{lab}[deg];num. electron");
  tlD->AddEntry(hDall,"e^{-} (ALL)","l");
  TH1F *hDeid = (TH1F*)fD->Get("eth_eid");
  hDeid->SetLineColor(2);
  hDeid->SetLineWidth(2);
  hDeid->SetLineStyle(9);
  tlD->AddEntry(hDeid,"e^{-} (EID)","l");

  TLegend *tlP = new TLegend(0.1,0.89,0.9,1.0);
  tlP->SetTextSize(0.08);
  tlP->SetHeader("trunk 26841 + patch");
  TH1F *hPall = (TH1F*)fP->Get("eth_all");
  hPall->SetLineColor(4);
  hPall->SetLineWidth(2);
  hPall->SetTitle(";#theta_{lab}[deg];num. electron");
  tlP->AddEntry(hPall,"e^{-} (ALL)","l");
  TH1F *hPeid = (TH1F*)fP->Get("eth_eid");
  hPeid->SetLineColor(4);
  hPeid->SetLineWidth(2);
  hPeid->SetLineStyle(9);
  tlP->AddEntry(hPeid,"e^{-} (EID)","l");

  TLegend *tlE = new TLegend(0.1,0.89,0.9,1.0);
  tlE->SetHeader("Efficiency");
  tlE->SetTextSize(0.08);
  TEfficiency *effD = new TEfficiency(*hDeid, *hDall);
  //effD->GetXaxis()->SetRangeUser(12,30);
  effD->SetMarkerStyle(20);
  effD->SetMarkerSize(1);
  effD->SetMarkerColor(2);
  effD->SetLineColor(2);
  effD->SetTitle(";#theta_{lab}[deg];Efficiency");
  tlE->AddEntry(effD, "trunk 26841", "pl");

  TEfficiency *effP = new TEfficiency(*hPeid, *hPall);
  //effP->GetXaxis()->SetRangeUser(12,30);
  effP->SetMarkerStyle(20);
  effP->SetMarkerSize(1);
  effP->SetMarkerColor(4);
  effP->SetLineColor(4);
  tlE->AddEntry(effP, "trunk 26841 + patch", "pl");

  TCanvas *tc = new TCanvas("tc","tc",1000,700);
  tc->Divide(2);

  tc->cd(1);
  hDall->Draw();
  hDeid->Draw("same");
  tlD->Draw();

  tc->cd(2);
  hPall->Draw();
  hPeid->Draw("same");
  tlP->Draw();

  //tc->cd(3);
  //effP->Draw();
  //effD->Draw("same");
  //tlE->Draw();

}
コード例 #22
0
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
int main (int argc, char ** argv) {

  // check number of inpt parameters
  if(argc < 2){
    cerr<<"Forgot to parse the cfg file --> exit "<<endl;
    return -1;
  }

  // Set Root style from global enviroment path                                                                                                                               
  string ROOTStyle;
  if(getenv ("ROOTStyle")!=NULL){
    ROOTStyle = getenv ("ROOTStyle");
    gROOT->ProcessLine((".x "+ROOTStyle+"/setTDRStyle.C").c_str());
  }

  gStyle->SetOptStat(0);
  gStyle->SetPadTopMargin(0.09);
  gStyle->SetPadLeftMargin(0.13);
  gStyle->SetErrorX(0.5);


  // parse config file parameter
  if (gConfigParser) return 1 ;
  gConfigParser = new ConfigParser();

  TString config ; 
  config.Form("%s",argv[1]);

  if(!(gConfigParser->init(config))){
      cout << ">>> parseConfigFile::Could not open configuration file " << config << endl;
      return -1;
  }

  // import base directory where samples are located and txt file with the directory name + other info
  string InputBaseDirectory  = gConfigParser -> readStringOption("Input::InputBaseDirectory");

  // import from cfg file the cross section value for this sample
  float CrossSection   = gConfigParser -> readFloatOption("Input::CrossSection");

  // total number of events
  int maxEventNumber   = gConfigParser -> readFloatOption("Input::EventsNumber");

  // treeName
  string treeName      = gConfigParser -> readStringOption("Input::TreeName");

  // take the cut list
  string InputCutList  = gConfigParser -> readStringOption("Input::InputCutList");

  // Read the cut file
  vector <cutContainer> CutList;
  if(ReadInputCutFile(InputCutList,CutList) <= 0){
    cerr<<" Empty Cut List File or not Exisisting --> Exit "<<endl; return -1;}

  // take the variable list to be plotted
  string InputVariableList  = gConfigParser -> readStringOption("Input::InputVariableList");
  vector<variableContainer> variableList;

  if(ReadInputVariableFile(InputVariableList,variableList) <= 0 ){
    cerr<<" Empty Variable List File or not Exisisting --> Exit "<<endl; return -1;}

  // take lumi and other parameters
  float lumi  =  gConfigParser -> readFloatOption("Option::Lumi"); // fb^(-1)
  lumi *= 1000. ;   // transform into pb^(-1)

  finalStateString    = gConfigParser -> readStringOption("Option::finalStateString");

  matchingCone        = gConfigParser -> readFloatOption("Option::matchingCone"); 
  minLeptonCleaningPt = gConfigParser -> readFloatOption("Option::minLeptonCleaningPt"); 
  minLeptonCutPt      = gConfigParser -> readFloatOption("Option::minLeptonCutPt");
  minJetCutPt         = gConfigParser -> readFloatOption("Option::minJetCutPt");
  usePuppiAsDefault   = gConfigParser -> readBoolOption("Option::usePuppiAsDefault");
  leptonIsoCut_mu     = gConfigParser -> readFloatOption("Option::leptonIsoCutMu");
  leptonIsoCut_el     = gConfigParser -> readFloatOption("Option::leptonIsoCutEl");
  leptonIsoCutLoose   = gConfigParser -> readFloatOption("Option::leptonIsoCutLoose");

  // output directory
  string outputPlotDirectory = gConfigParser -> readStringOption("Output::outputPlotDirectory");
  system(("mkdir -p output/"+outputPlotDirectory).c_str());
  system(("rm -r output/"+outputPlotDirectory+"/*").c_str());
  system(("mkdir -p output/"+outputPlotDirectory+"/xs").c_str());
  system(("mkdir -p output/"+outputPlotDirectory+"/norm").c_str());


  ///// Start the analysis  
  map<string,TH1F*> histoCutEff ;

  TChain* chain = new TChain (treeName.c_str()) ;  
  chain->Add ((InputBaseDirectory+"/*.root").c_str()) ;
  int totEvent = chain->GetEntries();

  readTree* reader  = new readTree((TTree*)(chain));

  cout<<"Lumi (fb-1) "<<lumi/1000<<" entries before "<<totEvent<<" cross section "<<CrossSection<<" Nevents before selections "<<lumi*CrossSection<<" weight "<<lumi*CrossSection/float(totEvent)<<endl;

  float weight = 1.0*lumi*CrossSection/float(totEvent) ;

  // make the plot container 
  vector<histoContainer> plotVector;

  for(size_t iCut = 0; iCut < CutList.size(); iCut++){
    histoCutEff["WW_EWK_pos_"+to_string(iCut)+"_"+CutList.at(iCut).cutLayerName] = new TH1F(("WW_EWK_pos_"+to_string(iCut)+"_"+CutList.at(iCut).cutLayerName).c_str(),"",15,0,15);
    for(size_t iVar = 0; iVar < variableList.size(); iVar++){
      plotVector.push_back(histoContainer(CutList.at(iCut).cutLayerName,variableList.at(iVar)));
    }
  }

  int passingLHEFilter = 0 ;
  
  int maximumEvents = chain->GetEntries () ;
  if (maxEventNumber > 0 && maxEventNumber < maximumEvents) 
    maximumEvents = maxEventNumber ;
  
  // Loop on the events
  for(int iEvent = 0; iEvent < maximumEvents ; iEvent++){

    reader->fChain->GetEntry(iEvent) ;

    if (iEvent % 100000 == 0) cout << "reading event " << iEvent << "\n" ;

    // filter LHE level leptons
    if(TString(finalStateString).Contains("UU")){
      if(fabs(reader->leptonLHEpid1) != 13 or fabs(reader->leptonLHEpid2) != 13)
        continue;
    }
    else if(TString(finalStateString).Contains("EE")){
      if(fabs(reader->leptonLHEpid1) != 11 or fabs(reader->leptonLHEpid2) != 11) continue;
    }
    else if(TString(finalStateString).Contains("EU")){
      if(fabs(reader->leptonLHEpid1) != 11 or fabs(reader->leptonLHEpid2) !=13) continue ;
    }
    else if(TString(finalStateString).Contains("UE")){
      if(fabs(reader->leptonLHEpid1) != 13 or fabs(reader->leptonLHEpid2) !=11) continue ;
    }
    else{
      cerr<<"problem with lhe level filter definition --> skip event"<<endl;
      continue;
    }

    passingLHEFilter++;

    // if an event pass the cut, fill the associated map                                                              
    leptonContainer lepton1,lepton2,parton1,parton2,neutrino1,neutrino2,vboson1,vboson2;

    lepton1.lepton4V_.SetPtEtaPhiM(reader->leptonLHEpt1,reader->leptonLHEeta1,reader->leptonLHEphi1,reader->leptonLHEm1);
    lepton1.charge_  = reader->leptonLHEch1;
    lepton1.flavour_ = reader->leptonLHEpid1;  

    lepton2.lepton4V_.SetPtEtaPhiM(reader->leptonLHEpt2,reader->leptonLHEeta2,reader->leptonLHEphi2,reader->leptonLHEm2);
    lepton2.charge_  = reader->leptonLHEch2;
    lepton2.flavour_ = reader->leptonLHEpid2;  

    parton1.lepton4V_.SetPtEtaPhiM(reader->jetLHEPartonpt1,reader->jetLHEPartoneta1,reader->jetLHEPartonphi1,0.);
    parton2.lepton4V_.SetPtEtaPhiM(reader->jetLHEPartonpt2,reader->jetLHEPartoneta2,reader->jetLHEPartonphi2,0.);

    neutrino1.lepton4V_.SetPtEtaPhiM(reader->neutrinoLHEpt1,reader->neutrinoLHEeta1,reader->neutrinoLHEphi1,0.);
    neutrino1.charge_  = 0.;
    neutrino1.flavour_ = reader->neutrinoLHEpid1;  

    neutrino2.lepton4V_.SetPtEtaPhiM(reader->neutrinoLHEpt2,reader->neutrinoLHEeta2,reader->neutrinoLHEphi2,0.);
    neutrino2.charge_  = 0.;
    neutrino2.flavour_ = reader->neutrinoLHEpid2;  

    vboson1.lepton4V_.SetPtEtaPhiM(reader->vbosonLHEpt1,reader->vbosonLHEeta1,reader->vbosonLHEphi1,reader->vbosonLHEm1);
    vboson1.charge_  = reader->vbosonLHEch1;
    vboson1.flavour_ = reader->vbosonLHEpid1;  
    
    vboson2.lepton4V_.SetPtEtaPhiM(reader->vbosonLHEpt2,reader->vbosonLHEeta2,reader->vbosonLHEphi2,reader->vbosonLHEm2);
    vboson2.charge_  = reader->vbosonLHEch2;
    vboson2.flavour_ = reader->vbosonLHEpid2;  

    float minDR_1 = 999;
    float minDR_2 = 999;

    vector<leptonContainer> lepton, neutrino;
    lepton.push_back(lepton1);
    lepton.push_back(lepton2);
    neutrino.push_back(neutrino1);
    neutrino.push_back(neutrino2);

    leptonContainer leptFromV1, leptFromV2, neuFromV1, neuFromV2;

    for(size_t iLep= 0; iLep < lepton.size(); iLep++){
      for(size_t iNeu = 0; iNeu < neutrino.size(); iNeu++){
	if((lepton.at(iLep).lepton4V_+neutrino.at(iNeu).lepton4V_).DeltaR(vboson1.lepton4V_) < minDR_1 ){
	  minDR_1    = (lepton.at(iLep).lepton4V_+neutrino.at(iNeu).lepton4V_).DeltaR(vboson1.lepton4V_);
	  leptFromV1 = lepton.at(iLep);
	  neuFromV1  = neutrino.at(iNeu);
	}

	if((lepton.at(iLep).lepton4V_+neutrino.at(iNeu).lepton4V_).DeltaR(vboson2.lepton4V_) < minDR_2){
	  minDR_2    = (lepton.at(iLep).lepton4V_+neutrino.at(iNeu).lepton4V_).DeltaR(vboson2.lepton4V_);
	  leptFromV2 = lepton.at(iLep);
	  neuFromV2  = neutrino.at(iNeu);
	}	

      }
    }

    if(leptFromV1.lepton4V_ == leptFromV2.lepton4V_ or neuFromV1.lepton4V_ == neuFromV2.lepton4V_){
      cerr<<" bad matching with gen W "<<endl;
      continue;
    }
		       

    double costheta1 = 0;
    double costheta2 = 0;
    double Phi  = 0;
    double costhetastar  = 0;
    double Phi1  = 0;

    double costheta1_vbf = 0;
    double costheta2_vbf = 0;
    double Phi_vbf = 0;
    double costhetastar_vbf = 0;
    double Phi1_vbf = 0;


    TLorentzVector VV = vboson1.lepton4V_ + vboson2.lepton4V_;

    if(leptFromV1.charge_ > 0  and leptFromV2.charge_ > 0){

      computeAnglesResonance(VV,vboson1.lepton4V_,neuFromV1.lepton4V_,leptFromV1.lepton4V_,vboson2.lepton4V_,neuFromV2.lepton4V_,leptFromV2.lepton4V_,
			     costheta1,costheta2,Phi,costhetastar,Phi1);

      computeAnglesVBF(VV,vboson1.lepton4V_,neuFromV1.lepton4V_,leptFromV1.lepton4V_,vboson2.lepton4V_,neuFromV2.lepton4V_,leptFromV2.lepton4V_,parton1.lepton4V_,
		       parton2.lepton4V_,costheta1_vbf,costheta2_vbf,Phi_vbf,costhetastar_vbf,Phi1_vbf);
    }
    else if(leptFromV1.charge_ < 0  and leptFromV2.charge_ < 0){

      computeAnglesResonance(VV,vboson1.lepton4V_,leptFromV1.lepton4V_,neuFromV1.lepton4V_,vboson2.lepton4V_,leptFromV2.lepton4V_,neuFromV2.lepton4V_,
			     costheta1,costheta2,Phi,costhetastar,Phi1);

      computeAnglesVBF(VV,vboson1.lepton4V_,leptFromV1.lepton4V_,neuFromV1.lepton4V_,vboson2.lepton4V_,leptFromV2.lepton4V_,neuFromV2.lepton4V_,parton1.lepton4V_,
		       parton2.lepton4V_,costheta1_vbf,costheta2_vbf,Phi_vbf,costhetastar_vbf,Phi1_vbf);

    }

    else if(leptFromV1.charge_ < 0  and leptFromV2.charge_ > 0){
      computeAnglesResonance(VV,vboson1.lepton4V_,leptFromV1.lepton4V_,neuFromV1.lepton4V_,vboson2.lepton4V_,neuFromV2.lepton4V_,leptFromV2.lepton4V_,
			     costheta1,costheta2,Phi,costhetastar,Phi1);

      computeAnglesVBF(VV,vboson1.lepton4V_,leptFromV1.lepton4V_,neuFromV1.lepton4V_,vboson2.lepton4V_,neuFromV2.lepton4V_,leptFromV2.lepton4V_,parton1.lepton4V_,
		       parton2.lepton4V_,costheta1_vbf,costheta2_vbf,Phi_vbf,costhetastar_vbf,Phi1_vbf);
    }
    else if(leptFromV1.charge_ > 0  and leptFromV2.charge_ < 0){

      computeAnglesResonance(VV,vboson1.lepton4V_,neuFromV1.lepton4V_,leptFromV1.lepton4V_,vboson2.lepton4V_,leptFromV2.lepton4V_,neuFromV2.lepton4V_,
			     costheta1,costheta2,Phi,costhetastar,Phi1);

      computeAnglesVBF(VV,vboson1.lepton4V_,neuFromV1.lepton4V_,leptFromV1.lepton4V_,vboson2.lepton4V_,leptFromV2.lepton4V_,neuFromV2.lepton4V_,parton1.lepton4V_,
		       parton2.lepton4V_,costheta1_vbf,costheta2_vbf,Phi_vbf,costhetastar_vbf,Phi1_vbf);

    }
    else{ cerr<<" wrong charge composition "<<endl;
      continue;
    }
    
    float mTR = 0;
    float mR  = 0;

    TLorentzVector L_met ,L_dijet, L_dilepton, L_LLmet; 

    L_met      = neutrino1.lepton4V_ + neutrino2.lepton4V_;
    L_dijet    = parton1.lepton4V_   + parton2.lepton4V_;
    L_dilepton = lepton1.lepton4V_   + lepton2.lepton4V_;
    L_LLmet    = L_dilepton + L_met ;

    computeRazor(lepton1.lepton4V_,lepton2.lepton4V_,L_met,mTR,mR);

    if(lepton1.lepton4V_.Pt() < minLeptonCutPt or lepton2.lepton4V_.Pt() < minLeptonCutPt) continue;

    // Loop  on the cut list --> one cut for each polarization
    for(size_t iCut = 0; iCut < CutList.size(); iCut++){

      // cut the events
      string name = "WW_EWK";
      if(!passCutContainerSelection(reader,
                                    CutList.at(iCut),
                                    name,
				    int(iCut),
                                    usePuppiAsDefault,
                                    minLeptonCutPt,
                                    minLeptonCleaningPt,
                                    leptonIsoCut_mu,
                                    leptonIsoCut_el,
                                    leptonIsoCutLoose,
                                    matchingCone,
                                    minJetCutPt,
                                    histoCutEff,
				    finalStateString)) continue;

      
      float asimL = (lepton1.lepton4V_.Pt()-lepton2.lepton4V_.Pt())/(lepton1.lepton4V_.Pt()+lepton2.lepton4V_.Pt()) ;


      float asimJ    = (parton1.lepton4V_.Pt()-parton2.lepton4V_.Pt())/(parton1.lepton4V_.Pt()+parton2.lepton4V_.Pt()) ;
      float Rvar     = (lepton1.lepton4V_.Pt()*lepton2.lepton4V_.Pt())/(parton1.lepton4V_.Pt()*parton2.lepton4V_.Pt()) ;

      // loop on variables
      for(size_t iVar = 0; iVar < variableList.size(); iVar++){
        histoContainer tmpPlot;
        tmpPlot.cutName = CutList.at(iCut).cutLayerName;
        tmpPlot.varName = variableList.at(iVar).variableName;
        vector<histoContainer>::iterator itVec ;
        itVec = find(plotVector.begin(),plotVector.end(),tmpPlot);
        if(itVec == plotVector.end()){
          cerr<<"Problem -->plot not found for "<<CutList.at(iCut).cutLayerName<<"  "<<variableList.at(iVar).variableName<<endl;
          continue ;
        }
	
	// vector boson info
	if(variableList.at(iVar).variableName == "ptV1"){
          itVec->histogram->Fill(vboson1.lepton4V_.Pt(),1.*weight) ; 
        }
	else if(variableList.at(iVar).variableName == "ptV2"){
          itVec->histogram->Fill(vboson2.lepton4V_.Pt(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "etaV1"){
          itVec->histogram->Fill(vboson1.lepton4V_.Eta(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "etaV2"){
          itVec->histogram->Fill(vboson2.lepton4V_.Eta(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptVV"){
          itVec->histogram->Fill(L_dijet.Pt(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "mVV"){
          itVec->histogram->Fill(L_dijet.M(),weight) ;
        }

	// decay information
	if(variableList.at(iVar).variableName == "costheta1"){
          itVec->histogram->Fill(fabs(costheta1),1.*weight) ; 
        }
	else if(variableList.at(iVar).variableName == "costheta2"){
          itVec->histogram->Fill(fabs(costheta2),weight) ;
        }
	if(variableList.at(iVar).variableName == "costheta1_vbf"){
          itVec->histogram->Fill(fabs(costheta1_vbf),1.*weight) ; 
        }
	else if(variableList.at(iVar).variableName == "costheta2_vbf"){
          itVec->histogram->Fill(fabs(costheta2_vbf),weight) ;
        }

	if(variableList.at(iVar).variableName == "Phi"){
          itVec->histogram->Fill(fabs(Phi),1.*weight) ; 
        }
	else if(variableList.at(iVar).variableName == "Phi1"){
          itVec->histogram->Fill(fabs(Phi1),weight) ;
        }
	if(variableList.at(iVar).variableName == "Phi_vbf"){
          itVec->histogram->Fill(fabs(Phi_vbf),1.*weight) ; 
        }
	else if(variableList.at(iVar).variableName == "Phi1_vbf"){
          itVec->histogram->Fill(fabs(Phi1_vbf),weight) ;
        }

	else if(variableList.at(iVar).variableName == "costhetastar"){
          itVec->histogram->Fill(fabs(costhetastar),weight) ;
        }
	else if(variableList.at(iVar).variableName == "costhetastar_vbf"){
          itVec->histogram->Fill(fabs(costhetastar_vbf),weight) ;
        }

	else if(variableList.at(iVar).variableName == "mTR"){
          itVec->histogram->Fill(mTR,weight) ;
	}

	else if(variableList.at(iVar).variableName == "mR"){
          itVec->histogram->Fill(mR,weight) ;
	}

	// jet info

	if(variableList.at(iVar).variableName == "ptj1"){
          itVec->histogram->Fill(parton1.lepton4V_.Pt(),1.*weight) ; 
        }
	else if(variableList.at(iVar).variableName == "ptj2"){
          itVec->histogram->Fill(parton2.lepton4V_.Pt(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "etaj1"){
          itVec->histogram->Fill(parton1.lepton4V_.Eta(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "etaj2"){
          itVec->histogram->Fill(parton2.lepton4V_.Eta(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "detajj"){
          itVec->histogram->Fill(fabs(parton1.lepton4V_.Eta()-parton2.lepton4V_.Eta()),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptjj"){
          itVec->histogram->Fill(L_dijet.Pt(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "mjj"){
          itVec->histogram->Fill(L_dijet.M(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "Asim_j"){
          itVec->histogram->Fill(asimJ,weight) ;
        }
	else if(variableList.at(iVar).variableName == "DeltaPhi_JJ"){
          itVec->histogram->Fill(fabs(parton1.lepton4V_.DeltaPhi(parton2.lepton4V_)),weight) ;
        }

	else if(variableList.at(iVar).variableName == "ptl1"){
          itVec->histogram->Fill(lepton1.lepton4V_.Pt(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptl2"){
          itVec->histogram->Fill(lepton2.lepton4V_.Pt(),weight) ;
        }
 
	else if(variableList.at(iVar).variableName == "etal1"){
          itVec->histogram->Fill(lepton1.lepton4V_.Eta(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "etal2"){
          itVec->histogram->Fill(lepton2.lepton4V_.Eta(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "mll"){
          itVec->histogram->Fill(L_dilepton.M(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptll"){
          itVec->histogram->Fill(L_dilepton.Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_LL"){
          itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(lepton2.lepton4V_)),weight) ;
        }
	else if(variableList.at(iVar).variableName == "Asim_l"){
          itVec->histogram->Fill(asimL,weight) ;
        }

	else if(variableList.at(iVar).variableName == "met"){
          itVec->histogram->Fill(L_met.Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "R"){
          itVec->histogram->Fill(Rvar,weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_LMet"){
          itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(L_met)),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptLMet"){
          itVec->histogram->Fill((lepton1.lepton4V_ + L_met).Pt(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "DeltaPhi_TLMet"){
          itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(L_met)),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptTLMet"){
          itVec->histogram->Fill((lepton2.lepton4V_ + L_met).Pt(),weight) ;
        }
	else if(variableList.at(iVar).variableName == "DeltaPhi_LLMet"){
          itVec->histogram->Fill(fabs(L_dilepton.DeltaPhi(L_met)),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptLLMet"){
          itVec->histogram->Fill((L_dilepton + L_met).Pt(),weight) ;
        }
	///
	else if(variableList.at(iVar).variableName == "DeltaPhi_LJL"){
          itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(parton1.lepton4V_)),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptLJL"){
          itVec->histogram->Fill((lepton1.lepton4V_+parton1.lepton4V_).Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_TJL"){
          itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(parton2.lepton4V_)),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptTJL"){
          itVec->histogram->Fill((lepton1.lepton4V_+parton2.lepton4V_).Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_JJL"){
          itVec->histogram->Fill(fabs(lepton1.lepton4V_.DeltaPhi(L_dijet)),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptJJL"){
          itVec->histogram->Fill((lepton1.lepton4V_+L_dijet).Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_LJTL"){
          itVec->histogram->Fill(fabs(lepton2.lepton4V_.DeltaPhi(parton1.lepton4V_)),weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_TJTL"){
          itVec->histogram->Fill(fabs(lepton2.lepton4V_.DeltaPhi(parton2.lepton4V_)),weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_JJTL"){
          itVec->histogram->Fill(fabs(lepton2.lepton4V_.DeltaPhi(L_dijet)),weight) ;
        }


	else if(variableList.at(iVar).variableName == "ptLJTL"){
          itVec->histogram->Fill((lepton2.lepton4V_+parton1.lepton4V_).Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "ptTJTL"){
          itVec->histogram->Fill((lepton2.lepton4V_+parton2.lepton4V_).Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "ptJJTL"){
          itVec->histogram->Fill((lepton2.lepton4V_+L_dijet).Pt(),weight) ;
        }

 
	else if(variableList.at(iVar).variableName == "DeltaPhi_LJLL"){
          itVec->histogram->Fill(fabs(L_dilepton.DeltaPhi(parton1.lepton4V_)),weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_TJLL"){
          itVec->histogram->Fill(fabs(L_dilepton.DeltaPhi(parton2.lepton4V_)),weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_JJLL"){
          itVec->histogram->Fill(fabs(L_dilepton.DeltaPhi(L_dijet)),weight) ;
        }

	else if(variableList.at(iVar).variableName == "ptLJLL"){
          itVec->histogram->Fill((L_dilepton+parton1.lepton4V_).Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "ptTJLL"){
          itVec->histogram->Fill((L_dilepton+parton2.lepton4V_).Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "ptJJLL"){
          itVec->histogram->Fill((L_dilepton+L_dijet).Pt(),weight) ;
        }

	///
	else if(variableList.at(iVar).variableName == "DeltaPhi_JJMet"){
          itVec->histogram->Fill(fabs(L_dijet.DeltaPhi(L_met)),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptJJMet"){
          itVec->histogram->Fill((L_dijet+L_met).Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_LJMet"){
          itVec->histogram->Fill(fabs(parton1.lepton4V_.DeltaPhi(L_met)),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptLJMet"){
          itVec->histogram->Fill((parton1.lepton4V_+L_met).Pt(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "DeltaPhi_TJMet"){
          itVec->histogram->Fill(fabs(parton2.lepton4V_.DeltaPhi(L_met)),weight) ;
        }
	else if(variableList.at(iVar).variableName == "ptTJMet"){
          itVec->histogram->Fill((parton2.lepton4V_+L_met).Pt(),weight) ;
        }
 
	else if(variableList.at(iVar).variableName == "mlljj"){
          itVec->histogram->Fill((L_dilepton+L_dijet).M(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "mlljjmet"){
          itVec->histogram->Fill((L_dilepton+L_dijet+L_met).M(),weight) ;
        }

	else if(variableList.at(iVar).variableName == "mTH"){
          itVec->histogram->Fill(sqrt(2*L_dilepton.Pt()*L_met.Pt()*(1-TMath::Cos(L_dilepton.DeltaPhi(L_met)))),weight) ;
        } 
      } // loop on variables
      
    } // Loop  on the cut list

  } // Loop on the events

  
  TFile* outputEfficiency = new TFile(("output/"+outputPlotDirectory+"/outputEfficiency.root").c_str(),"RECREATE");

  for(map<string,TH1F*>::const_iterator itMap = histoCutEff.begin(); itMap !=  histoCutEff.end(); itMap++){
    itMap->second->Scale(1./itMap->second->GetBinContent(1));
    itMap->second->Write();
  }

  outputEfficiency->Close();    

  
  // make the canvas and basic banners                                                                                                                                         
  TCanvas *cCanvas = new TCanvas("cCanvas","",1,52,550,550);
  cCanvas->SetTicks();
  cCanvas->SetFillColor(0);
  cCanvas->SetBorderMode(0);
  cCanvas->SetBorderSize(2);
  cCanvas->SetTickx(1);
  cCanvas->SetTicky(1);
  cCanvas->SetRightMargin(0.05);
  cCanvas->SetBottomMargin(0.12);
  cCanvas->SetFrameBorderMode(0);

  cCanvas->cd();

  TPad* upperPad = new TPad("upperPad", "upperPad", .005, .180, .995, .980);
  TPad* lowerPad = new TPad("lowerPad", "lowerPad", .005, .005, .995, .18);
  lowerPad->SetGridx();
  lowerPad->SetGridy();
  upperPad->SetLeftMargin(0.12);
  upperPad->SetRightMargin(0.1);
  lowerPad->SetLeftMargin(0.12);
  lowerPad->SetRightMargin(0.1);
  lowerPad->SetTopMargin(0.002);

  lowerPad->Draw();
  upperPad->Draw();

  TCanvas *cCanvasNorm = new TCanvas("cCanvasNorm","",1,52,550,550);
  cCanvasNorm->SetTicks();
  cCanvasNorm->SetFillColor(0);
  cCanvasNorm->SetBorderMode(0);
  cCanvasNorm->SetBorderSize(2);
  cCanvasNorm->SetTickx(1);
  cCanvasNorm->SetTicky(1);
  cCanvasNorm->SetRightMargin(0.05);
  cCanvasNorm->SetBottomMargin(0.12);
  cCanvasNorm->SetFrameBorderMode(0);

  TLatex * tex = new TLatex(0.88,0.92," 14 TeV");
  tex->SetNDC();
  tex->SetTextAlign(31);
  tex->SetTextFont(42);
  tex->SetTextSize(0.045);
  tex->SetLineWidth(2);
  TLatex * tex2 = new TLatex(0.14,0.92,"Delphes");
  tex2->SetNDC();
  tex2->SetTextFont(61);
  tex2->SetTextSize(0.045);
  tex2->SetLineWidth(2);
  TLatex * tex3 = new TLatex(0.295,0.92,"Simulation Preliminary");
  tex3->SetNDC();
  tex3->SetTextFont(52);
  tex3->SetTextSize(0.04);
  tex3->SetLineWidth(2);

  TLegend* legend = new TLegend(0.55,0.75,0.85,0.89);
  legend->SetBorderSize(0);
  legend->SetFillColor(0);
  legend->SetFillStyle(0);
  legend->SetTextSize(0.04);
  legend->SetTextFont(42);
  legend->SetNColumns (3) ;
 
  // make the plot on the same canvas for each variable (legend entry is the cut layer name)  
  vector<TH1F*>  numerator ;
  vector<TH1F*>  denominator ;
  for(size_t iVar = 0; iVar < variableList.size(); iVar++){ // loop on var
   
    numerator.clear();
    denominator.clear();

    for(size_t iCut = 0; iCut < CutList.size(); iCut++){ // loop on cuts
        histoContainer tmpPlot;
        tmpPlot.cutName = CutList.at(iCut).cutLayerName;
        tmpPlot.varName = variableList.at(iVar).variableName;
        vector<histoContainer>::iterator itVec ;
        itVec = find(plotVector.begin(),plotVector.end(),tmpPlot);
        if(itVec == plotVector.end()){
          cerr<<"Problem -->plot not found for "<<CutList.at(iCut).cutLayerName<<"  "<<variableList.at(iVar).variableName<<endl;
        }

       
        itVec->histogram->GetXaxis()->SetTitleSize(0.04);
        itVec->histogram->GetXaxis()->SetTitleOffset(1.16);
        itVec->histogram->GetXaxis()->SetLabelSize(0.04);

        itVec->histogram->GetYaxis()->SetRangeUser(0.001,itVec->histogram->GetMaximum()*1.25);
        itVec->histogram->GetYaxis()->SetTitleSize(0.05);
        itVec->histogram->GetYaxis()->SetTitleOffset(1.20);
        itVec->histogram->GetYaxis()->SetLabelSize(0.04);

        itVec->histogram->SetLineColor(iCut+1);

        if(iCut %2 == 0)
          itVec->histogram->SetLineStyle(1);
        else
          itVec->histogram->SetLineStyle(2);

        itVec->histogram->SetLineWidth(2);
        itVec->histogram->GetYaxis()->SetTitle("#sigma x lumi");

        upperPad->cd();

        if(iCut == 0) 
          itVec->histogram->Draw("hist");
        else
          itVec->histogram->Draw("hist same");

        legend->AddEntry(itVec->histogram,CutList.at(iCut).cutLayerName.c_str(),"l");

        if(itVec->findCutByLabel("LL")) numerator.push_back(itVec->histogram);
        denominator.push_back(itVec->histogram);

	cCanvasNorm->cd();

	TH1F* htempNorm = (TH1F*) itVec->histogram->Clone((string(itVec->histogram->GetName())+"_norm").c_str());
	htempNorm->Scale(1./itVec->histogram->Integral());

	htempNorm->GetYaxis()->SetRangeUser(0.,htempNorm->GetMaximum()*1.5);

        if(iCut == 0)
          htempNorm->Draw("hist");
        else
          htempNorm->Draw("hist same");
    }
    
    // make ratio plot
    lowerPad->cd();
    
    TH1F* numTotal = 0;
    TH1F* denTotal = 0;
    TH1F* ratio    = 0;
    TH1F* ratioW   = 0;

    for(size_t itNum = 0; itNum < numerator.size(); itNum ++){
      if(itNum == 0 and ratio == 0) 
        numTotal = (TH1F*) numerator.at(itNum)->Clone(("Num_"+string(numerator.at(itNum)->GetName())).c_str());
      else if(ratio !=0) 
        numTotal->Add(numerator.at(itNum));
    }

    for(size_t itDen = 0; itDen < denominator.size(); itDen ++){
      if(itDen == 0 and denTotal == 0 ) {
        denTotal = (TH1F*) denominator.at(itDen)->Clone(("Den_"+string(denominator.at(itDen)->GetName())).c_str());
      }
      else if(denTotal !=0){  
        denTotal->Add(denominator.at(itDen));
      }
    }
    
    ratio = new TH1F(("Ratio_"+string(denominator.at(0)->GetName())).c_str(),"",numTotal->GetNbinsX(),numTotal->GetBinLowEdge(1),numTotal->GetBinLowEdge(numTotal->GetNbinsX()+1));
    ratio->GetYaxis()->SetTitle("S/(#sqrt{S+B})");
    ratio->SetMarkerSize(1.1);

    ratioW = new TH1F(("ratioW_"+string(denominator.at(0)->GetName())).c_str(),"",numTotal->GetNbinsX(),numTotal->GetBinLowEdge(1),numTotal->GetBinLowEdge(numTotal->GetNbinsX()+1));
    ratioW->GetYaxis()->SetTitle("weighted S/(#sqrt{S+B})");
    ratioW->SetMarkerSize(1.1);

    TString name = "norm_" ;
    name += denTotal->GetName () ;
    TH1F * norm_denTotal = (TH1F *) denTotal->Clone (name) ;
    norm_denTotal->Scale (1. / norm_denTotal->GetMaximum ()) ; 
    // weight the S/sqrt (B) by the shape of the total, 
    // so that only bins with a lot of stats become visibly significant
    for(int iBin = 0; iBin < ratio->GetNbinsX()+1; iBin++){
      if(denTotal->GetBinContent(iBin) !=0){ 
        ratioW->SetBinContent(iBin,
			      norm_denTotal->GetBinContent (iBin) * numTotal->GetBinContent(iBin) / 
			      sqrt(denTotal->GetBinContent(iBin)));
        ratio->SetBinContent(iBin,
			     numTotal->GetBinContent(iBin) / sqrt(denTotal->GetBinContent(iBin)));
      }
      else 
	ratio->SetBinContent(iBin,0.);
    }
 
    ratio->GetXaxis()->SetTitle("");
    ratio->SetLineColor(kBlue);
    ratio->SetLineStyle(2);
    ratio->SetLineWidth(2);
    ratio->GetXaxis()->SetLabelOffset(999);
    ratio->GetXaxis()->SetLabelSize(0);
    ratio->GetYaxis()->SetLabelSize(0.15);
    ratio->GetYaxis()->SetTitleSize(0.15);
    ratio->GetYaxis()->SetTitleOffset(0.30);
    ratio->GetYaxis()->SetNdivisions(504);

    ratioW->GetXaxis()->SetTitle("");
    ratioW->SetLineColor(kBlack);
    ratioW->SetLineWidth(2);
    ratioW->GetXaxis()->SetLabelOffset(999);
    ratioW->GetXaxis()->SetLabelSize(0);
    ratioW->GetYaxis()->SetLabelSize(0.15);
    ratioW->GetYaxis()->SetTitleSize(0.15);
    ratioW->GetYaxis()->SetTitleOffset(0.30);
    ratioW->GetYaxis()->SetNdivisions(504);

    ratio->GetYaxis()->SetRange(min(ratio->GetMinimum(),ratioW->GetMinimum())*0.9,max(ratio->GetMaximum(),ratioW->GetMaximum())*1.1);    


    TH1F * frame = lowerPad->DrawFrame (ratio->GetXaxis ()->GetXmin (), 0., 
                                        ratio->GetXaxis ()->GetXmax (), 2.) ;
    frame->GetXaxis()->SetTitle (ratio->GetXaxis ()->GetTitle ()) ;
    frame->GetYaxis()->SetTitle (ratio->GetYaxis ()->GetTitle ()) ;
    frame->GetXaxis()->SetLabelOffset(999);
    frame->GetXaxis()->SetLabelSize(0);
    frame->GetYaxis()->SetLabelSize(0.15);
    frame->GetYaxis()->SetTitleSize(0.15);
    frame->GetYaxis()->SetTitleOffset(0.30);
    frame->GetYaxis()->SetNdivisions(504);

    ratio->Draw("P");    
    ratioW->Draw("Lsame");    
    
    upperPad->cd();
    
    tex->Draw("same");
    tex2->Draw("same");
    tex3->Draw("same");
    legend->Draw("same");

    cCanvas->SaveAs(string("output/"+outputPlotDirectory+"/xs/"+variableList.at(iVar).variableName+".pdf").c_str(),"pdf");
    cCanvas->SaveAs(string("output/"+outputPlotDirectory+"/xs/"+variableList.at(iVar).variableName+".png").c_str(),"png");
    cCanvas->SaveAs(string("output/"+outputPlotDirectory+"/xs/"+variableList.at(iVar).variableName+".root").c_str(),"root");

    cCanvasNorm->cd();

    tex->Draw("same");
    tex2->Draw("same");
    tex3->Draw("same");
    legend->Draw("same");

    cCanvasNorm->SaveAs(string("output/"+outputPlotDirectory+"/norm/"+variableList.at(iVar).variableName+".pdf").c_str(),"pdf");
    cCanvasNorm->SaveAs(string("output/"+outputPlotDirectory+"/norm/"+variableList.at(iVar).variableName+".png").c_str(),"png");
    cCanvasNorm->SaveAs(string("output/"+outputPlotDirectory+"/norm/"+variableList.at(iVar).variableName+".root").c_str(),"root");

    
    legend->Clear();
    
  } // loop on var

  cout<<"LHE filter efficiency : "<<passingLHEFilter<<" totEvent "<<totEvent<<" efficiency "<<float(passingLHEFilter)/float(totEvent)*100<<" % "<<endl;
  
  //Normalize histograms
  for(size_t ihisto = 0; ihisto < plotVector.size(); ihisto++){
    if(plotVector.at(ihisto).varName == "DeltaPhi_LL")
      cout<<"Events Histo "<<plotVector.at(ihisto).histogram->GetName()<<" unweighted "<<plotVector.at(ihisto).histogram->GetEntries()<<" weighted "<<plotVector.at(ihisto).histogram->Integral(0,plotVector.at(ihisto).histogram->GetNbinsX()+1)<<endl;
  }	          

  return 0 ;
}  
コード例 #23
0
ファイル: TPeaksHiggs.C プロジェクト: hkaushalya/CDFPhoJets
void Plot::FitSignal(int mode, int fitMode) {

	const int nPar = 6;
	TRandom ran;

	if(mode==0) {
		gStyle->SetOptLogy(1);
	} else {
		gStyle->SetOptLogy(0);
	}
	gStyle->SetOptStat(0);
	gStyle->SetOptTitle(0);
	const float limitBinSize = 2.0; // **** bin size here
	TCanvas* c = NewCanvas();
	c->Divide(1,2);

	gROOT->cd();
	TH1F* cc = new TH1F("CCSignal","CC Signal",500,0.0,1000.0);
	TH1F* ccBg = new TH1F("CCBgFit","CC Bg Fit",500,0.0,1000.0);
	TH1F* ccBgErr = new TH1F("CCBgErr","CC Bg Err",500,0.0,1000.0);
	TH1F* ccBgP = new TH1F("CCBgPlus","CC Bg Plus",500,0.0,1000.0);
	TH1F* ccBgM = new TH1F("CCBgMinus","CC Bg Minus",500,0.0,1000.0);
	TH1F* cp = new TH1F("CPSignal","CP Signal",500,0.0,1000.0);
	TH1F* cpBg = new TH1F("CPBgFit","CP Bg Fit",500,0.0,1000.0);
	TH1F* cpBgErr = new TH1F("CPBgErr","CP Bg Err",500,0.0,1000.0);
	TH1F* cpBgP = new TH1F("CPBgPlus","CP Bg Plus",500,0.0,1000.0);
	TH1F* cpBgM = new TH1F("CPBgMinus","CP Bg Minus",500,0.0,1000.0);
	TMatrixD matrix(nPar,nPar);

	fd->cd();

	TH1F* hInt,*hBgInt;
	char fitname[100];
	for(int ind=0; ind<2; ind++) {
		if(debug) printf("starting ind %i\n",ind);
		c->cd(ind+1);
		gStyle->SetOptLogy(1);
		printf("Starting %i ######################################\n",ind);

		TH1F* h;
		//char cind[20];
		//char handle[100];
		//sprintf(handle,"side_1exp_%02i_%02i_%02i",ind,mode,fitMode);
		TF1* fits[4];
		//TF1* dpx[4];
		if(debug) printf("looking for h %i\n",int(fd));
		if(ind==0) {
			h = (TH1F*)fd->FindObjectAny("pair_mass_2GeV1");
		} else if(ind==1) {
			h = (TH1F*)fd->FindObjectAny("pair_mass_2GeV3");
		}
		if(debug) printf("new h %i\n",int(h));

		if(debug) printf("new fit\n");
		sprintf(fitname,"hfit_%1i",ind);
		fits[ind] = new TF1(fitname,"([0]*pow((x-30.0),[1])+[3]*pow((x-30.0),0.2))*([2]*exp(-[2]*(x-30.0))+[4]*[5]*exp(-[5]*(x-30.0)))",30.0,500.0);
		//fits[ind] = new TF1(fitname,"([0]*((1-[3])*pow((x-30.0),[1])+[3]*pow((x-30.0),0.2)))*(exp(-[2]*(x-30.0))+[4]*exp(-[5]*(x-30.0)))",30.0,500.0);
		fits[ind]->SetParameter(0,0.0004);
		fits[ind]->SetParameter(1,2);
		fits[ind]->SetParameter(2,0.02);
		fits[ind]->SetParameter(3,0.005);
		//fits[ind]->SetParameter(3,0.5);
		fits[ind]->SetParameter(4,1.005);
		fits[ind]->SetParameter(5,0.05);

		float llim = 30.0;
		h->Fit(fits[ind],"LN","",llim,1000.0);

		double par[20],parMin[20],fval,fvalMin;
		for(int i=0; i<nPar; i++) parMin[i] = fits[ind]->GetParameter(i);

		gMinuit->Eval(nPar,0,fvalMin,parMin,0);
		//printf("got back %10.5f\n",fvalMin);

		// save the fit results in a histogram, for limit program
		for(int ibin=16; ibin<250; ibin++) {
			float xx = h->GetBinCenter(ibin);
			float yy = fits[ind]->Eval(xx);
			if(ind==0) {
				cc->SetBinContent(ibin,h->GetBinContent(ibin));
				ccBg->SetBinContent(ibin,yy);
				ccBgErr->SetBinContent(ibin,0.0);
				ccBgP->SetBinContent(ibin,0.0);
				ccBgM->SetBinContent(ibin,99999.0);
			} else {
				cp->SetBinContent(ibin,h->GetBinContent(ibin));
				cpBg->SetBinContent(ibin,yy);
				cpBgErr->SetBinContent(ibin,0.0);
				cpBgP->SetBinContent(ibin,0.0);
				cpBgM->SetBinContent(ibin,99999.0);
			}
		}

		//vary the parameters to find an error envelope
		double par2[20],fval2=1e10;
		int pslim = (ind==0?25000:150000);
		for(int ips=0; ips<pslim; ips++) {
			if(ips%10000==0) printf("Processing %d\n",ips);
			for(int i=0; i<nPar; i++) {
				par[i] = parMin[i];
			}
			for(int i=0; i<nPar; i++) {
				//int i = (ips%2==0?0:3);
				par[i] = parMin[i]+(2.0*(ran.Uniform()-0.5))*fits[ind]->GetParError(i);
			}
			fval = 0.0;
			gMinuit->Eval(nPar,0,fval,par,0);
			if((fval-fvalMin)<1.0) {
				printf("Found nearby min %10.5f\n",fval-fvalMin);
				float eOld,eNew;
				for(int ibin=16; ibin<250; ibin++) {
					float xx = h->GetBinCenter(ibin);
					for(int i=0; i<nPar; i++) fits[ind]->SetParameter(i,par[i]);
					float yy = fits[ind]->Eval(xx);
					for(int i=0; i<nPar; i++) fits[ind]->SetParameter(i,parMin[i]);
					float yyMin = fits[ind]->Eval(xx);
					TH1F *hBgErr,*hBgP,*hBgM;
					if(ind==0) {
						hBgErr = ccBgErr; hBgP = ccBgP; hBgM = ccBgM;
					} else {
						hBgErr = cpBgErr; hBgP = cpBgP; hBgM = cpBgM;
					}

					eOld = hBgErr->GetBinContent(ibin);
					eNew = yy - yyMin;
					if(eOld>fabs(eNew)) hBgErr->SetBinContent(ibin,fabs(eNew));
					eOld = hBgP->GetBinContent(ibin);
					if(yy>eOld)  hBgP->SetBinContent(ibin,yy);
					eOld = hBgM->GetBinContent(ibin);
					if(yy<eOld)  hBgM->SetBinContent(ibin,yy);
				}

			} // end if near maximum

			/*
				if(fval<fval2) {
				for(int i=0; i<nPar; i++) par2[i] = par[i];
				fval2 = fval;
				}
				*/
		}

		/*
			printf("forcing new fit..\n");
			for(int i=0; i<nPar; i++) {
			printf("old,new = %10.5f %10.5f\n",parMin[i],par2[i]);
			fits[ind]->SetParameter(i,par2[i]);
			}
			*/

		// restore original fit
		fval = 0.0;
		gMinuit->Eval(nPar,0,fval,parMin,0);
		for(int i=0; i<nPar; i++) fits[ind]->SetParameter(i,parMin[i]);



		//extract fit error matrix
		gMinuit->mnemat(matrix.GetMatrixArray(),nPar);
		matrix.Print();

		for(int i=0; i<nPar; i++) {
			for(int j=0; j<nPar; j++) {
				printf("%10.5f",matrix(i,j)/sqrt(matrix(i,i)*matrix(j,j)));
			}
			printf("\n");
		}
		//matrix.Draw("text");

		float hm = h->GetMaximum();
		if(mode==0) {
			//TAxis* ax = h->GetXaxis();
			//ax->SetRangeUser(24.1,199.9);
			h->SetMaximum(1.2*hm);
			//h->SetMinimum(0.0);
		} else if(mode==1) {
			TAxis* ax = h->GetXaxis();
			ax->SetRangeUser(20.0,500.0);
			h->SetMaximum(1.15*hm);
			h->SetMinimum(0.0);
		}


		h->Draw();
		fits[ind]->SetLineColor(1);
		fits[ind]->SetLineWidth(2.0);
		fits[ind]->Draw("SAME");
		// find chi2's and KS's
		//AnaChiKs(h,fits[ind]);



		TAxis* ax,*ay;
		ax = h->GetXaxis(); 
		ay = h->GetYaxis();
		ax->SetTitle("m(#gamma#gamma) (GeV/c^{2})"); 
		ay->SetTitle("Entries/2 GeV/c^{2}");
		ax->CenterTitle(); ay->CenterTitle();
		ax->SetTitleOffset(0.9);
		ay->SetTitleOffset(1.0);
		ax->SetTitleSize(0.08);
		ay->SetTitleSize(0.07);
		ax->SetLabelSize(0.07);
		ay->SetLabelSize(0.07);

		gPad->SetLeftMargin(0.16);
		gPad->SetBottomMargin(0.16);

		TText* text;
		text = new TLatex(0.5,0.8,"Diphoton Data");
		text->SetNDC(true);
		text->SetTextSize(0.06);
		text->Draw();
		if(ind==0)      text = new TLatex(0.5,0.72,"Central-Central");
		else if(ind==1) text = new TLatex(0.5,0.72,"Central-Plug");
		text->SetNDC(true);
		text->SetTextSize(0.06);
		text->Draw();
		if(ind==0) {
			text = new TLatex(0.15,0.92,"W/Z H#rightarrow X(#gamma#gamma)");
			text->SetNDC(true);
			text->SetTextSize(0.08);
			text->Draw();

			text = new TLatex(0.5,0.92,"CDF Run II Preliminary, 2.0 fb^{-1}");
			text->SetNDC(true);
			text->SetTextSize(0.06);
			text->Draw();
		}    

		/*
			if(debug) printf("start loop\n");
			int ibin;
			for(ibin=16; ibin<=250; ibin++) {
			if(debug) printf("start bin            %i\n",ibin);
			float xx = (ibin-0.5)*2.0; // *** bin width here
			if(debug) printf("-1 test ibin %i\n",ibin);
			float yy = fits[ind]->Eval(xx);
		//printf("%f  yy= %f \n",xx,yy);
		// the derivative of this yield wrt parameters
		if(debug) printf("0 test ibin %i\n",ibin);
		double y0 = yy;
		if(debug) printf("1 test ibin %i\n",ibin);
		TMatrixD vv(nPar,1);
		float dirSize = 0.5;
		for(int i=0; i<nPar; i++){
		int ipar = i;
		double par = fits[ind]->GetParameter(ipar);
		double spar = fits[ind]->GetParError(ipar);
		double parp = par + dirSize*spar;
		fits[ind]->SetParameter(ipar,parp);
		double yp = fits[ind]->Eval(xx);
		vv(i,0) = limitBinSize*(yp-y0)/(dirSize*spar);
		fits[ind]->SetParameter(ipar,par);
		//printf("%f %f %f\n",yp,y0,spar);
		}
		//vv.Print();
		if(debug) printf("start matrix %i\n",ibin);
		TMatrixD tempM(matrix, TMatrixDBase::kMult, vv);
		//matrix.Print();
		TMatrixD tempN(vv, TMatrixDBase::kTransposeMult, tempM);
		//tempN.Print();
		float bgSig = 0.0;
		if(tempN(0,0)>0.0) bgSig = sqrt(tempN(0,0));
		// ****** hack temp  **********
		bgSig = 0.3*y0;


		// file hists to be saved
		if(debug) printf("start fill %i\n",ibin);
		if(ind==0) {
		//printf("filling cc %i %f\n",ibin,h->GetBinContent(ibin));
		cc->SetBinContent(ibin,h->GetBinContent(ibin));
		//printf("getting cc %i %f\n",ibin,cc->GetBinContent(ibin));
		ccBg->SetBinContent(ibin,yy);
		ccBgErr->SetBinContent(ibin,bgSig);
		ccBgP->SetBinContent(ibin,yy+bgSig);
		ccBgM->SetBinContent(ibin,TMath::Max(yy-bgSig,float(0.0)));
		//if(ibin==27) {
		//printf("bg %f %f \n",yy,bgSig);
		//}
		} else {
		cp->SetBinContent(ibin,h->GetBinContent(ibin));
		cpBg->SetBinContent(ibin,yy);
		cpBgErr->SetBinContent(ibin,bgSig);
		cpBgP->SetBinContent(ibin,yy+bgSig);
		cpBgM->SetBinContent(ibin,TMath::Max(yy-bgSig,float(0.0)));
		}
		if(debug) printf("end fill %i\n",ibin);
		}
		*/

	}

	printf("cc plus  BG=%f\n",ccBgP->GetSum());
	printf("cc minus BG=%f\n",ccBgM->GetSum());
	printf("cp plus  BG=%f\n",cpBgP->GetSum());
	printf("cp minus BG=%f\n",cpBgM->GetSum());

	char fn[100];
	if(mode==0) {
		sprintf(fn,"FitSignal_%d",fitMode);
		savePlot(c,fn);
	} else if(mode==1) {
		sprintf(fn,"FitSignalLin_%d",fitMode);
		savePlot(c,fn);
	}

	//if(mode!=0) return;

	// plot of fit results
	gStyle->SetOptLogy(0);
	c = NewCanvas();
	c->Divide(1,2);

	c->cd(1);
	cc->Draw();
	ccBg->Draw("SAME");
	c->cd(2);
	ccBgErr->SetMinimum(0.0); ccBgErr->SetMaximum(4.0); 
	ccBgErr->Draw();
	ccBgP->SetLineStyle(2); ccBgP->Draw("SAME");
	ccBgM->SetLineStyle(2); ccBgM->Draw("SAME");

	savePlot(c,"FitSignalResultsCC");

	c = NewCanvas();
	c->Divide(1,2);

	c->cd(1);
	cp->Draw();
	cpBg->Draw("SAME");
	c->cd(2);
	cpBgErr->SetMinimum(0.0); cpBgErr->SetMaximum(4.0); 
	cpBgErr->Draw();
	cpBgP->SetLineStyle(2); cpBgP->Draw("SAME");
	cpBgM->SetLineStyle(2); cpBgM->Draw("SAME");

	savePlot(c,"FitSignalResultsCP");

	char title[100];
	if(name) {
		sprintf(title,"TPeaksHiggs_FitSignalHist_%s.root",name);
		TFile* ff = new TFile(title,"RECREATE");
		gROOT->GetList()->Write();
		ff->Close();
	}

}
コード例 #24
0
ファイル: fill_minEE_class.C プロジェクト: dfigueiredo/Torino
void fill_minEE_class::Loop()
{


   TFile *fpyt = new TFile("files/pythiaD6T_ee_v1.root");
   TTree *tree_pyt = (TTree*)gDirectory->Get("tree_");


   //   TFile *fpom = (TFile*)gROOT->GetListOfFiles()->FindObject("files/DiffractiveMC.root");
   TFile *fpom = new TFile("files/DiffractiveMC_ee_v1.root");
   TTree *tree_pom = (TTree*)gDirectory->Get("tree_");

   //   TFile *fzee = (TFile*)gROOT->GetListOfFiles()->FindObject("files/ZetaSkim_ee.root");
   TFile *fzee = new TFile("files/ZetaSkim_ee_v1.root");
   //   TFile *fzee = new TFile("files/ZetaSkim_mm.root");
   TTree *tree_zee = (TTree*)gDirectory->Get("tree_");



   //   Int_t hnbin = 25;
   Float_t llow = 0.;
   Float_t lup = 250.;
   TH1F *Hpompyt = new TH1F("Hpompyt", "pompyt", hnbin, llow, lup);
   TH1F *Hpythia = new TH1F("Hpythia", "pythia", hnbin, llow, lup);
   TH1F *Hdata = new TH1F("Hdata", "data", hnbin, llow, lup);
   TH1F *HSum = new TH1F("HSum", "HSum", hnbin, llow, lup);

   NCanvas(1,1);
   //Go to  Pythia

   fChain =tree_pyt;
   Init(fChain);


   Long64_t nentries = fChain->GetEntriesFast();   
   cout << "number of entries in Pythia = " << nentries << endl; 
   
   Long64_t nbytes = 0, nb = 0;
   for (Long64_t jentry=0; jentry<nentries;jentry++) {
     Long64_t ientry = LoadTree(jentry);
     if (ientry < 0) break;
     
     nb = fChain->GetEntry(jentry);   nbytes += nb;
     // if (Cut(ientry) < 0) continue;     
     if (numberOfVertexes == 1){
     Hpythia->Fill(TMath::Min(energyTot_PF_EE_minus,energyTot_PF_EE_plus));
     }
   }


   // go to Pompyt

   fChain = tree_pom;
   Init(fChain);
   nentries = fChain->GetEntriesFast();
   cout << "number of entries in Pompyt = " << nentries << endl; 
   
   nbytes = 0, nb = 0;
   for (jentry=0; jentry<nentries;jentry++) {
     ientry = LoadTree(jentry);
     if (ientry < 0) break;
     
     nb = fChain->GetEntry(jentry);   nbytes += nb;
     // if (Cut(ientry) < 0) continue;
     if (numberOfVertexes == 1){
       Hpompyt->Fill(TMath::Min(energyTot_PF_EE_minus,energyTot_PF_EE_plus));
     }
   }
   
   
   // go to  Zee

   fChain = tree_zee;
   Init(fChain);
   nentries = fChain->GetEntriesFast();
   cout << "number of entries in Zee = " << nentries << endl; 
   nbytes = 0, nb = 0;
   for (jentry=0; jentry<nentries;jentry++) {
     ientry = LoadTree(jentry);
     if (ientry < 0) break;
     
     nb = fChain->GetEntry(jentry);   nbytes += nb;
     // if (Cut(ientry) < 0) continue;
     //      Zee->cd();
     if (numberOfVertexes == 1){
     Hdata->Fill(TMath::Min(energyTot_PF_EE_minus,energyTot_PF_EE_plus));
     }
   }
     


   // Show the results

   MyC->cd(1);

   Hpythia->Draw();
   Hpompyt->Draw("SAMES");
   Hdata->Draw("SAMES");
   


  //  cout << Pcdata->lenght() << endl;

  NHtoV(Hdata, Pcdata, Pedata);
  NHtoV(Hpompyt, Pcpompyt, Pepompyt);
  NHtoV(Hpythia, Pcpythia, Pepythia);


 cout << " the content of data[2] is = " << Pcdata[2] << "+-"<<Pedata[2] << endl ;
 cout << " the content of pythia[2] is = " << Pcpythia[2] << "+-"<<Pepythia[2] << endl ;
 cout << " the content of pythia[2] is = " << Pcpompyt[2] << "+-"<<Pepompyt[2] << endl ;


 // Here  we go: the minuit show
 
  TMinuit *gMinuit = new TMinuit(NPAR);  //initialize TMinuit with a maximum of NPAR params
  gMinuit->SetFCN(fcn);
  
  Double_t arglist[NPAR]; // ???
  Int_t ierflg = 0;

// Set starting values and step sizes for parameters

  Double_t vstart[NPAR] ;
  Double_t step[NPAR] ;
  Double_t par[NPAR] ,fpar[NPAR];
  char parName[NPAR];
  Int_t n;
  parName[0] = "Pythia";
  parName[1] = "Pompyt";

  par[0] = Hdata->Integral()/Hpythia->Integral();
  par[1] = 0.05*Hdata->Integral()/Hpompyt->Integral();


  for (n=0 ; n<NPAR ; n++)
    {
      vstart[n] = par[n]  ;
      step[n] = 0.5 ;
      sprintf(parName,"a%d",n);
      gMinuit->mnparm(n, parName, vstart[n], step[n], 0,0,ierflg);
    }

  cout << "par[0] set to = " << par[0] << " while par[1] = " << par[1] << endl;
  arglist[0] = 1;

  gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);  
  gMinuit->mnexcm("SET PRINT", arglist,1,ierflg);

  //Scan on parameter = 1
  arglist[0] = 1;
  gMinuit->mnexcm("SCAN",  arglist,1,ierflg);
  
  //Maximum number of calls
  arglist[0] = 500;
  gMinuit->mnexcm("MIGRAD", arglist,1,ierflg);
 


  // Print results
  Double_t amin,edm,errdef;
  Int_t nvpar,nparx,icstat;

  gMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
  gMinuit->mnprin(3,amin);


  //Get the final fit parameters
  for (n=0 ; n<NPAR ; n++)
    {
      Double_t parameter, erro ;
      gMinuit->GetParameter(n,parameter,erro) ;
      fpar[n] = parameter ;
    }
  
  cout << " The final parameter values are: "<< fpar[0] << " , " << fpar[1] << endl;

  Float_t SD_frac = (fpar[1]*Hpompyt->Integral())/Hdata->Integral();
  //  Float_t NSD_events = fpar[0]*Hpythia->Integral();
  // Float_t Data_events = Hdata->Integral();

  cout << " The fraction of SD events is = " << SD_frac << endl;


  // }
  // void fill_minEE_class::show(){


  //Show the final plot

  MyC->cd(1);

  Hpythia->Scale(fpar[0]); 
  Hpompyt->Scale(fpar[1]); 

  Hdata->SetMarkerColor(2);
  Hdata->GetXaxis()->SetTitle("Min(EE-,EE+) Energy [GeV] ");
  Hdata->GetYaxis()->SetTitle("Entries");
  Hpompyt->SetLineColor(4);
  Hpythia->SetLineColor(6);
  Hpompyt->SetLineStyle(2);
  Hpythia->SetLineStyle(2);
   
  Float_t DMax = 1.2*Hdata->GetMaximum();
  Hdata->SetMaximum(DMax);
  Hdata->Draw("p");

  Hpythia->Draw("SAMES");
  Hpompyt->Draw("SAMES");
  
  HSum->Add(Hpythia);
  HSum->Add(Hpompyt);
  HSum->SetLineColor(1);
  HSum->SetLineStyle(1);
  HSum->Draw("SAMES");

}
コード例 #25
0
ファイル: printBfraction.C プロジェクト: kurtejung/bJetTools
void printBfraction(char *tagger="discr_ssvHighEff", Double_t workingPoint=2, char *taggerName="ssvHighEff", int doCent=2, int do3bin=1) {

  gROOT->ForceStyle(1);

  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);


  gStyle->SetTextFont(42);
  gStyle->SetLabelFont(42,"XYZ");
  gStyle->SetTitleFont(42,"XYZ");

  // hack
  if(doCent)gStyle->SetErrorX(0);
  gStyle->SetLabelSize(0.05,"xy");
  gStyle->SetTitleSize(0.05,"xy");
  gStyle->SetTitleOffset(1.5,"xy");
  gStyle->SetPadLeftMargin(0.15);
  gStyle->SetPadBottomMargin(0.12);
  gStyle->SetNdivisions(408,"y");


  TFile *fin1, *fin2;
  if(doCent){
    if(doCent==1){
      fin1 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL1_centDep_80_100.root");
      fin2 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL0_centDep_80_100.root");
    }
    if(doCent==2){
      fin1 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL1_centDep_100_120.root");
      fin2 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL0_centDep_100_120.root");
    }
    // broken
    //fin1 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL1_centDep_80_100.root");
    //fin2 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL0_centDep_80_100.root");
  }
  else{
    // try to smear by 2 sigma
    //fin1 = new TFile("output/bFractionMerged_Smear2Sigma_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root");
    //fin2 = new TFile("output/bFractionMerged_Smear2Sigma_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root");
    // with reg tracks in reco jets
    //fin1 = new TFile("output/bFractionMerged_regPFJets_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root");
    //fin2 = new TFile("output/bFractionMerged_regPFJets_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root");
    if(do3bin){
      fin1 = new TFile("output/bFractionMerged_3bins_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root");
      fin2 = new TFile("output/bFractionMerged_3bins_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root");
    }
    else{
      fin1 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL1_bin_0_40_eta_0_2.root");
      fin2 = new TFile("output/bFractionMerged_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root");
      // old naming convention
    //fin1 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL1_bin_0_40_eta_0_2.root");
    //fin2 = new TFile("output/bFractionMerged_ssvHighEffat2.0FixCL0_bin_0_40_eta_0_2.root");

    }
  }

  TH1F *hBFractionMC = (TH1F*) fin1->Get("hBFractionMC");

  TH1F *hBFractionData = (TH1F*) fin1->Get("hBFractionData");
  TH1F *hBFractionDataLTJP = (TH1F*) fin1->Get("hBFractionDataLTJP");
  TH1F *hBFractionJPdirect = (TH1F*) fin1->Get("hBFractionJPdirect");

  TH1F *hBFractionDataFixC = (TH1F*) fin2->Get("hBFractionData");
  TH1F *hBFractionDataLTJPFixC = (TH1F*) fin2->Get("hBFractionDataLTJP");
  TH1F *hBFractionJPdirectFixC = (TH1F*) fin2->Get("hBFractionJPdirect");

  


  /*  --- correction due to Jet Energy Scale (calcul) ---
  correct(hBFractionMC);
  correct(hBFractionData);
  correct(hBFractionDataMoreC);
  correct(hBFractionDataLessC);
  correct(hBFractionDataLTJP);
  correct(hBFractionDataLTJPMoreC);
  correct(hBFractionDataLTJPLessC);
  correct(hBFractionJPdirect);
  correct(hBFractionJPdirectMoreC);
  correct(hBFractionJPdirectLessC);
  //*/

  //*  --- correction due to Jet Energy Scale (by hand) ---
  if(doCent){
    correctByCent(hBFractionMC,doCent);
    correctByCent(hBFractionData,doCent);
    correctByCent(hBFractionDataFixC,doCent);
    correctByCent(hBFractionDataLTJP,doCent);
    correctByCent(hBFractionDataLTJPFixC,doCent);
    correctByCent(hBFractionJPdirect,doCent);
    correctByCent(hBFractionJPdirectFixC,doCent);
  }
  else{
    //*
    correct2(hBFractionMC,do3bin);
    correct2(hBFractionData,do3bin);
    correct2(hBFractionDataFixC,do3bin);
    correct2(hBFractionDataLTJP,do3bin);
    correct2(hBFractionDataLTJPFixC,do3bin);
    correct2(hBFractionJPdirect,do3bin);
    correct2(hBFractionJPdirectFixC,do3bin);
    //*/
  }
  //*/

  //  --- plots with variation of charm ---


  TCanvas *cBFraction1 = new TCanvas("cBFraction1","b-jet fraction",600,600);
  hBFractionMC->SetLineColor(2);
  hBFractionMC->SetLineWidth(2);
  hBFractionMC->SetMarkerColor(2);
  //hBFractionMC->SetMarkerStyle(4);
  if(!doCent)hBFractionMC->SetAxisRange(80,200,"X");
  hBFractionMC->SetAxisRange(0,0.06,"Y");
  hBFractionMC->SetTitleOffset(1,"X");  
  hBFractionMC->GetYaxis()->SetTitle("b-jet fraction");;
  //hBFractionMC->Draw("e1"); 
  
  //hBFractionMC->GetYaxis()->SetNdivisions(505);
  
  TH1F *hBFractionMC_dummy= (TH1F*)hBFractionMC->Clone("hBFractionMC_dummy");
  hBFractionMC_dummy->SetLineWidth(0);
  hBFractionMC_dummy->SetLineColor(0);
  hBFractionMC_dummy->SetMarkerSize(0);
  hBFractionMC_dummy->Draw(); 
  //  hBFractionMC->Draw("hist"); 

  hBFractionData->SetMarkerStyle(8);
  hBFractionData->Draw("e1,same");  
  hBFractionDataLTJP->SetLineColor(kGreen-2); 
  hBFractionDataLTJP->SetMarkerColor(kGreen-2); 
  hBFractionDataLTJP->SetMarkerStyle(8); 
  hBFractionDataLTJP->Draw("e1,same");
  hBFractionJPdirect->SetMarkerStyle(8); 
  hBFractionJPdirect->SetMarkerColor(kBlue);
  hBFractionJPdirect->SetLineColor(kBlue);
  hBFractionJPdirect->Draw("e1,same");

  
  hBFractionDataFixC->SetLineStyle(2);
  //hBFractionDataFixC->Draw("e1same");   
  hBFractionDataLTJPFixC->SetLineColor(kGreen-2);
  hBFractionDataLTJPFixC->SetMarkerColor(kGreen-2);
  hBFractionDataLTJPFixC->SetMarkerStyle(4);
  hBFractionDataLTJPFixC->SetLineStyle(2);
  hBFractionDataLTJPFixC->Draw("e1same");
  hBFractionJPdirectFixC->SetLineStyle(2);
  //hBFractionJPdirectFixC->Draw("e1same");

  
  TLegend *legFrac1 = new TLegend(0.15,0.65,0.87,0.95);

  legFrac1->SetBorderSize(0);
  legFrac1->SetFillStyle(0);
  legFrac1->SetHeader("PbPb, #sqrt{s_{NN}} = 2.76 TeV");
  legFrac1->AddEntry(hBFractionDataLTJP,Form("SSVHE, LT method",taggerName,workingPoint),"pl");
  legFrac1->AddEntry(hBFractionDataLTJPFixC,Form("SSVHE, LT method, Floating Charm Norm.",taggerName,workingPoint),"pl");
  legFrac1->AddEntry(hBFractionData,Form("SSVHE, MC eff.",taggerName,workingPoint),"pl");
  legFrac1->AddEntry(hBFractionJPdirect,"Jet Probability","pl");
  //legFrac1->AddEntry(hBFractionMC,"MC Input (reconstructed)","l");

  legFrac1->Draw();




  //  --- plots of LT method with syst. uncertainty ---

  TCanvas *cBFraction2 = new TCanvas("cBFraction2","b-jet fraction",600,600);

  TH1F *hBFractionMC2 = hBFractionMC->Clone("hBFractionMC2");
  if(!doCent)hBFractionMC2->GetXaxis()->SetRangeUser(80,200);
  hBFractionMC2->SetMarkerSize(0);
  hBFractionMC2->SetMaximum(0.06);
  hBFractionMC2->SetMinimum(0.0);
  hBFractionMC2->Draw("hist");


  TGraphAsymmErrors *gBFractionMC2 = new TGraphAsymmErrors(hBFractionMC);
  if(!doCent){
    setMeanPt(gBFractionMC2,hBFractionMC,0,do3bin);
    gBFractionMC2->GetXaxis()->SetRangeUser(80,200);
  }



  TLatex *prel;
  if(doCent)prel= new TLatex(10,0.0615,"CMS preliminary");
  else prel= new TLatex(85,0.0615,"CMS preliminary");
  prel->Draw();

  TLatex *roots = new TLatex(147,0.0615,"#sqrt{s_{NN}} = 2.76 TeV");
  roots->Draw();

  if(!doCent){
    TLatex *csel = new TLatex(90,0.05,"Centrality 0-100%");
    csel->Draw();
  }
  TLatex *ptlabel;
  if(doCent==1) ptlabel= new TLatex(20,0.005,"80 < Jet p_{T} < 100 GeV/c");
  if(doCent==2) ptlabel= new TLatex(20,0.005,"100 < Jet p_{T} < 120 GeV/c");
  if(doCent)ptlabel->Draw();

  // to be precise we should evaluate mcStatErr for 3 bins seperately
  float mcStatErr[4] = {0.03,0.06,0.07,0.15};

  
  //TGraphAsymmErrors *gSyst = new TGraphAsymmErrors(3);
  TGraphErrors *gSyst;
  if(do3bin) gSyst= new TGraphErrors(3);
  else gSyst= new TGraphErrors(4);
  Double_t errCLratio, errMethod, totalSystErr;

  for(Int_t i=1;i<=hBFractionDataLTJP->GetNbinsX();i++) {
    gSyst->SetPoint(i-1,hBFractionDataLTJP->GetBinCenter(i),hBFractionDataLTJP->GetBinContent(i));
    cout<<" central value "<<hBFractionDataLTJP->GetBinContent(i)<<endl;
    errCLratio = abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionDataLTJPFixC->GetBinContent(i));
    errMethod = max(abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionData->GetBinContent(i)),abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionJPdirect->GetBinContent(i)));
    double errJES = 0.14*hBFractionDataLTJP->GetBinContent(i);
    
    totalSystErr = norm(errCLratio,errMethod,errJES);
    gSyst->SetPointError(i-1,hBFractionDataLTJP->GetBinWidth(i)/2,totalSystErr);
    cout<<" sys error "<<totalSystErr<<endl;
    // add in MC template uncertainties
    float origStatErr = hBFractionDataLTJP->GetBinError(i);
    int statBin=i-1;
    if(doCent==1) statBin=0;
    if(doCent==2) statBin=1;
    float extraStatErr = mcStatErr[statBin]*hBFractionDataLTJP->GetBinContent(i);
    float totalStatErr = sqrt(origStatErr*origStatErr + extraStatErr*extraStatErr);
    hBFractionDataLTJP->SetBinError(i,totalStatErr);
    cout<<" total error "<<sqrt(totalSystErr*totalSystErr+totalStatErr*totalStatErr)<<endl;

  }

  gSyst->SetFillColor(5);
  gSyst->Draw("2");


  gBFractionMC2->Draw("Z,p,same");
  hBFractionMC2->Draw("hist,same");


  TGraphAsymmErrors *gBFractionDataLTJP2 = new TGraphAsymmErrors(hBFractionDataLTJP);
  if(!doCent)setMeanPt(gBFractionDataLTJP2,hBFractionDataLTJP,1,do3bin);
  gBFractionDataLTJP2->SetLineColor(1);
  gBFractionDataLTJP2->SetMarkerColor(1);
  gBFractionDataLTJP2->SetMarkerSize(1.5);
  gBFractionDataLTJP2->Draw("p,e1,same");


  TLegend *legFrac2 = new TLegend(0.2,0.15,0.8,0.34);
  if(doCent){
    legFrac2->SetX1(0.365);
    legFrac2->SetY1(0.657);
    legFrac2->SetX2(0.965);
    legFrac2->SetY2(0.848);
  }

  legFrac2->SetHeader("#int L dt = 150 #mub^{-1}");
  legFrac2->SetBorderSize(0);
  legFrac2->SetFillStyle(0);
  legFrac2->AddEntry(gBFractionDataLTJP2,"PbPb data","p");
  legFrac2->AddEntry(gBFractionMC2,"PYTHIA+HYDJET 1.8","lp");
  legFrac2->AddEntry(gSyst,"Exp. uncertainty","f");
  legFrac2->Draw();

 
  cBFraction2->RedrawAxis();

}
コード例 #26
0
void PlotPubHisto(TObjArray histograms,TEnv *params){
    // This is a modification of the AddHistos macro
    
    // Number of histos to plot:
    Int_t ntot = histograms.GetEntries();
    
    // Check we have what we expect (the order should be: data, qcd, wjets, etc...)
    for(Int_t i = 0; i<ntot; i++){
	if(histograms[i]==0) {
	    cout<<"Error in AddHistos: histogram "<<i<<" is a NULL pointer!"<<endl;
	    return;
	}
	TH1F * hthis = (TH1F*) histograms[i];
	// include the overflow/underflow bins:
	int numbins = hthis->GetNbinsX(); //this is the last bin plotted
	double hicontent = hthis->GetBinContent(numbins);
	double overflow  = hthis->GetBinContent(numbins+1);// this bin contains the overflow
	double locontent = hthis->GetBinContent(1);// this is the first bin plotted
	double underflow = hthis->GetBinContent(0);// this bin contains the underflow
	if (underflow>0 || overflow>0){
	    //printf("%-20s numbins=%4i hicontent=%4.2f over=%4.2f locontent=%4.2f underflow=%4.2f \n",
	    //	 title.Data(),numbins,hicontent,overflow,locontent,underflow);
	}
	hthis->SetBinContent(numbins,hicontent+overflow);
	hthis->SetBinContent(1,locontent+underflow);
    }
    
    // define a few additional line styles:
    gStyle->SetLineStyleString(5,"20 12 4 12");
    gStyle->SetLineStyleString(6,"20 12 4 12 4 12 4 12");
    gStyle->SetLineStyleString(7,"20 20");
    gStyle->SetLineStyleString(8,"20 12 4 12 4 12");
    gStyle->SetLineStyleString(9,"80 25");
    gStyle->SetLineStyleString(10,"50 10 10 10");
    gStyle->SetLineStyleString(17,"30 25");
    gStyle->SetLineStyleString(20,"60 20");
    gStyle->SetLineStyleString(21,"60 20 20 20");
    int lineStyle[20];
    for(int i=0;i<20;i++) {
	lineStyle[i]=i;
    }

    // the first histogram in the list:
    TH1F *h0=((TH1F*) histograms[0])->Clone();
    
    // histogram output filename
    TString oFileName=params->GetValue("Histo.Output.Filename","bogus.eps");
    
    // figure out the number of signals
    Int_t nsig=1;
    if(params->Defined("Histo.Signal.Title.1")) nsig=1;
    if(params->Defined("Histo.Signal.Title.2")) nsig=2;
    if(params->Defined("Histo.Signal.Title.3")) nsig=3;
    
    cout << " I will use nsig = " << nsig << " signal sources" << endl;
    
    // Do the cumulative summing, except for the data
    TObjArray addedhistos; addedhistos.Clear();
    TObjArray signalhistos; signalhistos.Clear();
    TString sampletitles[20];
    Int_t nbkg=0;
    for(Int_t i = 1; i<ntot; i++){// i runs over histograms[i], so data is for i=0
	ostringstream baseSrcName;
	baseSrcName << "Files." << i+1 << ".";// Counting starts at 1: Files.1.Name: Data
	TString bSrcName(baseSrcName.str().c_str());
	// skip some if we want to show them as lines
	TString htitle=params->GetValue(bSrcName+"Title","");
	sampletitles[i-1]=htitle;
	if(params->GetValue("Histo.ShowSignalSeparately",0)==1 &&
	   // skip the last two if the signal title is not defined:
	   ( ( !(params->Defined("Histo.Signal.Title")||params->Defined("Histo.Signal.Title.1")) && i>=ntot-nsig) 
	     // skip the signal if the signal title is defined
	     || params->GetValue("Histo.Signal.Title",".")==htitle
	     || params->GetValue("Histo.Signal.Title.1",".")==htitle
	     || params->GetValue("Histo.Signal.Title.2",".")==htitle
	     || params->GetValue("Histo.Signal.Title.3",".")==htitle
	     ) ) {
	    TH1F * hthis = (TH1F*) histograms[i]->Clone();
	    cout<<" Found signal in location "<<i+1<<" with name "<<htitle.Data()<<endl;
	    signalhistos.Add(hthis);
	} else {
	    TH1F * hthis = (TH1F*) histograms[i]->Clone();
	    addedhistos.Add(hthis); // Fill in the new TObjArray with a copy 
	    //cout << " Adding bkg " << i << " " << htitle.Data() << " " << hthis->Integral() << endl;
	    // add all of the backgrounds
	    if (i>1) {// i=0 is the data, and we must start with the second
		      // background to add the previous
		TH1F * hprevious = (TH1F*) addedhistos[i-2];
		if ( hthis->GetXaxis()->GetNbins() != hprevious->GetXaxis()->GetNbins() ) {
		    // Protection against _whoran histogram. 
		    // We cannot add two histograms with different numbers of bins!
		    cout<<"Error in AddHistos: incompatible number of bins!"<<endl;  
		    return;
		}
		hthis->Add(hprevious); // Do the addition
		addedhistos.RemoveAt(i-1); // And substitute whatever we had 
		addedhistos.AddAt(hthis,i-1);
		nbkg++;
		//cout << "Substituing bkg " << i << " + " << i-1 << " in addedhistos["<< i-1 <<"]" << endl;
	    }	    
	} // end of: if adding histograms
    }
    cout << " nbkg = " << nbkg << endl; 
    
    // Rebin histos if necessary, but first calculate KS:
    TH1F *hbkg = (TH1F*) addedhistos[nbkg];
    double KS = h0->KolmogorovTest(hbkg);
    double chi2ndf = h0->Chi2Test(hbkg, "UWUFOFCHI2/NDF");
    //cout << title.Data() << " KS = " << KS << " chi2/NDF = " << chi2ndf << endl;
    // Rebin? Set nrebin = 0 to NOT do rebinning. 
    // Will rebin only histos whose maximum x axis value exceeds 20. 
    // Anything with less will most probably be already made of integers, so no
    // need to rebin that! 
    Int_t nbinsx = h0->GetXaxis()->GetNbins();
    Int_t nbinsy = 100;
    Int_t nrebin = 5;
    if ( nbinsx > 750 && nbinsx <= 1000) nrebin = 30;
    if ( nbinsx > 400 && nbinsx <= 750 ) nrebin = 25;//20
    if ( nbinsx > 300 && nbinsx <= 400 ) nrebin = 25;//15
    if ( nbinsx > 200 && nbinsx <= 300 ) nrebin = 25;//15
    if ( nbinsx > 150 && nbinsx <= 200 ) nrebin = 10;//10
    if ( nbinsx > 100 && nbinsx <= 150 ) nrebin = 10;//10
    if ( nbinsx > 50 && nbinsx <= 100 )  nrebin = 10;//10
    if ( nbinsx > 20 && nbinsx <= 50 )   nrebin = 2;
    if ( nbinsx <= 20 ) nrebin = 1;  
    
    printf(" Saw nbins =%4i, rebinning by nrebin =%2i to final %3i bins \n",nbinsx,nrebin,int(nbinsx/nrebin));	

    if ( nrebin != 0 ) {
	h0->Rebin(nrebin); // data
	for (Int_t i = 0; i<=nbkg; i++){
	    TH1F * h = (TH1F*) addedhistos[i];
	    h->Rebin(nrebin);
	}
	for (Int_t i = 0; i<nsig; i++){
	    TH1F * h = (TH1F*) signalhistos[i];
	    h->Rebin(nrebin);
	}
    }

    // default text size: 0.045
    // make it bigger for the paper
    float textSize = 0.045;
    if(params->GetValue("Histo.Preliminary","yes")==TString("paper")) textSize=0.07;
    if(params->Defined("Histo.TextSize")) textSize=params->GetValue("Histo.TextSize",0.07);
    
    // Now, check largest dimensions so that we can plot all histograms at once.
    Float_t xmin=9999., xmax=-9999., ymin=9999., ymax=-9999.;
    for(Int_t i = 0; i<=nbkg; i++){
	TH1F * h = (TH1F*) addedhistos[i];
	ostringstream baseSrcName;
	baseSrcName << "Files." << i+1 << ".";
	TString bSrcName(baseSrcName.str().c_str());
	
	TAxis *axis = h->GetXaxis();
	if( axis->GetXmin() < xmin ) xmin = axis->GetXmin();
	if( axis->GetXmax() > xmax ) xmax = axis->GetXmax();
	if( h->GetMinimum() < ymin ) ymin = h->GetMinimum();
	if( h->GetMaximum() > ymax ) ymax = h->GetMaximum();
    }
    ymax = TMath::Nint(ymax*1.25+1); // Make enough room for the big legend
    TString title = h0->GetTitle();
    
    //
    // now check if we should simply use the ranges that was passed to us.
    if(params->Defined("Histo.Xmin")) xmin = params->GetValue("Histo.Xmin",0.);
    if(params->Defined("Histo.Xmax")) xmax = params->GetValue("Histo.Xmax",0.);
    if(params->Defined("Histo.Ymin")) ymin = params->GetValue("Histo.Ymin",0.);
    if(params->Defined("Histo.Ymax")) ymax = params->GetValue("Histo.Ymax",0.);
    
    // Now make the frame:
    TH2F * frame = new TH2F("frame","",nbinsx,xmin,xmax,nbinsy,ymin,ymax);
    cout<<" frame has xmin "<<xmin<<", xmax "<<xmax<<", ymax "<<ymax<<endl;
    
    // get the x- and y-axis titles
    TString ytitle=params->GetValue("Histo.YTitle","");
    if ( params->Defined("Histo.XTitle")) {
	frame->SetXTitle(params->GetValue("Histo.XTitle",""));
    } else {
	frame->SetXTitle(h0->GetTitle());
    }
    frame->SetYTitle(ytitle.Data()); 
    // also set the text size for the X and Y axis titles and numbers
    // do this globally for the style we are using
    float axisLabelSize=textSize;
    frame->GetXaxis()->SetLabelSize(axisLabelSize);
    frame->GetYaxis()->SetLabelSize(axisLabelSize);
    frame->GetXaxis()->SetTitleSize(axisLabelSize);
    frame->GetYaxis()->SetTitleSize(axisLabelSize);
    
    frame->SetStats(false);
    // reduce the axis title offset if the fonts are very large
    if(textSize>0.055) frame->GetXaxis()->SetTitleOffset(1.0);
    // also change the X axis title offset to move it farther away from the numbers
    if(params->Defined("Histo.XTitle.Offset")) {
	float xtitoffset=params->GetValue("Histo.XTitle.Offset",1.0);
	frame->GetXaxis()->SetTitleOffset(xtitoffset);
    }
    
    // also change the y axis title offset to move it farther away from the numbers
    frame->GetYaxis()->SetTitleOffset(1.0);
    // reduce the axis title offset if the fonts are very large
    if(textSize>0.055) frame->GetYaxis()->SetTitleOffset(1.0);
    
    // set the axes divisions
    frame->GetXaxis()->SetNdivisions(505,true);
    if(params->Defined("Histo.XNdivisions")) frame->GetXaxis()->SetNdivisions(params->GetValue("Histo.XNdivisions",505),kTRUE);
    if(params->Defined("Histo.YNdivisions")) frame->GetYaxis()->SetNdivisions(params->GetValue("Histo.YNdivisions",505),kTRUE);
    
    // make sure the X axis title and Y axis title are in black!
    frame->GetXaxis()->SetTitleColor(1);
    frame->GetYaxis()->SetTitleColor(1);

    // Could plot in log scale...
    //gPad->SetLogy();

    // finally: Draw
    frame->Draw();
    
    // Draw the background ones:
    for(Int_t i=nbkg; i>=0; i--){
	TH1F * h = (TH1F*) addedhistos[i];
	h->SetStats(kFALSE);
	
	ostringstream baseSrcName;
	baseSrcName << "Files." << i+2 << ".";// to account for the data which is Files.1
	TString bSrcName(baseSrcName.str().c_str());
	Int_t hcolor=params->GetValue(bSrcName+"Color",1); 	
	h->SetLineColor(1);      
	h->SetFillColor(hcolor);
        if (i==nbkg) printf(" Data Yield = %5.2f ; SumBkg = %5.2f ; Data-SumBkg diff = %5.2f%% \n",
	   		     h0->Integral(),h->Integral(),(h0->Integral()-h->Integral())*100./h0->Integral());
	printf(" plotting bkg i=%2i name=%20.20s file=%2i integral=%5.1f color=%2i\n",
	       i,sampletitles[i].Data(),i+2,h->Integral(),hcolor);
	int fillStyle=params->GetValue(bSrcName+"FillStyle",1001);
	h->SetFillStyle(fillStyle);
	h->DrawCopy("Hist,Same");
    }
    //
    // and draw the signal ones
    // draw them in reverse order so that the last one will be on top.
    //for(Int_t i=ntot-3; i<ntot; i++){
    for(Int_t i=nsig-1; i>=0; i--){
	ostringstream baseSrcName;
	baseSrcName << "Files." << ntot+1-nsig+i << ".";
	TString bSrcName(baseSrcName.str().c_str());
	
	Int_t hcolor=params->GetValue(bSrcName+"Color",1);
	TH1F * h = (TH1F*) signalhistos[i];
       	if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=90"))        h->Add (h, 1.07874865  -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=100"))  h->Add (h, 1.62317373  -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=110"))  h->Add (h, 2.31347600  -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=120"))  h->Add (h, 3.25275183  -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=130"))  h->Add (h, 4.54142919  -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=140"))  h->Add (h, 6.19195046  -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=150"))  h->Add (h, 8.38307290  -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=160"))  h->Add (h, 11.31721008 -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=170"))  h->Add (h, 14.85376469 -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=180"))  h->Add (h, 19.54537459 -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=190"))  h->Add (h, 25.44594010 -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=200"))  h->Add (h, 32.94784356 -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=220"))  h->Add (h, 54.09499080 -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=240"))  h->Add (h, 86.85079034 -1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=260"))  h->Add (h, 136.31406761-1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=280"))  h->Add (h, 210.70375053-1.000);
	else if (sampletitles[ntot-1-nsig+i].Contains("m_{H}=300"))  h->Add (h, 319.79533099-1.000);
	
	printf(" plotting sig i=%2i name=%20.20s file=%2i integral=%5.1f color=%2i\n",
	       i,sampletitles[ntot-1-nsig+i].Data(),ntot+1-nsig+i,h->Integral(),hcolor);
	// create a white background around each line (helps readibility):
	TH1F *h1=h->Clone();
	h1->SetStats(kFALSE);
	h1->SetLineWidth(6);
	h1->SetLineColor(0);h1->SetFillColor(0);
	h1->SetLineStyle(1);
	h1->SetFillStyle(0);
	h1->Draw("HIST,SAME");
	// now draw the proper line:
	h->SetStats(kFALSE);
	h->SetLineWidth(6);
	h->SetLineColor(hcolor);h->SetFillColor(0);	
	Int_t hlinestyle = params->GetValue(bSrcName+"LineStyle",1);
	h->SetLineStyle(hlinestyle);
	h->SetFillStyle(0);	
	// finally, draw!
	h->Draw("HIST,SAME");      
    } // end of: drawing signal as separate lines
    
    // Data is special: 
    // change the default size of the little bar at the end of the error bar here
    gStyle->SetEndErrorSize(3);
    // also, maybe don't display the error bars along the X axis:
    //gStyle->SetErrorX(0);  // X error bars not displayed
    gStyle->SetErrorX(0.5);  // X error bars have width of a bin
    // now set the rest
    h0->SetMarkerSize(2);
    // if there are too many points (>80), keep the marker size smaller
    if(h0->GetNbinsX()>=50) h0->SetMarkerSize(1);
    //if(h0->GetNbinsX()>=100) h0->SetMarkerSize(1);
    h0->SetLineWidth(3);
    h0->SetMarkerStyle(8);
    h0->SetMarkerColor(1);
    h0->Draw("E1,SAME");
    
    // Print some comparison:
    //ostringstream basefactor;
    //basefactor << "Files." << nbkg+3 << "." << "Factor";
    //TString timesfactor(basefactor.str().c_str()); 
    //Double_t nprod = params->GetValue(timesfactor,1.000);
    //printf("Data Yield = %5.2f ; SumBkg = %5.2f ; SumBkg+Sig = %5.2f ; Data-SumBkg diff = %5.2f%% \n",
    //        h0->Integral(),hbkg2->Integral,(hbkg2->Integral()+(signalhistos[0]->Integral()/nprod),
    //        (h0->Integral()-hbkg2->Integral)*100./h0->Integral()));

    //
    // Print D0 and lumi:
    //
    TText *t1 = new TText();
    t1->SetTextFont(62);
    t1->SetTextColor(1);   
    t1->SetNDC();
    t1->SetTextAlign(12);
    t1->SetTextSize(textSize);
    TString prelim="D\328 Preliminary";
    if(oFileName.EndsWith(".eps")) {
	prelim="D\349 Preliminary L=3.7 fb^-1#";
    }
    else if(oFileName.EndsWith(".gif")) {
	prelim="D\328 Preliminary L=3.7 fb^-1#";
    }
    t1->DrawTextNDC(0.13,0.965,prelim.Data());

    // a counter of how much text we have added from the top
    int nAddTextLines=0;
    
    // any additional text?
    for(int iText=1;iText<20;iText++) {
	ostringstream baseTextName;
	baseTextName << "Histo.AddText." << iText;
	TString bTextName(baseTextName.str().c_str());
	if(params->Defined(bTextName)) {
	    // we are adding a line of text
	    TLatex *t2 = new TLatex();
	    t2->SetTextFont(62);
	    t2->SetTextColor(13);   
	    t2->SetTextAlign(32);
	    t2->SetNDC();
	    t2->SetTextSize(textSize);
	    TString addText(params->GetValue(bTextName,"."));
	    float x0=0.94;
	    float y0=0.96-(nAddTextLines)*0.05;
	    
	    // check if the user specified an alternative location for the text
	    if(params->Defined(bTextName+".X0")) x0=params->GetValue(bTextName+".X0",0.94);
	    if(params->Defined(bTextName+".Y0")) y0=params->GetValue(bTextName+".Y0",0.8);
	    if(params->Defined(bTextName+".TextSize")) t2->SetTextSize(params->GetValue(bTextName+".TextSize",textSize));
	    
	    // and increment the counter keeping track of how much we added,
	    // but only if the user didn't move the label around.
	    if(!params->Defined(bTextName+".X0")) nAddTextLines++;
	    printf("AddText %4.2f %4.2f %s\n",x0,y0,addText.Data());
	    
	    t2->DrawLatex(x0,y0,addText.Data()); 
	}
    }// end additional text
    
    // now draw the frame axis again so that we can see the tick marks
    frame->Draw("sameaxis");
    
    // Legend:
    TString showLegend(params->GetValue("Histo.ShowLegend","."));
    if( showLegend != "no" ){ 
	float lgdxmin=.65, lgdxmax=.90, lgdymin=.50, lgdymax=.91;
	if(showLegend=="yes" || showLegend=="right") {
	    
	} else if (showLegend=="left"){
	    lgdxmin=.16;
	    lgdxmax=.42;
	}
	TLegend *lgd = new TLegend(lgdxmin,lgdymin,lgdxmax,lgdymax); 
	// This line makes the legend transparent (not grey, ewwww!): 
	lgd->SetBorderSize(0); lgd->SetTextSize(textSize*0.9);// 10% less size 
	lgd->SetTextFont(62); lgd->SetFillColor(0);
	// Plot the legend in reverse order (but data goes first):
	NiceAddEntry(lgd,h0,params->GetValue("Files.1.Title","Data"),"PL");
	for(Int_t i = nbkg; i>=0; i--){
	    TH1F * h = (TH1F*) addedhistos[i];
	    TString lgd_entry= sampletitles[i]; // sampletitles runs from 0 (firstbkg) to ntot-1
	    NiceAddEntry(lgd,h,lgd_entry.Data(),"F");	
	}
	for(Int_t i = nsig-1; i>=0; i--){
	    TH1F * h = (TH1F*) signalhistos[i];
	    TString lgd_entry = sampletitles[i+nbkg+1]; // sampletitles runs from 0 (firstbkg) to ntot-1
	    ostringstream basefactor;
	    basefactor << "Files." << i+nbkg+3 << "." << "Factor";
	    TString timesfactor(basefactor.str().c_str());
	    Double_t nprod = params->GetValue(timesfactor,1.000);
	    if (nprod != 1.0 ) lgd_entry.Form("%s x%2.0f",lgd_entry.Data(),nprod);
	    //cout << i+nbkg+3 << " " << nprod << " " << lgd_entry.Data() << endl;
	    NiceAddEntry(lgd,h,lgd_entry.Data(),"L"); 
	}
	lgd->Draw("SAME");	
    }// show legend


    // Draw the KS:
    TLatex *ks = new TLatex();
    ks->SetTextFont(62);
    ks->SetTextColor(1);   
    TString ks_val = Form("KS = %3.2f",KS);
    ks->SetTextAlign(11); ks->SetTextSize(0.03); // ks->SetTextAngle(90); 
    ks->DrawTextNDC(0.83,0.93,ks_val.Data());
    TString chi2_val = Form("#chi^{2}/ndf = %3.1f",chi2ndf);
    ks->SetNDC(true); ks->DrawLatex(0.83,0.97,chi2_val.Data());
    //
    // Voila!
    //
}
コード例 #27
0
ファイル: analyse_ch_eff.C プロジェクト: IMBOMKI/Geant4
// Function for the computation of channeling efficiency at various incoming angle
Int_t AnalyseChannelingEfficiency(TTree *fTree,Float_t fChannelingMinimum = 35., Float_t fChannelingMaximum = 70.){
    //**//Channeling Gaussian Fit Function
    TF1 *vChanneling = new TF1("vChanneling","gaus",fChannelingMinimum,fChannelingMaximum);
    vChanneling->SetParNames("Const","Mean","Sigma");
    vChanneling->SetLineColor(4);
    vChanneling->SetLineStyle(2);

    TH2D *hChannelingPlot = new TH2D("hChannelingPlot","Deflection Angle vs. Incoming Angle;Horizontal Incoming Angle [#murad];Horizontal Deflection Angle [#murad]",21,-10.5,10.5,256,-127.5,128.5);
    
    TH1F *hChannelingEfficiency = new TH1F("hChannelingEfficiency","G4Channeling;Horizontal Incoming Angle [#murad];Efficiency [%]",21,-10.5,10.5);

    fTree->Draw("-(angXout-angXin):-angXin>>hChannelingPlot");
    
    Double_t vNormalizationToAmorphous = 0.965; // Normalization for channeling efficiency, see PRSTAB 11, 063501 (2008)
    
    for(int i=2;i<=21;i++){
        TH1D* h1 = hChannelingPlot->ProjectionY("h1",i,i);
        h1->Fit(vChanneling,"QR");
        Double_t *vChannelingParameters;
        vChannelingParameters = vChanneling->GetParameters();
        hChannelingEfficiency->SetBinContent(i,ComputeEfficiency(h1,vChannelingParameters)/vNormalizationToAmorphous);
        h1->Delete();
    }
    hChannelingEfficiency->SetLineColor(3);
    hChannelingEfficiency->SetLineStyle(4);
    hChannelingEfficiency->SetMarkerColor(3);
    hChannelingEfficiency->SetFillStyle(0);
    hChannelingEfficiency->SetMarkerStyle(20);
    hChannelingEfficiency->Draw("PL");

    TGraph* gRoughExperimentalData = new TGraph(11);
    gRoughExperimentalData->SetPoint(	0	,	-10	,	20	);
    gRoughExperimentalData->SetPoint(	1	,	-8	,	38	);
    gRoughExperimentalData->SetPoint(	2	,	-6	,	56	);
    gRoughExperimentalData->SetPoint(	3	,	-4	,	72	);
    gRoughExperimentalData->SetPoint(	4	,	-2	,	80	);
    gRoughExperimentalData->SetPoint(	5	,	0	,	84	);
    gRoughExperimentalData->SetPoint(	6	,	2	,	82	);
    gRoughExperimentalData->SetPoint(	7	,	4	,	78	);
    gRoughExperimentalData->SetPoint(	8	,	6	,	66	);
    gRoughExperimentalData->SetPoint(	9	,	8	,	52	);
    gRoughExperimentalData->SetPoint(	10	,	10	,	37	);

    gRoughExperimentalData->SetLineColor(4);
    gRoughExperimentalData->SetLineStyle(3);
    gRoughExperimentalData->SetFillStyle(0);
    gRoughExperimentalData->SetFillColor(0);
    gRoughExperimentalData->SetMarkerColor(4);
    gRoughExperimentalData->SetMarkerStyle(21);
    gRoughExperimentalData->SetTitle("Phys. Lett. B 680, 129");

    gRoughExperimentalData->Draw("sameCP");

    TLegend *aLegend = new TLegend(0.30,0.15,0.55,0.3);
    aLegend->AddEntry(hChannelingEfficiency);
    aLegend->AddEntry(gRoughExperimentalData);
    aLegend->SetFillStyle(0);
    aLegend->SetLineColor(0);
    aLegend->Draw();

    return 0;
}
コード例 #28
0
ファイル: theoryPlot3S.C プロジェクト: zhlinl/usercode
theoryPlot3S(){

  double norm = 0.25;

//  gROOT->SetStyle("Plain");
  gROOT->LoadMacro("../xsection/setTDRStyle_modified.C");
  setTDRStyle();
  TString ytitle = TString::Format("d^{2}#sigma/dp_{T}dy #times #Beta(#mu#mu)  (nb/(GeV/c))");

  enum enuth {_data=0,_pythia,_cem,_cascade};
  int grcolor[4] = {1,4, 2,8};
  for(int i=0;i<4;i++) grcolor[i]=1; //remove color

  TFile cmsFile("xsection_3s_rap_0_2.root");
  TGraphAsymmErrors* cmsdata = ((TMultiGraph*)cmsFile.Get("mg1"))->GetListOfGraphs()->At(1);
//  TGraphAsymmErrors* cmsdata1 = ((TMultiGraph*)cmsFile.Get("mg1"))->GetListOfGraphs()->At(1);

  TCanvas *c2 = new TCanvas();//"c1","title",800,600);
  TH1F *frame = gPad->DrawFrame(0,0.0002,30,1);
  //TH2F * frame = new TH2F("frame","", 1000,0.,30., 0, 0.001,10);
  frame->SetStats(0);
  frame->GetXaxis()->SetTitle("p_{T}^{Y} (GeV/c)");
  frame->GetYaxis()->SetTitle(ytitle);
  frame->GetYaxis()->SetTitleOffset(1.1);
  frame->Draw();

  //////////////////////////////////////////////
  ///// PYTHIA
  //////////////////////////////////////////////

  TFile* fp = new TFile("../GenCrossSection/genXSupsilon3S.root"); // open the file
  TH1F* hist1 = (TH1F*)gDirectory->Get("genPt"); // get the hist
  TH1F* genPtLargeBins = (TH1F*)gDirectory->Get("genPtLargeBins"); // get the hist
  TGraphAsymmErrors* genPtLargeBinsGraph = (TGraphAsymmErrors*)gDirectory->Get("genPtLargeBinsGraph");
  //  hist1->Draw();

///////////////////////////////////////////////
  ////// Color octet Pierre
  ///////////////////////////////////////////////
  /*
  ifstream in;
  if(opt==1){
  in.open("DirectJpsi_CMSfullrap_clean.dat");
  } 
  if(opt==2){
    in.open("DirectJpsi_CMSrap_0_1.4_clean.dat");
  }
  if(opt==3){
    in.open("DirectJpsi_CMSrap_1.4_2.4_clean.dat");
  }
  Float_t pt[200], xscen[200], xsmin[200], xsmax[200], xserrlow[200], xserrhigh[200],pterr[200], xscen_corr[200], xserrlow_corr[200], xserrhigh_corr[200];
  for(int i=0; i<39; i++){
    in >> pt[i] >> xscen[i] >> xserrlow[i] >> xserrhigh[i]; 
    cout << "pt[i]= " << pt[i] << " xscen[i]= "<< xscen[i] <<"+" << xserrlow[i]<<  "-" << xserrhigh[i]<<  endl;
    xserrlow[i]=fabs(xserrhigh[i]);
    xserrhigh[i]=xserrlow[i];
    pterr[i]=0;
    Float_t factor=1000*0.0598;
    xscen_corr[i]=xscen[i]*factor;
    xserrlow_corr[i]=xserrlow[i]*factor;
    xserrhigh_corr[i]=xserrhigh[i]*factor;
  }
  
  TGraphAsymmErrors* gr;
  gr= new TGraphAsymmErrors(39,pt,xscen_corr,pterr,pterr, xserrlow_corr,xserrhigh_corr);
  gr->SetFillColor(7);
  gr->SetLineColor(7);
  TGraph * grline;
  grline= new TGraph(39,pt,xscen_corr);
  grline->SetLineWidth(5);
  grline->SetLineColor(7);
  */

  ///////////////////////////////////////////
  ///// CASCADE
  ///////////////////////////////////////////
  TH1F* histcascade_dir = new TH1F("hcas1","dsigma/dptjpsi*BR(jpsi->mumu) (pb/GeV) vs ptjpsi ",100,0.,100.);
  TH1F* histcascade_chi2p = new TH1F("hcas2","dsigma/dptjpsi*BR(jpsi->mumu) (pb/GeV) vs ptjpsi ",100,0.,100.);

  ifstream in,in1;
  in.open("Upsilon-txt/upsilon3s-pt-1eta2-dir3s.txt");
  in1.open("Upsilon-txt/upsilon3s-pt-1eta2-chi2p.txt");

  Float_t pt_cas_dir[200], pterr_cas_dir[200], xsc_cas_dir[200];
  Float_t pt_cas_chi2p[200], pterr_cas_chi2p[200], xsc_cas_chi2p[200];
  for(int i=1; i<101; i++){
    in >> xsc_cas_dir[i] >> pt_cas_dir[i] ;//cascade_dir;
    in1 >> xsc_cas_chi2p[i] >> pt_cas_chi2p[i];//cascade_chi2p

    // from Ramona Vogt
//    xscen[i]=cem*2*3.14*pt[i]*0.0248;
    cout << "CASCADE_dir: pt[i]= " << pt_cas_dir[i] << " xsc_cas_dir[i]= "<< xsc_cas_dir[i]<<  endl;
    cout << "CASCADE_chi2: pt[i]= " << pt_cas_chi2p[i] << " xsc_cas_chi2p[i]"<< xsc_cas_chi2p[i]<<  endl;
//    pterr[i]=0; // not known
  }
  for(int i=1; i<101; i++){
    histcascade_dir->SetBinContent(i, xsc_cas_dir[i]);
    histcascade_chi2p->SetBinContent(i, xsc_cas_chi2p[i]);
  }
   histcascade_dir->Add(histcascade_chi2p);
  //histcem->SetLineWidth(2);
  //histcem->SetLineColor(2);
  cout<<"CASCADE intgrated cross section = "<<histcascade_dir->Integral("width")<<endl;

/*
  TFile* f1 = new TFile("cascade-pp-7000-upsilon.root"); // open the file
  f1->cd("BPH10_003");
  TH1F* hh=(TH1F*)gDirectory->Get("h101");
  TFile* f2 = new TFile("cascade-pp-7000-chi_b.root"); // open the file
  f2->cd("BPH10_003");
  TH1F* gg=(TH1F*)gDirectory->Get("h101");
  gg->Add(hh);
  gg->SetLineWidth(2);
  gg->SetLineColor(8);
*/
  ////////////////////////
  /// CEM
  ////////////////////////

  TH1F* histcem = new TH1F("htot1","dsigma/dptjpsi*BR(jpsi->mumu) (pb/GeV) vs ptjpsi ",98,1.,50.);
  ifstream in;
  in.open("upsilon_cem.dat");

  Float_t pt[200], pterr[200], xscen[200];
  for(int i=1; i<97; i++){
    Float_t cem;
    in >> pt[i] >> cem;
    // from Ramona Vogt
    xscen[i]=cem*2*3.14*pt[i]*0.0248 *0.2;
//    cout << "CEM: pt[i]= " << pt[i] << " xscen[i]= "<< xscen[i]<<  endl;
    pterr[i]=0; // not known
  }
  for(int i=1; i<97; i++){
    histcem->SetBinContent(i, xscen[i]);
  }

  ////////////////////////////
  /// NOW ALL TOGETHER!
  ////////////////////////////
  c2->cd();
  c2->SetLeftMargin(0.15);
  c2->SetLogy();
  frame->Draw();
  ///// pierre
  //gr->Draw("E4");
  ///// cascade 
//  gg->Draw("same" "HIST");
  ///// cem
  cmsdata->SetLineWidth(3);
  //cmsdata->SetMarkerColor(1);
  //cmsdata->SetMarkerStyle(20);
  //cmsdata->SetMarkerSize(0.5);

  cmsdata->SetLineColor(grcolor[_data]);
  hist1  ->SetLineColor(grcolor[_pythia]);
  histcem->SetLineColor(grcolor[_cem]);
  histcascade_dir   ->SetLineColor(grcolor[_cascade]);

  histcascade_dir->SetLineWidth(3);
  histcascade_dir->SetLineStyle(3);

  histcem->SetLineWidth(2);
  histcem->SetLineStyle(6);

  hist1->SetLineWidth(2);
  hist1->SetLineStyle(1);

 //normalize
  histcascade_dir     ->Scale(norm);
  hist1  ->Scale(norm);
  histcem->Scale(norm);
  normalize(cmsdata,norm);

  ///// cascade 
  histcascade_dir->Draw("sameHIST");

  histcem->Draw("same HIST L");
  //// /pyt
  hist1->Draw("same HIST 9 C");
  cmsdata->Draw("P");
//  cmsdata1->Draw("Psame");

  TLatex latex;
  latex.DrawLatex(22,0.01,"|y^{#Upsilon}|<2");

  TLatex latex2;
  latex2.DrawLatex(2,0.0003,"#Upsilon(3S)");

  TLatex latex3;
  latex3.DrawLatex(2,0.0001 , "#sqrt{s}=7 TeV, L= 3 pb^{-1}");

  TLegend *leg = new TLegend(0.65,0.65,0.9,0.9);
//  leg->SetBorderSize(0);
//  leg->SetFillColor(10);
 
  leg->AddEntry(cmsdata, "CMS data", "PML");
  
  //leg->AddEntry(gr, "Direct #Upsilon, LO NRQCD, Artoisenet", "FL");
  leg->AddEntry(hist1,"PYTHIA", "L");
  leg->AddEntry(histcem, "CEM", "L");
  leg->AddEntry(histcascade_dir, "CASCADE", "L");

  leg->Draw();
  c2->Print("theoryPlot3S.gif");
  c2->Print("theoryPlot3S.eps");
  c2->Print("theoryPlot3S.pdf");

  hist1->Scale(1.02/1.7);
  hist1->Draw("same HIST 9c");
  c2->Print("theoryPlot3Sscaled.gif");
  c2->Print("theoryPlot3Sscaled.eps");
  c2->Print("theoryPlot3Sscaled.pdf");

  for(int i=0; i<cmsdata->GetN(); i++){
    cmsdata->GetEXhigh()[i+1] = 0;//genPtLargeBins->GetEXhigh()[i];
    cmsdata->GetEXlow()[i+1] = 0;// genPtLargeBins->GetEXlow()[i];
  }
  for(int i=0; i<genPtLargeBinsGraph->GetN(); i++){
//    genPtLargeBinsGraph->GetEYhigh()[i] = 0;
//    genPtLargeBinsGraph->GetEYlow()[i] = 0;
    genPtLargeBinsGraph->GetY()[i] = genPtLargeBinsGraph->GetY()[i]*1.02/1.7*norm;
  }
  frame->Draw();
  genPtLargeBinsGraph->SetMarkerStyle(1);
  genPtLargeBinsGraph->SetMarkerSize(0.01);
  genPtLargeBinsGraph->Draw("same PEz");
  cmsdata->Draw("same P");
  leg = new TLegend(0.4,0.75,0.9,0.9);
  leg->AddEntry(cmsdata, "CMS data", "PMLE");
  leg->AddEntry(genPtLargeBinsGraph,"PYTHIA (normalized)", "L");
  leg->Draw();
  latex.DrawLatex(21,0.08,"|y^{#Upsilon}| < 2");
  latex2.DrawLatex(2,0.0015,"#Upsilon(3S)");
  latex3.DrawLatex(2,0.0004 , "#sqrt{s} = 7 TeV, L = 3 pb^{ -1}");
  c2->Print("theoryPlot3Sbinned.gif");
  c2->Print("theoryPlot3Sbinned.eps");
  c2->Print("theoryPlot3Sbinned.pdf");
  hist1->Draw("same HIST c");
  c2->Print("theoryPlot3Scombined.gif");
  c2->Print("theoryPlot3Scombined.eps");
  c2->Print("theoryPlot3Scombined.pdf");

  for(int i=0; i<cmsdata->GetN(); i++){
    cmsdata->GetX()[i+1] = genPtLargeBinsGraph->GetX()[i];
    cmsdata->GetEXhigh()[i+1] = 0;//genPtLargeBins->GetEXhigh()[i];
    cmsdata->GetEXlow()[i+1] =0;// genPtLargeBins->GetEXlow()[i];
  }
  frame->Draw();
  hist1->Draw("same HIST c");
  cmsdata->Draw("same P");
  leg = new TLegend(0.4,0.75,0.9,0.9);
  leg->AddEntry(cmsdata, "CMS data", "PML");
  leg->AddEntry(hist1,"PYTHIA (normalized)", "L");
  leg->Draw();
  latex.DrawLatex(21,0.08,"|y^{#Upsilon}| < 2");
  latex2.DrawLatex(2,0.0015,"#Upsilon(3S)");
  latex3.DrawLatex(2,0.0004 , "#sqrt{s} = 7 TeV, L = 3 pb^{ -1}");
  c2->Print("theoryPlot3Sxpos.gif");
  c2->Print("theoryPlot3Sxpos.eps");
  c2->Print("theoryPlot3Sxpos.pdf");
}
コード例 #29
0
ファイル: plot_tree.C プロジェクト: abrennan87/SiMs_project
bool plot_tree(char* quantity,char* plotdim="(100,0.,3.)",bool log=true)
{
  char tmp1[250];
  char tmp2[300];
  char tmp3[100];
  sprintf(tmp2,"pythia.root");

  TFile* file;
  file=new TFile(tmp2);
  if(!file->IsOpen()) {
    cout << "No file "<<tmp2<<endl;
    return false;
  }
  file->cd();

  gROOT->SetStyle("Plain");
  const int maxjets=1+4;
  TH1F* hists[maxjets];
  sprintf(tmp3,"%s",quantity);
  TCanvas* c1=new TCanvas(tmp3,tmp3);
  c1->SetLogy();
  TLegend* leg=new TLegend(0.99,0.7,0.7,0.95);
  sprintf(tmp3,"l%s",quantity);
  leg->SetName(tmp3);
  int color[5]={2,4,3,5,6};
  int style[5]={2,3,4,3,4};

  //  bool ptw=false;
  TLeaf *leaf_Xsec = xsecs->FindLeaf("Xsecfact");
  Float_t Xsecfact;
  leaf_Xsec->SetAddress(&Xsecfact);
  xsecs->GetEntry(0);
  if (events->GetEntries()>0) {
  for(int i=0;i<maxjets;i++){
    events->SetLineWidth(2);
    events->SetLineColor(i+2);
    events->SetLineStyle(i+2);
    
    if(log) 
      sprintf(tmp1,"log10(%s)>>%s%i%s",quantity,quantity,i,plotdim);
    else 
      sprintf(tmp1,"%s>>%s%i%s",quantity,quantity,i,plotdim);
    sprintf(tmp2,"%e*(Npart==%i)",Xsecfact,i);

    cout << "events->Draw("<<tmp1<<","<<tmp2<<");"<<endl;
    events->Draw(tmp1,tmp2);

    sprintf(tmp3,"%s%i",quantity,i);
    hists[i]=(TH1F*)gROOT->FindObject(tmp3);
    if(!hists[i]){
      cout << "Failed to get object "<<tmp3<<endl;
      return false;
    }
  }
  }

  TH1F *hsum = (TH1F*)hists[0]->Clone();
  sprintf(tmp3,"%ssum",quantity);
  hsum->SetName(tmp3);
  for(int i=1;i<maxjets;i++)
    hsum->Add(hists[i]);
  cout << "Integral of "<<quantity<<": "<<hsum->Integral()<<endl;
  hsum->SetLineWidth(2);
  hsum->SetLineColor(1);
  hsum->SetLineStyle(1);
  //  hsum->SetMinimum(hsum->GetMaximum()*1e-3);
  hsum->SetStats(kFALSE);
  sprintf(tmp3,"%s",quantity);
  hsum->SetTitle(tmp3);
  sprintf(tmp3,"log10(%s)",quantity);
  hsum->GetXaxis()->SetTitle(tmp3);
  hsum->GetYaxis()->SetTitle("Cross section (pb/bin)");
  hsum->Draw();
  leg->AddEntry(hsum->GetName(),"Sum of contributions");

  for(int i=0;i<maxjets;i++){
    hists[i]->Draw("same");
    sprintf(tmp3,"%i-jet sample",i);
    leg->AddEntry(hists[i]->GetName(),tmp3);
  }

  leg->Draw();

  sprintf(tmp2,"%s.eps",quantity);
  cout << "Saving plot as " << tmp2 << endl;
  c1->SaveAs(tmp2);
  return true;
}
コード例 #30
0
ファイル: ptBestFit.C プロジェクト: chernyavskaya/vbfHbbShare
void ptBestFit(float BIN_SIZE=5.0,bool BLIND=false,TString MASS,TString NAME)
{
  gROOT->ProcessLine(".x ../../common/styleCMSTDR.C");
  gSystem->Load("libHiggsAnalysisCombinedLimit.so");
  gROOT->ForceStyle();
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  gROOT->SetBatch(1);
  gStyle->SetPadRightMargin(0.04);
  gStyle->SetPadLeftMargin(0.16);
  gStyle->SetPadTopMargin(0.06);
  gStyle->SetPadBottomMargin(0.10);
  gStyle->SetTitleFont(42,"XY");
  gStyle->SetTitleSize(0.0475,"XY");
  gStyle->SetTitleOffset(0.9,"X");
  gStyle->SetTitleOffset(1.5,"Y");
  gStyle->SetLabelSize(0.0375,"XY");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    delete ds;
  }

  cout << "chi2sumS: " << chi2sumS << endl;
  cout << "chi2sumB: " << chi2sumB << endl;
  cout << "nparS: " << nparS << endl;
  cout << "nparB: " << nparB << endl;
  cout << "nbinsum: " << nparsum << endl;
  cout << "chi2sumS/(nbinsum - nparS): " << chi2sumS / (float)(nparsum - nparS) << endl;
  cout << "chi2sumB/(nbinsum - nparB): " << chi2sumB / (float)(nparsum - nparB) << endl;
  delete datasets; 
}