foo.h file:
class TMyClass : public TNamed {
private:
TChain *fChain; // !analyses chain, trees
TBranch *fMyBranch; // branch
bla_bla;
public:
Bool_t Notify(); // overridde TObject
void AnalyzeEntry(const Int_t entry) const;
TChain *GetChain() const { return fChain; }
bla_bla;
};
foo.cxx file:
TMyClass::TMyClass()
{
fMyBranch = 0;
}
bla_bla;
//____________________________
void TMyClass::AnalyzeEntry(const Int_t entry) const
{
Long64_t localEntry = fChain->LoadTree(entry); // also call Notify()
if (fMyBranch)
fMyBranch->GetEntry(localEntry);
AnyFunctionWithCurrentEntry();
}
//____________________________
Bool_t TMyClass::Notify()
{
fMyBranch = fChain->GetBranch("any_branch");
if (fChain->GetCurrentFile())
Printf("Processing file: %s",fChain->GetCurrentFile()->GetName());
return kTRUE;
}
and now:
[ul]
root [ ] TMyClass *foo = new TMyClass(“foo”);
// fChain is any TTree or TChain
root [ ] foo->AnalyzeEntry(12345); // all OK, function Notify() is calling
root [ ] Processing file: /home/user/any_file.root
[/ul]
but
[ul]
root [ ] TMyClass *foo = new TMyClass(“foo”);
// fChain is any TTree or TChain
root [ ] foo->GetChain()->Draw(“any_var”); // afther this command, member fReadEntry in TTree.cxx is more than 0
root [ ] foo->AnalyzeEntry(12345); // function Notify() is not calling (because fRead in not <0) and fMyBranch = 0
// How solve this problem ( without direct call foo->Notify() ) ?
[/ul]
Thanks and sorry to my poor English.