示例#1
2
void simplePlotter(){

  const unsigned int n = 6;

  TFile* ftt[n];

  // diboson
  char* names[n] = {"BB-4p-0-500_100TEV_40PileUp",
		    "BB-4p-500-1500_100TEV_40PileUp",
		    "BB-4p-1500-3000_100TEV_40PileUp",
		    "BB-4p-3000-5500_100TEV_40PileUp",
		    "BB-4p-5500-9000_100TEV_40PileUp",
		    "BB-4p-9000-100000_100TEV_40PileUp"};


  char* labels[n] = {"S*_{T} < 1 TeV","S*_{T} 1-2 TeV","S*_{T} 2-3.5 TeV","S*_{T} 3.5-5.5 TeV","S*_{T} 5.5-8.5 TeV","S*_{T} > 8.5 TeV"};

  int   colors[n] = { 2 , 3 , 4 , 5 , 6 , 7 };

  TH1F* hst[n];

  THStack* htstack = new THStack();

  TLegend *leg = new TLegend(0.5,0.5,0.8,0.8);

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

    ftt[i] = TFile::Open(Form("output/%s.root",names[i]));
    hst[i] = (TH1F*) ftt[i]->Get("st");
    hst[i]->SetFillColor(colors[i]);

    cout << "Integral " << i << " " << hst[i]->Integral() << endl;

    hst[i]->GetXaxis()->SetTitle("S_{T} [GeV]");
    hst[i]->GetYaxis()->SetTitle("events");

    leg->AddEntry( hst[i] , labels[i] , "lf" );

    htstack->Add(hst[i]);

  }

  TCanvas *c2 = new TCanvas("c2","c2",1200,600);
  c2->cd();
  gStyle->SetOptStat(0);

  gPad->SetLogy();
  htstack->Draw();
  htstack->GetXaxis()->SetTitle("S_{T} [GeV]");
  htstack->GetYaxis()->SetTitle("events");

  TLatex *t = new TLatex();
  t->SetNDC();
  t->DrawLatex(0.5,0.85,"t#bar{t} events, 100 TeV, L = 1 pb^{-1}");

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

}
示例#2
0
void plotComparison(TFile **input, const string &title, const bool &reverse_order = false)
{
    TH1 *qcd = merge("htlep", input, 0, QCD_CHANNELS);
    TH1 *ttjets = get("htlep", input[TTJETS], TTJETS);
    TH1 *zjets = get("htlep", input[ZJETS], ZJETS);
    TH1 *wjets = get("htlep", input[WJETS], WJETS);
    TH1 *data = merge("htlep", input, RERECO, RERECO + DATA_CHANNELS);
    data->SetFillColor(0);
    
    THStack *stack = new THStack();
    stack->Add(qcd);
    stack->Add(ttjets);
    stack->Add(zjets);
    stack->Add(wjets);

    if (reverse_order)
    {
        stack->Draw("h");
        data->Draw("h same");
    }
    else
    {
        data->Draw("h");
        stack->Draw("h same");
    }

    TLegend *legend = createLegend(title.c_str());
    legend->Draw();
}
void stack_ring_contribs(const string& fFile, const string& fTitleExt, const string& fNameExt) {
                                
   string title = "<E> in i#eta Ring " + fTitleExt + ";i#eta;<E> [GeV]";
                                
   TFile file(fFile.c_str());   
   file.cd("offsetAnalysis");   
                                
   TH1D *p_AEEREB  = p_AvgEinEREB->ProjectionX();
   TH1D *p_AEEREE  = p_AvgEinEREE->ProjectionX();
   TH1D *p_AEERHB  = p_AvgEinERHB->ProjectionX();
   TH1D *p_AEERHE  = p_AvgEinERHE->ProjectionX();
   TH1D *p_AEERHFl = p_AvgEinERHFl->ProjectionX();
   TH1D *p_AEERHFs = p_AvgEinERHFs->ProjectionX();
   //TH1D *p_AEERHO  = p_AvgEinC5HO->ProjectionX();
         
   p_AEEREB->SetFillColor(50);
   p_AEEREE->SetFillColor(8);
   p_AEERHB->SetFillColor(4);
   p_AEERHE->SetFillColor(6);
   p_AEERHFl->SetFillColor(16);
   p_AEERHFs->SetFillColor(12);
   //p_AEERHO->SetFillColor(7);
   
   TCanvas *c = new TCanvas("c", "",1120,800);
   c->cd();
   
   THStack *hs = new THStack("hs",title.c_str());
   
   hs->Add(p_AEEREB);
   hs->Add(p_AEEREE);
   hs->Add(p_AEERHB);
   hs->Add(p_AEERHE);
   hs->Add(p_AEERHFl);
   hs->Add(p_AEERHFs);
   //hs->Add(p_AEERHO);
   hs->Draw("hist");
   
   TLegend *legend = new TLegend(.6,.55,.68,.85);
   legend->SetBorderSize(1);
   legend->SetFillColor(0);
   //legend->SetFillStyle(0);
   legend->SetTextFont(42);
   legend->AddEntry(p_AEEREB,"EB","f");
   legend->AddEntry(p_AEEREE,"EE","f");
   legend->AddEntry(p_AEERHB,"HB","f");
   legend->AddEntry(p_AEERHE,"HE","f");
   legend->AddEntry(p_AEERHFl,"HFl","f");
   legend->AddEntry(p_AEERHFs,"HFs","f");
   //legend->AddEntry(p_AEERHO,"HO","f");
   legend->Draw();
   
   string fileName = "p_AvgEinER_stacked__" + fNameExt + ".png";
   
   c->SetGridy();
   c->SaveAs(fileName.c_str());

   delete legend;
   delete hs;
   delete c;
}
示例#4
0
文件: multicolor.C 项目: Y--/root
void multicolor(Int_t isStack=0) {
   TCanvas *c1 = new TCanvas;
   Int_t nbins = 20;
   TH2F *h1 = new TH2F("h1","h1",nbins,-4,4,nbins,-4,4);
   h1->SetFillColor(kBlue);
   TH2F *h2 = new TH2F("h2","h2",nbins,-4,4,nbins,-4,4);
   h2->SetFillColor(kRed);
   TH2F *h3 = new TH2F("h3","h3",nbins,-4,4,nbins,-4,4);
   h3->SetFillColor(kYellow);
   THStack *hs = new THStack("hs","three plots");
   hs->Add(h1);
   hs->Add(h2);
   hs->Add(h3);
   TRandom r;
   Int_t i;
   for (i=0;i<20000;i++) h1->Fill(r.Gaus(),r.Gaus());
   for (i=0;i<200;i++) {
      Int_t ix = (Int_t)r.Uniform(0,nbins);
      Int_t iy = (Int_t)r.Uniform(0,nbins);
      Int_t bin = h1->GetBin(ix,iy);
      Double_t val = h1->GetBinContent(bin);
      if (val <= 0) continue;
      if (!isStack) h1->SetBinContent(bin,0);
      if (r.Rndm() > 0.5) {
         if (!isStack) h2->SetBinContent(bin,0);
         h3->SetBinContent(bin,val);
      } else {
         if (!isStack) h3->SetBinContent(bin,0);
         h2->SetBinContent(bin,val);
      }
   }
   hs->Draw("lego1");
}
示例#5
0
THStack* CutFlow::buildStack(AllSamples samples, Variable variable){

	THStack *hs = new THStack("hs","test");

	hs->Add(samples.qcd->histo);
	hs->Add(samples.vjets->histo);
	hs->Add(samples.single_t->histo);
	hs->Add(samples.ttbar->histo);

	return hs;
}
示例#6
0
void createInputs(int n = 2) 
{
   for(UInt_t i = 0; i < (UInt_t)n; ++i ) {
      TFile *file = TFile::Open(TString::Format("input%d.root",i),"RECREATE");
      TH1F * h = new TH1F("h1","",10,0,100);
      h->Fill(10.5); h->Fill(20.5);
 
      Int_t nbins[5];
      Double_t xmin[5];
      Double_t xmax[5];
      for(UInt_t j = 0; j < 5; ++j) {
         nbins[j] = 10; xmin[j] = 0; xmax[j] = 10;
      }
      THnSparseF *sparse = new THnSparseF("sparse", "sparse", 5, nbins, xmin, xmax);
      Double_t coord[5] = {0.5, 1.5, 2.5, 3.5, 4.5};
      sparse->Fill(coord);
      sparse->Write();
      
      THStack *stack = new THStack("stack","");
      h = new TH1F("hs_1","",10,0,100);
      h->Fill(10.5); h->Fill(20.5);
      h->SetDirectory(0);
      stack->Add(h);
      h = new TH1F("hs_2","",10,0,100);
      h->Fill(30.5); h->Fill(40.5);
      h->SetDirectory(0);
      stack->Add(h);
      stack->Write();

      TGraph *gr = new TGraph(3);
      gr->SetName("exgraph");
      gr->SetPoint(0,1,1);
      gr->SetPoint(1,2,2);
      gr->SetPoint(2,3,3);
      
      gr->Write();
      
      TTree *tree = new TTree("tree","simplistic tree");
      Int_t data = 0;
      tree->Branch("data",&data);
      for(Int_t l = 0; l < 2; ++l) {
         data = l;
         tree->Fill();
      }
      
      file->Write();
      delete file;
   }
}
示例#7
0
void PlotHistsNhitsPerModule(TFile* f, TTree* tr, TString strMillepedeRes, TString strOutdir)
{
  TString canvName="c_";
  canvName+=strMillepedeRes;
  canvName+="_";
  canvName+=StrPlotType(NHITS);
  canvName.ReplaceAll(".res","");


  //enum {PXB,PXF,TIB,TID,TOB,TEC};
  int colors[6]={1,2,3,4,6,7};
//  TString labels[6]={"PXB","PXF","TIB","TID","TOB","TEC"};

  f->cd();
  TCanvas* canv = new TCanvas(canvName,canvName,600,600);
  canv->SetLogx();
  canv->SetLogy();

  for (int ind=1; ind<=1; ind++){
    TString strHist = "hNhits_";
    strHist+=StrPar(ind);
    TString strCut="label<700000 && ((label%20-1)%9+1)==";
    strCut+=ind;
    TStyle style; 
    style.SetTitleFontSize(0.2);
    THStack *hSt = new THStack("hNhits","# of derivatives (~tracks or hits) per module");
    TLegend *leg = new TLegend(0.75,0.65,0.95,0.95);
    for (int inv=0; inv<6; inv++){
      std::cout<<"- - - - - -"<<std::endl;
      std::cout<<subdLabels[inv]<<":"<<std::endl;
      std::cout<<StrCutSubd(inv)<<": "<<tr->GetEntries(StrCutSubd(inv))<<" parameters"<<std::endl;
      TString strHist1=strHist;
      strHist1+=ind;
      strHist1+=inv;
      TH1F* hValInt = new TH1F(strHist1,strHist1,300,10,15000);  
      TString strCut1 = strCut+TString(" && ")+StrCutSubd(inv);
      tr->Draw(TString("Nhits>>")+strHist1,strCut1,"goff");
      std::cout<<"# hits = "<<(int)hValInt->GetMean()<<"+-"<<(int)hValInt->GetRMS()<<std::endl;
      hValInt->SetLineColor(1);
      hValInt->SetFillColor(colors[inv]);
      hValInt->SetLineWidth(2);
      hSt->Add(hValInt);
      leg->AddEntry(hValInt,subdLabels[inv],"f");
      leg->SetFillColor(0);
    }
    hSt->Draw();
    leg->Draw("same");
    
  }//end of loop over ind

  canvName+=".png";
  TString saveName=strOutdir+canvName;
  canv->SaveAs(saveName);
  saveName.ReplaceAll(".png",".pdf");
  canv->SaveAs(saveName);
}//end of PlotHistsNhitsPerModule
示例#8
0
  //____________________________________________________________________
  void Run(const char* newName,        const char* oldName,
	   const char* newTitle="New", const char* oldTitle="Old")
  {
    TFile* newFile = TFile::Open(newName,"READ");
    TFile* oldFile = TFile::Open(oldName,"READ");
    if (!newFile || !oldFile) return;

    TH1* newCent = GetH1(newFile, "realCent");
    TH1* oldCent = GetH1(oldFile, "realCent");
    if (!newCent || !oldCent) return;

    TString  t; t.Form("#it{R}=#frac{%s}{%s}", newTitle, oldTitle);
    TCanvas* c     = new TCanvas("c", t, 1200, 800);
    c->SetTopMargin(0.01);
    c->SetRightMargin(0.20);
    fLegend = new TLegend(1-c->GetRightMargin(),
			  c->GetBottomMargin(),
			  1, 1-c->GetTopMargin(),
			  t);
    fLegend->SetFillStyle(0);
    fLegend->SetBorderSize(0);
    THStack* stack = new THStack("ratios","");
			       
    fMin = +1e6;
    fMax = -1e6;
    TH1* one = 0;
    for (Int_t i = newCent->GetNbinsX(); i--;) {
      Double_t c1 = newCent->GetXaxis()->GetBinLowEdge(i+1);
      Double_t c2 = newCent->GetXaxis()->GetBinUpEdge(i+1);
      Info("", "c1=%f c2=%f", c1, c2);
      TH1*     r  = One(newFile, oldFile, c1, c2);    
      if (!r) continue;
      if (!one) {
	one = static_cast<TH1*>(r->Clone("one"));
	one->SetDirectory(0);
	one->Reset();
	for (Int_t j = 1; j <= one->GetNbinsX(); j++) {
	  one->SetBinContent(j,1);
	  one->SetBinError  (j,0);
	}
      }
      // r->Add(one, i-1);
      // r->Scale(TMath::Power(10,i));
      stack->Add(r);
    }
    stack->Draw("nostack");
    stack->SetMinimum(0.95*fMin);
    stack->SetMaximum(1.05*fMax);
    stack->GetHistogram()->SetXTitle("#eta");
    stack->GetHistogram()->SetYTitle("#it{R}");
    fLegend->Draw();
    c->Modified();
    c->Update();
    c->cd();
    c->SaveAs(Form("%sover%s.png", newTitle, oldTitle));
  }  
示例#9
0
THStack *stack(TH1** hists, char *hsn = "histstack", char *htn = "stack o hists") {
  int goodcolors[] = { kRed+1, kGreen+1, kBlue, kYellow+1, kMagenta+1, kCyan+1, 9 };
  THStack *hs = new THStack(hsn,htn);
  for (int i = 0; i < 6; i++) {
    hists[i]->SetLineColor(goodcolors[i]);
    if (hists[i]->InheritsFrom("TH2")) hists[i]->SetOption("colz");
    hs->Add(hists[i]);
  }
  return hs;
}
示例#10
0
void superimposeHistos()
{
  TFile* bFile = TFile::Open("Electron_In_Jets_900GeV_bJets.root");
  TFile* cFile = TFile::Open("Electron_In_Jets_900GeV_cJets.root");
  TFile* udsgFile = TFile::Open("Electron_In_Jets_900GeV_udsgJets.root");
  
  TIter next(bFile->GetListOfKeys());
  TFile* newFile = new TFile("testFile.root", "RECREATE");
  while(TKey* key = (TKey*)next())
  {
    TH1F* bHist = (TH1F*)bFile->Get(key->GetName());
    bHist->SetFillColor(2);
    
    TH1F* cHist = (TH1F*)cFile->Get(key->GetName());
    cHist->SetFillColor(3);
    
    TH1F* udsgHist = (TH1F*)udsgFile->Get(key->GetName());
    udsgHist->SetFillColor(4);
    
    THStack* stack = new THStack(bHist->GetName(), bHist->GetTitle());
    stack->Add(udsgHist, "hist ][");
    stack->Add(cHist, "hist ][");
    stack->Add(bHist, "hist ][");
    
    TLegend* legend = new TLegend(0.5, 0.68, 0.88, 0.88);
    legend->AddEntry(bHist, "b-Jets");
    legend->AddEntry(cHist, "c-Jets");
    legend->AddEntry(udsgHist, "udsg-Jets");
    
    TCanvas* canvas = new TCanvas(bHist->GetName());
    stack->Draw();
    stack->GetXaxis()->SetTitle(bHist->GetXaxis()->GetTitle());
    legend->Draw();
    canvas->Write(canvas->GetName());
  }
  
  newFile->Close();
  bFile->Close();
  cFile->Close();
  udsgFile->Close();
}
示例#11
0
void Matching_Comp() {

  const int n_Signal = 1;
  const int n_Hist = 33;
  const int n_Category=5;

  const TString File_Name[n_Signal] = {"Tstar_M-1300"};

  int Color[n_Category] = { 628, 412,415,858, 868};//858,
  //EColor Color[n_Hist] = { kRed, kGreen, kBlue, 434,kCyan};

  const TString Hist_Name[n_Hist] = {"Discriminator_sum","Number of subjets gluon had","Number of subjets gluon lep","DeltaR_GluonGluon","DeltaR_TopTop","DeltaR_TopHad_BLep","Pt_Ratio_gluonhad_subjets","DeltaR_gluonhad_subjets","DeltaR_gluonlep_subjets","CSV_gluonLep","CSV_bLep","DeltaR_GluonTop_lep","DeltaR_GluonTop_had","DeltaR_GluonHad_TopLep","DeltaR_GluonLep_TopHad","M_TstarhadTstarlep_Diff_rel","Pt_Ratio_blep_toplep","Pt_Diff_gluonlep_toplep","Pt_Diff_gluonlep_gluonhad","Pt_Diff_gluon_top_lep","Pt_Diff_gluon_top_had","M_Tstarlep_rec","M_Tstarhad_rec","M_toplep","M_tophad","M_Tstar_comb","M_Tstar_ratio","Pt_Tstar_ratio","M_gluon_ratio","M_gluonhad","M_gluonlep","Pt_gluonhad","Pt_gluonlep"};

  const TString Hist_Label[n_Hist] = {"#Chi^{2}","Number of subjets gluon had","Number of subjets gluon lep","#Delta R Gluon Gluon","#Delta R Top Top","#Delta R Top_{Had} B_{Lep}","Pt Ratio gluonhad subjets","#Delta R gluon had subjets","#Delta R gluon had subjets","CSV_gluonLep","CSV bLep","#Delta R gluon top lep","#Delta R gluon top had","#Delta R gluon_{had} top_{lep}","#Delta R gluon_{lep} top_{had}","M_TstarhadTstarlep_Diff_rel","Pt Ratio b_{lep} top_{lep}","Pt Diff gluonlep toplep","Pt Diff gluonlep gluonhad","Pt Diff gluon top lep","Pt Diff gluon top had","T*  Mass, lep","T*  Mass, had","M top lep","M top had","M T* comb","M_Tstar_ratio","Pt_Tstar_ratio","M_gluon_ratio","M_gluonhad","M_gluonlep","Pt gluonhad","Pt gluonlep"};

  const TString Category_Name[n_Category] = {"chi2_gluon_nomatch__HypHists","chi2_gluon_switch__HypHists","chi2_gluonlep_semimatch__HypHists", "chi2_gluonhad_semimatch__HypHists","chi2_gluon_match__HypHists"};//"chi2_gluonhad_semimatch__HypHists",
  const TString Legend_Name[n_Category] = {"No Match","Switched","Semimatch, wrong gluon","Semimatch, gluon", "Match"}; //"Semimatch, gluon",

  TLegend* leg1 = new TLegend(0.67,0.65,0.87,0.87);
  leg1->SetBorderSize(0);

  for(int i = 0; i<n_Signal; i++){
    TFile *signal = new TFile("/nfs/dust/cms/user/multh/RunII_80X_v3/Selection/Nominal/03Feb2017_Relaunch_17Jan2018/Muons/Kinematic_Study/uhh2.AnalysisModuleRunner.MC."+File_Name[i]+".root");

    TH1F *h_signal[n_Hist][n_Category];

    for(int j= 0; j<n_Hist; j++){
      THStack *hs = new THStack("hs","");
      
      for(int k = 0; k<n_Category; k++){
	h_signal[j][k] = (TH1F*)signal->Get(Category_Name[k]+"/"+Hist_Name[j]);
	h_signal[j][k] ->SetFillColor(Color[k]);
	h_signal[j][k] -> SetLineColor(Color[k]);
	h_signal[j][k] ->SetLineWidth(2);
	if(j==0)leg1->AddEntry(h_signal[j][k],Legend_Name[k],"f");

      hs->Add(h_signal[j][k]);

    }    

    TCanvas *b1 = new TCanvas("b1","b1",800,600);
    gStyle->SetOptStat(0);
    hs->Draw("hist");
    hs->GetXaxis()->SetTitle(Hist_Label[j]);
    hs->GetXaxis()->SetTitleSize(0.05);
    leg1->Draw();
    b1->Modified();

    b1->SaveAs("/nfs/dust/cms/user/multh/CMSSW_8_0_26_patch2/src/UHH2/TstarSemiLeptonic/Plots/"+Hist_Name[j]+"_match.pdf");
    }
    
  }
}
示例#12
0
void StackPlots( TFile* f1, vector<string> hist, vector<string> leg, vector<Color_t> color, string xtitle_, string ytitle_, string xunit, string savePath, bool ylog=0, int rebin=1){
	int Bins = 0;
	int x1 = 0;
	int x2 = 0;
	int size = hist.size();
	float binwidth = 0;
	char title[100], xtitle[100], ytitle[100];
	TH1F* h1[size];
	for(int i=0; i<size; i++){
		h1[i] = (TH1F*)f1->Get(hist[i].c_str());
		h1[i]->UseCurrentStyle();
		h1[i]->Rebin(rebin); 
		if( Bins != 0 ){ if( h1[i]->GetXaxis()->GetLast() != Bins ) { cout<<"Error: Exist different bin size( plot: "<<i<<")"<<endl; }}
		Bins = h1[i]->GetXaxis()->GetLast();
		binwidth = h1[i]->GetBinWidth(1);
		x1 = h1[i]->GetXaxis()->GetBinLowEdge(1);
		x2 = h1[i]->GetXaxis()->GetBinUpEdge(Bins);

		h1[i]->SetLineWidth(1);
		h1[i]->SetLineColor(color[i]);
		h1[i]->SetFillColor(color[i]);
	}

	sprintf(xtitle,"%s [%s]",xtitle_.c_str(),xunit.c_str());
	sprintf(ytitle,"%s / [%3.0f%s]",ytitle_.c_str(),binwidth,xunit.c_str());
	sprintf(title,";%s;%s",xtitle,ytitle);
	cout<<Bins<<" "<<x1<<" "<<x2<<endl;
	TH1F* hs_stack = new TH1F("hs_stack",title,Bins,x1,x2);
        THStack *hs = new THStack("hs","");

	TLegend* leg_ = new TLegend(0.65,0.65,0.85,0.85);
	TCanvas* c1 = new TCanvas("c1", "", 850, 700);
        c1->SetGridx();
        c1->SetGridy();
	gStyle->SetOptStat(0);
	gStyle->SetOptTitle(0);
	hs_stack->UseCurrentStyle();
	hs->SetHistogram(hs_stack);	
	for(int i=0; i<size; i++){
		hs->Add(h1[i]);
		leg_->AddEntry(h1[i],leg[i].c_str(),"f");
	}
        leg_->SetFillStyle(0);
        leg_->SetBorderSize(0);
        leg_->SetTextSize(0.042);
	if( ylog ) gPad->SetLogy();
	hs->SetMinimum(1);
	hs->SetMaximum(1e+13);
	hs->Draw();
	leg_->Draw();
	c1->SaveAs(savePath.c_str());
}
void plot_example(){
 THStack *hs = new THStack("hs","");
   TH1F *h1 = new TH1F("h1","test hstack",10,-4,4);
   h1->FillRandom("gaus",20000);
   h1->SetFillColor(kRed);
   hs->Add(h1);
   TH1F *h2 = new TH1F("h2","test hstack",10,-4,4);
   h2->FillRandom("gaus",15000);
   h2->SetFillColor(kBlue);
   hs->Add(h2);
   TH1F *h3 = new TH1F("h3","test hstack",10,-4,4);
   h3->FillRandom("gaus",10000);
   h3->SetFillColor(kGreen);
   hs->Add(h3);
   TCanvas *cs = new TCanvas("cs","cs",10,10,700,900);
   TText T; T.SetTextFont(42); T.SetTextAlign(21);
   cs->Divide(2,2);
   cs->cd(1); hs->Draw(); T.DrawTextNDC(.5,.95,"Default drawing option");
   cs->cd(2); hs->Draw("nostack"); T.DrawTextNDC(.5,.95,"Option \"nostack\"");
   cs->cd(3); hs->Draw("nostackb"); T.DrawTextNDC(.5,.95,"Option \"nostackb\"");
   cs->cd(4); hs->Draw("lego1"); T.DrawTextNDC(.5,.95,"Option \"lego1\"");
}
示例#14
0
THStack * FromTH1FMakeTHStack(vector<TH1F*> * histo, TString stack_name, vector<TString> * h_description, bool order_size, bool nostack, TString x_axis, TString y_axis, TH1F * data){
 
  if((int) histo->size() != (int) h_description->size()){ Error("Histogram numbers and legend items do not match");}

  THStack * stack = new THStack("stack", stack_name);
  stack->SetTitle("");
  TLegend * legend = new TLegend(0.7,0.5,0.9,0.9);
  legend->SetFillColor(0);

  Int_t h_array_size = (int) histo->size();
  Int_t reorder[h_array_size];
  if(order_size){
    Float_t integral[h_array_size];
    for(int itr = 0; itr < h_array_size; itr++){
      integral[itr] = (*histo)[itr]->Integral();
    }
    for(int itr1 = 0; itr1 < h_array_size; itr1++){
      for(int itr2 = 0; itr2 < h_array_size; itr2++){
	if(itr1 == itr2) continue;
	if(integral[itr1] < integral[itr2]){
	  reorder[itr1] += 1;
	}
      }
    }
  }
  for(int itr = 0; itr < h_array_size; itr++){
    if( nostack ){ stack->Add((*histo)[reorder[itr]], "nostack"); }
    if(!nostack ){ stack->Add((*histo)[reorder[itr]]); }
    legend->AddEntry((*histo)[itr], (*h_description)[itr], "f");
  }
  if(data != NULL){ 
    stack->Add(data, "nostack");
    legend->AddEntry(data, "Data", "p");
  }

  return stack;

}
示例#15
0
// Add a histogram to top of a stack
double addHistogram(const TString & fileName, const TString & histoName, const int color, THStack & hs,
    const TString & leg, TLegend *legend, const float lumi, int minIntegral=1, int maxIntegral=-1 )
{
  TFile * inputFile= new TFile (fileName, "READ");
  TH1F * histo = (TH1F*)inputFile->Get(histoName);
  TH1::SetDefaultSumw2();
  histo->Scale(lumi);

  histo->SetFillColor(color);
  hs.Add(histo);

  legend->AddEntry(histo, leg, "f");

  if ( maxIntegral==-1 ) maxIntegral=histo->GetNbinsX();

  return histo->Integral( minIntegral, maxIntegral );
}
示例#16
0
THStack *getstack(TTree *nt, TString name, TString var, vector<TString> cuts,int bins = 100, float xmin = 0, float xmax = 200)
{
  THStack *hs = new THStack(name,name);
  int N = cuts.size();
  vector<TH1F *> vh(N);
  for (int i=0;i<N;i++) {
    vh[i] = geth(Form("%s%d",name.Data(),i),bins,xmin,xmax);

    vh[i]->SetFillColor(TColor::GetColorDark(i+2));
    vh[i]->SetFillStyle(1001);
    nt->Project(vh[i]->GetName(),var.Data(),Form("weight*(%s)",cuts[i].Data()),"");//,1000);
    hs->Add(vh[i],"hist");
    cout<<vh[i]->Integral()<<endl;
  }
  hs->SetMinimum(1E-2);

  return hs;
}
示例#17
0
  // Do the loop here, so that we can use options like "errors"
  void Draw( const TString & xTitle = "", const TString & yTitle = "", const bool errors = false ) {

    // Create a new THStack so that it handle tha maximum
    // THStack stack(name_, title_);
    THStack * stack = new THStack(name_, title_);

    int colorIndex = 0;
    if( !(histoList_.empty()) ) {
      std::vector<TH1*>::iterator histoIter = histoList_.begin();
      for( ; histoIter != histoList_.end(); ++histoIter, ++colorIndex ) {
        TH1 * histo = *histoIter;
        if(errors) histo->Sumw2();
        // histo->SetNormFactor(1);
        if( colorIndex < 4 ) histo->SetLineColor(colors_[colorIndex]);
        else histo->SetLineColor(colorIndex);
        // Draw and get the maximum value
        TString normalizedHistoName(histo->GetName());
        TH1 * normalizedHisto = (TH1*)histo->Clone(normalizedHistoName+"clone");
        normalizedHisto->Scale(1/normalizedHisto->Integral());
        stack->Add(normalizedHisto);
      }
      // Take the maximum of all the drawed histograms
      // First we need to draw the histogram, or getAxis() will return 0... (see root code...)
      canvas_->Draw();
      canvas_->cd();
      stack->Draw("nostack");
      stack->GetYaxis()->SetTitleOffset(1.2);
      stack->GetYaxis()->SetTitle(yTitle);
      stack->GetXaxis()->SetTitle(xTitle);
      stack->GetXaxis()->SetTitleColor(kBlack);
      stack->Draw("nostack");
      legend_->Draw("same");

      canvas_->Update();
      canvas_->Draw();
      canvas_->ForceUpdate();
      //canvas_->Print("test.pdf");
      canvas_->Write();

    }
  }
