RooFit problem when get a Bool_t from a TTree

Dear experts,
I am trying to import bool variables from a ROOT TTree.
I have got my bool in this way:

TFile file = new TFile(“mytree.root”);
TTree
newtree = file->Get(“newtree”);
RooRealVar test(“test”,“test”,-10,10);
RooArgSet ntuplaVar(test);
RooDataSet data(“data”,“data”,newtree, ntuplaVar);

but i have this error:
Error in TTree::SetBranchAddress: The pointer type given “Double_t” (8) does not correspond to the type needed “Char_t” (1) by the branch: test

As far as i have understood Double_t, Float_t, Int_t, UInt_t and Bool_t should be automatically converted to Double_t. In my code it works for the Int_t but I get the previous error for Bool_t variables…what i miss?
I am using RooFit v3.10.
Thank you,
Valentina

Hi Valentina,

RooFit explicitly supports conversion from the data type ‘UChar_t’ which is the Boolean.
You seem to have a ‘Char_t’, which I do not support (but could). I’ll add this as a fix
for the next release. I’ve file this in Savannah as #74321

Wouter

Hi,

This has been fixed for 5.28.

Wouter

Hi,

I am having a similar problem to the one above: I am trying to read a boolean variable from a tree as follows:


RooRealVar mZZ(“mZZ”, “zz inv mass”, 200,800);
RooRealVar eventWeight(“eventWeight”,“eventWeight”,0,10);
RooRealVar nBTags(“nBTags”,“nBTags”,-1,3);
RooRealVar isSidebands(“isSidebands”,“isSidebands”,0,1);

RooDataSet data_sig(“data_sig”,“data”,tree,RooArgSet(mZZ,eventWeight,nBTags,isSidebands),“nBTags==0 && isSidebands==0”,“eventWeight”);

However, this give me an error:

[#0] ERROR:InputArguments – RooAbsReal::attachToTree(isSidebands) data type Bool_t is not supported

I am running Root 5.29.02 and roofit 4.3. Is there something wrong with what I am doing?

andrew

I have the same problem with v5.33
what is the solution???
walter