Please read tips for efficient and successful posting and posting code
Hi,
I want to create a new branch on an existing tree using entries from two existing branches
void makeAvgBranch() {
TFile* inFile = new TFile("somefile.root", "update");
TTree* tree = static_cast<TTree*>(inFile->Get("someTree"));
tree->Print();
Double_t newBranch;
TBranch* avgBranch = tree->Branch("avg", &newBranch);
Double_t data_a, data_b;
tree->SetBranchAddress("a", &data_a);
tree->SetBranchAddress("b", &data_b);
for (int i = 0; i < tree->GetEntries(); i++) {
tree->GetEntry(i);
newBranch = 0.5*(data_a + data_b);
avgBranch->Fill();
}
tree->Print();
}
However, when I tried to fill the new branch, I get the following errors:
Error in <TBranch::WriteBasketImpl>: basket's WriteBuffer failed.
Error in <TBranch::TBranch::Fill>: Failed to write out basket.
The errors only occur periodically.
Here is the info on the branches:
*............................................................................*
*Br 25 :a : Double_t *
*Entries : 5388854 : Total Size= 43124605 bytes File Size = 2529536 *
*Baskets : 122 : Basket Size= 1506304 bytes Compression= 17.05 *
*............................................................................*
*Br 26 :b : Double_t *
*Entries : 5388854 : Total Size= 43124479 bytes File Size = 2886215 *
*Baskets : 122 : Basket Size= 1506304 bytes Compression= 14.94 *
*............................................................................*
*Br 48 :avg : avg/D *
*Entries : 5388854 : Total Size= 43116791 bytes All baskets in memory *
*Baskets : 1350 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
where a and b are the two existing branches and avg is the new branch that I created. Why am I getting these errors? And how are they affecting the new branch?