示例#18
0
文件: DrawTree.C 项目: nsahoo/cmssw-1
void DrawTree::Project(Params& A) {

    char name[128];
    sprintf(name,"drawTree%d_%d",fN,_countAdd++);
    A._Hname=name;
    _tree->Project(name,A._varexp.c_str(),A._selection.c_str(),A._option.c_str(),A._nentries,A._firstentry);

    TH1* h = (TH1*)gDirectory->Get(A._Hname.c_str());

    h->SetMarkerStyle(_MarkerStyle+(_MarkerCount0++));
    h->SetMarkerColor(_MarkerColor+(_MarkerCount1++));

    A._TH=h;
    _stack.Add(h);
    cout << A._legend.c_str() << endl;
    _legend->AddEntry(h,A._legend.c_str(),"P");

    float axmin=h->GetXaxis()->GetXmin();
    float axmax=h->GetXaxis()->GetXmax();

    if (xmin>axmin)
        xmin=axmin;
    if (xmax<axmax)
        xmax=axmax;

    if (A._varexp.find(":") != string::npos) {
        A._1D=false;
        float aymin=h->GetYaxis()->GetXmin();
        float aymax=h->GetYaxis()->GetXmax();

        if (ymin>aymin)
            ymin=aymin;
        if (ymax<aymax)
            ymax=aymax;

    }
}
void plotasym(int top){
  if (setup("vm","","pol__")==kFALSE) return;

  THStack* hs = new THStack(TString::Format("asym_top%d",top), TString::Format("asym_top%d",top));

  int itop = top-1;
  TFile* fy = _fyexp[itop];
  TIter nextkey(fy->GetListOfKeys());
  TKey *key;
  while (key = (TKey*)nextkey()) {
    TString Q2Wdirname = key->GetName();
    if(Q2Wdirname.EqualTo("hYW_Dir") || Q2Wdirname.EqualTo("hYW"))continue;
    cout << "Q2Wdirname = " << Q2Wdirname << endl;
    TString hname = TString::Format("%s/hAsym/Varset1/hAsym_ACC_CORR_phi",Q2Wdirname.Data());
    cout << "hname = " << hname << endl;
    TH1D* h = (TH1D*)fy->Get(hname);
    if (h==NULL) cout << "histogram not found" << endl;
    //h->Draw();
    hs->Add(h,"e1");
  }
  TCanvas *c = new TCanvas(hs->GetName(),hs->GetTitle());
  hs->Draw("pads");

}
示例#20
0
void cutFlowStudyMu( Double_t hltEff_=0.94, Int_t applyHLTData_ = 1, Int_t applyHLTMC_ = 1 , Float_t hMass_ = 115) 
{
  
  
  ofstream out(Form("cutFlow_MuTauStream_iter3_%.0f.txt",hMass_)); 
  out.precision(4);

  TCut hltData("((HLTmu==1 && run<=163261) || (HLTx==1 && run>163261))");
  TCut hltMC("HLTx==1");
 
  TFile *fFullData                = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011_iter3/treeMuTauStream_Run2011-Mu.root","READ"); 
  TFile *fFullSignalVBF           = new TFile(Form("/data_CMS/cms/lbianchini//MuTauStream2011_iter3/treeMuTauStream_VBFH%.0f-Mu-powheg-PUS1.root",hMass_),"READ"); 

  float equivalentGGMass = 115;
  float scaleGGH = 1.0;
    if(hMass_ == 125){
      equivalentGGMass = 120;
      scaleGGH = 0.821;
    }
  if(hMass_ == 135){
    equivalentGGMass = 130;
    scaleGGH = 0.757;
  }

  TFile *fFullSignalGGH           = new TFile(Form("/data_CMS/cms/lbianchini//MuTauStream2011_iter3/treeMuTauStream_GGFH%.0f-Mu-powheg-PUS1.root",equivalentGGMass),"READ");  
  TFile *fFullBackgroundDYTauTau  = new TFile("/data_CMS/cms/lbianchini/MuTauStream2011_iter3/treeMuTauStream_DYJets-Mu-50-madgraph-PUS1.root","READ"); 
  TFile *fFullBackgroundDYMuMu    = new TFile("/data_CMS/cms/lbianchini/MuTauStream2011_iter3/treeMuTauStream_DYJets-Mu-50-madgraph-PUS1.root","READ"); 
  //TFile *fFullBackgroundWJets     = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011_iter3/treeMuTauStream_WJets-Mu-madgraph-PUS1.root","READ"); 
  TFile *fFullBackgroundEWK       = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011_iter3/treeMuTauStream_ElectroWeak.root","READ"); 
  TFile *fFullBackgroundQCD       = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011_iter3/treeMuTauStream_QCDmu-pythia-20-15-PUS1.root","READ"); 
  //TFile *fFullBackgroundTTbar     = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011_iter3/treeMuTauStream_TTJets-Mu-madgraph-PUS1.root","READ"); 
  //TFile *fFullBackgroundSingleTop = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011_iter3/treeMuTauStream_SingleTop-Mu.root","READ"); 
  //TFile *fFullBackgroundDiBoson   = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011_iter3/treeMuTauStream_DiBoson-Mu.root","READ"); 
  TFile *fFullBackgroundTop   = new TFile("/data_CMS/cms/lbianchini//MuTauStream2011_iter3/treeMuTauStream_Top.root","READ"); 

  // OpenNTuples
  TString fDataName                = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleRun2011-Mu_Open_MuTauStream.root";
  TString fSignalNameVBF           = Form("/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleVBFH%.0f-Mu-powheg-PUS1_Open_MuTauStream.root",hMass_);
  TString fSignalNameGGH           = Form("/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleGGFH%.0f-Mu-powheg-PUS1_Open_MuTauStream.root",equivalentGGMass);
  TString fBackgroundNameDYTauTau  = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleDYJets-Mu-50-madgraph-PUS1_Open_MuTauStream.root";
  TString fBackgroundNameDYMuMu    = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleDYJets-Mu-50-madgraph-PUS1_Open_MuTauStream.root";
  TString fBackgroundNameWJets     = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleWJets-Mu-madgraph-PUS1_Open_MuTauStream.root";
  TString fBackgroundNameEWK       = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleElectroWeak_Open_MuTauStream.root";
  TString fBackgroundNameQCD       = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleQCDmu-pythia-20-15-PUS1_Open_MuTauStream.root";
  TString fBackgroundNameTTbar     = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleTTJets-Mu-madgraph-PUS1_Open_MuTauStream.root";
  TString fBackgroundNameTop       = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleTop_Open_MuTauStream.root";
  TString fBackgroundNameSingleTop = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleSingleTop-Mu_Open_MuTauStream.root";
  TString fBackgroundNameDiBoson   = "/data_CMS/cms/lbianchini/VbfJetsStudy/OpenNtuples/MuTauStream2011_iter3/Inclusive/nTupleDiBoson-Mu_Open_MuTauStream.root";

  TFile *fData(0); 
  TFile *fSignalVBF(0); 
  TFile *fSignalGGH(0); 
  TFile *fBackgroundDYTauTau(0);
  TFile *fBackgroundDYMuMu(0);
  TFile *fBackgroundWJets(0);
  TFile *fBackgroundEWK(0);
  TFile *fBackgroundQCD(0);
  TFile *fBackgroundTTbar(0);
  TFile *fBackgroundTop(0);
  TFile *fBackgroundSingleTop(0);
  TFile *fBackgroundDiBoson(0);
 
  fData               = TFile::Open( fDataName ); 
  fSignalVBF          = TFile::Open( fSignalNameVBF ); 
  fSignalGGH          = TFile::Open( fSignalNameGGH ); 
  fBackgroundDYTauTau = TFile::Open( fBackgroundNameDYTauTau ); 
  fBackgroundDYMuMu   = TFile::Open( fBackgroundNameDYMuMu ); 
  //fBackgroundWJets    = TFile::Open( fBackgroundNameWJets ); 
  fBackgroundEWK      = TFile::Open( fBackgroundNameEWK ); 
  fBackgroundQCD      = TFile::Open( fBackgroundNameQCD ); 
  //fBackgroundTTbar    = TFile::Open( fBackgroundNameTTbar ); 
  fBackgroundTop      = TFile::Open( fBackgroundNameTop ); 
  //fBackgroundSingleTop= TFile::Open( fBackgroundNameSingleTop ); 
  //fBackgroundDiBoson  = TFile::Open( fBackgroundNameDiBoson ); 

  if(!fSignalVBF || !fBackgroundDYTauTau || /*!fBackgroundWJets ||*/ !fBackgroundQCD  /* || !fBackgroundTTbar || !fBackgroundSingleTop*/ ||
     !fSignalGGH || !fBackgroundDYMuMu || /*!fBackgroundDiBoson ||*/ !fBackgroundTop || !fBackgroundEWK || !fData){
    std::cout << "ERROR: could not open files" << std::endl;
    exit(1);
  }

  TString tree = "outTreePtOrd";

  TTree *data                = (TTree*)fData->Get(tree);
  TTree *signalVBF           = (TTree*)fSignalVBF->Get(tree);
  TTree *signalGGH           = (TTree*)fSignalGGH->Get(tree);

  TFile* dummy1 = new TFile("dummy1.root","RECREATE");
  TTree *backgroundDYTauTau  = ((TTree*)fBackgroundDYTauTau->Get(tree))->CopyTree("isTauLegMatched>0.5");
  TTree *backgroundDYMuMu    = ((TTree*)fBackgroundDYMuMu->Get(tree))->CopyTree("isTauLegMatched<0.5");
  cout <<backgroundDYTauTau->GetEntries() << " -- " << backgroundDYMuMu->GetEntries() << endl;

  //TTree *backgroundWJets     = (TTree*)fBackgroundWJets->Get(tree);
  TTree *backgroundEWK       = (TTree*)fBackgroundEWK->Get(tree);
  TTree *backgroundQCD       = (TTree*)fBackgroundQCD->Get(tree);
  //TTree *backgroundTTbar     = (TTree*)fBackgroundTTbar->Get(tree);
  TTree *backgroundTop       = (TTree*)fBackgroundTop->Get(tree);
  //TTree *backgroundSingleTop = (TTree*)fBackgroundSingleTop->Get(tree);
  //TTree *backgroundDiBoson   = (TTree*)fBackgroundDiBoson->Get(tree);

  // here I define the map between a sample name and its tree
  std::map<std::string,TTree*> tMap;
  tMap["Data"]=data;
  tMap["ggH115"]=signalGGH;
  tMap["qqH115"]=signalVBF;
  tMap["Ztautau"]=backgroundDYTauTau;
  tMap["ZfakeTau"]=backgroundDYMuMu;
  //tMap["Wjets"]=backgroundWJets;
  tMap["EWK"]=backgroundEWK;
  tMap["QCD"]=backgroundQCD;
  //tMap["TTbar"]=backgroundTTbar;
  tMap["Top"]=backgroundTop;
  //tMap["SingleTop"]=backgroundSingleTop;
  //tMap["DiBoson"]=backgroundDiBoson;

  std::map<std::string,TTree*>::iterator jt;

  
  // here I choose the order in the stack
  std::vector<string> samples;
  samples.push_back("ggH115");
  samples.push_back("qqH115");
  //samples.push_back("DiBoson");
  samples.push_back("Top");
  //samples.push_back("SingleTop");
  //samples.push_back("TTbar");
  //samples.push_back("Wjets");
  samples.push_back("EWK");
  samples.push_back("QCD");
  samples.push_back("ZfakeTau");
  samples.push_back("Ztautau");
  samples.push_back("Data");

  float kFactorQCD=1.0;
  std::map<std::string,float> crossSec;
  crossSec["ggH115"]=( 7.65e-02 * 18.13 * scaleGGH);
  crossSec["qqH115"]=( 0.1012);
  //crossSec["DiBoson"]=( -1  );
  //crossSec["TTbar"]=( 157.5 );
  //crossSec["SingleTop"]=( -1 );
  //crossSec["Wjets"]=( 31314.0);
  crossSec["EWK"]= (-1);
  crossSec["Top"]= (-1);
  crossSec["ZfakeTau"]=( 3048  );
  crossSec["Ztautau"]=( 3048  );
  crossSec["QCD"]=( 296600000*0.0002855 * kFactorQCD); //K-factor from fit in signal region 1.7
  crossSec["Data"]=( 0 );

  float Lumi = 191.;

  // here I choose the order in the stack
  std::vector<string> filters;
  filters.push_back("total");
  filters.push_back("vertex");
  filters.push_back("at least 1 mu-tau");
  filters.push_back("mu pt-eta");
  filters.push_back("mu-ID");
  filters.push_back("tau pt-eta");
  filters.push_back("tau-ID");
  filters.push_back("tau against-mu");
  filters.push_back("tau against-e");
  filters.push_back("tau-iso");
  filters.push_back("mu-iso");
  filters.push_back("di-mu veto");
  filters.push_back("Mt");
  filters.push_back("OS");
  filters.push_back("2-jets");
  filters.push_back("2-tag jets");
  filters.push_back("VBF cuts");
  filters.push_back("jet-veto");
  filters.push_back("Mass Window");
  //filters.push_back("Mass Window");
  //filters.push_back("HLT-matching");

  // here I define the map between a sample name and its file ptr
  std::map<std::string,TFile*> fullMap;
  fullMap["Data"]     = fFullData;
  fullMap["ggH115"]   = fFullSignalGGH;
  fullMap["qqH115"]   = fFullSignalVBF;
  fullMap["Ztautau"]  = fFullBackgroundDYTauTau;
  fullMap["ZfakeTau"] = fFullBackgroundDYMuMu;
  //fullMap["Wjets"]    = fFullBackgroundWJets;
  fullMap["EWK"]    = fFullBackgroundEWK;
  fullMap["QCD"]      = fFullBackgroundQCD;
  //fullMap["TTbar"]    = fFullBackgroundTTbar;
  fullMap["Top"]    = fFullBackgroundTop;
  //fullMap["SingleTop"]= fFullBackgroundSingleTop;
  //fullMap["DiBoson"]  = fFullBackgroundDiBoson;

  std::map<std::string,TFile*>::iterator it;

  std::map<std::string,float> cutMap_allEventsFilter;
  std::map<std::string,float> cutMap_allEventsFilterE;

  std::map<std::string,float> cutMap_vertexScrapingFilter;
  std::map<std::string,float> cutMap_vertexScrapingFilterE;

  std::map<std::string,float> cutMap_atLeastOneMuTauFilter;
  std::map<std::string,float> cutMap_atLeastOneMuTauFilterE;

  std::map<std::string,float> cutMap_muPtEtaFilter;
  std::map<std::string,float> cutMap_muPtEtaFilterE;

  std::map<std::string,float> cutMap_muPtEtaIDFilter;
  std::map<std::string,float> cutMap_muPtEtaIDFilterE;

  std::map<std::string,float> cutMap_tauPtEtaFilter;
  std::map<std::string,float> cutMap_tauPtEtaFilterE;

  std::map<std::string,float> cutMap_tauPtEtaIDFilter;
  std::map<std::string,float> cutMap_tauPtEtaIDFilterE;

  std::map<std::string,float> cutMap_tauPtEtaIDAgMuFilter;
  std::map<std::string,float> cutMap_tauPtEtaIDAgMuFilterE;

  std::map<std::string,float> cutMap_tauPtEtaIDAgMuAgElecFilter;
  std::map<std::string,float> cutMap_tauPtEtaIDAgMuAgElecFilterE;

  std::map<std::string,float> cutMap_TauIso;
  std::map<std::string,float> cutMap_TauIsoE;

  std::map<std::string,float> cutMap_MuIso;
  std::map<std::string,float> cutMap_MuIsoE;

  std::map<std::string,float> cutMap_DiMuVeto;
  std::map<std::string,float> cutMap_DiMuVetoE;

  std::map<std::string,float> cutMap_Mt;
  std::map<std::string,float> cutMap_MtE;

  std::map<std::string,float> cutMap_OS;
  std::map<std::string,float> cutMap_OSE;

  std::map<std::string,float> cutMap_2jets;
  std::map<std::string,float> cutMap_2jetsE;

  std::map<std::string,float> cutMap_VBFPre;
  std::map<std::string,float> cutMap_VBFPreE;

  std::map<std::string,float> cutMap_VBF;
  std::map<std::string,float> cutMap_VBFE;

  std::map<std::string,float> cutMap_JetVeto;
  std::map<std::string,float> cutMap_JetVetoE;

  std::map<std::string,float> cutMap_antiBtag;
  std::map<std::string,float> cutMap_antiBtagE;

  std::map<std::string,float> cutMap_MassWindow;
  std::map<std::string,float> cutMap_MassWindowE;

  std::map<std::string,float> cutMap_HLT;
  std::map<std::string,float> cutMap_HLTE;

  std::vector< std::map<std::string,float> > allFilters;
  allFilters.push_back(cutMap_allEventsFilter);
  allFilters.push_back(cutMap_vertexScrapingFilter);
  allFilters.push_back(cutMap_atLeastOneMuTauFilter);
  allFilters.push_back(cutMap_muPtEtaFilter);
  allFilters.push_back(cutMap_muPtEtaIDFilter);
  allFilters.push_back(cutMap_tauPtEtaFilter);
  allFilters.push_back(cutMap_tauPtEtaIDFilter);
  allFilters.push_back(cutMap_tauPtEtaIDAgMuFilter);
  allFilters.push_back(cutMap_tauPtEtaIDAgMuAgElecFilter);
 

  std::vector< std::map<std::string,float> > allFiltersE;
  allFiltersE.push_back(cutMap_allEventsFilterE);
  allFiltersE.push_back(cutMap_vertexScrapingFilterE);
  allFiltersE.push_back(cutMap_atLeastOneMuTauFilterE);
  allFiltersE.push_back(cutMap_muPtEtaFilterE);
  allFiltersE.push_back(cutMap_muPtEtaIDFilterE);
  allFiltersE.push_back(cutMap_tauPtEtaFilterE);
  allFiltersE.push_back(cutMap_tauPtEtaIDFilterE);
  allFiltersE.push_back(cutMap_tauPtEtaIDAgMuFilterE);
  allFiltersE.push_back(cutMap_tauPtEtaIDAgMuAgElecFilterE);
 
  std::vector< std::map<std::string,float> > offlineFilters;
  offlineFilters.push_back(cutMap_TauIso);
  offlineFilters.push_back(cutMap_MuIso);
  offlineFilters.push_back(cutMap_DiMuVeto);
  offlineFilters.push_back(cutMap_Mt);
  offlineFilters.push_back(cutMap_OS);
  offlineFilters.push_back(cutMap_2jets);
  offlineFilters.push_back(cutMap_VBFPre);
  offlineFilters.push_back(cutMap_VBF);
  offlineFilters.push_back(cutMap_JetVeto);
  offlineFilters.push_back(cutMap_MassWindow);
  //offlineFilters.push_back(cutMap_HLT);

  std::vector< std::map<std::string,float> > offlineFiltersE;
  offlineFiltersE.push_back(cutMap_TauIsoE);
  offlineFiltersE.push_back(cutMap_MuIsoE);
  offlineFiltersE.push_back(cutMap_DiMuVetoE);
  offlineFiltersE.push_back(cutMap_MtE);
  offlineFiltersE.push_back(cutMap_OSE);
  offlineFiltersE.push_back(cutMap_2jetsE);
  offlineFiltersE.push_back(cutMap_VBFPreE);
  offlineFiltersE.push_back(cutMap_VBFE);
  offlineFiltersE.push_back(cutMap_JetVetoE);
  offlineFiltersE.push_back(cutMap_MassWindowE);
  //offlineFiltersE.push_back(cutMap_HLTE);

  std::vector< string > offlineCuts;
  offlineCuts.push_back("combIsoLeg2<2");
  offlineCuts.push_back("combRelIsoLeg1DBeta<0.10");
  offlineCuts.push_back("muFlag==0");
  offlineCuts.push_back("(pZeta-1.5*pZetaVis>-20)");
  offlineCuts.push_back("diTauCharge==0");
  offlineCuts.push_back("pt1>30 && pt2>30");
  offlineCuts.push_back("eta1*eta2<0");
  offlineCuts.push_back("Deta>3.5 && Mjj>350");
  offlineCuts.push_back("ptVeto<30");
  offlineCuts.push_back("diTauSVFitMass>85 && diTauSVFitMass<145");

  std::vector< string > filtersByName;
  filtersByName.push_back("allEventsFilter");
  filtersByName.push_back("vertexScrapingFilter");
  filtersByName.push_back("atLeastOneMuTauFilter");
  filtersByName.push_back("muPtEtaFilter");
  filtersByName.push_back("muPtEtaIDFilter");
  filtersByName.push_back("tauPtEtaFilter");
  filtersByName.push_back("tauPtEtaIDFilter");
  filtersByName.push_back("tauPtEtaIDAgMuFilter");
  filtersByName.push_back("tauPtEtaIDAgMuAgElecFilter");
  
  for(unsigned int k = 0 ; k <filtersByName.size() ; k++){

    for(it = fullMap.begin(); it != fullMap.end(); it++){
      TH1F* allEvents = (TH1F*)(it->second)->Get("allEventsFilter/totalEvents");
      float totalEvents = allEvents->GetBinContent(1);
      allEvents = (TH1F*)(it->second)->Get( (filtersByName[k]+"/totalEvents").c_str() );
      float tot =  allEvents->GetBinContent(1);
      float totalEquivalentEvents = allEvents->GetEffectiveEntries();
      if(crossSec[it->first]>0){
	tot *= (Lumi/ (totalEvents/crossSec[it->first]) * hltEff_  ) ;
      } else if (crossSec[it->first]<0) tot *= Lumi/1000*hltEff_;
      (allFilters[k])[it->first]  = tot;
      (allFiltersE[k])[it->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0;
    }
  }

  for(unsigned int k =0; k < offlineFilters.size(); k++){
    
    for(jt = tMap.begin(); jt != tMap.end(); jt++){
      cout<<jt->first<<endl;
      TH1F* h1 = new TH1F("h1","",1,-10,10);
      string tmp_cut = "tightestHPSWP>-1";
      for(unsigned v = 0; v <=k ; v++){
        tmp_cut = tmp_cut + " && "+offlineCuts[v];
      }
      if((jt->first).find("Data")!=string::npos && applyHLTData_) tmp_cut = tmp_cut+" && ((HLTmu==1 && run<=163261) || (HLTx==1 && run\
>163261))";
      if((jt->first).find("Data")==string::npos && applyHLTMC_)   tmp_cut = tmp_cut+" && HLTmu==1";
      tmp_cut = "sampleWeight*puWeight*("+tmp_cut+")";
      cout << tmp_cut << endl;
      TCut cut(tmp_cut.c_str());

      jt->second->Draw("etaL1>>h1",cut);
      if((jt->first).find("Data")==string::npos) h1->Scale(Lumi/1000*hltEff_);
      if((jt->first).find("QCD")!=string::npos) h1->Scale(kFactorQCD);
      float tot = h1->Integral();
      cout << tot << endl;
      float totalEquivalentEvents = h1->GetEffectiveEntries();
      (offlineFilters[k])[jt->first] = tot;
      (offlineFiltersE[k])[jt->first] = totalEquivalentEvents>0 ? sqrt(totalEquivalentEvents)*(tot/totalEquivalentEvents) : 0;
      delete h1;
    }

  }

  for(unsigned k = 0; k<offlineFilters.size() ; k++) allFilters.push_back(offlineFilters[k]);
  for(unsigned k = 0; k<offlineFilters.size() ; k++) allFiltersE.push_back(offlineFiltersE[k]);


  std::vector<std::pair<float,float> > SMsums;

  for(unsigned int i = 0; i < allFilters.size(); i++){
    float SM=0,SME2=0;
    int helper = 0;
    for(int k = 0 ; k < samples.size()-1; k++){
      if( !(samples[k].find("Z")!=string::npos && i<9 && helper!=0) ) 
	SM+=(allFilters[i].find(samples[k]))->second;
      if( !(samples[k].find("Z")!=string::npos && i<9 && helper!=0) ) 
	SME2+=(allFiltersE[i].find(samples[k]))->second*(allFiltersE[i].find(samples[k]))->second;
      if( samples[k].find("Z")!=string::npos ) helper++;
    }
    SMsums.push_back( make_pair(SM,SME2 ));
  }


  //out<<"\\begin{center}"<<endl;
  out<<"\\begin{tabular}[!htbp]{|c";
  for(int k = 0 ; k < samples.size(); k++) out<<"|c";
  out<<"|c|} \\hline"<<endl;
  out<< "Cut & ";
  for(int k = 0 ; k < samples.size(); k++){
    out << (fullMap.find(samples[k]))->first;
    if(k!=samples.size()-1) out <<" & " ;
    else out << " & $\\Sigma$ SM \\\\ " << endl;
  }
  out <<  " \\hline" << endl;

  
  for(int i = 0; i < allFilters.size(); i++){
    out << filters[i] << " & ";
    for(int k = 0 ; k < samples.size(); k++){
      if(samples[k].find("Data")==string::npos) 
	out << (allFilters[i].find(samples[k]))->second << " $\\pm$ " << (allFiltersE[i].find(samples[k]))->second;
      else
	out << (allFilters[i].find(samples[k]))->second;
      if(k!=samples.size()-1) out <<" & " ;
      else out << " & " << SMsums[i].first << "$\\pm$" <<  sqrt(SMsums[i].second) << " \\\\ " << endl;
    }
    out <<  " \\hline" << endl;

  }
  
  out<<"\\end{tabular}"<<endl;
  //out<<"\\end{center}"<<endl;

  ///////////////////////////////////////////////////////////////////////////////////////////////
  TCanvas *c1 = new TCanvas("c1CutFlowMass","",5,30,650,600);
  c1->SetGrid(0,0);
  c1->SetFillStyle(4000);
  c1->SetFillColor(10);
  c1->SetTicky();
  c1->SetObjectStat(0);
  c1->SetLogy(1);
 
  TLegend* leg = new TLegend(0.55,0.55,0.80,0.88,NULL,"brNDC");
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(0.04);
  leg->SetHeader( "#mu+#tau" );

  THStack* aStack = new THStack("aStack",Form("CMS Preliminary 2011    #sqrt{s}=7 TeV L=%.0f pb^{-1}",Lumi));

  std::vector<TH1F*> histos;
  for(unsigned int k = 0 ; k < samples.size(); k++){
    TH1F* h1 = new TH1F( ("h1_"+samples[k]).c_str(), Form("CMS Preliminary 2011    #sqrt{s}=7 TeV L=%.0f pb^{-1} ; ; Events",Lumi) , filters.size(), 0, filters.size());

    if( (samples[k]).find("ZfakeTau")!=string::npos ) {
      h1->SetFillColor(7);
      leg->AddEntry(h1,"Z+jets, fake-#tau","F");
    }
    if( (samples[k]).find("Ztautau")!=string::npos ) {
      h1->SetFillColor(kRed);
      leg->AddEntry(h1,"Z+jets, genuine #tau","F");
    }
    if( (samples[k]).find("TTbar")!=string::npos ) {
      h1->SetFillColor(kBlue);
      leg->AddEntry(h1,"t#bar{t}+jets","F");
    }
    if( (samples[k]).find("SingleTop")!=string::npos ) {
      h1->SetFillColor(kMagenta);
      leg->AddEntry(h1,"single-t","F");
    }
    if( (samples[k]).find("Top")!=string::npos ) {
      h1->SetFillColor(kMagenta);
      leg->AddEntry(h1,"Top","F");
    }
    if( (samples[k]).find("Wjets")!=string::npos ) {
      h1->SetFillColor(kGreen);
      leg->AddEntry(h1,"W+jets","F");
    }
    if( (samples[k]).find("EWK")!=string::npos ) {
      h1->SetFillColor(kGreen);
      leg->AddEntry(h1,"W+Others","F");
    }
    if( (samples[k]).find("DiBoson")!=string::npos ) {
      h1->SetFillColor(38);
      leg->AddEntry(h1,"Di-Boson","F");
    }
    if( (samples[k]).find("QCD")!=string::npos ) {
      h1->SetFillColor(42);
      leg->AddEntry(h1,"QCD-multijets","F");
    }
    if((samples[k]).find("qqH115")!=string::npos){
      h1->SetLineWidth(2);
      h1->SetLineColor(kBlack);
      h1->SetFillColor(kBlack);     
      h1->SetFillStyle(3004);
      leg->AddEntry(h1,"qqH(115)","F");
    }
    if((samples[k]).find("ggH115")!=string::npos){
      h1->SetLineWidth(2);
      h1->SetLineColor(kBlack);  
      h1->SetFillColor(kBlack);     
      h1->SetFillStyle(3005);
      leg->AddEntry(h1,"ggH(115)","F");
    }
    

    //h1->SetLineWidth(1.4);
    for(int v = 0; v < filters.size(); v++){
      h1->GetXaxis()->SetBinLabel(v+1,filters[v].c_str());
      h1->SetBinContent(v+1, (allFilters[v].find(samples[k]))->second );
    }
    if(samples[k].find("Data")!=string::npos){
      h1->Sumw2();
      h1->SetMarkerStyle(20);
      h1->SetMarkerSize(1.2);
      h1->SetMarkerColor(kBlack);
      h1->SetLineColor(kBlack);
      leg->AddEntry(h1,"DATA","P");
    }
    //else leg->AddEntry(h1,samples[k].c_str(),"L");
    histos.push_back(h1);
  }

  for(unsigned int k = 0 ; k < histos.size(); k++){
    string histoName =  std::string( histos[k]->GetName() );
    if( histoName.find("Data")== string::npos) aStack->Add(histos[k]);
  }
  aStack->Draw("HIST");
  TH1F* hStack = (TH1F*)aStack->GetHistogram();
  aStack->GetYaxis()->SetRangeUser(0.01,10000000);

  for(unsigned int k = 0 ; k < histos.size(); k++){
    string histoName =  std::string( histos[k]->GetName() );
    if( histoName.find("Data")!= string::npos){
      histos[k]->Sumw2();
      histos[k]->Draw("PSAME");
    }
  }

  leg->Draw();

  return;

}
示例#21
0
文件: Extract.C 项目: ktf/AliPhysics
/** 
 * Extract ALICE PbPb @ 5.02TeV over |eta|<2
 * 
 * @param filename  Input file name 
 * @param outname   Output file name 
 * @param reweigh   Whether it is reweighed 
 */
void
Extract(const char* filename="dndneta.pbpb502.20151124.root",
	const char* outname="TRACKLETS_5023_PbPb.input",
	Bool_t      reweigh=false)
{
  if (filename == 0) return;
  TFile* file = TFile::Open(filename, "READ");
  TObjArray* arr = static_cast<TObjArray*>(file->Get("TObjArray"));
  // Now count number of bins
  Int_t nBins = 0;
  TIter next(arr);
  TObject* obj = 0;
  while ((obj = next())) {
    if (TString(obj->GetName()).Contains("DataCorrSignal")) 
      nBins++;
  }
  Info("ExtractdNdeta", "Defining %d centrality bins", nBins);
  TArrayD c(nBins+1);
  if (nBins == 5) {
    c[0] = 0; c[1] = 10; c[2] = 20; c[3] = 40; c[4] = 60; c[5] = 80;
  }
  else if (nBins >= 9) {
    c[0] =  0; c[1] =  5; c[2] = 10; c[3] = 20; c[4] = 30; c[5] = 40;
    c[6] = 50; c[7] = 60; c[8] = 70; c[9] = 80;
    if (nBins >= 10) c[10] =  90;
    if (nBins >= 11) c[11] = 100;
  }
  
  THStack* all = new THStack("all","all");
  std::ofstream out(outname);
  std::ostream& o = out; // std::cout;
  // std::ostream& o = std::cout;
  
  o << "*author: SHAHOYAN : 2015\n"
    << "*title: Full centrality dependence of the charged "
    << "particle pseudo-rapidity density over the widest "
    << "possible pseudo-rapidity range in Pb-Pb collisions "
    << "at 5.02 TeV\n"
    << "*detector: TRACKLETS\n"
    << "*experiment: CERN-LHC-TRACKLETS\n"
    << "*comment: CERN-LHC: We present the charged particle pseudo-rapidity "
    << "density of charged particles in Pb-Pb collisions at sqrt(s)/nucleon "
    "= 5.02 over the widest possible pseudo-rapidity and centrality range "
    << "possible.\n"  << std::endl;
  
  for (Int_t i = 0; i < nBins; i++) {
    TString hName = Form("bin%d_DataCorrSignal_PbPb",i);
    TH1* h = static_cast<TH1*>(arr->FindObject(hName));
    if (!h) {
      hName.ReplaceAll("PbPb", "PBPB");
      h = static_cast<TH1*>(arr->FindObject(hName));
      if (!h) {
	Warning("", "Histogram (%s) missing for bin %d", hName.Data(), i);
	arr->Print();
	continue;
      }
    }
    
    Color_t      col = PbPbColor(c[i], c[i+1]);
    h->SetLineColor(col);
    h->SetMarkerColor(col);
    h->SetFillColor(col);
    all->Add(h);
    Info("","Making GSE for %0d%% to %3d%% (%d)",
	 Int_t(c[i]), Int_t(c[i+1]), col);
    
    MakeGSE(o, h, c[i], c[i+1], reweigh);
  }
  // all->Draw("nostack");
  o << "*E" << std::endl;
  out.close();

  TCanvas*        can = new TCanvas("c","C", 1600, 800);
  can->SetRightMargin(0.2);
  can->SetTopMargin(0.01);

  TLegend*        cl = new TLegend(1-can->GetRightMargin(),
				   can->GetBottomMargin(),.99,
				   1-can->GetTopMargin());
  cl->SetFillStyle(0);
  cl->SetBorderSize(0);
  
  gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+");
  TList* ll = GraphSysErr::Import(outname);
  // ll->ls();

  TIter next(ll);
  TObject* obj = 0;
  Bool_t first = true;
  TH1* frame = 0;
  Double_t min=100000, max=0;
  Int_t i = 0;
  while ((obj = next())) {
    if (c[i+1] > 80) break;
    GraphSysErr* g = static_cast<GraphSysErr*>(obj);
    Color_t      col = PbPbColor(c[i], c[i+1]);
    TLegendEntry* e =  cl->AddEntry("", Form("%4.1f-%4.1f%%", c[i], c[i+1]),
				    "F");
    e->SetFillColor(col);
    e->SetFillStyle(1001);
    g->SetLineColor(col);
    g->SetMarkerColor(col);
    g->SetFillColor(col);
    // g->Print("qual");
    g->SetDataOption(GraphSysErr::kNoTick);
    g->SetSumOption(GraphSysErr::kBox);
    g->SetSumLineColor(col);
    g->SetSumFillColor(col);
    g->SetCommonSumOption(GraphSysErr::kBox);
    g->SetCommonSumLineColor(col);
    g->SetCommonSumFillColor(col);
    g->SetName(Form("tracklets%03dd%02d_%03dd%02d",
		    Int_t(c[i]),   Int_t(c[i]*100) % 100,
		    Int_t(c[i+1]), Int_t(c[i+1]*100) % 100));
    g->SetTitle(Form("%4.1f - %4.1f%%", c[i], c[i+1]));
    if (first) g->Draw("combine stat quad axis xbase=2.5");
    else       g->Draw("combine stat quad xbase=2.5");
    if (!frame)
      frame = g->GetMulti()->GetHistogram();
    first = false;
    Double_t mn, mx;
    g->GetMinMax("combine stat quad", mn, mx);
    FindLeastLargest(g, c[i], c[i+1]);
    min = TMath::Min(min, mn);
    max = TMath::Max(max, mx);
    i++;
  }
  frame->SetMinimum(min*.9);
  frame->SetMaximum(max*1.1);
  cl->Draw();

  TFile* outFile = TFile::Open(Form("PbPb5023midRapidity%s.root",
				    reweigh ? "Reweighed" : "Normal"),
			       "RECREATE");
  ll->Write("container",TObject::kSingleKey);
  outFile->Write();
  
  can->SaveAs(Form("PbPb5023midRapidity%s.png",
		   reweigh ? "Reweighed" : "Normal"));
}
示例#22
0
void ttbar_isojet1CSV()
{
//=========Macro generated from canvas: c1/c1
//=========  (Sun Dec 11 15:16:19 2016) by ROOT version6.06/01
   TCanvas *c1 = new TCanvas("c1", "c1",1,1,1200,1416);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   c1->SetHighLightColor(2);
   c1->Range(0,0,1,1);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.15);
   c1->SetRightMargin(0.05);
   c1->SetTopMargin(0.07);
   c1->SetBottomMargin(0.13);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: pad1
   TPad *pad1 = new TPad("pad1", "pad1",0,0.3,1,1);
   pad1->Draw();
   pad1->cd();
   pad1->Range(-0.1875,0,1.0625,0.6289089);
   pad1->SetFillColor(0);
   pad1->SetBorderMode(0);
   pad1->SetBorderSize(2);
   pad1->SetTickx(1);
   pad1->SetTicky(1);
   pad1->SetLeftMargin(0.15);
   pad1->SetRightMargin(0.05);
   pad1->SetTopMargin(0.07);
   pad1->SetBottomMargin(0);
   pad1->SetFrameFillStyle(0);
   pad1->SetFrameBorderMode(0);
   pad1->SetFrameFillStyle(0);
   pad1->SetFrameBorderMode(0);
   
   THStack *h = new THStack();
   h->SetName("h");
   h->SetTitle("");
   h->SetMinimum(0);
   h->SetMaximum(0.5570336);
   
   TH1F *h_stack_23 = new TH1F("h_stack_23","",10,0,1);
   h_stack_23->SetMinimum(0);
   h_stack_23->SetMaximum(0.5848853);
   h_stack_23->SetDirectory(0);
   h_stack_23->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   h_stack_23->SetLineColor(ci);
   h_stack_23->GetXaxis()->SetLabelFont(42);
   h_stack_23->GetXaxis()->SetLabelOffset(0.007);
   h_stack_23->GetXaxis()->SetTitleSize(0.05);
   h_stack_23->GetXaxis()->SetTickLength(0.025);
   h_stack_23->GetXaxis()->SetTitleFont(42);
   h_stack_23->GetYaxis()->SetTitle("a.u.");
   h_stack_23->GetYaxis()->SetLabelFont(42);
   h_stack_23->GetYaxis()->SetLabelOffset(0.007);
   h_stack_23->GetYaxis()->SetTitleSize(0.05);
   h_stack_23->GetYaxis()->SetTickLength(0.025);
   h_stack_23->GetYaxis()->SetTitleOffset(1.5);
   h_stack_23->GetYaxis()->SetTitleFont(42);
   h_stack_23->GetZaxis()->SetLabelFont(42);
   h_stack_23->GetZaxis()->SetLabelOffset(0.007);
   h_stack_23->GetZaxis()->SetTitleSize(0.05);
   h_stack_23->GetZaxis()->SetTickLength(0.025);
   h_stack_23->GetZaxis()->SetTitleFont(42);
   h->SetHistogram(h_stack_23);
   
   
   TH1D *h_isojet1CSV_QCD__265 = new TH1D("h_isojet1CSV_QCD__265","",10,0,1);
   h_isojet1CSV_QCD__265->SetBinContent(1,0.002129117);
   h_isojet1CSV_QCD__265->SetBinContent(2,0.001248327);
   h_isojet1CSV_QCD__265->SetBinContent(3,0.0006205357);
   h_isojet1CSV_QCD__265->SetBinContent(4,0.001430306);
   h_isojet1CSV_QCD__265->SetBinContent(5,0.001031553);
   h_isojet1CSV_QCD__265->SetBinContent(6,0.0005098467);
   h_isojet1CSV_QCD__265->SetBinContent(7,0.0002095089);
   h_isojet1CSV_QCD__265->SetBinContent(8,9.216642e-05);
   h_isojet1CSV_QCD__265->SetBinContent(10,0.004314199);
   h_isojet1CSV_QCD__265->SetBinError(1,0.001510477);
   h_isojet1CSV_QCD__265->SetBinError(2,0.0006911766);
   h_isojet1CSV_QCD__265->SetBinError(3,0.0004578373);
   h_isojet1CSV_QCD__265->SetBinError(4,0.0008388365);
   h_isojet1CSV_QCD__265->SetBinError(5,0.0008715622);
   h_isojet1CSV_QCD__265->SetBinError(6,0.0005098467);
   h_isojet1CSV_QCD__265->SetBinError(7,0.0002095089);
   h_isojet1CSV_QCD__265->SetBinError(8,9.216642e-05);
   h_isojet1CSV_QCD__265->SetBinError(10,0.002213733);
   h_isojet1CSV_QCD__265->SetEntries(25);
   h_isojet1CSV_QCD__265->SetStats(0);

   ci = TColor::GetColor("#cccccc");
   h_isojet1CSV_QCD__265->SetFillColor(ci);
   h_isojet1CSV_QCD__265->GetXaxis()->SetTitle("isojet 1 CSV");
   h_isojet1CSV_QCD__265->GetXaxis()->SetLabelFont(42);
   h_isojet1CSV_QCD__265->GetXaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_QCD__265->GetXaxis()->SetTitleSize(0.05);
   h_isojet1CSV_QCD__265->GetXaxis()->SetTickLength(0.025);
   h_isojet1CSV_QCD__265->GetXaxis()->SetTitleFont(42);
   h_isojet1CSV_QCD__265->GetYaxis()->SetTitle("a.u.");
   h_isojet1CSV_QCD__265->GetYaxis()->SetLabelFont(42);
   h_isojet1CSV_QCD__265->GetYaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_QCD__265->GetYaxis()->SetTitleSize(0.05);
   h_isojet1CSV_QCD__265->GetYaxis()->SetTickLength(0.025);
   h_isojet1CSV_QCD__265->GetYaxis()->SetTitleFont(42);
   h_isojet1CSV_QCD__265->GetZaxis()->SetLabelFont(42);
   h_isojet1CSV_QCD__265->GetZaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_QCD__265->GetZaxis()->SetTitleSize(0.05);
   h_isojet1CSV_QCD__265->GetZaxis()->SetTickLength(0.025);
   h_isojet1CSV_QCD__265->GetZaxis()->SetTitleFont(42);
   h->Add(h_isojet1CSV_QCD,"");
   
   TH1D *h_isojet1CSV_Diboson__266 = new TH1D("h_isojet1CSV_Diboson__266","",10,0,1);
   h_isojet1CSV_Diboson__266->SetBinContent(1,0.006910874);
   h_isojet1CSV_Diboson__266->SetBinContent(2,0.01156259);
   h_isojet1CSV_Diboson__266->SetBinContent(3,0.00597142);
   h_isojet1CSV_Diboson__266->SetBinContent(4,0.003397186);
   h_isojet1CSV_Diboson__266->SetBinContent(5,0.003453268);
   h_isojet1CSV_Diboson__266->SetBinContent(6,0.001659304);
   h_isojet1CSV_Diboson__266->SetBinContent(7,0.001617052);
   h_isojet1CSV_Diboson__266->SetBinContent(8,0.001259235);
   h_isojet1CSV_Diboson__266->SetBinContent(9,0.000286628);
   h_isojet1CSV_Diboson__266->SetBinContent(10,0.00067562);
   h_isojet1CSV_Diboson__266->SetBinError(1,0.001086007);
   h_isojet1CSV_Diboson__266->SetBinError(2,0.001467728);
   h_isojet1CSV_Diboson__266->SetBinError(3,0.001077108);
   h_isojet1CSV_Diboson__266->SetBinError(4,0.0008370875);
   h_isojet1CSV_Diboson__266->SetBinError(5,0.0009085276);
   h_isojet1CSV_Diboson__266->SetBinError(6,0.000631351);
   h_isojet1CSV_Diboson__266->SetBinError(7,0.0006254813);
   h_isojet1CSV_Diboson__266->SetBinError(8,0.0005614698);
   h_isojet1CSV_Diboson__266->SetBinError(9,0.0001726014);
   h_isojet1CSV_Diboson__266->SetBinError(10,0.0003333104);
   h_isojet1CSV_Diboson__266->SetEntries(227);
   h_isojet1CSV_Diboson__266->SetStats(0);

   ci = TColor::GetColor("#9966cc");
   h_isojet1CSV_Diboson__266->SetFillColor(ci);
   h_isojet1CSV_Diboson__266->GetXaxis()->SetTitle("isojet 1 CSV");
   h_isojet1CSV_Diboson__266->GetXaxis()->SetLabelFont(42);
   h_isojet1CSV_Diboson__266->GetXaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_Diboson__266->GetXaxis()->SetTitleSize(0.05);
   h_isojet1CSV_Diboson__266->GetXaxis()->SetTickLength(0.025);
   h_isojet1CSV_Diboson__266->GetXaxis()->SetTitleFont(42);
   h_isojet1CSV_Diboson__266->GetYaxis()->SetTitle("a.u.");
   h_isojet1CSV_Diboson__266->GetYaxis()->SetLabelFont(42);
   h_isojet1CSV_Diboson__266->GetYaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_Diboson__266->GetYaxis()->SetTitleSize(0.05);
   h_isojet1CSV_Diboson__266->GetYaxis()->SetTickLength(0.025);
   h_isojet1CSV_Diboson__266->GetYaxis()->SetTitleFont(42);
   h_isojet1CSV_Diboson__266->GetZaxis()->SetLabelFont(42);
   h_isojet1CSV_Diboson__266->GetZaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_Diboson__266->GetZaxis()->SetTitleSize(0.05);
   h_isojet1CSV_Diboson__266->GetZaxis()->SetTickLength(0.025);
   h_isojet1CSV_Diboson__266->GetZaxis()->SetTitleFont(42);
   h->Add(h_isojet1CSV_Diboson,"");
   
   TH1D *h_isojet1CSV_ZpLjets__267 = new TH1D("h_isojet1CSV_ZpLjets__267","",10,0,1);
   h_isojet1CSV_ZpLjets__267->SetBinContent(1,0.00997839);
   h_isojet1CSV_ZpLjets__267->SetBinContent(2,0.01450317);
   h_isojet1CSV_ZpLjets__267->SetBinContent(3,0.006432142);
   h_isojet1CSV_ZpLjets__267->SetBinContent(4,0.004194575);
   h_isojet1CSV_ZpLjets__267->SetBinContent(5,0.003727646);
   h_isojet1CSV_ZpLjets__267->SetBinContent(6,0.002569373);
   h_isojet1CSV_ZpLjets__267->SetBinContent(7,0.001898935);
   h_isojet1CSV_ZpLjets__267->SetBinContent(8,0.001314676);
   h_isojet1CSV_ZpLjets__267->SetBinContent(9,0.001323422);
   h_isojet1CSV_ZpLjets__267->SetBinContent(10,0.001471477);
   h_isojet1CSV_ZpLjets__267->SetBinError(1,0.0002843835);
   h_isojet1CSV_ZpLjets__267->SetBinError(2,0.0003526741);
   h_isojet1CSV_ZpLjets__267->SetBinError(3,0.0002379666);
   h_isojet1CSV_ZpLjets__267->SetBinError(4,0.0002075278);
   h_isojet1CSV_ZpLjets__267->SetBinError(5,0.0001971644);
   h_isojet1CSV_ZpLjets__267->SetBinError(6,0.0001564817);
   h_isojet1CSV_ZpLjets__267->SetBinError(7,0.0001321731);
   h_isojet1CSV_ZpLjets__267->SetBinError(8,0.0001133749);
   h_isojet1CSV_ZpLjets__267->SetBinError(9,0.0001162263);
   h_isojet1CSV_ZpLjets__267->SetBinError(10,0.0001379738);
   h_isojet1CSV_ZpLjets__267->SetEntries(24915);
   h_isojet1CSV_ZpLjets__267->SetStats(0);

   ci = TColor::GetColor("#3399cc");
   h_isojet1CSV_ZpLjets__267->SetFillColor(ci);
   h_isojet1CSV_ZpLjets__267->GetXaxis()->SetTitle("isojet 1 CSV");
   h_isojet1CSV_ZpLjets__267->GetXaxis()->SetLabelFont(42);
   h_isojet1CSV_ZpLjets__267->GetXaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_ZpLjets__267->GetXaxis()->SetTitleSize(0.05);
   h_isojet1CSV_ZpLjets__267->GetXaxis()->SetTickLength(0.025);
   h_isojet1CSV_ZpLjets__267->GetXaxis()->SetTitleFont(42);
   h_isojet1CSV_ZpLjets__267->GetYaxis()->SetTitle("a.u.");
   h_isojet1CSV_ZpLjets__267->GetYaxis()->SetLabelFont(42);
   h_isojet1CSV_ZpLjets__267->GetYaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_ZpLjets__267->GetYaxis()->SetTitleSize(0.05);
   h_isojet1CSV_ZpLjets__267->GetYaxis()->SetTickLength(0.025);
   h_isojet1CSV_ZpLjets__267->GetYaxis()->SetTitleFont(42);
   h_isojet1CSV_ZpLjets__267->GetZaxis()->SetLabelFont(42);
   h_isojet1CSV_ZpLjets__267->GetZaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_ZpLjets__267->GetZaxis()->SetTitleSize(0.05);
   h_isojet1CSV_ZpLjets__267->GetZaxis()->SetTickLength(0.025);
   h_isojet1CSV_ZpLjets__267->GetZaxis()->SetTitleFont(42);
   h->Add(h_isojet1CSV_Z+jets,"");
   
   TH1D *h_isojet1CSV_WpLjets__268 = new TH1D("h_isojet1CSV_WpLjets__268","",10,0,1);
   h_isojet1CSV_WpLjets__268->SetBinContent(1,0.01060448);
   h_isojet1CSV_WpLjets__268->SetBinContent(2,0.01194981);
   h_isojet1CSV_WpLjets__268->SetBinContent(3,0.007295854);
   h_isojet1CSV_WpLjets__268->SetBinContent(4,0.004201536);
   h_isojet1CSV_WpLjets__268->SetBinContent(5,0.003315037);
   h_isojet1CSV_WpLjets__268->SetBinContent(6,0.002154035);
   h_isojet1CSV_WpLjets__268->SetBinContent(7,0.001704806);
   h_isojet1CSV_WpLjets__268->SetBinContent(8,0.001590696);
   h_isojet1CSV_WpLjets__268->SetBinContent(9,0.001506952);
   h_isojet1CSV_WpLjets__268->SetBinContent(10,0.00135957);
   h_isojet1CSV_WpLjets__268->SetBinError(1,0.0007760229);
   h_isojet1CSV_WpLjets__268->SetBinError(2,0.0008063374);
   h_isojet1CSV_WpLjets__268->SetBinError(3,0.0006567409);
   h_isojet1CSV_WpLjets__268->SetBinError(4,0.0005519722);
   h_isojet1CSV_WpLjets__268->SetBinError(5,0.0004860992);
   h_isojet1CSV_WpLjets__268->SetBinError(6,0.0003673486);
   h_isojet1CSV_WpLjets__268->SetBinError(7,0.0003806515);
   h_isojet1CSV_WpLjets__268->SetBinError(8,0.0003677212);
   h_isojet1CSV_WpLjets__268->SetBinError(9,0.0003252218);
   h_isojet1CSV_WpLjets__268->SetBinError(10,0.0002763251);
   h_isojet1CSV_WpLjets__268->SetEntries(3309);
   h_isojet1CSV_WpLjets__268->SetStats(0);

   ci = TColor::GetColor("#66cc66");
   h_isojet1CSV_WpLjets__268->SetFillColor(ci);
   h_isojet1CSV_WpLjets__268->GetXaxis()->SetTitle("isojet 1 CSV");
   h_isojet1CSV_WpLjets__268->GetXaxis()->SetLabelFont(42);
   h_isojet1CSV_WpLjets__268->GetXaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_WpLjets__268->GetXaxis()->SetTitleSize(0.05);
   h_isojet1CSV_WpLjets__268->GetXaxis()->SetTickLength(0.025);
   h_isojet1CSV_WpLjets__268->GetXaxis()->SetTitleFont(42);
   h_isojet1CSV_WpLjets__268->GetYaxis()->SetTitle("a.u.");
   h_isojet1CSV_WpLjets__268->GetYaxis()->SetLabelFont(42);
   h_isojet1CSV_WpLjets__268->GetYaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_WpLjets__268->GetYaxis()->SetTitleSize(0.05);
   h_isojet1CSV_WpLjets__268->GetYaxis()->SetTickLength(0.025);
   h_isojet1CSV_WpLjets__268->GetYaxis()->SetTitleFont(42);
   h_isojet1CSV_WpLjets__268->GetZaxis()->SetLabelFont(42);
   h_isojet1CSV_WpLjets__268->GetZaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_WpLjets__268->GetZaxis()->SetTitleSize(0.05);
   h_isojet1CSV_WpLjets__268->GetZaxis()->SetTickLength(0.025);
   h_isojet1CSV_WpLjets__268->GetZaxis()->SetTitleFont(42);
   h->Add(h_isojet1CSV_W+jets,"");
   
   TH1D *h_isojet1CSV_TopsPoPLFcP__269 = new TH1D("h_isojet1CSV_TopsPoPLFcP__269","",10,0,1);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(1,0.09097508);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(2,0.09232326);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(3,0.04269338);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(4,0.02949662);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(5,0.02281892);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(6,0.01709603);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(7,0.01404044);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(8,0.009499499);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(9,0.006095059);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(10,0.003040849);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinError(1,0.0009372855);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinError(2,0.0009857636);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinError(3,0.0007155424);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinError(4,0.0005977933);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinError(5,0.0005373378);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinError(6,0.0004781073);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinError(7,0.0004489056);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinError(8,0.0003875753);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinError(9,0.0003337873);
   h_isojet1CSV_TopsPoPLFcP__269->SetBinError(10,0.0003173281);
   h_isojet1CSV_TopsPoPLFcP__269->SetEntries(45754);
   h_isojet1CSV_TopsPoPLFcP__269->SetStats(0);

   ci = TColor::GetColor("#cc33cc");
   h_isojet1CSV_TopsPoPLFcP__269->SetFillColor(ci);
   h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetTitle("isojet 1 CSV");
   h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetLabelFont(42);
   h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetTitleSize(0.05);
   h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetTickLength(0.025);
   h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetTitleFont(42);
   h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetTitle("a.u.");
   h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetLabelFont(42);
   h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetTitleSize(0.05);
   h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetTickLength(0.025);
   h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetTitleFont(42);
   h_isojet1CSV_TopsPoPLFcP__269->GetZaxis()->SetLabelFont(42);
   h_isojet1CSV_TopsPoPLFcP__269->GetZaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_TopsPoPLFcP__269->GetZaxis()->SetTitleSize(0.05);
   h_isojet1CSV_TopsPoPLFcP__269->GetZaxis()->SetTickLength(0.025);
   h_isojet1CSV_TopsPoPLFcP__269->GetZaxis()->SetTitleFont(42);
   h->Add(h_isojet1CSV_Top (LF),"");
   
   TH1D *h_isojet1CSV_TopsPoPHFcP__270 = new TH1D("h_isojet1CSV_TopsPoPHFcP__270","",10,0,1);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(1,0.01878166);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(2,0.02708098);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(3,0.01896531);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(4,0.01870601);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(5,0.01924485);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(6,0.02077131);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(7,0.02899544);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(8,0.03698897);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(9,0.07325594);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(10,0.2676551);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinError(1,0.0004640739);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinError(2,0.0005643558);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinError(3,0.0004957084);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinError(4,0.0004766015);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinError(5,0.0004665302);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinError(6,0.0005070097);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinError(7,0.0006476121);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinError(8,0.0007056579);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinError(9,0.0009826258);
   h_isojet1CSV_TopsPoPHFcP__270->SetBinError(10,0.001744809);
   h_isojet1CSV_TopsPoPHFcP__270->SetEntries(77950);
   h_isojet1CSV_TopsPoPHFcP__270->SetStats(0);

   ci = TColor::GetColor("#ff9900");
   h_isojet1CSV_TopsPoPHFcP__270->SetFillColor(ci);
   h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetTitle("isojet 1 CSV");
   h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetLabelFont(42);
   h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetTitleSize(0.05);
   h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetTickLength(0.025);
   h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetTitleFont(42);
   h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetTitle("a.u.");
   h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetLabelFont(42);
   h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetTitleSize(0.05);
   h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetTickLength(0.025);
   h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetTitleFont(42);
   h_isojet1CSV_TopsPoPHFcP__270->GetZaxis()->SetLabelFont(42);
   h_isojet1CSV_TopsPoPHFcP__270->GetZaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_TopsPoPHFcP__270->GetZaxis()->SetTitleSize(0.05);
   h_isojet1CSV_TopsPoPHFcP__270->GetZaxis()->SetTickLength(0.025);
   h_isojet1CSV_TopsPoPHFcP__270->GetZaxis()->SetTitleFont(42);
   h->Add(h_isojet1CSV_Top (HF),"");
   h->Draw("hist");
   
   TH1D *hsum__271 = new TH1D("hsum__271","",10,0,1);
   hsum__271->SetBinContent(1,0.1393796);
   hsum__271->SetBinContent(2,0.1586681);
   hsum__271->SetBinContent(3,0.08197864);
   hsum__271->SetBinContent(4,0.06142623);
   hsum__271->SetBinContent(5,0.05359128);
   hsum__271->SetBinContent(6,0.0447599);
   hsum__271->SetBinContent(7,0.04846618);
   hsum__271->SetBinContent(8,0.05074524);
   hsum__271->SetBinContent(9,0.082468);
   hsum__271->SetBinContent(10,0.2785168);
   hsum__271->SetBinError(1,0.002288647);
   hsum__271->SetBinError(2,0.002167196);
   hsum__271->SetBinError(3,0.001617233);
   hsum__271->SetBinError(4,0.001528597);
   hsum__271->SetBinError(5,0.001538373);
   hsum__271->SetBinError(6,0.001141764);
   hsum__271->SetBinError(7,0.001103813);
   hsum__271->SetBinError(8,0.001058293);
   hsum__271->SetBinError(9,0.001107265);
   hsum__271->SetBinError(10,0.002872657);
   hsum__271->SetEntries(45);
   hsum__271->SetStats(0);

   ci = 1202;
   color = new TColor(ci, 0, 0, 0, " ", 0.99);
   hsum__271->SetFillColor(ci);
   hsum__271->SetFillStyle(3003);
   hsum__271->SetLineWidth(0);
   hsum__271->GetXaxis()->SetTitle("isojet 1 CSV");
   hsum__271->GetXaxis()->SetLabelFont(42);
   hsum__271->GetXaxis()->SetLabelOffset(0.007);
   hsum__271->GetXaxis()->SetTitleSize(0.05);
   hsum__271->GetXaxis()->SetTickLength(0.025);
   hsum__271->GetXaxis()->SetTitleFont(42);
   hsum__271->GetYaxis()->SetTitle("a.u.");
   hsum__271->GetYaxis()->SetLabelFont(42);
   hsum__271->GetYaxis()->SetLabelOffset(0.007);
   hsum__271->GetYaxis()->SetTitleSize(0.05);
   hsum__271->GetYaxis()->SetTickLength(0.025);
   hsum__271->GetYaxis()->SetTitleFont(42);
   hsum__271->GetZaxis()->SetLabelFont(42);
   hsum__271->GetZaxis()->SetLabelOffset(0.007);
   hsum__271->GetZaxis()->SetTitleSize(0.05);
   hsum__271->GetZaxis()->SetTickLength(0.025);
   hsum__271->GetZaxis()->SetTitleFont(42);
   hsum__271->Draw("e2 same");
   
   TH1D *h_isojet1CSV_Data__272 = new TH1D("h_isojet1CSV_Data__272","",10,0,1);
   h_isojet1CSV_Data__272->SetBinContent(1,0.138368);
   h_isojet1CSV_Data__272->SetBinContent(2,0.1592858);
   h_isojet1CSV_Data__272->SetBinContent(3,0.08381231);
   h_isojet1CSV_Data__272->SetBinContent(4,0.06152831);
   h_isojet1CSV_Data__272->SetBinContent(5,0.05196457);
   h_isojet1CSV_Data__272->SetBinContent(6,0.04475643);
   h_isojet1CSV_Data__272->SetBinContent(7,0.04833695);
   h_isojet1CSV_Data__272->SetBinContent(8,0.05059832);
   h_isojet1CSV_Data__272->SetBinContent(9,0.08235183);
   h_isojet1CSV_Data__272->SetBinContent(10,0.2789975);
   h_isojet1CSV_Data__272->SetBinError(1,0.002553194);
   h_isojet1CSV_Data__272->SetBinError(2,0.002739394);
   h_isojet1CSV_Data__272->SetBinError(3,0.0019871);
   h_isojet1CSV_Data__272->SetBinError(4,0.001702564);
   h_isojet1CSV_Data__272->SetBinError(5,0.001564659);
   h_isojet1CSV_Data__272->SetBinError(6,0.00145209);
   h_isojet1CSV_Data__272->SetBinError(7,0.001509057);
   h_isojet1CSV_Data__272->SetBinError(8,0.001543953);
   h_isojet1CSV_Data__272->SetBinError(9,0.001969711);
   h_isojet1CSV_Data__272->SetBinError(10,0.003625484);
   h_isojet1CSV_Data__272->SetEntries(21226);
   h_isojet1CSV_Data__272->SetStats(0);
   h_isojet1CSV_Data__272->SetLineWidth(3);
   h_isojet1CSV_Data__272->SetMarkerStyle(20);
   h_isojet1CSV_Data__272->SetMarkerSize(2);
   h_isojet1CSV_Data__272->GetXaxis()->SetTitle("isojet 1 CSV");
   h_isojet1CSV_Data__272->GetXaxis()->SetLabelFont(42);
   h_isojet1CSV_Data__272->GetXaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_Data__272->GetXaxis()->SetTitleSize(0.05);
   h_isojet1CSV_Data__272->GetXaxis()->SetTickLength(0.025);
   h_isojet1CSV_Data__272->GetXaxis()->SetTitleFont(42);
   h_isojet1CSV_Data__272->GetYaxis()->SetTitle("a.u.");
   h_isojet1CSV_Data__272->GetYaxis()->SetLabelFont(42);
   h_isojet1CSV_Data__272->GetYaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_Data__272->GetYaxis()->SetTitleSize(0.05);
   h_isojet1CSV_Data__272->GetYaxis()->SetTickLength(0.025);
   h_isojet1CSV_Data__272->GetYaxis()->SetTitleFont(42);
   h_isojet1CSV_Data__272->GetZaxis()->SetLabelFont(42);
   h_isojet1CSV_Data__272->GetZaxis()->SetLabelOffset(0.007);
   h_isojet1CSV_Data__272->GetZaxis()->SetTitleSize(0.05);
   h_isojet1CSV_Data__272->GetZaxis()->SetTickLength(0.025);
   h_isojet1CSV_Data__272->GetZaxis()->SetTitleFont(42);
   h_isojet1CSV_Data__272->Draw("elp same");
   
   TLegend *leg = new TLegend(0.6,0.55,0.88,0.9,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(0);
   TLegendEntry *entry=leg->AddEntry("h_isojet1CSV_Data","Data","ELP");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(3);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(2);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_Top (HF)","Top (HF)","F");

   ci = TColor::GetColor("#ff9900");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_Top (LF)","Top (LF)","F");

   ci = TColor::GetColor("#cc33cc");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_W+jets","W+jets","F");

   ci = TColor::GetColor("#66cc66");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_Z+jets","Z+jets","F");

   ci = TColor::GetColor("#3399cc");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_Diboson","Diboson","F");

   ci = TColor::GetColor("#9966cc");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_QCD","QCD","F");

   ci = TColor::GetColor("#cccccc");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   
   leg = new TLegend(0.6,0.55,0.88,0.9,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(0);
   entry=leg->AddEntry("h_isojet1CSV_Data","Data","ELP");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(3);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(2);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_Top (HF)","Top (HF)","F");

   ci = TColor::GetColor("#ff9900");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_Top (LF)","Top (LF)","F");

   ci = TColor::GetColor("#cc33cc");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_W+jets","W+jets","F");

   ci = TColor::GetColor("#66cc66");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_Z+jets","Z+jets","F");

   ci = TColor::GetColor("#3399cc");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_Diboson","Diboson","F");

   ci = TColor::GetColor("#9966cc");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("h_isojet1CSV_QCD","QCD","F");

   ci = TColor::GetColor("#cccccc");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   TLatex *   tex = new TLatex(0.18,0.85,"CMS");
tex->SetNDC();
   tex->SetTextSize(0.06);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.28,0.85,"Preliminary");
tex->SetNDC();
   tex->SetTextFont(52);
   tex->SetTextSize(0.06);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.9,0.94,"36.6 fb^{-1} (13 TeV)");
tex->SetNDC();
   tex->SetTextAlign(31);
   tex->SetTextFont(42);
   tex->SetTextSize(0.04);
   tex->SetLineWidth(2);
   tex->Draw();
   pad1->Modified();
   c1->cd();
  
// ------------>Primitives in pad: pad2
   TPad *pad2 = new TPad("pad2", "pad2",0,0.05,1,0.3);
   pad2->Draw();
   pad2->cd();
   pad2->Range(-0.1875,-0.8914286,1.0625,0.48);
   pad2->SetFillColor(0);
   pad2->SetBorderMode(0);
   pad2->SetBorderSize(2);
   pad2->SetGridy();
   pad2->SetTickx(1);
   pad2->SetTicky(1);
   pad2->SetLeftMargin(0.15);
   pad2->SetRightMargin(0.05);
   pad2->SetTopMargin(0);
   pad2->SetBottomMargin(0.3);
   pad2->SetFrameFillStyle(0);
   pad2->SetFrameBorderMode(0);
   pad2->SetFrameFillStyle(0);
   pad2->SetFrameBorderMode(0);
   
   TH1D *ratio__273 = new TH1D("ratio__273","",10,0,1);
   ratio__273->SetBinContent(1,-0.00725764);
   ratio__273->SetBinContent(2,0.003892779);
   ratio__273->SetBinContent(3,0.0223676);
   ratio__273->SetBinContent(4,0.001661897);
   ratio__273->SetBinContent(5,-0.0303539);
   ratio__273->SetBinContent(6,-7.754564e-05);
   ratio__273->SetBinContent(7,-0.002666473);
   ratio__273->SetBinContent(8,-0.002895236);
   ratio__273->SetBinContent(9,-0.001408637);
   ratio__273->SetBinContent(10,0.001725793);
   ratio__273->SetBinError(1,0.0001);
   ratio__273->SetBinError(2,0.0001);
   ratio__273->SetBinError(3,0.0001);
   ratio__273->SetBinError(4,0.0001);
   ratio__273->SetBinError(5,0.0001);
   ratio__273->SetBinError(6,0.0001);
   ratio__273->SetBinError(7,0.0001);
   ratio__273->SetBinError(8,0.0001);
   ratio__273->SetBinError(9,0.0001);
   ratio__273->SetBinError(10,0.0001);
   ratio__273->SetMinimum(-0.48);
   ratio__273->SetMaximum(0.48);
   ratio__273->SetEntries(21236);
   ratio__273->SetStats(0);
   ratio__273->SetLineWidth(3);
   ratio__273->SetMarkerStyle(20);
   ratio__273->SetMarkerSize(2);
   ratio__273->GetXaxis()->SetTitle("isojet 1 CSV");
   ratio__273->GetXaxis()->SetLabelFont(43);
   ratio__273->GetXaxis()->SetLabelOffset(0.007);
   ratio__273->GetXaxis()->SetLabelSize(30);
   ratio__273->GetXaxis()->SetTitleSize(40);
   ratio__273->GetXaxis()->SetTickLength(0.025);
   ratio__273->GetXaxis()->SetTitleOffset(5);
   ratio__273->GetXaxis()->SetTitleFont(43);
   ratio__273->GetYaxis()->SetTitle("#frac{Data-Exp}{Exp}");
   ratio__273->GetYaxis()->SetNdivisions(5);
   ratio__273->GetYaxis()->SetLabelFont(43);
   ratio__273->GetYaxis()->SetLabelOffset(0.007);
   ratio__273->GetYaxis()->SetLabelSize(30);
   ratio__273->GetYaxis()->SetTitleSize(40);
   ratio__273->GetYaxis()->SetTickLength(0.025);
   ratio__273->GetYaxis()->SetTitleOffset(2.5);
   ratio__273->GetYaxis()->SetTitleFont(43);
   ratio__273->GetZaxis()->SetLabelFont(42);
   ratio__273->GetZaxis()->SetLabelOffset(0.007);
   ratio__273->GetZaxis()->SetTitleSize(0.05);
   ratio__273->GetZaxis()->SetTickLength(0.025);
   ratio__273->GetZaxis()->SetTitleFont(42);
   ratio__273->Draw("elp");
   
   TH1D *zero__274 = new TH1D("zero__274","",10,0,1);
   zero__274->SetBinError(1,0.002553194);
   zero__274->SetBinError(2,0.002739394);
   zero__274->SetBinError(3,0.0019871);
   zero__274->SetBinError(4,0.001702564);
   zero__274->SetBinError(5,0.001564659);
   zero__274->SetBinError(6,0.00145209);
   zero__274->SetBinError(7,0.001509057);
   zero__274->SetBinError(8,0.001543953);
   zero__274->SetBinError(9,0.001969711);
   zero__274->SetBinError(10,0.003625484);
   zero__274->SetEntries(21236);
   zero__274->SetStats(0);
   zero__274->SetLineWidth(3);
   zero__274->SetMarkerStyle(20);
   zero__274->SetMarkerSize(2);
   zero__274->GetXaxis()->SetTitle("isojet 1 CSV");
   zero__274->GetXaxis()->SetLabelFont(42);
   zero__274->GetXaxis()->SetLabelOffset(0.007);
   zero__274->GetXaxis()->SetTitleSize(0.05);
   zero__274->GetXaxis()->SetTickLength(0.025);
   zero__274->GetXaxis()->SetTitleFont(42);
   zero__274->GetYaxis()->SetTitle("a.u.");
   zero__274->GetYaxis()->SetLabelFont(42);
   zero__274->GetYaxis()->SetLabelOffset(0.007);
   zero__274->GetYaxis()->SetTitleSize(0.05);
   zero__274->GetYaxis()->SetTickLength(0.025);
   zero__274->GetYaxis()->SetTitleFont(42);
   zero__274->GetZaxis()->SetLabelFont(42);
   zero__274->GetZaxis()->SetLabelOffset(0.007);
   zero__274->GetZaxis()->SetTitleSize(0.05);
   zero__274->GetZaxis()->SetTickLength(0.025);
   zero__274->GetZaxis()->SetTitleFont(42);
   zero__274->Draw("hist same");
   
   TH1D *sumratioup__275 = new TH1D("sumratioup__275","",10,0,1);
   sumratioup__275->SetBinContent(1,0.01642024);
   sumratioup__275->SetBinContent(2,0.01365867);
   sumratioup__275->SetBinContent(3,0.01972749);
   sumratioup__275->SetBinContent(4,0.02488509);
   sumratioup__275->SetBinContent(5,0.02870566);
   sumratioup__275->SetBinContent(6,0.02550863);
   sumratioup__275->SetBinContent(7,0.02277492);
   sumratioup__275->SetBinContent(8,0.02085501);
   sumratioup__275->SetBinContent(9,0.01342661);
   sumratioup__275->SetBinContent(10,0.01031412);
   sumratioup__275->SetBinError(1,0.002288647);
   sumratioup__275->SetBinError(2,0.002167196);
   sumratioup__275->SetBinError(3,0.001617233);
   sumratioup__275->SetBinError(4,0.001528597);
   sumratioup__275->SetBinError(5,0.001538373);
   sumratioup__275->SetBinError(6,0.001141764);
   sumratioup__275->SetBinError(7,0.001103813);
   sumratioup__275->SetBinError(8,0.001058293);
   sumratioup__275->SetBinError(9,0.001107265);
   sumratioup__275->SetBinError(10,0.002872657);
   sumratioup__275->SetEntries(55);
   sumratioup__275->SetStats(0);

   ci = 1202;
   color = new TColor(ci, 0, 0, 0, " ", 0.99);
   sumratioup__275->SetFillColor(ci);
   sumratioup__275->SetFillStyle(3003);
   sumratioup__275->GetXaxis()->SetTitle("isojet 1 CSV");
   sumratioup__275->GetXaxis()->SetLabelFont(42);
   sumratioup__275->GetXaxis()->SetLabelOffset(0.007);
   sumratioup__275->GetXaxis()->SetTitleSize(0.05);
   sumratioup__275->GetXaxis()->SetTickLength(0.025);
   sumratioup__275->GetXaxis()->SetTitleFont(42);
   sumratioup__275->GetYaxis()->SetTitle("a.u.");
   sumratioup__275->GetYaxis()->SetLabelFont(42);
   sumratioup__275->GetYaxis()->SetLabelOffset(0.007);
   sumratioup__275->GetYaxis()->SetTitleSize(0.05);
   sumratioup__275->GetYaxis()->SetTickLength(0.025);
   sumratioup__275->GetYaxis()->SetTitleFont(42);
   sumratioup__275->GetZaxis()->SetLabelFont(42);
   sumratioup__275->GetZaxis()->SetLabelOffset(0.007);
   sumratioup__275->GetZaxis()->SetTitleSize(0.05);
   sumratioup__275->GetZaxis()->SetTickLength(0.025);
   sumratioup__275->GetZaxis()->SetTitleFont(42);
   sumratioup__275->Draw("hist same");
   
   TH1D *sumratiodown__276 = new TH1D("sumratiodown__276","",10,0,1);
   sumratiodown__276->SetBinContent(1,-0.01642024);
   sumratiodown__276->SetBinContent(2,-0.01365867);
   sumratiodown__276->SetBinContent(3,-0.01972749);
   sumratiodown__276->SetBinContent(4,-0.02488509);
   sumratiodown__276->SetBinContent(5,-0.02870566);
   sumratiodown__276->SetBinContent(6,-0.02550863);
   sumratiodown__276->SetBinContent(7,-0.02277492);
   sumratiodown__276->SetBinContent(8,-0.02085501);
   sumratiodown__276->SetBinContent(9,-0.01342661);
   sumratiodown__276->SetBinContent(10,-0.01031412);
   sumratiodown__276->SetBinError(1,0.002288647);
   sumratiodown__276->SetBinError(2,0.002167196);
   sumratiodown__276->SetBinError(3,0.001617233);
   sumratiodown__276->SetBinError(4,0.001528597);
   sumratiodown__276->SetBinError(5,0.001538373);
   sumratiodown__276->SetBinError(6,0.001141764);
   sumratiodown__276->SetBinError(7,0.001103813);
   sumratiodown__276->SetBinError(8,0.001058293);
   sumratiodown__276->SetBinError(9,0.001107265);
   sumratiodown__276->SetBinError(10,0.002872657);
   sumratiodown__276->SetEntries(55);
   sumratiodown__276->SetStats(0);

   ci = 1202;
   color = new TColor(ci, 0, 0, 0, " ", 0.99);
   sumratiodown__276->SetFillColor(ci);
   sumratiodown__276->SetFillStyle(3003);
   sumratiodown__276->GetXaxis()->SetTitle("isojet 1 CSV");
   sumratiodown__276->GetXaxis()->SetLabelFont(42);
   sumratiodown__276->GetXaxis()->SetLabelOffset(0.007);
   sumratiodown__276->GetXaxis()->SetTitleSize(0.05);
   sumratiodown__276->GetXaxis()->SetTickLength(0.025);
   sumratiodown__276->GetXaxis()->SetTitleFont(42);
   sumratiodown__276->GetYaxis()->SetTitle("a.u.");
   sumratiodown__276->GetYaxis()->SetLabelFont(42);
   sumratiodown__276->GetYaxis()->SetLabelOffset(0.007);
   sumratiodown__276->GetYaxis()->SetTitleSize(0.05);
   sumratiodown__276->GetYaxis()->SetTickLength(0.025);
   sumratiodown__276->GetYaxis()->SetTitleFont(42);
   sumratiodown__276->GetZaxis()->SetLabelFont(42);
   sumratiodown__276->GetZaxis()->SetLabelOffset(0.007);
   sumratiodown__276->GetZaxis()->SetTitleSize(0.05);
   sumratiodown__276->GetZaxis()->SetTickLength(0.025);
   sumratiodown__276->GetZaxis()->SetTitleFont(42);
   sumratiodown__276->Draw("hist same");
   
   Double_t Graph0_fx1023[10] = {
   0.05,
   0.15,
   0.25,
   0.35,
   0.45,
   0.55,
   0.65,
   0.75,
   0.85,
   0.95};
   Double_t Graph0_fy1023[10] = {
   -0.00725764,
   0.003892779,
   0.0223676,
   0.001661897,
   -0.0303539,
   -7.754564e-05,
   -0.002666473,
   -0.002895236,
   -0.001408637,
   0.001725793};
   Double_t Graph0_fex1023[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph0_fey1023[10] = {
   0.01831827,
   0.01726493,
   0.02423924,
   0.02771721,
   0.02919614,
   0.03244177,
   0.03113628,
   0.03042557,
   0.02388455,
   0.01301711};
   TGraphErrors *gre = new TGraphErrors(10,Graph0_fx1023,Graph0_fy1023,Graph0_fex1023,Graph0_fey1023);
   gre->SetName("Graph0");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineWidth(3);
   
   TH1F *Graph_Graph1023 = new TH1F("Graph_Graph1023","Graph",100,0,1.04);
   Graph_Graph1023->SetMinimum(-0.07016574);
   Graph_Graph1023->SetMaximum(0.05722253);
   Graph_Graph1023->SetDirectory(0);
   Graph_Graph1023->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1023->SetLineColor(ci);
   Graph_Graph1023->GetXaxis()->SetLabelFont(42);
   Graph_Graph1023->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph1023->GetXaxis()->SetTitleSize(0.05);
   Graph_Graph1023->GetXaxis()->SetTickLength(0.025);
   Graph_Graph1023->GetXaxis()->SetTitleFont(42);
   Graph_Graph1023->GetYaxis()->SetLabelFont(42);
   Graph_Graph1023->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1023->GetYaxis()->SetTitleSize(0.05);
   Graph_Graph1023->GetYaxis()->SetTickLength(0.025);
   Graph_Graph1023->GetYaxis()->SetTitleFont(42);
   Graph_Graph1023->GetZaxis()->SetLabelFont(42);
   Graph_Graph1023->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1023->GetZaxis()->SetTitleSize(0.05);
   Graph_Graph1023->GetZaxis()->SetTickLength(0.025);
   Graph_Graph1023->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1023);
   
   gre->Draw("pe0");
   pad2->Modified();
   c1->cd();
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
}
示例#23
0
//===============================
void DrawFit(Double_t nSigma, Int_t iRapBin, Int_t iPTBin){

  gStyle->SetFillColor(0);

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

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

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

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

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

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

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

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


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

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

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

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



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


/// produce pedagogical plot

  	  cout<<"Plot pedagogical"<<endl;

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

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

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

	  double maxSig=2.5;


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

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

      }

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

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

      }

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


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

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


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

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


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

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

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

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

		plotLegend->Draw();

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


  }


}
示例#24
0
void plotQCDTemplates()
{
    TH1 *htlep_s1 = merge("htlep", input_s1, 0, QCD_CHANNELS, true);
    TH1 *htlep_s2 = merge("htlep", input_s2, 0, QCD_CHANNELS, true);
    TH1 *htlep_signal = merge("htlep", input_signal, 0, QCD_CHANNELS, true);

    TH1 *mttbar_before_htlep_s1 =
        merge("mttbar_before_htlep", input_s1, 0, QCD_CHANNELS, true);
    TH1 *mttbar_before_htlep_s2 =
        merge("mttbar_before_htlep", input_s2, 0, QCD_CHANNELS, true);
    TH1 *mttbar_before_htlep_signal =
        merge("mttbar_before_htlep", input_signal, 0, QCD_CHANNELS, true);

    TH1 *mttbar_after_htlep_s1 =
        merge("mttbar_after_htlep", input_s1, 0, QCD_CHANNELS, true);
    TH1 *mttbar_after_htlep_s2 = 
        merge("mttbar_after_htlep", input_s2, 0, QCD_CHANNELS, true);
    TH1 *mttbar_after_htlep_signal =
        merge("mttbar_after_htlep", input_signal, 0, QCD_CHANNELS, true);
 
    string canvas_title = "QCD Templates";
    TCanvas *canvas = new TCanvas(canvas_title.c_str(), canvas_title.c_str());
    canvas->SetWindowSize(1200, 480);
    canvas->Divide(3);

    canvas->cd(1);
    htlep_s1->SetLineColor(4);
    htlep_s1->SetMarkerColor(4);
    htlep_s1->SetFillColor(0);
    
    htlep_s2->SetLineColor(2);
    htlep_s2->SetMarkerColor(2);
    htlep_s2->SetFillColor(0);

    htlep_signal->SetLineColor(1);
    htlep_signal->SetMarkerColor(1);
    htlep_signal->SetFillColor(0);

    THStack *stack = new THStack();
    stack->Add(htlep_s1);
    stack->Add(htlep_s2);
    stack->Add(htlep_signal);

    stack->Draw("nostack");

    TLegend *legend = createLegend("H_{T}^{lep}");
    legend->Draw();

    canvas->cd(2);
    mttbar_before_htlep_s1->SetLineColor(4);
    mttbar_before_htlep_s1->SetMarkerColor(4);
    
    mttbar_before_htlep_s2->SetLineColor(2);
    mttbar_before_htlep_s2->SetMarkerColor(2);

    mttbar_before_htlep_signal->SetLineColor(1);
    mttbar_before_htlep_signal->SetMarkerColor(1);

    stack = new THStack();
    stack->Add(mttbar_before_htlep_s1);
    stack->Add(mttbar_before_htlep_s2);
    stack->Add(mttbar_before_htlep_signal);

    stack->Draw("nostack h");

    legend = createLegend("M_{t#bar{t}} before H_{T}^{lep}");
    legend->Draw();

    canvas->cd(3);
    mttbar_after_htlep_s1->SetLineColor(4);
    mttbar_after_htlep_s1->SetMarkerColor(4);
    
    mttbar_after_htlep_s2->SetLineColor(2);
    mttbar_after_htlep_s2->SetMarkerColor(2);

    mttbar_after_htlep_signal->SetLineColor(1);
    mttbar_after_htlep_signal->SetMarkerColor(1);

    stack = new THStack();
    stack->Add(mttbar_after_htlep_s1);
    stack->Add(mttbar_after_htlep_s2);
    stack->Add(mttbar_after_htlep_signal);

    stack->Draw("nostack h");

    legend = createLegend("M_{t#bar{t}} after H_{T}^{lep}");
    legend->Draw();
}
void makePlots_csvSF_13TeV( TString inputFileName  = "infile.root", bool isHF = true, TString dirPostFix = "", bool compareIterations = false ) {

  TFile *histFile = TFile::Open(inputFileName);


  TString dirprefix = "Images/Images_2014_08_26_csvSF_13TeV" + dirPostFix + "/";

  struct stat st;
  if( stat(dirprefix.Data(),&st) != 0 )  mkdir(dirprefix.Data(),0777);

  // single jet specific plots
  int nPt = 6;
  int nEta = 1;
  TString flavor = "HF";
  if ( !isHF ){
    nPt = 4; nEta = 3;
    flavor = "LF";
  }

  //////
  TH1D* h_Data_jet_csv[nPt][nEta];
  TH1D* h_MC_b_jet_csv[nPt][nEta];
  TH1D* h_MC_nonb_jet_csv[nPt][nEta];

  /////
  int nCSVBins = 18; //Number of bins 
  double xBins_hf[19] = {-0.04, 0.0, 0.122, 0.244, 0.331, 0.418, 0.505, 0.592, 0.679, 0.7228, 0.7666, 0.8104, 0.8542, 0.898, 0.9184, 0.9388, 0.9592, 0.9796, 1.01};

  // int nCSVBins = 14;
  // double xBins_hf[15] = {-0.04, 0.0, 0.244, 0.418, 0.592, 0.679, 0.7666, 0.8104, 0.8542, 0.898, 0.9184, 0.9388, 0.9592, 0.9796, 1.01};


  if(!isHF) nCSVBins = 21;
  double xBins_lf[22] = {-0.04, 0.0, 0.04, 0.08, 0.12, 0.16, 0.2, 0.244, 0.331, 0.418, 0.505, 0.592, 0.679, 0.752, 0.825, 0.898, 0.915, 0.932, 0.949, 0.966, 0.983, 1.01};
  // if(!isHF) nCSVBins = 15;
  // double xBins_lf[16] = {-0.04, 0.0, 0.04, 0.08, 0.12, 0.16, 0.2, 0.244, 0.331, 0.418, 0.505, 0.592, 0.679, 0.825, 0.949, 1.01};


  //TCanvas* c1 = new TCanvas("c1","c1",600,600);
  TCanvas* c1 = new TCanvas("c1","c1",600,500);

  c1->SetTopMargin(0.08);
  c1->SetRightMargin(0.08);


  TString flavor_file = flavor;
  flavor_file.ToLower();

  TFile *fitFile_iter0 = TFile::Open("csv_rwt_fit_" + flavor_file + "_v0.root");
  TFile *fitFile_iter1 = TFile::Open("csv_rwt_fit_" + flavor_file + "_v1.root");
  TFile *fitFile_iter2 = TFile::Open("csv_rwt_fit_" + flavor_file + "_v2.root");



  TString plotName;

  int iHist = -1;
  for ( int iPt=0; iPt<nPt; iPt++){
    for ( int iEta=0; iEta<nEta; iEta++){
      iHist++;

      TString h_Data_Name = Form("csv_Data_Pt%i_Eta%i",iPt,iEta);
      TString h_b_Name = Form("csv_MC_bjets_Pt%i_Eta%i",iPt,iEta);
      TString h_nonb_Name = Form("csv_MC_nonbjets_Pt%i_Eta%i",iPt,iEta);

      
      h_Data_jet_csv[iPt][iEta] = (TH1D*)histFile->Get(h_Data_Name.Data());
      h_MC_b_jet_csv[iPt][iEta] = (TH1D*)histFile->Get(h_b_Name.Data());
      h_MC_nonb_jet_csv[iPt][iEta] = (TH1D*)histFile->Get(h_nonb_Name.Data());

      // rebin
      TH1D* h_csv_data = NULL;
      TH1D* h_csv_mc_b = NULL;
      TH1D* h_csv_mc_nonb = NULL;
      if( isHF ){
	h_csv_data = (TH1D*)h_Data_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_hf );
	h_csv_mc_b = (TH1D*)h_MC_b_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_hf );
	h_csv_mc_nonb = (TH1D*)h_MC_nonb_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_hf );
      }
      else{
	h_csv_data = (TH1D*)h_Data_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_lf );
	h_csv_mc_b = (TH1D*)h_MC_b_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_lf );
	h_csv_mc_nonb = (TH1D*)h_MC_nonb_jet_csv[iPt][iEta]->Rebin( nCSVBins, Form("csv_Data_Pt%i_Eta%i_temp",iPt,iEta), xBins_lf );
      }

      h_csv_data->SetBinContent(1,h_Data_jet_csv[iPt][iEta]->GetBinContent(1));
      h_csv_data->SetBinError(1,h_Data_jet_csv[iPt][iEta]->GetBinError(1));

      h_csv_mc_b->SetBinContent(1,h_MC_b_jet_csv[iPt][iEta]->GetBinContent(1));
      h_csv_mc_b->SetBinError(1,h_MC_b_jet_csv[iPt][iEta]->GetBinError(1));

      h_csv_mc_nonb->SetBinContent(1,h_MC_nonb_jet_csv[iPt][iEta]->GetBinContent(1));
      h_csv_mc_nonb->SetBinError(1,h_MC_nonb_jet_csv[iPt][iEta]->GetBinError(1));

      h_csv_data->SetStats(0);
      //h_csv_data->GetXaxis()->SetRangeUser(0.0001, 1.001);

      h_csv_data->SetTitle(";CSV");

      h_csv_data->SetMarkerStyle(20);

      h_csv_mc_b->SetFillColor(kRed);
      h_csv_mc_nonb->SetFillColor(kGreen+1);

      h_csv_mc_b->SetLineColor(kRed);
      h_csv_mc_nonb->SetLineColor(kGreen+1);

      h_csv_data->SetLineWidth(2);
      h_csv_mc_b->SetLineWidth(2);
      h_csv_mc_nonb->SetLineWidth(2);


      TLegend *legend = new TLegend(0.14,0.93,0.9,0.98);

      legend->SetFillColor(kWhite);
      legend->SetLineColor(kWhite);
      legend->SetShadowColor(kWhite);
      legend->SetTextFont(42);
      legend->SetTextSize(0.05);

      legend->SetNColumns(3);

      legend->AddEntry(h_csv_data,"Data","pe");
      if( isHF ){
	legend->AddEntry(h_csv_mc_b,"b jets","l");
	legend->AddEntry(h_csv_mc_nonb,"non-b jets","l");
      }
      else{
	legend->AddEntry(h_csv_mc_b,"HF jets","l");
	legend->AddEntry(h_csv_mc_nonb,"LF jets","l");
      }

      TH1D* h_diff = (TH1D*) h_csv_data->Clone( Form("csv_diff_Pt%i_Eta%i",iPt,iEta) );

      THStack *hs = new THStack("hs","");
      if( isHF ){
	hs->Add(h_csv_mc_b);
	hs->Add(h_csv_mc_nonb);

	h_diff->Add(h_csv_mc_nonb,-1);
      }
      else{
	hs->Add(h_csv_mc_nonb);
	hs->Add(h_csv_mc_b);

	h_diff->Add(h_csv_mc_b,-1);
      }

      TH1D* h_ratio = (TH1D*) h_diff->Clone( Form("csv_ratio_Pt%i_Eta%i",iPt,iEta) );
      if( isHF ) h_ratio->Divide( h_csv_mc_b );
      else       h_ratio->Divide( h_csv_mc_nonb );
      

      TString title    = Form("%s SF Pt%i Eta%i",flavor.Data(),iPt,iEta);

      TLatex BinInfoLatex(0.6, 0.86, title.Data());
	
      BinInfoLatex.SetNDC();
      BinInfoLatex.SetTextFont(42);
      BinInfoLatex.SetTextSize(0.04);

      h_csv_data->Draw("pe1");
      hs->Draw("histsame");
      h_csv_data->Draw("pe1same");
      
      legend->Draw();
      BinInfoLatex.Draw();

      c1->RedrawAxis();

      plotName = dirprefix + Form("csv_%s_SF_Pt%i_Eta%i_astack",flavor.Data(),iPt,iEta) + ".png";

      c1->Print(plotName.Data());



      TLegend *legend_diff = new TLegend(0.14,0.93,0.9,0.98);

      legend_diff->SetFillColor(kWhite);
      legend_diff->SetLineColor(kWhite);
      legend_diff->SetShadowColor(kWhite);
      legend_diff->SetTextFont(42);
      legend_diff->SetTextSize(0.05);

      legend_diff->SetNColumns(2);

      if( isHF ){
	legend_diff->AddEntry(h_diff,"(Data - nonb)","pe");
	legend_diff->AddEntry(h_csv_mc_b,"b jets","l");
      }
      else{
	legend_diff->AddEntry(h_diff,"(Data - b)","pe");
	legend_diff->AddEntry(h_csv_mc_nonb,"LF jets","l");
      }



      h_diff->Draw("pe1");
      if( isHF ) h_csv_mc_b->Draw("pe1same");
      else       h_csv_mc_nonb->Draw("pe1same");
      h_diff->Draw("pe1same");

      legend_diff->Draw();
      BinInfoLatex.Draw();

      c1->RedrawAxis();

      plotName = dirprefix + Form("csv_%s_SF_Pt%i_Eta%i_bdiff",flavor.Data(),iPt,iEta) + ".png";

      c1->Print(plotName.Data());



      h_ratio->GetYaxis()->SetRangeUser(0.,2.);
      h_ratio->SetTitle(";CSV;Data/MC SF");
      h_ratio->Draw("pe1");

      BinInfoLatex.Draw();

      c1->RedrawAxis();

      plotName = dirprefix + Form("csv_%s_SF_Pt%i_Eta%i_cratio",flavor.Data(),iPt,iEta) + ".png";

      c1->Print(plotName.Data());


      if( compareIterations ){


	TString h_iter_Data_Name = Form("h_csv_Data_Pt%i_Eta%i",iPt,iEta);
	TString h_iter_b_Name = Form("h_csv_MC_bjets_Pt%i_Eta%i",iPt,iEta);
	TString h_iter_nonb_Name = Form("h_csv_MC_nonbjets_Pt%i_Eta%i",iPt,iEta);
	TString h_iter_csv_ratio_Name = Form("temp_csv_ratio_Pt%i_Eta%i",iPt,iEta);
 
	TH1D* h_iter_Data_jet_csv_iter0 = (TH1D*)fitFile_iter0->Get(h_iter_Data_Name.Data())->Clone(h_iter_Data_Name+"v0");
	TH1D* h_iter_MC_b_jet_csv_iter0 = (TH1D*)fitFile_iter0->Get(h_iter_b_Name.Data())->Clone(h_iter_b_Name+"v0");
	TH1D* h_iter_MC_nonb_jet_csv_iter0 = (TH1D*)fitFile_iter0->Get(h_iter_nonb_Name.Data())->Clone(h_iter_nonb_Name+"v0");
	
	TH1D* h_iter_Data_jet_csv_iter1 = (TH1D*)fitFile_iter1->Get(h_iter_Data_Name.Data())->Clone(h_iter_Data_Name+"v1");
	TH1D* h_iter_MC_b_jet_csv_iter1 = (TH1D*)fitFile_iter1->Get(h_iter_b_Name.Data())->Clone(h_iter_b_Name+"v1");
	TH1D* h_iter_MC_nonb_jet_csv_iter1 = (TH1D*)fitFile_iter1->Get(h_iter_nonb_Name.Data())->Clone(h_iter_nonb_Name+"v1");

	TH1D* h_iter_Data_jet_csv_iter2 = (TH1D*)fitFile_iter2->Get(h_iter_Data_Name.Data())->Clone(h_iter_Data_Name+"v2");
	TH1D* h_iter_MC_b_jet_csv_iter2 = (TH1D*)fitFile_iter2->Get(h_iter_b_Name.Data())->Clone(h_iter_b_Name+"v2");
	TH1D* h_iter_MC_nonb_jet_csv_iter2 = (TH1D*)fitFile_iter2->Get(h_iter_nonb_Name.Data())->Clone(h_iter_nonb_Name+"v2");

	TH1D* h_iter0 = (TH1D*)h_iter_Data_jet_csv_iter0->Clone(h_iter_csv_ratio_Name+"v0");
	TH1D* h_iter1 = (TH1D*)h_iter_Data_jet_csv_iter1->Clone(h_iter_csv_ratio_Name+"v1");
	TH1D* h_iter2 = (TH1D*)h_iter_Data_jet_csv_iter2->Clone(h_iter_csv_ratio_Name+"v2");
	if( isHF ){
	  h_iter0->Add(h_iter_MC_nonb_jet_csv_iter0, -1);
	  h_iter0->Divide(h_iter_MC_b_jet_csv_iter0);

	  h_iter1->Add(h_iter_MC_nonb_jet_csv_iter1, -1);
	  h_iter1->Divide(h_iter_MC_b_jet_csv_iter1);

	  h_iter2->Add(h_iter_MC_nonb_jet_csv_iter2, -1);
	  h_iter2->Divide(h_iter_MC_b_jet_csv_iter2);
	}
	else {
	  h_iter0->Add(h_iter_MC_b_jet_csv_iter0, -1);
	  h_iter0->Divide(h_iter_MC_nonb_jet_csv_iter0);

	  h_iter1->Add(h_iter_MC_b_jet_csv_iter1, -1);
	  h_iter1->Divide(h_iter_MC_nonb_jet_csv_iter1);

	  h_iter2->Add(h_iter_MC_b_jet_csv_iter2, -1);
	  h_iter2->Divide(h_iter_MC_nonb_jet_csv_iter2);
	}


	TString iter_fit_histo_name = Form("csv_ratio_Pt%d_Eta%d_final",iPt,iEta);

	//TString iter_histo_name = Form("h_csv_ratio_%d",iHist);
	TH1D* h_fit_iter0 = (TH1D*)fitFile_iter0->Get(iter_fit_histo_name)->Clone(iter_fit_histo_name+"v0");
	TH1D* h_fit_iter1 = (TH1D*)fitFile_iter1->Get(iter_fit_histo_name)->Clone(iter_fit_histo_name+"v1");
	TH1D* h_fit_iter2 = (TH1D*)fitFile_iter2->Get(iter_fit_histo_name)->Clone(iter_fit_histo_name+"v2");

	h_fit_iter0->SetLineColor(kRed);
	h_fit_iter1->SetLineColor(kGreen+1);
	h_fit_iter2->SetLineColor(kBlue);

	h_fit_iter0->SetLineWidth(2);
	h_fit_iter1->SetLineWidth(2);
	h_fit_iter2->SetLineWidth(2);

	h_iter0->SetLineColor(kRed);
	h_iter1->SetLineColor(kGreen+1);
	h_iter2->SetLineColor(kBlue);

	h_iter0->SetLineWidth(2);
	h_iter1->SetLineWidth(2);
	h_iter2->SetLineWidth(2);

	h_fit_iter0->SetStats(0);
	h_fit_iter0->GetYaxis()->SetRangeUser(0.,2.);

	h_fit_iter0->SetTitle(";CSV;Data/MC CSV SF");

	h_fit_iter0->Draw("hist");
	h_iter0->Draw("pe1same");
	h_fit_iter1->Draw("histsame");
	h_iter1->Draw("pe1same");
	h_fit_iter2->Draw("histsame");
	h_iter2->Draw("pe1same");

	c1->RedrawAxis();


	TLegend *legend_iter = new TLegend(0.14,0.93,0.9,0.98);

	legend_iter->SetFillColor(kWhite);
	legend_iter->SetLineColor(kWhite);
	legend_iter->SetShadowColor(kWhite);
	legend_iter->SetTextFont(42);
	legend_iter->SetTextSize(0.05);

	legend_iter->SetNColumns(3);

	legend_iter->AddEntry(h_iter0,"Iter0","l");
	legend_iter->AddEntry(h_iter1,"Iter1","l");
	legend_iter->AddEntry(h_iter2,"Iter2","l");

	legend_iter->Draw();
	BinInfoLatex.Draw();

	c1->RedrawAxis();

	plotName = dirprefix + Form("csv_%s_SF_Pt%i_Eta%i_diters",flavor.Data(),iPt,iEta) + ".png";

	c1->Print(plotName.Data());
      }
    }
  }



  std::cout << "Done." << std::endl;

}
示例#26
0
void plottingmacro_IVF()
{


  double fa = 0.46502;
  double fb = 0.53498;
  bool debug_ = true;

  //  std::string path("Nov10thFall11Plots/");
  //  std::string path("Nov10Fall1160MTopSlimPlots/");
  std::string path("Nov10Fall1160MTopIVFPlots_b/");

  if(debug_)
    std::cout << "Init the style form setTDRStyle" << std::endl;
  setTDRStyle();
  gStyle->SetErrorX(0.5);
  gROOT->ForceStyle();
  initOptions();
  

  if(debug_)
    std::cout << "Init the sample" << std::endl;
  //  std::vector<Sample> s = Nov10thDiJetPtUpdatedSlimHistos();
  //std::vector<Sample> s = Nov10Fall1160MTopSlimHistos();
  std::vector<Sample> s = Nov10Fall1160MTopIVFHistos();

  Sample data(1,"fake data","S1.root",0,true,1000);

  if(debug_)
    std::cout << "Init the data sample" << std::endl;
  for(size_t i=0;i< s.size();i++) if(s[i].data) {data=s[i];break;}

  if(debug_)
    std::cout << "Ls data sample" << std::endl;
  data.file()->ls(); 

  if(debug_)
    std::cout << "Init the mc sample" << std::endl;
  for(size_t i=0;i< s.size();i++) s[i].dump(1,fa,fb);

  std::vector<std::string> names;

  if(debug_)
    std::cout << "Get List of Keys" << std::endl;
  TList * subs = data.file()->GetListOfKeys();
  for(size_t i=0;i< subs->GetSize();i++)
    {
      TString nn = subs->At(i)->GetName();
      if( nn.Contains(TRegexp("Count*")) )
	continue;
      if(debug_)
	std::cout << "Get List of Keys in subdirs" << std::endl;
      TList * objs = ((TDirectoryFile *)data.file()->Get(subs->At(i)->GetName()))->GetListOfKeys();
      for(size_t j=0;j< objs->GetSize();j++)
	{
	  if(debug_)
	    std::cout << "Name = " << subs->At(i)->GetName()+std::string("/")  + objs->At(j)->GetName() << std::endl;
	  names.push_back(subs->At(i)->GetName()+std::string("/")  + objs->At(j)->GetName());
	  //      std::cout << subs->At(i)->GetName() << "/"  << objs->At(j)->GetName() << std::endl;
	  //TODO: select plots via regexp
	}
    }


  if(debug_)
    std::cout << "Starting plotting" << std::endl;

  std::string process;

  for(size_t i = 0 ; i < names.size() ; i++) 
    {
      
      std::map<std::string,TH1F *> grouped;
      TString n=names[i];
      //      if(!n.Contains(TRegexp("VlightRegionHZee/HiggsPtVlightRegionHZee"))) continue;
      //      if(!n.Contains(TRegexp("VlightRegionHZee/ZPtVlightRegionHZee"))) continue;
      //      if(!n.Contains(TRegexp("VlightRegionHZee"))) continue;
      //      if(!n.Contains(TRegexp("ZSVRegionZmmSV"))) continue;
      //      if(!n.Contains(TRegexp("ZSVRegionZeeSV"))) continue;
      //      if(!n.Contains(TRegexp("ZSVRegionZcombSV"))) continue;
      //      if(!n.Contains(TRegexp("ZSVPureRegionZcombSV"))) continue;
      //      if(!n.Contains(TRegexp("ZSVTTbarPureRegionZcombSV"))) continue;
      if(!n.Contains(TRegexp("TTbarRegionZeeSVJets"))) continue;

      if(n.Contains(TRegexp("RegionHZcomb")))
	process = "Z(l^{+}l^{-})H(b#bar{b})";
      if(n.Contains(TRegexp("RegionHZmm")))
	process = "Z(#mu^{+}#mu^{-})H(b#bar{b})";
      if(n.Contains(TRegexp("RegionHZee")))
	process = "Z(e^{+}e^{-})H(b#bar{b})";

      if(debug_)
	std::cout << "Creating the Canvas" << std::endl;

      TCanvas *c = new TCanvas();
      c->SetLogy(false);
      c->SetTitle(names[i].c_str());

      if(debug_)
	std::cout << "Creating histograms" << std::endl;
  
      TH1F *hd = ((TH1F*)data.file()->Get(names[i].c_str()));
      hd->Sumw2();
      Options o=options[names[i]];
      //      hd->Rebin(o.rebin);
      hd->SetMarkerStyle(20);
      hd->GetXaxis()->SetLabelOffset(99);
      hd->SetYTitle(o.yaxis.c_str());
      double nbin = hd->GetNbinsX();
      double min_bin = hd->GetXaxis()->GetXmin();
      double max_bin = hd->GetXaxis()->GetXmax();
      TH1F *hmc = new TH1F("hmc","hmc", nbin, min_bin, max_bin);
      hmc->SetFillColor(kWhite);
      hmc->Sumw2();
      //      hmc->Rebin(o.rebin);

      if(debug_)
	std::cout << "Creating the THStack and Legend" << std::endl;
      THStack * sta = new THStack("sta",hd->GetTitle());
      TLegend * l = new TLegend(o.legendx1,o.legendy1,o.legendx2,o.legendy2); //0.7,0.1,0.9,0.6);
      l->SetFillColor(kWhite);
      l->SetBorderSize(0);
      l->SetTextFont(62);
      l->SetTextSize(0.03);
      if(debug_)
	std::cout << "Adding data to the legend" << std::endl;  
      l->AddEntry(hd, "Data","P");
      if(debug_)
	std::cout << "Adding MC to the THStack" << std::endl;  

      //with the proper trigger eff
      //      double SF[] = {1.01,1.03,1.00};
      //      double SF[] = {1.03,1.054,1.032};
      double SF[] = {1.0,1.0,1.0};

      if(debug_){
	for(int i = 0; i< 3; ++i)
	  std::cout << "SF [" << i << "] = " << SF[i] << std::endl;
      }

      double mcIntegral=0;
      for(size_t j=0;j< s.size() ;j++) 
	{ 
	  if(!s[j].data) 
	    {
	      if(debug_)
		std::cout << "Creating TH1F from file " << s[j].name << std::endl;  
	      TH1F * h = ((TH1F*)s[j].file()->Get(names[i].c_str()));
	      h->Sumw2();
	      if(debug_){
		std::cout << "TH1F created from file " << s[j].name << std::endl;  
		std::cout << "Scaling : " << s[j].scale(data.lumi(),fa,fb) << std::endl;  
		std::cout << "Scaling with SF : " << s[j].scale(data.lumi(),fa,fb,SF) << std::endl;  
		std::cout << "Histo integral before scaling = " << h->Integral() << std::endl;
	      }
	      h->Scale(s[j].scale(data.lumi(),fa,fb,SF));
	      if(debug_){
		std::cout << "Histo integral after scaling = " << h->Integral() << std::endl;
		std::cout << "Managing style... " << std::endl;  
	      }
	      h->SetLineWidth(1.);
	      h->SetFillColor(s[j].color);
	      h->SetLineColor(s[j].color);
	      //	      h->Rebin(options[names[i]].rebin);
	      if(debug_)
		std::cout << "Cloning and update legend " << std::endl;  
	      if(grouped.find(s[j].name) == grouped.end()){
		l->AddEntry(h,s[j].name.c_str(),"F");
	      }
	      std::cout << "Sample : " << s[j].name << " - Integral for plot " << names[i] << " = " << h->Integral(-10000,10000) << std::endl;
	      mcIntegral += h->Integral();
	      sta->Add(h);
	      hmc->Add(h);	      
	      //TO FIX grouped map
	      // sovrascrive histo con lo stesso nome tipo VV o ST etc...
	      grouped[s[j].name]=(TH1F *)h->Clone(("_"+names[i]).c_str());
	    }
	}

      if(debug_){
	std::cout << "Data total = " << hd->Integral() << std::endl;
	std::cout << "MC = " << mcIntegral << std::endl;
	std::cout << "Data/MC = " << hd->Integral()/mcIntegral << std::endl;
      }

      TPad * TopPad = new TPad("TopPad","Top Pad",0.,0.3,1.,1. ) ;
      TPad * BtmPad = new TPad("BtmPad","Bottom Pad",0.,0.,1.,0.313 ) ;
      TopPad->SetBottomMargin(0.02);
      BtmPad->SetTopMargin(0.0);
      BtmPad->SetFillStyle(4000);
      TopPad->SetFillStyle(4000);
      BtmPad->SetFillColor(0);
      BtmPad->SetBottomMargin(0.35);
      TopPad->Draw() ;
      BtmPad->Draw() ;
      std::cout << "hd maximum = " << hd->GetMaximum() << "  sta maximum = " << sta->GetMaximum() << std::endl;
      double maxY;
      if(hd->GetMaximum() > sta->GetMaximum()) maxY = (hd->GetMaximum())*1.5;
      else maxY = (sta->GetMaximum())*1.5;
      TopPad->cd();
      hd->Draw("E1X0");
      sta->Draw("sameHIST");
      hmc->Draw("sameE2");
      hmc->SetFillColor(2);
      hmc->SetMarkerSize(0);
      hmc->SetFillStyle(3013);
      hd->Draw("E1X0same");
      l->Draw("same");
      std::cout << "Set Maximum to = " << maxY << std::endl;
      hd->GetYaxis()->SetRangeUser(0.,maxY);
      hd->GetXaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max);

      BtmPad->cd();
      std::cout << "Division" << std::endl;

      TH1D * divisionErrorBand = (TH1D*)(hmc)->Clone("divisionErrorBand");
      divisionErrorBand->Sumw2();
      divisionErrorBand->Divide(hmc);
      divisionErrorBand->Draw("E2");      
      divisionErrorBand->SetMaximum(2.49);
      divisionErrorBand->SetMinimum(0);
      divisionErrorBand->SetMarkerStyle(20);
      divisionErrorBand->SetMarkerSize(0.55);
      divisionErrorBand->GetXaxis()->SetTitleOffset(1.12);
      divisionErrorBand->GetXaxis()->SetLabelSize(0.12);
      divisionErrorBand->GetXaxis()->SetTitleSize(0.5);
      divisionErrorBand->GetYaxis()->SetTitle("Data/MC");
      divisionErrorBand->GetYaxis()->SetLabelSize(0.12);
      divisionErrorBand->GetYaxis()->SetTitleSize(0.12);
      divisionErrorBand->GetYaxis()->SetTitleOffset(0.40);
      divisionErrorBand->GetYaxis()->SetNdivisions(505);
      //divisionErrorBand->UseCurrentStyle();
      divisionErrorBand->SetFillColor(2);
      divisionErrorBand->SetFillStyle(3001);
      divisionErrorBand->SetMarkerSize(0.);

      TH1D * division = (TH1D*)(hd)->Clone("division");
      division->Sumw2();
      division->Divide(hmc);
//       division->SetMaximum(2.5);
//       division->SetMinimum(0);
//       division->SetMarkerStyle(20);
//       division->SetMarkerSize(0.55);
//       division->GetXaxis()->SetLabelSize(0.12);
//       division->GetXaxis()->SetTitleSize(0.14);
//       division->GetYaxis()->SetLabelSize(0.10);
//       division->GetYaxis()->SetTitleSize(0.10);
//      division->GetYaxis()->SetTitle("Data/MC");
      Double_t min = division->GetXaxis()->GetXmin();
      Double_t max = division->GetXaxis()->GetXmax();
      division->Draw("E1X0same");

      TLine *line = new TLine(min, 1.0, max, 1.0);
      line->SetLineColor(kRed);
      line->Draw("same");
      
      TLegend * leg3 =new TLegend(0.50,0.86,0.69,0.96);
      leg3->AddEntry(divisionErrorBand,"MC uncert. (stat.)","f");
      leg3->SetFillColor(0);
      leg3->SetLineColor(0);
      leg3->SetShadowColor(0);
      leg3->SetTextFont(62);
      leg3->SetTextSize(0.06);
      leg3->Draw();

      TPaveText *pave = new TPaveText(0.15,0.85,0.32,0.96,"brNDC");
      pave->SetTextAlign(12);
      pave->SetLineColor(0);
      pave->SetFillColor(0);
      pave->SetShadowColor(0);
      //TText *text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f",histDt->Chi2Test(histCopyMC5,"UWCHI2/NDF"),histDt->KolmogorovTest(histCopyMC5))); // stat + sys
      TText *text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f",hd->Chi2Test(hmc,"UWCHI2/NDF"),hd->KolmogorovTest(hmc))); // stat only
      text->SetTextFont(62);
      text->SetTextSize(0.08);
      pave->Draw();

      TopPad->cd();
      TLatex latex;
      latex.SetNDC();
      latex.SetTextAlign(12);
      latex.SetTextSize(0.052);
      latex.DrawLatex(0.17,0.89,"CMS Preliminary");
      latex.SetTextSize(0.04);
      latex.DrawLatex(0.17,0.84,"#sqrt{s} = 7 TeV, L = 4.7 fb^{-1}");
      //      latex.DrawLatex(0.17,0.79,"Z(e^{+}e^{-})H(b#bar{b})");
      latex.DrawLatex(0.17,0.79,process.c_str());
      c->Update();
      std::string cName= hd->GetName();
      cName += "_bare.pdf";
      cName = path+cName;
      c->Print(cName.c_str(),"pdf");

//       std::cout << names[i] << " d: " <<  hd->Integral() << " ";
//       THStack * sta2 = new THStack("sta2",hd->GetTitle());
//       float tot=0;
//       float toterr2=0;

//       if(debug_)
// 	std::cout << "Putting the iterator in the for loop" << std::endl;
//       for(std::map<std::string,TH1F *>::reverse_iterator it=grouped.rbegin(); it!=grouped.rend();++it)
//  	{
// 	  if(debug_)
// 	    std::cout << "Using the iterator" << std::endl;
// 	  std::cout << (*it).first << " " << (*it).second->Integral() << " | " << std::endl ;
// 	  if((*it).second->GetEntries() > 0) {
// 	    float er=1.*sqrt((*it).second->GetEntries())/(*it).second->GetEntries()*(*it).second->Integral();
// 	    toterr2+=er*er;
// 	  }
// 	  tot+=(*it).second->Integral();
// 	  sta2->Add(it->second);
//  	}
//       std::cout << " Tot: " << tot << "+-" << sqrt(toterr2) <<  " SF: " << hd->Integral()/tot << std::endl;
//       TCanvas *c2 = new TCanvas();
//       c2->SetTitle(names[i].c_str());
//       std::cout << "hd maximum = " << hd->GetMaximum() << "  sta2 maximum = " << sta2->GetMaximum() << std::endl;
//       if(hd->GetMaximum() > sta2->GetMaximum()) maxY =  hd->GetBinContent(hd->GetMaximumBin()) * 1.5;
//       else maxY = ( sta2->GetMaximum())*1.5;
//       //      hd->Draw("E1"); 
//       sta2->Draw("PADSHIST");
//       //    hd->Draw("E1same");
//       //      l->Draw("same");
//       std::cout << "Set Maximum to = " << maxY << std::endl;
//       hd->GetYaxis()->SetRangeUser(0.,maxY);
//       hd->GetXaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max);
//       c2->Update();

//       std::string c2Name = hd->GetName();
//       c2Name = path+c2Name;
//       c2Name += "_norm.pdf";
//       c2->Print(c2Name.c_str(),"pdf");  

    }

}
MatrixMethod_Results_PullTest_EMu(string selection, string eventType){


  float NjetsMin = -0.5;
  float NjetsMax = 5.5;

  gROOT->SetStyle("Plain");
  gStyle->SetOptStat(0);
  
  TFile * file_Expected   = new TFile("MatrixMethod_OutPut_EMuCase_MC_Fast_PullTest.root");
  TFile * file_Estimated  = new TFile("MatrixMethod_OutPut_EMuCase_MC_Fast_PullTest.root");

  file_Expected->cd();
  TH1F* tt_TTDilept  = (TH1F*)gROOT->FindObject("MMExpected_TTEMu_TTbarSignal");
  TH1F* tl_TTDilept = (TH1F*)gROOT->FindObject("MMExpected_TLEMu_TTbarSignal");
  TH1F* lt_TTDilept  = (TH1F*)gROOT->FindObject("MMExpected_LTEMu_TTbarSignal");
  TH1F* ll_TTDilept  = (TH1F*)gROOT->FindObject("MMExpected_LLEMu_TTbarSignal");

  tt_TTDilept->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  tl_TTDilept->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  lt_TTDilept->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  ll_TTDilept->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);

  TH1F* tt_TTSemi_TF  = (TH1F*)gROOT->FindObject("MMExpected_TTEMu_TTbarSemileptonic_TF");
  TH1F* tl_TTSemi_TF = (TH1F*)gROOT->FindObject("MMExpected_TLEMu_TTbarSemileptonic_TF");
  TH1F* lt_TTSemi_TF  = (TH1F*)gROOT->FindObject("MMExpected_LTEMu_TTbarSemileptonic_TF");
  TH1F* ll_TTSemi_TF  = (TH1F*)gROOT->FindObject("MMExpected_LLEMu_TTbarSemileptonic_TF");

  tt_TTSemi_TF->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  tl_TTSemi_TF->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  lt_TTSemi_TF->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  ll_TTSemi_TF->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);

  TH1F* tt_TTSemi_FT  = (TH1F*)gROOT->FindObject("MMExpected_TTEMu_TTbarSemileptonic_FT");
  TH1F* tl_TTSemi_FT = (TH1F*)gROOT->FindObject("MMExpected_TLEMu_TTbarSemileptonic_FT");
  TH1F* lt_TTSemi_FT  = (TH1F*)gROOT->FindObject("MMExpected_LTEMu_TTbarSemileptonic_FT");
  TH1F* ll_TTSemi_FT  = (TH1F*)gROOT->FindObject("MMExpected_LLEMu_TTbarSemileptonic_FT");

  tt_TTSemi_FT->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  tl_TTSemi_FT->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  lt_TTSemi_FT->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  ll_TTSemi_FT->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);

  TH1F* tt_TTBckg  = (TH1F*)gROOT->FindObject("MMExpected_TTEMu_TTbar");
  TH1F* tl_TTBckg = (TH1F*)gROOT->FindObject("MMExpected_TLEMu_TTbar");
  TH1F* lt_TTBckg  = (TH1F*)gROOT->FindObject("MMExpected_LTEMu_TTbar");
  TH1F* ll_TTBckg  = (TH1F*)gROOT->FindObject("MMExpected_LLEMu_TTbar");

  tt_TTBckg->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  tl_TTBckg->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  lt_TTBckg->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  ll_TTBckg->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);

  tt_TTDilept->SetFillColor(kRed+1);
  tl_TTDilept->SetFillColor(kRed+1);
  lt_TTDilept->SetFillColor(kRed+1);
  ll_TTDilept->SetFillColor(kRed+1);

  tt_TTSemi_TF->SetFillColor(kRed-7);
  tl_TTSemi_TF->SetFillColor(kRed-7);
  lt_TTSemi_TF->SetFillColor(kRed-7);
  ll_TTSemi_TF->SetFillColor(kRed-7);

  tt_TTSemi_FT->SetFillColor(kRed-4);
  tl_TTSemi_FT->SetFillColor(kRed-4);
  lt_TTSemi_FT->SetFillColor(kRed-4);
  ll_TTSemi_FT->SetFillColor(kRed-4);

  tt_TTBckg->SetFillColor(kRed-7);
  tl_TTBckg->SetFillColor(kRed-7);
  lt_TTBckg->SetFillColor(kRed-7);
  ll_TTBckg->SetFillColor(kRed-7);
  
  THStack* ttSignalLike = new THStack("ttSignalLike","tt signal like");
  ttSignalLike->Add(tt_TTDilept);
  THStack* tlSignalLike = new THStack("tlSignalLike","tl signal like");
  tlSignalLike->Add(tl_TTDilept);
  THStack* ltSignalLike = new THStack("ltSignalLike","lt signal like");
  ltSignalLike->Add(lt_TTDilept);
  THStack* llSignalLike = new THStack( "llSignalLike", "ll signal like");
  llSignalLike->Add(ll_TTDilept);

  THStack* ttWLike = new THStack( "ttWLike"," tt W-like" );
  ttWLike->Add(tt_TTSemi_TF);
  ttWLike->Add(tt_TTSemi_FT);
  THStack* tlWLike = new THStack("tlWLike","tl W-like");
  tlWLike->Add(tl_TTSemi_TF);
  tlWLike->Add(lt_TTSemi_FT);
  THStack* ltWLike = new THStack( "ltWLike", "lt W-like" );
  ltWLike->Add(lt_TTSemi_TF);
  ltWLike->Add(tl_TTSemi_FT);
  THStack* llWLike = new THStack( "llWLike", "ll W-like" );
  llWLike->Add(ll_TTSemi_TF);
  llWLike->Add(ll_TTSemi_FT);
  
  THStack* ttQCDLike = new THStack("ttQCDLike",  "tt QCD-like" );
  ttQCDLike->Add(tt_TTBckg);
  THStack* tlQCDLike = new THStack("tlQCDLike","tl QCD-like");
  tlQCDLike->Add(tl_TTBckg);
  THStack* ltQCDLike = new THStack("ltQCDLike","lt QCD-like");
  ltQCDLike->Add(lt_TTBckg);
  THStack* llQCDLike = new THStack("llQCDLike",  "ll QCD-like" );
  llQCDLike->Add(ll_TTBckg);

  
  file_Estimated->cd();
  
  TH1F* estimate_LL_QCD  = (TH1F*)gROOT->FindObject("MMEstimated_LLEMu_FF" );
  TH1F* estimate_TT_QCD  = (TH1F*)gROOT->FindObject("MMEstimated_TTEMu_FF" );
  TH1F* estimate_TL_QCD = (TH1F*)gROOT->FindObject("MMEstimated_TLEMu_FF");
  TH1F* estimate_LT_QCD = (TH1F*)gROOT->FindObject("MMEstimated_LTEMu_FF");

  estimate_LL_QCD->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  estimate_TT_QCD->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  estimate_TL_QCD->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  estimate_LT_QCD->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);

  // Be careful, here TF and FT estimates are added together to give WJets-like estimate
  TH1F* estimate_LL_TF  = (TH1F*)gROOT->FindObject("MMEstimated_LLEMu_TF" );
  TH1F* estimate_TT_TF  = (TH1F*)gROOT->FindObject("MMEstimated_TTEMu_TF" );
  TH1F* estimate_LT_TF = (TH1F*)gROOT->FindObject("MMEstimated_LTEMu_TF");
  TH1F* estimate_TL_TF = (TH1F*)gROOT->FindObject("MMEstimated_TLEMu_TF");

  TH1F* estimate_LL_WJets  = (TH1F*)gROOT->FindObject("MMEstimated_LLEMu_FT" );
  TH1F* estimate_TT_WJets = (TH1F*)gROOT->FindObject("MMEstimated_TTEMu_FT" );
  TH1F* estimate_LT_WJets = (TH1F*)gROOT->FindObject("MMEstimated_LTEMu_FT");
  TH1F* estimate_TL_WJets = (TH1F*)gROOT->FindObject("MMEstimated_TLEMu_FT");

  estimate_LL_WJets->Add(estimate_LL_TF, estimate_LL_WJets, 1, 1);
  estimate_TT_WJets->Add(estimate_TT_TF, estimate_TT_WJets, 1, 1);
  estimate_LT_WJets->Add(estimate_LT_TF, estimate_LT_WJets, 1, 1);
  estimate_TL_WJets->Add(estimate_TL_TF, estimate_TL_WJets, 1, 1);
  ///////

  estimate_LL_WJets->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  estimate_TT_WJets->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  estimate_LT_WJets->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  estimate_TL_WJets->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);

  TH1F* estimate_LL_Signal  = (TH1F*)gROOT->FindObject("MMEstimated_LLEMu_TT" );
  TH1F* estimate_TT_Signal  = (TH1F*)gROOT->FindObject("MMEstimated_TTEMu_TT" );
  TH1F* estimate_TL_Signal = (TH1F*)gROOT->FindObject("MMEstimated_TLEMu_TT");
  TH1F* estimate_LT_Signal = (TH1F*)gROOT->FindObject("MMEstimated_LTEMu_TT");

  estimate_LL_Signal->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  estimate_TT_Signal->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  estimate_TL_Signal->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
  estimate_LT_Signal->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);

  title = new TLatex(10.,10.,"CMS preliminary");
  title->SetNDC();
  title->SetTextAlign(12);
  title->SetX(0.60);
  title->SetY(0.70);
  title->SetTextFont(42);
  title->SetTextSize(0.04);
  title->SetTextSizePixels(24);
    
  TLegend* qw = 0;
  qw = new TLegend(0.70,0.75,0.95,0.95);
  qw->SetFillColor(kWhite);

  if( selection == "TT"){
    
    
    if(eventType == "Signal"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_TT_Signal->SetMarkerStyle(20);
      estimate_TT_Signal->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_TT_Signal->GetYaxis()->SetTitle("Number of events");
      estimate_TT_Signal->GetYaxis()->SetLabelSize(0.025);
      estimate_TT_Signal->SetTitle("Signal-like e#mu (tight-tight)");
      estimate_TT_Signal->Draw();
      ttSignalLike->Draw("hesame");
      estimate_TT_Signal->Draw("same");
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, tt_TTDilept);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(tt_TTDilept, " t#bar{t} signal ","f");
      qw->AddEntry(estimate_TT_Signal,    " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("TTSignalEMu_PullTest.pdf");
    }
    
    
    if(eventType == "Wlike"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_TT_WJets->SetMarkerStyle(20);
      estimate_TT_WJets->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_TT_WJets->GetYaxis()->SetTitle("Number of events");
      estimate_TT_WJets->GetYaxis()->SetLabelSize(0.025);
      estimate_TT_WJets->SetTitle("W+jets-like e#mu (tight-tight)");
      estimate_TT_WJets->Draw();
      ttWLike->Draw("hesame");
      estimate_TT_WJets->Draw("same");
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, tt_TTSemi_TF);
      tmp->Add(tmp, tt_TTSemi_FT);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(tt_TTSemi_TF, " t#bar{t} semileptonic TF","f");
      qw->AddEntry(tt_TTSemi_FT, " t#bar{t} semileptonic FT","f");
      qw->AddEntry(estimate_TT_WJets,    " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("TTWlikeEMu_PullTest.pdf");
    }
    
    
    if(eventType == "QCDlike"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_TT_QCD->SetMarkerStyle(20);
      estimate_TT_QCD->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_TT_QCD->GetYaxis()->SetTitle("Number of events");
      estimate_TT_QCD->GetYaxis()->SetLabelSize(0.025);
      estimate_TT_QCD->SetTitle("QCD-like e#mu (tight-tight)");
      estimate_TT_QCD->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_TT_QCD->Draw();
      ttQCDLike->Draw("hesame");
      estimate_TT_QCD->Draw("same");
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, tt_TTBckg);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      estimate_TT_QCD->Draw("same");
      thegraph->Draw("e2same");
      qw->AddEntry(tt_TTBckg, " t#bar{t} hadronic ","f");
      qw->AddEntry(estimate_TT_QCD, " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("TTQCDEMu_PullTest.pdf");      
    }
    
    
  }
  
  if( selection == "LT"){
    
    
    if(eventType == "Signal"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_LT_Signal->SetMarkerStyle(20);
      estimate_LT_Signal->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_LT_Signal->GetYaxis()->SetTitle("Number of events");
      estimate_LT_Signal->GetYaxis()->SetLabelSize(0.025);
      estimate_LT_Signal->SetTitle("Signal-like e#mu (loose-tight)");
      estimate_LT_Signal->Draw();
      ltSignalLike->Draw("hesame");
      estimate_LT_Signal->Draw("same");
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, lt_TTDilept);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(lt_TTDilept, " t#bar{t} signal ","f");
      qw->AddEntry(estimate_LT_Signal,    " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("LTSignalEMu_PullTest.pdf");
    }
    
    
    if(eventType == "Wlike"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_LT_WJets->SetMarkerStyle(20);
      estimate_LT_WJets->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_LT_WJets->GetYaxis()->SetTitle("Number of events");
      estimate_LT_WJets->GetYaxis()->SetLabelSize(0.025);
      estimate_LT_WJets->SetTitle("W+jets-like e#mu (loose-tight)");
      estimate_LT_WJets->Draw();
      ltWLike->Draw("hesame");
      estimate_LT_WJets->Draw("same");
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, tl_TTSemi_TF);
      tmp->Add(tmp, lt_TTSemi_FT);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(tl_TTSemi_TF, " t#bar{t} semileptonic TF","f");
      qw->AddEntry(lt_TTSemi_FT, " t#bar{t} semileptonic FT","f");
      qw->AddEntry(estimate_LT_WJets,    " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("LTWlikeEMu_PullTest.pdf");      
    }
    
    
    if(eventType == "QCDlike"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_LT_QCD->SetMarkerStyle(20);
      estimate_LT_QCD->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_LT_QCD->GetYaxis()->SetTitle("Number of events");
      estimate_LT_QCD->GetYaxis()->SetLabelSize(0.025);
      estimate_LT_QCD->SetTitle("QCD-like e#mu (loose-tight)");
      estimate_LT_QCD->Draw();
      ltQCDLike->Draw("hesame");
      estimate_LT_QCD->Draw("same"); 
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, lt_TTBckg);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(lt_TTBckg, " t#bar{t} hadronic ","f");
      qw->AddEntry(estimate_LT_QCD, " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("LTQCDEMu_PullTest.pdf");      
    }
    
    
  }






  if( selection == "TL"){
    
    
    if(eventType == "Signal"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_TL_Signal->SetMarkerStyle(20);
      estimate_TL_Signal->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_TL_Signal->GetYaxis()->SetTitle("Number of events");
      estimate_TL_Signal->GetYaxis()->SetLabelSize(0.025);
      estimate_TL_Signal->SetTitle("Signal-like e#mu (tight-loose)");
      estimate_TL_Signal->Draw();
      estimate_TL_Signal->Draw();
      tlSignalLike->Draw("hesame");
      estimate_TL_Signal->Draw("same");
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, tl_TTDilept);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(tl_TTDilept, " t#bar{t} signal ","f");
      qw->AddEntry(estimate_TL_Signal,    " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("TLSignalEMu_PullTest.pdf");
    }
    
    
    if(eventType == "Wlike"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_TL_WJets->SetMarkerStyle(20);
      estimate_TL_WJets->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_TL_WJets->GetYaxis()->SetTitle("Number of events");
      estimate_TL_WJets->GetYaxis()->SetLabelSize(0.025);
      estimate_TL_WJets->SetTitle("W+jets-like e#mu (tight-loose)");
      estimate_TL_WJets->Draw();
      tlWLike->Draw("hesame");
      estimate_TL_WJets->Draw("same");
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, tl_TTSemi_TF);
      tmp->Add(tmp, lt_TTSemi_FT);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(tl_TTSemi_TF, " t#bar{t} semileptonic TF","f");
      qw->AddEntry(lt_TTSemi_FT, " t#bar{t} semileptonic FT","f");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("TLWlikeEMu_PullTest.pdf");      
    }
    
    
    if(eventType == "QCDlike"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_TL_QCD->SetMarkerStyle(20);
      estimate_TL_QCD->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_TL_QCD->GetYaxis()->SetTitle("Number of events");
      estimate_TL_QCD->GetYaxis()->SetLabelSize(0.025);
      estimate_TL_QCD->SetTitle("QCD-like e#mu (tight-loose)");
      estimate_TL_QCD->Draw();
      tlQCDLike->Draw("hesame");
      estimate_TL_QCD->Draw("same"); 
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, tl_TTBckg);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(tl_TTBckg, " t#bar{t} hadronic ","f");
      qw->AddEntry(estimate_TL_QCD, " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("TLQCDEMu_PullTest.pdf");      
    }
    
    
  }









  
  
  
  
  
  if( selection == "LL"){
    
    
    if(eventType == "Signal"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_LL_Signal->SetMarkerStyle(20);
      estimate_LL_Signal->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_LL_Signal->GetYaxis()->SetTitle("Number of events");
      estimate_LL_Signal->GetYaxis()->SetLabelSize(0.025);
      estimate_LL_Signal->SetTitle("Signal-like e#mu (loose-loose)");
      estimate_LL_Signal->Draw();
      llSignalLike->Draw("hesame");
      estimate_LL_Signal->Draw("same");
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, ll_TTDilept);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(ll_TTDilept, " t#bar{t} signal ","f");
      qw->AddEntry(estimate_LL_Signal,    " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("LLSignalEMu_PullTest.pdf");      
    }
    
    
    if(eventType == "Wlike"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_LL_WJets->SetMarkerStyle(20);
      estimate_LL_WJets->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_LL_WJets->GetYaxis()->SetTitle("Number of events");
      estimate_LL_WJets->GetYaxis()->SetLabelSize(0.025);
      estimate_LL_WJets->SetTitle("W+jets-like e#mu (loose-loose)");
      estimate_LL_WJets->Draw();
      llWLike->Draw("hesame");
      estimate_LL_WJets->Draw("same");
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, ll_TTSemi_TF);
      tmp->Add(tmp, ll_TTSemi_FT);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(ll_TTSemi_TF, " t#bar{t} semileptonic TF","f");
      qw->AddEntry(ll_TTSemi_FT, " t#bar{t} semileptonic FT","f");
      qw->AddEntry(estimate_LL_WJets,    " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("LLWlikeEMu_PullTest.pdf");      
    }
    
    
    if(eventType == "QCDlike"){
      TCanvas * canv = new TCanvas(("canvPullTest_EMu_"+selection+eventType).c_str(), ("canvPullTest_EMu_"+selection+eventType).c_str(), 600, 800);
      estimate_LL_QCD->SetMarkerStyle(20);
      estimate_LL_QCD->GetXaxis()->SetTitle("Jet multiplicity");
      estimate_LL_QCD->GetYaxis()->SetTitle("Number of events");
      estimate_LL_QCD->GetYaxis()->SetLabelSize(0.025);
      estimate_LL_QCD->SetTitle("QCD-like e#mu (loose-loose)");
      estimate_LL_QCD->Draw(); 
      llQCDLike->Draw("hesame");
      estimate_LL_QCD->Draw("same"); 
      TH1F * tmp  = new TH1F("tmp",  "tmp",  11, -0.5,  10.5);
      tmp->GetXaxis()->SetRangeUser(NjetsMin,NjetsMax);
      tmp->Add(tmp, ll_TTBckg);
      TGraphErrors *thegraph = new TGraphErrors(tmp);
      thegraph->SetFillStyle(3005);
      thegraph->SetFillColor(1);
      thegraph->Draw("e2same");
      qw->AddEntry(ll_TTBckg, " t#bar{t} hadronic ","f");
      qw->AddEntry(estimate_LL_QCD, " Matrix Method  ","p");
      qw->Draw("same");
      title->Draw("same");
      canv->SaveAs("LLQCDEMu_PullTest.pdf");      
    }
    
    
  }
   
 
 
}
示例#28
0
void doStackGen() {

  TStyle *simpleStyle = new TStyle("simpleStyle","");
  simpleStyle->SetCanvasColor(0);
  simpleStyle->SetFrameFillColor(0);
  simpleStyle->SetStatColor(0);
  simpleStyle->SetOptStat(0);
  simpleStyle->SetTitleFillColor(0);
  simpleStyle->SetCanvasBorderMode(0);
  simpleStyle->SetPadBorderMode(0);
  simpleStyle->SetFrameBorderMode(0);
  simpleStyle->cd();

  TFile* inFile = TFile::Open("RxGenOutputFile.root");



  TH1D* h1_RchGen_vs_eta = (TH1D*)inFile->Get("RchGen_vs_eta");
  TH1D* h1_RgammaGen_vs_eta = (TH1D*)inFile->Get("RgammaGen_vs_eta");
  TH1D* h1_RnhGen_vs_eta = (TH1D*)inFile->Get("RnhGen_vs_eta");
//  TH1D* h1_RmuGen_vs_eta = (TH1D*)inFile->Get("RmuGen_vs_eta_PFItCone5");

  int nBinsX_RchGen = h1_RchGen_vs_eta->GetNbinsX();
  int nBinsX_RgammaGen = h1_RgammaGen_vs_eta->GetNbinsX();
  int nBinsX_RnhGen = h1_RnhGen_vs_eta->GetNbinsX();
//  int nBinsX_RmuGen = h1_RmuGen_vs_eta->GetNbinsX();

  double minX_RchGen = h1_RchGen_vs_eta->GetXaxis()->GetXmin();
  double maxX_RchGen = h1_RchGen_vs_eta->GetXaxis()->GetXmax();

  double minX_RgammaGen = h1_RgammaGen_vs_eta->GetXaxis()->GetXmin();
  double maxX_RgammaGen = h1_RgammaGen_vs_eta->GetXaxis()->GetXmax();

  double minX_RnhGen = h1_RnhGen_vs_eta->GetXaxis()->GetXmin();
  double maxX_RnhGen = h1_RnhGen_vs_eta->GetXaxis()->GetXmax();

//  double minX_RmuGen = h1_RmuGen_vs_eta->GetXaxis()->GetXmin();
//  double maxX_RmuGen = h1_RmuGen_vs_eta->GetXaxis()->GetXmax();

  TH1D* h1_RchGen_vs_eta_stack = new TH1D("RchGen_vs_eta_stack", "", nBinsX_RchGen, minX_RchGen, maxX_RchGen);
  h1_RchGen_vs_eta_stack->SetFillColor(kRed);
  h1_RchGen_vs_eta_stack->SetXTitle("#eta^{GEN}");
 
  TH1D* h1_RgammaGen_vs_eta_stack = new TH1D("RgammaGen_vs_eta_stack", "", nBinsX_RgammaGen, minX_RgammaGen, maxX_RgammaGen);
  h1_RgammaGen_vs_eta_stack->SetFillColor(kGreen);
  h1_RgammaGen_vs_eta_stack->SetXTitle("#eta^{GEN}");

  TH1D* h1_RnhGen_vs_eta_stack = new TH1D("RnhGen_vs_eta_stack", "", nBinsX_RnhGen, minX_RnhGen, maxX_RnhGen);
  h1_RnhGen_vs_eta_stack->SetFillColor(kBlue);
  h1_RnhGen_vs_eta_stack->SetXTitle("#eta^{GEN}");

//  TH1D* h1_RmuGen_vs_eta_stack = new TH1D("RmuGen_vs_eta", "", nBinsX_RmuGen, minX_RmuGen, maxX_RmuGen);
//  h1_RmuGen_vs_eta_stack->SetFillColor(kYellow);
 // h1_RmuGen_vs_eta_stack->SetXTitle("#eta^{GEN}");

  for(int i=1; i<101; ++i) {
    h1_RchGen_vs_eta_stack->SetBinContent( i, h1_RchGen_vs_eta->GetBinContent(i) );
    h1_RgammaGen_vs_eta_stack->SetBinContent( i, h1_RgammaGen_vs_eta->GetBinContent(i) );
    h1_RnhGen_vs_eta_stack->SetBinContent( i, h1_RnhGen_vs_eta->GetBinContent(i) );
//    h1_RmuGen_vs_eta_stack->SetBinContent( i, h1_RmuGen_vs_eta->GetBinContent(i) );
  }


  THStack* stack = new THStack("stack", "");
  stack->Add(h1_RchGen_vs_eta_stack);
  stack->Add(h1_RgammaGen_vs_eta_stack);
  stack->Add(h1_RnhGen_vs_eta_stack);
//  stack->Add(h1_RmuGen_vs_eta_stack);
  stack->Draw();
  stack->GetXaxis()->SetTitle("#eta^{GEN}");
  stack->GetYaxis()->SetTitle("% of Jet Energy");

  TCanvas* c1 = new TCanvas("c1", "c1", 800, 600);
  c1->cd();
  stack->Draw();
  c1->SaveAs("Plots/genstack_vs_eta.eps");

  TH1D* h1_Rnh_neutron_vs_eta = (TH1D*)inFile->Get("Rnh_neutron_vs_eta");
  TH1D* h1_Rnh_K0L_vs_eta = (TH1D*)inFile->Get("Rnh_K0L_vs_eta");
  TH1D* h1_Rnh_K0S_vs_eta = (TH1D*)inFile->Get("Rnh_K0S_vs_eta");
  TH1D* h1_Rnh_lambda_vs_eta = (TH1D*)inFile->Get("Rnh_lambda_vs_eta");
  TH1D* h1_Rnh_csi_vs_eta = (TH1D*)inFile->Get("Rnh_csi_vs_eta");

  int nBinsX_Rnh_neutron = h1_Rnh_neutron_vs_eta->GetNbinsX();
  int nBinsX_Rnh_K0L = h1_Rnh_K0L_vs_eta->GetNbinsX();
  int nBinsX_Rnh_K0S = h1_Rnh_K0S_vs_eta->GetNbinsX();
  int nBinsX_Rnh_lambda = h1_Rnh_lambda_vs_eta->GetNbinsX();
  int nBinsX_Rnh_csi = h1_Rnh_csi_vs_eta->GetNbinsX();

  double minX_Rnh_neutron = h1_Rnh_neutron_vs_eta->GetXaxis()->GetXmin();
  double maxX_Rnh_neutron = h1_Rnh_neutron_vs_eta->GetXaxis()->GetXmax();

  double minX_Rnh_K0L = h1_Rnh_K0L_vs_eta->GetXaxis()->GetXmin();
  double maxX_Rnh_K0L = h1_Rnh_K0L_vs_eta->GetXaxis()->GetXmax();

  double minX_Rnh_K0S = h1_Rnh_K0S_vs_eta->GetXaxis()->GetXmin();
  double maxX_Rnh_K0S = h1_Rnh_K0S_vs_eta->GetXaxis()->GetXmax();

  double minX_Rnh_lambda = h1_Rnh_lambda_vs_eta->GetXaxis()->GetXmin();
  double maxX_Rnh_lambda = h1_Rnh_lambda_vs_eta->GetXaxis()->GetXmax();

  double minX_Rnh_csi = h1_Rnh_csi_vs_eta->GetXaxis()->GetXmin();
  double maxX_Rnh_csi = h1_Rnh_csi_vs_eta->GetXaxis()->GetXmax();


  TH1D* h1_Rnh_neutron_vs_eta_stack = new TH1D("Rnh_neutron_vs_eta_stack", "", nBinsX_Rnh_neutron, minX_Rnh_neutron, maxX_Rnh_neutron);
  h1_Rnh_neutron_vs_eta_stack->SetFillColor(kBlue+4);
  h1_Rnh_neutron_vs_eta_stack->SetXTitle("#eta^{GEN}");

  TH1D* h1_Rnh_K0L_vs_eta_stack = new TH1D("Rnh_K0L_vs_eta_stack", "", nBinsX_Rnh_K0L, minX_Rnh_K0L, maxX_Rnh_K0L);
  h1_Rnh_K0L_vs_eta_stack->SetFillColor(kBlue);
  h1_Rnh_K0L_vs_eta_stack->SetXTitle("#eta^{GEN}");

  TH1D* h1_Rnh_K0S_vs_eta_stack = new TH1D("Rnh_K0S_vs_eta_stack", "", nBinsX_Rnh_K0S, minX_Rnh_K0S, maxX_Rnh_K0S);
  h1_Rnh_K0S_vs_eta_stack->SetFillColor(kCyan);
  h1_Rnh_K0S_vs_eta_stack->SetXTitle("#eta^{GEN}");

  TH1D* h1_Rnh_lambda_vs_eta_stack = new TH1D("Rnh_lambda_vs_eta_stack", "", nBinsX_Rnh_lambda, minX_Rnh_lambda, maxX_Rnh_lambda);
  h1_Rnh_lambda_vs_eta_stack->SetFillColor(kCyan+2);
  h1_Rnh_lambda_vs_eta_stack->SetXTitle("#eta^{GEN}");

  TH1D* h1_Rnh_csi_vs_eta_stack = new TH1D("Rnh_csi_vs_eta_stack", "", nBinsX_Rnh_csi, minX_Rnh_csi, maxX_Rnh_csi);
  h1_Rnh_csi_vs_eta_stack->SetFillColor(kCyan+4);
  h1_Rnh_csi_vs_eta_stack->SetXTitle("#eta^{GEN}");

  for(int i=1; i<101; ++i) {
    h1_Rnh_neutron_vs_eta_stack->SetBinContent( i, h1_Rnh_neutron_vs_eta->GetBinContent(i) );
    h1_Rnh_K0L_vs_eta_stack->SetBinContent( i, h1_Rnh_K0L_vs_eta->GetBinContent(i) );
    h1_Rnh_K0S_vs_eta_stack->SetBinContent( i, h1_Rnh_K0S_vs_eta->GetBinContent(i) );
    h1_Rnh_lambda_vs_eta_stack->SetBinContent( i, h1_Rnh_lambda_vs_eta->GetBinContent(i) );
    h1_Rnh_csi_vs_eta_stack->SetBinContent( i, h1_Rnh_csi_vs_eta->GetBinContent(i) );
  }


  THStack* stackNH = new THStack("stackNH", "");
  stackNH->Add(h1_Rnh_neutron_vs_eta_stack);
  stackNH->Add(h1_Rnh_K0L_vs_eta_stack);
  stackNH->Add(h1_Rnh_K0S_vs_eta_stack);
  stackNH->Add(h1_Rnh_lambda_vs_eta_stack);
  stackNH->Add(h1_Rnh_csi_vs_eta_stack);
  stackNH->Draw();
  stackNH->GetXaxis()->SetTitle("#eta^{GEN}");
  stackNH->GetYaxis()->SetTitle("% of Jet Neutral Hadron Energy");

  TCanvas* c3 = new TCanvas("c3", "c3", 800, 600);
  c3->cd();
  stackNH->Draw();
  c3->SaveAs("Plots/genstackNH_vs_eta.eps");

/*
  int nBins = 21;
  Double_t Lower[nBins];
    
  for(int iLower=0; iLower<11; ++iLower)
    Lower[iLower] = iLower*10.; 
  
  Lower[11] = 120.;
  Lower[12] = 140.;
  Lower[13] = 160.;
  Lower[14] = 180.;
  Lower[15] = 200.;
  Lower[16] = 250.;
  Lower[17] = 300.;
  Lower[18] = 400.;
  Lower[19] = 500.;
  Lower[20] = 600.;


  TH1D* h1_RchGen_vs_pt = (TH1D*)inFile->Get("RchGen_vs_pt_PFItCone5");
  TH1D* h1_RgammaGen_vs_pt = (TH1D*)inFile->Get("RgammaGen_vs_pt_PFItCone5");
  TH1D* h1_RnhGen_vs_pt = (TH1D*)inFile->Get("RnhGen_vs_pt_PFItCone5");
//  TH1D* h1_RmuGen_vs_pt = (TH1D*)inFile->Get("RmuGen_vs_pt_PFItCone5");

  TH1D* h1_RchGen_vs_pt_stack = new TH1D("RchGen_vs_pt", "", nBins-2, Lower);
  h1_RchGen_vs_pt_stack->SetFillColor(kRed);
  h1_RchGen_vs_pt_stack->SetXTitle("p_{T}^{GEN}");
 
  TH1D* h1_RgammaGen_vs_pt_stack = new TH1D("RgammaGen_vs_pt", "", nBins-2, Lower);
  h1_RgammaGen_vs_pt_stack->SetFillColor(kGreen);
  h1_RgammaGen_vs_pt_stack->SetXTitle("p_{T}^{GEN}");

  TH1D* h1_RnhGen_vs_pt_stack = new TH1D("RnhGen_vs_pt", "", nBins-2, Lower);
  h1_RnhGen_vs_pt_stack->SetFillColor(kBlue);
  h1_RnhGen_vs_pt_stack->SetXTitle("p_{T}^{GEN}");

//  TH1D* h1_RmuGen_vs_pt_stack = new TH1D("RmuGen_vs_pt", "", nBins-2, Lower);
//  h1_RmuGen_vs_pt_stack->SetFillColor(kYellow);
//  h1_RmuGen_vs_pt_stack->SetXTitle("p_{T}^{GEN}");

  for(int i=1; i<21; ++i) {
    h1_RchGen_vs_pt_stack->SetBinContent( i, h1_RchGen_vs_pt->GetBinContent(i) );
    h1_RgammaGen_vs_pt_stack->SetBinContent( i, h1_RgammaGen_vs_pt->GetBinContent(i) );
    h1_RnhGen_vs_pt_stack->SetBinContent( i, h1_RnhGen_vs_pt->GetBinContent(i) );
//    h1_RmuGen_vs_pt_stack->SetBinContent( i, h1_RmuGen_vs_pt->GetBinContent(i) );
  }


  THStack* stack2 = new THStack("stack2", "");
  stack2->Add(h1_RchGen_vs_pt_stack);
  stack2->Add(h1_RgammaGen_vs_pt_stack);
  stack2->Add(h1_RnhGen_vs_pt_stack);
//  stack2->Add(h1_RmuGen_vs_pt_stack);
  stack2->Draw();
  stack2->GetXaxis()->SetTitle("p_{T}^{GEN} [GeV/c]");
  stack2->GetYaxis()->SetTitle("% of Jet Energy");

  TCanvas* c2 = new TCanvas("c2", "c2", 800, 600);
  c2->cd();
  stack2->Draw();
  c2->SaveAs("Plots/genstack_vs_pt.eps");


  TH1D* h1_RchGen_vs_pt_barrel = (TH1D*)inFile->Get("RchGen_vs_pt_barrel_PFItCone5");
  TH1D* h1_RgammaGen_vs_pt_barrel = (TH1D*)inFile->Get("RgammaGen_vs_pt_barrel_PFItCone5");
  TH1D* h1_RnhGen_vs_pt_barrel = (TH1D*)inFile->Get("RnhGen_vs_pt_barrel_PFItCone5");
//  TH1D* h1_RmuGen_vs_pt_barrel = (TH1D*)inFile->Get("RmuGen_vs_pt_barrel_PFItCone5");

  TH1D* h1_RchGen_vs_pt_barrel_stack = new TH1D("RchGen_vs_pt_barrel", "", nBins-2, Lower);
  h1_RchGen_vs_pt_barrel_stack->SetFillColor(kRed);
  h1_RchGen_vs_pt_barrel_stack->SetXTitle("p_{T}^{GEN}");
 
  TH1D* h1_RgammaGen_vs_pt_barrel_stack = new TH1D("RgammaGen_vs_pt_barrel", "", nBins-2, Lower);
  h1_RgammaGen_vs_pt_barrel_stack->SetFillColor(kGreen);
  h1_RgammaGen_vs_pt_barrel_stack->SetXTitle("p_{T}^{GEN}");

  TH1D* h1_RnhGen_vs_pt_barrel_stack = new TH1D("RnhGen_vs_pt_barrel", "", nBins-2, Lower);
  h1_RnhGen_vs_pt_barrel_stack->SetFillColor(kBlue);
  h1_RnhGen_vs_pt_barrel_stack->SetXTitle("p_{T}^{GEN}");

//  TH1D* h1_RmuGen_vs_pt_barrel_stack = new TH1D("RmuGen_vs_pt_barrel", "", nBins-2, Lower);
//  h1_RmuGen_vs_pt_barrel_stack->SetFillColor(kYellow);
//  h1_RmuGen_vs_pt_barrel_stack->SetXTitle("p_{T}^{GEN}");

  for(int i=1; i<21; ++i) {
    h1_RchGen_vs_pt_barrel_stack->SetBinContent( i, h1_RchGen_vs_pt_barrel->GetBinContent(i) );
    h1_RgammaGen_vs_pt_barrel_stack->SetBinContent( i, h1_RgammaGen_vs_pt_barrel->GetBinContent(i) );
    h1_RnhGen_vs_pt_barrel_stack->SetBinContent( i, h1_RnhGen_vs_pt_barrel->GetBinContent(i) );
 //   h1_RmuGen_vs_pt_barrel_stack->SetBinContent( i, h1_RmuGen_vs_pt_barrel->GetBinContent(i) );
  }


  THStack* stack3 = new THStack("stack3", "");
  stack3->Add(h1_RchGen_vs_pt_barrel_stack);
  stack3->Add(h1_RgammaGen_vs_pt_barrel_stack);
  stack3->Add(h1_RnhGen_vs_pt_barrel_stack);
//  stack3->Add(h1_RmuGen_vs_pt_barrel_stack);
  stack3->Draw();
  stack3->GetXaxis()->SetTitle("p_{T}^{GEN} [GeV/c]");
  stack3->GetYaxis()->SetTitle("% of Jet Energy");

  c2->cd();
  stack3->Draw();
  c2->SaveAs("Plots/genstack_vs_pt_barrel.eps");


  TH1D* h1_RchGen_vs_pt_endcap = (TH1D*)inFile->Get("RchGen_vs_pt_endcap_PFItCone5");
  TH1D* h1_RgammaGen_vs_pt_endcap = (TH1D*)inFile->Get("RgammaGen_vs_pt_endcap_PFItCone5");
  TH1D* h1_RnhGen_vs_pt_endcap = (TH1D*)inFile->Get("RnhGen_vs_pt_endcap_PFItCone5");
//  TH1D* h1_RmuGen_vs_pt_endcap = (TH1D*)inFile->Get("RmuGen_vs_pt_endcap_PFItCone5");

  TH1D* h1_RchGen_vs_pt_endcap_stack = new TH1D("RchGen_vs_pt_endcap", "", nBins-2, Lower);
  h1_RchGen_vs_pt_endcap_stack->SetFillColor(kRed);
  h1_RchGen_vs_pt_endcap_stack->SetXTitle("p_{T}^{GEN}");

  TH1D* h1_RgammaGen_vs_pt_endcap_stack = new TH1D("RgammaGen_vs_pt_endcap", "", nBins-2, Lower);
  h1_RgammaGen_vs_pt_endcap_stack->SetFillColor(kGreen);
  h1_RgammaGen_vs_pt_endcap_stack->SetXTitle("p_{T}^{GEN}");

  TH1D* h1_RnhGen_vs_pt_endcap_stack = new TH1D("RnhGen_vs_pt_endcap", "", nBins-2, Lower);
  h1_RnhGen_vs_pt_endcap_stack->SetFillColor(kBlue);
  h1_RnhGen_vs_pt_endcap_stack->SetXTitle("p_{T}^{GEN}");

//  TH1D* h1_RmuGen_vs_pt_endcap_stack = new TH1D("RmuGen_vs_pt_endcap", "", nBins-2, Lower);
//  h1_RmuGen_vs_pt_endcap_stack->SetFillColor(kYellow);
//  h1_RmuGen_vs_pt_endcap_stack->SetXTitle("p_{T}^{GEN}");

  for(int i=1; i<21; ++i) {
    h1_RchGen_vs_pt_endcap_stack->SetBinContent( i, h1_RchGen_vs_pt_endcap->GetBinContent(i) );
    h1_RgammaGen_vs_pt_endcap_stack->SetBinContent( i, h1_RgammaGen_vs_pt_endcap->GetBinContent(i) );
    h1_RnhGen_vs_pt_endcap_stack->SetBinContent( i, h1_RnhGen_vs_pt_endcap->GetBinContent(i) );
    //h1_RmuGen_vs_pt_endcap_stack->SetBinContent( i, h1_RmuGen_vs_pt_endcap->GetBinContent(i) );
  }


  THStack* stack4 = new THStack("stack4", "");
  stack4->Add(h1_RchGen_vs_pt_endcap_stack);
  stack4->Add(h1_RgammaGen_vs_pt_endcap_stack);
  stack4->Add(h1_RnhGen_vs_pt_endcap_stack);
//  stack4->Add(h1_RmuGen_vs_pt_endcap_stack);
  stack4->Draw();
  stack4->GetXaxis()->SetTitle("p_{T}^{GEN} [GeV/c]");
  stack4->GetYaxis()->SetTitle("% of Jet Energy");

  c2->cd();
  stack4->Draw();
  c2->SaveAs("Plots/genstack_vs_pt_endcap.eps");
*/
} 
int main(int argc, char** argv)
{ 
 TDRStyle();
 
 gStyle->SetPadTopMargin(0.11);
 gStyle->SetPadLeftMargin(0.07);
 gStyle->SetPadRightMargin(0.23);
 gStyle->cd(); 
 
 
 std::cout << " " << std::endl;
 std::cout << " " << std::endl;
 std::cout << "      ___|                       |                     \\  |   ___|         /      __ \\     \\  __ __|   \\          " << std::endl;
 std::cout << "     |       _ \\   |   |  __ \\   __|   _ \\   __|      |\\/ |  |            /       |   |   _ \\    |    _ \\       " << std::endl;
 std::cout << "     |      (   |  |   |  |   |  |     __/  |         |   |  |           /        |   |  ___ \\   |   ___ \\          " << std::endl;
 std::cout << "    \\____| \\___/  \\__,_| _|  _| \\__| \\___| _|        _|  _| \\____|     _/        ____/ _/    _\\ _| _/    _\\   " << std::endl; 
 std::cout << " " << std::endl;
 std::cout << " " << std::endl; 
 std::cout << " " << std::endl; 
 std::cout << "      ___|                |                            |   _)                         " << std::endl;
 std::cout << "    \\___ \\   |   |   __|  __|   _ \\  __ `__ \\    _` |  __|  |   __|   __|         " << std::endl;
 std::cout << "          |  |   | \\__ \\  |     __/  |   |   |  (   |  |    |  (    \\__ \\     " << std::endl;
 std::cout << "    _____/  \\__, | ____/ \\__| \\___| _|  _|  _| \\__,_| \\__| _| \\___| ____/       " << std::endl;
 std::cout << "            ____/                                                                     " << std::endl;
 std::cout << " " << std::endl;
 std::cout << " " << std::endl;
 
 
 
 
 char normal[] = { 0x1b, '[', '0', ';', '3', '9', 'm', 0 };
 char black[] = { 0x1b, '[', '0', ';', '3', '0', 'm', 0 };
 char red[] = { 0x1b, '[', '0', ';', '3', '1', 'm', 0 };
 char green[] = { 0x1b, '[', '0', ';', '3', '2', 'm', 0 };
 char yellow[] = { 0x1b, '[', '0', ';', '3', '3', 'm', 0 };
 char blue[] = { 0x1b, '[', '0', ';', '3', '4', 'm', 0 };
 char purple[] = { 0x1b, '[', '0', ';', '3', '5', 'm', 0 };
 char cyan[] = { 0x1b, '[', '0', ';', '3', '6', 'm', 0 };
 char Lgray[] = { 0x1b, '[', '0', ';', '3', '7', 'm', 0 };
 char Dgray[] = { 0x1b, '[', '0', ';', '3', '8', 'm', 0 };
 char Bred[] = { 0x1b, '[', '1', ';', '3', '1', 'm', 0 };
 //for bold colors, just change the 0 after the [ to a 1
 
 EColor vColor[1000] = {
  kGreen,
  //kMagenta,(EColor) (kMagenta+1),(EColor) (kMagenta+2),
  kTeal,//(EColor) (kTeal+1),
  kRed,
  kGray,
  kOrange,(EColor) (kOrange+1),
  kBlue,//(EColor)(kBlue+1),(EColor) (kBlue+2),
  (EColor) (kPink+2),//(EColor) (kPink+1),(EColor) (kPink+2),
  kViolet,
  kYellow,
  kGray,(EColor) (kGray+1),(EColor) (kViolet),(EColor) (kYellow),(EColor) (kGray)
 };
 
 
 
 
 //Check if all nedeed arguments to parse are there                                                                                                                               
 if(argc != 2)
 {
  std::cerr << ">>>>> analysis.cpp::usage: " << argv[0] << " configFileName" << std::endl ;
  return 1;
 }


 // Parse the config file                                                                                                                                                          
 parseConfigFile (argv[1]) ;
 
 std::string treeName  = gConfigParser -> readStringOption("Input::treeName");
 std::string treeNameSelections = gConfigParser -> readStringOption("Input::treeNameSelections");
 std::string fileSamples = gConfigParser -> readStringOption("Input::fileSamples");
 std::string inputDirectory = gConfigParser -> readStringOption("Input::inputDirectory");
 
 double LUMI = gConfigParser -> readDoubleOption("Input::Lumi");
 
 double LumiSyst = gConfigParser -> readDoubleOption("Input::LumiSyst");
 
 double Discovery = gConfigParser -> readDoubleOption("Input::Discovery");
 
 std::vector<std::string> SignalName;
 SignalName = gConfigParser -> readStringListOption("Input::SignalName");
 
 ///==== PU reweight (begin) ====
 std::vector<double> PUMC   = gConfigParser -> readDoubleListOption("PU::PUMC");
 std::vector<double> PUDATA = gConfigParser -> readDoubleListOption("PU::PUDATA");
 PUclass PU;
 
 std::cout << " PUMC.size()   = " << PUMC.size()   << std::endl;
 std::cout << " PUDATA.size() = " << PUDATA.size() << std::endl;
 
 if (PUMC.size() != PUDATA.size()) {
  std::cerr << " ERROR " << std::endl;
  return 1;
 }
 
 double sumPUMC = 0;
 for (int itVPU = 0; itVPU < PUMC.size(); itVPU++ ){
  sumPUMC += PUMC.at(itVPU);  
 }
 double sumPUDATA = 0;
 for (int itVPU = 0; itVPU < PUDATA.size(); itVPU++ ){
  sumPUDATA += PUDATA.at(itVPU);  
 } 
 
 for (int itVPU = 0; itVPU < PUMC.size(); itVPU++ ){
  PU.PUWeight.push_back(PUDATA.at(itVPU) / PUMC.at(itVPU) * sumPUMC / sumPUDATA);
 }

 PU.Write("autoWeight.cxx");
 gROOT->ProcessLine(".L autoWeight.cxx");
 ///==== PU reweight (end) ====
 
 ///==== save PU distribution in TH1F ====
 TH1F* hPUMC   = new TH1F("hPUMC","hPUMC",PUMC.size(),0,PUMC.size());
 TH1F* hPUDATA = new TH1F("hPUDATA","hPUDATA",PUDATA.size(),0,PUDATA.size());
 TH1F* hPUWeight = new TH1F("hPUWeight","hPUWeight",PUDATA.size(),0,PUDATA.size());
 
 for (int itVPU = 0; itVPU < PUMC.size(); itVPU++ ){
  hPUMC     -> SetBinContent(itVPU+1,PUMC.at(itVPU) / sumPUMC);
  hPUDATA   -> SetBinContent(itVPU+1,PUDATA.at(itVPU) / sumPUDATA);
  hPUWeight -> SetBinContent(itVPU+1,PUDATA.at(itVPU) / PUMC.at(itVPU) * sumPUMC / sumPUDATA);
 }
 
 
 
 TTree *treeEffVect[100];
 TTree *treeJetLepVect[100];
 

 
  //  [iCut] 
 TString* infoString[20];
 TLatex *infoLatex[20]; 
 TCanvas* ccCanvas[20];
 TCanvas* ccCanvasPull[20];
 TH1F* histoSumMC[20];
 //  [iName][iCut]
 TH1F* histo[100][20];
 TH1F* histo_temp[100][20];

 //  [iName][iCut]
 double numEvents[100][20];
 
 char *nameSample[1000];
 char *nameHumanReadable[1000];
 char* xsectionName[1000];
 
 double Normalization[1000];
 double xsection[1000];
 char nameFileIn[1000];
 sprintf(nameFileIn,"%s",fileSamples.c_str());

 int numberOfSamples = ReadFile(nameFileIn, nameSample, nameHumanReadable, xsectionName);

 
 double XSection  = gConfigParser -> readDoubleOption("Plot::XSection");
 
 ///==== list of selections to perform (NOT sequential additive selections) ====
 std::string CutFile = gConfigParser -> readStringOption("Selections::CutFile");
 std::vector<std::string> vCut;
 std::cout << " nCuts = " << ReadFileCut(CutFile, vCut) << std::endl;
 
 
 ///==== list of systematic variables to change ====
//  std::string CutSystematicFile = gConfigParser -> readfStringOption("Selections::CutSystematicFile");
// 
//  std::vector< std::pair< int, std::pair<std::string, double> > > listSystematics;
//  ReadFileSystematics(CutSystematicFile, listSystematics);
//  ModifyCut(vCut,listSystematics);

 
  std::string CutSystematicFile = gConfigParser -> readStringOption("Selections::CutSystematicFile");
 
  std::vector< std::pair< std::string, std::string> > listSystematics;
  ReadFileSystematicsWithRegion(CutSystematicFile, listSystematics);
  ModifyCutWithRegion(vCut,listSystematics);
  
  
  
  ///==== something to load/exec ====
  try {
   std::string toLoad = gConfigParser -> readStringOption("Exec::ToLoad");
   std::string toExec = ".L ";
   toExec += toLoad;
   toExec += ".cxx";
   gROOT->ProcessLine(toExec.c_str());
   std::cout << std::endl;
   std::cout << " load: " << toLoad.c_str() << std::endl;
   std::cout << " do:   " << toExec.c_str() << std::endl;
   std::cout << std::endl;
  }
  catch (char const* exceptionString){
   std::cerr << " exception = " << exceptionString << std::endl;
  }
  
 
 ///==== output file ====
 std::string OutFileName    = gConfigParser -> readStringOption("Output::outFileName");
 std::cout << ">>>>> Output::outFileName  " << OutFileName  << std::endl;  
 
 TFile outFile(OutFileName.c_str(),"RECREATE");
 outFile.cd();
 
 
 ///==== debug flag ====
 
 bool  debug = false; 
 try {
  debug = gConfigParser -> readBoolOption("Input::debug");
 }
 catch (char const* exceptionString){
  std::cerr << " exception = " << exceptionString << std::endl;
 }
 std::cout << ">>>>> input::debug  " << debug  << std::endl;  
 
 ///==== program ====
 
 
 double start, end;
 start = clock();
 
 
 for (int iSample=0; iSample<numberOfSamples; iSample++){
  xsection[iSample] = atof(xsectionName[iSample]);
 }
 
 for (int iSample=0; iSample<numberOfSamples; iSample++){
  
  char nameFile[20000];
  sprintf(nameFile,"%s/out_NtupleProducer_%s.root",inputDirectory.c_str(),nameSample[iSample]);  
  TFile* f = new TFile(nameFile, "READ");
  
  treeEffVect[iSample] = (TTree*) f->Get(treeNameSelections.c_str());
  char nameTreeEff[100];
  sprintf(nameTreeEff,"treeEff_%d",iSample); 
  treeEffVect[iSample]->SetName(nameTreeEff);      
  
  treeJetLepVect[iSample] = (TTree*) f->Get(treeName.c_str());
  char nameTreeJetLep[100];
  sprintf(nameTreeJetLep,"treeJetLep_%d",iSample); 
  treeJetLepVect[iSample]->SetName(nameTreeJetLep);
 }
 
 ///===== create map for joint sample ====
 
 std::vector<int> join_samples;
 std::vector<std::string> name_samples;
 for (int iSample=0; iSample<numberOfSamples; iSample++){
  name_samples.push_back(nameHumanReadable[iSample]);
  join_samples.push_back(-1);
 }
 
 
 std::vector<std::string> reduced_name_samples;
 std::vector<int>         reduced_name_samples_flag;
 for (int iSample = (numberOfSamples-1); iSample>= 0; iSample--){
  bool flag_name = false;
  for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
   if (reduced_name_samples.at(iName) == name_samples.at(iSample)) flag_name = true;
  }
  if (flag_name == false) {
   reduced_name_samples.push_back(name_samples.at(iSample));
   reduced_name_samples_flag.push_back(-1);
  }
 }
 
 std::cout << " numberOfSamples = " << numberOfSamples << std::endl;
 
 for (int iSample = (numberOfSamples-1); iSample>= 0; iSample--){
  double XSection;
  int numEntriesBefore;
  double preselection_efficiency;
  treeEffVect[iSample]->SetBranchAddress("XSection",&XSection);
  treeEffVect[iSample]->SetBranchAddress("numEntriesBefore",&numEntriesBefore);
  treeEffVect[iSample]->SetBranchAddress("preselection_efficiency",&preselection_efficiency);  
  treeEffVect[iSample]->GetEntry(0);
  
  std::cout << " Xsection = " << XSection << " ~~~> " << xsection[iSample] << std::endl;
  XSection = xsection[iSample];
  
  if (numEntriesBefore != 0) {
   Normalization[iSample] = LUMI * XSection * preselection_efficiency / numEntriesBefore;
  }
  else {
   Normalization[iSample] = 0; 
  }    
 }
 
 
 
 TLegend* leg = new TLegend(0.8,0.25,0.98,0.78);
 bool LegendBuilt = false;

 TString lumiName = Form("#splitline{L = %.1f pb^{-1}}{#splitline{#sqrt{s} = 7}{CMS preliminary}}", LUMI);
//  TString lumiName = Form("#sqrt{s}=7 TeV   L=%.1f pb^{-1}", LUMI);
 TLatex *latex = new TLatex(0.80, 0.90, lumiName); 
 latex->SetTextAlign(12);
 latex->SetNDC();
 latex->SetTextFont(42);
 latex->SetTextSize(0.03);
  
 ///==== get number in sample list that correspond to DATA ====
 int numDATA = -1;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  if (reduced_name_samples.at(iName) == "DATA") {
   numDATA = iName;
  }
 }
 
 
 if (debug) std::cout << " Cut size = " << vCut.size() << " ~~ " << std::endl;
 std::cout.precision (2) ;
 std::cout.unsetf(std::ios::scientific);
 ///==== cicle on selections ====
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  TString Cut = Form ("%s",vCut.at(iCut).c_str());
  if (debug) std::cout << " Cut[" << iCut << ":" << vCut.size() << "] = " << Cut.Data() << " ~~ " << std::endl;
  ///==== initialize ====
  for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
   reduced_name_samples_flag.at(iName) = -1;
  }
  
  ///==== cicle on samples ====
  for (int iSample = (numberOfSamples-1); iSample>= 0; iSample--){
   if (debug) std::cout << " Sample[" << iSample << ":" << numberOfSamples << "] = " << nameSample[iSample] << " ~~ " << std::endl;
   TString name_histo_temp = Form("%s_%d_temp",nameSample[iSample], iCut);
   histo_temp[iSample][iCut] = new TH1F(name_histo_temp,name_histo_temp,100,-10,10000000000);
   char toDraw[1000];
   sprintf(toDraw,"eventId >> %s",name_histo_temp.Data());      
   histo_temp[iSample][iCut] -> Sumw2(); //---- così mette l'errore giusto!
   
   TString CutExtended;
   bool isData = false;
   for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
    if (name_samples.at(iSample) == reduced_name_samples.at(iName)){
     if (iName == numDATA) {
      isData = true;
     }
    }
   }  
   if (!isData) {
    CutExtended = Form ("(%s) * autoWeight(numPUMC)",Cut.Data());    
   }
   else {
    CutExtended = Form ("(%s)",Cut.Data());    
   }
   if (debug) std::cerr << " drawing ..." << std::endl;
   treeJetLepVect[iSample]->Draw(toDraw,CutExtended,"");
   if (debug) std::cerr << " drawn ..." << std::endl;
   
   if (Normalization[iSample]>0) { 
    histo_temp[iSample][iCut] -> Scale(Normalization[iSample]); 
   }
   for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
    if (name_samples.at(iSample) == reduced_name_samples.at(iName)){
     if (reduced_name_samples_flag.at(iName) == -1){
      TString name_histoTot_temp = Form("%s_%d_Tot_temp",reduced_name_samples.at(iName).c_str(),iCut);
      TString name_HR_histoTot_temp = Form("cut %d",iCut);
      histo[iName][iCut] = new TH1F(name_histoTot_temp,name_HR_histoTot_temp,100,-10,10000000000);
      histo[iName][iCut] -> Sumw2(); //---- così mette l'errore giusto!
      reduced_name_samples_flag.at(iName) = 1;
     }
     histo[iName][iCut] -> Add(histo_temp[iSample][iCut]);
    }
   }
   std::cout << "Processing: " << blue << (((double) iCut)/vCut.size())*100. << "% "  << normal <<  " -- " <<  red << (((double) numberOfSamples - iSample)/(numberOfSamples))*100. << "% \r"  << normal << std::flush;   
  } ///==== end cicle on samples ====
