VGM Version 5.3
Loading...
Searching...
No Matches
Volume.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 Volume
14// ---------------
15// VGM implementation for Geant4 volume.
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
19#include "VGM/solids/ISolid.h"
20
24
25#include "G4LogicalVolume.hh"
26#include "G4Material.hh"
27#include "G4VSolid.hh"
28
29#include <iostream>
30
31//_____________________________________________________________________________
32Geant4GM::Volume::Volume(const std::string& name, VGM::ISolid* solid,
33 const std::string& materialName, const std::string& mediumName)
34 : VGM::IVolume(),
35 BaseVGM::VVolume(solid),
36 fLogicalVolume(0),
37 fMediumName(mediumName)
38{
43
44 // Get solid from the solid map
45 G4VSolid* g4Solid = Geant4GM::SolidMap::Instance()->GetSolid(solid);
46
47 // Get material from G4
48 G4Material* g4Material = G4Material::GetMaterial(materialName);
49
50 if (!g4Material) {
51 std::cerr << " Geant4GM::Volume::Volume:" << std::endl;
52 std::cerr << " Material \"" << materialName << "\" not found."
53 << std::endl;
54 std::cerr << "*** Error: Aborting execution ***" << std::endl;
55 exit(1);
56 }
57
58 // Create logical volume
59 fLogicalVolume = new G4LogicalVolume(g4Solid, g4Material, name);
60
61 // Register logical volume in the map
62 Geant4GM::VolumeMap::Instance()->AddVolume(this, fLogicalVolume);
63}
64
65//_____________________________________________________________________________
67 VGM::ISolid* solid, G4LogicalVolume* lv, const std::string& mediumName)
68 : VGM::IVolume(),
69 BaseVGM::VVolume(solid),
70 fLogicalVolume(lv),
71 fMediumName(mediumName)
72{
74
75 // Register logical volume in the map
76 Geant4GM::VolumeMap::Instance()->AddVolume(this, fLogicalVolume);
77}
78
79//_____________________________________________________________________________
80Geant4GM::Volume::Volume() : VGM::IVolume(), BaseVGM::VVolume()
81{
83}
84
85//_____________________________________________________________________________
87 : VGM::IVolume(rhs), BaseVGM::VVolume(rhs)
88{
90}
91
92//_____________________________________________________________________________
97
98//
99// public functions
100//
101
102//_____________________________________________________________________________
103std::string Geant4GM::Volume::Name() const
104{
105 //
106 return fLogicalVolume->GetName();
107}
108
109//_____________________________________________________________________________
111{
112 //
113 return fLogicalVolume->GetMaterial()->GetName();
114}
115
116//_____________________________________________________________________________
118{
119 //
120 return fMediumName;
121}
122
123//_____________________________________________________________________________
125{
127
128 G4VSolid* g4Solid = Geant4GM::SolidMap::Instance()->GetSolid(solid);
129 fLogicalVolume->SetSolid(g4Solid);
130}
virtual void ResetSolid(VGM::ISolid *solid)
Definition VVolume.cxx:91
G4VSolid * GetSolid(VGM::ISolid *iSolid) const
Definition SolidMap.cxx:68
static SolidMap * Instance()
Definition SolidMap.cxx:28
void AddVolume(VGM::IVolume *, G4LogicalVolume *)
Definition VolumeMap.cxx:60
static VolumeMap * Instance()
Definition VolumeMap.cxx:28
VGM implementation for Geant4 volume.
Definition Volume.h:36
virtual std::string MediumName() const
Return the name of the associated medium.
Definition Volume.cxx:117
virtual std::string Name() const
Return the name of this volume.
Definition Volume.cxx:103
virtual ~Volume()
Definition Volume.cxx:93
virtual void ResetSolid(VGM::ISolid *solid)
Definition Volume.cxx:124
virtual std::string MaterialName() const
Return the name of the associated material.
Definition Volume.cxx:110
The VGM interface to solids.
Definition ISolid.h:58
BaseVGM utilities.
Definition utilities.h:23
VGM interfaces.
Definition VMedium.h:28