コード例 #1
0
ファイル: drawhwwshapevar.C プロジェクト: jaehyeok/hww2013
void drawshapesystsinglemass(TString mvaType, ofstream & text, int mH, int njet, TString cardDir, TString outputDir)
{

  const char *table_head = "\\begin{figure}[!htb]\n\\begin{center}\n\\begin{tabular}{cc}\n";
  const char *table_end = "\\end{tabular}\n\\end{center}\n";
  const char *table_caption = "The central shape is shown with black lines with error bars. The up and down shape variations are shown with red and blue dashed lines respectively. The ratio between the up/down shapes to the central one is shown as well. }\n\\end{figure}\n";
  
  // write down the plots in latex format

  // ggH variations
  // text << table_head;
  //  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "ggH", "ggHBounding", false, false);
  // drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "of", "ggH", "ggHBounding", false, false);
  // text << table_end;
  // text << Form("\\caption{%s output shape variations for ggH due to higher order effects in sf (left) and of (right) for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;

  // WW variations
  text << table_head;
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "qqWW", "WWBounding", false, true);
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "of", "qqWW", "WWBounding", false, true);
  text << table_end;
  text << Form("\\caption{%s output shape variations for WW due to higher order effects from mc@nlo and madgraph differences in sf (left) and of (right) for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;

  // WW variations
  text << table_head;
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "qqWW", "WWNLOBounding", false, true);
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "of", "qqWW", "WWNLOBounding", false, true);
  text << table_end;
  text << Form("\\caption{%s output shape variations for WW due to qcd scale variations from mc@nlo in sf (left) and of (right) for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;
/*
  // Wjets variations
  text << table_head;
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "Wjets", "WBounding", false, true);
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "of", "Wjets", "WBounding", false, true);
  text << table_end;
  text << Form("\\caption{%s output shape variations for Wjets due to FR variations in data, in sf (left) and of (right) for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;
*/
 /* 
  // Wjets variations
  text << table_head;
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "Wjets", "WMCBounding", false, true);
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "of", "Wjets", "WMCBounding", false, true);
  text << table_end;
  text << Form("\\caption{%s output shape variations for Wjets due to data/MC differences, in sf (left) and of (right) for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;
*/ 
/*
  // Zjets variations
  text << table_head;
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "Zjets", "ZBounding", true, true);
  text << table_end;
  text << Form("\\caption{%s output shape variations for Zjets due to the difference between the loose met region in data and the signal region in MC in the sf for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;
  
 
  // Top variation
  text << table_head;
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "Top", "TopBounding", false, true);
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "of", "Top", "TopBounding", false, true);
  text << table_end;
  text << Form("\\caption{%s output shape variations for Top due to powheg/madgraph differences, in sf (left) and of (right) for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;

  // MET variation for qqWW
  text << table_head;
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "qqWW", "METResBounding", false, true);
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "of", "qqWW", "METResBounding", false, true);
  text << table_end;
  text << Form("\\caption{%s output shape variations for qqWW due to MET resolution, in sf (left) and of (right) for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;

  // LEPRES variation for qqWW
  text << table_head;
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "qqWW", "LepResBounding", false, true);
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "of", "qqWW", "LepResBounding", false, true);
  text << table_end;
  text << Form("\\caption{%s output shape variations for qqWW due to lepton resolution, in sf (left) and of (right) for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;

  // LepEff variation for qqWW
  text << table_head;
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "qqWW", "LepEffBounding", false, true);
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "of", "qqWW", "LepEffBounding", false, true);
  text << table_end;
  text << Form("\\caption{%s output shape variations for qqWW due to lepton efficiency, in sf (left) and of (right) for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;

  // LEPRES variation for qqWW
  text << table_head;
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "sf", "qqWW", "JESBounding", false, true);
  drawsingle(mvaType, cardDir, outputDir, text, mH, njet, "of", "qqWW", "JESBounding", false, true);
  text << table_end;
  text << Form("\\caption{%s output shape variations for qqWW due to Jet Energy Scale, in sf (left) and of (right) for mH=%i GeV in the %i jet bin.", mvaType.Data(), mH, njet) << table_caption;
*/
}
コード例 #2
0
ファイル: comparesample.C プロジェクト: nhanvtran/usercode
void createPlot(std::vector<TString> samples, std::vector<TString> files, std::vector<TString> legend)
{

  TString y_title = "Number of Entries";
  const int nHist = files.size(); // number of files

  // Declare the histograms to be saved 
  TH1F *h_mll[nHist];
  TH1F *h_dilpt[nHist];
  TH1F *h_dphill[nHist];
  TH1F *h_leadleppt[nHist];
  TH1F *h_trailleppt[nHist];
  TH1F *h_met[nHist];
  TH1F *h_mt[nHist];
  
  // Get the histograms from the ntuples
  for (int i=0;i<nHist;i++) {
    TString treeName = "angles";
    TChain *chain = new TChain(treeName);
    chain->Add(files[i]);
    assert(chain);
    
    // declare histograms  to fill
    Color_t color = kBlack;
    TString sampleName = samples[i];
    if ( sampleName.Contains("SMHiggs",TString::kExact )) color = kBlue;
    if ( sampleName.Contains("PSHiggs", TString::kExact)) color = kMagenta;
    if ( sampleName.Contains("T",  TString::kExact)) color = kRed;
    if ( sampleName.Contains("THiggs",  TString::kExact)) color = kRed;


    
    // define the histograms to plot
    
    // dilmass 
    h_mll[i] = new TH1F(TString("HWW_"+sampleName+"_hdilmass"), TString("HWW_"+sampleName+"_hdilmass"), 20, 0, 200);
    h_mll[i]->SetLineColor(color);
    h_mll[i]->SetMarkerColor(color);
    
    // leading lepton pT
    h_leadleppt[i] = new TH1F(TString("HWW_"+sampleName+"_hleadleppt"), TString("HWW_"+sampleName+"_hleadleppt"), 20, 0, 100);
    h_leadleppt[i]->SetLineColor(color);
    h_leadleppt[i]->SetMarkerColor(color);
   
    // trailing lepton pT
    h_trailleppt[i] = new TH1F(TString("HWW_"+sampleName+"_htrailleppt"), TString("HWW_"+sampleName+"_htrailleppt"), 20, 0, 100);
    h_trailleppt[i]->SetLineColor(color);
    h_trailleppt[i]->SetMarkerColor(color);
    
    // MET
    h_met[i] = new TH1F(TString("HWW_"+sampleName+"_hmet"), TString("HWW_"+sampleName+"_hmet"), 20, 0, 100);
    h_met[i]->SetLineColor(color);
    h_met[i]->SetMarkerColor(color);
    
    
    // dilepton pT
    h_dilpt[i] = new TH1F(TString("HWW_"+sampleName+"_hdilpt"), TString("HWW_"+sampleName+"_hdilpt"), 30, 20, 100);
    h_dilpt[i]->SetLineColor(color);
    h_dilpt[i]->SetMarkerColor(color);
    
    // deltaphi (ll)
    h_dphill[i] = new TH1F(TString("HWW_"+sampleName+"_hdphi"), TString("HWW_"+sampleName+"_hdphi"), 18, 0, 180.0);
    h_dphill[i]->SetLineColor(color);
    h_dphill[i]->SetMarkerColor(color);
    
    // transverse mass
    h_mt[i] = new TH1F(TString("HWW_"+sampleName+"_hmt"), TString("HWW_"+sampleName+"_hmt"), 20, 0, 200);
    h_mt[i]->SetLineColor(color);
    h_mt[i]->SetMarkerColor(color);
    

    std::cout  << "Processing " << chain->GetEntries() << " entries. \n";
    int nEntries =  chain->GetEntries() ;
    int nSelected = 0;
    
    // mcfm variables to be used
    double mll_ = 0.0;
    double leadleppt_ = 0.0;
    double trailleppt_ = 0.0;
    double leadlepeta_ = 0.0;
    double traillepeta_ = 0.0;
    double dphill_ = 0.0;
    double met_ = 0.0;
    double mt_ = 0.0;
    double dilpt_ = 0.0;
    double wt_ = 1.0;

    if (chain->GetBranchStatus("mll"))
      chain->SetBranchAddress("mll", &mll_);

    if (chain->GetBranchStatus("leadleppt"))
      chain->SetBranchAddress("leadleppt", &leadleppt_);

    if (chain->GetBranchStatus("trailleppt"))
      chain->SetBranchAddress("trailleppt", &trailleppt_);

    if (chain->GetBranchStatus("dphill"))
      chain->SetBranchAddress("dphill", &dphill_);

    if (chain->GetBranchStatus("met"))
      chain->SetBranchAddress("met", &met_);
    
    if (chain->GetBranchStatus("mt"))
      chain->SetBranchAddress("mt", &mt_);

    if (chain->GetBranchStatus("dilpt"))
      chain->SetBranchAddress("dilpt", &dilpt_);
    
      if (chain->GetBranchStatus("leadlepeta"))
      chain->SetBranchAddress("leadlepeta", &leadlepeta_);

    if (chain->GetBranchStatus("traillepeta"))
      chain->SetBranchAddress("traillepeta", &traillepeta_);

    if (chain->GetBranchStatus("wt"))
      chain->SetBranchAddress("wt", &wt_);
   
    for ( int ievt = 0; ievt < chain->GetEntries(); ievt++) {
      chain->GetEntry(ievt);
      
      //
      // apply WW selections
      // 
      
      if ( ievt == 0 ) 
	std::cout << leadleppt_ << "\t" << trailleppt_ << "\t" << dilpt_ << "\t" << met_ << "\t" << mll_ << "\n";

      float weight = wt_;

      if ( leadleppt_ < 20. ) continue;
      if ( trailleppt_ < 10. ) continue;
      if ( TMath::Abs(leadlepeta_) > 2.5) continue;
      if ( TMath::Abs(traillepeta_) > 2.5) continue;
      
      /*
      if ( dilpt_ < 45.) continue;
      if ( mll_ < 12.) continue;
      if ( met_ < 20.) continue;

      */
      
      h_mll[i]->Fill(mll_, weight);
      h_dilpt[i]->Fill(dilpt_, weight);
      h_dphill[i]->Fill(dphill_ * 180. / TMath::Pi(), weight);
      h_leadleppt[i]->Fill(leadleppt_, weight);
      h_trailleppt[i]->Fill(trailleppt_, weight);
      h_mt[i]->Fill(mt_, weight);
      h_met[i]->Fill(met_, weight);

      // 
      // apply HWW selections for 125 
      // 
      
      if ( higgselection(mH, mt_, mll_, dphill_, leadleppt_, trailleppt_) ) 
	nSelected++;
    } // end of event loop in each sample
    
    std::cout << Form("sample %s: selection effiency is %i / %i = %.2f\n", samples[i].Data(), nSelected, nEntries, float(nSelected)/float(nEntries));
  }
  
  drawsingle("mll", nHist, h_mll, samples, legend, "Dilepton Invariant Mass [GeV]");
  drawsingle("dphill", nHist, h_dphill, samples, legend, "#Delta#phi(leptons) [degrees]");
  drawsingle("mt", nHist, h_mt, samples, legend, "Transverse Higgs Mass [GeV]");
  drawsingle("met", nHist, h_met, samples, legend, "Transverse Missing Energy [GeV]");
  drawsingle("dilpt", nHist, h_dilpt, samples, legend, "Dilepton pT [GeV]");
  
  output_file->cd();
  
  for(int i=0;i<nHist;i++) {
    h_mll[i]->Write();
    h_dphill[i]->Write();
    h_leadleppt[i]->Write();
    h_trailleppt[i]->Write();
    h_met[i]->Write();
    h_mt[i]->Write();
    h_dilpt[i]->Write();
    
  }
  
  // tidy up
  
  for ( int i = 0; i<nHist;i++) {
    delete h_mll[i];
    delete h_dphill[i];
    delete h_leadleppt[i];
    delete h_trailleppt[i];
    delete h_met[i];
    delete h_mt[i];
    delete h_dilpt[i];
  }

}
コード例 #3
0
ファイル: drawsimple8vs7.C プロジェクト: yanyangao/usercode
void drawsimple8vs7()
{

  bool normalize = 1;
  bool doEightTeV = 1;
  
  bool doWW = 0;
  bool doHiggs = 1;
  
  
  TString plotDir;
  TString fileName;

  
  if ( doWW) {
    plotDir = Form("wwmadgraph/%s/", cuts.Data());
    fileName = Form("histos_wwmadgraph_%s.root", cuts.Data());
    drawsingle(fileName, "mt_ww", "Transverse Higgs Mass [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "met_ww", "MET [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "leadleppt_ww", "Leading Lepton pT [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "trailleppt_ww", "Trailing Lepton pT [GeV]", normalize, doEightTeV, plotDir); 
    drawsingle(fileName, "leadlepeta_ww", "Leading Lepton #eta [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "traillepeta_ww", "Trailing Lepton #eta [GeV]", normalize, doEightTeV, plotDir); 
    drawsingle(fileName, "mll_ww", "Dilepton Mass [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "dilpt_ww", "Dilepton pT [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "dPhi_ww", "#Delta#Phi(dileptons) [degrees]", normalize, doEightTeV, plotDir);
    // drawsingle(fileName, "dR_ww", "#Delta R(dileptons)", normalize, doEightTeV, plotDir);
  }

  if ( doHiggs) {
    plotDir = Form("hww%i/%s/", mH, cuts.Data());;
    if ( fromMCFM) 
      plotDir = Form("hww%imcfm/%s/", mH, cuts.Data());;
    fileName = Form("histos_hww%i_%s.root", mH, cuts.Data());
    drawsingle(fileName, "mt_hww", "Transverse Higgs Mass [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "met_hww", "MET [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "leadleppt_hww", "Leading Lepton pT [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "trailleppt_hww", "Trailing Lepton pT [GeV]", normalize, doEightTeV, plotDir); 
    drawsingle(fileName, "leadlepeta_hww", "Leading Lepton #eta [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "traillepeta_hww", "Trailing Lepton #eta [GeV]", normalize, doEightTeV, plotDir); 
    drawsingle(fileName, "mll_hww", "Dilepton Mass [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "dilpt_hww", "Dilepton pT [GeV]", normalize, doEightTeV, plotDir);
    drawsingle(fileName, "dPhi_hww", "#Delta#Phi(dileptons) [degrees]", normalize, doEightTeV, plotDir);
  }
  
}