VGM
Version 5.5
Toggle main menu visibility
Loading...
Searching...
No Matches
packages
RootGM
source
solids
Ellipsoid.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 Ellipsoid
14
// ---------------
15
// VGM implementation for Root elliptical tube solid.
16
//
17
// Author: Ivana Hrivnacova; IPN Orsay
18
19
#include "
RootGM/solids/Ellipsoid.h
"
20
#include "
RootGM/common/Units.h
"
21
#include "
RootGM/solids/SolidMap.h
"
22
23
#include "TGeoBBox.h"
24
#include "TGeoBoolNode.h"
25
#include "TGeoCompositeShape.h"
26
#include "TGeoMatrix.h"
27
#include "TGeoScaledShape.h"
28
#include "TGeoSphere.h"
29
30
//_____________________________________________________________________________
31
RootGM::Ellipsoid::Ellipsoid
(
const
std::string& name,
double
dx,
double
dy,
32
double
dz,
double
zBottomCut,
double
zTopCut)
33
:
VGM
::ISolid(),
34
VGM
::IEllipsoid(),
35
BaseVGM
::
VEllipsoid
(),
36
fEllipsoid(0),
37
fDx(dx),
38
fDy(dy),
39
fDz(dz),
40
fZBottomCut(zBottomCut),
41
fZTopCut(zTopCut)
42
{
49
50
// First create a sphere with rmin = 0, rmax = dx
51
TGeoSphere* sphere =
52
new
TGeoSphere(
"sphere"
, 0., dx /
RootGM::Units::Length
());
53
54
// The scale to trasform sphere in ellipsoid
55
TGeoScale* scale =
new
TGeoScale(1.0, dy / dx, dz / dx);
56
57
// The ellipsoid without z-cuts
58
TGeoScaledShape* scaledShape =
59
new
TGeoScaledShape(
"scaledSphere"
, sphere, scale);
60
61
if
(zBottomCut == 0. && zTopCut == 0.) {
62
fEllipsoid = scaledShape;
63
fEllipsoid->SetName(name.data());
64
}
65
else
{
66
// adjust cut parameters if they are not consistent
67
if
(zBottomCut == 0. || zBottomCut > dz) zBottomCut = -dz;
68
if
(zTopCut == 0. || zTopCut < zBottomCut) zTopCut = dz;
69
70
// The composite shape applying z cuts
71
Double_t origin[3];
72
origin[0] = 0.;
73
origin[1] = 0.;
74
origin[2] = 0.5 * (zBottomCut + zTopCut) /
RootGM::Units::Length
();
75
TGeoBBox* cutBox =
new
TGeoBBox(
"cutBox"
, 2. * dx /
RootGM::Units::Length
(),
76
2. * dy /
RootGM::Units::Length
(),
77
0.5 * (zTopCut - zBottomCut) /
RootGM::Units::Length
(), origin);
78
79
TGeoBoolNode* boolNode =
new
TGeoIntersection(scaledShape, cutBox);
80
81
fEllipsoid =
new
TGeoCompositeShape(name.data(), boolNode);
82
}
83
84
RootGM::SolidMap::Instance
()->
AddSolid
(
this
, fEllipsoid);
85
}
86
87
//_____________________________________________________________________________
88
RootGM::Ellipsoid::Ellipsoid
(TGeoScaledShape* scaledShape)
89
:
VGM
::ISolid(),
90
VGM
::IEllipsoid(),
91
BaseVGM
::
VEllipsoid
(),
92
fEllipsoid(scaledShape),
93
fDx(0.),
94
fDy(0.),
95
fDz(0.),
96
fZBottomCut(0.),
97
fZTopCut(0.)
98
99
{
102
103
TGeoSphere* sphere =
dynamic_cast<
TGeoSphere*
>
(scaledShape->GetShape());
104
const
Double_t* scale = scaledShape->GetScale()->GetScale();
105
106
Double_t rmax = sphere->GetRmax();
107
Double_t sx = scale[0];
108
Double_t sy = scale[1];
109
Double_t sz = scale[2];
110
111
fDx = rmax * sx *
RootGM::Units::Length
();
112
fDy = rmax * sy *
RootGM::Units::Length
();
113
fDz = rmax * sz *
RootGM::Units::Length
();
114
115
RootGM::SolidMap::Instance
()->
AddSolid
(
this
, fEllipsoid);
116
}
117
118
//_____________________________________________________________________________
119
RootGM::Ellipsoid::Ellipsoid
()
120
:
VGM
::ISolid(),
VGM
::IEllipsoid(),
BaseVGM
::
VEllipsoid
()
121
{
123
}
124
125
//_____________________________________________________________________________
126
RootGM::Ellipsoid::Ellipsoid
(
const
Ellipsoid
& rhs)
127
:
VGM
::ISolid(rhs),
VGM
::IEllipsoid(rhs),
BaseVGM
::
VEllipsoid
(rhs)
128
{
130
}
131
132
//_____________________________________________________________________________
133
RootGM::Ellipsoid::~Ellipsoid
()
134
{
135
//
136
}
137
138
//_____________________________________________________________________________
139
std::string
RootGM::Ellipsoid::Name
()
const
{
return
fEllipsoid->GetName(); }
140
141
//_____________________________________________________________________________
142
double
RootGM::Ellipsoid::XSemiAxis
()
const
{
return
fDx; }
143
144
//_____________________________________________________________________________
145
double
RootGM::Ellipsoid::YSemiAxis
()
const
{
return
fDy; }
146
147
//_____________________________________________________________________________
148
double
RootGM::Ellipsoid::ZSemiAxis
()
const
{
return
fDz; }
149
150
//_____________________________________________________________________________
151
double
RootGM::Ellipsoid::ZBottomCut
()
const
{
return
fZBottomCut; }
152
153
//_____________________________________________________________________________
154
double
RootGM::Ellipsoid::ZTopCut
()
const
{
return
fZTopCut; }
Units.h
Ellipsoid.h
SolidMap.h
BaseVGM::VEllipsoid::VEllipsoid
VEllipsoid()
Definition
VEllipsoid.cxx:30
RootGM::Ellipsoid::Ellipsoid
Ellipsoid()
Definition
Ellipsoid.cxx:119
RootGM::Ellipsoid::ZSemiAxis
virtual double ZSemiAxis() const
Return the semi-axis of the ellipse along z in mm.
Definition
Ellipsoid.cxx:148
RootGM::Ellipsoid::XSemiAxis
virtual double XSemiAxis() const
Return the semi-axis of the ellipse along x in mm.
Definition
Ellipsoid.cxx:142
RootGM::Ellipsoid::Name
virtual std::string Name() const
Return the name of this solid.
Definition
Ellipsoid.cxx:139
RootGM::Ellipsoid::~Ellipsoid
virtual ~Ellipsoid()
Definition
Ellipsoid.cxx:133
RootGM::Ellipsoid::YSemiAxis
virtual double YSemiAxis() const
Return the semi-axis of the ellipse along y in mm.
Definition
Ellipsoid.cxx:145
RootGM::Ellipsoid::ZTopCut
virtual double ZTopCut() const
Return the z top cut in mm.
Definition
Ellipsoid.cxx:154
RootGM::Ellipsoid::Ellipsoid
Ellipsoid(const std::string &name, double dx, double dy, double dz, double zBottomCut, double zTopCut)
Definition
Ellipsoid.cxx:31
RootGM::Ellipsoid::ZBottomCut
virtual double ZBottomCut() const
Return the z bottom cut in mm.
Definition
Ellipsoid.cxx:151
RootGM::SolidMap::AddSolid
void AddSolid(VGM::ISolid *, TGeoShape *)
Definition
SolidMap.cxx:59
RootGM::SolidMap::Instance
static SolidMap * Instance()
Definition
SolidMap.cxx:28
RootGM::Units::Length
static double Length()
Return Root length unit in VGM units.
Definition
Units.h:84
BaseVGM
BaseVGM utilities.
Definition
utilities.h:23
VGM
VGM interfaces.
Definition
VMedium.h:28
Generated on
for VGM by
1.17.0