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
Showing posts with label ROOT. Show all posts
Showing posts with label ROOT. Show all posts
Sunday, May 27, 2012
Wednesday, February 1, 2012
ROOT to perform a shell command in a macro
You can make a ROOT macro execute another root macro or a shell command using the following line:
gROOT->ProcessLine("!shell_command");
or
gROOT->ProcessLine("ThisRootMacro()");
Don't forget that the macro needs to be uploaded first:
gROOT->LoadMaco(ThisRootMacro.C);
gROOT->ProcessLine("!shell_command");
or
gROOT->ProcessLine("ThisRootMacro()");
Don't forget that the macro needs to be uploaded first:
gROOT->LoadMaco(ThisRootMacro.C);
Thursday, December 2, 2010
Updating ROOT on your machine.
I was running ROOT 5.18 on my laptop and it has the interesting issue of saving the plots 90 degrees rotated. I never bothered myself with this until someone brought the issue on CMS's hypernews. The solutions she got were:
1- You can change the size of the canvas to be rectangle
TCanvas *c = new TCanvas("c","",800,850); Quite easy but we need to remember that the TDR style for CMS papers is 600 by 600.
2- It turned out that this issue is solved in the new releases (after 5.22).
So the challenge was to try to update my old ROOT release. These days they have clear instructions about installing ROOT. The problem is that this is not a full package and installing without care will create a mess! so doing the instructions you can use that release in the current shell. but not if you opened a new one.
I wanted something more "default". So here is the trick:
in 'root' edit file names: .bashrc
and at the bottom i added:
. $HOME/Desktop/Research/ROOT522/root/bin/thisroot.sh
which is the place where the new installation is.
1- You can change the size of the canvas to be rectangle
TCanvas *c = new TCanvas("c","",800,850); Quite easy but we need to remember that the TDR style for CMS papers is 600 by 600.
2- It turned out that this issue is solved in the new releases (after 5.22).
So the challenge was to try to update my old ROOT release. These days they have clear instructions about installing ROOT. The problem is that this is not a full package and installing without care will create a mess! so doing the instructions you can use that release in the current shell. but not if you opened a new one.
I wanted something more "default". So here is the trick:
in 'root' edit file names: .bashrc
and at the bottom i added:
. $HOME/Desktop/Research/ROOT522/root/bin/thisroot.sh
which is the place where the new installation is.
Subscribe to:
Posts (Atom)