Skip to content

Commit

Permalink
add more comments to the GeoHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
SanghyunKo committed Jul 22, 2024
1 parent 4c861e3 commit 9eab1d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions DDCore/include/DD4hep/GeoHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ namespace dd4hep {

protected:
bool m_propagateRegions { false };

/// actual container with std::vector (preserves order)
std::map<int, std::vector<const TGeoNode*> >* m_data { nullptr };
/// redundant container with std::set (for lookup purpose)
std::map<int, std::set<const TGeoNode*> >* m_set_data { nullptr };

std::map<const TGeoNode*, std::vector<TGeoNode*> >* m_daughters { nullptr };
/// Internal helper to collect geometry information from traversal
GeoHandler& i_collect(const TGeoNode* parent,
Expand Down
5 changes: 5 additions & 0 deletions DDCore/src/GeoHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ detail::GeoHandler::~GeoHandler() {
}

std::map<int, std::vector<const TGeoNode*> >* detail::GeoHandler::release() {
/// release the std::vector geometry container (preserves order)
std::map<int, std::vector<const TGeoNode*> >* d = m_data;
m_data = nullptr;

/// the std::set container (for lookup purpose) is not needed anymore, so delete it
/// the container is always present since the call of the constructor
/// we never expect to call release() twice (will release nullptr)
delete m_set_data;
m_set_data = nullptr;

Expand Down Expand Up @@ -162,6 +166,7 @@ detail::GeoHandler& detail::GeoHandler::i_collect(const TGeoNode* /* parent */,
}
}
/// Collect the hierarchy of placements
/// perform lookup using std::set::emplace (faster than std::find for the large number of geometries)
if ( (*m_set_data)[level].emplace(current).second ) {
(*m_data)[level].push_back(current);
}
Expand Down

0 comments on commit 9eab1d4

Please sign in to comment.