If you have a TObjArray with other TObjArray inside and you try to apply a method to the nested TObjArrays you are told that TObject has no member called whatever you are trying to use, be it At() or Add() or anything else.
It seems that Root asumes that something inside a TObjArray won’t be a TCollection.
Here is the shortest code I’ve made that produces this mistake:
#include "TObjArray.h"
#include "TH2D.h"
int main()
{
TObjArray* myArray = new TObjArray(1);
TObjArray* myNestedArray = new TObjArray(1);
myArray->Add(myNestedArray);
TH2D* h1 = new TH2D("h1", "H1", 9, 0, 1.8, 1000, -20, 20);
myArray->At(0)->At(0)->Add(h1);
}
You’re welcome, and well, it works because TObjArray::At(idx) returns a pointer to a TObject, hence the need of casting to the proper inherited class (TObjArray*)
Indeed. If you want h1 into myArray, then do: myArray->Add(h1);
It seems obvious enough to me…