#include #include #include #include #include #include #include #include #include #include "TLeaf.h" #include "TROOT.h" #include "TFile.h" #include "TTree.h" #include "TChain.h" #include "TNtuple.h" #include "TBranch.h" #include "TFileCollection.h" #include "TGraphErrors.h" using namespace std; using namespace TMath; void test() { // Creating a new root file to save new histograms TFile *histofile = new TFile("NewFile.root","RECREATE"); // calling existed files TFile *bkg=new TFile("background.root","READ"); TFile *single_top=new TFile("single_top.root","READ"); // finding the considered histograms in the files TH1 *bkg_lep_PostvdDeltaEta =(TH1*) bkg->Get("lep_PostvdDeltaEta"); TH1 *singleT_lep_PostvdDeltaEta = (TH1*)single_top->Get("lep_PostvdDeltaEta"); bkg_lep_PostvdDeltaEta->SetDirectory(histofile); bkg_lep_PostvdDeltaEta->Add(singleT_lep_PostvdDeltaEta, -1); histofile->Write(); histofile->Close(); }