Accessing variables via SetBranchAddress

See:

Try:

{
  TFile *f = TFile::Open("selected.root");
  if (!f) return; // just a precaution
  
  TTree *t; f->GetObject("recData", t);
  if (!t) { delete f; return; } // just a precaution
  
  t->SetMakeClass(1);
  t->SetBranchStatus("*", 0);
  
  Int_t fFDEvents_;
  // note: you must know kMaxevent_fFDEvents from somewhere else,
  //       e.g. use TTree::MakeClass to get it
  const Int_t kMaxevent_fFDEvents = 3;
  Double_t fEnergy[kMaxevent_fFDEvents]; //[fFDEvents_]
  
  t->SetBranchStatus("event.fFDEvents", 1);
  t->SetBranchAddress("event.fFDEvents", &fFDEvents_);
  
  t->SetBranchStatus("event.fFDEvents.fFdRecShower.fEnergy", 1);
  t->SetBranchAddress("event.fFDEvents.fFdRecShower.fEnergy", fEnergy);
  
  for(Long64_t i = 0; i < t->GetEntries(); i++) {
    t->GetEntry(i);
    
    if (fFDEvents_ > kMaxevent_fFDEvents) {
      // note: the stack is corrupt, a SIGSEV crash is possible
      std::cout << i << " : " << fFDEvents_ << " :"
                << " FATAL ERROR : fFDEvents_ > kMaxevent_fFDEvents = "
                << kMaxevent_fFDEvents << std::endl;
      delete f; // automatically deletes "t", too
      return; // try to get out of here
    }
    
    std::cout << i << " : " << fFDEvents_ << " :";
    for (Int_t j = 0; j < fFDEvents_; j++) std::cout << " " << fEnergy[j];
    std::cout << std::endl;
  }
  
  // t->ResetBranchAddresses(); // detach "t" from local variables
  delete f; // automatically deletes "t", too
}