Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G4GDML: VALIDATION ERROR! when parsing Gdml in Geant4 #32

Open
lobis opened this issue Mar 19, 2021 · 6 comments
Open

G4GDML: VALIDATION ERROR! when parsing Gdml in Geant4 #32

lobis opened this issue Mar 19, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@lobis
Copy link
Contributor

lobis commented Mar 19, 2021

I have seen the following errors when trying to parse the geometry with Geant4. To parse the geometry I have just done:

// Geant4 code
#include "iostream"
#include "G4GDMLParser.hh"

using namespace std;

void parseGdml(const string &filename = "Setup.gdml") {
    G4GDMLParser parser;
    cout << "Reading from '" << filename << "'" << endl;
    parser.Read(filename.c_str());
}

int main() {
    cout << "Starting..." << endl;
    parseGdml();
}

Which should load the geometry from a gdml file. They error is G4GDML: VALIDATION ERROR!. I have included a few lines here:

...
G4GDML: VALIDATION ERROR! no declaration found for element 'physvol' at line: 4165
G4GDML: VALIDATION ERROR! attribute 'name' is not declared for element 'physvol' at line: 4165
G4GDML: VALIDATION ERROR! no declaration found for element 'volumeref' at line: 4166
G4GDML: VALIDATION ERROR! attribute 'ref' is not declared for element 'volumeref' at line: 4166
G4GDML: VALIDATION ERROR! no declaration found for element 'position' at line: 4167
G4GDML: VALIDATION ERROR! attribute 'x' is not declared for element 'position' at line: 4167
G4GDML: VALIDATION ERROR! attribute 'y' is not declared for element 'position' at line: 4167
...

Looks like they format is not compatible with the Geant4 parser? We have encountered this in the past, when I build geometries I usually test it using the root event visualizer but after doing some simulation we find additional errors. In the case of this geometry, it is correctly read from root via TGeoManager::Import("Setup.gdml");. I have tried modifying a few things in the .gdml that I could think of but no luck.

I attach a zip of the .gdml geometry (it is the one in the gdml-script test called babyiaxo) Setup.zip

@altavir
Copy link
Member

altavir commented Mar 19, 2021

The error does not make any sense because required elements are present at given lines. My only suspects are the square brackets I use in names, I am not sure if home-made parser in the GEANT is able to understand them. Could you check if it will work with a small reproducer with square bracket in names?

Also maybe @Zelenyy has some insight on that?

@altavir
Copy link
Member

altavir commented Mar 19, 2021

The first problem: head gdml tag must include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd" (#33)

@altavir
Copy link
Member

altavir commented Mar 19, 2021

The second problem: empty names are not allowed, this probably occurs only for positions and rotations. (#34)

@Zelenyy
Copy link
Member

Zelenyy commented Mar 19, 2021

@lobis You shouldn't define in materials tag than materials which pre-defined in GEANT4 (such as G4_AIR) and should define only unknown materials. Or you must re-define pre-defined materials fully.

@altavir
Copy link
Member

altavir commented Mar 19, 2021

#35 as well

@lobis
Copy link
Contributor Author

lobis commented Mar 19, 2021

@lobis You shouldn't define in materials tag than materials which pre-defined in GEANT4 (such as G4_AIR) and should define only unknown materials. Or you must re-define pre-defined materials fully.

I deliberately redefined them in a file called NIST.xml which is built by retrieving the definitions from Geant, so they should match exactly. I need to do this in order to visualize the geometries with root, because even though Geant recognizes this materials when performing simulations, the root TGeoManager does not, an paints everything gray, which makes debugging difficult. If you have a better solution please advice.

Edit: Now that I read your comment again I see I probably have not defined the NIST materials fully, I will look into this, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants