EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
compareHitHistograms.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file compareHitHistograms.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 /*
10  * compareHitHistograms.C
11  *
12  * Created on: 15 Dec 2016
13  * Author: jhrdinka
14  */
15 
16 #include <tuple>
17 #include "TFile.h"
18 #include "TH1F.h"
19 #include "TROOT.h"
20 #include "TTree.h"
21 
22 // This root script draws all histograms given in a vector into the same Canvas.
23 // The information should be handed over as a vector of a tuple.
24 // The first entry should be the Name of the file, where the histogram can be
25 // found. The second entry should be the name of the histogram. The third entry
26 // is the color in which the histogram should be printed.
27 
28 void
30  std::vector<std::tuple<std::string, std::string, int>> hist)
31 {
32  for (auto& i : hist) {
33  std::cout << "Opening file: " << std::get<0>(i).c_str() << std::endl;
34  TFile inputFile(std::get<0>(i).c_str());
35  TDirectory dir = outputFile.mkdir(layerName.c_str());
36  dir->cd();
37 
38  std::cout << "Comparing Histogram: " << std::get<1>(i).c_str() << std::endl;
39 
40  TH2F* h = (TH2F*)inputFile.Get(std::get<1>(i).c_str());
41  h->SetMarkerColor(std::get<2>(i));
42  h->Draw("same");
43  h->SetDirectory(0);
44 
45  inputFile.Close();
46  }
47 }