@@ -81,12 +81,9 @@ bool G4World::createG4Material(const std::shared_ptr<GMaterial> &gmaterial) {
8181 hasOpticalProperties = true ;
8282 };
8383
84- auto addConstantProperty = [&](const char *propertyName, double value) {
85- // default values initialied to zero
86- if (value == 0 ) { return ; }
87-
84+ auto addConstantProperty = [&](const char *propertyName, double value, bool isSet) {
85+ if (!isSet) { return ; }
8886 materialPropertiesTable->AddConstProperty (propertyName, value);
89-
9087 hasOpticalProperties = true ;
9188 };
9289
@@ -100,15 +97,20 @@ bool G4World::createG4Material(const std::shared_ptr<GMaterial> &gmaterial) {
10097 addProperty (" SCINTILLATIONCOMPONENT2" , gmaterial->getSlowComponent ());
10198
10299 // scalar properties
103- addConstantProperty (" SCINTILLATIONYIELD" , gmaterial->getScintillationYield ());
104- addConstantProperty (" RESOLUTIONSCALE" , gmaterial->getResolutionScale ());
105-
106- addConstantProperty (" SCINTILLATIONTIMECONSTANT1" , gmaterial->getFasttimeConstant () * CLHEP ::ns);
107- addConstantProperty (" SCINTILLATIONTIMECONSTANT2" , gmaterial->getSlowtimeConstant () * CLHEP ::ns);
108- addConstantProperty (" SCINTILLATIONYIELD1" , gmaterial->getYieldratio ());
100+ addConstantProperty (" SCINTILLATIONYIELD" , gmaterial->getScintillationYield (),
101+ gmaterial->hasScintillationYield ());
102+ addConstantProperty (" RESOLUTIONSCALE" , gmaterial->getResolutionScale (),
103+ gmaterial->hasResolutionScale ());
104+
105+ addConstantProperty (" SCINTILLATIONTIMECONSTANT1" , gmaterial->getFasttimeConstant () * CLHEP ::ns,
106+ gmaterial->hasFasttimeConstant ());
107+ addConstantProperty (" SCINTILLATIONTIMECONSTANT2" , gmaterial->getSlowtimeConstant () * CLHEP ::ns,
108+ gmaterial->hasSlowtimeConstant ());
109+ addConstantProperty (" SCINTILLATIONYIELD1" , gmaterial->getYieldratio (),
110+ gmaterial->hasYieldratio ());
109111
110112 double getBirksConstant = gmaterial->getBirksConstant ();
111- if (getBirksConstant != 0 ) {
113+ if (gmaterial-> hasBirksConstant () ) {
112114 g4materialsMap[materialName]->GetIonisation ()->SetBirksConstant (getBirksConstant);
113115 hasOpticalProperties = true ;
114116 }
0 commit comments