I am looking at the following piece of code:
StJetEvent* jets = 0;
jetChain->SetBranchAddress("AntiKtR060NHits12",&jets);
Where we have that:
The class of jetChain
is TChain
and the definition of SetBranchAddress
is:
Int_t TChain::SetBranchAddress ( const char * bname, void * add, TBranch ** ptr = 0)
The definition of the relevant parameters inside of the the argument of the SetBranchAddress
is:
bname is the name of a branch. add is the address of the branch.
For some reason, when I look at SetBranchAddress("AntiKtR060NHits12",&jets)
, based on the definition of the function SetBranchAddress
, I would think that the second parameter that needs to be passed is a pointer, but instead the address of the pointer jets
is passed. This is consistent with what the definition of what the second parameter is, but from my basic understanding, I thought that void * add
means to pass a pointer and NOT the address of the pointer.
Can someone please provide me with some clarification, please? Thank you very much!
The syntax &z
returns a pointer to z
. The terms "address of X" and "pointer to X" mean almost exactly the same thing.
int z;
int* q = &z; // now q is a pointer to z
int** r = &q;
When we say "q is a pointer to z", we mean two things:
So here, 'r' is a pointer to 'q' for the same reasons.