Skip to content
Snippets Groups Projects
Commit cfd48dc9 authored by Scott Snyder's avatar Scott Snyder Committed by Walter Lampl
Browse files

MuonReadoutGeometryR4: Speed up tube layer sorting.

MuonReadoutGeometryR4: Speed up tube layer sorting.

In the comparison function for MdtTubeLayer, don't bother calling the underlying
comparison functions if the objects being compared are identical.
GeoPhysValSorter, in particular, is expensive to call.
This speeds things up considerably, especially in the debug build.
parent ec983be5
No related branches found
No related tags found
No related merge requests found
......@@ -12,11 +12,18 @@ namespace MuonGMR4{
bool MdtTubeLayerSorter::operator()(const MdtTubeLayer& a, const MdtTubeLayer& b) const{
static const GeoTrf::TransformSorter trfSort{};
const int trfCmp = trfSort.compare(a.layerTransform(), b.layerTransform());
if (trfCmp) return trfCmp < 0;
static const GeoPhysVolSorter physSort{};
return physSort(a.m_layerNode, b.m_layerNode);
// Don't bother calling the underlying comparisons
// if the objects are the same. This saves a lot of time.
if (&a.layerTransform() != &b.layerTransform()) {
static const GeoTrf::TransformSorter trfSort{};
const int trfCmp = trfSort.compare(a.layerTransform(), b.layerTransform());
if (trfCmp) return trfCmp < 0;
}
if (a.m_layerNode != b.m_layerNode) {
static const GeoPhysVolSorter physSort{};
return physSort(a.m_layerNode, b.m_layerNode);
}
return false;
}
bool MdtTubeLayerSorter::operator()(const MdtTubeLayerPtr&a, const MdtTubeLayerPtr& b) const{
return (*this)(*a, *b);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment