Handle a TFile trought different class

Dear all,

really I don’t know if this question has been already answered please in case point me to the link.

What I would like to do is the following:

I have a root analysis class made with MakeClass and I have compiled it.

Now I’m going to rationalize the code that I have wrote since start to became a big wale :frowning:

At this point my problem is the following I would like to have a central class like a “kernel” and appended to this class a series of various small classes that basically do nothing else that fill histos.

My naive idea for solve my problem is define a TFile in the “kernel” and pass the pointer to it to each sub classes and in each of this classes separately defining the set of histos that I want to create and fill.

When I’m at the endJob of the “kernel” call a method for each sub classes that wrote in the file and at the very end close the file form the “kernel”.

Do you think that this approach works?

If yes do you know if I can use the same strategy for a TSelector?

Thank you very much for any help and suggestions.

Cheers,
Filippo

Hi,

This sounds reasonable. It should work even better with TSelector where your could have your kernel be a class inheriting from TSelector (and having a member which is the TFile).

Cheers,
Philippe.