VGM Version 5.3
Loading...
Searching...
No Matches
MaterialMap.cxx
Go to the documentation of this file.
1// $Id$
2
3// -----------------------------------------------------------------------
4// The RootGM 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 Root materials.
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
20
22
23#include "TGeoMaterial.h"
24
25RootGM::MaterialMap* RootGM::MaterialMap::fgInstance = 0;
26
27//_____________________________________________________________________________
29{
31
32 if (!fgInstance) new RootGM::MaterialMap();
33
34 return fgInstance;
35}
36
37//_____________________________________________________________________________
38RootGM::MaterialMap::MaterialMap() : fRootMaterials(), fVgmMaterials()
39{
41
42 fgInstance = this;
43}
44
45//_____________________________________________________________________________
47{
49}
50
51//_____________________________________________________________________________
53{
54 //
55 fgInstance = 0;
56}
57
58//
59// public methods
60//
61
62//_____________________________________________________________________________
64 VGM::IMaterial* iMaterial, TGeoMaterial* rootMaterial)
65{
67
68 fRootMaterials[iMaterial] = rootMaterial;
69 fVgmMaterials[rootMaterial] = iMaterial;
70}
71
72//_____________________________________________________________________________
74{
76
77 std::cout << "Root Materials Map: " << std::endl;
78
79 int counter = 0;
81 for (i = fRootMaterials.begin(); i != fRootMaterials.end(); i++) {
82 VGM::IMaterial* iMaterial = (*i).first;
83 TGeoMaterial* rootMaterial = (*i).second;
84
85 std::cout << " " << counter++ << "th entry:"
86 << " vgmMaterial " << iMaterial << " " << iMaterial->Name()
87 << " rootMaterial " << rootMaterial << " "
88 << rootMaterial->GetName() << std::endl;
89 }
90}
91
92//_____________________________________________________________________________
93TGeoMaterial* RootGM::MaterialMap::GetMaterial(VGM::IMaterial* iMaterial) const
94{
96
97 RootMaterialMapCIterator i = fRootMaterials.find(iMaterial);
98 if (i != fRootMaterials.end())
99 return (*i).second;
100 else
101 return 0;
102}
103
104//_____________________________________________________________________________
106 TGeoMaterial* rootMaterial) const
107{
109
110 VgmMaterialMapCIterator i = fVgmMaterials.find(rootMaterial);
111 if (i != fVgmMaterials.end())
112 return (*i).second;
113 else
114 return 0;
115}
The map between VGM and Root material.
Definition MaterialMap.h:36
TGeoMaterial * GetMaterial(VGM::IMaterial *iMaterial) const
RootMaterialMap::const_iterator RootMaterialMapCIterator
Definition MaterialMap.h:39
VgmMaterialMap::const_iterator VgmMaterialMapCIterator
Definition MaterialMap.h:42
void AddMaterial(VGM::IMaterial *, TGeoMaterial *)
static MaterialMap * Instance()
The VGM interface to materials.
Definition IMaterial.h:44
virtual std::string Name() const =0
Return the name of this element.