AIDASoft / DD4hep

Detector Description Toolkit for High Energy Physics
http://dd4hep.cern.ch
GNU Lesser General Public License v3.0
49 stars 95 forks source link

XMLLoader can not handle compact filename without the path #1039

Closed atolosadelgado closed 1 year ago

atolosadelgado commented 1 year ago

Hi,

It seems XMLLoader cannot handle a local file like "compact_file.xml", but only "./compact_file.xml" (Thanks @andresailer for spotting the problem)

If the "./" is missing, it prefix the filename with the wrong path $PWD/file: , which leads to not finding the file.

Then, if file path is provided, it works as expected:

ddsim --compactFile $FCCDETECTORS/Detector/DetCommon/compact/Box.xml --runType run --macroFile overlap.mac --part.userParticleHandler=''
.....................[a lot of info here].............................
Geant4UIManager  INFO  ++ Executing UI setup:overlap.mac
Running geometry overlaps check...
Checking overlaps for volume Box0_vol_0:0 (G4Box) ... OK! 
Geometry overlaps check completed !

Geant4Kernel     INFO  ++ Terminate Geant4 and delete associated actions.
DDSim            INFO DDSim            INFO  Total Time:   5.46 s (User), 1.43 s (System)

If we create a symbolic link and do not provide file path, it fails with the following output

$ ln -s $FCCDETECTORS/Detector/DetCommon/compact/Box.xml Box.xml
$ ln -s $FCCDETECTORS/Detector/DetCommon/compact/elements.xml elements.xml
$ ln -s $FCCDETECTORS/Detector/DetCommon/compact/materials.xml materials.xml

$ ddsim --compactFile Box.xml --runType run --macroFile overlap.mac --part.userParticleHandler=''
PersistencyIO    INFO  +++ Set Streamer to dd4hep::OpaqueDataBlock
Info in <TGeoManager::TGeoManager>: Geometry default, Detector Geometry created
Info in <TGeoNavigator::BuildCache>: --- Maximum geometry depth set to 100
XMLLoader        INFO  +++ Processing XML file: file:Box.xml
XercesC          FATAL +++ FATAL Error at file "", Line 0 Column: 0 Message:unable to open primary document entity '/afs/cern.ch/user/a/atolosad/file:Box.xml'
Traceback (most recent call last):
  File "/cvmfs/sw.hsf.org/spackages6/dd4hep/1.22/x86_64-centos7-gcc11.2.0-opt/7peyh/bin/ddsim", line 25, in <module>
    RUNNER.run()
  File "/cvmfs/sw.hsf.org/spackages6/dd4hep/1.22/x86_64-centos7-gcc11.2.0-opt/7peyh/lib/python3.9/site-packages/DDSim/DD4hepSimulation.py", line 312, in run
    kernel.loadGeometry(str("file:" + compactFile))
cppyy.gbl.std.runtime_error: void dd4hep::sim::Geant4Kernel::loadGeometry(const string& compact_file) =>
    runtime_error: dd4hep: Failed to parse the XML file file:Box.xml [Invalid XML ROOT handle]
dd4hep: while parsing file:Box.xml
dd4hep: with plugin:DD4hep_XMLLoader

Thank you for your time.

Best, Alvaro

MarkusFrankATcernch commented 1 year ago

@atolosadelgado @andresailer This must be ddsim specific. For other applications this seems to work. e.g. $> geoDisplay -compact SiD.xml behaves as expected.