Beispiel #1
0
int main( int argc, char* argv[] ) {

  if( argc!=3 && argc!=4 ) {
    std::cout << "USAGE: ./draw_golfcourse [(string)data_dataset] [data_mc] [nbtags=\"ALL\"]" << std::endl;
    exit(23);
  }
  

  std::string data_dataset(argv[1]);

  std::string data_mc(argv[2]);

  int nbtags=-1;
  if( argc==4 ) {
    nbtags = atoi(argv[3]);
  }


  TString data_dataset_tstr(data_dataset);
  std::string PUType = "Run2011A";
  float lumi = 2100.;
  if( data_dataset=="HR11" ) {
    PUType = "HR11";
    lumi = 4200.;
  } else if( data_dataset=="HR11_v2" ) {
    PUType = "HR11_73pb";
    lumi = 4600.;
  } if( data_dataset_tstr.BeginsWith("Run2011B") ) {
    PUType = "Run2011B";
  }

  DrawBase* db = new DrawBase("Golfcourse");
  db->set_lumiNormalization(lumi);
  std::string dataFileName = "HZZlljjRM_DATA_" + data_dataset + "_optLD_looseBTags_v2_ALL.root";
  TFile* file_data = TFile::Open(dataFileName.c_str());
  db->add_dataFile( file_data, "data" );

  //db->set_isCMSArticle(true);

  TGraph* graphObserved = get_observedLimit( data_dataset, data_mc, nbtags );

  graphObserved->SetMarkerStyle(21);
  graphObserved->SetMarkerSize(.85);
  graphObserved->SetLineWidth(3.);
  //graphObserved->SetMarkerColor(kGreen+4);
  //graphObserved->SetMarkerSize(1.);

  std::pair<TGraphAsymmErrors*,TGraphAsymmErrors*> graphs_expected = get_expectedLimit( data_dataset, data_mc, nbtags );
  TGraphAsymmErrors* graphExpected68 = graphs_expected.first;
  TGraphAsymmErrors* graphExpected95 = graphs_expected.second;

  TGraphAsymmErrors* graphExpected68_forLegend = new TGraphAsymmErrors(*graphExpected68);
  graphExpected68_forLegend->SetFillColor(kGreen);

  graphExpected68->SetFillColor(kGreen);
  graphExpected68->SetLineColor(kBlack);
  graphExpected68->SetLineStyle(2);
  graphExpected68->SetLineWidth(2);
  graphExpected68->SetFillStyle(1001);//solid

  graphExpected95->SetFillColor(kYellow);
  graphExpected95->SetFillStyle(1001);//solid

  float xmin = 180.;
  float xmax = 620.;

  float yMax = 8.;
  if( data_dataset=="Run2011A_FULL" ) yMax = 10.;
  if( nbtags!=-1 ) yMax=12.;

  TH2D* axes = new TH2D("axes", "", 10, xmin, xmax, 10, 0., yMax );
  axes->SetXTitle("m_{H} [GeV]");
  axes->SetYTitle("#sigma_{95%} / #sigma_{SM}");

  //TPaveText* labelCMS = get_labelCMS(db);
  TPaveText* labelCMS = db->get_labelCMS();
  TPaveText* labelSqrt = db->get_labelSqrt();


  TLine* line_one = new TLine( xmin, 1., xmax, 1.);
  line_one->SetLineColor(kRed);
  line_one->SetLineWidth(2);

  char legendTitle[200];
  sprintf( legendTitle, "%d b-tag Category", nbtags );

  TLegend* legend;
  if( nbtags!=-1 ) 
    legend = new TLegend( 0.35, 0.6, 0.85, 0.90, legendTitle );
  else
    legend = new TLegend( 0.35, 0.6, 0.85, 0.90);
  legend->SetFillColor(10);
  legend->SetFillStyle(1001);
  legend->SetBorderSize(1);
  legend->SetTextSize(0.034);
  legend->SetTextFont(42);
  legend->AddEntry( graphExpected68, "Bayesian Expected", "L" ); 
  legend->AddEntry( graphExpected68_forLegend, "Expected #pm 1#sigma", "F" ); 
  legend->AddEntry( graphExpected95, "Expected #pm 2#sigma", "F" ); 
  legend->AddEntry( line_one, "SM", "L" ); 

  TCanvas* c1 = new TCanvas("c1", "", 630, 600);
  c1->SetGrid(true);
  c1->cd();
  axes->Draw("AXIS");
  labelCMS->Draw("same");
  labelSqrt->Draw("same");
  graphExpected95->Draw("3same");
  graphExpected68->Draw("3same");
  graphExpected68->Draw("LXsame");
  gPad->RedrawAxis();
  line_one->Draw("same");
  legend->Draw("same");

  char canvasName[500];
  if( nbtags>=0 )
    sprintf( canvasName, "datacards_%s_fit%s/upperLimitExpected_%s_%dbtag.eps", data_dataset.c_str(), data_mc.c_str(), data_dataset.c_str(), nbtags );
  else
    sprintf( canvasName, "datacards_%s_fit%s/upperLimitExpected_%s.eps", data_dataset.c_str(), data_mc.c_str(), data_dataset.c_str() );
  c1->SaveAs(canvasName);


  c1->Clear();

  // now also observed:

  TLegend* legend2;
  if( nbtags!=-1 ) 
    legend2 = new TLegend( 0.35, 0.6, 0.85, 0.90, legendTitle );
  else
    legend2 = new TLegend( 0.35, 0.6, 0.85, 0.90);
  legend2->SetFillColor(10);
  legend2->SetFillStyle(1001);
  legend2->SetBorderSize(1);
  legend2->SetTextSize(0.034);
  legend2->SetTextFont(42);
  legend2->AddEntry( graphObserved, "Bayesian Observed", "LP" ); 
  legend2->AddEntry( graphExpected68, "Bayesian Expected", "L" ); 
  legend2->AddEntry( graphExpected68_forLegend, "Expected #pm 1#sigma", "F" ); 
  legend2->AddEntry( graphExpected95, "Expected #pm 2#sigma", "F" ); 
  legend2->AddEntry( line_one, "SM", "L" ); 


  axes->Draw();
  labelCMS->Draw("same");
  labelSqrt->Draw("same");
  graphExpected95->Draw("3same");
  graphExpected68->Draw("3same");
  graphExpected68->Draw("LXsame");
  gPad->RedrawAxis();
  line_one->Draw("same");
  graphObserved->Draw("PLsame");
  legend2->Draw("same");

  if( nbtags>=0 )
    sprintf( canvasName, "datacards_%s_fit%s/upperLimit_%s_%dbtag.eps", data_dataset.c_str(), data_mc.c_str(), data_dataset.c_str(), nbtags );
  else
    sprintf( canvasName, "datacards_%s_fit%s/upperLimit_%s.eps", data_dataset.c_str(), data_mc.c_str(), data_dataset.c_str() );
  c1->SaveAs(canvasName);


  char expectedLimitFileName[300];
  if( nbtags>=0 )
    sprintf( expectedLimitFileName, "datacards_%s_fit%s/expectedLimit_%s_%dbtag.txt", data_dataset.c_str(), data_mc.c_str(), data_dataset.c_str(), nbtags );
  else
    sprintf( expectedLimitFileName, "datacards_%s_fit%s/expectedLimit_%s.txt", data_dataset.c_str(), data_mc.c_str(), data_dataset.c_str() );
  ofstream ofs_expected(expectedLimitFileName);
  ofs_expected << "mH\tmedian\tlow95\tlow68\tup68\tup95" << std::endl;
  for( unsigned imass=0; imass<graphExpected95->GetN(); ++imass ) {
    Double_t mass, expectedUL;
    graphExpected95->GetPoint( imass, mass, expectedUL );
    float up95 = graphExpected95->GetErrorYhigh( imass );
    float up68 = graphExpected68->GetErrorYhigh( imass );
    float low95 = graphExpected95->GetErrorYlow( imass );
    float low68 = graphExpected68->GetErrorYlow( imass );
    ofs_expected << mass << "\t" << expectedUL << "\t" << low95 << "\t" << low68 << "\t" << up68 << "\t" << up95 << std::endl;
  }
  ofs_expected.close();

  char observedLimitFileName[300];
  if( nbtags>=0 )
    sprintf( observedLimitFileName, "datacards_%s_fit%s/observedLimit_%s_%dbtag.txt", data_dataset.c_str(), data_mc.c_str(), data_dataset.c_str(), nbtags );
  else
    sprintf( observedLimitFileName, "datacards_%s_fit%s/observedLimit_%s.txt", data_dataset.c_str(), data_mc.c_str(), data_dataset.c_str() );
  ofstream ofs_observed(observedLimitFileName);
  ofs_observed << "mH\tobservedLimit" << std::endl;
  for( unsigned imass=0; imass<graphObserved->GetN(); ++imass ) {
    Double_t mass, observedUL;
    graphObserved->GetPoint( imass, mass, observedUL );
    ofs_observed << mass << "\t" << observedUL << std::endl;
  }
  ofs_observed.close();


  return 0;


}
int main(int argc, char* argv[]) {

  if (argc != 5) {
    std::cout << "USAGE: ./drawPhotonJet [data_dataset] [mc_SIGNAL_dataset] [recoType] [jetAlgo]" << std::endl;
    exit(23);
  }

  std::string data_dataset(argv[1]);
  std::string mc_photonjet(argv[2]);
  std::string recoType(argv[3]);
  std::string jetAlgo(argv[4]);
  recoType = (recoType == "pf") ? "PFlow" : "PUPPI";
  jetAlgo = (jetAlgo == "ak4") ? "AK4" : "AK8";
  std::string postFix = recoType + jetAlgo;
  if(recoType == "PFlow") postFix += "chs";

  TString dataFileName;
  dataFileName = TString::Format("PhotonJet_%s_%s.root", data_dataset.c_str(), postFix.c_str());
  TFile* dataFile = TFile::Open(dataFileName);  
  if (dataFile) {
    std::cout << "Opened data file '" << dataFileName << "'." << std::endl;
  }
  
  TString mc1FileName;
  mc1FileName = TString::Format("PhotonJet_%s_%s.root", mc_photonjet.c_str(), postFix.c_str()); 
  TFile* mcPhotonJetFile = TFile::Open(mc1FileName);
  if (mcPhotonJetFile) {
    std::cout << "Opened mc file '" << mc1FileName << "'." << std::endl;
  }
  
  TString outputDir = TString::Format("PhotonJetPlots_%s_vs_%s_%s_EnergyFractions",data_dataset.c_str(), mc_photonjet.c_str(), postFix.c_str());
  mkdir(outputDir, 0777);
  
  TFile * inputfile;
  TString type;  
  EtaBinning etaBinning;
  size_t etaBinningSize = etaBinning.size() + 1;
  
  for(int ii = 0; ii<2; ii++){
    
    inputfile = (ii == 0) ? mcPhotonJetFile : dataFile; 
    type = (ii == 0) ? "mc" : "data"; 
    
    PtBinning ptBinning;
    std::vector<std::pair<float, float> > ptBins = ptBinning.getBinning();
    size_t ptBinningSize = ptBinning.size();
    std::pair<float, float> currentBin;
    
    TString histoName;
    TString histoName_tmp;
    TH1F *h_tmp;
    TString stackName;

    Float_t dataResponse = 0.;
    Float_t dataResponseErr = 0.;    
    //  Float_t meanTruncFraction = 0.99;
    //  Float_t rmsTruncFraction = 0.99;  
    //  Float_t dataRMS = 0.;
    //  Float_t dataRMSErr = 0.;
    
    Float_t ptphot_bins[ptBinningSize+1];
    TH1F *hCHFrac[etaBinningSize];
    TH1F *hNHFrac[etaBinningSize];
    TH1F *hElFrac[etaBinningSize];
    TH1F *hPhFrac[etaBinningSize];
    TH1F *hMuFrac[etaBinningSize];
    THStack *hsum[etaBinningSize];
    
    for(size_t j = 0; j<ptBinningSize; j++) {
      currentBin = ptBinning.getBinValue(j);
      ptphot_bins[j] = currentBin.first;
      if(j == ptBinningSize-1) ptphot_bins[j+1] = currentBin.second;
    }
    
    for (size_t i = 0; i < etaBinningSize; i++) {
      for(int frac=0; frac<5; frac++) {
	if(i == etaBinningSize-1){
	  if(frac==0){
	    histoName = TString::Format("ChHadronFraction_eta0013");
	    hCHFrac[i] = new TH1F(histoName,histoName,ptBinningSize,ptphot_bins);
	  } else if(frac==1){
	    histoName = TString::Format("NHadronFraction_eta0013");
	    hNHFrac[i] = new TH1F(histoName,histoName,ptBinningSize,ptphot_bins);
	  } else if(frac==2) {
	    histoName = TString::Format("CEmFraction_eta0013");
	    hElFrac[i] = new TH1F(histoName,histoName,ptBinningSize,ptphot_bins);
	  } else if(frac==3) {
	    histoName = TString::Format("NEmFraction_eta0013");
	    hPhFrac[i] = new TH1F(histoName,histoName,ptBinningSize,ptphot_bins);
	  } else {
	    histoName = TString::Format("MuFraction_eta0013");
	    hMuFrac[i] = new TH1F(histoName,histoName,ptBinningSize,ptphot_bins);
	  }
	}else{
	  if(frac==0){
	    histoName = TString::Format("ChHadronFraction_%s", etaBinning.getBinName(i).c_str());
	    hCHFrac[i] = new TH1F(histoName,histoName,ptBinningSize,ptphot_bins);
	  } else if(frac==1){
	    histoName = TString::Format("NHadronFraction_%s", etaBinning.getBinName(i).c_str());
	    hNHFrac[i] = new TH1F(histoName,histoName,ptBinningSize,ptphot_bins);
	  } else if(frac==2) {
	    histoName = TString::Format("CEmFraction_%s", etaBinning.getBinName(i).c_str());
	    hElFrac[i] = new TH1F(histoName,histoName,ptBinningSize,ptphot_bins);
	  } else if(frac==3) {
	    histoName = TString::Format("NEmFraction_%s", etaBinning.getBinName(i).c_str());
	    hPhFrac[i] = new TH1F(histoName,histoName,ptBinningSize,ptphot_bins);
	  } else {
	    histoName = TString::Format("MuFraction_%s", etaBinning.getBinName(i).c_str());
	    hMuFrac[i] = new TH1F(histoName,histoName,ptBinningSize,ptphot_bins);
	  }
	}

	for(size_t j = 0; j<ptBinningSize; j++) {
	  histoName_tmp=histoName;
	  currentBin = ptBinning.getBinValue(j);
	  histoName_tmp.Append(TString::Format("_ptPhot_%i",int(currentBin.first)));
	  histoName_tmp.Append(TString::Format("_%i", int(currentBin.second)));
	  h_tmp=(TH1F*)inputfile->Get("analysis/ecomposition/"+histoName_tmp);
	  //     fitTools::getTruncatedMeanAndRMS(h_tmp, dataResponse, dataResponseErr, dataRMS, dataRMSErr, meanTruncFraction, rmsTruncFraction);
	  dataResponse = h_tmp->GetMean();
	  dataResponseErr = h_tmp->GetMeanError();
	  // dataRMS = h_tmp->GetRMS();
	  // dataRMSErr = h_tmp->GetRMSError();

	  if(frac==0) {
	    hCHFrac[i]->SetBinContent(j+1,dataResponse);
	    hCHFrac[i]->SetBinError(j+1,dataResponseErr);
	  } else if(frac==1) {
	    hNHFrac[i]->SetBinContent(j+1,dataResponse);
	    hNHFrac[i]->SetBinError(j+1,dataResponseErr);
	  } else if(frac==2) {
	    hElFrac[i]->SetBinContent(j+1,dataResponse);
	    hElFrac[i]->SetBinError(j+1,dataResponseErr);
	  } else if(frac==3){
	    hPhFrac[i]->SetBinContent(j+1,dataResponse);
	    hPhFrac[i]->SetBinError(j+1,dataResponseErr);
	  } else {
	    hMuFrac[i]->SetBinContent(j+1,dataResponse);
	    hMuFrac[i]->SetBinError(j+1,dataResponseErr);
	  }	  
	}
      }//loop on frac 
      
      //stack them
      if(i == etaBinningSize-1){
	stackName = TString::Format("JetEnergyComposition_eta0013");
      }else{
	stackName = TString::Format("JetEnergyComposition_%s", etaBinning.getBinName(i).c_str());
      }
      hsum[i] = new THStack(stackName, stackName);
      
      if(type == "mc"){
	hMuFrac[i]->SetFillColor(7);
	hMuFrac[i]->SetFillStyle(1001);
	hElFrac[i]->SetFillColor(4);          
	hElFrac[i]->SetFillStyle(1001);
	hNHFrac[i]->SetFillColor(8);          
	hNHFrac[i]->SetFillStyle(1001);
	hPhFrac[i]->SetFillColor(6);     
	hPhFrac[i]->SetFillStyle(1001);  
	hCHFrac[i]->SetFillColor(2);     
	hCHFrac[i]->SetFillStyle(1001); 
      }else{
	hMuFrac[i]->SetMarkerStyle(29);
	hElFrac[i]->SetMarkerStyle(22);
	hNHFrac[i]->SetMarkerStyle(21);
	hPhFrac[i]->SetMarkerStyle(23);
	hCHFrac[i]->SetMarkerStyle(20);
      }

      hsum[i]->Add(hCHFrac[i]);      
      hsum[i]->Add(hPhFrac[i]);
      hsum[i]->Add(hNHFrac[i]);
      hsum[i]->Add(hElFrac[i]);
      hsum[i]->Add(hMuFrac[i]);     
      
      TCanvas *c = new TCanvas("c","c",600,600);    
      gPad->SetLogx();
      if(type == "mc") {
	hsum[i]->Draw("hist");
      }else{
	hsum[i]->Draw();
      }

      if(pdf_aussi) c->SaveAs(outputDir+"/"+type+"_"+stackName+".pdf");
      c->SaveAs(outputDir+"/"+type+"_"+stackName+".png");
      c->Destructor();
	 
    }// eta bins
 
    TFile out(outputDir+"/"+type+"_EComposition.root","recreate");
    out.cd();
    for (size_t i = 0; i < etaBinningSize; i++) {
      hCHFrac[i]->Write();
      hNHFrac[i]->Write();
      hElFrac[i]->Write();
      hPhFrac[i]->Write();
      hMuFrac[i]->Write();
      hsum[i]->Write();
    }
    out.Close();
  }

  TString dataName;
  dataName = TString::Format(outputDir+"/data_EComposition.root");
  TFile* data = TFile::Open(dataName);
  if (data) {
    std::cout << "Opened data file '" << dataName << "'." << std::endl;
  }
  
  TString mcName;
  mcName = TString::Format(outputDir+"/mc_EComposition.root");  
  TFile* mcFile = TFile::Open(mcName);
  if(mcFile){
    std::cout << "Opened mc file '" << mcName << "'." << std::endl;
  }

  TString histoName;
  THStack *h_data;
  THStack *h_mc;
  TString histoNameEnFrac;
  TH1F *h_dataEnFrac;
  TH1F *h_mcEnFrac;
  
  for (size_t i = 0; i < etaBinningSize; i++) {

    if(i == etaBinningSize-1){
      histoName = TString::Format("JetEnergyComposition_eta0013");
    }else{
      histoName = TString::Format("JetEnergyComposition_%s", etaBinning.getBinName(i).c_str());
    }

    h_data=(THStack*)data->Get(histoName);
    h_mc=(THStack*)mcFile->Get(histoName);

    TLegend *leg = new TLegend(0.20 , 0.1, 0.50, 0.40);

    TCanvas *c = new TCanvas("c","c",800,800);    

    // Data / MC comparison
    TPad* pad_hi = new TPad("pad_hi", "", 0., 0.3333333, 0.99, 0.99);
    pad_hi->SetLogx();
    pad_hi->SetLeftMargin(0.15);
    pad_hi->SetBottomMargin(0.015);
    pad_hi->Draw();
     
    // Data - MC
    TPad* pad_lo = new TPad("pad_lo", "", 0., 0., 0.99, 0.3333333);
    pad_lo->SetGridy();
    pad_lo->SetLogx();
    pad_lo->SetLeftMargin(0.15);
    pad_lo->SetTopMargin(1.);
    pad_lo->SetBottomMargin(0.3);
    pad_lo->Draw();
    ////////////////////////////////////     

    pad_lo->cd();
     
    for(int frac=0; frac<5; frac++) {
      if(i == etaBinningSize-1){
	if(frac==0){
	  histoNameEnFrac = TString::Format("ChHadronFraction_eta0013");
	} else if(frac==1){
	  histoNameEnFrac = TString::Format("NHadronFraction_eta0013");
	} else if(frac==2) {
	  histoNameEnFrac = TString::Format("CEmFraction_eta0013");
	} else if(frac==3) {
	  histoNameEnFrac = TString::Format("NEmFraction_eta0013");
	} else {
	  histoNameEnFrac = TString::Format("MuFraction_eta0013");
	}
      }else{
	if(frac==0){
	  histoNameEnFrac = TString::Format("ChHadronFraction_%s", etaBinning.getBinName(i).c_str());
	} else if(frac==1){
	  histoNameEnFrac = TString::Format("NHadronFraction_%s", etaBinning.getBinName(i).c_str());
	} else if(frac==2) {
	  histoNameEnFrac = TString::Format("CEmFraction_%s", etaBinning.getBinName(i).c_str());
	} else if(frac==3) {
	  histoNameEnFrac = TString::Format("NEmFraction_%s", etaBinning.getBinName(i).c_str());
	} else {
	  histoNameEnFrac = TString::Format("MuFraction_%s", etaBinning.getBinName(i).c_str());
	}
      }
    
      h_dataEnFrac = (TH1F*)data->Get(histoNameEnFrac);
      h_mcEnFrac = (TH1F*)mcFile->Get(histoNameEnFrac);
       
      TH1D *h_diff = (TH1D*)h_dataEnFrac->Clone("h_diff");
      h_diff->Add(h_mcEnFrac, -1);
      h_diff->Scale(100);
      if(frac==0){
	h_diff->GetXaxis()->SetLabelSize(0.085);
	h_diff->GetYaxis()->SetLabelSize(0.07);
	h_diff->GetYaxis()->SetTitleOffset(0.50);
	h_diff->GetXaxis()->SetTitleSize(0.09);
	h_diff->GetYaxis()->SetTitleSize(0.07);	 	 
	h_diff -> SetTitle("");
	h_diff-> GetXaxis()->SetMoreLogLabels();
	h_diff-> GetXaxis()->SetNoExponent();
	h_diff-> GetYaxis()->SetNdivisions(508);
	h_diff -> SetYTitle("Data - MC (%)");
	h_diff -> SetXTitle("p_{T} [GeV]");
	h_diff -> SetStats(kFALSE);
	h_diff -> SetMarkerColor(2);	
	h_diff -> SetLineColor(2);
	h_diff -> GetYaxis()->SetRangeUser(-10., 10.);
	// federico -- da togliere
	h_diff->GetXaxis()-> SetRangeUser(175, 2500);
	h_diff -> Draw();

	leg -> AddEntry(h_diff, "Charged Hadron En. Frac.", "PL");
      }else{
	if(frac==1){
	  h_diff->SetMarkerColor(8);
	  h_diff->SetLineColor(8);
	  leg -> AddEntry(h_diff, "Neutral Hadron En. Frac.", "PL");
	}else if(frac==2){
	  h_diff->SetMarkerColor(4);
	  h_diff->SetLineColor(4);
	  leg -> AddEntry(h_diff, "Charged Electromagnetic En. Frac.", "PL");
	}else if(frac==3){
	  h_diff->SetMarkerColor(6);
	  h_diff->SetLineColor(6);
	  leg -> AddEntry(h_diff, "Neutral Electromagnetic En. Frac.", "PL");
	}else if(frac==4){
	  h_diff->SetMarkerColor(7);
	  h_diff->SetLineColor(7);
	  leg -> AddEntry(h_diff, "Muon En. Frac.", "PL");
	}

	h_diff -> Draw("same");
      }
    }
    

    pad_hi -> cd();  
    h_mc->GetYaxis()->SetTitle("PF Energy Fraction");
    h_mc->GetYaxis()-> SetNdivisions(511);
    h_mc-> GetXaxis()->SetLabelColor(kWhite);
    //federico -- da togliere
    h_mc->GetXaxis()-> SetRangeUser(175, 2500);
    h_mc->Draw("hist");
    h_data->Draw("same");
    leg -> Draw();

    if(pdf_aussi) c->SaveAs(outputDir+"/dataMC_"+histoName+".pdf");
    c->SaveAs(outputDir+"/dataMC_"+histoName+".png");
    c->Destructor();
     
  }// eta bins


}
Beispiel #3
0
int main(int argc, char* argv[]) {

  if (argc != 7 && argc != 8) {
    std::cout << "USAGE: ./draw_vs_npv [data_dataset] [mc_SIGNAL_dataset] [mc_BG_dataset] [recoType] [jetAlgo] [norm ('LUMI' or 'SHAPE')] [flags=\"\"]" << std::endl;
    exit(23);
  }

  gROOT->SetBatch();

  std::string data_dataset(argv[1]);
  std::string mc_photonjet(argv[2]);
  std::string mc_QCD(argv[3]);
  std::string recoType(argv[4]);
  std::string jetAlgo(argv[5]);
  std::string norm(argv[6]);
  if (norm != "LUMI" && norm != "SHAPE") {
    std::cout << "'" << norm << "' normalization not implemented yet." << std::endl;
    std::cout << "Only 'LUMI' and 'SHAPE' currently supported." << std::endl;
    std::cout << "Exiting." << std::endl;
    exit(9811);
  }
  std::string flags = "";
  if (argc == 8) {
    std::string flags_str(argv[7]);
    flags = flags_str;
  }


  std::string algoType;
  if (recoType == "calo") {
    algoType = jetAlgo;
  } else {
    algoType = recoType + jetAlgo;
  }
  if (recoType == "jpt" && jetAlgo == "akt4") {
    algoType = "jptak4";
  }

  jetAlgo = (jetAlgo == "ak4") ? "AK4" : "AK8";
  recoType = (recoType == "pf") ? "PFlow" : "Calo";
  std::string postFix = recoType + jetAlgo;

  postFix += "chs";


  //Float_t etamax = 3.;
  //bool sameEvents = false; //until njets histos have no overflows... or maybe use GetEntries instead of integral?

  drawBase* db = new drawBase("PhotonJet", recoType, jetAlgo, OUTPUT_GRAPHS);
  db->set_pdf_aussi((bool)false);
  db->set_flags(flags);
  db->set_isCMSArticle(false);

  std::cout << "flags set." << std::endl;

  TString dataFileName;
  if (flags.length() > 0) {
    dataFileName = TString::Format("PhotonJet_%s_%s_%s.root", data_dataset.c_str(), postFix.c_str(), flags.c_str());
  } else {
    dataFileName = TString::Format("PhotonJet_%s_%s.root", data_dataset.c_str(), postFix.c_str());
  }

  TFile* dataFile = TFile::Open(dataFileName);

  if (dataFile) {
    std::cout << "Opened data file '" << dataFileName << "'." << std::endl;
    db->add_dataFile(dataFile, data_dataset);
  }

  TString mc1FileName;
  if (flags.length() > 0) {
    mc1FileName = TString::Format("PhotonJet_%s_%s_%s.root", mc_photonjet.c_str(), postFix.c_str(), flags.c_str());
  } else {
    mc1FileName = TString::Format("PhotonJet_%s_%s.root", mc_photonjet.c_str(), postFix.c_str());
  }
  TFile* mcPhotonJetFile = TFile::Open(mc1FileName);
  std::cout << "Opened mc file '" << mc1FileName << "'." << std::endl;

  if (mcPhotonJetFile) {
    db->add_mcFile(mcPhotonJetFile, mc_photonjet, "#gamma + jets MC", BALANCING);
  }

  if (mc_QCD != "") {
    TString mc2FileName;
    if (flags.length() > 0) {
      mc2FileName = TString::Format("PhotonJet_%s_%s_%s.root", mc_QCD.c_str(), postFix.c_str(), flags.c_str());
    } else {
      mc2FileName = TString::Format("PhotonJet_%s_%s.root", mc_QCD.c_str(), postFix.c_str());
    }
    TFile* mcQCDFile = TFile::Open(mc2FileName);
    std::cout << "Opened mc file '" << mc2FileName << "'." << std::endl;

    if (mcQCDFile && mc_QCD != mc_photonjet) {
      db->add_mcFile(mcQCDFile, mc_QCD, "QCD MC", MPF);
    }
  }

  // MC should already be normalized to a lumi of 1 pb-1
  // Read luminosity
  double dLumi = 1e6;
  if (dataFile) {
    TParameter<double>* lumi = static_cast<TParameter<double>*>(dataFile->Get("analysis/luminosity"));
    dLumi = lumi->GetVal();
  }

  std::cout<< "Lumi "<< dLumi << std::endl;  

  //  db->set_lumi(dLumi * 1e-6);
  db->set_lumi(dLumi);
  if (norm == "LUMI") {
    db->set_lumiNormalization();
  } else {
    db->set_shapeNormalization();
  }
  
  db->setFolder("analysis");
  std::string outputDir = "PhotonJetPlots_" + db->get_fullSuffix() + "/vs_npv";
  db->set_outputdir(outputDir);
  
  bool log = true;
  gErrorIgnoreLevel = kWarning;
  
  db->setOutputGraphs(OUTPUT_GRAPHS);
  
  VertexBinning vertexBinning;
  std::vector<std::pair<int, int> > vertexBins = vertexBinning.getBinning();
  
  EtaBinning etaBinning;
  size_t etaBinningSize = etaBinning.size();
  
  db->set_rebin(2);
  
  db->setFolder("analysis/vertex");
  for (size_t i = 0; i < etaBinningSize; i++) {
    db->set_legendTitle(etaBinning.getBinTitle(i));
    
    TString responseName = TString::Format("resp_balancing_%s", etaBinning.getBinName(i).c_str());
    db->drawHisto_vs_vertex(vertexBins, responseName.Data(), "Balancing Response", "", "Events", log);
    
    // Raw jets
    //responseName = TString::Format("resp_balancing_raw_%s", etaBinning.getBinName(i).c_str());
    //db->drawHisto_vs_vertex(ptBins, responseName.Data(), "Balancing Response (raw jets)", "", "Events", log);
    
    responseName = TString::Format("resp_mpf_%s", etaBinning.getBinName(i).c_str());
    db->drawHisto_vs_vertex(vertexBins, responseName.Data(), "MPF Response", "", "Events", log);
    
    // Raw jets
    //responseName = TString::Format("resp_mpf_raw_%s", etaBinning.getBinName(i).c_str());
    //db->drawHisto_vs_vertex(ptBins, responseName.Data(), "MPF Response (raw ME_{T})", "", "Events", log);
    
  }
  // Special case eta < 1.3
  
  db->set_legendTitle("|#eta| < 1.3");
  db->drawHisto_vs_vertex(vertexBins, "resp_balancing_eta0013", "Balancing Response", "", "Events", log);
  //db->drawHisto_vs_pt(ptBins, "resp_balancing_raw_eta013", "Balancing Response (raw jets)", "", "Events", log);
  
  db->drawHisto_vs_vertex(vertexBins, "resp_mpf_eta0013", "MPF Response", "", "Events", log);
  //db->drawHisto_vs_vertex(ptBins, "resp_mpf_raw_eta013", "MPF Response (raw ME_{T})", "", "Events", log);
  
  delete db;
  db = NULL;
  
  return 0;
  
}
Beispiel #4
0
int main(int argc, char* argv[]) {

  if( argc != 8 && argc != 7 ) {
    std::cout << "USAGE: ./drawMinBias [(string)DiJet/Inclusive] [(string)data_dataset] [(string)mc_dataset] [(string)algoType] [(int)pt_thresh] [(string)raw/corr] [(bool)useID=true]" << std::endl;
    exit(23);
  }

  std::string dijet_inclusive( argv[1] );
  std::string data_dataset( argv[2] );
  std::string mc_dataset( argv[3] );
  std::string algoType( argv[4] );
  int pt_thresh = atoi( argv[5] );
  std::string raw_corr( argv[6] );
  Float_t etamax = 3.;

  bool useID = true;
  if( argc==8 ) {
    std::string bool_str( argv[7] );
    if( bool_str=="false" ) useID = false;
  }

  bool sameEvents = false; //until njets histos have no overflows... or maybe use GetEntries instead of integral?

  DrawBase* db = new DrawBase("MinBias");
  db->set_raw_corr( raw_corr );
  db->set_pt_thresh( pt_thresh );
  //db->set_etamax( etamax );
  db->set_etamax(3.);
  db->set_pdf_aussi((bool)false);

  char outputdir_char[200];
  sprintf( outputdir_char, "%sPlots_%s_vs_%s_%s_%dGeV%s_eta%d", dijet_inclusive.c_str(), data_dataset.c_str(), mc_dataset.c_str(), algoType.c_str(), pt_thresh, raw_corr.c_str(), (int)(10.*db->get_etamax()));
  std::string outputdir_str(outputdir_char);
  if( !useID )
    outputdir_str = outputdir_str + "_noID";

  db->set_outputdir(outputdir_str);

  //std::string dataFileName = "MinBias_" + data_dataset + "_" + algoType;
  char dataFileName[150];
  if( useID )
    sprintf( dataFileName, "%s_%s_%s_%dGeV%s_eta%d.root", dijet_inclusive.c_str(), data_dataset.c_str(), algoType.c_str(), pt_thresh, raw_corr.c_str(), (int)(10.*db->get_etamax()));
    //sprintf( dataFileName, "%s_DATA_%s_%s_%dGeV%s_eta%d.root", data_dataset.c_str(), algoType.c_str(), pt_thresh, raw_corr.c_str(), (int)(10.*ETAMAX));
  else 
    sprintf( dataFileName, "%s_%s_%s_%dGeV%s_eta%d_noID.root", dijet_inclusive.c_str(), data_dataset.c_str(), algoType.c_str(), pt_thresh, raw_corr.c_str(), (int)(10.*db->get_etamax()));
    //sprintf( dataFileName, "%s_DATA_%s_%s_%dGeV%s_eta%d_noDeltaPhi.root", data_dataset.c_str(), algoType.c_str(), pt_thresh, raw_corr.c_str(), (int)(10.*ETAMAX));
  TFile* dataFile = TFile::Open(dataFileName);
  std::cout << "Opened data file '" << dataFileName << "'." << std::endl;

  db->set_dataFile( dataFile );

  char mcFileName[150];
//if( mc_dataset=="" ) {
//  if( useID )
//    sprintf( mcFileName, "%s_%s_%s_%dGeV%s_eta%d.root", dijet_inclusive.c_str(), data_dataset.c_str(), algoType.c_str(), pt_thresh, raw_corr.c_str(), (int)(10.*ETAMAX));
//  else
//    sprintf( mcFileName, "%s_%s_%s_%dGeV%s_eta%d_noID.root", dijet_inclusive.c_str(), data_dataset.c_str(), algoType.c_str(), pt_thresh, raw_corr.c_str(), (int)(10.*ETAMAX));
//} else {
    if( useID )
      sprintf( mcFileName, "%s_%s_%s_%dGeV%s_eta%d.root", dijet_inclusive.c_str(), mc_dataset.c_str(), algoType.c_str(), pt_thresh, raw_corr.c_str(), (int)(10.*db->get_etamax()));
    else
      sprintf( mcFileName, "%s_%s_%s_%dGeV%s_eta%d_noID.root", dijet_inclusive.c_str(), mc_dataset.c_str(), algoType.c_str(), pt_thresh, raw_corr.c_str(), (int)(10.*db->get_etamax()));
//}
  TFile* mcFile = TFile::Open(mcFileName);
  std::cout << "Opened mc file '" << mcFileName << "'." << std::endl;

  db->set_mcFile( mcFile );

  if( sameEvents ) {
    db->set_sameEventNormalization();
  } else {
    db->set_sameInstanceNormalization();
  }

//TH1F* h1_nJets_data = (TH1F*)dataFile->Get("nJets");
//TH1F* h1_nJets_mc = (TH1F*)mcFile->Get("nJets");

//TH1F* h1_phiJet_data = (TH1F*)dataFile->Get("phiJet");
//TH1F* h1_phiJet_mc = (TH1F*)mcFile->Get("phiJet");


//Float_t scaleFactor = ( sameEvents ) ? h1_nJets_data->Integral()/h1_nJets_mc->Integral() : h1_phiJet_data->Integral()/h1_phiJet_mc->Integral();

  bool log = true;

  if( dijet_inclusive == "DiJet" ) {
    db->drawHisto( "deltaPhiJet", "",0);
    db->drawHisto( "asymmJet", "");
    db->drawHisto( "diJetMass", "",1, log);
  }

  db->drawHisto( "massJet", "",1, log);
  db->drawHisto( "MoEJet", "",1, log);

  db->drawHisto( "ptJet", "",1, log);
  db->drawHisto( "ptCorrJet", "",1, log);
  db->drawHisto( "ptCorrJet", "barrel",1, log);
  db->drawHisto( "ptCorrJet", "endcap",1, log);
  db->drawHisto( "ptCorrJet", "eta1430",1, log);
  db->drawHisto( "ptCorrJet", "Rch050",1, log);
  db->drawHisto( "ptCorrJet", "Rch5070",1, log);
  db->drawHisto( "ptCorrJet", "Rch70100",1, log);
  db->drawHisto( "phiJet", "");
  db->drawHisto( "etaJet", "");

  db->drawHisto( "nCandJet", "",log);

  db->drawHisto( "RchJet", "",1);
  db->drawHisto( "RchJet", "eta02",1);
  db->drawHisto( "RchJet", "eta23",1);
  db->drawHisto( "RchJet", "barrel",1);
  db->drawHisto( "RchJet", "eta163",1);
  db->drawHisto( "RchJet", "eta1425",1);
  db->drawHisto( "RnhJet", "",1, log);
  db->drawHisto( "RnhJet", "eta02",1, log);
  db->drawHisto( "RnhJet", "eta23",1, log);
  db->drawHisto( "RnhJet", "barrel",1, log);
  db->drawHisto( "RnhJet", "eta163",1, log);
  db->drawHisto( "RnhJet", "eta1425",1, log);
  db->drawHisto( "RgammaJet", "",1, log);
  db->drawHisto( "RgammaJet", "eta02",1, log);
  db->drawHisto( "RgammaJet", "eta23",1, log);
  db->drawHisto( "RgammaJet", "barrel",1, log);
  db->drawHisto( "RgammaJet", "eta163",1, log);
  db->drawHisto( "RgammaJet", "eta1425",1, log);
  db->drawHisto( "RgammanhJet", "barrel",1, log);
  db->drawHisto( "RgammanhJet", "eta163",1, log);
  db->drawHisto( "RgammanhJet", "eta1425",1, log);

  db->drawHisto( "EchJet", "",1, log);
  db->drawHisto( "EchJet", "eta02",1, log);
  db->drawHisto( "EchJet", "eta23",1, log);
  db->drawHisto( "EchJet", "barrel",1, log);
  db->drawHisto( "EchJet", "eta163",1, log);
  db->drawHisto( "EchJet", "eta1425",1, log);
  db->drawHisto( "EnhJet", "",1, log);
  db->drawHisto( "EnhJet", "eta02",1, log);
  db->drawHisto( "EnhJet", "eta23",1, log);
  db->drawHisto( "EnhJet", "barrel",1, log);
  db->drawHisto( "EnhJet", "eta163",1, log);
  db->drawHisto( "EnhJet", "eta1425",1, log);
  db->drawHisto( "EgammaJet", "",1, log);
  db->drawHisto( "EgammaJet", "eta02",1, log);
  db->drawHisto( "EgammaJet", "eta23",1, log);
  db->drawHisto( "EgammaJet", "barrel",1, log);
  db->drawHisto( "EgammaJet", "eta163",1, log);
  db->drawHisto( "EgammaJet", "eta1425",1, log);
  db->drawHisto( "EgammanhJet", "barrel",1, log);
  db->drawHisto( "EgammanhJet", "eta163",1, log);
  db->drawHisto( "EgammanhJet", "eta1425",1, log);

  db->drawHisto( "PTchJet", "",1, log);
  db->drawHisto( "PTgammaJet", "",1, log);
  db->drawHisto( "PTnhJet", "",1, log);

  db->drawHisto( "EphotAveJet", "",1, log);

  db->drawHisto( "NchJet", "",1, log);
  db->drawHisto( "NchJet", "barrel",1, log);
  db->drawHisto( "NchJet", "eta163",1, log);
  db->drawHisto( "NchJet", "eta1425",1, log);
  db->drawHisto( "NchJet", "eta02",1, log);
  db->drawHisto( "NchJet", "eta23",1, log);
  db->drawHisto( "NnhJet", "",1, log);
  db->drawHisto( "NnhJet", "eta02",1, log);
  db->drawHisto( "NnhJet", "eta23",1, log);
  db->drawHisto( "NnhJet", "barrel",1, log);
  db->drawHisto( "NnhJet", "eta163",1, log);
  db->drawHisto( "NnhJet", "eta1425",1, log);
  db->drawHisto( "NgammaJet", "",1, log);
  db->drawHisto( "NgammaJet", "eta02",1, log);
  db->drawHisto( "NgammaJet", "eta23",1, log);
  db->drawHisto( "NgammaJet", "barrel",1, log);
  db->drawHisto( "NgammaJet", "eta163",1, log);
  db->drawHisto( "NgammaJet", "eta1425",1, log);
  db->drawHisto( "NgammanhJet", "barrel",1, log);
  db->drawHisto( "NgammanhJet", "eta163",1, log);
  db->drawHisto( "NgammanhJet", "eta1425",1, log);

  std::string ptVar;
  if( raw_corr=="raw" )
    ptVar = "pt";
  else 
    ptVar = "ptCorr";

  db->drawProfile( "pt", "eta", 1);
  db->drawProfile( "ptCorr", "eta", 1);

  db->drawProfile( "Rch", "eta", 1);
  db->drawProfile( "Rgamma", "eta", 1);
  db->drawProfile( "Rnh", "eta", 1);
  db->drawProfile( "Rgammanh", "eta", 1);

  db->drawProfile( "Ech", "eta", 1);
  db->drawProfile( "Egamma", "eta", 1);
  db->drawProfile( "Enh", "eta", 1);
  db->drawProfile( "Egammanh", "eta", 1);

  db->drawProfile( "PTch", "eta", 1);
  db->drawProfile( "PTgamma", "eta", 1);
  db->drawProfile( "PTnh", "eta", 1);

  db->drawProfile( "Nch", "eta", 1);
  db->drawProfile( "Ngamma", "eta", 1);
  db->drawProfile( "Nnh", "eta", 1);
  db->drawProfile( "Ngammanh", "eta", 1);

  db->drawProfile( "Rch", ptVar, 1);
  db->drawProfile( "Rgamma", ptVar, 1);
  db->drawProfile( "Rnh", ptVar, 1);

  db->drawProfile( "Ech", ptVar, 1);
  db->drawProfile( "Egamma", ptVar, 1);
  db->drawProfile( "Enh", ptVar, 1);

  db->drawProfile( "Nch", ptVar, 1);
  db->drawProfile( "Ngamma", ptVar, 1);
  db->drawProfile( "Nnh", ptVar, 1);

  db->drawProfile( "Egamma", "Ech", 1);
  db->drawProfile( "Enh",    "Ech", 1);

  db->drawProfile( "Rgamma", "Rch", 1);
  db->drawProfile( "Rnh",    "Rch", 1);
  db->drawProfile( "Rgamma",    "Rnh", 1);

//drawH2( dataFile, mcFile, "Rgamma", "Rch", 1);
//drawH2( dataFile, mcFile, "Rnh",    "Rch", 1);
//drawH2( dataFile, mcFile, "Rnh",    "Rgamma", 1);

  db->drawProfile( "Ngamma", "Nch", 1);
  db->drawProfile( "Nnh",    "Nch", 1);

  // stacks:
  db->drawStack( "R", "eta", "RECO", (bool)true);
  db->drawStack( "R", "eta", "RECO", (bool)false);

  db->drawStack( "R", ptVar, "barrel", "RECO", (bool)true);
  db->drawStack( "R", ptVar, "barrel", "RECO", (bool)false);

  db->drawStack( "R", "phi", "barrel", "RECO", (bool)true);
  db->drawStack( "R", "phi", "barrel", "RECO", (bool)false);

  db->drawStack( "R", "eta", "GEN", (bool)false);
  db->drawStack( "R", "pt", "barrel", "GEN", (bool)false);
  db->drawStack( "R", "phi", "barrel", "GEN", (bool)false);

  return 0;

}  
int main(int argc, char* argv[]) {

  if (argc != 7 && argc != 8) {
    std::cout << "USAGE: ./drawPhotonJet [data_dataset] [mc_SIGNAL_dataset] [mc_BG_dataset] [recoType] [jetAlgo]" << std::endl;
    exit(23);
  }

  setPrettyStyle();

  std::string data_dataset(argv[1]);
  std::string mc_photonjet(argv[2]);
  std::string mc_QCD(argv[3]);
  std::string recoType(argv[4]);
  std::string jetAlgo(argv[5]);

  std::string algoType;
  if (recoType == "calo") {
    algoType = jetAlgo;
  } else {
    algoType = recoType + jetAlgo;
  }
  if (recoType == "jpt" && jetAlgo == "akt5") {
    algoType = "jptak5";
  }

  std::string flags = "";

  jetAlgo = (jetAlgo == "ak5") ? "AK5" : "AK7";
  recoType = (recoType == "pf") ? "PFlow" : "Calo";
  std::string postFix = recoType + jetAlgo;

  postFix += "chs";

  TString dataFileName;
  if (flags.length() > 0) {
    dataFileName = TString::Format("PhotonJet_%s_%s_%s.root", data_dataset.c_str(), postFix.c_str(), flags.c_str());
  } else {
    dataFileName = TString::Format("PhotonJet_%s_%s.root", data_dataset.c_str(), postFix.c_str());
  }

  TFile* dataFile = TFile::Open(dataFileName);
  std::cout << "Opened data file '" << dataFileName << "'." << std::endl;

  //db->add_dataFile(dataFile, data_dataset);

  TString mc1FileName;
  if (flags.length() > 0) {
    mc1FileName = TString::Format("PhotonJet_%s_%s_%s.root", mc_photonjet.c_str(), postFix.c_str(), flags.c_str());
  } else {
    mc1FileName = TString::Format("PhotonJet_%s_%s.root", mc_photonjet.c_str(), postFix.c_str());
  }

  TFile* mcPhotonJetFile = TFile::Open(mc1FileName);
  std::cout << "Opened mc file '" << mc1FileName << "'." << std::endl;

  if (mcPhotonJetFile) {
    //db->add_mcFile(mcPhotonJetFile, mc_photonjet, "#gamma+jet MC", 46);
  }

  if (mc_QCD != "") {
    TString mc2FileName;
    if (flags.length() > 0) {
      mc2FileName = TString::Format("PhotonJet_%s_%s_%s.root", mc_QCD.c_str(), postFix.c_str(), flags.c_str());
    } else {
      mc2FileName = TString::Format("PhotonJet_%s_%s.root", mc_QCD.c_str(), postFix.c_str());
    }
    TFile* mcQCDFile = TFile::Open(mc2FileName);
    std::cout << "Opened mc file '" << mc2FileName << "'." << std::endl;

    if (mcQCDFile && mc_QCD != mc_photonjet) {
      //db->add_mcFile(mcQCDFile, mc_QCD, "QCD MC", 38);
    }
  }

  // Create output directory
  mkdir("plots", 0755);

  TString directoryName = "";
  
  if (mc_QCD.length() == 0)
    directoryName = TString::Format("plots/%s_vs_%s_%s", data_dataset.c_str(), mc_photonjet.c_str(), postFix.c_str());
  else
    directoryName = TString::Format("plots/%s_vs_%s_plus_%s_%s", data_dataset.c_str(), mc_photonjet.c_str(), mc_QCD.c_str(), postFix.c_str());
  mkdir(directoryName, 0755);

  directoryName = TString::Format("%s/extrapolation", directoryName.Data());
  mkdir(directoryName, 0755);

  TParameter<double>* pLumi = static_cast<TParameter<double>*>(dataFile->Get("analysis/luminosity"));
  double lumi = pLumi->GetVal() * 1e-9;

  //bool log = true;
  gErrorIgnoreLevel = kWarning;

  EtaBinning etaBinning;
  size_t etaBinningSize = etaBinning.size();

  TString rootFolder = "analysis/new_extrapolation";
  for (size_t i = 0; i < etaBinningSize; i++) {

    const std::string& etaName = etaBinning.getBinName(i);
    std::cout << "Processing " << etaName << std::endl;
    
    TString responseName = TString::Format("%s/extrap_resp_balancing_%s_graph", rootFolder.Data(), etaName.c_str());
    TString outputName = TString::Format("%s/extrap_resp_balancing_%s.pdf", directoryName.Data(), etaName.c_str());
    TGraphErrors* data = (TGraphErrors*) dataFile->Get(responseName);
    TGraphErrors* mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawGraphs(data, mc, "Balancing", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", etaBinning.getBinTitle(i), lumi, outputName.Data());

    // Raw jets
    responseName = TString::Format("%s/extrap_resp_balancing_raw_%s_graph", rootFolder.Data(), etaName.c_str());
    outputName = TString::Format("%s/extrap_resp_balancing_raw_%s.pdf", directoryName.Data(), etaName.c_str());
    data = (TGraphErrors*) dataFile->Get(responseName);
    mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawGraphs(data, mc, "Balancing", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw jets)", etaBinning.getBinTitle(i), lumi, outputName.Data());

    responseName = TString::Format("%s/extrap_resp_mpf_%s_graph", rootFolder.Data(), etaName.c_str());
    outputName = TString::Format("%s/extrap_resp_mpf_%s.pdf", directoryName.Data(), etaName.c_str());
    data = (TGraphErrors*) dataFile->Get(responseName);
    mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawGraphs(data, mc, "MPF", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", etaBinning.getBinTitle(i), lumi, outputName.Data());

    // Raw jets
    responseName = TString::Format("%s/extrap_resp_mpf_raw_%s_graph", rootFolder.Data(), etaName.c_str());
    outputName = TString::Format("%s/extrap_resp_mpf_raw_%s.pdf", directoryName.Data(), etaName.c_str());
    data = (TGraphErrors*) dataFile->Get(responseName);
    mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawGraphs(data, mc, "MPF", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw #slashed{E_{t}})", etaBinning.getBinTitle(i), lumi, outputName.Data());
  }
  // Special case eta < 1.3
  {
    const std::string& etaName = "eta013";
    std::cout << "Processing " << etaName << std::endl;
    
    TString responseName = TString::Format("%s/extrap_resp_balancing_%s_graph", rootFolder.Data(), etaName.c_str());
    TString outputName = TString::Format("%s/extrap_resp_balancing_%s.pdf", directoryName.Data(), etaName.c_str());
    TGraphErrors* data = (TGraphErrors*) dataFile->Get(responseName);
    TGraphErrors* mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawGraphs(data, mc, "Balancing", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", "#eta #leq 1.3", lumi, outputName.Data());

    // Raw jets
    responseName = TString::Format("%s/extrap_resp_balancing_raw_%s_graph", rootFolder.Data(), etaName.c_str());
    outputName = TString::Format("%s/extrap_resp_balancing_raw_%s.pdf", directoryName.Data(), etaName.c_str());
    data = (TGraphErrors*) dataFile->Get(responseName);
    mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawGraphs(data, mc, "Balancing", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw jets)", "#eta #leq 1.3", lumi, outputName.Data());

    responseName = TString::Format("%s/extrap_resp_mpf_%s_graph", rootFolder.Data(), etaName.c_str());
    outputName = TString::Format("%s/extrap_resp_mpf_%s.pdf", directoryName.Data(), etaName.c_str());
    data = (TGraphErrors*) dataFile->Get(responseName);
    mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawGraphs(data, mc, "MPF", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", "#eta #leq 1.3", lumi, outputName.Data());

    // Raw jets
    responseName = TString::Format("%s/extrap_resp_mpf_raw_%s_graph", rootFolder.Data(), etaName.c_str());
    outputName = TString::Format("%s/extrap_resp_mpf_raw_%s.pdf", directoryName.Data(), etaName.c_str());
    data = (TGraphErrors*) dataFile->Get(responseName);
    mc = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawGraphs(data, mc, "MPF", "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw #slashed{E_{t}})", "#eta #leq 1.3", lumi, outputName.Data());
  }

  //db->set_legendTitle("|#eta| < 1.3");
  //db->drawHisto_vs_pt(ptBins, "resp_mpf_eta013", "MPF Response", "", "Events", log);
  //db->drawHisto_vs_pt(ptBins, "resp_mpf_raw_eta013", "MPF Response (raw ME_{T})", "", "Events", log);
  for (size_t i = 0; i < etaBinningSize; i++) {

    const std::string& etaName = etaBinning.getBinName(i);
    std::cout << "Processing " << etaName << std::endl;
    
    TString responseName = TString::Format("%s/extrap_resp_balancing_%s_graph", rootFolder.Data(), etaName.c_str());
    TString outputName = TString::Format("%s/extrap_resp_combined_%s", directoryName.Data(), etaName.c_str());
    TGraphErrors* balancingData = (TGraphErrors*) dataFile->Get(responseName);
    TGraphErrors* balancingMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    responseName = TString::Format("%s/extrap_resp_mpf_%s_graph", rootFolder.Data(), etaName.c_str());
    TGraphErrors* mpfData = (TGraphErrors*) dataFile->Get(responseName);
    TGraphErrors* mpfMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawCombinedGraphs(balancingData, balancingMC, mpfData, mpfMC, "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", etaBinning.getBinTitle(i), lumi, outputName.Data());

    responseName = TString::Format("%s/extrap_resp_balancing_raw_%s_graph", rootFolder.Data(), etaName.c_str());
    outputName = TString::Format("%s/extrap_resp_combined_raw_%s", directoryName.Data(), etaName.c_str());
    balancingData = (TGraphErrors*) dataFile->Get(responseName);
    balancingMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    responseName = TString::Format("%s/extrap_resp_mpf_raw_%s_graph", rootFolder.Data(), etaName.c_str());
    mpfData = (TGraphErrors*) dataFile->Get(responseName);
    mpfMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawCombinedGraphs(balancingData, balancingMC, mpfData, mpfMC, "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw objects)", etaBinning.getBinTitle(i), lumi, outputName.Data());

  }

  // Eta < 1.3
  {
    const std::string& etaName = "eta013";
    std::cout << "Processing " << etaName << std::endl;
    
    TString responseName = TString::Format("%s/extrap_resp_balancing_%s_graph", rootFolder.Data(), etaName.c_str());
    TString outputName = TString::Format("%s/extrap_resp_combined_%s", directoryName.Data(), etaName.c_str());
    TGraphErrors* balancingData = (TGraphErrors*) dataFile->Get(responseName);
    TGraphErrors* balancingMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    responseName = TString::Format("%s/extrap_resp_mpf_%s_graph", rootFolder.Data(), etaName.c_str());
    TGraphErrors* mpfData = (TGraphErrors*) dataFile->Get(responseName);
    TGraphErrors* mpfMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawCombinedGraphs(balancingData, balancingMC, mpfData, mpfMC, "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response", "#eta #leq 1.3", lumi, outputName.Data());

    responseName = TString::Format("%s/extrap_resp_balancing_raw_%s_graph", rootFolder.Data(), etaName.c_str());
    outputName = TString::Format("%s/extrap_resp_combined_raw_%s", directoryName.Data(), etaName.c_str());
    balancingData = (TGraphErrors*) dataFile->Get(responseName);
    balancingMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    responseName = TString::Format("%s/extrap_resp_mpf_raw_%s_graph", rootFolder.Data(), etaName.c_str());
    mpfData = (TGraphErrors*) dataFile->Get(responseName);
    mpfMC = (TGraphErrors*) mcPhotonJetFile->Get(responseName);

    drawCombinedGraphs(balancingData, balancingMC, mpfData, mpfMC, "p_{t}^{2^{nd} jet} / p_{t}^{#gamma}", "Jet response (raw objects)", "#eta #leq 1.3", lumi, outputName.Data());
  }

  return 0;
}