TChainIndex help

Hi,

I have 2 TChains for competing analyses. Each Tree in each chain has a TTimeStamp in each event. I’d like to search for events in one chain, find the corresponding event by matching the event times in the 2nd chain, then make plots comparing the matched events. But I’m having a hard time figuring out how to use TChainIndex to do this (if it’s even possible).

If my TChains are ch1 and ch2, I’d like to do the something like the following:

  1. BuildIndex on ch1 using major = TTimeStamp object.
  2. BuildIndex on ch2 using major = TTimeStamp object.
  3. for each event in ch1, extract the index value, call it val.
  4. Check if ch2->GetEntryNumberWithIndex(val) returns a matching event, if so plot the relevant data.

I can not find any complete examples of how to do something like this though. It’s not clear to me how to loop over the index values in the TChain, what member function gets at them?

Is the method I’m describing the correct way to use indices on TChains to search for matching events?