Capabilities of TSelector with multiple datasets

Hi everyone,
I have a general purpose question regarding TSelector. I have written a (quite large) analysis code to run over a dataset, based open TSelector. To expand my analysis I would like to run over 5 datasets and fill the histograms with a weighting, which is different for each dataset. Moving away from TSelector would require quite a considerable rewriting of my code.
What I want to know, is if this is possible without running it 5 times separately and filling arrays of histograms to add together using a macro after the code is terminated. This would not be ideal as I have a lot of histograms in the code.

That is to say, is it possible in theory to

  • run the function Begin once to declare my histograms once only
  • run the TSelector function Process once for each dataset, filling the (same) histogram with the appropriate weighting each time
  • run the terminate function only once to plot the histograms

In your TSelector::Process function you can detect when a new file is loaded by the TChain (Save the pointer to the chain (say fChain) as a data member of your selector. Use for example
and use an array of weights function of the tree number in the chain.