VGM Version 5.3
Loading...
Searching...
No Matches
Polyhedra.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 Polyhedra
14// ------------------
15// VGM implementation for Root polyhedra solid.
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
20#include "RootGM/common/Units.h"
22
23#include "TGeoPgon.h"
24
25#include <iostream>
26#include <math.h>
27
28const int RootGM::Polyhedra::fgkMaxNofZPlanes = 50;
29double* RootGM::Polyhedra::fgZBuffer = 0;
30double* RootGM::Polyhedra::fgRinBuffer = 0;
31double* RootGM::Polyhedra::fgRoutBuffer = 0;
32
33//_____________________________________________________________________________
34RootGM::Polyhedra::Polyhedra(const std::string& name, double sphi, double dphi,
35 int nofSides, int nofZPlanes, double* z, double* rin, double* rout)
36 : VGM::ISolid(), VGM::IPolyhedra(), BaseVGM::VPolyhedra(), fPolyhedra(0)
37{
48 //
49 double* param = new double[4 + 3 * nofZPlanes];
50 // number of parameters: sphi, dphi, nz + 3*nofZPlanes
51
52 param[0] = sphi / RootGM::Units::Angle();
53 param[1] = dphi / RootGM::Units::Angle();
54 param[2] = nofSides;
55 param[3] = nofZPlanes;
56
57 for (int i = 0; i < nofZPlanes; i++) {
58 int j = 4 + 3 * i;
59 param[j] = z[i] / RootGM::Units::Length();
60 param[j + 1] = rin[i] / RootGM::Units::Length();
61 param[j + 2] = rout[i] / RootGM::Units::Length();
62 }
63
64 fPolyhedra = new TGeoPgon(param);
65 fPolyhedra->SetName(name.data());
66
67 RootGM::SolidMap::Instance()->AddSolid(this, fPolyhedra);
68 CreateBuffers();
69
70 delete[] param;
71}
72
73//_____________________________________________________________________________
74RootGM::Polyhedra::Polyhedra(TGeoPgon* polyhedra)
75 : VGM::ISolid(),
76 VGM::IPolyhedra(),
77 BaseVGM::VPolyhedra(),
78 fPolyhedra(polyhedra)
79{
81
82 RootGM::SolidMap::Instance()->AddSolid(this, fPolyhedra);
83 CreateBuffers();
84}
85
86//_____________________________________________________________________________
88 : VGM::ISolid(), VGM::IPolyhedra(), BaseVGM::VPolyhedra()
89{
91}
92
93//_____________________________________________________________________________
95 : VGM::ISolid(rhs), VGM::IPolyhedra(rhs), BaseVGM::VPolyhedra(rhs)
96{
98}
99
100//_____________________________________________________________________________
105
106//_____________________________________________________________________________
107void RootGM::Polyhedra::CreateBuffers()
108{
109 if (!fgZBuffer) fgZBuffer = new double[fgkMaxNofZPlanes];
110 if (!fgRinBuffer) fgRinBuffer = new double[fgkMaxNofZPlanes];
111 if (!fgRoutBuffer) fgRoutBuffer = new double[fgkMaxNofZPlanes];
112}
113
114//_____________________________________________________________________________
115std::string RootGM::Polyhedra::Name() const { return fPolyhedra->GetName(); }
116
117//_____________________________________________________________________________
119{
120 return fPolyhedra->GetPhi1() * RootGM::Units::Angle();
121}
122
123//_____________________________________________________________________________
125{
126 return fPolyhedra->GetDphi() * RootGM::Units::Angle();
127}
128
129//_____________________________________________________________________________
130int RootGM::Polyhedra::NofSides() const { return fPolyhedra->GetNedges(); }
131
132//_____________________________________________________________________________
133int RootGM::Polyhedra::NofZPlanes() const { return fPolyhedra->GetNz(); }
134
135//_____________________________________________________________________________
137{
138 int nofZPlanes = NofZPlanes();
139 if (nofZPlanes > fgkMaxNofZPlanes) {
140 nofZPlanes = fgkMaxNofZPlanes;
141 std::cerr << "+++ Warning +++" << std::endl;
142 std::cerr << " Number of Zplanes > size of buffer." << std::endl;
143 std::cerr << " only " << nofZPlanes << " values are returned."
144 << std::endl;
145 }
146
147 for (int i = 0; i < nofZPlanes; i++)
148 fgZBuffer[i] = fPolyhedra->GetZ(i) * RootGM::Units::Length();
149
150 return fgZBuffer;
151}
152
153//_____________________________________________________________________________
155{
156 int nofZPlanes = NofZPlanes();
157 if (nofZPlanes > fgkMaxNofZPlanes) {
158 nofZPlanes = fgkMaxNofZPlanes;
159 std::cerr << "+++ Warning +++" << std::endl;
160 std::cerr << " Number of Zplanes > size of buffer." << std::endl;
161 std::cerr << " only " << nofZPlanes << " values are returned."
162 << std::endl;
163 }
164
165 for (int i = 0; i < nofZPlanes; i++)
166 fgRinBuffer[i] = fPolyhedra->GetRmin(i) * RootGM::Units::Length();
167
168 return fgRinBuffer;
169}
170
171//_____________________________________________________________________________
173{
174 int nofZPlanes = NofZPlanes();
175 if (nofZPlanes > fgkMaxNofZPlanes) {
176 nofZPlanes = fgkMaxNofZPlanes;
177 std::cerr << "+++ Warning +++" << std::endl;
178 std::cerr << " Number of Zplanes > size of buffer." << std::endl;
179 std::cerr << " only " << nofZPlanes << " values are returned."
180 << std::endl;
181 }
182
183 for (int i = 0; i < nofZPlanes; i++)
184 fgRoutBuffer[i] = fPolyhedra->GetRmax(i) * RootGM::Units::Length();
185
186 return fgRoutBuffer;
187}
VGM implementation for Root polyhedra solid.
Definition Polyhedra.h:32
virtual double * InnerRadiusValues() const
Return the array of innner radius of the planes in mm.
virtual int NofZPlanes() const
Return number of planes perpendicular to the z axis.
virtual double * ZValues() const
Return the array of z positions of the planes in mm.
virtual ~Polyhedra()
virtual double * OuterRadiusValues() const
Return the array of outer radius of the planes in mm.
virtual double StartPhi() const
Return starting phi angle of the segment in deg.
virtual int NofSides() const
Return number of sides of the cross section between the given phi limits.
virtual double DeltaPhi() const
Return opening phi angle of the segment in deg.
virtual std::string Name() const
Return the name of this solid.
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
static double Angle()
Return Root angle unit in VGM units.
Definition Units.h:85
BaseVGM utilities.
Definition utilities.h:23
VGM interfaces.
Definition VMedium.h:28