Dear @vpadulan ,
Thank you very much!
I slightly extended the notifier to get for example the current filename:
struct MyNotifier{
MyNotifier() : fChain(0)
{}
void Init(TTree* tree)
{
fChain=tree;
}
bool Notify(){
std::cout << "Notification! reading new file" << "\n";
std::cout <<"File name: "<<fChain->GetCurrentFile()->GetName()<<std::endl;
return true;
}
TTree *fChain;
};
This works well with the chain, but when I try what you suggest with the TTreeReader:
...
TTreeReader myReader(&c);
TTreeReaderValue<int> var1(myReader,"column1");
MyNotifier n;
n.Init(&c);
TNotifyLink<MyNotifier> l{&n};
l.PrependLink(*myReader.GetTree());
int counter =0;
while (myReader.Next())
{
counter++;
std::cout <<"Event: "<<counter<<" "<<*var1<<std::endl;
}
works as well, however I get a warning:
Warning in <TChain::TTree::SetNotify>: The tree or chain already has a fNotify registered and it is a TNotifyLink, while the new object is not a TNotifyLink. Setting fNotify to the new value will lead to an orphan linked list of TNotifyLinks and it is most likely not intended. If this is the intended goal, please call SetNotify(nullptr) first to silence this warning.
it seems that the notification is set up twice?
In that case, I don’t understand which Notify link is already set up? I tried calling c.SetNotify(nullptr); before setting up myReader and MyNotifier but this didn’t help?
Thank you
Zdenek