Skip to content

Commit

Permalink
Add dichroic properties to gdml
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesJieranShen committed Feb 27, 2024
1 parent 1b72e97 commit 2834cd1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/geo/src/gdml/GDMLWriteSolids.cc
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,42 @@ void GDMLWriteSolids::OpticalSurfaceWrite(xercesc::DOMElement* solElement, const
if (surf->GetMaterialPropertiesTable()) {
PropertyWrite(optElement, surf);
}
const G4Physics2DVector* const dichroic_vector = const_cast<G4OpticalSurface*>(surf)->GetDichroicVector();
xercesc::DOMElement* propElement;
if (dichroic_vector) {
propElement = NewElement("dichroic_data");
size_t length_x = dichroic_vector->GetLengthX();
size_t length_y = dichroic_vector->GetLengthY();
propElement->setAttributeNode(NewAttribute("x_length", length_x));
propElement->setAttributeNode(NewAttribute("y_length", length_y));
xercesc::DOMElement* x_element = NewElement("x");
xercesc::DOMElement* y_element = NewElement("y");
std::ostringstream xvalues;
std::ostringstream yvalues;
for (size_t i = 0; i < length_x; i++) {
if (i != 0) xvalues << " ";
xvalues << dichroic_vector->GetX(i);
}
x_element->setAttributeNode(NewAttribute("values", xvalues.str()));
for (size_t i = 0; i < length_y; i++) {
if (i != 0) yvalues << " ";
yvalues << dichroic_vector->GetY(i);
}
y_element->setAttributeNode(NewAttribute("values", yvalues.str()));
propElement->appendChild(x_element);
propElement->appendChild(y_element);
xercesc::DOMElement* data = NewElement("data");
std::ostringstream data_values;
for (size_t i = 0; i < length_x; i++) {
for (size_t j = 0; j < length_y; j++) {
if (i != 0 || j != 0) data_values << " ";
data_values << dichroic_vector->GetValue(i, j);
}
}
data->setAttributeNode(NewAttribute("values", data_values.str()));
propElement->appendChild(data);
optElement->appendChild(propElement);
}

solElement->appendChild(optElement);
}
Expand Down

0 comments on commit 2834cd1

Please sign in to comment.