VGM Version 5.3
Loading...
Searching...
No Matches
ElementMap.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 - 2010 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 Root elements.
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
20
22
23#include "TGeoElement.h"
24
25RootGM::ElementMap* RootGM::ElementMap::fgInstance = 0;
26
27//_____________________________________________________________________________
29{
31
32 if (!fgInstance) new ElementMap();
33
34 return fgInstance;
35}
36
37//_____________________________________________________________________________
38RootGM::ElementMap::ElementMap() : fTGeoElements(), 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, TGeoElement* tgeoElement)
65{
67
68 fTGeoElements[iElement] = tgeoElement;
69 fVgmElements[tgeoElement] = iElement;
70}
71
72//_____________________________________________________________________________
74{
76
77 std::cout << "Geant4 Elements Map: " << std::endl;
78
79 int counter = 0;
81 for (i = fTGeoElements.begin(); i != fTGeoElements.end(); i++) {
82 VGM::IElement* iElement = (*i).first;
83 TGeoElement* 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//_____________________________________________________________________________
92TGeoElement* RootGM::ElementMap::GetElement(VGM::IElement* iElement) const
93{
95
96 TGeoElementMapCIterator i = fTGeoElements.find(iElement);
97 if (i != fTGeoElements.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 Root elements.
Definition ElementMap.h:36
VgmElementMap::const_iterator VgmElementMapCIterator
Definition ElementMap.h:42
virtual ~ElementMap()
void AddElement(VGM::IElement *, TGeoElement *)
TGeoElement * GetElement(VGM::IElement *iElement) const
static ElementMap * Instance()
TGeoElementMap::const_iterator TGeoElementMapCIterator
Definition ElementMap.h:39
void Print() const
The VGM interface to elements.
Definition IElement.h:34
virtual std::string Name() const =0
Return the name of this element.