@@ -36,7 +36,7 @@ See LICENSE.md for further details
3636 * Use the Ok() method to check if the opening went ok.
3737 * */
3838GateXMLDocument::GateXMLDocument (const G4String& filename) :
39- m_ok(false ), m_reset(true )
39+ m_ok(false ), m_reset(true ), m_filename(filename)
4040
4141//
4242// SJ COMMENTS## : read the file by using a messenger mechanism
@@ -305,7 +305,28 @@ void GateXMLDocument::SetState(GateXMLDocumentState state)
305305 m_cur = state.cur ;
306306 m_reset = state.reset ;
307307}
308-
308+
309+ // geant4 v11 replaces some properties name by new one
310+ // We propose suggestion for replacements in error message.
311+ const G4String suggest_values_for_keys (const G4String& key)
312+ {
313+ if (key == " FASTTIMECONSTANT" )
314+ return " SCINTILLATIONTIMECONSTANT1" ;
315+ else if ( key == " YIELDRATIO" )
316+ return " SCINTILLATIONYIELD1" ;
317+ else if ( key == " FASTCOMPONENT" )
318+ return " SCINTILLATIONCOMPONENT1" ;
319+ return " ?" ;
320+
321+ }
322+
323+
324+
325+ const G4String &GateXMLDocument::GetFilename () const
326+ {
327+ return m_filename;
328+ }
329+
309330G4MaterialPropertiesTable* ReadMaterialPropertiesTable (GateXMLDocument* doc)
310331{
311332 G4MaterialPropertiesTable* table = 0 ;
@@ -328,7 +349,21 @@ G4MaterialPropertiesTable* ReadMaterialPropertiesTable(GateXMLDocument* doc)
328349 G4String unitstr = " 1 " + doc->GetProperty (" unit" );
329350 value *= G4UIcmdWithADoubleAndUnit::GetNewDoubleValue (unitstr.c_str ());
330351 }
331- table->AddConstProperty (property.c_str (), value);
352+
353+ auto list_of_known_properties_key = &table->GetMaterialConstPropertyNames ();
354+ if (std::count (list_of_known_properties_key->begin (), list_of_known_properties_key->end (), property))
355+ {
356+ table->AddConstProperty (property.c_str (), value);
357+ }
358+ else
359+ {
360+ G4cout << " Unknown property '" << property << " ' in xml file '" << doc->GetFilename () << " '. Abort simulation." << G4endl;
361+ G4cout << " Suggestion: property '" << property << " ' can be replaced by '" << suggest_values_for_keys (property) << " '" << G4endl;
362+ exit (-1 );
363+
364+ }
365+
366+
332367 }
333368 else if (doc->GetName () == " propertyvector" )
334369 {
@@ -358,7 +393,22 @@ G4MaterialPropertiesTable* ReadMaterialPropertiesTable(GateXMLDocument* doc)
358393 G4double value = G4UIcmdWithADouble::GetNewDoubleValue (valuestr.c_str ());
359394 vector->InsertValues (energy*energyunit, value*unit);
360395 }
361- table->AddProperty (property.c_str (), vector);
396+
397+
398+ auto list_of_known_properties_key = &table->GetMaterialPropertyNames ();
399+ if (std::count (list_of_known_properties_key->begin (), list_of_known_properties_key->end (), property))
400+ {
401+ table->AddProperty (property.c_str (), vector);
402+ }
403+ else
404+ {
405+ G4cout << " Unknown propertyvector '" << property << " ' in xml file '" << doc->GetFilename () << " '. Abort simulation." << G4endl;
406+ G4cout << " Suggestion: propertyvector '" << property << " ' can be replaced by '" << suggest_values_for_keys (property) << " '" << G4endl;
407+ exit (-1 );
408+ }
409+
410+
411+
362412 doc->Leave ();
363413 }
364414 }
0 commit comments