예제 #1
0
void DrawHistos(TString infile = "histos.root"){
    set_plot_style();
    gStyle->SetOptStat(0);
    gStyle->SetOptTitle(0);
    
    TFile *_file0 = TFile::Open(infile);
    TH1* hHardPartonspT = (TH1*)gROOT->FindObject("hHardPartonspT");
    TH1* hHardPartonsName = (TH1*)gROOT->FindObject("hHardPartonsName");
    TH1* hParticlepT = (TH1*)gROOT->FindObject("hParticlepT");
    TH2* hParticleEtaPhi = (TH2*)gROOT->FindObject("hParticleEtaPhi");

    TCanvas* can1 = new TCanvas("can1","",600,600);
    gPad->SetLeftMargin(0.15);
    gPad->SetLogy();
    SetHist(hParticlepT,"p_{T} (GeV/c)","Counts",2);
    SetHist(hHardPartonspT,"p_{T} (GeV/c)","Counts",1);
    hParticlepT->Draw();
    hHardPartonspT->Draw("same");
    TLegend* leg1 = new TLegend(0.6,0.7,0.85,0.85);
    SetLeg(leg1);
    leg1->AddEntry(hHardPartonspT,"Hard Parton","L");
    leg1->AddEntry(hParticlepT,"Final Particles","L");
    leg1->Draw();
    can1->SaveAs("pTgraph.png");
    
    TCanvas* can2 = new TCanvas("can2","",600,600);
    gPad->SetLeftMargin(0.15);
    SetHist(hHardPartonsName,"parton ID","Counts",1);
    hHardPartonsName->Draw();
    
    TCanvas* can3 = new TCanvas("can3","",600,600);
    gPad->SetLeftMargin(0.15);
    SetHist(hParticleEtaPhi,"p_{T} (GeV/c)","Counts",1);
    hParticleEtaPhi->Draw("COLZ");
   
    
  }
예제 #2
0
void GetFRFromSingleEl(){
  
  TString pathmc= "/home/jalmond/Analysis/LQanalyzer/data/output/SSElectronSingleEl/HNDiElectron_mc_5_3_14.root";
  TString pathdata= "/home/jalmond/Analysis/LQanalyzer/data/output/SSElectronSingleEl/HNDiElectron_data_5_3_14.root";
  TString pathnp= "/home/jalmond/Analysis/LQanalyzer/data/output/SSElectronSingleEl/NP/HNDiElectron_SKnonprompt_5_3_14.root";

  TFile * fmc = new TFile(pathmc.Data());
  TFile * fdata = new TFile(pathdata.Data());
  TFile * fnp = new TFile(pathnp.Data());
  if(!fmc) return;
  /// Set Plotting style                                                                                                                              
  setTDRStyle();
  gStyle->SetPalette(1);


  TH1F* h_data_hist =  dynamic_cast<TH1F*>(fdata->Get("SingleEl_CR/h_leadingElectronPt_SingleEl_CR"));
  TH1F* h_mc = dynamic_cast<TH1F*>(fmc->Get("SingleEl_CR/h_leadingElectronPt_SingleEl_CR"));
  
  CheckHist(h_data_hist);
  CheckHist(h_mc);

  TCanvas* c1 = new TCanvas("GetFRFromSingleEl", "Plot", 800, 600);

  SetApp(h_data_hist, kRed, 1,3);
  SetApp(h_mc, kBlue, 1,3);

  Rebin(h_data_hist, h_mc, 1);

  SetHist(h_data_hist,  h_mc, "p_{T} [GeV]", "Events",  0., 100.);

  h_data_hist->Draw("hist");
  
  
  TH1* h_np =  dynamic_cast<TH1F*>(h_data_hist->Clone("clone"));
  
  for(int ibin=1; ibin < h_np->GetNbinsX()+1; ibin++){
    float npvalue = h_data_hist->GetBinContent(ibin) - h_mc->GetBinContent(ibin);
    h_np->SetBinContent(ibin, npvalue);
  }
  
  h_mc->Add(h_np,1.);
  h_mc->Draw("histsame");
  
  TLegend* legend= new TLegend(0.5,0.8,0.7,0.9);
  legend->SetFillColor(10);
  legend->SetBorderSize(0);
  legend->SetTextSize(0.04);
  
  legend->AddEntry(h_data_hist,"data", "l");
  legend->AddEntry(h_mc,"bkg","l");
  legend->Draw("same");
  
  TH1F* h_loose = dynamic_cast<TH1F*>(fnp->Get("SingleElLoose_CR/h_leadingElectronPt_SingleElLoose_CR"));
  TH1F* h_tight = dynamic_cast<TH1F*>(fnp->Get("SingleElTight_CR/h_leadingElectronPt_SingleElTight_CR"));
  
  vector<double> r;
  r.push_back(0.80);
  r.push_back(0.81);
  r.push_back(0.855);
  r.push_back(0.878);
  r.push_back(0.90);
  r.push_back(0.92);
  r.push_back(0.94);
  r.push_back(0.95);
  r.push_back(0.96);
  r.push_back(0.97);
  r.push_back(0.99);
  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);
r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);
 r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);  r.push_back(0.99);

  for(int ibin=1; ibin < h_np->GetNbinsX()+1; ibin++){
    cout << "Number of fakes = " << h_np->GetBinContent(ibin) << " while number of loose = " << h_loose->GetBinContent(ibin) << " number pf tight = " <<  h_tight->GetBinContent(ibin) << endl;
    if(h_np->GetBinContent(ibin) > 0) {
      double fratio = h_np->GetBinContent(ibin) / h_loose->GetBinContent(ibin); 
      double fr = fratio/ (1.+fratio);
      cout << "(lowest bound on) Fake rate = " << fr << endl;
      
      double alpha = 1./(r.at(ibin-1) - fr);
      double ftight = h_tight->GetBinContent(ibin) *  alpha * fr * (1- r.at(ibin-1));
      
      fratio = (h_np->GetBinContent(ibin) + ftight  ) / h_loose->GetBinContent(ibin);
      fr = fratio/ (1.+fratio); 

      cout << "(1st it bound on) Fake rate = " << fr << endl;
      
      ftight = h_tight->GetBinContent(ibin) *  alpha * fr * (1- r.at(ibin-1));

      fratio = (h_np->GetBinContent(ibin) + ftight  ) / h_loose->GetBinContent(ibin);
      fr = fratio/ (1.+fratio);

      cout << "(2st it bound on) Fake rate = " << fr << endl;

      ftight = h_tight->GetBinContent(ibin) *  alpha * fr * (1- r.at(ibin-1));

      fratio = (h_np->GetBinContent(ibin) + ftight  ) / h_loose->GetBinContent(ibin);
      fr = fratio/ (1.+fratio);

      cout << "(3rd it bound on) Fake rate = " << fr << endl;

      ftight = h_tight->GetBinContent(ibin) *  alpha * fr * (1- r.at(ibin-1));

      fratio = (h_np->GetBinContent(ibin) + ftight  ) / h_loose->GetBinContent(ibin);
      fr = fratio/ (1.+fratio);

      cout << "(4th it bound on) Fake rate = " << fr << endl;


    }
    
  }
  
  c1->SaveAs(("GetFRFromSingleEl_pt.pdf"));
}