#include "TCanvas.h" #include "TROOT.h" #include #include #include #include "TFile.h" #include "TLegend.h" void mwe(){ TFile *ttbar = TFile::Open("ttbar_out.root"); //in this file are those histograms that I want to take out and use TH1D *ttbar1_pt = (TH1D*)ttbar->Get("h_muon1_pt"); TH1D *ttbar1_eta = (TH1D*)ttbar->Get("h_muon1_eta"); TH1D *ttbar1_phi = (TH1D*)ttbar->Get("h_muon1_phi"); std::vector names {"ttbar1_pt", "ttbar1_eta", "ttbar1_phi"}; std::vector histos; //pointer to histograms for (const auto& name: names){ histo.push_back(static_cast(name)) }; for (auto histo:histos){ histo->SetFillStyle(1001); }; //such piece of code would be here multiple times, for top + W, for dibosons, etc. TCanvas *Canvas1_pt = new TCanvas("Canvas1_pt", "muon1 pt", 1000, 800); ttbar1_pt->Draw("same hist"); //I chose one of them }