Hi,
I think this is a very basic question, but I cannot seem to find the solution.
I have a root macro than simply does something like this:
void mylooper(){
string rootfiles;
rootfiles=*.root;
gROOT->LoadMacro("MyNTupleLooper.C++g");
MyNTupleLooper *a = new MyNTupleLooper();
a->AddFiles(rootfiles.c_str());
a->Loop();
}
Were MyNTupleLooper.C is a lopper class made by MakeClass and where I have modified MakeClass to handle a chain of files (The AddFiles function)
this works perfectly.
Now, I have wanted for some time to be able to loop over this sequence for different datasets, thus each time I would like to create a new MyNTupleLooper object, and new output, just as it would be if I just ran the macro twice for example.
But I have no idea how to delete the previous object here, a, and begin again. I always get the problem of histograms being replaced, even if I try to do something like this:
void mylooper(){
for(int it=0; it<path.size(); it++){
gROOT->Reset();
MyNTupleLooper *a = new MyNTupleLooper();
a->AddFiles(path.at(it).c_str());
a->Loop();
}
}
where path now is a vector object with the paths to my dataset-rootfiles (ntuples). I was hoping that to create the MyNTupleLooper object for each iteration again with new would be the solution, but obviously it is not.
Any suggestions are welcome
Thanks!
Maiken