Hello
I have a TTree with leafs made of Double_t and I also stored there a TF1, called wZ.
In my code:
TF1 *wZ=new TF1("wZ","0.003843*TMath::Sqrt( 1. + TMath::Power( (x-44.99)/0.1736 , 2) )",43.,45.5);
TFile *fout = new TFile("GR.root","RECREATE");
TTree *tree = new TTree("tree","GR");
Double_t Z ;
tree->Branch( "Z" ,&Z );
tree->Branch( "wZ" , wZ );
for () {
tree->Fill();
}
The Print method in root shows:
******************************************************************************
*Tree :tree : GR *
*Entries : 234 : Total = 124032 bytes File Size = 7584 *
* : : Tree compression factor = 18.11 *
******************************************************************************
*Br 0 :Z : Z/D *
*Entries : 234 : Total Size= 2421 bytes File Size = 235 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 8.26 *
*............................................................................*
[more leafs here]
*............................................................................*
*Br 7 :wZ : TF1 *
*Entries : 234 : Total Size= 106553 bytes File Size = 3471 *
*Baskets : 4 : Basket Size= 32000 bytes Compression= 30.56 *
*............................................................................*
Then in my ROOT session:
root [2] tree->Draw("wZ:Z>>h","Vbias==300","goff")
for (Int_t i=1;i<5;i++) cout<<h->GetBinContent(i)<<endl ;
0
0
0
0
root [3] tree->Draw("wZ:Z","Vbias==300")
Error in <TTreeFormula::Compile>: Invalid Syntax "<"
Error in <ROOT::Math::BrentMinimizer1D::Minimize>: Search didn't converge
Info in <TSelectorDraw::AbortProcess>: Variable compilation failed: {wZ:Z,Vbias==300}
(long long) -1
root [6] tree->Draw("wZ->Eval(Z)","Vbias==300")
Error in <TTreeFormula::DefinedVariable>: Unknown method:Eval(Z) in TF1
Error in <TTreeFormula::Compile>: Bad numerical expression : "wZ.Eval(Z)"
Info in <TSelectorDraw::AbortProcess>: Variable compilation failed: {wZ->Eval(Z),Vbias==300}
(long long) -1
Another option would be, for me, defining a new wZ2 as:
TF1 *wZ2=new TF1("wZ2","0.003843*TMath::Sqrt( 1. + TMath::Power( (x-44.99)/0.1736 , 2) )",43.,45.5);
and try to use it on the variables of the tree, but it does not work either.
Finally, the option of calling a file like suggested here:
https://root-forum.cern.ch/t/use-own-tf1-in-ttree-draw/20959/2?u=mfglinux_gmail
is not flexible enough for me, since I want to test several combination of leafs
Please read tips for efficient and successful posting and posting code
_ROOT Version:6.24/08
_Platform:Ubuntu 22.04.2 LTS
_Compiler:gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04.1)