Can 'struct'-style branches be variable length arrays?

I’m trying to find a solution for structured data in a TTree which doesn’t involve TStreamerInfo (we exclude ClassDef from our code for Reasons).

Our simulation framework supports a varying number of detectors at runtime, each with its own (possibly different) number of channels. I’d like to store and access info with “nested” variable length arrays, along the lines of:

struct DetSum {
  int detID;
  int nchan;
  double E[MAXCHAN];
};

int ndet;
DetSum detinfo[MAXDET];

summary->Branch("ndet", &ndet, "ndet/I");
summary->Branch("Det[ndet].", detinfo, "id/I:nchan/I:E[nchan]/D");

Is this sort of construction allowed? Searching the documentation (for subbrach, split, etc.) was not successful.

ClassDef is not required for I/O. Generating dictionary eventhough it is not strictly necessary makes things much easier.

No, the “leaflist” technique does not support arrays of struct. You might get away with

struct DetInfo {
  int ndet
  int detID[MAXDET]
  int nchan[MAXDET];
  double E[MAXDET][MAXCHAN];
};

But it might be much simplier to use:

struct DetSum {
  int detID;
  int nchan;
  std::vector<double> E;
};
and
std::vector<DetSum> detinfo;

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.