I know that my question is too beginner . Anyhow I have to work with Geant4 and I need to get a histogram.
I am a newbie to both LInux and c++
I am running ubuntu 10.10 , I have installed root successfully .
I don’t know to write a histogramming code from where I have to start. I have had a look at documentations but didn’t find any sample code. I will really appreciate if any one can give me a good hint.
Many thanks in advance
Well… first of all you can try creating a simple histogram at the command line!
Type root in a bash shell (= Terminal), then write these simple lines of code:
root TH1D *myFirstHisto = new TH1D("myFirstHisto","My first histogram in ROOT!", 100,-5,5) root for(int i = 0; i < 100000; i++)myFirstHisto->Fill( gRandom->Gaus(0,1) ) root myFirstHisto->Draw() root myFirstHisto->Fit("gaus")
I think this is the best way to enjoy ROOT (so was for me)! Ah, press ENTER after each line!
Another hint: start reading the ROOT tutorials! (in the $ROOTSYS/tutorials folder or via web
at http://root.cern.ch/root/html/tutorials/ )… in the hist directory there are many script examples.
Thank you for your response. Actually I have to learn working with Geant4. I have installed both AIDA and root for analysis.
they have their own histogramming code, I ran those codes but the output is a .root file.
I don’t know if I can open this file in root!
I have trasfered my output file with the name AnaEx01.root to the /root7macros and then I opened root and ,tried to load and open this file but I got:
Bad source file(binary) ~/root/macros/AnaEx01.root interpreter error recovered
Thanks again in advance
Sorry, I thought you were a ROOT beginner! Anyway… in general if you have a .root file you should be able to open it via TBrowser, i.e. open ROOT in your working directory, type at the command line
and browse your .root file if possible.
On the other hand if it’s a binary file maybe it contains histogram data as a binary sequence. In this case you can convert it in a ASCII .dat file of floats or doubles with a standard C or C++ program.
Really thanks for your nice help