Weird problem with Bool_t branch in ROOT 4.04/02

I am trying to create a small ROOT (4.04/02) file with a single-entry TTree, but no “real” data (all zeroes). I have to do this in order to instantiate TMultiLayerPerceptrons, which apparently can only function if given a TTree being read back from a file.

Unfortunately, I am encountering an error message I have not seen before. One of the branches of my tree is a Bool_t. I can create and write out my little TTree just fine, but on readback I get

Error in TTree::SetBranchAddress: The pointer type given “Bool_t” (18) does not
correspond to the type needed “Char_t” (1) by the branch: isSignal

I have plenty of other ROOT files where branches contain Bool_t’s, and I’ve never seen this error. Here is a small executable which reproduces the problem:

#include “TFile.h”
#include “TTree.h”

int main() {
Bool_t isSignal = kFALSE;

TFile dummy(“dummy.root”,“RECREATE”);
TTree* boolOut = new TTree(“NoBools”,“No bool branches?”);
boolOut->Branch(“isSignal”, &isSignal, “isSignal/B”, 100);
boolOut->Print();
boolOut->Fill();
boolOut->Write();
dummy.Close();

TFile playback(“dummy.root”);
TTree* boolBack = (TTree*)playback.Get(“NoBools”);
assert(0 != boolBack);
boolBack->SetBranchAddress(“isSignal”,&isSignal);
boolBack->GetBranch(“isSignal”);
boolBack->GetEntry(0);
boolBack->Print();
playback.Close();
}

Is this error expected in ROOT 4.04/02? Am I doing something wrong with the code above?

see in: root.cern.ch/root/htmldoc/TTree. … ree:Branch

  • B : an 8 bit signed integer (Char_t)
  • O : a boolean (Bool_t)

Jan