//   std::cout << "Processing: " << blue << (((double) iCut)/vCut.size())*100. << "% \r"  << normal << std::flush;   
 } ///==== end cicle on selections ====
 
 //  [iName]
 TH1F* hTrend[100];
 THStack* hsTrend;
 //  [iCut]
 TPie* hTrendPie[100];
 
 //  [iCut]
 THStack* hs[100];
 
 std::cout << std::endl;
 
 ///==== cicle on selections ====
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  TString nameStack = Form("%d_stack",iCut);
  hs[iCut] = new THStack(nameStack,nameStack);
  
  for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
   histo[iName][iCut]->GetXaxis()->SetTitle("eventId");
   histo[iName][iCut]->SetMarkerColor(vColor[iName]);
   histo[iName][iCut]->SetLineColor(vColor[iName]);
   histo[iName][iCut]->SetFillColor(vColor[iName]);
   histo[iName][iCut]->SetLineWidth(2);
   histo[iName][iCut]->SetFillStyle(3001);
   
   bool isSig = false;
   for (std::vector<std::string>::const_iterator itSig = SignalName.begin(); itSig != SignalName.end(); itSig++){
    if (reduced_name_samples.at(iName) == *itSig) isSig = true;
   }
   
   if (!isSig && reduced_name_samples.at(iName) != "DATA") {
    hs[iCut]->Add(histo[iName][iCut]);
   }
   else {
    if (!isSig) {
     histo[iName][iCut]->SetMarkerStyle(20);
     histo[iName][iCut]->SetMarkerSize(1);
     histo[iName][iCut]->SetMarkerColor(kBlack);
     histo[iName][iCut]->SetLineColor(kBlack);
     histo[iName][iCut]->SetFillColor(kBlack);
     histo[iName][iCut]->SetLineWidth(2);
     histo[iName][iCut]->SetFillStyle(3001);  
    }
    else {
     histo[iName][iCut]->SetMarkerStyle(21);
     histo[iName][iCut]->SetMarkerSize(1);
     histo[iName][iCut]->SetLineWidth(2);
     histo[iName][iCut]->SetFillStyle(3001);  
    }
   }
  }
  ///==== histo sum MC ====    
  ///==== Add systrematic error ====
  AddError(hs[iCut],LumiSyst);
  histoSumMC[iCut] = ((TH1F*)(hs[iCut]->GetStack()->Last()));

  std::cout << " MC / DATA[" << iCut << "] = "<< histoSumMC[iCut]->Integral() << " / " << histo[numDATA][iCut]->Integral() << " = " << (histo[numDATA][iCut]->Integral() ? histoSumMC[iCut]->Integral()/ histo[numDATA][iCut]->Integral() : 0) << std::endl;
  
  ///==== legend ====
  if (!LegendBuilt){
   for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
    leg->AddEntry(histo[iName][iCut],reduced_name_samples.at(iName).c_str(),"pf");    
    LegendBuilt = true;
   }
  }
 }
 std::cout << std::endl << std::endl;
 
 ///==== calculate number of events after each step of the analysis ====
 //  [iName][iCut]
 hsTrend = new THStack("Trend","Trend");
 
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  TString nameTHTrendPie = Form("%d_Trend_Pie",iCut);
  hTrendPie[iCut] = new TPie (nameTHTrendPie,nameTHTrendPie,reduced_name_samples.size());
 }
 
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  TString nameTHTrend = Form("%s_Trend",reduced_name_samples.at(iName).c_str());
  hTrend[iName] = new TH1F (nameTHTrend,nameTHTrend,vCut.size()+1,0,vCut.size()+1);
  hTrend[iName]->GetXaxis()->SetTitle("Selections");

  if (iName == numDATA) {
   hTrend[iName]->SetMarkerStyle(20);
   hTrend[iName]->SetMarkerSize(1);
   hTrend[iName]->SetMarkerColor(kBlack);
   hTrend[iName]->SetLineColor(kBlack);
   hTrend[iName]->SetFillColor(kBlack);
   hTrend[iName]->SetLineWidth(2);
   hTrend[iName]->SetFillStyle(3001);  
  }
  else {
   hTrend[iName]->SetMarkerColor(vColor[iName]);
   hTrend[iName]->SetLineColor(vColor[iName]);
   hTrend[iName]->SetFillColor(vColor[iName]);
   hTrend[iName]->SetLineWidth(2);
   hTrend[iName]->SetFillStyle(3001);
  }
  for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
   double error = 0;
   numEvents[iName][iCut] = histo[iName][iCut]->IntegralAndError(0,histo[iName][iCut]->GetNbinsX()+1,error);
   hTrend[iName]->SetBinContent(iCut+1,numEvents[iName][iCut]);
   hTrend[iName]->SetBinError(iCut+1,error);

   TString nameBin = Form("%d",iCut);
   hTrend[iName]->GetXaxis()->SetBinLabel(iCut+1,nameBin);
