Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
compareDistributions.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file compareDistributions.C
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include "TFile.h"
10 #include "TH1F.h"
11 #include "TROOT.h"
12 #include "TTree.h"
13 
17 
18 void
20  std::string hist1Name,
21  int col1,
22  std::string inFile2,
23  std::string hist2Name,
24  int col2)
25 {
26  std::cout << "Opening file: " << inFile1 << std::endl;
27  TFile inputFile1(inFile1.c_str());
28  std::cout << "Opening file: " << inFile2 << std::endl;
29  TFile inputFile2(inFile2.c_str());
30  std::cout << "Comparing Histograms: " << hist1Name << " & " << hist2Name
31  << std::endl;
32 
33  TH1F* h1 = (TH1F*)inputFile1.Get(hist1Name.c_str());
34  TH1F* h2 = (TH1F*)inputFile2.Get(hist2Name.c_str());
35 
36  h1->SetLineColor(col1);
37  h1->DrawNormalized();
38  h2->SetLineColor(col2);
39  h2->DrawNormalized("same");
40 
41  TLegend* leg = new TLegend(0.72, 0.71, 0.99, 0.95);
42  leg->AddEntry(h1, hist1Name.c_str());
43  leg->AddEntry(h2, hist2Name.c_str());
44  leg->Draw();
45 
46  h1->SetDirectory(0);
47  h2->SetDirectory(0);
48 
49  inputFile1.Close();
50  inputFile2.Close();
51 }