TString path = "/nfs/fanae/user/palencia/april14Run2/TOP/TopTrees/jun23_nobtagSFnewCut/"; TH1F* GetSample(TString); TH1F* GetHisto1D(TFile*,TString); void run(){ TH1F* h = 0; // TTbar h = GetSample("TTbar_Powheg"); cout << "TTbar "<< h -> GetBinContent(6) * 1000 << " " << h -> GetBinContent(7) * 1000 << endl; // Single top h = GetSample("TW"); h -> Add(GetSample("TbarW")); cout << "Singletop "<< h -> GetBinContent(6) * 1000 << " " << h -> GetBinContent(7) * 1000 << endl; // WJets h = GetSample("WJets_aMCatNLO"); cout << "WJets "<< h -> GetBinContent(6) * 1000 << " " << h -> GetBinContent(7) * 1000 << endl; // ZJets h = GetSample("ZJets_aMCatNLO"); cout << "ZJets "<< h -> GetBinContent(6) * 1000 << " " << h -> GetBinContent(7) * 1000 << endl; // Diboson h = GetSample("WZ"); h -> Add(GetSample("ZZ")); h -> Add(GetSample("WW")); cout << "Diboson " << h -> GetBinContent(6) * 1000 << " " << h -> GetBinContent(7) * 1000 << endl; // TTbar semilept h = GetSample("TTbarSemiLep_Powheg"); cout << "TTbar semilept " << h -> GetBinContent(6) * 1000 << " " << h -> GetBinContent(7) * 1000 << endl; return; } TH1F* GetSample(TString samplename) { TFile* _file0 = TFile::Open(path + "/Tree_13TeV_EA_" + samplename + ".root"); TH1F* h = GetHisto1D(_file0,"H_Yields_ElMu"); _file0 -> Close(); return h; } TH1F* GetHisto1D(TFile *file, TString histoname) { if (!file) { std::cerr << "ERROR: Could not load file" << std::endl; return 0; } TH1F* h = (TH1F*) file->Get(histoname)->Clone(histoname); if (!h) { std::cerr << "ERROR[TopSelector]: Could not find histogram " << histoname << std::endl; return 0; } h->SetDirectory(0); return h; };