//     IntegralAndError
//     Double_t IntegralAndError(Int_t binx1, Int_t binx2, Double_t& err, Option_t* option = "") const
   std::cout << ">>>  numEvents[" << iName << "," << reduced_name_samples.at(iName) << "][" << iCut << "] = " << numEvents[iName][iCut] << " , " << histo[iName][iCut]->GetEntries() << " , " << histo[iName][iCut]->GetEffectiveEntries() << std::endl;
   
   if (iName != numDATA) {
    hTrendPie[iCut]->SetTextSize(0.04);
    hTrendPie[iCut]->SetTextFont(12);
    hTrendPie[iCut]->SetEntryFillColor(iName,vColor[iName]);
    hTrendPie[iCut]->SetEntryFillStyle(iName,3001);
    hTrendPie[iCut]->SetEntryLabel(iName, reduced_name_samples.at(iName).c_str());
    hTrendPie[iCut]->SetEntryLineColor(iName, vColor[iName]);
    hTrendPie[iCut]->SetEntryLineStyle(iName, 2);
    hTrendPie[iCut]->SetEntryLineWidth(iName, 2);
    hTrendPie[iCut]->SetEntryRadiusOffset(iName, 0.01);
    hTrendPie[iCut]->SetEntryVal(iName,numEvents[iName][iCut]);
   }
   else {
    hTrendPie[iCut]->SetEntryLabel(iName, "");
   }
  }
  if (iName != numDATA) {
   hsTrend->Add(hTrend[iName]);
  }
 }
 AddError(hsTrend,LumiSyst);
 
 TH1F* hTrendSumMC = ((TH1F*)(hsTrend->GetStack()->Last()));
 ///==== hTrend with pull plot ====
 TH1F* hPullTrendSumMC = PullPlot(hTrend[numDATA], hTrendSumMC);
  
 LumiSyst = 0; ///---- bug fix
 
 
 
 
 TCanvas* cTrendPie[100];
 TCanvas* cTrendPieAll = new TCanvas("cTrendPieAll","cTrendPieAll",400 * vCut.size(),400);
 cTrendPieAll -> Divide (vCut.size());
 TCanvas* cTrend = new TCanvas("cTrend","cTrend",400,400);
 TCanvas* cTrendSample[100];
 
 
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  TString nameCanvas = Form("%d_Canvas_Sample",iName);
  cTrendSample[iName] = new TCanvas(nameCanvas,nameCanvas,400,400);
  hTrend[iName] -> Draw();
  gPad->SetLogy();
  gPad->SetGrid();
 }
 
 
 
 
 
 
 ///~~~~ for efficiency calculation ~~~~
 
 std::vector<double> numEntriesFirstStep_reduced_samples;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  numEntriesFirstStep_reduced_samples.push_back(0);
  for (int iSample = (numberOfSamples-1); iSample>= 0; iSample--){
   if (name_samples.at(iSample) == reduced_name_samples.at(iName)){
//     numEntriesFirstStep_reduced_samples.at(iName) += (Normalization[iSample] ? (1. / Normalization[iSample] * LUMI * xsection[iSample] * LUMI * xsection[iSample]) : -1);
    numEntriesFirstStep_reduced_samples.at(iName) += (xsection[iSample] * LUMI);
   }
  }
 }
