I’m very new to ROOT and I have a small issue with MakeClass.
I have a multitude of Tchains they all have the same Ttrees (same name but different content of course). So I use MakeClass on one of the Tchains to produce the .C and .h files and I wanted to know if there is a way to modify the .C and .h files so that I can loop over all the different Tchains. In other words, I want to go to the first Tchain plot the content of a certain variable (Leaf) into a Histogram then go to the next Tchain plot the variable of interest again etc …
In an interactive ROOT session, you can try:
// load the MakeClass generated source code once
TChain *t; // define a pointer which will keep the "current" chain
MyClass *p; // define a pointer which will keep the "current" analysis
// the sequence below can be repeated many times for different chains
t = new TChain("MyTree"); // create the "current" chain
t->Add("MyFiles*.root"); // add all required files to the "current" chain
p = new MyClass(t); // create the analysis object for the "current" chain
p->Loop(); // loop over all "current" chain's entries
delete p; // no longer needed
delete t; // no longer needed
Thank you very much this is what I needed.
I have one issue now which is that when I try to write this in a script and run it all at once I don’t know how to include the first line too: “.L MyClass.C” . I’m sorry if this is a stupid question.
In a named ROOT macro, you should be able to simply:
Thank you for your answer. I have tried that before asking my question but it didn’t work I don’t know why.
This works perfectly. I’m very thankful to you !
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.