VGM Version 5.3
Loading...
Searching...
No Matches
MaterialMap.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 MaterialMap
14// ------------------
15// The map between VGM and G4 materials.
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
20
22
23Geant4GM::MaterialMap* Geant4GM::MaterialMap::fgInstance = 0;
24
25#include "G4Material.hh"
26
27//_____________________________________________________________________________
29{
31
32 if (!fgInstance) new MaterialMap();
33
34 return fgInstance;
35}
36
37//_____________________________________________________________________________
38Geant4GM::MaterialMap::MaterialMap() : fG4Materials(), fVgmMaterials()
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::IMaterial* iMaterial, G4Material* g4Material)
65{
67
68 fG4Materials[iMaterial] = g4Material;
69 fVgmMaterials[g4Material] = iMaterial;
70}
71
72//_____________________________________________________________________________
74{
76
77 std::cout << "G4 Materials Map: " << std::endl;
78
79 int counter = 0;
81 for (i = fG4Materials.begin(); i != fG4Materials.end(); i++) {
82 VGM::IMaterial* iMaterial = (*i).first;
83 G4Material* g4Material = (*i).second;
84
85 std::cout << " " << counter++ << "th entry:"
86 << " vgmMaterial " << iMaterial << " " << iMaterial->Name()
87 << " g4Material " << g4Material << " " << g4Material->GetName()
88 << std::endl;
89 }
90}
91
92//_____________________________________________________________________________
94{
96
97 G4MaterialMapCIterator i = fG4Materials.find(iMaterial);
98 if (i != fG4Materials.end())
99 return (*i).second;
100 else
101 return 0;
102}
103
104//_____________________________________________________________________________
106{
108
109 VgmMaterialMapCIterator i = fVgmMaterials.find(g4Material);
110 if (i != fVgmMaterials.end())
111 return (*i).second;
112 else
113 return 0;
114}
The map between VGM and Geant4 material.
Definition MaterialMap.h:36
G4MaterialMap::const_iterator G4MaterialMapCIterator
Definition MaterialMap.h:39
static MaterialMap * Instance()
G4Material * GetMaterial(VGM::IMaterial *iMaterial) const
VgmMaterialMap::const_iterator VgmMaterialMapCIterator
Definition MaterialMap.h:42
void AddMaterial(VGM::IMaterial *, G4Material *)
The VGM interface to materials.
Definition IMaterial.h:44
virtual std::string Name() const =0
Return the name of this element.