Hi! I am a begginer using trees, I have .root file with a lot of variables, I have just declared all of them in my .C document, I declared them like:
vector<double> *Station=0;
after that I do:
t->SetBranchAddress(“Station”,&Station);
I want to work with this variable as a vector, so I do:
Double_t *sig = new Double_t [n]; //n is the number of entries in the tree
sig =Station->data();
After that I do a cout to check that everything is correct but it isn’t because it doesn’t show me nothing.
Could you tell me where is the problem?
Thank you very much.
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