Passing a histogram


ROOT Version (6.12/04):
Platform, compiler (MacOS 10.12.6, clang 9.0):


Hi,

I have a script that defines a class (e.g. MainEvent), and then there are two function constructors:
MainEvent::MainEvent (run_no) that finds four root files twith the same run_no, gets the data and so on, and a second one TH1F* MainEvent::Clusters() that makes one TH2F from the data from the four files, then finds the clusters and returns a TH1F histogram. The first one (MainEvent, void) calls the second one (Clusters) in it. In the end I make a loop over many runs and I run " new MainEvent (run_no) " over many runs.
My question is how can I pass the TH1F from each run to pile them up (add them for all runs)? I cannot pass the histo from MainEvent (I get error: constructor cannot have a return type). Any advice is highly appreciated. Thank you!

You can add parameter to the constructor:

MainEvent::MainEvent (run_no, &h) 
1 Like

Yepp, that worked. Thanks a lot!

Hi again,

Regarding the post above, I have about 350 runs to loop, so I need to add 350 histograms (TH1I). When I pass the histograms as parameters through the constructor, the compilations is OK, the program starts well and then ROOT just crashes after 15 loops. Each TH1I histogram has 15000 bins. Is this a memory issue? Thanks!

It could be. hard to tel without seeing the code.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.