"Bytecount too large" and "Segmentation Violation" Errors on Writing an Index to a TTree

Hi,
I’m using root v6.12/06 and have been trying to take a large TTree in a data file (~1.8 GB) that needs to have some of its data altered, and then add an index to the resulting tree. I have used the following code to do so:

void CleanUpLib() {
    TFile *fin = new TFile("inputdata.root");
    TTree *pltree = (TTree*)fin->Get("pmtresponse/PhotonLibraryData");
    int     Voxel;          pltree->SetBranchAddress("Voxel",          &Voxel);
    int     OpChannel;      pltree->SetBranchAddress("OpChannel",      &OpChannel);
    Float_t Visibility;     pltree->SetBranchAddress("Visibility",     &Visibility);
    Float_t ReflVisibility; pltree->SetBranchAddress("ReflVisibility", &ReflVisibility);
    Float_t ReflTfirst;     pltree->SetBranchAddress("ReflTfirst",     &ReflTfirst);
    //-----
    TFile *fout = new TFile("data_cleaned.root","RECREATE");
    TTree *cltree = new TTree("PhotonLibraryData", "PhotonLibraryData");
    int     cVoxel;          cltree->Branch("Voxel",          &cVoxel,         "Voxel/I");
    int     cOpChannel;      cltree->Branch("OpChannel",      &cOpChannel,     "OpChannel/I");
    Float_t cVisibility;     cltree->Branch("Visibility",     &cVisibility,    "Visibility/F");
    Float_t cReflVisibility; cltree->Branch("ReflVisibility", &cReflVisibility,"ReflVisibility/F");
    Float_t cReflTfirst;     cltree->Branch("ReflTfirst",     &cReflTfirst,    "ReflTfirst/F");
    //-----
    
    // COPY ALL BUT ONE OF THE DUPLICATE SETS TO THE NEW TREE cltree
    const int TotNum = pltree->GetEntries();
    for (int V = 0; V < TotNum; V++) {
        if (V>=160142198 && V<=160201637) {
            // SKIP THESE ENTRIES BECAUSE REASONS
            continue;
        }
        //COPY ELEMENTS TO NEW TREE
        pltree->GetEntry(V);
        cVoxel = Voxel;
        cOpChannel = OpChannel;
        cVisibility = Visibility;
        cReflVisibility = ReflVisibility;
        cReflTfirst = ReflTfirst;
        cltree->Fill();
    }
    delete fin;
    // BUILD INDEX AND WRITE TO FILE
    int cTotNum = cltree->GetEntries();
    cltree->SetEstimate(cTotNum);
    cltree->BuildIndex("Voxel","OpChannel");
    cltree->Print();
    fout->cd();
    cltree->Write();
    delete fout;
}

Without the BuildIndex() line, the code runs as expected. However, when BuildIndex() is included once the code gets to the Write() line I get two Error in <TBufferFile::WriteByteCount>: bytecount too large (more than 1073741822) errors followed by a segmentation violation. The new file does in fact exist regardless of these errors, though it doesn’t contain the index.

I know from reading other forum posts that this is probably happening due to me saving more than 1GB of data in a single buffer. How do I successfully get the index written to file without this error, and why is it the index that’s causing the problem?

Any help would be greatly appreciated!

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

It looks like the index is too large to fit within the 1Gb limit for an individual I/O buffer.