File indexing completed on 2025-10-31 08:17:24
0001 
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 #include "TFile.h"
0010 #include "TH1F.h"
0011 #include "TROOT.h"
0012 #include "TTree.h"
0013 
0014 
0015 
0016 
0017 
0018 void
0019 compareDistributions(std::string inFile1,
0020                      std::string hist1Name,
0021                      int         col1,
0022                      std::string inFile2,
0023                      std::string hist2Name,
0024                      int         col2)
0025 {
0026   std::cout << "Opening file: " << inFile1 << std::endl;
0027   TFile inputFile1(inFile1.c_str());
0028   std::cout << "Opening file: " << inFile2 << std::endl;
0029   TFile inputFile2(inFile2.c_str());
0030   std::cout << "Comparing Histograms: " << hist1Name << " & " << hist2Name
0031             << std::endl;
0032 
0033   TH1F* h1 = (TH1F*)inputFile1.Get(hist1Name.c_str());
0034   TH1F* h2 = (TH1F*)inputFile2.Get(hist2Name.c_str());
0035 
0036   h1->SetLineColor(col1);
0037   h1->DrawNormalized();
0038   h2->SetLineColor(col2);
0039   h2->DrawNormalized("same");
0040 
0041   TLegend* leg = new TLegend(0.72, 0.71, 0.99, 0.95);
0042   leg->AddEntry(h1, hist1Name.c_str());
0043   leg->AddEntry(h2, hist2Name.c_str());
0044   leg->Draw();
0045 
0046   h1->SetDirectory(0);
0047   h2->SetDirectory(0);
0048 
0049   inputFile1.Close();
0050   inputFile2.Close();
0051 }