There is an excellent RDataSource subclass that allows xAOD files, and I’m trying to add friend trees. The way I’m trying to do it right now seems to be creating a lot of code duplication, so I was hoping that you could offer me some advice on making this more elegantly?
What I have right now
On top of the existing RDataSource;
- On initialisation, I get a list of all branches in the friend trees, and their types.
- When each slot is initialised (
InitSlot( unsigned int slot, ULong64_t firstEntry )),I create a second TChain containing the xAOD and friends, specifically for reading data from the friend trees. For each branch in the friend tree that is not a container I useSetBranchAddressto get a pointer to the element, stored as avoid *. - When
GetColumnReadersis called, it’s the pointers created inInitSlotthat are returned. - When each entry is set (
SetEntry( unsigned int slot, ULong64_t entry )), for the non-containers it’s enough to callGetEntryon the friend chain for the slot. For the container branches (RVec) it’s going to be ugly, it seems I will need to copy the content of the container each time a new event is set; as in root/RTreeColumnReader.hxx at b1b6d269215eeeff07f99e4e94623c49fd920243 · root-project/root · GitHub My main concern is this seems unavoidable, even for branches that are not used.
Can you see a neater alterative?
Any way to limit the columns I need to read from in GetEntry?
Edit; so actually I realise that unless a column has been accessed with GetColumnReaders, there is no need to do anything about it. So maybe the simplest way is to do the SetBranchAddress and/or create placeholder RVec pointers in GetColumnReaders, and keep track of which columns are in use there, so that only container branches that are actually in use get copied in SetEntry?