Matching vector to a TTreeReaderArray in TSelector loop

Dear experts,

I have a very simple question regarding the usage of TTreeReaderValue and TTreeReaderArray.
I’m using a TSelector to loop over a tree, my final output will be a skimmed tree. I do not have problems to fill my flat variables, for example the number of jets:

Once defined:

TTreeReaderValue<Int_t> n_jet = {fReader, "n_jet"};
Int_t shortTree_n_jet;

in the loop I do:

shortTree_n_jet = *n_jet;

How can I do the same for vectors? For example the jet momenta:

TTreeReaderArray<float> jet_pt = {fReader, "jet_pt"};
vector<float> shortTree_jet_pt;

what about the matching?
shortTree_jet_pt = ?

Is there a smart way to do it without looping on the TreeReaderArray and fill the corresponding vector?

Thanks for the attention.


ROOT Version v6-10-04

Hi Francesco,

if you are skimming a tree, maybe a good option is to use TDataFrame. More specifically, you can filter your events, manipulate the quantities in the dataset, add new ones and save everything as a new dataset (also in parallel) - all this without worrying about details such as TTreeReader. See for instance this code example.


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