DD4hep  1.33.0
Detector Description Toolkit for High Energy Physics
SurfaceManager.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : F.Gaede
11 //
12 //==========================================================================
13 #include "DDRec/SurfaceManager.h"
14 
15 #include "DDRec/SurfaceHelper.h"
16 #include "DD4hep/VolumeManager.h"
17 #include "DD4hep/Detector.h"
18 
19 #include <sstream>
20 
21 namespace dd4hep {
22  namespace rec {
23 
25 
26  // have to make sure the volume manager is populated once in order to have
27  // the volumeIDs attached to the DetElements
28 
30 
31  initialize(theDetector) ;
32  }
33 
34 
35  const SurfaceMap* SurfaceManager::map( const std::string& name ) const {
36 
37  SurfaceMapsMap::const_iterator it = _map.find( name ) ;
38 
39  if( it != _map.end() ){
40 
41  return & it->second ;
42  }
43 
44  return nullptr ;
45  }
46 
47  void SurfaceManager::initialize(const Detector& description) {
48 
49  for(const auto& type : description.detectorTypes()) {
50 
51  const std::vector<DetElement>& dets = description.detectors( type ) ;
52 
53  for(const auto& det : dets) {
54 
55  const std::string& name = det.name() ;
56 
57  SurfaceHelper surfH( det ) ;
58 
59  const SurfaceList& detSL = surfH.surfaceList() ;
60 
61  // add an empty map for this detector in case there are no surfaces attached
62  _map.emplace(name , SurfaceMap());
63 
64  for( auto* surf : detSL ) {
65  // enter surface into map for this detector
66  _map[ name ].emplace(surf->id(), surf );
67 
68  // enter surface into map for detector type
69  _map[ type ].emplace(surf->id(), surf );
70 
71  // enter surface into world map
72  _map[ "world" ].emplace(surf->id(), surf );
73 
74  }
75  }
76  }
77 
78  }
79 
80  std::string SurfaceManager::toString() const {
81 
82  std::stringstream sstr ;
83 
84  sstr << "-------- SurfaceManager contains the following maps : --------- " << std::endl ;
85 
86  for( SurfaceMapsMap::const_iterator mi = _map.begin() ; mi != _map.end() ; ++mi ) {
87 
88  sstr << " key: " << mi->first << " \t number of surfaces : " << mi->second.size() << std::endl ;
89  }
90  sstr << "---------------------------------------------------------------- " << std::endl ;
91 
92  return sstr.str() ;
93  }
94 
95 
96  } // namespace
97 }// namespace
SurfaceManager.h
dd4hep::rec::SurfaceManager::map
const SurfaceMap * map(const std::string &name) const
Definition: SurfaceManager.cpp:35
Detector.h
dd4hep::Detector::detectors
virtual const HandleMap & detectors() const =0
Accessor to the map of sub-detectors.
dd4hep::rec::SurfaceManager::toString
std::string toString() const
create a string with all available maps and their size (number of surfaces)
Definition: SurfaceManager.cpp:80
dd4hep::rec::SurfaceMap
std::multimap< unsigned long, ISurface * > SurfaceMap
typedef for surface maps, keyed by the cellID
Definition: SurfaceManager.h:25
SurfaceHelper.h
dd4hep::rec::SurfaceManager::initialize
void initialize(const Detector &theDetector)
initialize all known surface maps
Definition: SurfaceManager.cpp:47
VolumeManager.h
dd4hep::rec::SurfaceList
Definition: Surface.h:679
dd4hep::rec::SurfaceHelper::surfaceList
const SurfaceList & surfaceList()
Definition: SurfaceHelper.h:44
dd4hep::VolumeManager::getVolumeManager
static VolumeManager getVolumeManager(const Detector &description)
static accessor calling DD4hepVolumeManagerPlugin if necessary
Definition: VolumeManager.cpp:420
dd4hep::Detector::detectorTypes
virtual std::vector< std::string > detectorTypes() const =0
Access the available detector types.
dd4hep::rec::SurfaceManager::_map
SurfaceMapsMap _map
Definition: SurfaceManager.h:73
dd4hep::rec::SurfaceManager::SurfaceManager
SurfaceManager()=delete
No default constructor.
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
det
DetElement::Object * det
Definition: AlignmentsCalculator.cpp:66
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::rec::SurfaceHelper
Definition: SurfaceHelper.h:29