Hello everyone,
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();
upgradeTree->SetBranchAddress(“L1Upgrade”, &l1_);
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).
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.