VGM
Version 5.5
Toggle main menu visibility
Loading...
Searching...
No Matches
packages
RootGM
source
volumes
Volume.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 Volume
14
// ---------------
15
// VGM implementation for Root volume.
16
//
17
// Author: Ivana Hrivnacova; IPN Orsay
18
19
#include "
VGM/solids/IDisplacedSolid.h
"
20
21
#include "
RootGM/solids/SolidMap.h
"
22
#include "
RootGM/volumes/Volume.h
"
23
#include "
RootGM/volumes/VolumeMap.h
"
24
25
#include "TGeoManager.h"
26
#include "TGeoMedium.h"
27
#include "TGeoShape.h"
28
29
#include <iostream>
30
31
//_____________________________________________________________________________
32
RootGM::Volume::Volume
(
33
const
std::string& name,
VGM::ISolid
* solid,
const
std::string& mediumName)
34
:
VGM
::IVolume(),
BaseVGM
::
VVolume
(solid), fGeoVolume(0)
35
{
39
40
// Get solid from the solid map
41
// If displaced solid, get its constituent solid
42
VGM::ISolid
* constSolid = solid;
43
while
(constSolid->
Type
() ==
VGM::kDisplaced
) {
44
VGM::IDisplacedSolid* displacedSolid =
45
dynamic_cast<VGM::IDisplacedSolid*>(constSolid);
46
constSolid = displacedSolid->ConstituentSolid();
47
}
48
49
TGeoShape* geoSolid =
RootGM::SolidMap::Instance
()->GetSolid(constSolid);
50
// Get medium from Root
51
TGeoMedium* geoMedium = gGeoManager->GetMedium(mediumName.data());
52
53
if (!geoMedium) {
54
std::cerr <<
"+++ Warning +++"
<< std::endl;
55
std::cerr <<
" RootGM::Volume::Volume:"
<< std::endl;
56
std::cerr <<
" Medium \""
<< mediumName <<
"\" not found."
<< std::endl;
57
}
58
59
// Create logical volume
60
fGeoVolume =
new
TGeoVolume(name.data(), geoSolid, geoMedium);
61
62
// Register logical volume in the map
63
RootGM::VolumeMap::Instance
()->
AddVolume
(
this
, fGeoVolume);
64
}
65
66
//_____________________________________________________________________________
67
RootGM::Volume::Volume
(
VGM::ISolid
* solid, TGeoVolume* volume)
68
:
VGM
::IVolume(),
BaseVGM
::
VVolume
(solid), fGeoVolume(volume)
69
{
71
72
// Register logical volume in the map
73
RootGM::VolumeMap::Instance
()->
AddVolume
(
this
, fGeoVolume);
74
}
75
76
//_____________________________________________________________________________
77
RootGM::Volume::Volume
() :
VGM
::IVolume(),
BaseVGM
::
VVolume
()
78
{
80
}
81
82
//_____________________________________________________________________________
83
RootGM::Volume::Volume
(
const
Volume
& rhs)
84
:
VGM
::IVolume(rhs),
BaseVGM
::
VVolume
(rhs)
85
{
87
}
88
89
//_____________________________________________________________________________
90
RootGM::Volume::~Volume
()
91
{
92
//
93
}
94
95
//
96
// public functions
97
//
98
99
//_____________________________________________________________________________
100
std::string
RootGM::Volume::Name
()
const
101
{
102
//
103
return
std::string(fGeoVolume->GetName());
104
}
105
106
//_____________________________________________________________________________
107
std::string
RootGM::Volume::MaterialName
()
const
108
{
109
//
110
// Root volumes may not have medium
111
//
112
if
(!fGeoVolume->GetMedium() ||
113
(fGeoVolume->GetMedium() && !fGeoVolume->GetMedium()->GetMaterial()))
114
return
"None"
;
115
116
return
std::string(fGeoVolume->GetMedium()->GetMaterial()->GetName());
117
}
118
119
//_____________________________________________________________________________
120
std::string
RootGM::Volume::MediumName
()
const
121
{
122
//
123
// Root volumes may not have medium
124
//
125
if
(!fGeoVolume->GetMedium())
return
"None"
;
126
127
return
std::string(fGeoVolume->GetMedium()->GetName());
128
}
129
130
//_____________________________________________________________________________
131
void
RootGM::Volume::ResetVolume
(TGeoVolume* volume)
132
{
134
135
TGeoVolume* oldVolume = fGeoVolume;
136
137
fGeoVolume = volume;
138
if
(oldVolume) fGeoVolume->SetMedium(oldVolume->GetMedium());
139
140
RootGM::VolumeMap::Instance
()->
AddVolume
(
this
, fGeoVolume);
141
// Check solid for this case
142
}
IDisplacedSolid.h
SolidMap.h
VolumeMap.h
Volume.h
BaseVGM::VVolume::VVolume
VVolume(VGM::ISolid *solid)
Definition
VVolume.cxx:43
RootGM::SolidMap::Instance
static SolidMap * Instance()
Definition
SolidMap.cxx:28
RootGM::VolumeMap::Instance
static VolumeMap * Instance()
Definition
VolumeMap.cxx:28
RootGM::VolumeMap::AddVolume
void AddVolume(VGM::IVolume *, TGeoVolume *)
Definition
VolumeMap.cxx:63
RootGM::Volume::~Volume
virtual ~Volume()
Definition
Volume.cxx:90
RootGM::Volume::MediumName
virtual std::string MediumName() const
Return the name of the associated medium.
Definition
Volume.cxx:120
RootGM::Volume::ResetVolume
void ResetVolume(TGeoVolume *rootVolume)
Definition
Volume.cxx:131
RootGM::Volume::Volume
Volume(const std::string &name, VGM::ISolid *solid, const std::string &mediumName)
Definition
Volume.cxx:32
RootGM::Volume::MaterialName
virtual std::string MaterialName() const
Return the name of the associated material.
Definition
Volume.cxx:107
RootGM::Volume::Volume
Volume()
Definition
Volume.cxx:77
RootGM::Volume::Name
virtual std::string Name() const
Return the name of this volume.
Definition
Volume.cxx:100
VGM::ISolid
The VGM interface to solids.
Definition
ISolid.h:58
VGM::ISolid::Type
virtual SolidType Type() const =0
Return the type of this solid.
BaseVGM
BaseVGM utilities.
Definition
utilities.h:23
VGM
VGM interfaces.
Definition
VMedium.h:28
VGM::kDisplaced
@ kDisplaced
Definition
ISolid.h:49
Generated on
for VGM by
1.17.0