When writing: SS1 yt; tree->Branch("yt.", &yt, 32000, 99);
When reading (in any case, you must “delete ipyt;” in the end): SS1 *ipyt = 0; tree->SetBranchAddress("yt.", &ipyt);
or: SS1 *ipyt = new SS1(); tree->SetBranchAddress("yt.", &ipyt);
void HandleBOR_Scaler(int run, int gFileNumber, int time, IScaler *pscaler)
{
....
else tree->SetBranchAddress("scaler",&pscaler);
...
}
Unfortunately this pattern is a “disaster” …
This is asking the TTree to record and later use the address of the function variable. After the end of the function execution, the address will be reused for other purpose but the TTree (when GetEntry is called) will read and write at that address with … random and usually catastrophic (in the best case scenario you get a segmentation fault but at a weird looking place).
To partially solve the problem you would both needs to change the paratemer type from a pointer to a reference to a pointer:
void HandleBOR_Scaler(int run, int gFileNumber, int time, IScaler *pscaler)
AND make sure that HandleBOR_Scaler is called with a pointer variable whose lifetime is greater or equal to the lifetime of the TTree.