Hi!
I have a output file from a simulation with error values. This file has the x bins, the y value and RMS, resulting from the simulation. I created a script to convert this file to a TProfile because on the root manual said “Profile histograms are used to display the mean value of Y and its RMS for each bin in X. Profile histograms are in many cases an elegant replacement of two-dimensional histograms.”. But I don’t see the option on the TProfile to insert the error values from a file, only saw the weights. How can I put those error values in the TProfile?
This is one of the files:
[quote] # Results from PENCYL.
Energy distribution of transmitted photons.
1st column: E (eV).
2nd and 3rd columns: probability density and STU (1/(eV*particle)).
5.050000E+06 5.799000E-10 2.284469E-11
5.150000E+06 5.535000E-10 2.231866E-11
5.250000E+06 5.353000E-10 2.194867E-11
5.350000E+06 5.155000E-10 2.153894E-11
5.450000E+06 4.977000E-10 2.116383E-11
5.550000E+06 4.868000E-10 2.093081E-11
5.650000E+06 4.766000E-10 2.071037E-11
5.750000E+06 4.595000E-10 2.033546E-11
5.850000E+06 4.336000E-10 1.975406E-11
5.950000E+06 4.270000E-10 1.960315E-11
6.050000E+06 4.061000E-10 1.911740E-11
6.150000E+06 4.024000E-10 1.903012E-11
6.250000E+06 4.073000E-10 1.914563E-11
6.350000E+06 3.833000E-10 1.857301E-11
6.450000E+06 3.790000E-10 1.846854E-11
6.550000E+06 3.510000E-10 1.777326E-11
6.650000E+06 3.360000E-10 1.738936E-11
6.750000E+06 3.437000E-10 1.758748E-11
6.850000E+06 3.205000E-10 1.698354E-11
6.950000E+06 3.181000E-10 1.691984E-11
7.050000E+06 2.960000E-10 1.632152E-11
7.150000E+06 2.897000E-10 1.614690E-11
7.250000E+06 2.899000E-10 1.615247E-11
7.350000E+06 2.818000E-10 1.592523E-11
7.450000E+06 2.703000E-10 1.559690E-11
7.550000E+06 2.730000E-10 1.567461E-11
7.650000E+06 2.512000E-10 1.503577E-11
7.750000E+06 2.388000E-10 1.465998E-11
7.850000E+06 2.341000E-10 1.451499E-11
7.950000E+06 2.403000E-10 1.470594E-11
8.050000E+06 2.308000E-10 1.441233E-11
8.150000E+06 2.307000E-10 1.440921E-11
8.250000E+06 2.156000E-10 1.392967E-11
8.350000E+06 2.002000E-10 1.342298E-11
8.450000E+06 1.940000E-10 1.321350E-11
8.550000E+06 1.910000E-10 1.311094E-11
8.650000E+06 1.794000E-10 1.270658E-11
8.750000E+06 1.728000E-10 1.247066E-11
8.850000E+06 1.714000E-10 1.242004E-11
8.950000E+06 1.608000E-10 1.202987E-11
9.050000E+06 1.593000E-10 1.197363E-11
9.150000E+06 1.491000E-10 1.158395E-11
9.250000E+06 1.425000E-10 1.132467E-11
9.350000E+06 1.356000E-10 1.104710E-11
9.450000E+06 1.320000E-10 1.089947E-11
9.550000E+06 1.317000E-10 1.088708E-11
9.650000E+06 1.223000E-10 1.049136E-11
9.750000E+06 1.153000E-10 1.018670E-11
9.850000E+06 1.080000E-10 9.858953E-12
9.950000E+06 9.980000E-11 9.477294E-12
1.005000E+07 9.580000E-11 9.285428E-12
1.015000E+07 8.130000E-11 8.553912E-12
1.025000E+07 7.660000E-11 8.302980E-12
1.035000E+07 6.690000E-11 7.759484E-12
1.045000E+07 5.980000E-11 7.336190E-12
1.055000E+07 5.370000E-11 6.951959E-12
1.065000E+07 4.380000E-11 6.278521E-12
1.075000E+07 3.960000E-11 5.969913E-12
1.085000E+07 2.770000E-11 4.992988E-12
1.095000E+07 1.370000E-11 3.511408E-12[/quote]
And this is the script that I wrote:
[code]//This program must be inside the folder with the all the energy’s folders
{
char name[20], title[20], file_name[30];
ifstream read;
string line;
float x, y, rms, file=8.0;
int 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);
//Check if data file is open and reports
if(read.is_open())
cout << "File ./" << file_name << " is open.\n";
else
cout << "Error opening " << file_name << ".\n";
//put stream pointer in the 6th line
for(n=1; n<=5; n++){
getline (read,line);
cout << "Stream pointer currently in line " << n << ".\n";
cout << "Confirmation: " << line << "\n";
}
//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);
//get and write data lines
while( std::getline (read,line)){
//read data from file
istringstream(line,ios_base::in) >> x >> y >> rms;
printf("Confirmation of data reading: x=%.2E; y=%.2E; rms=%.2E\n", x, y, rms);
//Fill histogram with data from a line
h->Fill(x,y);
line.clear();
}
//close the data files
read.close();
}
TFile f(“histograms.root”,“RECREATE”,“Bremsstrahlung”);
Hlist.Write();
}
[/code]