I am an undergraduate student trying to display histograms by opening a root file in which an analysis object is stored. This object contains the chains and their associated histograms. In ROOT I do:
root  TFile f("/afs/desy.de/user/l/lbdwyer/h1/oo/H1AnalysisExample/Analysis$
root  f->ls()
KEY: H1AnalysisExample AnalysisExample;1 H1Analysis
In my class I use:
to get my analysis object, H1Analysis, and a “c out” statement confirms that I have it, how can I now access the chains and their histograms?
Thank you for your help,
In newer version of ROOT you can simply do:
in older version of ROOT, do
H1AnalysisExample *example = (H1AnalysisExample*)f->Get("H1Analysis");Cheers,
Thank you for your help. I have tried the line of code that you suggestyed and it crashed my application when I pressed the close button in the dialog box of my gui, yielding the attached errors. Any ideas why?
I have also attached my close dialog box function and the function that reads back the chain of data files and fills the histogram. How can I get a chain from within the analysis object on file and put it through this sequence of events and display the histogram?
AddHistoFunction.C (702 Bytes)
CloseFunction.C (754 Bytes)
CloseErrors.C (2.27 KB)
You need to have TFile* f = new TFile(“yourdatafile.root”); before you call f->GetObject(“H1Analysis”,example);
This is the reason for the crash when you press the close button. For the rest I will leave Philippe to answer your questions.
Best regards, Ilka
[quote]How can I get a chain from within the analysis object on file and put it through this sequence of events and display the histogram?
[/quote]I am not sure what you mean. After retrieve the object from the file you can use any of its interface? Which object are refering to? What operation are you trying to applu? In which context? What did you try?
I want to get the H1Analysis object, which contains two chains of files, event data and model simulation. I have an executable in which I open the root file and get the H1Analysis object. I run my gui and enter the name of the chain that I want to display into a text entry in a dialog box, when I close the dialog box it calls a function that gets this chain, gets the histograms from the chain, fills them and draws them on the canvas. However, I keep getting the error that the chain name that I enter, i.e. data, is out of scope.
Your help is much appreciated,
Remember that you have 2 environment running. One is your compiled code and one is the interpreter. The interpreter environment is used whenever you execute a command using a string (for example in the signal/slot mechanism) or on the command. The interpreter only knows about what was explicitly defined to him.
[quote]However, I keep getting the error that the chain name that I enter, i.e. data, is out of scope.[/quote]This means that you have never declared a variable whose name is ‘data’ to the interpreter!
In the following I assume that you ‘chains’ are object of the class ‘Chain’.
What you need to do is after