#include "RooDataHist.h" #include "TH3F.h" #include "RooRealVar.h" #include "RooWorkspace.h" #include "TFile.h" #include int main(int argc, char **argv){ TH3F* histo = new TH3F("test","test",277,0,100,277,0,100,160,0,100); for(int i=1;i<278;i++){ for(int j=1;j<278;j++){ for(int k=k;k<161;k++){ histo->SetBinContent(i,j,k,i+j+k); } } } RooRealVar x("x","x",0,0,100); RooRealVar y("y","y",0,0,100); RooRealVar z("z","s",0,0,100); RooArgSet args(x,y,z); RooDataHist* testdatahist = new RooDataHist("t","t",args,histo); RooDataHist* t2=(RooDataHist*)testdatahist->Clone("t2"); TFile* file = TFile::Open("test.root","RECREATE"); testdatahist->Write(); t2->Write(); file->Close(); RooWorkspace ws("ws"); ws.import(*testdatahist); std::cout << "Writing workspace with one histogram" << std::endl; ws.writeToFile("test1.root"); ws.import(*t2); std::cout << "Writing workspace with two histograms" << std::endl; ws.writeToFile("test2.root"); }