//   Normalization[iSample] = LUMI * XSection * preselection_efficiency / numEntriesBefore;
//   1. / Normalization[iSample] = numEntriesBefore / preselection_efficiency / LUMI / XSection;
//   1. / Normalization[iSample] * LUMI * xsection[iSample] = numEntriesBefore / preselection_efficiency;
//   1. / Normalization[iSample] * LUMI * xsection[iSample] * LUMI * xsection[iSample] = numEntriesBefore / preselection_efficiency * LUMI * xsection[iSample];

 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  std::cout << "[" << reduced_name_samples.at(iName) << "] = " << numEntriesFirstStep_reduced_samples.at(iName) << std::endl;
 }
 
 std::cout.precision (2) ;
 std::cout.unsetf(std::ios::scientific);


 
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << " *********************************** " << std::endl;
 std::cout << std::setw (12) << "sample";
 std::cout << " | " << std::setw (8) <<  -1;
 std::cout << " [" << std::setw (8) <<  "XXX";
 std::cout << " ]";
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  std::cout << " | " << std::setw (8) <<  iCut;
  std::cout << " [" << std::setw (8) <<  "XXX";
  std::cout << " ]";
 }
 std::cout << std::endl;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  std::cout << std::setw (12) << reduced_name_samples.at(iName) ;
  std::cout << " | " << cyan << std::setw (8) <<  numEntriesFirstStep_reduced_samples.at(iName);
  std::cout << normal << " [" << std::setw (8) <<  "XXX";
  std::cout << " ]";
  for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
   std::cout << " | " << blue << std::setw (8) <<  hTrend[iName]->GetBinContent(iCut+1);
   std::cout << normal << " [" << std::setw (8) <<  hTrend[iName]->GetBinError(iCut+1);
   std::cout << " ]";
  }
  std::cout << std::endl;
 }
 
 std::cout << std::endl;
 std::cout << " *********************************** " << std::endl;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  std::cout << " | " << std::setw (8) << reduced_name_samples.at(iName) ;
  std::cout << " [" << std::setw (8) <<  "err";
  std::cout << " ]";
 }
 std::cout << std::endl;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  std::cout << " | " << cyan << std::setw (8) <<  numEntriesFirstStep_reduced_samples.at(iName);
  std::cout << normal << " [" << std::setw (8) <<  "XXX";
  std::cout << " ]";
 }
 std::cout << std::endl;
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
   std::cout << " | " << blue << std::setw (8) <<  hTrend[iName]->GetBinContent(iCut+1);
   std::cout << normal << " [" << std::setw (8) <<  hTrend[iName]->GetBinError(iCut+1);
   std::cout << " ]";
  }
  std::cout << std::endl;
 }
 
 
 
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << " *********************************** " << std::endl;
 std::cout << " ************* 1 fb-1 ************* " << std::endl;
 std::cout << std::setw (12) << "sample";
 std::cout << " | " << std::setw (8) <<  -1;
 std::cout << " [" << std::setw (8) <<  "XXX";
 std::cout << " ]";
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  std::cout << " | " << std::setw (8) <<  iCut;
  std::cout << " [" << std::setw (8) <<  "XXX";
  std::cout << " ]";
 }
 std::cout << std::endl;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  std::cout << std::setw (12) << reduced_name_samples.at(iName) ;
  std::cout << " | " << purple << std::setw (9) <<  1000 / LUMI * numEntriesFirstStep_reduced_samples.at(iName);
  std::cout << normal << " [" << std::setw (9) <<  "XXX";
  std::cout << " ]";
  for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
   std::cout << " | " << red << std::setw (9) <<  hTrend[iName]->GetBinContent(iCut+1) / LUMI * 1000.;
   std::cout << normal << " [" << std::setw (9) <<  hTrend[iName]->GetBinError(iCut+1) / LUMI * 1000.;
   std::cout << " ]";
  }
  std::cout << std::endl;
 }
 
 std::cout << std::endl;
 std::cout << " *********************************** " << std::endl;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  std::cout << " | " << red << std::setw (8) << reduced_name_samples.at(iName) ;
  std::cout << normal << " [" << std::setw (8) <<  "err";
  std::cout << " ]";
 }
 std::cout << std::endl;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  std::cout << " | " << purple << std::setw (8) <<  1000 / LUMI * numEntriesFirstStep_reduced_samples.at(iName);
  std::cout << normal << " [" << std::setw (8) <<  "XXX";
  std::cout << " ]";
 }
 std::cout << std::endl;
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
   std::cout << " | " << red << std::setw (8) <<  hTrend[iName]->GetBinContent(iCut+1) / LUMI * 1000.;
   std::cout << normal << " [" << std::setw (8) <<  hTrend[iName]->GetBinError(iCut+1) / LUMI * 1000.;
   std::cout << " ]";
  }
  std::cout << std::endl;
 }
 
  
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << " **************************************** " << std::endl;
 std::cout << " ************* efficiency *************** " << std::endl;
 std::cout << std::setw (12) << "sample";
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  std::cout << " | " << std::setw (8) <<  iCut;
  std::cout << " [" << std::setw (8) <<  "XXX";
  std::cout << " ]";
 }
 std::cout << std::endl;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  std::cout << std::setw (12) << reduced_name_samples.at(iName) ;
  for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
   std::cout << " | " << yellow << std::setw (8) <<  hTrend[iName]->GetBinContent(iCut+1) / numEntriesFirstStep_reduced_samples.at(iName);
   std::cout << normal << " [" << std::setw (8) <<  hTrend[iName]->GetBinError(iCut+1) / numEntriesFirstStep_reduced_samples.at(iName);
