Пример #1
0
void makeTFNormalizationPlots()
{
  gROOT->SetBatch(true);

  TH1::AddDirectory(false);

  std::string inputFilePath = "/afs/cern.ch/user/v/veelken/scratch0/CMSSW_5_3_14/src/TauAnalysis/SVfitMEM/";
  std::string inputFileName = "testTFNormalization.root";
  TString inputFileName_full = inputFilePath;
  if ( !inputFileName_full.EndsWith("/") ) inputFileName_full.Append("/");
  inputFileName_full.Append(inputFileName.data());
  TFile* inputFile = new TFile(inputFileName_full.Data());

  TH1* histogram_norm_met    = loadHistogram(inputFile, "", "norm_met");
  TH1* histogram_norm_lepTau = loadHistogram(inputFile, "", "norm_lepTau");
  TH1* histogram_norm_hadTau = loadHistogram(inputFile, "", "norm_hadTau");

  showHistograms(800, 600, 
		 histogram_norm_met,
		 0.99, 1.01, "Normalization", 1.15,
		 true, 1.e0, 2.9e+3, "Toys", 1.20,
		 "plots/norm_met.pdf");
  showHistograms(800, 600, 
		 histogram_norm_lepTau,
		 0.99, 1.01, "Normalization", 1.15,
		 true, 1.e0, 2.9e+3, "Toys", 1.20,
		 "plots/norm_lepTau.pdf");
  showHistograms(800, 600, 
		 histogram_norm_hadTau,
		 0.99, 1.01, "Normalization", 1.15,
		 true, 1.e0, 2.9e+3, "Toys", 1.20,
		 "plots/norm_hadTau.pdf");

  delete inputFile;
}
Пример #2
0
void makePlot_shift_minus_central(
       const std::string& inputFilePath_ref, const std::string& inputFileName_ref, 
       const std::string& histogramName_ref_shift, const std::string& histogramName_ref_central, const std::string& legendEntry_ref,
       const std::string& inputFilePath_test, const std::string& inputFileName_test, 
       const std::string& histogramName_test_shift, const std::string& histogramName_test_central, const std::string& legendEntry_test, 
       const std::string& inputFilePath_test2, const std::string& inputFileName_test2, 
       const std::string& histogramName_test2_shift, const std::string& histogramName_test2_central, const std::string& legendEntry_test2,
       const std::string& outputFileName)
{
  std::cout << "<makePlot_shift_minus_central>:" << std::endl;

  TString inputFileName_ref_full = inputFilePath_ref;
  if ( !inputFileName_ref_full.EndsWith("/") ) inputFileName_ref_full.Append("/");
  inputFileName_ref_full.Append(inputFileName_ref.data());
  TFile* inputFile_ref = new TFile(inputFileName_ref_full.Data());
  TH1* histogram_ref_shift = loadHistogram(inputFile_ref, histogramName_ref_shift);
  TH1* histogram_ref_central = loadHistogram(inputFile_ref, histogramName_ref_central);
  TH1* histogram_ref_shift_minus_centralAbs = 0;
  TH1* histogram_ref_shift_minus_centralRel = 0;
  double integral_ref = -1.;
  if ( histogram_ref_shift && histogram_ref_central ) {
    std::string histogramName_ref_shift_minus_centralAbs = Form("%s_minus_%sAbs", histogram_ref_shift->GetName(), histogram_ref_central->GetName());
    histogram_ref_shift_minus_centralAbs = subtractHistograms(histogramName_ref_shift_minus_centralAbs, histogram_ref_shift, histogram_ref_central, kAbsolute);
    std::string histogramName_ref_shift_minus_centralRel = Form("%s_minus_%sRel", histogram_ref_shift->GetName(), histogram_ref_central->GetName());
    histogram_ref_shift_minus_centralRel = subtractHistograms(histogramName_ref_shift_minus_centralRel, histogram_ref_shift, histogram_ref_central, kRelative);
    integral_ref = compIntegral(histogram_ref_shift_minus_centralAbs);
    std::cout << " integral_ref = " << integral_ref << std::endl;
    divideByBinWidth(histogram_ref_shift_minus_centralAbs);
  }

  TString inputFileName_test_full = inputFilePath_test;
  if ( !inputFileName_test_full.EndsWith("/") ) inputFileName_test_full.Append("/");
  inputFileName_test_full.Append(inputFileName_test.data());
  TFile* inputFile_test = ( inputFileName_test_full != inputFileName_ref_full ) ? 
    new TFile(inputFileName_test_full.Data()) : inputFile_ref;
  TH1* histogram_test_shift = loadHistogram(inputFile_test, histogramName_test_shift);
  TH1* histogram_test_central = loadHistogram(inputFile_test, histogramName_test_central);
  TH1* histogram_test_shift_minus_centralAbs = 0;
  TH1* histogram_test_shift_minus_centralRel = 0;
  double integral_test = -1.;
  if ( histogram_test_shift && histogram_test_central ) {
    std::string histogramName_test_shift_minus_centralAbs = Form("%s_minus_%sAbs", histogram_test_shift->GetName(), histogram_test_central->GetName());
    histogram_test_shift_minus_centralAbs = subtractHistograms(histogramName_test_shift_minus_centralAbs, histogram_test_shift, histogram_test_central, kAbsolute);
    std::string histogramName_test_shift_minus_centralRel = Form("%s_minus_%sRel", histogram_test_shift->GetName(), histogram_test_central->GetName());
    histogram_test_shift_minus_centralRel = subtractHistograms(histogramName_test_shift_minus_centralRel, histogram_test_shift, histogram_test_central, kRelative);
    integral_test = compIntegral(histogram_test_shift_minus_centralAbs);
    std::cout << " integral_test = " << integral_test << std::endl;
    divideByBinWidth(histogram_test_shift_minus_centralAbs);
  }

  TFile* inputFile_test2 = 0;
  TH1* histogram_test2_shift_minus_centralAbs = 0;
  TH1* histogram_test2_shift_minus_centralRel = 0;
  double integral_test2 = -1.;
  if ( inputFilePath_test2 != "" && inputFileName_test2 != "" && histogramName_test2_shift != "" && histogramName_test2_central != "" ) {
    TString inputFileName_test2_full = inputFilePath_test2;
    if ( !inputFileName_test2_full.EndsWith("/") ) inputFileName_test2_full.Append("/");
    inputFileName_test2_full.Append(inputFileName_test2.data());
    inputFile_test2 = ( inputFileName_test2_full != inputFileName_ref_full ) ? 
      new TFile(inputFileName_test2_full.Data()) : inputFile_ref;
    TH1* histogram_test2_shift = loadHistogram(inputFile_test2, histogramName_test2_shift);
    TH1* histogram_test2_central = loadHistogram(inputFile_test2, histogramName_test2_central);
    if ( histogram_test2_shift && histogram_test2_central ) {
      std::string histogramName_test2_shift_minus_centralAbs = Form("%s_minus_%sAbs", histogram_test2_shift->GetName(), histogram_test2_central->GetName());
      histogram_test2_shift_minus_centralAbs = subtractHistograms(histogramName_test2_shift_minus_centralAbs, histogram_test2_shift, histogram_test2_central, kAbsolute);
      std::string histogramName_test2_shift_minus_centralRel = Form("%s_minus_%sRel", histogram_test2_shift->GetName(), histogram_test2_central->GetName());
      histogram_test2_shift_minus_centralRel = subtractHistograms(histogramName_test2_shift_minus_centralRel, histogram_test2_shift, histogram_test2_central, kRelative);
      integral_test2 = compIntegral(histogram_test2_shift_minus_centralAbs);
      std::cout << " integral_test2 = " << integral_test2 << std::endl;
      divideByBinWidth(histogram_test2_shift_minus_centralAbs);
    }
  }

  size_t idx = outputFileName.find_last_of('.');
  std::string outputFileName_abs = std::string(outputFileName, 0, idx);
  outputFileName_abs.append("_absolute");
  if ( idx != std::string::npos ) outputFileName_abs.append(std::string(outputFileName, idx));

  showHistograms(800, 900, 
		 histogram_ref_shift_minus_centralAbs, legendEntry_ref, integral_ref,
		 histogram_test_shift_minus_centralAbs, legendEntry_test, integral_test, 
		 histogram_test2_shift_minus_centralAbs, legendEntry_test2, integral_test2, 
		 //NULL, "", 0.,
		 NULL, "", 0.,
		 NULL, "", 0.,
		 NULL, "", 0.,
		 "m_{#tau#tau} [GeV]", 1.10,
		 true, 1.e-4, 1.e+4, "1/dm_{#tau#tau} [1/GeV]", 1.30,
		 0.34, 0.72,
		 outputFileName_abs.data());
  
  std::string outputFileName_rel = std::string(outputFileName, 0, idx);
  outputFileName_rel.append("_relative");
  if ( idx != std::string::npos ) outputFileName_rel.append(std::string(outputFileName, idx));
  
  showHistograms(800, 900, 
		 histogram_ref_shift_minus_centralRel, legendEntry_ref, integral_ref,
		 histogram_test_shift_minus_centralRel, legendEntry_test, integral_test, 
		 histogram_test2_shift_minus_centralRel, legendEntry_test2, integral_test2, 
		 //NULL, "", 0.,
		 NULL, "", 0.,
		 NULL, "", 0.,
		 NULL, "", 0.,
		 "m_{#tau#tau} [GeV]", 1.10,
		 true, 1.e-4, 1.e+4, "#Delta 1/dm_{#tau#tau}", 1.30,
		 0.34, 0.72,
		 outputFileName_rel.data());

  delete inputFile_ref;
  if ( inputFile_test != inputFile_ref ) delete inputFile_test;
  if ( inputFile_test2 != inputFile_ref && inputFile_test2 != inputFile_test ) delete inputFile_test2;
}
Пример #3
0
void makePlot(
       const std::string& inputFilePath_ref, const std::string& inputFileName_ref, const std::string& histogramName_ref, const std::string& legendEntry_ref,
       const std::string& inputFilePath_test, const std::string& inputFileName_test, const std::string& histogramName_test, const std::string& legendEntry_test, 
       const std::string& inputFilePath_test2, const std::string& inputFileName_test2, const std::string& histogramName_test2, const std::string& legendEntry_test2,
       const std::string& outputFileName)
{
  std::cout << "<makePlot_shift_minus_central>:" << std::endl;

  TString inputFileName_ref_full = inputFilePath_ref;
  if ( !inputFileName_ref_full.EndsWith("/") ) inputFileName_ref_full.Append("/");
  inputFileName_ref_full.Append(inputFileName_ref.data());
  TFile* inputFile_ref = new TFile(inputFileName_ref_full.Data());
  TH1* histogram_ref = loadHistogram(inputFile_ref, histogramName_ref);
  double integral_ref = compIntegral(histogram_ref);
  divideByBinWidth(histogram_ref);

  TString inputFileName_test_full = inputFilePath_test;
  if ( !inputFileName_test_full.EndsWith("/") ) inputFileName_test_full.Append("/");
  inputFileName_test_full.Append(inputFileName_test.data());
  TFile* inputFile_test = ( inputFileName_test_full != inputFileName_ref_full ) ? 
    new TFile(inputFileName_test_full.Data()) : inputFile_ref;
  TH1* histogram_test = loadHistogram(inputFile_test, histogramName_test);
  double integral_test = compIntegral(histogram_test);
  divideByBinWidth(histogram_test);
  
  TFile* inputFile_test2 = 0;
  TH1* histogram_test2 = 0;
  double integral_test2 = -1.;
  if ( inputFilePath_test2 != "" && inputFileName_test2 != "" && histogramName_test2 != "" ) {
    TString inputFileName_test2_full = inputFilePath_test2;
    if ( !inputFileName_test2_full.EndsWith("/") ) inputFileName_test2_full.Append("/");
    inputFileName_test2_full.Append(inputFileName_test2.data());
    inputFile_test2 = ( inputFileName_test2_full != inputFileName_ref_full ) ? 
      new TFile(inputFileName_test2_full.Data()) : inputFile_ref;
    histogram_test2 = loadHistogram(inputFile_test2, histogramName_test2);
    integral_test2 = compIntegral(histogram_test2);
    divideByBinWidth(histogram_test2);
  }
  
  showHistograms(800, 900, 
		 histogram_ref, legendEntry_ref, integral_ref,
		 histogram_test, legendEntry_test, integral_test, 
		 histogram_test2, legendEntry_test2, integral_test2, 
		 //NULL, "", 0.,
		 NULL, "", 0.,
		 NULL, "", 0.,
		 NULL, "", 0.,
		 "m_{#tau#tau} [GeV]", 1.10,
		 true, 1.e-4, 1.e+4, "1/dm_{#tau#tau} [1/GeV]", 1.30,
		 0.34, 0.72,
		 outputFileName.data());

  TH1* histogramErr_ref = compHistogramErr(histogram_ref);
  TH1* histogramErr_test = compHistogramErr(histogram_test);
  TH1* histogramErr_test2 = ( histogram_test2 ) ?
    compHistogramErr(histogram_test2) : 0;
  std::string outputFileNameErr = TString(outputFileName.data()).ReplaceAll(".png", "_Err.png").Data();
  showHistograms(800, 900, 
		 histogramErr_ref, legendEntry_ref, -1.,
		 histogramErr_test, legendEntry_test, -1., 
		 histogramErr_test2, legendEntry_test2, -1., 
		 //NULL, "", 0.,
		 NULL, "", 0.,
		 NULL, "", 0.,
		 NULL, "", 0.,
		 "m_{#tau#tau} [GeV]", 1.10,
		 true, 1.e-4, 1.e+4, "#sigma(1/dm_{#tau#tau}) [1/GeV]", 1.30,
		 0.34, 0.72,
		 outputFileNameErr.data());

  delete histogramErr_ref;
  delete histogramErr_test;
  delete histogramErr_test2;
  
  delete inputFile_ref;
  if ( inputFile_test != inputFile_ref ) delete inputFile_test;
  if ( inputFile_test2 != inputFile_ref && inputFile_test2 != inputFile_test ) delete inputFile_test2;
}
Пример #4
0
void compareSyncNtuples(const std::string & ref_str,
                        const std::string & test_str,
                        const std::string & sample_str)
{
  gROOT->SetBatch(true);
  gErrorIgnoreLevel = kWarning;

  const NtupleMetaData & ref = ntupleMetadataMap.at(sample_str).at(ref_str);
  const NtupleMetaData & test = ntupleMetadataMap.at(sample_str).at(test_str);

  TFile* inputFile_ref = openFile(ref.inputFilePath, ref.inputFileName);
  TTree* tree_ref = loadTree(inputFile_ref, ref.treeName, ref.dirName);
  TFile* inputFile_test = openFile(test.inputFilePath, test.inputFileName);
  TTree* tree_test = loadTree(inputFile_test, test.treeName, test.dirName);

  const std::string outputFilePath = base_dir + "plots/" +
                                     sample_str + "/" + ref.legendEntry + "_vs_" + test.legendEntry;
  struct stat st = {0};
  if(stat(outputFilePath.c_str(), &st) == -1)
    _mkdir(outputFilePath.c_str());

  std::vector<branchEntryType*> branchesToCompare;
  branchesToCompare.push_back(new branchEntryType("n_presel_mu", "I", "", 20, -0.5, 19.5));
  branchesToCompare.push_back(new branchEntryType("n_fakeablesel_mu", "I", "", 20, -0.5, 19.5));
//  branchesToCompare.push_back(new branchEntryType("n_cutsel_mu", "I", "", 20, -0.5, 19.5));
  branchesToCompare.push_back(new branchEntryType("n_mvasel_mu", "I", "", 20, -0.5, 19.5));
  branchesToCompare.push_back(new branchEntryType("n_presel_ele", "I", "", 20, -0.5, 19.5));
  branchesToCompare.push_back(new branchEntryType("n_fakeablesel_ele", "I", "", 20, -0.5, 19.5));
//  branchesToCompare.push_back(new branchEntryType("n_cutsel_ele", "I", "", 20, -0.5, 19.5));
  branchesToCompare.push_back(new branchEntryType("n_mvasel_ele", "I", "", 20, -0.5, 19.5));
  branchesToCompare.push_back(new branchEntryType("n_presel_tau", "I", "", 20, -0.5, 19.5));
  branchesToCompare.push_back(new branchEntryType("n_presel_jet", "I", "", 20, -0.5, 19.5));
  branchesToCompare.push_back(new branchEntryType("mu0_charge", "I", "n_presel_mu >= 1", 3, -1.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("mu0_jetNDauChargedMVASel", "F", "n_presel_mu >= 1", 20, -0.5, 19.5));
  branchesToCompare.push_back(new branchEntryType("mu0_jetPtRel", "F", "n_presel_mu >= 1", 100., -0.01, 10.));
  branchesToCompare.push_back(new branchEntryType("mu0_miniIsoNeutral", "F", "n_presel_mu >= 1", 100, -0.01, 100.));
  branchesToCompare.push_back(new branchEntryType("mu0_miniIsoCharged", "F", "n_presel_mu >= 1", 100, -0.01, 100.));
  branchesToCompare.push_back(new branchEntryType("mu0_E", "F", "n_presel_mu >= 1", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("mu0_conept", "F", "", 100, 0., 1000.));
  branchesToCompare.push_back(new branchEntryType("mu0_jetPtRatio", "F", "n_presel_mu >= 1", 100, -0.01, 3.));
  branchesToCompare.push_back(new branchEntryType("mu0_leptonMVA", "F", "n_presel_mu >= 1", 100, -1., +1.));
  branchesToCompare.push_back(new branchEntryType("mu0_jetCSV", "F", "n_presel_mu >= 1", 100, 0., +1.));
  branchesToCompare.push_back(new branchEntryType("mu0_dpt_div_pt", "F", "n_presel_mu >= 1", 100, 0., +0.25));
  branchesToCompare.push_back(new branchEntryType("mu0_segmentCompatibility", "F", "n_presel_mu >= 1", 100, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("mu0_phi", "F", "n_presel_mu >= 1", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("mu0_sip3D", "F", "n_presel_mu >= 1", 100, 0., +10.));
  branchesToCompare.push_back(new branchEntryType("mu0_pt", "F", "n_presel_mu >= 1", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("mu0_miniRelIso", "F", "n_presel_mu >= 1", 100, -0.01, 1.));
  branchesToCompare.push_back(new branchEntryType("mu0_dxy", "F", "n_presel_mu >= 1", 100, -0.1, +0.1));
  branchesToCompare.push_back(new branchEntryType("mu0_eta", "F", "n_presel_mu >= 1", 100, -3., +3.));
  branchesToCompare.push_back(new branchEntryType("mu0_dz", "F", "n_presel_mu >= 1", 100, -0.2, +0.2));
  branchesToCompare.push_back(new branchEntryType("mu0_isfakeablesel", "I", "n_presel_mu >= 1", 2, -0.5, +1.5));
//  branchesToCompare.push_back(new branchEntryType("mu0_iscutsel", "I", "n_presel_mu >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("mu0_ismvasel", "I", "n_presel_mu >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("mu1_charge", "I", "n_presel_mu >= 2", 3, -1.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("mu1_jetNDauChargedMVASel", "F", "n_presel_mu >= 2", 20, -0.5, 19.5));
  branchesToCompare.push_back(new branchEntryType("mu1_jetPtRel", "F", "n_presel_mu >= 2", 100., -0.01, 10.));
  branchesToCompare.push_back(new branchEntryType("mu1_miniIsoNeutral", "F", "n_presel_mu >= 2", 100, -0.01, 100.));
  branchesToCompare.push_back(new branchEntryType("mu1_miniIsoCharged", "F", "n_presel_mu >= 2", 100, -0.01, 100.));
  branchesToCompare.push_back(new branchEntryType("mu1_E", "F", "n_presel_mu >= 2", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("mu1_conept", "F", "", 100, 0., 500.));
  branchesToCompare.push_back(new branchEntryType("mu1_jetPtRatio", "F", "n_presel_mu >= 2", 100, -0.01, 3.));
  branchesToCompare.push_back(new branchEntryType("mu1_leptonMVA", "F", "n_presel_mu >= 2", 100, -1., +1.));
  branchesToCompare.push_back(new branchEntryType("mu1_jetCSV", "F", "n_presel_mu >= 2", 100, 0., +1.));
  branchesToCompare.push_back(new branchEntryType("mu1_dpt_div_pt", "F", "n_presel_mu >= 2", 100, 0., +0.25));
  branchesToCompare.push_back(new branchEntryType("mu1_segmentCompatibility", "F", "n_presel_mu >= 2", 100, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("mu1_phi", "F", "n_presel_mu >= 2", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("mu1_sip3D", "F", "n_presel_mu >= 2", 100, 0., +10.));
  branchesToCompare.push_back(new branchEntryType("mu1_pt", "F", "n_presel_mu >= 2", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("mu1_miniRelIso", "F", "n_presel_mu >= 2", 100, -0.01, 1.));
  branchesToCompare.push_back(new branchEntryType("mu1_dxy", "F", "n_presel_mu >= 2", 100, -0.1, +0.1));
  branchesToCompare.push_back(new branchEntryType("mu1_eta", "F", "n_presel_mu >= 2", 100, -3., +3.));
  branchesToCompare.push_back(new branchEntryType("mu1_dz", "F", "n_presel_mu >= 2", 100, -0.2, +0.2));
  branchesToCompare.push_back(new branchEntryType("mu1_isfakeablesel", "I", "n_presel_mu >= 1", 2, -0.5, +1.5));
//  branchesToCompare.push_back(new branchEntryType("mu1_iscutsel", "I", "n_presel_mu >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("mu1_ismvasel", "I", "n_presel_mu >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("ele0_ntMVAeleID", "F", "n_presel_ele >= 1", 100, -1., +1.));
  branchesToCompare.push_back(new branchEntryType("ele0_charge", "I", "n_presel_ele >= 1", 3, -1.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("ele0_jetNDauChargedMVASel", "F", "n_presel_ele >= 1", 20, -0.5, +19.5));
  branchesToCompare.push_back(new branchEntryType("ele0_jetPtRel", "F", "n_presel_ele >= 1", 100, -0.01, 10.));
  branchesToCompare.push_back(new branchEntryType("ele0_miniIsoNeutral", "F", "n_presel_ele >= 1", 100, -0.01, 100.));
  branchesToCompare.push_back(new branchEntryType("ele0_miniIsoCharged", "F", "n_presel_ele >= 1", 100, -0.01, 100.));
  branchesToCompare.push_back(new branchEntryType("ele0_E", "F", "n_presel_ele >= 1", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("ele0_conept", "F", "", 100, 0., 1000.));
  branchesToCompare.push_back(new branchEntryType("ele0_jetPtRatio", "F", "n_presel_ele >= 1", 100, -0.01, 3.));
  branchesToCompare.push_back(new branchEntryType("ele0_leptonMVA", "F", "n_presel_ele >= 1", 100, -1., +1.));
  branchesToCompare.push_back(new branchEntryType("ele0_jetCSV", "F", "n_presel_ele >= 1", 100, 0., +1.));
  branchesToCompare.push_back(new branchEntryType("ele0_phi", "F", "n_presel_ele >= 1", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("ele0_sip3D", "F", "n_presel_ele >= 1", 100, 0., +10.));
  branchesToCompare.push_back(new branchEntryType("ele0_pt", "F", "n_presel_ele >= 1", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("ele0_miniRelIso", "F", "n_presel_ele >= 1", 100, -0.01, 1.));
  branchesToCompare.push_back(new branchEntryType("ele0_dxy", "F", "n_presel_ele >= 1", 100, -0.1, +0.1));
  branchesToCompare.push_back(new branchEntryType("ele0_eta", "F", "n_presel_ele >= 1", 100, -3.0, +3.0));
  branchesToCompare.push_back(new branchEntryType("ele0_dz", "F", "n_presel_ele >= 1", 100, -0.2, +0.2));
  branchesToCompare.push_back(new branchEntryType("ele0_nMissingHits", "I", "n_presel_ele >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("ele0_isChargeConsistent", "I", "n_presel_ele >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("ele0_isfakeablesel", "I", "n_presel_ele >= 1", 2, -0.5, +1.5));
//  branchesToCompare.push_back(new branchEntryType("ele0_iscutsel", "I", "n_presel_ele >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("ele0_ismvasel", "I", "n_presel_ele >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("ele1_ntMVAeleID", "F", "n_presel_ele >= 2", 100, -1., +1.));
  branchesToCompare.push_back(new branchEntryType("ele1_charge", "I", "n_presel_ele >= 2", 3, -1.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("ele1_jetNDauChargedMVASel", "F", "n_presel_ele >= 2", 20, -0.5, +19.5));
  branchesToCompare.push_back(new branchEntryType("ele1_jetPtRel", "F", "n_presel_ele >= 2", 100, -0.01, 10.));
  branchesToCompare.push_back(new branchEntryType("ele1_miniIsoNeutral", "F", "n_presel_ele >= 2", 100, -0.01, 100.));
  branchesToCompare.push_back(new branchEntryType("ele1_miniIsoCharged", "F", "n_presel_ele >= 2", 100, -0.01, 100.));
  branchesToCompare.push_back(new branchEntryType("ele1_E", "F", "n_presel_ele >= 2", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("ele1_conept", "F", "", 100, 0., 500.));
  branchesToCompare.push_back(new branchEntryType("ele1_jetPtRatio", "F", "n_presel_ele >= 2", 100, -0.01, 3.));
  branchesToCompare.push_back(new branchEntryType("ele1_leptonMVA", "F", "n_presel_ele >= 2", 100, -1., +1.));
  branchesToCompare.push_back(new branchEntryType("ele1_jetCSV", "F", "n_presel_ele >= 2", 100, 0., +1.));
  branchesToCompare.push_back(new branchEntryType("ele1_phi", "F", "n_presel_ele >= 2", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("ele1_sip3D", "F", "n_presel_ele >= 2", 100, 0., +10.));
  branchesToCompare.push_back(new branchEntryType("ele1_pt", "F", "n_presel_ele >= 2", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("ele1_miniRelIso", "F", "n_presel_ele >= 2", 100, -0.01, 1.));
  branchesToCompare.push_back(new branchEntryType("ele1_dxy", "F", "n_presel_ele >= 2", 100, -0.1, +0.1));
  branchesToCompare.push_back(new branchEntryType("ele1_eta", "F", "n_presel_ele >= 2", 100, -3.0, +3.0));
  branchesToCompare.push_back(new branchEntryType("ele1_dz", "F", "n_presel_ele >= 2", 100, -0.2, +0.2));
  branchesToCompare.push_back(new branchEntryType("ele1_nMissingHits", "I", "n_presel_ele >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("ele1_isChargeConsistent", "I", "n_presel_ele >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("ele1_isfakeablesel", "I", "n_presel_ele >= 2", 2, -0.5, +1.5));
//  branchesToCompare.push_back(new branchEntryType("ele1_iscutsel", "I", "n_presel_ele >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("ele1_ismvasel", "I", "n_presel_ele >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_againstElectronVTightMVA6", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_againstElectronTightMVA6", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_againstElectronMediumMVA6", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_againstElectronLooseMVA6", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_againstElectronVLooseMVA6", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_againstMuonLoose3", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byVTightIsolationMVArun2v1DBdR03oldDMwLT", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byTightIsolationMVArun2v1DBdR03oldDMwLT", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byMediumIsolationMVArun2v1DBdR03oldDMwLT", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byLooseCombinedIsolationDeltaBetaCorr3Hits", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_decayModeFindingOldDMs", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_againstMuonTight3", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byLooseCombinedIsolationDeltaBetaCorr3HitsdR03", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_decayModeFindingNewDMs", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_charge", "I", "n_presel_tau >= 1", 3, -1.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byTightCombinedIsolationDeltaBetaCorr3Hits", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byMediumCombinedIsolationDeltaBetaCorr3Hits", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byMediumCombinedIsolationDeltaBetaCorr3HitsdR03", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byTightCombinedIsolationDeltaBetaCorr3HitsdR03", "I", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byLooseIsolationMVArun2v1DBdR03oldDMwLT", "F", "n_presel_tau >= 1", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau0_byCombinedIsolationDeltaBetaCorr3Hits", "F", "n_presel_tau >= 1", 100, -0.01, 5.));
  branchesToCompare.push_back(new branchEntryType("tau0_dz", "F", "n_presel_tau >= 1", 100, -0.3, +0.3));
  branchesToCompare.push_back(new branchEntryType("tau0_dxy", "F", "n_presel_tau >= 1", 100, -0.2, +0.2));
  branchesToCompare.push_back(new branchEntryType("tau0_pt", "F", "n_presel_tau >= 1", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("tau0_eta", "F", "n_presel_tau >= 1", 100, -3., +3.));
  branchesToCompare.push_back(new branchEntryType("tau0_phi", "F", "n_presel_tau >= 1", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("tau0_E", "F", "n_presel_tau >= 1", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("tau1_againstElectronVTightMVA6", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_againstElectronTightMVA6", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_againstElectronMediumMVA6", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_againstElectronLooseMVA6", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_againstElectronVLooseMVA6", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_againstMuonLoose3", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byVTightIsolationMVArun2v1DBdR03oldDMwLT", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byTightIsolationMVArun2v1DBdR03oldDMwLT", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byMediumIsolationMVArun2v1DBdR03oldDMwLT", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byLooseCombinedIsolationDeltaBetaCorr3Hits", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_decayModeFindingOldDMs", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_againstMuonTight3", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byLooseCombinedIsolationDeltaBetaCorr3HitsdR03", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_decayModeFindingNewDMs", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_charge", "I", "n_presel_tau >= 2", 3, -1.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byTightCombinedIsolationDeltaBetaCorr3Hits", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byMediumCombinedIsolationDeltaBetaCorr3Hits", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byMediumCombinedIsolationDeltaBetaCorr3HitsdR03", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byTightCombinedIsolationDeltaBetaCorr3HitsdR03", "I", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byLooseIsolationMVArun2v1DBdR03oldDMwLT", "F", "n_presel_tau >= 2", 2, -0.5, +1.5));
  branchesToCompare.push_back(new branchEntryType("tau1_byCombinedIsolationDeltaBetaCorr3Hits", "F", "n_presel_tau >= 2", 100, -0.01, 5.));
  branchesToCompare.push_back(new branchEntryType("tau1_dz", "F", "n_presel_tau >= 2", 100, -0.3, +0.3));
  branchesToCompare.push_back(new branchEntryType("tau1_dxy", "F", "n_presel_tau >= 2", 100, -0.2, +0.2));
  branchesToCompare.push_back(new branchEntryType("tau1_pt", "F", "n_presel_tau >= 2", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("tau1_eta", "F", "n_presel_tau >= 2", 100, -3., +3.));
  branchesToCompare.push_back(new branchEntryType("tau1_phi", "F", "n_presel_tau >= 2", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("tau1_E", "F", "n_presel_tau >= 2", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("jet0_CSV", "F", "n_presel_jet >= 1", 100, 0., +1.));
  branchesToCompare.push_back(new branchEntryType("jet0_pt", "F", "n_presel_jet >= 1", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("jet0_eta", "F", "n_presel_jet >= 1", 100, -3., +3.));
  branchesToCompare.push_back(new branchEntryType("jet0_phi", "F", "n_presel_jet >= 1", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("jet0_E", "F", "n_presel_jet >= 1", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("jet1_CSV", "F", "n_presel_jet >= 2", 100, 0., +1.));
  branchesToCompare.push_back(new branchEntryType("jet1_pt", "F", "n_presel_jet >= 2", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("jet1_eta", "F", "n_presel_jet >= 2", 100, -3., +3.));
  branchesToCompare.push_back(new branchEntryType("jet1_phi", "F", "n_presel_jet >= 2", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("jet1_E", "F", "n_presel_jet >= 2", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("jet2_CSV", "F", "n_presel_jet >= 3", 100, 0., +1.));
  branchesToCompare.push_back(new branchEntryType("jet2_pt", "F", "n_presel_jet >= 3", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("jet2_eta", "F", "n_presel_jet >= 3", 100, -3., +3.));
  branchesToCompare.push_back(new branchEntryType("jet2_phi", "F", "n_presel_jet >= 3", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("jet2_E", "F", "n_presel_jet >= 3", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("jet3_CSV", "F", "n_presel_jet >= 4", 100, 0., +1.));
  branchesToCompare.push_back(new branchEntryType("jet3_pt", "F", "n_presel_jet >= 4", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("jet3_eta", "F", "n_presel_jet >= 4", 100, -3., +3.));
  branchesToCompare.push_back(new branchEntryType("jet3_phi", "F", "n_presel_jet >= 4", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("jet3_E", "F", "n_presel_jet >= 4", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("PFMET", "F", "", 100, 0., 250.));
  branchesToCompare.push_back(new branchEntryType("PFMETphi", "F", "", 36, -TMath::Pi(), +TMath::Pi()));
  branchesToCompare.push_back(new branchEntryType("MHT", "F", "", 100, 0., 600.));
  branchesToCompare.push_back(new branchEntryType("metLD", "F", "", 100, 0., 2.));
  branchesToCompare.push_back(new branchEntryType("lep0_conept", "F", "", 100, 0., 1000.));
  branchesToCompare.push_back(new branchEntryType("lep1_conept", "F", "", 100, 0., 500.));
  branchesToCompare.push_back(new branchEntryType("mindr_lep0_jet", "F", "", 100, 0., 5.));
  branchesToCompare.push_back(new branchEntryType("mindr_lep1_jet", "F", "", 100, 0., 5.));
//  branchesToCompare.push_back(new branchEntryType("n_jet25_recl", "F", "", 100, 0., 50.));
  branchesToCompare.push_back(new branchEntryType("MT_met_lep0", "F", "", 100, 0., 500.));
  branchesToCompare.push_back(new branchEntryType("avg_dr_jet", "F", "", 100, 0., 6.));
  branchesToCompare.push_back(new branchEntryType("MVA_2lss_ttV", "F", "(n_fakeablesel_mu + n_fakeablesel_ele) >= 2", 100, -1., 1.));
  branchesToCompare.push_back(new branchEntryType("MVA_2lss_ttbar", "F", "(n_fakeablesel_mu + n_fakeablesel_ele) >= 2", 100, -1., 1.));

  for ( std::vector<branchEntryType*>::const_iterator branch = branchesToCompare.begin();
        branch != branchesToCompare.end(); ++branch ) {
    std::cout << "plotting " << (*branch)->branchName_ << "..." << std::endl;

    branchEntryType* branch_ref = (*branch)->Clone("ref");
    if(branch_ref->fillHistogram(tree_ref, ref.selection) < 0)
      branch_ref->histogram_ = nullptr;
    else
      normalizeHistogram(branch_ref->histogram_);
    
    branchEntryType* branch_test = (*branch)->Clone("test");
    if(branch_test->fillHistogram(tree_test, test.selection) < 0)
      branch_test->histogram_ = nullptr;
    else
      normalizeHistogram(branch_test->histogram_);

    std::string outputFileName = Form("compareSyncNtuples_%s.png", (*branch)->branchName_.data());
    showHistograms(800, 900, 
                   branch_ref->histogram_, ref.legendEntry,
                   branch_test->histogram_, test.legendEntry,
                   NULL, "",
                   NULL, "",
                   NULL, "",
                   NULL, "",
                   (*branch)->branchName_, 1.10,
                   true, 1.e-4, 1.e+1, "N", 1.30,
                   0.16, 0.80,
                   outputFilePath, outputFileName);

    delete branch_ref;
    delete branch_test;
  }
  
  for ( std::vector<branchEntryType*>::const_iterator it = branchesToCompare.end();
        it != branchesToCompare.end(); ++it ) {
    delete (*it);
  }

  delete inputFile_ref;
  delete inputFile_test;
}
void makeSVfitPerformancePlots_WH()
{
  std::string inputFileName = "/data1/veelken/tmp/svFitStudies/WH/2012May01/svFitPerformanceAnalysisPlots_all_2012Mar13.root";
  TFile* inputFile = new TFile(inputFileName.data());

  gROOT->SetBatch(true);

  std::string directory_PSkine_woLogM_Int     = "nSVfitAnalyzerOption3b";
  std::string directory_PSkine_woLogM_Fit     = "nSVfitAnalyzerOption3a";
  std::string directory_PSkine_wLogM_Int      = "nSVfitAnalyzerOption1b";
  std::string directory_PSkine_wLogM_Fit      = "nSVfitAnalyzerOption1a";
  std::string directory_MEkine12_wPolZorH_Int = "nSVfitAnalyzerOption6b";
  std::string directory_MEkine12_wPolZorH_Fit = "nSVfitAnalyzerOption6a";
  
  std::string histogramName_svFitMass = "svFitMass";
  std::string xAxisTitle_svFitMass    = "M_{#tau#tau} / GeV";

  std::vector<double> xPoints_metResolution;
  xPoints_metResolution.push_back(5.);
  xPoints_metResolution.push_back(10.);
  xPoints_metResolution.push_back(15.);
  xPoints_metResolution.push_back(20.);

  std::vector<double> massPoints;
  massPoints.push_back(90.);
  massPoints.push_back(120.);
  massPoints.push_back(140.);
  massPoints.push_back(160.);

  std::vector<double> massPointsToCompare;
  massPointsToCompare.push_back(90.);
  massPointsToCompare.push_back(120.);

  double metResolution_nominal = -1.;
  //double metResolution_nominal = 15.;

  std::vector<std::string> channels;
  channels.push_back("WtoMuNuHiggsToDiTau");

  std::vector<std::string> label_ZplusJets;
  label_ZplusJets.push_back(std::string("Sim. WZ #rightarrow #mu#nu#tau#tau"));

  std::vector<std::string> label_Higgs120;
  label_Higgs120.push_back(std::string("Sim. WH #rightarrow #mu#nu#tau#tau"));
  label_Higgs120.push_back(std::string("M = 120 GeV"));

  //-----------------------------------------------------------------------------
  // make plots comparing Fit vs. Integration 
  // in terms of resolution
  //-----------------------------------------------------------------------------

  for ( std::vector<std::string>::const_iterator channel = channels.begin();
	channel != channels.end(); ++channel ) {
    for ( std::vector<double>::const_iterator massPoint = massPointsToCompare.begin();
	  massPoint != massPointsToCompare.end(); ++massPoint ) {
      TH1* histogram1 = 
	getHistogram(inputFile, *channel, *massPoint, directory_PSkine_woLogM_Int, 
		     histogramName_svFitMass, metResolution_nominal);
      std::string legendEntry1 = "PS, Int";
      TH1* histogram2 = 
	getHistogram(inputFile, *channel, *massPoint, directory_PSkine_wLogM_Fit, 
		     histogramName_svFitMass, metResolution_nominal);
      std::string legendEntry2 = "PS + log(M), Fit";
      std::vector<std::string> label;
      std::string process = "";
      double xMax = -1.;
      if ( (*massPoint) == 90. ) {
	label = label_ZplusJets;
	process = "ZToTauTau";
	xMax = 250.;
      } else if  ( (*massPoint) == 120. ) {
	label = label_Higgs120;
	process = "HToTauTau_M-120";
	xMax = 250.;
      } else assert(0);
      double yMax = 0.;
      if   ( (*massPoint) <  95. ) yMax = 0.30;
      else                         yMax = 0.25;
      double labelSizeY = label.size()*0.05;
      showHistograms(800, 600, 
		     histogram1, legendEntry1,
		     histogram2, legendEntry2,
		     NULL, "",
		     NULL, "",
		     0.04, 0.61, 0.74, 0.28, 0.15,
		     label, 0.04, 0.17, 0.89 - labelSizeY, 0.18, labelSizeY, 
		     0., xMax, xAxisTitle_svFitMass, 1.2,
		     false, 0., yMax, "a.u.", 1.4,
		     Form("svFitPerformance_%s_%s_Fit_vs_Int_linear_WH.eps", process.data(), channel->data()));
      showHistograms(800, 600, 
		     histogram1, legendEntry1,
		     histogram2, legendEntry2,
		     NULL, "",
		     NULL, "",
		     0.04, 0.61, 0.74, 0.28, 0.15,
		     label, 0.04, 0.17, 0.89 - labelSizeY, 0.18, labelSizeY, 
		     0., 1.4*xMax, xAxisTitle_svFitMass, 1.2,
		     true, 1.e-4, 1.e0, "a.u.", 1.4,
		     Form("svFitPerformance_%s_%s_Fit_vs_Int_log_WH.eps", process.data(), channel->data()));
    }
  }
    
  //-----------------------------------------------------------------------------
  // make plots comparing different Likelihood models 
  // for leptonic and hadronic tau decays (in Integration mode)
  // in terms of resolution
  //-----------------------------------------------------------------------------
    
  for ( std::vector<std::string>::const_iterator channel = channels.begin();
	channel != channels.end(); ++channel ) {
    for ( std::vector<double>::const_iterator massPoint = massPointsToCompare.begin();
	  massPoint != massPointsToCompare.end(); ++massPoint ) {
      TH1* histogram1 = 0;
      std::string legendEntry1 = "";
      TH1* histogram2 = 0;
      std::string legendEntry2 = "";
      TH1* histogram3 = 0;
      std::string legendEntry3 = "";
      TH1* histogram4 = 0;
      std::string legendEntry4 = "";
      double legendSizeX = 0.;      
      double yMax = 0.;
      if ( (*channel) == "WtoMuNuHiggsToDiTau" ) {	
	histogram1 = 
	  getHistogram(inputFile, *channel, *massPoint, directory_PSkine_woLogM_Int, 
		       histogramName_svFitMass, metResolution_nominal);
	legendEntry1 = "PS, Int";
	histogram2 = 
	  getHistogram(inputFile, *channel, *massPoint, directory_MEkine12_wPolZorH_Int, 
		       histogramName_svFitMass, metResolution_nominal);
	legendEntry2 = "ME, Int";
	//histogram3 = 
	//  getHistogram(inputFile, *channel, *massPoint, directory_MCkine_selected_Int, 
	//	       histogramName_svFitMass, metResolution_nominal);
	//legendEntry3 = "MC, Int";
	legendSizeX = 0.12;
	if   ( (*massPoint) <  95. ) yMax = 0.30;
	else                         yMax = 0.25;
      } else assert(0);
      unsigned numLegendEntries = 0;
      if ( legendEntry1 != "" ) ++numLegendEntries;
      if ( legendEntry2 != "" ) ++numLegendEntries;
      if ( legendEntry3 != "" ) ++numLegendEntries;
      if ( legendEntry4 != "" ) ++numLegendEntries;
      double legendSizeY = 0.05*numLegendEntries;
      std::vector<std::string> label;
      std::string process = "";
      double xMax = -1.;
      if ( (*massPoint) == 90. ) {
	label = label_ZplusJets;
	process = "ZToTauTau";
	xMax = 250.;
      } else if  ( (*massPoint) == 120. ) {
	label = label_Higgs120;
	process = "HToTauTau_M-120";
	xMax = 250.;
      } else assert(0);
      double labelSizeY = label.size()*0.05;
      showHistograms(800, 600, 
		     histogram1, legendEntry1,
		     histogram2, legendEntry2,
		     histogram3, legendEntry3,
		     histogram4, legendEntry4,
		     0.04, 0.89 - legendSizeX, 0.89 - legendSizeY, legendSizeX, legendSizeY,
		     label, 0.04, 0.17, 0.89 - labelSizeY, 0.18, labelSizeY, 
		     0., xMax, xAxisTitle_svFitMass, 1.2,
		     false, 0., yMax, "a.u.", 1.4,
		     Form("svFitPerformance_%s_%s_compLikelihoodModels_linear_WH.eps", process.data(), channel->data()));
      showHistograms(800, 600, 
		     histogram1, legendEntry1,
		     histogram2, legendEntry2,
		     histogram3, legendEntry3,
		     histogram4, legendEntry4,
		     0.04, 0.89 - legendSizeX, 0.74, legendSizeX, 0.15,
		     label, 0.04, 0.17, 0.89 - labelSizeY, 0.18, labelSizeY, 
		     0., xMax, xAxisTitle_svFitMass, 1.2,
		     true, 1.e-4, 1.e0, "a.u.", 1.4,
		     Form("svFitPerformance_%s_%s_compLikelihoodModels_log_WH.eps", process.data(), channel->data()));
    }
  }
  
  int colors_style1[3] = { 1, 2, 4 };                      // style 1: used to show respone and symmetric resolution for Z vs. Higgs(120)
  int markerStyles_style1[3] = { 20, 21, 33 };

  int colors_style2[6] = { 1, 1, 2, 2, 4, 4 };             // style 2: used to show asymmetric resolution for Z vs. Higgs(120)
  int markerStyles_style2[6] = { 22, 32, 20, 24, 21, 25 }; //   (22 = right tail of resolution, 23 = left tail of resolution)
  
  //-----------------------------------------------------------------------------
  // make plots comparing SVfit mass distributions 
  // obtained for different values of MET resolution
  // in terms of response and resolution
  //-----------------------------------------------------------------------------
/*    
  for ( std::vector<std::string>::const_iterator channel = channels.begin();
	channel != channels.end(); ++channel ) {
    for ( std::vector<double>::const_iterator massPoint = massPointsToCompare.begin();
	  massPoint != massPointsToCompare.end(); ++massPoint ) {
      std::vector<std::string> label;
      std::string process = "";
      double xMax = -1.;
      if ( (*massPoint) == 90. ) {
	label = label_ZplusJets;
	process = "ZToTauTau";
	xMax = 250.;
      } else if  ( (*massPoint) == 120. ) {
	label = label_Higgs120;
	process = "HToTauTau_M-120";
      } else assert(0);
      int numEntries = TMath::Max(4, (int)xPoints_metResolution.size());
      std::vector<TH1*> histograms(numEntries);
      std::vector<std::string> legendEntries(numEntries);
      int idx = 0;
      for ( std::vector<double>::const_iterator metResolution = xPoints_metResolution.begin();
	    metResolution != xPoints_metResolution.end(); ++metResolution ) {
	histograms[idx] =  
	  getHistogram(inputFile, *channel, *massPoint, directory_PSkine_woLogM_Int, 
		       histogramName_svFitMass, *metResolution);
	legendEntries[idx] = Form("#sigma_{X} = #sigma_{Y} = %1.0f GeV", *metResolution);
	++idx;
      }
      showHistograms(800, 600, 
		     histograms[0], legendEntries[0],
		     histograms[1], legendEntries[1],
		     histograms[2], legendEntries[2],
		     histograms[3], legendEntries[3],
		     0.04, 0.61, 0.74, 0.28, 0.15,
		     label, 0.04, 0.175, 0.725, 0.24, 0.165, 
		     0., xMax, xAxisTitle_svFitMass, 1.2,
		     false, 0., 0.35, "a.u.", 1.4,
		     Form("svFitPerformance_%s_%s_PSkine_woLogM_Int_vs_metResolution_linear_WH.eps", process.data(), channel->data()));
      showHistograms(800, 600,
		     histograms[0], legendEntries[0],
		     histograms[1], legendEntries[1],
		     histograms[2], legendEntries[2],
		     histograms[3], legendEntries[3],
		     0.04, 0.61, 0.74, 0.28, 0.15,
		     label, 0.04, 0.175, 0.725, 0.24, 0.165, 
		     0., xMax, xAxisTitle_svFitMass, 1.2,
		     true, 1.e-4, 1.e0, "a.u.", 1.4,
		     Form("svFitPerformance_%s_%s_PSkine_woLogM_Int_vs_metResolution_log_WH.eps", process.data(), channel->data()));
    }
  }

  for ( std::vector<std::string>::const_iterator channel = channels.begin();
	channel != channels.end(); ++channel ) {
    std::map<std::string, std::vector<histogram_vs_X_Type> > histograms_vs_metResolution; // key = process
    for ( std::vector<double>::const_iterator massPoint = massPointsToCompare.begin();
	  massPoint != massPointsToCompare.end(); ++massPoint ) {
      std::string process = "";
      if      ( (*massPoint) ==  90. ) process = "ZToTauTau";
      else if ( (*massPoint) == 120. ) process = "HToTauTau_M-120";
      else assert(0);
      for ( std::vector<double>::const_iterator metResolution = xPoints_metResolution.begin();
	    metResolution != xPoints_metResolution.end(); ++metResolution ) {
	TH1* histogram =  
	  getHistogram(inputFile, *channel, *massPoint, directory_PSkine_woLogM_Int, 
		       histogramName_svFitMass, *metResolution);
	histograms_vs_metResolution[process].push_back(
	  histogram_vs_X_Type(histogram, *metResolution, 0., 0.));
      }    
    }
    std::vector<std::string> label_metResolution;
    TGraph* graph_ZplusJets_response = makeGraph(histograms_vs_metResolution["ZToTauTau"], 90., "response");
    TGraph* graph_Higgs120_response  = makeGraph(histograms_vs_metResolution["HToTauTau_M-120"], 120., "response");
    showGraphs(800, 600,
	       graph_ZplusJets_response, "Sim. Z #rightarrow #tau#tau", 
	       graph_Higgs120_response, "Sim. H_{120} #rightarrow #tau#tau",
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       colors_style1, markerStyles_style1,
	       0.04, 0.61, 0.74, 0.28, 0.15,
	       label_metResolution, 0.04, 0.175, 0.725, 0.24, 0.165, 
	       0., 25., "#sigma_{X/Y} / GeV", 1.2,
	       0.75, 1.25, "<M_{#tau#tau}>/M", 1.4,
	       Form("svFitPerformance_%s_PSkine_woLogM_Int_response_vs_metResolution_WH.eps", channel->data()));
    TGraph* graph_ZplusJets_response_asymmetric = makeGraph(histograms_vs_metResolution["ZToTauTau"], 90., "response_asymmetric");
    TGraph* graph_Higgs120_response_asymmetric  = makeGraph(histograms_vs_metResolution["HToTauTau_M-120"], 120., "response_asymmetric");
    showGraphs(800, 600,
	       graph_ZplusJets_response_asymmetric, "Sim. Z #rightarrow #tau#tau", 
	       graph_Higgs120_response_asymmetric, "Sim. H_{120} #rightarrow #tau#tau",
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       colors_style1, markerStyles_style1,
	       0.04, 0.61, 0.74, 0.28, 0.15,
	       label_metResolution, 0.04, 0.175, 0.725, 0.24, 0.165, 
	       0., 25., "#sigma_{X/Y} / GeV", 1.2,
	       0.75, 1.25, "M_{#tau#tau}^{max}/M", 1.4,
	       Form("svFitPerformance_%s_PSkine_woLogM_Int_response_vs_metResolution_asymmetric_WH.eps", channel->data()));
    TGraph* graph_ZplusJets_resolution = makeGraph(histograms_vs_metResolution["ZToTauTau"], 90., "resolution");
    TGraph* graph_Higgs120_resolution  = makeGraph(histograms_vs_metResolution["HToTauTau_M-120"], 120., "resolution");
    showGraphs(800, 600,
	       graph_ZplusJets_resolution, "Sim. Z #rightarrow #tau#tau", 
	       graph_Higgs120_resolution, "Sim. H_{120} #rightarrow #tau#tau",
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       colors_style1, markerStyles_style1,
	       0.04, 0.61, 0.74, 0.28, 0.15,
	       label_metResolution, 0.04, 0.175, 0.725, 0.24, 0.165, 
	       0., 25., "#sigma_{X/Y} / GeV", 1.2,
	       0., 0.50, "#sigmaM_{#tau#tau}/<M_{#tau#tau}>", 1.4,
	       Form("svFitPerformance_%s_PSkine_woLogM_Int_resolution_vs_metResolution_WH.eps", channel->data()));
    TGraph* graph_ZplusJets_resolution_asymmetric_left  = makeGraph(histograms_vs_metResolution["ZToTauTau"], 90., "resolution_asymmetric_left");
    TGraph* graph_ZplusJets_resolution_asymmetric_right = makeGraph(histograms_vs_metResolution["ZToTauTau"], 90., "resolution_asymmetric_right");
    TGraph* graph_Higgs120_resolution_asymmetric_left   = makeGraph(histograms_vs_metResolution["HToTauTau_M-120"], 120., "resolution_asymmetric_left");
    TGraph* graph_Higgs120_resolution_asymmetric_right  = makeGraph(histograms_vs_metResolution["HToTauTau_M-120"], 120., "resolution_asymmetric_right");
    showGraphs(800, 600,
	       graph_ZplusJets_resolution_asymmetric_right, "Sim. Z #rightarrow #tau#tau +",
	       graph_ZplusJets_resolution_asymmetric_left, "Sim. Z #rightarrow #tau#tau -",
	       graph_Higgs120_resolution_asymmetric_right, "Sim. H_{120} #rightarrow #tau#tau +",
	       graph_Higgs120_resolution_asymmetric_left, "Sim. H_{120} #rightarrow #tau#tau -",
	       NULL, "", 
	       NULL, "", 
	       colors_style2, markerStyles_style2,
	       0.04, 0.59, 0.64, 0.30, 0.25,
	       label_metResolution, 0.04, 0.175, 0.725, 0.24, 0.165, 
	       0., 25., "#sigma_{X/Y} / GeV", 1.2,
	       0., 0.60, "#sigmaM_{#tau#tau}/M_{#tau#tau}^{max}", 1.4,
	       Form("svFitPerformance_%s_PSkine_woLogM_Int_resolution_vs_metResolution_asymmetric_WH.eps", channel->data()));
  }
 */
  //-----------------------------------------------------------------------------
  // make plots of response and resolution 
  // obtained for different values of the true tau-pair mass
  //-----------------------------------------------------------------------------

  for ( std::vector<std::string>::const_iterator channel = channels.begin();
	channel != channels.end(); ++channel ) {
    std::vector<histogram_vs_X_Type> histograms_vs_mA;
    std::vector<double> y_true_array;
    for ( std::vector<double>::const_iterator massPoint = massPoints.begin();
	  massPoint != massPoints.end(); ++massPoint ) {
      std::string process = "";
      if ( (*massPoint) == 90. ) {
	process = "ZToTauTau";
      } else {
	process = Form("HToTauTau_M-%1.0f", *massPoint);
      }
      TH1* histogram = 
	getHistogram(inputFile, *channel, *massPoint, directory_PSkine_woLogM_Int, 
		     histogramName_svFitMass, metResolution_nominal);
      histograms_vs_mA.push_back(
	histogram_vs_X_Type(histogram, *massPoint, 0., 0.));
      y_true_array.push_back(*massPoint);
    }
    std::vector<std::string> label_mA;
    TGraph* graph_response = makeGraph(histograms_vs_mA, y_true_array, "response");
    showGraphs(800, 600,
	       graph_response, "Sim. Z/H #rightarrow #tau#tau",
	       NULL, "", 
	       NULL, "",
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       colors_style1, markerStyles_style1,
	       0.04, 0.61, 0.74, 0.28, 0.15,
	       label_mA, 0.04, 0.175, 0.725, 0.24, 0.165, 
	       70., 180., "M / GeV", 1.2,
	       0.75, 1.25, "<M_{#tau#tau}>/M", 1.4,
	       Form("svFitPerformance_%s_PSkine_woLogM_Int_response_vs_mA_WH.eps", channel->data()));
    TGraph* graph_response_asymmetric = makeGraph(histograms_vs_mA, y_true_array, "response_asymmetric");
    showGraphs(800, 600,
	       graph_response_asymmetric, "Sim. Z/H #rightarrow #tau#tau", 
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       colors_style1, markerStyles_style1,
	       0.04, 0.61, 0.74, 0.28, 0.15,
	       label_mA, 0.04, 0.175, 0.725, 0.24, 0.165, 
	       70., 180., "M / GeV", 1.2,
	       0.75, 1.25, "M_{#tau#tau}^{max}/M", 1.4,
	       Form("svFitPerformance_%s_PSkine_woLogM_Int_response_vs_mA_asymmetric_WH.eps", channel->data()));
    TGraph* graph_resolution = makeGraph(histograms_vs_mA, y_true_array, "resolution");
    showGraphs(800, 600,
	       graph_resolution, "Sim. Z/H #rightarrow #tau#tau", 
	       NULL, "", 
	       NULL, "",
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       colors_style1, markerStyles_style1,
	       0.04, 0.61, 0.74, 0.28, 0.15,
	       label_mA, 0.04, 0.175, 0.725, 0.24, 0.165, 
	       70., 180., "M / GeV", 1.2,
	       0., 0.50, "#sigmaM_{#tau#tau}/<M_{#tau#tau}>", 1.4,
	       Form("svFitPerformance_%s_PSkine_woLogM_Int_resolution_vs_mA_WH.eps", channel->data()));
    TGraph* graph_resolution_asymmetric_left  = makeGraph(histograms_vs_mA, y_true_array, "resolution_asymmetric_left");
    TGraph* graph_resolution_asymmetric_right = makeGraph(histograms_vs_mA, y_true_array, "resolution_asymmetric_right");
    showGraphs(800, 600,
	       graph_resolution_asymmetric_right, "Sim. Z/H #rightarrow #tau#tau +",
	       graph_resolution_asymmetric_left, "Sim. Z/H #rightarrow #tau#tau -",
	       NULL, "",
	       NULL, "", 
	       NULL, "", 
	       NULL, "", 
	       colors_style2, markerStyles_style2,
	       0.04, 0.59, 0.74, 0.30, 0.15,
	       label_mA, 0.04, 0.175, 0.725, 0.24, 0.165, 
	       70., 180., "M / GeV", 1.2,
	       0., 0.50, "#sigmaM_{#tau#tau}/M_{#tau#tau}^{max}", 1.4,
	       Form("svFitPerformance_%s_PSkine_woLogM_Int_resolution_vs_mA_asymmetric_WH.eps", channel->data()));
  }
      
  delete inputFile;
}