Problem 2143 - Diffrent OpticalSurface with same MaterialPropertiesTable will not be writed to GDML file in correct way.
Summary: Diffrent OpticalSurface with same MaterialPropertiesTable will not be writed...
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: persistency/gdml (show other problems)
Version: 10.5
Hardware: All Linux
: P4 minor
Assignee: Witold.Pokorski
URL:
Depends on:
Blocks:
 
Reported: 2019-03-01 12:16 CET by Binbin Qi
Modified: 2019-04-15 09:06 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Binbin Qi 2019-03-01 12:16:13 CET
When I difined three diffrent G4OpticalSurface called opQuartzAlUpSurface, opQuartzAlDownSurface and opQuartzAlSideSurface. And they have a same MaterialPropertiesTable. The coed showed as bellow:

  463   G4double ephoton[num] = {0.4*eV, 6.02*eV};
  464   G4double reflecAbsorbtion[2] ={0.99, 0.99};
  465   G4MaterialPropertiesTable* SMPT_Absorbtion = new G4MaterialPropertiesTable();
  466   SMPT_Absorbtion ->AddProperty("REFLECTIVITY", ephoton, reflecAbsorbtion, 2);
  467 
  468   opQuartzAlUpSurface   ->SetMaterialPropertiesTable(SMPT_Absorbtion);
  469   opQuartzAlDownSurface ->SetMaterialPropertiesTable(SMPT_Absorbtion);
  470   opQuartzAlSideSurface ->SetMaterialPropertiesTable(SMPT_Absorbtion);

And When I use G4GDMLParser to write these structure to GDML file, I found there are three same matrixs named REFLECTIVITYox3bc7a70 in GDML file:

   9     <matrix coldim="2" name="REFLECTIVITY0x3bc7a70" values="4e-07 0.99 6.02e-06 0.99"/>
  10     <matrix coldim="2" name="REFLECTIVITY0x3bc7a70" values="4e-07 0.99 6.02e-06 0.99"/>
  11     <matrix coldim="2" name="REFLECTIVITY0x3bc7a70" values="4e-07 0.99 6.02e-06 0.99"/>


Suggested fix:
 //G4GDMLWriteMaterials.hh
 81    std::vector<const G4Isotope*> isotopeList;
 82    std::vector<const G4Element*> elementList;
 83    std::vector<const G4Material*> materialList;
 84    std::vector<const G4PhysicsOrderedFreeVector*> propertyList; //add
 85    xercesc::DOMElement* materialsElement;
 86 };

 //G4GDMLWriteMaterials.cc

 290 void G4GDMLWriteMaterials::MaterialsWrite(xercesc::DOMElement* element)
 291 {
 292 #ifdef G4VERBOSE
 293    G4cout << "G4GDML: Writing materials..." << G4endl;
 294 #endif
 295    materialsElement = NewElement("materials");
 296    element->appendChild(materialsElement);                                                 
 297 
 298    isotopeList.clear();
 299    elementList.clear();
 300    materialList.clear();
 301    propertyList.clear();  //add
 302 }

 209 void G4GDMLWriteMaterials::PropertyVectorWrite(const G4String& key,
 210                            const G4PhysicsOrderedFreeVector* const pvec)
 211 {
 212    for (size_t i=0; i<propertyList.size(); i++)   // Check if property is
 213    {                                             // already in the list!
 214      if (propertyList[i] == pvec)  { return; }
 215    }
 216    propertyList.push_back(pvec);
 217 
 218    const G4String matrixref = GenerateName(key, pvec);
 219    xercesc::DOMElement* matrixElement = NewElement("matrix");
 220    matrixElement->setAttributeNode(NewAttribute("name", matrixref));
 221    matrixElement->setAttributeNode(NewAttribute("coldim", "2"));
 222    std::ostringstream pvalues;
 223    for (size_t i=0; i<pvec->GetVectorLength(); i++)
 224    {
 225        if (i!=0)  { pvalues << " "; }
 226        pvalues << pvec->Energy(i) << " " << (*pvec)[i];
 227    }
 228    matrixElement->setAttributeNode(NewAttribute("values", pvalues.str()));
 229 
 230    defineElement->appendChild(matrixElement);
 231 }
Comment 1 Witold.Pokorski 2019-04-15 09:06:40 CEST
Thanks for the fixes. This is now in the patch release.