Пример #1
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;
}
Пример #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;
}
void plotMarkovChainMonitorTree()
{
  std::string inputFilePath = "/data1/veelken/tmp/svFitStudies/";

  std::vector<std::string> eventsToProcess;
  eventsToProcess.push_back("1:102093:40804761");
  //eventsToProcess.push_back("1:3369:1346645");
  //eventsToProcess.push_back("1:89621:35819785");
  //eventsToProcess.push_back("1:79157:31638382");

  std::string genNtupleFileName = "/data1/veelken/tmp/svFitStudies/testNSVfitTrackLikelihoods3_ntuple_Higgs_mutau_125_2012Nov30.root";

  gROOT->SetBatch(true);

  for ( std::vector<std::string>::const_iterator eventToProcess = eventsToProcess.begin();
	eventToProcess != eventsToProcess.end(); ++eventToProcess ) {
    std::cout << "processing " << (*eventToProcess) << std::endl;
    TObjArray* run_ls_event = TString(eventToProcess->data()).Tokenize(":");
    assert(run_ls_event);
    if ( run_ls_event->GetEntries() != 3 ) {
      std::cerr << "Failed to parse " << (*eventToProcess) << " !!" << std::endl;
      assert(0);
    }

    int run = convertToInt(*run_ls_event, 0);
    int ls = convertToInt(*run_ls_event, 1);
    int event = convertToInt(*run_ls_event, 2);

    std::string inputFileName = Form(
      "%s/nSVfitProducerByIntegration2W%sMaxGenVertex_run%i_ls%i_ev%i_mc.root", 
      inputFilePath.data(), "decayKinePlusMEt", run, ls, event);
    TFile* inputFile = new TFile(inputFileName.data());
    assert(inputFile);

    std::string treeName = "monitorTree";
    TTree* monitorTree = dynamic_cast<TTree*>(inputFile->Get(treeName.data()));
    assert(monitorTree);

    int numEntries = monitorTree->GetEntries();

    TH2* histogramDensity_vs_X1_and_X2           = new TH2D("histogramDensity_vs_X1_and_X2",           "histogramDensity_vs_X1_and_X2",            100, 0., 1., 100, 0., 1.);
    TH2* histogramMass_vs_X1_and_X2              = new TH2D("histogramMass_vs_X1_and_X2",              "histogramMass_vs_X1_and_X2",               100, 0., 1., 100, 0., 1.);

    TH2* histogramDensity_vs_decayDist1_and_phi1 = new TH2D("histogramDensity_vs_decayDist1_and_phi1", "histogramDensity_vs_decayDist1_and_phi1",  200, -0.2, +0.2, 180, -TMath::Pi(), +TMath::Pi());
    TH2* histogramDensity_vs_X1_and_phi1         = new TH2D("histogramDensity_vs_X1_and_phi1",         "histogramDensity_vs_X1_and_phi1",          100,  0.,   1.,  180, -TMath::Pi(), +TMath::Pi());
    TH2* histogramDensity_vs_decayDist2_and_phi2 = new TH2D("histogramDensity_vs_decayDist2_and_phi2", "histogramDensity_vs_decayDist2_and_phi2",  200, -0.2, +0.2, 180, -TMath::Pi(), +TMath::Pi());
    TH2* histogramDensity_vs_X2_and_phi2         = new TH2D("histogramDensity_vs_X2_and_phi2",         "histogramDensity_vs_X2_and_phi2",          100,  0.,   1.,  180, -TMath::Pi(), +TMath::Pi());
        
    TH1* histogramDiTauPtDistribution            = new TH1D("histogramDiTauPtDistribution",            "histogramDiTauPtDistribution",             250, 0., 250.);
    TH1* histogramDiTauEtaDistribution           = new TH1D("histogramDiTauEtaDistribution",           "histogramDiTauEtaDistribution",            198, -9.9, +9.9);
    TH1* histogramDiTauPhiDistribution           = new TH1D("histogramDiTauPhiDistribution",           "histogramDiTauPhiDistribution",            360, -TMath::Pi(), +TMath::Pi());
    TH1* histogramDiTauMassDistribution          = new TH1D("histogramDiTauMassDistribution",          "histogramDiTauMassDistribution",           250, 0., 250.);
    
    TH1* histogramSVfitMass_unweighted                      = bookMassHistogram("histogramSVfitMass_unweighted");
    TH1* histogramSVfitMass_gjAngle_labGt0_00025_unweighted = bookMassHistogram("histogramSVfitMass_gjAngle_labGt0_00025_unweighted");
    TH1* histogramSVfitMass_gjAngle_labLt0_00025_unweighted = bookMassHistogram("histogramSVfitMass_gjAngle_labLt0_00025_unweighted");
    TH1* histogramSVfitMass_weighted                        = bookMassHistogram("histogramSVfitMass_weighted");
    TH1* histogramSVfitMass_gjAngle_labGt0_00025_weighted   = bookMassHistogram("histogramSVfitMass_gjAngle_labGt0_00025_weighted");
    TH1* histogramSVfitMass_gjAngle_labLt0_00025_weighted   = bookMassHistogram("histogramSVfitMass_gjAngle_labLt0_00025_weighted");

    TH1* histogramLeg1PtDistribution             = new TH1D("histogramLeg1PtDistribution",             "histogramLeg1PtDistribution",              250, 0., 250.);
    TH1* histogramLeg1EtaDistribution            = new TH1D("histogramLeg1EtaDistribution",            "histogramLeg1EtaDistribution",             198, -9.9, +9.9);
    TH1* histogramLeg1PhiDistribution            = new TH1D("histogramLeg1PhiDistribution",            "histogramLeg1PhiDistribution",             360, -TMath::Pi(), +TMath::Pi());
    TH1* histogramLeg1dEtaDistribution           = new TH1D("histogramLeg1dEtaDistribution",           "histogramLeg1dPhiDistribution",            400, -0.05, +0.05);
    TH1* histogramLeg1dPhiDistribution           = new TH1D("histogramLeg1dPhiDistribution",           "histogramLeg1dEtaDistribution",            400, -0.05, +0.05);
    TH2* histogramLeg1dPhi_vs_dEtaDistribution   = new TH2D("histogramLeg1dPhi_vs_dEtaDistribution",   "histogramLeg1dPhi_vs_dEtaDistribution",    400, -0.05, +0.05, 400, -0.05, +0.05);

    TH1* histogramLeg2PtDistribution             = new TH1D("histogramLeg2PtDistribution",             "histogramLeg1PtDistribution",              250, 0., 250.);
    TH1* histogramLeg2EtaDistribution            = new TH1D("histogramLeg2EtaDistribution",            "histogramLeg2EtaDistribution",             198, -9.9, +9.9);
    TH1* histogramLeg2PhiDistribution            = new TH1D("histogramLeg2PhiDistribution",            "histogramLeg2PhiDistribution",             360, -TMath::Pi(), +TMath::Pi());
    TH1* histogramLeg2dEtaDistribution           = new TH1D("histogramLeg2dEtaDistribution",           "histogramLeg2dPhiDistribution",            400, -0.05, +0.05);
    TH1* histogramLeg2dPhiDistribution           = new TH1D("histogramLeg2dPhiDistribution",           "histogramLeg2dEtaDistribution",            400, -0.05, +0.05);
    TH2* histogramLeg2dPhi_vs_dEtaDistribution   = new TH2D("histogramLeg2dPhi_vs_dEtaDistribution",   "histogramLeg2dPhi_vs_dEtaDistribution",    400, -0.05, +0.05, 400, -0.05, +0.05);

    TH1* histogramMoveDistribution               = new TH1D("histogramMoveDistribution",               "histogramMoveDistribution",               1000, 0., monitorTree->GetEntries());

    TGraph* graphEvolution_X1                    = new TGraph(numEntries);
    TGraph* graphEvolution_phiLab1               = new TGraph(numEntries);
    TGraph* graphEvolution_decayDist1            = new TGraph(numEntries);
    TGraph* graphEvolution_X2                    = new TGraph(numEntries);
    TGraph* graphEvolution_phiLab2               = new TGraph(numEntries);
    TGraph* graphEvolution_decayDist2            = new TGraph(numEntries);

    Float_t X1, phiLab1, decayDistance1, X2, phiLab2, decayDistance2;
    monitorTree->SetBranchAddress("x0", &X1);
    monitorTree->SetBranchAddress("x1", &phiLab1);
    //monitorTree->SetBranchAddress("x2", &decayDistance1);
    //monitorTree->SetBranchAddress("x3", &X2);
    //monitorTree->SetBranchAddress("x4", &phiLab2);
    //monitorTree->SetBranchAddress("x5", &decayDistance2);
    //monitorTree->SetBranchAddress("x0", &X1);
    //monitorTree->SetBranchAddress("x1", &phiLab1);
    monitorTree->SetBranchAddress("x2", &X2);
    monitorTree->SetBranchAddress("x3", &phiLab2);
    //monitorTree->SetBranchAddress("x1", &X2);
    //monitorTree->SetBranchAddress("x0", &phiLab1);
    //monitorTree->SetBranchAddress("x1", &phiLab2);

    Float_t diTauPt, diTauEta, diTauPhi, diTauMass;
    monitorTree->SetBranchAddress("APt", &diTauPt);
    monitorTree->SetBranchAddress("AEta", &diTauEta);
    monitorTree->SetBranchAddress("APhi", &diTauPhi);
    monitorTree->SetBranchAddress("AMass", &diTauMass);

    Float_t leg1Pt, leg1Eta, leg1Phi, leg1VisPt, leg1VisEta, leg1VisPhi;
    monitorTree->SetBranchAddress("A_leg1Pt", &leg1Pt);
    monitorTree->SetBranchAddress("A_leg1Eta", &leg1Eta);
    monitorTree->SetBranchAddress("A_leg1Phi", &leg1Phi);
    monitorTree->SetBranchAddress("A_leg1VisPt", &leg1VisPt);
    monitorTree->SetBranchAddress("A_leg1VisEta", &leg1VisEta);
    monitorTree->SetBranchAddress("A_leg1VisPhi", &leg1VisPhi);

    Float_t leg2Pt, leg2Eta, leg2Phi, leg2VisPt, leg2VisEta, leg2VisPhi;
    monitorTree->SetBranchAddress("A_leg2Pt", &leg2Pt);
    monitorTree->SetBranchAddress("A_leg2Eta", &leg2Eta);
    monitorTree->SetBranchAddress("A_leg2Phi", &leg2Phi);
    monitorTree->SetBranchAddress("A_leg2VisPt", &leg2VisPt);
    monitorTree->SetBranchAddress("A_leg2VisEta", &leg2VisEta);
    monitorTree->SetBranchAddress("A_leg2VisPhi", &leg2VisPhi);
    
    Int_t move;
    monitorTree->SetBranchAddress("move", &move);

    TF1* pdfWeight_vs_eta_m90 = new TF1("pdfWeight_vs_eta", "[0] + x*([1] + x*([2] + x*([3] + x*([4] + x*([5]  + x*[6])))))", -2., +2.); 
    pdfWeight_vs_eta_m90->SetParameter(0, 0.173744);
    pdfWeight_vs_eta_m90->SetParameter(1, 1.00115e-18);
    pdfWeight_vs_eta_m90->SetParameter(2, -0.0370055);
    pdfWeight_vs_eta_m90->SetParameter(3, 3.40875e-17);
    pdfWeight_vs_eta_m90->SetParameter(4, -0.014232);
    pdfWeight_vs_eta_m90->SetParameter(5, -1.07345e-17);
    pdfWeight_vs_eta_m90->SetParameter(6, 0.00320732);

    for ( int iEntry = 0; iEntry < numEntries; ++iEntry ) {
      monitorTree->GetEntry(iEntry);
      
      if ( (iEntry % 100000) == 0 ) 
      //if ( TMath::Abs(leg1Eta - leg1VisEta) < 0.000250 && TMath::Abs(leg1Phi - leg1VisPhi) < 0.000250 )
	std::cout << "entry #" << iEntry << ":" 
		  << " X1 = " << X1 << ", phiLab1 = " << phiLab1 << ", decayDistance1 = " << decayDistance1 << "," 
		  << " X2 = " << X2 << ", phiLab2 = " << phiLab2 << ", decayDistance2 = " << decayDistance2 << ", Mass = " << diTauMass << std::endl;
      
      //if ( !(leg2Eta > 0.0485 && leg2Eta < 0.0495) ) continue;
      //if ( !(phiLab1 > 1. && phiLab1 < 2.) ) continue;
      //if ( !(phiLab1 > -2. && phiLab1 < -1.) ) continue;

      histogramDensity_vs_X1_and_X2->Fill(X1, X2);
      histogramMass_vs_X1_and_X2->Fill(X1, X2, diTauMass);

      histogramDensity_vs_decayDist1_and_phi1->Fill(decayDistance1, phiLab1);
      histogramDensity_vs_X1_and_phi1->Fill(X1, phiLab1);
      histogramDensity_vs_decayDist2_and_phi2->Fill(decayDistance2, phiLab2);
      histogramDensity_vs_X2_and_phi2->Fill(X2, phiLab2);
    
      histogramDiTauPtDistribution->Fill(diTauPt);
      histogramDiTauEtaDistribution->Fill(diTauEta);
      histogramDiTauPhiDistribution->Fill(diTauPhi);
      histogramDiTauMassDistribution->Fill(diTauMass);

      double gjAngle_lab = TMath::Sqrt(square(leg1Eta - leg1VisEta) + square(leg1Phi - leg1VisPhi));
      double jacobiFactor = 2.*TMath::Pi()*gjAngle_lab;
      //double weight = jacobiFactor;
      //double weight = pdfWeight_vs_eta_m90->Eval(diTauEta);
      double weight = compDeltaFunctionJacobiFactor(X1)*compDeltaFunctionJacobiFactor(X2);
      //double weight = compDeltaFunctionJacobiFactor(X1)*compDeltaFunctionJacobiFactor(X2)*(X1*X2);      
      std::cout << "eta = " << diTauEta << ": weight = " << weight << std::endl;
      histogramSVfitMass_unweighted->Fill(diTauMass);
      histogramSVfitMass_weighted->Fill(diTauMass, weight);
      if ( gjAngle_lab > 0.00025 ) {
	histogramSVfitMass_gjAngle_labGt0_00025_unweighted->Fill(diTauMass);
	histogramSVfitMass_gjAngle_labGt0_00025_weighted->Fill(diTauMass, weight);
      } else {
	histogramSVfitMass_gjAngle_labLt0_00025_unweighted->Fill(diTauMass);
	histogramSVfitMass_gjAngle_labLt0_00025_weighted->Fill(diTauMass, weight);
      }

      histogramLeg1PtDistribution->Fill(leg1Pt);
      histogramLeg1EtaDistribution->Fill(leg1Eta);
      histogramLeg1PhiDistribution->Fill(leg1Phi);
      histogramLeg1dEtaDistribution->Fill(leg1Eta - leg1VisEta);
      histogramLeg1dPhiDistribution->Fill(leg1Phi - leg1VisPhi);
      histogramLeg1dPhi_vs_dEtaDistribution->Fill(leg1Eta - leg1VisEta, leg1Phi - leg1VisPhi);
      //std::cout << "leg1Eta = " << leg1Eta << ", leg1VisEta = " << leg1VisEta << " --> dEta = " << (leg1Eta - leg1VisEta) << ";"
      //	  << " leg1Phi = " << leg1Phi << ", leg1VisPhi = " << leg1VisPhi << " --> dPhi = " << (leg1Phi - leg1VisPhi) << std::endl;

      histogramLeg2PtDistribution->Fill(leg2Pt);
      histogramLeg2EtaDistribution->Fill(leg2Eta);
      histogramLeg2PhiDistribution->Fill(leg2Phi);
      histogramLeg2dEtaDistribution->Fill(leg2Eta - leg2VisEta);
      histogramLeg2dPhiDistribution->Fill(leg2Phi - leg2VisPhi);
      histogramLeg2dPhi_vs_dEtaDistribution->Fill(leg2Eta - leg2VisEta, leg2Phi - leg2VisPhi);
      //std::cout << "leg2Eta = " << leg2Eta << ", leg2VisEta = " << leg2VisEta << " --> dEta = " << (leg2Eta - leg2VisEta) << ";"
      //	  << " leg2Phi = " << leg2Phi << ", leg2VisPhi = " << leg2VisPhi << " --> dPhi = " << (leg2Phi - leg2VisPhi) << std::endl;

      histogramMoveDistribution->Fill(move);

      graphEvolution_X1->SetPoint(iEntry, move, X1);
      graphEvolution_phiLab1->SetPoint(iEntry, move, phiLab1);
      graphEvolution_decayDist1->SetPoint(iEntry, move, decayDistance1);
      graphEvolution_X2->SetPoint(iEntry, move, X2);
      graphEvolution_phiLab2->SetPoint(iEntry, move, phiLab2);
      graphEvolution_decayDist2->SetPoint(iEntry, move, decayDistance2);
    }
    
    histogramMass_vs_X1_and_X2->Divide(histogramDensity_vs_X1_and_X2);
    
    Float_t genX1, genX2;
    Float_t genDiTauPt, genDiTauEta, genDiTauPhi, genDiTauMass;
    //getGen(genNtupleFileName, run, ls, event, genX1, genX2, genDiTauPt, genDiTauEta, genDiTauPhi, genDiTauMass);
/*
    showHistogram2d(
      histogramDensity_vs_X1_and_X2, "X_{1}", "X_{2}", kNormByNegLogMax, 0.,   2., &genX1, &genX2, 
      Form("plots/plotMarkovChainMonitorTree_density_vs_X1andX2_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram2d(
      histogramMass_vs_X1_and_X2, "X_{1}", "X_{2}", kNormByValue, 0., 250., 0, 0, 
      Form("plots/plotMarkovChainMonitorTree_mass_vs_X1andX2_run%i_ls%i_ev%i.root", run, ls, event));

    showHistogram2d(
      histogramDensity_vs_decayDist1_and_phi1, "D^{decay}_{1}", "#phi^{lab}_{1}", kNormByNegLogMax, 0., 2., 0, 0, 
      Form("plots/plotMarkovChainMonitorTree_density_vs_decayDist1andPhi1_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram2d(
      histogramDensity_vs_X1_and_phi1, "X_{1}", "#phi^{lab}_{1}", kNormByNegLogMax, 0., 2., 0, 0, 
      Form("plots/plotMarkovChainMonitorTree_density_vs_X1andPhi1_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram2d(
      histogramDensity_vs_decayDist2_and_phi2, "D^{decay}_{2}", "#phi^{lab}_{2}", kNormByNegLogMax, 0., 2., 0, 0, 
      Form("plots/plotMarkovChainMonitorTree_density_vs_decayDist2andPhi2_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram2d(
      histogramDensity_vs_X2_and_phi2, "X_{2}", "#phi^{lab}_{2}", kNormByNegLogMax, 0., 2., 0, 0, 
      Form("plots/plotMarkovChainMonitorTree_density_vs_X2andPhi2_run%i_ls%i_ev%i.root", run, ls, event));
    
    showHistogram1d(
      histogramDiTauPtDistribution, "P_{T}^{#tau#tau}", &genDiTauPt, 
      Form("plots/plotMarkovChainMonitorTree_diTauPtDistribution_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramDiTauEtaDistribution, "#eta_{#tau#tau}", &genDiTauEta, 
      Form("plots/plotMarkovChainMonitorTree_diTauEtaDistribution_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramDiTauPhiDistribution, "#phi_{#tau#tau}", &genDiTauPhi, 
      Form("plots/plotMarkovChainMonitorTree_diTauPhiDistribution_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramDiTauMassDistribution, "M_{#tau#tau}", &genDiTauMass, 
      Form("plots/plotMarkovChainMonitorTree_diTauMassDistribution_run%i_ls%i_ev%i.root", run, ls, event));
 */
    divideByBinWidth(histogramSVfitMass_unweighted);
    std::cout << "SVfit mass (unweighted):" << std::endl;
    printMaximum(histogramSVfitMass_unweighted);
    showHistogram1d(
      histogramSVfitMass_unweighted, "M_{#tau#tau}", &genDiTauMass, 
      Form("plots/plotMarkovChainMonitorTree_svFitMass_unweighted_run%i_ls%i_ev%i.root", run, ls, event));
    divideByBinWidth(histogramSVfitMass_gjAngle_labGt0_00025_unweighted);
    showHistogram1d(
      histogramSVfitMass_gjAngle_labGt0_00025_unweighted, "M_{#tau#tau}", &genDiTauMass, 
      Form("plots/plotMarkovChainMonitorTree_svFitMass_gjAngle_labGt0_00025_unweighted_run%i_ls%i_ev%i.root", run, ls, event));
    divideByBinWidth(histogramSVfitMass_gjAngle_labLt0_00025_unweighted);    
    showHistogram1d(
      histogramSVfitMass_gjAngle_labLt0_00025_unweighted, "M_{#tau#tau}", &genDiTauMass, 
      Form("plots/plotMarkovChainMonitorTree_svFitMass_gjAngle_labLt0_00025_unweighted_run%i_ls%i_ev%i.root", run, ls, event));
    divideByBinWidth(histogramSVfitMass_weighted);
    std::cout << "SVfit mass (weighted by Jacobi factor):" << std::endl;
    printMaximum(histogramSVfitMass_weighted);
    showHistogram1d(
      histogramSVfitMass_weighted, "M_{#tau#tau}", &genDiTauMass, 
      Form("plots/plotMarkovChainMonitorTree_svFitMass_weighted_run%i_ls%i_ev%i.root", run, ls, event));
    divideByBinWidth(histogramSVfitMass_gjAngle_labGt0_00025_weighted);
    showHistogram1d(
      histogramSVfitMass_gjAngle_labGt0_00025_weighted, "M_{#tau#tau}", &genDiTauMass, 
      Form("plots/plotMarkovChainMonitorTree_svFitMass_gjAngle_labGt0_00025_weighted_run%i_ls%i_ev%i.root", run, ls, event));
    divideByBinWidth(histogramSVfitMass_gjAngle_labLt0_00025_weighted);    
    showHistogram1d(
      histogramSVfitMass_gjAngle_labLt0_00025_weighted, "M_{#tau#tau}", &genDiTauMass, 
      Form("plots/plotMarkovChainMonitorTree_svFitMass_gjAngle_labLt0_00025_weighted_run%i_ls%i_ev%i.root", run, ls, event));
/*
    showHistogram1d(
      histogramLeg1PtDistribution, "P_{T}^{1}", 0, 
      Form("plots/plotMarkovChainMonitorTree_leg1PtDistribution_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramLeg1EtaDistribution, "#eta_{1}", 0, 
      Form("plots/plotMarkovChainMonitorTree_leg1EtaDistribution_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramLeg1PhiDistribution, "#phi_{1}", 0, 
      Form("plots/plotMarkovChainMonitorTree_leg1PhiDistribution_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramLeg1dEtaDistribution, "#eta_{1} - #eta_{vis}", 0, 
      Form("plots/plotMarkovChainMonitorTree_leg1dEta_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramLeg1dPhiDistribution, "#phi_{1} - #phi_{vis}", 0, 
      Form("plots/plotMarkovChainMonitorTree_leg1dPhi_run%i_ls%i_ev%i.root", run, ls, event));
 */
    showHistogram2d(
      histogramLeg1dPhi_vs_dEtaDistribution, "#eta_{1} - #eta_{vis}", "#phi_{1} - #phi_{vis}", kNormByNegLogMax, 0., 2., 0, 0, 
      Form("plots/plotMarkovChainMonitorTree_leg1dPhi_vs_dEta_run%i_ls%i_ev%i.root", run, ls, event));
/*
    showHistogram1d(
      histogramLeg2PtDistribution, "P_{T}^{2}", 0, 
      Form("plots/plotMarkovChainMonitorTree_leg2PtDistribution_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramLeg2EtaDistribution, "#eta_{2}", 0, 
      Form("plots/plotMarkovChainMonitorTree_leg2EtaDistribution_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramLeg2PhiDistribution, "#phi_{2}", 0, 
      Form("plots/plotMarkovChainMonitorTree_leg2PhiDistribution_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramLeg2dEtaDistribution, "#eta_{2} - #eta_{vis}", 0, 
      Form("plots/plotMarkovChainMonitorTree_leg2dEta_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram1d(
      histogramLeg2dPhiDistribution, "#phi_{2} - #phi_{vis}", 0, 
      Form("plots/plotMarkovChainMonitorTree_leg2dPhi_run%i_ls%i_ev%i.root", run, ls, event));
    showHistogram2d(
      histogramLeg2dPhi_vs_dEtaDistribution, "#eta_{2} - #eta_{vis}", "#phi_{2} - #phi_{vis}", kNormByNegLogMax, 0., 2., 0, 0, 
      Form("plots/plotMarkovChainMonitorTree_leg2dPhi_vs_dEta_run%i_ls%i_ev%i.root", run, ls, event));

    showHistogram1d(
      histogramMoveDistribution, "Move", 0, 
      Form("plots/plotMarkovChainMonitorTree_moveDistribution_run%i_ls%i_ev%i.root", run, ls, event));
 */
/*    
    showGraph(
      graphEvolution_X1, "Move", &genX1, 0., 1., "X_{1}", 
      Form("plots/plotMarkovChainMonitorTree_evolution_X1_run%i_ls%i_ev%i.root", run, ls, event));
    showGraph(
      graphEvolution_phiLab1, "Move", 0, -TMath::Pi(), +TMath::Pi(), "#phi^{lab}_{1}", 
      Form("plots/plotMarkovChainMonitorTree_evolution_phiLab1_run%i_ls%i_ev%i.root", run, ls, event));
    showGraph(
      graphEvolution_decayDist1, "Move", 0, -1., +1., "D^{decay}_{1}",
      Form("plots/plotMarkovChainMonitorTree_evolution_decayDist1_run%i_ls%i_ev%i.root", run, ls, event));
    showGraph(
      graphEvolution_X2, "Move", &genX2, 0., 1., "X_{2}",   
      Form("plots/plotMarkovChainMonitorTree_evolution_X2_run%i_ls%i_ev%i.root", run, ls, event));
    showGraph(
      graphEvolution_phiLab2, "Move", 0, -TMath::Pi(), +TMath::Pi(), "#phi^{lab}_{2}",   
      Form("plots/plotMarkovChainMonitorTree_evolution_phiLab2_run%i_ls%i_ev%i.root", run, ls, event));
    showGraph(
      graphEvolution_decayDist2, "Move", 0, -1., +1., "D^{decay}_{2}", 
      Form("plots/plotMarkovChainMonitorTree_evolution_decayDist2_run%i_ls%i_ev%i.root", run, ls, event));
 */
    delete histogramDensity_vs_X1_and_X2;
    delete histogramMass_vs_X1_and_X2;

    delete histogramDensity_vs_decayDist1_and_phi1;
    delete histogramDensity_vs_X1_and_phi1;
    delete histogramDensity_vs_decayDist2_and_phi2;
    delete histogramDensity_vs_X2_and_phi2;

    delete histogramDiTauPtDistribution;
    delete histogramDiTauEtaDistribution;
    delete histogramDiTauPhiDistribution;
    delete histogramDiTauMassDistribution;

    delete histogramSVfitMass_unweighted;
    delete histogramSVfitMass_gjAngle_labGt0_00025_unweighted;
    delete histogramSVfitMass_gjAngle_labLt0_00025_unweighted;
    delete histogramSVfitMass_weighted;
    delete histogramSVfitMass_gjAngle_labGt0_00025_weighted;
    delete histogramSVfitMass_gjAngle_labLt0_00025_weighted;

    delete histogramLeg1PtDistribution;
    delete histogramLeg1EtaDistribution;
    delete histogramLeg1PhiDistribution;
    delete histogramLeg1dPhi_vs_dEtaDistribution;

    delete histogramLeg2PtDistribution;
    delete histogramLeg2EtaDistribution;
    delete histogramLeg2PhiDistribution;
    delete histogramLeg2dPhi_vs_dEtaDistribution;

    delete histogramMoveDistribution;

    delete graphEvolution_X1;
    delete graphEvolution_phiLab1;
    delete graphEvolution_decayDist1;
    delete graphEvolution_X2;
    delete graphEvolution_phiLab2;
    delete graphEvolution_decayDist2;

    delete inputFile;
  }
}