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