Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions DDRec/include/DDRec/SurfaceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,13 @@ namespace dd4hep {
SurfaceManager(const Detector& theDetector);

/// No default constructor
#if defined(G__ROOT)
SurfaceManager() = default ;
#else
SurfaceManager() = delete ;
#endif

~SurfaceManager() = default;
SurfaceManager(const SurfaceManager&) = delete;
SurfaceManager& operator=(const SurfaceManager&) = delete;
SurfaceManager(SurfaceManager&&) = default;
SurfaceManager& operator=(SurfaceManager&&) = default;
SurfaceManager(SurfaceManager&&) = delete;
SurfaceManager& operator=(SurfaceManager&&) = delete;


/** Get the maps of all surfaces associated to the given detector or
Expand All @@ -68,9 +64,11 @@ namespace dd4hep {


/// initialize all known surface maps
void initialize(const Detector& theDetector) ;
void initialize(const Detector& theDetector) const;

SurfaceMapsMap _map ;
mutable SurfaceMapsMap _map{} ;
const Detector& _theDetector ;
mutable std::once_flag _initializedFlag{} ;
};

} /* namespace rec */
Expand Down
10 changes: 7 additions & 3 deletions DDRec/src/SurfaceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,27 @@
#include "DDRec/SurfaceHelper.h"
#include "DD4hep/VolumeManager.h"
#include "DD4hep/Detector.h"
#include "DD4hep/Printout.h"

#include <sstream>

namespace dd4hep {
namespace rec {

SurfaceManager::SurfaceManager(const Detector& theDetector){
SurfaceManager::SurfaceManager(const Detector& theDetector) : _theDetector(theDetector) {

// have to make sure the volume manager is populated once in order to have
// the volumeIDs attached to the DetElements

VolumeManager::getVolumeManager(theDetector);

initialize(theDetector) ;
}


const SurfaceMap* SurfaceManager::map( const std::string& name ) const {

std::call_once( _initializedFlag, &SurfaceManager::initialize, this, _theDetector ) ;

SurfaceMapsMap::const_iterator it = _map.find( name ) ;

if( it != _map.end() ){
Expand All @@ -44,7 +46,7 @@ namespace dd4hep {
return nullptr ;
}

void SurfaceManager::initialize(const Detector& description) {
void SurfaceManager::initialize(const Detector& description) const {

for(const auto& type : description.detectorTypes()) {

Expand Down Expand Up @@ -75,6 +77,8 @@ namespace dd4hep {
}
}

printout(INFO,"SurfaceManager","%s" , description.extension<SurfaceManager>()->toString().c_str() );

}

std::string SurfaceManager::toString() const {
Expand Down
2 changes: 1 addition & 1 deletion DDRec/src/plugins/createSurfaceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ namespace dd4hep{
static long createSurfaceManager(Detector& description, int /*argc*/, char** /*argv*/) {

printout(INFO,"InstallSurfaceManager","**** running plugin InstallSurfaceManager ! " );
printout(INFO,"InstallSurfaceManager","**** the map of surfaces will be created on first access ! " );

description.addExtension<SurfaceManager>( new SurfaceManager(description) ) ;

printout(INFO,"InstallSurfaceManager","%s" , description.extension<SurfaceManager>()->toString().c_str() );

return 1;
}
Expand Down
Loading