Hi,
I’m having problems with TBranch Fill. I get the following errors when I run my code:
Error in <TBranch::WriteBasketImpl>: basket's WriteBuffer failed.
Error in <TBranch::TBranch::Fill>: Failed to write out basket.
I get these errors for only some of the events and despite the errors the output seems to be correct. The code is for the CMS Open Data guide so I need to know the reason behind the error, even though the code seems to work, because it might confuse the users.
Here is the code. I create new branches to my TTree:
int maxmuon=1000;
Float_t Dimuon_mass;
Float_t Dimuon_mass_cor;
Float_t Muon_pt_cor[maxmuon];
Float_t Muon_eta_cor[maxmuon];
Float_t Muon_phi_cor[maxmuon];
Float_t Muon_mass_cor[maxmuon];
TBranch *bDimuon_mass = DataTree->Branch("Dimuon_mass", &Dimuon_mass, "Dimuon_mass/F");
TBranch *bDimuon_mass_cor = DataTree->Branch("Dimuon_mass_cor", &Dimuon_mass_cor, "Dimuon_mass_cor/F");
TBranch *bMuon_pt_cor = DataTree->Branch("Muon_pt_cor", &Muon_pt_cor, "Muon_pt_cor[nMuon]/F");
TBranch *bMuon_eta_cor = DataTree->Branch("Muon_eta_cor", &Muon_eta_cor, "Muon_eta_cor[nMuon]/F");
TBranch *bMuon_phi_cor = DataTree->Branch("Muon_phi_cor", &Muon_phi_cor, "Muon_phi_cor[nMuon]/F");
TBranch *bMuon_mass_cor = DataTree->Branch("Muon_mass_cor", &Muon_mass_cor, "Muon_mass_cor[nMuon]/F");
Then I loop over the events. I get the error when I call Fill for the new branches. I’ve checked that the values I try to fill the branches with are correct and I can find the same values when I check the output file.
Int_t nEntries = (Int_t)DataTree->GetEntries();
for (Int_t k=0; k<nEntries; k++) {
DataTree->GetEntry(k);
// Select events with exactly two muons
if (nMuon == 2 ) {
// Select events with two muons of opposite charge
if (Muon_charge[0] != Muon_charge[1]) {
// Compute Dimuon_mass value
// ...
bDimuon_mass->Fill(); // Fill the branch
// Loop over muons in event
for (UInt_t i=0; i<nMuon; i++) {
// Compute new (corrected) values
// ...
}
// Fill branches
bMuon_eta_pos->Fill();
bMuon_eta_neg->Fill();
bMuon_pt_cor->Fill();
bMuon_eta_cor->Fill();
bMuon_phi_cor->Fill();
bMuon_mass_cor->Fill();
// Compute Dimuon_mass_cor value
// ...
bDimuon_mass_cor->Fill(); // Fill the branch
//Fill the corrected values to the new tree
DataTreeCor->Fill();
}
}
}
I looked at the ROOT source code and I believe that the error is caused on either line 1138, 1170 or 1291 in the code. I don’t how to find out which one it is and how to fix it. I also couldn’t find a way to not print this error without ignoring all errors (this solution would be okay as well).
-Anniina
ROOT Version: 6.22.08