/* Compile with: g++ -Wall -Wno-long-long -pedantic -ansi -I$(root-config --incdir --libs) -o NotifyTest NotifyTest.C */ #ifndef __CINT__ #include #include #include #endif // __CINT__ class TChatter: public TObject { public: unsigned int count; TChatter(): TObject(), count(0) {} virtual Bool_t Notify() { std::cout << "Changed! (#" << (++count) << ")" << std::endl; return true; } #ifdef __CINT__ ClassDef(TChatter, 0) #endif // __CINT__ }; // TChatter #ifdef __CINT__ ClassImp(TChatter) #endif // __CINT__ Long64_t NotifyTest(const char* treename, const char* treespec) { TChatter chatter; TChain chain(treename); chain.SetNotify(&chatter); chain.Add(treespec); Long64_t iEntry = 0, nEntries = chain.GetEntries(); while (iEntry < nEntries) chain.GetEntry(iEntry++); return iEntry; } // NotifyTest() #ifndef __CINT__ int main(int argc, char** argv) { if (argc != 3) return 1; Long64_t nEntries = NotifyTest(argv[1], argv[2]); std::cout << nEntries << " entries parsed." << std::endl; return 0; } // main() #endif // __CINT__