TString name=out; //out is a name of your output .root file TFile *newfile = new TFile(name.Data(),"recreate"); //actually creating it h_pos1[j]->Write(); //write your histograms like this newfile->Close(); //close fileReading:
TString fname=in; //in is your .root file that you want to open if(gSystem->Which("",fname2)){ //check if it exists (read note about it above) TFile f(fname);// actually opening it TH1F* time=(TH1F*)f.Get("time"); //get your histos like this. Don't forget to close your file afterwards!Merging histograms