Skip to content

Commit

Permalink
Fix "Called C++ object pointer is null" in DDCoreToDDXMLOutput::position
Browse files Browse the repository at this point in the history
  • Loading branch information
iarspider committed Sep 20, 2024
1 parent a86063d commit 114e49a
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions DetectorDescription/OfflineDBLoader/src/DDCoreToDDXMLOutput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -784,25 +784,27 @@ void DDCoreToDDXMLOutput::position(const TGeoVolume& parent,
xos << "<rChild name=\"" << childVolName << "\"/>" << std::endl;

const auto matrix = child.GetMatrix();
if (matrix != nullptr && !matrix->IsIdentity()) {
auto rot = matrix->GetRotationMatrix();
if (cms::rotation_utils::rotHash(rot) != cms::rotation_utils::identityHash) {
std::string rotNameStr = cms::rotation_utils::rotName(rot, context);
if (rotNameStr == "NULL") {
rotNameStr = child.GetName(); // Phys vol name
rotNameStr += parent.GetName();
cms::DDNamespace nameSpace(context);
cms::rotation_utils::addRotWithNewName(nameSpace, rotNameStr, rot);
if (matrix != nullptr) {
if (!matrix->IsIdentity()) {
auto rot = matrix->GetRotationMatrix();
if (cms::rotation_utils::rotHash(rot) != cms::rotation_utils::identityHash) {
std::string rotNameStr = cms::rotation_utils::rotName(rot, context);
if (rotNameStr == "NULL") {
rotNameStr = child.GetName(); // Phys vol name
rotNameStr += parent.GetName();
cms::DDNamespace nameSpace(context);
cms::rotation_utils::addRotWithNewName(nameSpace, rotNameStr, rot);
}
xos << "<rRotation name=\"" << rotNameStr << "\"/>" << std::endl;
}
xos << "<rRotation name=\"" << rotNameStr << "\"/>" << std::endl;
}
auto trans = matrix->GetTranslation();
using namespace cms_rounding;
xos << "<Translation x=\"" << roundIfNear0(trans[0]) << "*mm\"";
xos << " y=\"" << roundIfNear0(trans[1]) << "*mm\"";
xos << " z=\"" << roundIfNear0(trans[2]) << "*mm\"";
xos << "/>" << std::endl;
}
auto trans = matrix->GetTranslation();
using namespace cms_rounding;
xos << "<Translation x=\"" << roundIfNear0(trans[0]) << "*mm\"";
xos << " y=\"" << roundIfNear0(trans[1]) << "*mm\"";
xos << " z=\"" << roundIfNear0(trans[2]) << "*mm\"";
xos << "/>" << std::endl;
xos << "</PosPart>" << std::endl;
}

Expand Down

0 comments on commit 114e49a

Please sign in to comment.