VGM Version 5.3
Loading...
Searching...
No Matches
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
20#include "RootGM/common/Units.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//_____________________________________________________________________________
31RootGM::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//_____________________________________________________________________________
88RootGM::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//_____________________________________________________________________________
120 : VGM::ISolid(), VGM::IEllipsoid(), BaseVGM::VEllipsoid()
121{
123}
124
125//_____________________________________________________________________________
127 : VGM::ISolid(rhs), VGM::IEllipsoid(rhs), BaseVGM::VEllipsoid(rhs)
128{
130}
131
132//_____________________________________________________________________________
137
138//_____________________________________________________________________________
139std::string RootGM::Ellipsoid::Name() const { return fEllipsoid->GetName(); }
140
141//_____________________________________________________________________________
142double RootGM::Ellipsoid::XSemiAxis() const { return fDx; }
143
144//_____________________________________________________________________________
145double RootGM::Ellipsoid::YSemiAxis() const { return fDy; }
146
147//_____________________________________________________________________________
148double RootGM::Ellipsoid::ZSemiAxis() const { return fDz; }
149
150//_____________________________________________________________________________
151double RootGM::Ellipsoid::ZBottomCut() const { return fZBottomCut; }
152
153//_____________________________________________________________________________
154double RootGM::Ellipsoid::ZTopCut() const { return fZTopCut; }
VGM implementation for Root ellipsoid solid.
Definition Ellipsoid.h:33
virtual double ZSemiAxis() const
Return the semi-axis of the ellipse along z in mm.
virtual double XSemiAxis() const
Return the semi-axis of the ellipse along x in mm.
virtual std::string Name() const
Return the name of this solid.
virtual ~Ellipsoid()
virtual double YSemiAxis() const
Return the semi-axis of the ellipse along y in mm.
virtual double ZTopCut() const
Return the z top cut in mm.
virtual double ZBottomCut() const
Return the z bottom cut in mm.
void AddSolid(VGM::ISolid *, TGeoShape *)
Definition SolidMap.cxx:59
static SolidMap * Instance()
Definition SolidMap.cxx:28
static double Length()
Return Root length unit in VGM units.
Definition Units.h:84
BaseVGM utilities.
Definition utilities.h:23
VGM interfaces.
Definition VMedium.h:28