DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4Mapping.cpp
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 // Framework include files
16 #include "DD4hep/Printout.h"
17 #include "DDG4/Geant4Mapping.h"
18 #include "G4PVPlacement.hh"
19 #include <stdexcept>
20 
21 using namespace DD4hep::Simulation;
22 using namespace DD4hep::Geometry;
23 using namespace std;
24 
27  : m_lcdd(lcdd_ref), m_dataPtr(0) {
28 }
29 
32  if (m_dataPtr)
33  delete m_dataPtr;
34  m_dataPtr = 0;
35 }
36 
39  static Geant4Mapping inst(LCDD::getInstance());
40  return inst;
41 }
42 
45  if (m_dataPtr)
46  return;
47  throw runtime_error("Geant4Mapping: Attempt to access an invalid data block!");
48 }
49 
53  if (p)
54  delete p;
56  return data();
57 }
58 
62  m_dataPtr = 0;
63  return p;
64 }
65 
68  m_dataPtr = data_ptr;
69 }
70 
73  if (m_dataPtr) {
74  if (m_dataPtr->g4Paths.empty()) {
76  }
78  }
79  throw runtime_error(format("Geant4Mapping", "Cannot create volume manager without Geant4 geometry info [Invalid-Info]"));
80 }
81 
83 PlacedVolume Geant4Mapping::placement(const G4VPhysicalVolume* node) const {
84  checkValidity();
86  for (Geant4GeometryMaps::PlacementMap::const_iterator i = m.begin(); i != m.end(); ++i)
87  if ((*i).second == node)
88  return PlacedVolume((*i).first);
89  return PlacedVolume(0);
90 }
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:135
The Geant4VolumeManager to facilitate optimized lookups of cell IDs from touchables.
Geant4GeometryInfo & init()
Create and attach new data block. Delete old data block if present.
Geant4Mapping(LCDD &lcdd)
Initializing Constructor.
static LCDD & getInstance(void)
—Factory method----—
Definition: LCDDImp.cpp:87
std::map< PlacedVolume, G4VPhysicalVolume * > PlacementMap
std::string format(const std::string &src, const std::string &fmt,...)
Build formatted string.
Definition: Printout.cpp:267
void checkValidity() const
When resolving pointers, we must check for the validity of the data block.
virtual ~Geant4Mapping()
Standard destructor.
void attach(Geant4GeometryInfo *data)
Set a new data block.
Geant4GeometryMaps::PlacementMap g4Placements
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:87
The main interface to the DD4hep detector description package.
Definition: LCDD.h:82
Concreate class holding the relation information between geant4 objects and dd4hep objects...
Geometry mapping from DD4hep to Geant 4.
Definition: Geant4Mapping.h:36
PlacedVolume placement(const G4VPhysicalVolume *node) const
Accessor to resolve geometry placements.
Geant4VolumeManager volumeManager() const
Access the volume manager.
Geant4GeometryInfo * m_dataPtr
Definition: Geant4Mapping.h:52
Geant4GeometryMaps::Geant4PathMap g4Paths
static Geant4Mapping & instance()
Possibility to define a singleton instance.
Geant4GeometryInfo & data() const
Access to the data pointer.
Definition: Geant4Mapping.h:72
Geometry::PlacedVolume PlacedVolume
Definition: Geant4Mapping.h:43
Geant4GeometryInfo * detach()
Release data and pass over the ownership.
TGeoShape TGeoMedium * m
Definition: Volumes.cpp:294