Skip to content

Commit

Permalink
Keep existing behavior with latest version of DD4hep (#16)
Browse files Browse the repository at this point in the history
* Add nullptr check to keep working with newer DD4hep

---------

Co-authored-by: Andre Sailer <[email protected]>
  • Loading branch information
tmadlener and andresailer authored Feb 15, 2024
1 parent ac2b67f commit bba1b39
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 some 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 bba1b39

Please sign in to comment.