//    std::cout << " | " << yellow << std::setw (8) <<  hTrend[iName]->GetBinContent(iCut+1) << " / " << numEntriesFirstStep_reduced_samples.at(iName);
//    std::cout << normal << " [" << std::setw (8) <<  hTrend[iName]->GetBinError(iCut+1) << " / " << numEntriesFirstStep_reduced_samples.at(iName);
   std::cout << " ]";
  }
  std::cout << std::endl;
 }
 
 std::cout << std::endl;
 std::cout << " *********************************** " << std::endl;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  std::cout << " | " << std::setw (8) << reduced_name_samples.at(iName) ;
  std::cout << " [" << std::setw (8) <<  "err";
  std::cout << " ]";
 }
 std::cout << std::endl;
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
   std::cout << " | " << yellow << std::setw (8) <<  hTrend[iName]->GetBinContent(iCut+1) / numEntriesFirstStep_reduced_samples.at(iName);
   std::cout << normal << " [" << std::setw (8) <<  hTrend[iName]->GetBinError(iCut+1) / numEntriesFirstStep_reduced_samples.at(iName);
   std::cout << " ]";
  }
  std::cout << std::endl;
 }
 
 
 
 
 
 
 
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << " ****************************************************************** " << std::endl;
 std::cout << " ****************************************************************** " << std::endl;
 std::cout << " *********************** for Lands datacard *********************** " << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 
 
 
 std::string mass = "160";
 try {
  mass = gConfigParser -> readStringOption("Input::mass");
 }
 catch (char const* exceptionString){
  std::cerr << " exception = " << exceptionString << std::endl;
 }
 std::cout << ">>>>> input::mass  " << mass << std::endl;  
 
 std::ofstream myfile;
 std::string nameOutDataCard = "dataCard_H" + mass + ".txt";
 
 ///==== output - txt file name ====
 try {
  nameOutDataCard = gConfigParser -> readStringOption("Output::DataCard");
 }
 catch (char const* exceptionString){
  std::cerr << " exception = " << exceptionString << std::endl;
 }
 
 myfile.open (nameOutDataCard.c_str());
 std::cout << "Writing to: " << nameOutDataCard << std::endl;
 std::cout << std::endl;
 
 
 myfile << "Limit" << std::endl;
 myfile << "imax 1 number of channels" << std::endl;
 myfile << "jmax "<< (reduced_name_samples.size() - SignalName.size() - 1) << " number of background" << std::endl;
 //---- -1 to take into account "DATA"
 myfile << "kmax "<< 0 << " number of nuisance parameters" << std::endl;
 
 double totalSig = 0;
 double totalBkg = 0;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  if (iName != numDATA) {
   bool isSig = false;
   for (std::vector<std::string>::const_iterator itSig = SignalName.begin(); itSig != SignalName.end(); itSig++){
    if (reduced_name_samples.at(iName) == *itSig) isSig = true;
   }
   if (isSig) {
    totalSig += hTrend[iName]->GetBinContent(vCut.size());   ///---- last cut!
   }
   else {
    totalBkg += hTrend[iName]->GetBinContent(vCut.size());   ///---- last cut!
   }
  }
 }
 myfile << "-------------------------------------------------" << std::endl;
