#include "TFile.h" #include "TTree.h" #include void problem(void) { TFile *file = TFile::Open("/publicfs/dyb/data/userdata/chloh/Project/Production/RadioActivity/AmC/Output/run000.rec.root", "read"); if (!file) { std::cout << "Error: file not found." << std::endl; return; } TTree *tree; file->GetObject("Event/CalibReadout/CalibReadoutHeader", tree); if (!tree) { std::cout << "Error: tree not found." << std::endl; delete file; return; } tree->SetMakeClass(1); tree->SetBranchStatus("*", 0); tree->Print(); UInt_t triggerTimeSec=1; tree->SetBranchStatus("triggerTimeSec", 1); tree->SetBranchAddress("triggerTimeSec", &triggerTimeSec); Long64_t nentries=tree->GetEntries(); for(Long64_t jentry = 0; jentry < nentries; jentry++) { tree->GetEntry(jentry); std::cout << "triggerTimeSec = " << triggerTimeSec << std::endl; } tree->ResetBranchAddresses(); // "detach" from local variables }