void write_to_file(){ // Instance of our histogram TH1F h("my_histogram","My Title;X;# of entries",100,-5,5); // Let's fill it randomly h.FillRandom("gaus"); // Let's open a TFile TFile out_file("my_rootfile.root","RECREATE"); // Write the histogram in the file h.Write(); // Close the file out_file.Close(); }