Script to create histograms


I need to create a script that creates several histograms from several simulation data files. I read the parts of the user manual that I thought it would matter and based on that and my little experience in C++ I wrote this script. But when I try to execute it, I get this error:

[quote]root [0] .x create_histograms.cpp
Error in TFile::TFile: file histograms.root does not exist
Error: Function create_histograms() is not defined in current scope :0:
*** Interpreter error recovered ***
root [1][/quote]

I don’t know what’s causing this and even after rechecking the documentation, I see no solution. I don’t need that you tell me all the way through because I also want to know where I made the mistakes, so I don’t do them again. So what I ask is if you could just see the script and tell me where can I look information for the mistakes I’m doing, i.e., what section of the manual to look. Thank you in advance.

char name[20], title[20], file_name[30];
ifstream read;
string line;
Float_t x, y, rms, file=8.0;
Int_t i;
TProfile *h;
TObjArray Hlist(0);

//open data files
for(i=0; i<=6; i++, file+=0.5){

//put stream pointer in the 6th line
for(n=1; n<=5; n++){

//get and write data lines
  //read data from file
  sscanf(line,"%f %f %f", &x, &y, &rms);

  //write name and title of histogram
  sprintf(name,"%.1f", file);
  sprintf(title,"%.1f MeV", file);

  //create histogram
  h = new TProfile(name,title,60,5000000,11000000);

//close the data files


//open a root file and write the array to the file
TFile f(“histograms.root”,“Bremsstrahlung”);



TFile f("histograms.root","Bremsstrahlung"); Hlist->Write(); f.Close(); by

TFile f("histograms.root","recreate","Bremsstrahlung"); Hlist->Write();