TTreeReaderArray: erase an element


I’m looking at the TTreeReader tutorial at, specifically at this excerpt:

TTreeReader reader("MyTree", file);
TTreeReaderArray<float> raMuonPt(reader, "muons.fPt");
while (reader.Next()) {
    for (int iMuon = 0, nMuons =  raMuonPt.GetSize(); iMuon < nMuons; ++iMuon)

My question is: is there a way to delete some raMuonPt element, similarly to what std::vector::erase would do? What I’d like to do is to introduce another loop over muon pTs before the current one, check e.g. if muon pT > 1 MeV, and if not, to just get rid of this value altogether. Note I don’t want to do it via a continue statement - I want to have raMuonPt.GetSize() decreased, too. Is it possible?


ROOT Version: 6.14/04

The TTreeReaderArray interface does not (want to) know what kind of collection in underneath and thus it is likely challenging to modify it. Depending what you need to do in the end, you might either need to cache the value that pass the criteria in a new container or maybe just simply keep a count of the value that pass the criteria.

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