Problem with reading complex data structure as a sub-branch of a root tree

We are trying to read data from a .root file with a tree having a sub-branch that is
a vector<g2IntPt> xtals_intpts[kMaxxtals].

We are doing so by producing “.C” and “.h” files using datatree->MakeClass(“analysis”)
and loading the proper addition library:
.L /rec-data-b/analysis_14C/goddessSort/build/libGRETINA.so

Using the created analysis.C we can access properly all the other variables/leafs of
the tree but not those in " vector xtals_intpts[kMaxxtals] ".
In particular, the problem is that the variables in this structures are always zero (empty).

Here below the relevant code lines in the created file “analysis.h”:

/****************************************************/

.....

vector<g2IntPt> xtals_intpts[kMaxxtals];

........

TBranch        *b_xtals_intpts;   //!

......

fChain->SetBranchAddress("xtals.intpts", xtals_intpts, &b_xtals_intpts);


/****************************************************/

Here below the relevant code lines in the created file "analysis.C":

/****************************************************/
void analysis::Loop()
{
           
..... 

     b_xtals_intpts->GetEntry(ientry);
      
      
........     
  
      for(Int_t j=0; j<kMaxxtals; j++){
      	for(Int_t i=0; i<40; i++){
	
		cout << " "<< xtals_intpts[j].at(i).segE;
		
	}

......
/****************************************************/

Are we doing some trivial error?

MakeClass can not ‘read’ those branches (MakeClass does not support reading any full object).

You can try MakeSelector or better yet RDataFrame.

Thanks. Unfortunately also MakeSelector doesn’t work.
We succesfully accessed the data with:
teb->Draw(“g2.xtals.intpts.segE:g2.xtals.intpts.segNum>>(36,0,36,1000,0,3000”,“g2.xtals.crystalNum==22”,“colz”)

Using RDataFrame, would be:

ROOT::RDataFrame df(“teb”, “myfileToBeRead.root”);
auto entries1 = df.Count(“teb.g2”);
auto h = df.Histo1D(“teb.g2.xtals.intpts.segE[0]”);

(?) …but it gives to us seg fault…

I specify that we correctly loaded the external library with:
gSystem->Load(“libGRETINA.so”);

More particularly, when I do

ROOT::RDataFrame df(“teb”,“test.root”);
df.GetColumnNames()

it returns:

ROOT::RDF::RInterface::ColumnNames_t) { “g2.TObject.fUniqueID”, “fUniqueID”, “g2.TObject.fBits”, “fBits”, “g2.TObject”, “TObject”, “g2.runNumber”, “runNumber”, “g2.xtals.xtals.fUniqueID”, “xtals.fUniqueID”, “g2.xtals.xtals.fBits”, “xtals.fBits”, “g2.xtals.xtals.crystalID”, “xtals.crystalID”, “g2.xtals.xtals.crystalNum”, “xtals.crystalNum”, “g2.xtals.xtals.quadNum”, “xtals.quadNum”, “g2.xtals.xtals.timestamp”, “xtals.timestamp”, “g2.xtals.xtals.t0”, “xtals.t0”, “g2.xtals.xtals.chiSq”, “xtals.chiSq”, “g2.xtals.xtals.normChiSq”, “xtals.normChiSq”, “g2.xtals.xtals.bl”, “xtals.bl”, “g2.xtals.xtals.error”, “xtals.error”, …

I guess g2.xtals.xtals.error", “xtals.error” means that we cannot use also RDataFrame, right?

We managed to solve the problem:

we read the whole “xtals” structure as 1 single block (MakeSelector and MakeClass
“divide” it), using: TTreeReaderArray XXg2CrystalEvent xtalsXX = {fReader, “xtals”};

Sorry the 2 " XX" signs above have to be substituted by “smaller than” and “larger than” symbols, I don’t know why this signs did not appear in the post

It’s still weird that RDataFrame wasn’t able to access that data. Is there a chance that you could share that tree with us - one entry is enough!
Cheers, Axel

I think is useful idea. I have to ask formally permission to the spokesperson of the experiment before.
Would you sent me an email with such request?
Additional information is that we also tried with different root version (we are using v6-22-06). we tried with v6-24 and is the same. Instead with previous root6.14 we find no “xtals.error” but also without any ColumnNames for “xtals” appearing.