CINT problem, root 5.18.00

Hello,

I’m experimenting an issue with my recently installed root-5.18.00.
Executing a source file with .x always fails while a copy/paste from the source to CINT works.

Herewith an exemple with a root file containing a Tree. I also attach the source file which is assumed to load the root file and to define a TCut. The cut seems to be undefined when I execute the source with .x :

Thanks in advance for your help !

Best,
Gurvan

user@localhost /mnt/data/test $ root


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 5.18/00 16 January 2008 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      [root.cern.ch](http://root.cern.ch)            *
    
  •                                     *
    

ROOT 5.18/00 (trunk@21744, Apr 15 2008, 19:41:00 on linux)

CINT/ROOT C/C++ Interpreter version 5.16.29, Jan 08, 2008
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .x AnalysePhotoZ.C
root [1] verifSimul->Draw(“redshiftgen”, *simulcut);
Error: Symbol simulcut is not defined in current scope (tmpfile):1:
Error: Illegal pointer operation (tovalue) (tmpfile):1:
*** Interpreter error recovered ***
root [2] .q
user@localhost /mnt/data/test $ root


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 5.18/00 16 January 2008 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      [root.cern.ch](http://root.cern.ch)            *
    
  •                                     *
    

ROOT 5.18/00 (trunk@21744, Apr 15 2008, 19:41:00 on linux)

CINT/ROOT C/C++ Interpreter version 5.16.29, Jan 08, 2008
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] gROOT->Reset();
root [1] TTree* tree;
root [2] TFile* f = new TFile("/mnt/data/test/verifSimul.root");
root [3] TCut* simulcut = new TCut(“simulcut”, “simuldata==0”);
root [4] verifSimul->Draw(“redshiftgen”, *simulcut);
TCanvas::MakeDefCanvas: created default TCanvas with name c1
root [5] .q
AnalysePhotoZ.C (176 Bytes)

Hi,

void AnalysePhotoZ(){ gROOT->Reset();Never ever call gROOT->Reset inside a function. This unloads all the dictionary and interpreter information since the last time it got call (i.e. usually the ROOT startup). This includes the information about the function you are executing (i.e. the result are, as they say, implementation dependent :slight_smile:).

More importantly for you problem, you have:void AnalysePhotoZ(){ .... TCut* simulcut = new TCut("simulcut", "simuldata==0"); }so the variable simulcut goes out of scope at the end of the function and you can notuse it afterward (the TCut object you create is still allocated but you no longer have access to it).

If you want you TCut to still be available use (for example):

[code]TCut* simulcut = 0;
void AnalysePhotoZ(){

TTree* tree;
TFile* f = new TFile("/mnt/data/test/verifSimul.root");

simulcut = new TCut(“simulcut”, “simuldata==0”);
}
[/code]

Cheers,
Philippe.

Hi,

Ok, thank you very much !

Cheers,
Gurvan