Dereferencing a Pointer to a Vector

Hi all,

In a n-tuple I am working with, there is a variable that is a pointer to a vector (i.e called ‘lowpt_el_n’). I am wondering how I would dereference each element of ‘lowpt_el_n’ to get the value (not the address)? Here is the relevant code, every time I run it ROOT crashes:

Thanks in advance!
David Chataway

      std::vector<Int_t> *lowpt_el_n;
      TBranch *b_lowpt_el_n;            //Unsure about this
     tree->SetBranchAddress("lowpt_el_n", &lowpt_el_n, &b_lowpt_el_n);

for (Long_t iEvent = 0; iEvent< nEvent; iEvent++) {
tree->GetEntry(iEvent);

//Int_t a = (*lowpt_el_n)[0]; //First attempt

//vector<Int_t>& vecRef = *lowpt_el_n; //Second attempt
//Int_t b = vecRef[1];

std::vector<Int_t>::iterator it; // instantiate the iterator

for (it=lowpt_el_n->begin(); it!=lowpt_el_n->end(); ++it)
{std::cout << *it << std::endl;}

You have a pointer to a vector of ints, so I think the standard incantation would be
lowpt_el_n->at(0)

If the problem is with setting the branch address properly, thats a different issue, but without the crash information its hard to help. The documentation for the syntax of set branch address is here:
root.cern.ch/root/html/TBranchEl … SetAddress

Okay I tried lowpt_el_n->at(0), it still crashed.
Thanks for responding quickly.