Error in <HandleInterpreterException>: Error evaluating expression

Hi experts
I have an output root file which I try to fill with two TTrees using the code attached below.

The code compiles and runs successfully and I can see the TTrees in the TBrowser window and also the Branches make complete sense. (Please see the screenshot). In addition to my TTrees, I see some additional histograms, which I never asked for.

Now when I try to print the contents of my root file, I get this:

root [4] .ls
TFile**		RecoEfficiency.root
 TFile*		RecoEfficiency.root
  KEY: TDirectoryFile	RecoEfficiency;1	RecoEfficiency (RecoEfficiency) folder
  KEY: TH1D	FRH;1	FRH
  KEY: TH1D	FRV;1	FRV
  KEY: TH1D	rICKR;1	rICKR
  KEY: TH1D	rICKI;1	rICKI
  KEY: TH1D	PreC;1	PreC
  KEY: TH1D	PostC;1	PostC
  KEY: TH1D	PostO;1	PostO
  KEY: TH1D	PreD;1	PreD
  KEY: TH1D	PostDO;1	PostDO
  KEY: TH1D	ER;1	ER

Basically I’m not able to see the TTrees which I see in the TBrowser window. If I try , I get this error:

-bash-4.1$ root -l RecoEfficiency.root
root [0]
Attaching file RecoEfficiency.root as _file0...
(TFile *) 0x31808c0
root [1] TCanvas c1;
root [2] Matchtree->Draw("MC_Track_StartX_det>>h0");
input_line_67:2:3: error: use of undeclared identifier 'Matchtree'
 (Matchtree->Draw("MC_Track_StartX_det>>h0"))
  ^
Error in <HandleInterpreterException>: Error evaluating expression (Matchtree->Draw("MC_Track_Length>>h0")).
Execution of your code was aborted.

I have no idea what’s going on.
When I use the TBrowser window and click on the TTree while I use the above command, only then will the TTree appear in the canvas. I’m just thinking why does it have to depend on the TBrowser to work at all?

_ROOT Version:6.12/06
_Platform:Linux
_Compiler:gcc 7.3.0

RecoEfficiency_module.cc (14.8 KB)


This is not the expected behavior and there may be something unusual about the file. Can you share the ROOT file so we can look into this further?

Thanks for your reply @pcanal. The file is about 14 MB in size so I uploaded it to google drive:

https://drive.google.com/open?id=117ye3cc8BaKBwHAc7-rVZuqVf6r-tkKd

The unusual feature is that the TTree is stored in a subdirectory, which (confusingly) has the same name as the file:

$ root.exe -b -l ~/Downloads/RecoEfficiency.root 
root [0] 
Attaching file /Users/pcanal/Downloads/RecoEfficiency.root as _file0...
(TFile *) 0x7fba7deb5d60
root [1] gFile->ls()
TFile**		/Users/pcanal/Downloads/RecoEfficiency.root	
 TFile*		/Users/pcanal/Downloads/RecoEfficiency.root	
  KEY: TDirectoryFile	RecoEfficiency;1	RecoEfficiency (RecoEfficiency) folder
  KEY: TH1D	FRH;1	FRH
  KEY: TH1D	FRV;1	FRV
  KEY: TH1D	rICKR;1	rICKR
  KEY: TH1D	rICKI;1	rICKI
  KEY: TH1D	PreC;1	PreC
  KEY: TH1D	PostC;1	PostC
  KEY: TH1D	PostO;1	PostO
  KEY: TH1D	PreD;1	PreD
  KEY: TH1D	PostDO;1	PostDO
  KEY: TH1D	ER;1	ER
root [2] gFile->cd("RecoEfficiency")
(bool) true
root [3] gDirectory->ls()
TDirectoryFile*		RecoEfficiency	RecoEfficiency (RecoEfficiency) folder
 KEY: TTree	Matchtree;1	Matchtree
 KEY: TTree	RecoTracktree;1	RecoTracktree
root [4] Matchtree->Print()
******************************************************************************
*Tree    :Matchtree : Matchtree                                              *
*Entries :    91395 : Total =        12846428 bytes  File  Size =    8255543 *
*        :          : Tree compression factor =   1.56                       *
******************************************************************************
*Br    0 :MC_Track_StartX_det : MC_Track_StartX_det/D                        *
*Entries :    91395 : Total  Size=     734082 bytes  File Size  =     663981 *
*Baskets :       23 : Basket Size=      32000 bytes  Compression=   1.10     *

Cheers,
Philippe.

That makes sense. Thank you very much and have a nice day @pcanal !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.