VGM Version 5.3
Loading...
Searching...
No Matches
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
20
24
25#include "TGeoManager.h"
26#include "TGeoMedium.h"
27#include "TGeoShape.h"
28
29#include <iostream>
30
31//_____________________________________________________________________________
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//_____________________________________________________________________________
67RootGM::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//_____________________________________________________________________________
77RootGM::Volume::Volume() : VGM::IVolume(), BaseVGM::VVolume()
78{
80}
81
82//_____________________________________________________________________________
84 : VGM::IVolume(rhs), BaseVGM::VVolume(rhs)
85{
87}
88
89//_____________________________________________________________________________
94
95//
96// public functions
97//
98
99//_____________________________________________________________________________
100std::string RootGM::Volume::Name() const
101{
102 //
103 return std::string(fGeoVolume->GetName());
104}
105
106//_____________________________________________________________________________
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//_____________________________________________________________________________
120std::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//_____________________________________________________________________________
131void 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}
TGeoShape * GetSolid(VGM::ISolid *iSolid) const
Definition SolidMap.cxx:86
static SolidMap * Instance()
Definition SolidMap.cxx:28
static VolumeMap * Instance()
Definition VolumeMap.cxx:28
void AddVolume(VGM::IVolume *, TGeoVolume *)
Definition VolumeMap.cxx:63
VGM implementation for Root volume.
Definition Volume.h:36
virtual ~Volume()
Definition Volume.cxx:90
virtual std::string MediumName() const
Return the name of the associated medium.
Definition Volume.cxx:120
void ResetVolume(TGeoVolume *rootVolume)
Definition Volume.cxx:131
virtual std::string MaterialName() const
Return the name of the associated material.
Definition Volume.cxx:107
virtual std::string Name() const
Return the name of this volume.
Definition Volume.cxx:100
The VGM interface to solids.
Definition ISolid.h:58
virtual SolidType Type() const =0
Return the type of this solid.
BaseVGM utilities.
Definition utilities.h:23
VGM interfaces.
Definition VMedium.h:28
@ kDisplaced
Definition ISolid.h:49