Thanks for clicking on my question. It would be really helpful if someone could help me with this.
The code I am working with has these lines :
L1Analysis::L1AnalysisL1UpgradeDataFormat *l1_ = new L1Analysis::L1AnalysisL1UpgradeDataFormat();
From what i understand, it looks like we are passing the address of a pointer as the second argument of SetBranchAddress. I looked at each of the 5 SetBranchAddress() functions here :
but am still not able to figure out the exact meaning of the second argument and which of the 5 SetBranchAddress() is being referred here. If someone could explain where I am wrong in my thinking or maybe point to the correct answer, it would be really helpful.
Yes, you are passing the address of the pointer to an object (note: you should always use this pointer when referencing your object as ROOT may recreate the object and so its actual address, always stored in this pointer, may change).
I assume it is the “4th (templated) SetBranchAddress” method (but maybe @pcanal disagrees).
You do NOT need to create the object youself. You could also set
l1_ = 0 (and then the object would be automatically created by the SetBranchAddress call).
In any case, you are responsible for deleting the object when it is no longer used by your tree (e.g. after the tree is deleted).
Thanks a lot for responding to my post. I just got a chance to work on this again. Sorry for the very late reply.
Can you just elaborate what you mean in this?
You do not need “
l1_ = new ...”, you can simply have “
l1_ = 0”.
Oh, okay. In that case, at which command is the object created then?
Usually during the call to GetEntry (but also sometimes during the SetBranchAddress). Either way, the value of the pointer will be updated to reflect the creation.