Something sublty wrong with my ROOT code?

I’m not sure if there is, in fact, some subtle issue with my code (and, if so, whether it’s a ROOT issue or a C++ issue), but perhaps someone here can shed light on what’s going on.

The code below is designed to read TNtuple’s from three ROOT files, each of which contain UNIX timestamps during one year corresponding to events seen by a receiver. It then plots “coincidences” between timestamps by using the std::lower_bound algorithm to find the closest element greater than or equal to, and comparing that to one less than the returned itertor, thereby creating a list of triplets from the 3 ROOT files. Lastly, these triplets are sorted by closeness, and duplicates are removed, leaving only the closest unique matches.

I know for a fact that each receiver randomly goes off at least every few hundred ms or so, so I’d expect some random coincidences to occur. However, when I look at the UNIX timestamps from the triplets, they seem to cluster around the beginning of the year, and the middle of the year, with months-long gaps.

Is there something obvious I’m missing here? An obvious fault in my code, perhaps?

Are you sure that the timestamps are sorted (put another way, are your ROOT files guaranteed to be time sequential)? lower_bound() finds the first occurence of greater or equal. If the vector isn’t sorted that may not be the right find.

Yes, thanks for asking. I should’ve pointed this out. The data are guaranteed to be sorted. To be extra sure, I also run this code with an added line for sorting the vectors, and achieved the same result.