1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
{
char name[20], title[20], file_name[30];
ifstream read;
string line;
Float_t x, y, rms, file=8.0;
Int_t i, n;
TProfile *h;
TObjArray Hlist(0);
//open data files
for(i=0; i<=6; i++, file+=0.5){
sprintf(file_name,"%.1fmev/energy-ph-trans.dat",file);
read.open(file_name);
//put stream pointer in the 6th line
for(n=1; n<=8; n++){
getline(read,line);
}
//get and write data lines
while(!read.eof()){
//read data from file
line.clear();
getline(read,line);
sscanf(line," %.1f %.1f %.1f ", &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);
Hlist.Add(h);
h->Fill(x,y,rms);
}
//close the data files
read.close();
}
TFile f("histograms.root","Bremsstrahlung","RECREATE");
Hlist->Write();
}
|