VGM Version 5.3
Loading...
Searching...
No Matches
VolumeMap.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 VolumeMap
14// ------------------
15// The map between VGM and Geant4 volumes.
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
19#include "VGM/volumes/IVolume.h"
20
22
23#include "G4LogicalVolume.hh"
24
25Geant4GM::VolumeMap* Geant4GM::VolumeMap::fgInstance = 0;
26
27//_____________________________________________________________________________
29{
31
32 if (!fgInstance) new Geant4GM::VolumeMap();
33
34 return fgInstance;
35}
36
37//_____________________________________________________________________________
38Geant4GM::VolumeMap::VolumeMap() : fG4Volumes(), fVgmVolumes()
39{
41
42 fgInstance = this;
43}
44
45//_____________________________________________________________________________
47{
49}
50
51//_____________________________________________________________________________
53{
54 //
55
56 fgInstance = 0;
57}
58
59//_____________________________________________________________________________
61 VGM::IVolume* iVolume, G4LogicalVolume* g4Volume)
62{
64
65 fG4Volumes[iVolume] = g4Volume;
66 fVgmVolumes[g4Volume] = iVolume;
67}
68
69//_____________________________________________________________________________
71 G4LogicalVolume* g4Volume, const std::vector<G4LogicalVolume*>& volumes)
72{
73 fG4ParamVolumes[g4Volume] = volumes;
74}
75
76//_____________________________________________________________________________
78{
80
81 std::cout << "Geant4 Volumes Map: " << std::endl;
82
83 int counter = 0;
84 for (auto i = fG4Volumes.begin(); i != fG4Volumes.end(); i++) {
85 VGM::IVolume* iVolume = (*i).first;
86 G4LogicalVolume* lv = (*i).second;
87
88 std::cout << " " << counter++ << "th entry:"
89 << " vgmVolume " << iVolume << " " << iVolume->Name() << " LV "
90 << lv << " " << lv->GetName() << std::endl;
91 }
92}
93
94//_____________________________________________________________________________
95G4LogicalVolume* Geant4GM::VolumeMap::GetVolume(VGM::IVolume* iVolume) const
96{
98
99 auto i = fG4Volumes.find(iVolume);
100 if (i != fG4Volumes.end())
101 return (*i).second;
102 else
103 return 0;
104}
105
106//_____________________________________________________________________________
108{
110
111 auto i = fVgmVolumes.find(lv);
112 if (i != fVgmVolumes.end())
113 return (*i).second;
114 else
115 return 0;
116}
117
118//_____________________________________________________________________________
119const std::vector<G4LogicalVolume*>&
120Geant4GM::VolumeMap::GetParamVolumes(G4LogicalVolume* lv) const
121{
123 auto i = fG4ParamVolumes.find(lv);
124 if (i != fG4ParamVolumes.end())
125 return (*i).second;
126 else
127 return fDummyVector;
128}
The map between VGM and Geant4 volumes.
Definition VolumeMap.h:37
void AddParamVolume(G4LogicalVolume *, const std::vector< G4LogicalVolume * > &)
Definition VolumeMap.cxx:70
void AddVolume(VGM::IVolume *, G4LogicalVolume *)
Definition VolumeMap.cxx:60
void Print() const
Definition VolumeMap.cxx:77
static VolumeMap * Instance()
Definition VolumeMap.cxx:28
const std::vector< G4LogicalVolume * > & GetParamVolumes(G4LogicalVolume *lv) const
G4LogicalVolume * GetVolume(VGM::IVolume *iVolume) const
Definition VolumeMap.cxx:95
The VGM interface to volumes.
Definition IVolume.h:32
virtual std::string Name() const =0
Return the name of this volume.