//  myfile << "Observation   " << ((Discovery==1) ? (int) (totalBkg+totalSig) : (int) (totalBkg)) << std::endl;
 myfile << "Observation   " << hTrend[numDATA]->GetBinContent(vCut.size()) << std::endl;
 //# 1 = discovery, 0 = exclusion
 myfile << "-------------------------------------------------" << std::endl;
 
 
 myfile << std::setw (12) << " bin  " << std::setw (8) << 1 << "  ";
 for (int i=0; i < (reduced_name_samples.size() - SignalName.size() - 1); i++){
  myfile << std::setw (8) << 1 << "  ";
 }
 myfile << std::endl;
 
 myfile << std::setw (12) << " process  " << std::setw (8) << "sig" << "  ";
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  if (iName != numDATA) {
   bool isSig = false;
   for (std::vector<std::string>::const_iterator itSig = SignalName.begin(); itSig != SignalName.end(); itSig++){
    if (reduced_name_samples.at(iName) == *itSig) isSig = true;
   }
   if (!isSig) {
    myfile << std::setw (8) << reduced_name_samples.at(iName) << "  ";
   }
  }
 }
 myfile << std::endl;
 
 myfile << std::setw (12) << " process  " << std::setw (8) << 0 << "  ";
 for (int i=0; i < (reduced_name_samples.size() - SignalName.size() - 1); i++){
  myfile << std::setw (8) << i+1 << "  ";
 }
 myfile << std::endl;
 
 myfile << std::setw (12) << " rate  " << std::setw (8) << totalSig << "  ";
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  if (iName != numDATA) {
   bool isSig = false;
   for (std::vector<std::string>::const_iterator itSig = SignalName.begin(); itSig != SignalName.end(); itSig++){
    if (reduced_name_samples.at(iName) == *itSig) isSig = true;
   }
   if (!isSig) {
    myfile << std::setw (8) << hTrend[iName]->GetBinContent(vCut.size()) << "  ";
   }
  }
 }
 myfile << std::endl;
 
 
 myfile << "-------------------------------------------------" << std::endl;
 
 myfile.close(); 
 
 
 
 
 ///==== plot on the screen ====
 
 std::cout << "Limit" << std::endl;
 std::cout << "imax 1 number of channels" << std::endl;
 std::cout << "jmax "<< (reduced_name_samples.size() - SignalName.size() - 1) << " number of background" << std::endl;
 //---- -1 to take into account "DATA"
 std::cout << "kmax "<< 0 << " number of nuisance parameters" << std::endl;
 
 totalSig = 0;
 totalBkg = 0;
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  if (iName != numDATA) {
   bool isSig = false;
   for (std::vector<std::string>::const_iterator itSig = SignalName.begin(); itSig != SignalName.end(); itSig++){
    if (reduced_name_samples.at(iName) == *itSig) isSig = true;
   }
   if (isSig) {
    totalSig += hTrend[iName]->GetBinContent(vCut.size());   ///---- last cut!
   }
   else {
    totalBkg += hTrend[iName]->GetBinContent(vCut.size());   ///---- last cut!
   }
  }
 }
 std::cout << "-------------------------------------------------" << std::endl;
//  std::cout << "Observation   " << ((Discovery==1) ? (int) (totalBkg+totalSig) : (int) (totalBkg)) << std::endl;
 std::cout << "Observation   " << hTrend[numDATA]->GetBinContent(vCut.size()) << std::endl;
 //# 1 = discovery, 0 = exclusion
 std::cout << "-------------------------------------------------" << std::endl;
 
 
 std::cout << std::setw (12) << " bin  " << std::setw (8) << 1 << "  ";
 for (int i=0; i < (reduced_name_samples.size() - SignalName.size() - 1); i++){
  std::cout << std::setw (8) << 1 << "  ";
 }
 std::cout << std::endl;
 
 std::cout << std::setw (12) << " process  " << std::setw (8) << "sig" << "  ";
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  if (iName != numDATA) {
   bool isSig = false;
   for (std::vector<std::string>::const_iterator itSig = SignalName.begin(); itSig != SignalName.end(); itSig++){
    if (reduced_name_samples.at(iName) == *itSig) isSig = true;
   }
   if (!isSig) {
    std::cout << std::setw (8) << reduced_name_samples.at(iName) << "  ";
   }
  }
 }
 std::cout << std::endl;
 
 std::cout << std::setw (12) << " process  " << std::setw (8) << 0 << "  ";
 for (int i=0; i < (reduced_name_samples.size() - SignalName.size() - 1); i++){
  std::cout << std::setw (8) << i+1 << "  ";
 }
 std::cout << std::endl;
 
 std::cout << std::setw (12) << " rate  " << std::setw (8) << totalSig << "  ";
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  if (iName != numDATA) {
   bool isSig = false;
   for (std::vector<std::string>::const_iterator itSig = SignalName.begin(); itSig != SignalName.end(); itSig++){
    if (reduced_name_samples.at(iName) == *itSig) isSig = true;
   }
   if (!isSig) {
    std::cout << std::setw (8) << hTrend[iName]->GetBinContent(vCut.size()) << "  ";
   }
  }
 }
 std::cout << std::endl;
 
 
 std::cout << "-------------------------------------------------" << std::endl;
 
 
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 std::cout << std::endl;
 
 
 
 
 
 
 ///==== draw trend vs cut (begin)
 cTrend->cd();
 DrawStack(hsTrend,1,LumiSyst);
 hTrend[numDATA] -> Draw("EsameP");
 gPad->SetLogy();
 gPad->SetGrid();
 leg->Draw();
 latex->Draw();
  
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  TString nameCanvas = Form("%d_Canvas_Trend",iCut);
  cTrendPie[iCut] = new TCanvas(nameCanvas,nameCanvas,400,400);
  cTrendPie[iCut]->cd();
  hTrendPie[iCut] -> Draw("3d t nol");
  hTrendPie[iCut]->SetX(.45);
  hTrendPie[iCut]->SetRadius(.22);
  leg->Draw();
  latex->Draw();
  
  cTrendPieAll->cd(iCut+1);
  hTrendPie[iCut] -> Draw("3d t nol");
  hTrendPie[iCut]->SetX(.45);
  hTrendPie[iCut]->SetRadius(.22);
  leg->Draw();
  latex->Draw();
 }
 ///==== draw trend vs cut (end)
 
 
 
 std::cerr << " ******************************************* end *******************************************" << std::endl;
 end = clock();
 std::cout <<"Time = " <<  ((double) (end - start)) << " (a.u.)" << std::endl;  
 
 
 
 ///==== save output ====
 outFile.cd();
 cTrend -> Write();
 
 outFile.mkdir("Trend");
 outFile.cd("Trend");
 for (unsigned int iCut = 0; iCut<vCut.size(); iCut++){
  cTrendPie[iCut] -> Write();
 }
 cTrendPieAll -> Write();
 
 
 outFile.cd();
 outFile.mkdir("PU");
 outFile.cd("PU");
 
 hPUMC     -> Write();
 hPUDATA   -> Write();
 hPUWeight -> Write();
 
 
 outFile.cd();
 outFile.mkdir("Sample");
 outFile.cd("Sample");
 
 for (unsigned int iName=0; iName<reduced_name_samples.size(); iName++){
  cTrendSample[iName] ->Write();
 }  
 
 leg->Write();
 
}
示例#30
0
void doPlotsBtag_Log(bool logPlot){
setTDRStyle();

double lumi = 5800;
//stuff to choose
//bool logPlot = false; //true for log plot
int rebinFact = 1;

//isolation selection
//TString Isolation = "QCD No Iso/";
TString Isolation = "Ref selection/";
//TString Isolation = "QCD mu+jets PFRelIso/";
//TString Isolation = "QCD non iso mu+jets/";

TString Systematic = "central";

// number of btags
TString Nbtags = "2btags";  //standard  "2btags" , qcd "0btag"

//choose object
TString Obj = "";
//TString Obj = "MET/";

//muon variables
const int N = 2;
TString Variable;
TString Variables[N] = {"N_BJets", "N_BJets_reweighted"};
double MinXs[N] = {-0.5,-0.5};
double MaxXs[N] = {7.5,7.5};
TString XTitles[N] = {"B-tag Multiplicity", "B-tag Multiplicity"};



//loop over variables
for(int i = 0; i<2; i++){
double MinX = MinXs[i];
double MaxX = MaxXs[i];
Variable = Variables[i];
TString Xtitle = XTitles[i];

//Data
TH1D* data = getSample("SingleMu", 1, Obj, Variable, Isolation, rebinFact, "central");

//MC
TH1D* tt = getSample("TTJet", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* wjets = getSample("W1Jet", lumi*37509/57708550, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* w2jets = getSample("W2Jets", lumi*1750.0/34041404, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* w3jets = getSample("W3Jets", lumi*519.0/15536443, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* w4jets = getSample("W4Jets", lumi*214.0/13370904, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* zjets = getSample("DY1JetsToLL", lumi*5745.25/30457954, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* z2jets = getSample("DY2JetsToLL", lumi*181.0/21835749, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* z3jets = getSample("DY3JetsToLL", lumi*51.1/11010628, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* z4jets = getSample("DY4JetsToLL", lumi*23.04/6391785, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5",     lumi*34679.3/8500505, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd2 = getSample("QCD_Pt-20to30_MuEnrichedPt5",   lumi*2.87e8 * 0.0065/8486893, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd3 = getSample("QCD_Pt-30to50_MuEnrichedPt5",   lumi*6.609e7 * 0.0122/8928999, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd4 = getSample("QCD_Pt-50to80_MuEnrichedPt5",   lumi*8082000.0 * 0.0218/7256011, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd5 = getSample("QCD_Pt-80to120_MuEnrichedPt5",  lumi*1024000.0 * 0.0395/9030624, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd6 = getSample("QCD_Pt-120to170_MuEnrichedPt5", lumi*157800.0 * 0.0473/8500505, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd7 = getSample("QCD_Pt-170to300_MuEnrichedPt5", lumi*34020.0 * 0.0676/7662483, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd8 = getSample("QCD_Pt-300to470_MuEnrichedPt5", lumi*1757.0 * 0.0864/7797481, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd9 = getSample("QCD_Pt-470to600_MuEnrichedPt5", lumi*115.2 * 0.1024/2995767, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd10 = getSample("QCD_Pt-800to1000_MuEnrichedPt5",lumi*3.57 * 0.1033/4047142, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd11 = getSample("QCD_Pt-1000_MuEnrichedPt5",     lumi*0.774 * 0.1097/3807263, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* top_t = getSample("T_t-channel", lumi*56.4/3757707, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* top_tw = getSample("T_tW-channel", lumi*11.1/497395, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* top_s = getSample("T_s-channel", lumi*3.79/249516, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* tbar_t = getSample("Tbar_t-channel", lumi*30.7/1934817, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* tbar_tw = getSample("Tbar_tW-channel", lumi*11.1/493239, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* tbar_s = getSample("Tbar_s-channel", lumi*1.76/139948, Obj, Variable, Isolation, rebinFact, Systematic);

//make combined top and single top template
TH1D* sing_top = (TH1D*)top_t->Clone("top");
sing_top->Add(top_tw);sing_top->Add(top_s); sing_top->Add(tbar_t); sing_top->Add(tbar_tw);sing_top->Add(tbar_s);

zjets->Add(z2jets);
zjets->Add(z3jets);
zjets->Add(z4jets);  

wjets->Add(w2jets);
wjets->Add(w3jets);
wjets->Add(w4jets);

//make combined top and single top template
TH1D* qcd_all = (TH1D*)qcd->Clone("qcd_all");
qcd_all->Add(qcd2);
qcd_all->Add(qcd3);
qcd_all->Add(qcd4);
qcd_all->Add(qcd5);
qcd_all->Add(qcd6);
qcd_all->Add(qcd7);
qcd_all->Add(qcd8);
qcd_all->Add(qcd9);
qcd_all->Add(qcd10);
qcd_all->Add(qcd11);
  
THStack *hs = new THStack("hs","test");

qcd_all->SetLineColor(kBlack);
zjets->SetLineColor(kBlack);
wjets->SetLineColor(kBlack);	
sing_top->SetLineColor(kBlack);
tt->SetLineColor(kBlack);	

  hs->Add(qcd_all);
  hs->Add(zjets);
  hs->Add(wjets);
  hs->Add(sing_top);
  hs->Add(tt);

  //draw histos to files
  TCanvas *c1 = new TCanvas("Plot","Plot",900, 600);
		
  hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.2);
  hs->SetMinimum(1.);
  
  hs->Draw();
  data->Draw("E same");
  data->SetMarkerStyle(20);

//events:
cout << "ttbar: " << tt->Integral() << endl;
cout << "data: " << data->Integral() << endl;
  
  if(logPlot == true){
  hs->GetXaxis()->SetLimits(MinX, MaxX);
  }else{
  hs->GetXaxis()->SetLimits(MinX, 4.5);
  }
  
  hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05);
  hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05);
  
  
  	TLegend *tleg2;
	tleg2 = new TLegend(0.7,0.7,0.8,0.9);
	tleg2->SetTextSize(0.04);
	tleg2->SetBorderSize(0);
	tleg2->SetFillColor(10);
	tleg2->AddEntry(data , "2012 data", "lpe");
	tleg2->AddEntry(tt , "t#bar{t}", "f");
	tleg2->AddEntry(sing_top, "single top", "f");
	tleg2->AddEntry(wjets , "w+jets", "f");
	tleg2->AddEntry(zjets , "z+jets", "f");
	tleg2->AddEntry(qcd_all , "QCD", "f");
	
	//tleg2->AddEntry(singtEff, "single-t"      , "l");
	//tleg2->AddEntry(singtwEff, "single-tW"      , "l");
 	tleg2->Draw("same");	
	
	if(logPlot == true){
  	TText* textPrelim = doPrelim(0.12,0.96, "#geq 0 btags");
	textPrelim->Draw();
  	}else{
	TText* textPrelim = doPrelim(0.2,0.96, "");
	textPrelim->Draw();
	}
	
  if(logPlot ==true){
  c1->SetLogy();
  }	
  
  TString plotName("Plots/TTbarPlusVarAnalysis/Nbtags/");
  
  if(logPlot ==true){
    plotName += Variable+"_Log";  
  }else{
    plotName += Variable;  
  }
 
 
  c1->SaveAs(plotName+".pdf");
  c1->SaveAs(plotName+".png");
  delete c1;
  
  }
  	
}