I often use TGraph and TGraphErrors to make plots from text files with columns of data. Example below:
////////////////////////////////////
TGraphErrors *ProfNch09ATLAS = new TGraphErrors("Data/Profile_Nch_pT_09TeV_Data_ATLAS.dat", "%lg %lg %lg");
/////////////////////////////////
Which reads from the .dat file that has 3 columns of data. the x-value, the y-value, and the error in y-valye. If you need to add a 4th columns, the error in the x-value or the bin size, you can add it to be the 3rd column in your text file and the next file can be read using:
/////////////////////////////////
TGraphErrors("Data/Profile_Nch_pT_09TeV_Data_ATLAS.dat", "%lg %lg %lg %lg");
////////////////////////////////
but what id you had another plot that needs the original file? that is plotting on the the first two columns alongside the fourth. This time you can use the option *
///////////////////////////////
TGraphErrors("Data/Profile_Nch_pT_09TeV_Data_ATLAS.dat", "%lg %lg %*lg %lg");
///////////////////////////////
For files with a dilemeter different than '/t' and ' ' the 'option' argument need to be used. see http://root.cern.ch/root/html/TGraph.html
No comments:
Post a Comment