TFormula error while importing GDML file in ROOT6

Hi all,

There is problem with TFormula when importing a GDML file with formulas, particularly with sqrt function.

input_line_50:2:114: error: called object type 'Double_t' (aka 'double') is not a function or function pointer
  ...TFormula____id3421474189592982042(Double_t *x,Double_t *p){ return (p[4](p[2]*p[2]+p[1]*p[1]+2*p[1]*p[4](p[2]*p[2]...
                                                                                                         ~~~~^
Error in <TFormula::Eval>: Can't find TFormula____id3421474189592982042 function prototype with arguments Double_t*,Double_t*
Error in <TFormula::DoEval>: Formula is invalid or not properly initialized - try calling TFormula::Compile
Fatal in <TGDMLParse::Value>: Got bad value nan from string '(sqrt(RICH_camera_radius*RICH_camera_radius+RICH_camera_magic_length*RICH_camera_magic_length+2*RICH_camera_magic_length*sqrt(RICH_camera_radius*RICH_camera_radius-((3*RICH_pmt_size+2*RICH_camera_gap_size)/2)*((3*RICH_pmt_size+2*RICH_camera_gap_size)/2))))'
aborting

See this attachment:

error.txt (13.1 KB)

The same GDML file and macro worked for ROOT 5.34.30
Is this a bug which has to be cured or I am doing something wrong?


ROOT Version: 6.12/06
Platform: Ubuntu 18.04
Compiler: gcc 7.3.0


Thank you.

Can you post an example reproducing the problem ?

Sorry, I should have attached the GDML at once.
Here it is:
rich_v18a_3e.gdml.txt (203.8 KB)

Thank you.

And how do you use this file ?

This is written in the error.txt file attached to the first message.

void Import_GDML(TString richGeoFilename = “rich_v18a_3e.gdml”)
{
TGeoManager *gdml = new TGeoManager(“gdml”, “FAIRGeom”);
gdml->Import(richGeoFilename);
gdml->CloseGeometry();
gdml->CheckOverlaps();
}

Ah ok sorry. I made the macro:

void Import_GDML(TString richGeoFilename = "rich_v18a_3e.gdml")
{
   TGeoManager *gdml = new TGeoManager("gdml", "FAIRGeom");
   gdml->Import(richGeoFilename);
   gdml->CloseGeometry();
   gdml->CheckOverlaps();
}

When I run it I get:

$ root Import_GDML.C
   --------------------------------------------------------------------
  | Welcome to ROOT 6.15/01                        http://root.cern.ch |
  |                                       (c) 1995-2018, The ROOT Team |
  | Built for macosx64                                                 |
  | From heads/master@v6-13-04-1003-g40f3fa9467, Aug 23 2018, 15:32:14 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'         |
   --------------------------------------------------------------------

root [0] 
Processing Import_GDML.C...
Info in <TGeoManager::TGeoManager>: Geometry gdml, FAIRGeom created
Info in <TGeoManager::Import>: Reading geometry from file: rich_v18a_3e.gdml
Info in <TGeoManager::TGeoManager>: Geometry GDMLImport, Geometry imported from GDML created
input_line_51:2:115: error: called object type 'Double_t' (aka 'double') is not a function or function pointer
Double_t TFormula____id17079278974850424428(Double_t *x,Double_t *p){ return (p[4](p[2]*p[2]+p[1]*p[1]+2*p[1]*p[4](p[2]*p[2]-((3*p[3]+2*p[...
                                                                                                              ~~~~^
Error in <TFormula::PrepareEvalMethod>: Can't compile function TFormula____id17079278974850424428 prototype with arguments Double_t*,Double_t*
Error in <TFormula::InputFormulaIntoCling>: Error compiling formula expression in Cling
Error in <TFormula::ProcessFormula>: Formula "([sqrt]([RICH_camera_radius]*[RICH_camera_radius]+[RICH_camera_magic_length]*[RICH_camera_magic_length]+2*[RICH_camera_magic_length]*[sqrt]([RICH_camera_radius]*[RICH_camera_radius]-((3*[RICH_pmt_size]+2*[RICH_camera_gap_size])/2)*((3*[RICH_pmt_size]+2*[RICH_camera_gap_size])/2))))" is invalid !
Error in <TFormula::Eval>: Formula is invalid and not ready to execute 
Fatal in <TGDMLParse::Value>: Got bad value nan from string '(sqrt(RICH_camera_radius*RICH_camera_radius+RICH_camera_magic_length*RICH_camera_magic_length+2*RICH_camera_magic_length*sqrt(RICH_camera_radius*RICH_camera_radius-((3*RICH_pmt_size+2*RICH_camera_gap_size)/2)*((3*RICH_pmt_size+2*RICH_camera_gap_size)/2))))'
aborting
[/Users/couet/git/roottrunk-bin/lib/libCore.so] DefaultErrorHandler(int, bool, char const*, char const*) /Users/couet/git/roottrunk/core/base/src/TError.cxx:192
[/Users/couet/git/roottrunk-bin/lib/libCore.so] ErrorHandler /Users/couet/git/roottrunk/core/base/src/TError.cxx:0
[/Users/couet/git/roottrunk-bin/lib/libCore.so] TObject::DoError(int, char const*, char const*, __va_list_tag*) const /Users/couet/git/roottrunk/core/base/src/TObject.cxx:848
[/Users/couet/git/roottrunk-bin/lib/libCore.so] TObject::Fatal(char const*, char const*, ...) const /Users/couet/git/roottrunk/core/base/src/TObject.cxx:912
[/Users/couet/git/roottrunk-bin/lib/libGdml.so] TGDMLParse::Value(char const*) const /Users/couet/git/roottrunk/geom/gdml/src/TGDMLParse.cxx:580
[/Users/couet/git/roottrunk-bin/lib/libGdml.so] TGDMLParse::Tube(TXMLEngine*, void*, void*) /Users/couet/git/roottrunk/geom/gdml/src/TGDMLParse.cxx:2561
[/Users/couet/git/roottrunk-bin/lib/libGdml.so] TGDMLParse::ParseGDML(TXMLEngine*, void*) /Users/couet/git/roottrunk/geom/gdml/src/TGDMLParse.cxx:281
[/Users/couet/git/roottrunk-bin/lib/libGdml.so] TGDMLParse::ParseGDML(TXMLEngine*, void*) /Users/couet/git/roottrunk/geom/gdml/src/TGDMLParse.cxx:339
[/Users/couet/git/roottrunk-bin/lib/libGdml.so] TGDMLParse::ParseGDML(TXMLEngine*, void*) /Users/couet/git/roottrunk/geom/gdml/src/TGDMLParse.cxx:339
[/Users/couet/git/roottrunk-bin/lib/libGdml.so] TGDMLParse::GDMLReadFile(char const*) /Users/couet/git/roottrunk/geom/gdml/src/TGDMLParse.cxx:148
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)
[/Users/couet/git/roottrunk-bin/lib/libCling.so] cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (no debug info)
[/Users/couet/git/roottrunk-bin/lib/libCling.so] cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (no debug info)
[/Users/couet/git/roottrunk-bin/lib/libCling.so] TCling::Calc(char const*, TInterpreter::EErrorCode*) /Users/couet/git/roottrunk/core/metacling/src/TCling.cxx:3152
[/Users/couet/git/roottrunk-bin/lib/libCore.so] TROOT::ProcessLineFast(char const*, int*) /Users/couet/git/roottrunk/core/base/src/TROOT.cxx:2406
[/Users/couet/git/roottrunk-bin/lib/libGeom.so] TGeoManager::Import(char const*, char const*, char const*) /Users/couet/git/roottrunk/geom/geom/src/TGeoManager.cxx:3859
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)
[/Users/couet/git/roottrunk-bin/lib/libCling.so] cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (no debug info)
[/Users/couet/git/roottrunk-bin/lib/libCling.so] cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (no debug info)
[/Users/couet/git/roottrunk-bin/lib/libCling.so] cling::MetaSema::actOnxCommand(llvm::StringRef, llvm::StringRef, cling::Value*) (no debug info)
[/Users/couet/git/roottrunk-bin/lib/libCling.so] cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&, cling::Value*) (no debug info)
[/Users/couet/git/roottrunk-bin/lib/libCling.so] cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) (no debug info)
[/Users/couet/git/roottrunk-bin/lib/libCling.so] cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (no debug info)
[/Users/couet/git/roottrunk-bin/lib/libCling.so] HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) /Users/couet/git/roottrunk/core/metacling/src/TCling.cxx:2133
[/Users/couet/git/roottrunk-bin/lib/libCling.so] TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) /Users/couet/git/roottrunk/core/metacling/src/TCling.cxx:2275
[/Users/couet/git/roottrunk-bin/lib/libCling.so] TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) /Users/couet/git/roottrunk/core/metacling/src/TCling.cxx:3122
[/Users/couet/git/roottrunk-bin/lib/libCore.so] TApplication::ExecuteFile(char const*, int*, bool) /Users/couet/git/roottrunk/core/base/src/TApplication.cxx:1161
[/Users/couet/git/roottrunk-bin/lib/libCore.so] TApplication::ProcessFile(char const*, int*, bool) /Users/couet/git/roottrunk/core/base/src/TApplication.cxx:1033
[/Users/couet/git/roottrunk-bin/lib/libCore.so] TApplication::ProcessLine(char const*, bool, int*) /Users/couet/git/roottrunk/core/base/src/TApplication.cxx:1006
[/Users/couet/git/roottrunk-bin/lib/libRint.so] TRint::ProcessLineNr(char const*, char const*, int*) /Users/couet/git/roottrunk/core/rint/src/TRint.cxx:761
[/Users/couet/git/roottrunk-bin/lib/libRint.so] TRint::Run(bool) /Users/couet/git/roottrunk/core/rint/src/TRint.cxx:421
[/Users/couet/git/roottrunk-bin/bin/root.exe] main /Users/couet/git/roottrunk/main/src/rmain.cxx:32
[/usr/lib/system/libdyld.dylib] start (no debug info)

May be @agheata has an idea about this.

Dear Egor, I have fixed this in the master. We resolve GDML constants/variables in expressions by feeding them to TFormula. In this process we treat variables as function parameters and we have to surround them in the expression string with square brackets. The procedure was not working if the expression contained function calls such as sin/cos/sqrt, because these names were treated as normal variables.
Please have a quick check and let me know if the problem is fixed for you.

Thank you, Andrei.

Your fix solves the problem.

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