Skipping bad basket entry reads

Hi,

I am processing a large amount of root files using

TTreeReader reader(&chain);
auto variable = std::make_unique<TTreeReaderValue<Float_t>>(reader, "variable");
while(reader.Next()){
    std::cout<<**variable<<std::endl;
}

However, in some cases, I get segmentation violations in the form of

Error in <TBranch::GetBasket>: File: file.root at byte:0, branch:variable, entry:1125, badread=0, nerrors=1, basketnumber=139

I assume that these errors appear because in the pre-processing step something was not recorded properly. As I do not care about individual entries, I would like to ask if there is a way to simply skip these ‘bad’ entries. I already tried with

TTreeReader reader(&chain);
auto variable = std::make_unique<TTreeReaderValue<Float_t>>(reader, "variable");
while(reader.Next()){
    if (reader.GetEntryStatus() != TTreeReader::kEntryValid) continue;
    std::cout<<**variable<<std::endl;
}

But unfortunately this did not have any effect. Any help greatly appreciated!


ROOT Version: 6.26/04
Platform: linuxx8664
Compiler: gcc


Hi,

If the data is corrupted it might not be possible to prevent those segfaults, since the ROOT I/O libraries rely on some format specification to be met.

@pcanal any thoughts?

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