Skip to content

Commit

Permalink
Add nullptr check to keep working with newer DD4hep
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Feb 15, 2024
1 parent 877be61 commit cfea26e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/DDPlanarMeasLayer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,19 @@ DDPlanarMeasLayer::DDPlanarMeasLayer(dd4hep::rec::ISurface* surf, Double_t Bz,
auto detElement = static_cast<dd4hep::rec::Surface*>(surf)->detElement();
if(detElement.isValid()) {
try {
auto* ext = detElement.extension<dd4hep::rec::DoubleParameters>();
fSortingPolicy = ext->doubleParameters.at("SortingPolicy")/dd4hep::mm + epsilon * count++;
streamlog_out(DEBUG3) << "Found manual sorting policy for " << detElement.path()
<< " value [mm] " << fSortingPolicy
<< std::endl;
// DD4hep changes behavior slightly here at soe point. For more details
// see https://github.com/AIDASoft/DD4hep/issues/1229
auto* ext = detElement.extension<dd4hep::rec::DoubleParameters>(false);
if (ext) {
fSortingPolicy = ext->doubleParameters.at("SortingPolicy")/dd4hep::mm + epsilon * count++;
streamlog_out(DEBUG3) << "Found manual sorting policy for " << detElement.path()
<< " value [mm] " << fSortingPolicy
<< std::endl;
} else {
streamlog_out(DEBUG3) << "Extension DoubleParameters not found for DetElement:"
<< detElement.path()
<< std::endl;
}
} catch(std::runtime_error &) {
streamlog_out(DEBUG3) << "Extension DoubleParameters not found for DetElement:"
<< detElement.path()
Expand Down

0 comments on commit cfea26e

Please sign in to comment.