VGM Version 5.3
Loading...
Searching...
No Matches
ElementMap.cxx
Go to the documentation of this file.
1// $Id$
2
3// -----------------------------------------------------------------------
4// The Geant4GM package of the Virtual Geometry Model
5// Copyright (C) 2007, Ivana Hrivnacova
6// All rights reserved.
7//
8// For the licensing terms see vgm/LICENSE.
9// Contact: ivana@ipno.in2p3.fr
10// -----------------------------------------------------------------------
11
12//
13// Class ElementMap
14// ------------------
15// The map between VGM and Geant4 elements.
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
20
22
23#include "G4Element.hh"
24
25Geant4GM::ElementMap* Geant4GM::ElementMap::fgInstance = 0;
26
27//_____________________________________________________________________________
29{
31
32 if (!fgInstance) new ElementMap();
33
34 return fgInstance;
35}
36
37//_____________________________________________________________________________
38Geant4GM::ElementMap::ElementMap() : fG4Elements(), fVgmElements()
39{
41
42 fgInstance = this;
43}
44
45//_____________________________________________________________________________
50
51//_____________________________________________________________________________
53{
54 //
55 fgInstance = 0;
56}
57
58//
59// public methods
60//
61
62//_____________________________________________________________________________
64 VGM::IElement* iElement, G4Element* g4Element)
65{
67
68 fG4Elements[iElement] = g4Element;
69 fVgmElements[g4Element] = iElement;
70}
71
72//_____________________________________________________________________________
74{
76
77 std::cout << "Geant4 Elements Map: " << std::endl;
78
79 int counter = 0;
81 for (i = fG4Elements.begin(); i != fG4Elements.end(); i++) {
82 VGM::IElement* iElement = (*i).first;
83 G4Element* element = (*i).second;
84
85 std::cout << " " << counter++ << "th entry:"
86 << " vgmElement " << iElement << " " << iElement->Name()
87 << " LV " << element << " " << element->GetName() << std::endl;
88 }
89}
90
91//_____________________________________________________________________________
93{
95
96 G4ElementMapCIterator i = fG4Elements.find(iElement);
97 if (i != fG4Elements.end())
98 return (*i).second;
99 else
100 return 0;
101}
102
103//_____________________________________________________________________________
105{
107
108 VgmElementMapCIterator i = fVgmElements.find(element);
109 if (i != fVgmElements.end())
110 return (*i).second;
111 else
112 return 0;
113}
The map between VGM and Geant4 elements.
Definition ElementMap.h:36
VgmElementMap::const_iterator VgmElementMapCIterator
Definition ElementMap.h:42
G4ElementMap::const_iterator G4ElementMapCIterator
Definition ElementMap.h:39
void AddElement(VGM::IElement *, G4Element *)
static ElementMap * Instance()
G4Element * GetElement(VGM::IElement *iElement) const
The VGM interface to elements.
Definition IElement.h:34
virtual std::string Name() const =0
Return the name of this element.