Reading vectors from a tree

Please note that TTree::GetVal retrieves the results of the most recent TTree::Draw and nothing else.

Something like this should work:

vector<double> *Station = 0;
t->SetBranchAddress("Station", &Station);
Long64_t n = t->GetEntries();
for (Long64_t i = 0; i < n; i++) {
  t->GetEntry(i);
  ULong_t nsig = Station->size(); // MUST be done for every tree entry
  double *sig = Station->data(); // MUST be done for every tree entry
  for (ULong_t j = 0; j < nsig; j++) {
    std::cout << i << " : " << j << " : " << sig[j] << std::endl;
  }
}
t->ResetBranchAddresses(); // disconnect from local variables
delete Station; // cleanup
1 Like