#include #include #include #include #include void write_tree(char *fn,int base){ Int_t dat; fprintf(stderr,"Writing file %s, base is %d\n",fn,base); TFile *of=new TFile(fn,"RECREATE"); TTree *ot=new TTree("t1","Tree 1"); ot->Branch("DatBranch",&dat,"dat/I"); for(int i=0;i<4;i++){ dat=i+base; ot->Fill(); } ot->Write(); delete ot; delete of; } class BugSelector : public TSelector { public: Int_t dat; TTree *fTree; BugSelector(){ fprintf(stderr,"new BugSelector!\n"); }; ~BugSelector(){ fprintf(stderr,"bye BugSelector!\n"); }; virtual Bool_t Notify(){ fprintf(stderr,"Notify()\n"); return kTRUE; }; virtual void Begin(TTree *t){ fprintf(stderr,"Begin->"); Init(t); }; virtual void Init(TTree *t){ fprintf(stderr,"Init(%p)\n",t); fTree=t; t->SetBranchAddress("DatBranch",&dat); }; virtual void ProcessFill(Int_t entry){ fTree->GetEntry(entry); fprintf(stderr,"ProcessFill(%d) -> %d\n",entry,dat); }; }; int main(int argc,char **argv){ write_tree("tree1.root",100); write_tree("tree2.root",200); write_tree("tree3.root",300); TChain ch("t1","My Chain"); ch.Add("tree1.root"); ch.Add("tree2.root"); ch.Add("tree3.root"); BugSelector b; ch.Process(&b); }