From a3c3fa1cf24c1d96cc296123b5292d421fd3b1f6 Mon Sep 17 00:00:00 2001
From: Frank Gaede <frank.gaede@desy.de>
Date: Mon, 11 May 2015 14:12:47 +0000
Subject: [PATCH] added SurfaceManager::toString()
---
DDRec/include/DDRec/SurfaceManager.h | 5 +++++
DDRec/src/SurfaceManager.cpp | 29 +++++++++++++++++++++-------
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/DDRec/include/DDRec/SurfaceManager.h b/DDRec/include/DDRec/SurfaceManager.h
index 7700e4c20..19466aac2 100644
--- a/DDRec/include/DDRec/SurfaceManager.h
+++ b/DDRec/include/DDRec/SurfaceManager.h
@@ -2,6 +2,7 @@
#define DDRec_SurfaceManager_H_
#include "DDRec/Surface.h"
+#include <string>
namespace DD4hep {
namespace DDRec {
@@ -33,6 +34,10 @@ namespace DD4hep {
*/
const SurfaceMap* map( const std::string name ) const ;
+
+ ///create a string with all available maps and their size (number of surfaces)
+ std::string toString() const ;
+
protected :
diff --git a/DDRec/src/SurfaceManager.cpp b/DDRec/src/SurfaceManager.cpp
index 3bcb59838..9dbe6cf29 100644
--- a/DDRec/src/SurfaceManager.cpp
+++ b/DDRec/src/SurfaceManager.cpp
@@ -1,10 +1,9 @@
#include "DDRec/SurfaceManager.h"
#include "DDRec/SurfaceHelper.h"
-//#include "DDRec/DetectorSurfaces.h"
-//#include "DD4hep/Detector.h"
#include "DD4hep/LCDD.h"
-//#include "DD4hep/VolumeManager.h"
+
+#include <sstream>
namespace DD4hep {
@@ -39,7 +38,7 @@ namespace DD4hep {
LCDD& lcdd = LCDD::getInstance();
- std::vector<std::string> types = lcdd.detectorTypes() ;
+ const std::vector<std::string>& types = lcdd.detectorTypes() ;
for(unsigned i=0,N=types.size();i<N;++i){
@@ -56,11 +55,14 @@ namespace DD4hep {
for( SurfaceList::const_iterator it = detSL.begin() ; it != detSL.end() ; ++it ){
Surface* surf = *it ;
+ // enter surface into map for this detector
+ _map[ name ].insert( std::make_pair( surf->id(), surf ) ) ;
+
// enter surface into map for detector type
- _map[ types[i] ].insert( std::make_pair( surf->id() , surf ) ) ;
+ _map[ types[i] ].insert( std::make_pair( surf->id(), surf ) ) ;
- // enter surface into map for this detector
- _map[ name ].insert( std::make_pair( surf->id() , surf ) ) ;
+ // enter surface into world map
+ _map[ "world" ].insert( std::make_pair( surf->id(), surf ) ) ;
}
}
@@ -68,7 +70,20 @@ namespace DD4hep {
}
+ std::string SurfaceManager::toString() const {
+
+ std::stringstream sstr ;
+
+ sstr << "-------- SurfaceManager contains the following maps : --------- " << std::endl ;
+
+ for( SurfaceMapsMap::const_iterator mi = _map.begin() ; mi != _map.end() ; ++mi ) {
+
+ sstr << " key: " << mi->first << " \t number of surfaces : " << mi->second.size() << std::endl ;
+ }
+ sstr << "---------------------------------------------------------------- " << std::endl ;
+ return sstr.str() ;
+ }
} // namespace
--
GitLab