Hi all,
I want to copy some data taken from TTrees using SetBranchAddress, then pass that pointer to a new data object. Then I want to copy that data into the new object. Is it better to use TObject::Clone or simply use stl’s copy from algorithm? Or does it matter? Here’s a little pseudo code of what I mean.
TMyData *data = new TMyData();
tree->SetBranchAddress("data", &data);
tree->GetEntry(iGreatEvent);
TSuperClass *sc = new TSuperClass(data);
Now I want to copy the data into the new class so that I don’t follow with things that happen in the TTree class.
Does it matter if I do use
TSuperClass(TMyData *data){
fData = data->Clone()
// or
fData = new TMyData();
std::copy(fData, data, data+1);
}
I don’t know a ton about the TObject::Clone() function, but it does seem to allocate memory. Is there anything about ROOT that would make it important to use the Clone() function?
In general, in ROOT classes I like to stay consistent with other ROOT classes and functions. But, I don’t really like using Clone without really knowing what’s going on.
Elliott