Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TCTUB.cxx
Go to the documentation of this file.
1// @(#)root/g3d:$Id$
2// Author: Rene Brun 26/06/97
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TCTUB.h"
13#include "TBuffer.h"
14#include "TMath.h"
15
16
17/** \class TCTUB
18\ingroup g3d
19A cut tube with 11 parameters.
20
21\image html g3d_ctub.png
22
23The first 5 parameters
24are the same as for the TUBS. The remaining 6 parameters
25are the director cosines of the surfaces cutting the tube
26respectively at the low and high Z values.
27
28 - name: name of the shape
29 - title: shape's title
30 - material: (see TMaterial)
31 - rmin: inside radius
32 - rmax: outside radius
33 - dz: half length in z
34 - phi1: starting angle of the segment
35 - phi2: ending angle of the segment
36 - coslx: x dir cosinus at low z face
37 - cosly: y dir cosinus at low z face
38 - coslz: z dir cosinus at low z face
39 - coshx: x dir cosinus at high z face
40 - coshy: y dir cosinus at high z face
41 - coshz: z dir cosinus at high z face
42*/
43
44////////////////////////////////////////////////////////////////////////////////
45/// CTUB shape default constructor
46
48{
49 fCosLow[0] = 0.;
50 fCosLow[1] = 0.;
51 fCosLow[2] = 0.;
52 fCosHigh[0] = 0.;
53 fCosHigh[1] = 0.;
54 fCosHigh[2] = 0.;
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// CTUB shape normal constructor
59
60TCTUB::TCTUB(const char *name, const char *title, const char *material, Float_t rmin,
61 Float_t rmax, Float_t dz, Float_t phi1, Float_t phi2,
62 Float_t coslx, Float_t cosly, Float_t coslz,
63 Float_t coshx, Float_t coshy, Float_t coshz)
64 : TTUBS(name,title,material,rmin,rmax,dz,phi1,phi2)
65{
66 fCosLow[0] = coslx;
67 fCosLow[1] = cosly;
68 fCosLow[2] = coslz;
69 fCosHigh[0] = coshx;
70 fCosHigh[1] = coshy;
71 fCosHigh[2] = coshz;
74}
75
76////////////////////////////////////////////////////////////////////////////////
77/// CTUB shape normal constructor
78
79TCTUB::TCTUB(const char *name, const char *title, const char *material, Float_t rmin,
80 Float_t rmax, Float_t dz, Float_t phi1, Float_t phi2,
81 Float_t *lowNormal, Float_t *highNormal)
82 : TTUBS(name,title,material,rmin,rmax,dz,phi1,phi2)
83{
84 memcpy(fCosLow, lowNormal, sizeof(fCosLow) );
85 memcpy(fCosHigh,highNormal,sizeof(fCosHigh));
88}
89
90////////////////////////////////////////////////////////////////////////////////
91/// CTUB shape default destructor
92
94{
95}
96
97////////////////////////////////////////////////////////////////////////////////
98/// Product.
99
100static Double_t Product(const Double_t *x, const Float_t *y)
101{
102 Double_t s = 0;
103 for (int i= 0 ; i <2 ; i++ ) s += x[i]*y[i];
104 return s;
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Create TUBS points
109
111{
112 Float_t dz;
113 Int_t j, n;
114
116
117 dz = TTUBE::fDz;
118
119 if (points) {
120 Int_t indx = 0;
121
122 if (!fCoTab) MakeTableOfCoSin();
123
124 for (j = 0; j < n; j++) {
125 points[indx+6*n] = points[indx] = fRmin * fCoTab[j];
126 indx++;
127 points[indx+6*n] = points[indx] = fAspectRatio*fRmin * fSiTab[j];
128 indx++;
129 points[indx+6*n] = dz;
130 points[indx+6*n]-= Product(&points[indx+6*n-2],fCosHigh)/fCosHigh[2];
131 points[indx] =-dz;
132 points[indx] -= Product(&points[indx-2],fCosLow)/fCosLow[2];
133 indx++;
134 }
135 for (j = 0; j < n; j++) {
136 points[indx+6*n] = points[indx] = fRmax * fCoTab[j];
137 indx++;
138 points[indx+6*n] = points[indx] = fAspectRatio*fRmax * fSiTab[j];
139 indx++;
140 points[indx+6*n] = dz;
141 points[indx+6*n]-= Product(&points[indx+6*n-2],fCosHigh)/fCosHigh[2];
142 points[indx] =-dz;
143 points[indx] -= Product(&points[indx-2],fCosLow)/fCosLow[2];
144 indx++;
145 }
146 }
147}
148
149////////////////////////////////////////////////////////////////////////////////
150/// Stream an object of class TCTUB.
151
153{
154 if (R__b.IsReading()) {
155 UInt_t R__s, R__c;
156 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
157 if (R__v > 1) {
158 R__b.ReadClassBuffer(TCTUB::Class(), this, R__v, R__s, R__c);
159 return;
160 }
161 //====process old versions before automatic schema evolution
162 TTUBS::Streamer(R__b);
165 R__b.CheckByteCount(R__s, R__c, TCTUB::IsA());
166 //====end of old versions
167
168 } else {
169 R__b.WriteClassBuffer(TCTUB::Class(),this);
170 }
171}
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
short Version_t
Class version identifier (short).
Definition RtypesCore.h:79
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
static Double_t Product(const Double_t *x, const Float_t *y)
Product.
Definition TCTUB.cxx:100
char name[80]
Definition TGX11.cxx:148
point * points
Definition X3DBuffer.c:22
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t ReadStaticArray(Bool_t *b)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
void SetPoints(Double_t *points) const override
Create TUBS points.
Definition TCTUB.cxx:110
Float_t fCosHigh[3]
Definition TCTUB.h:33
void Streamer(TBuffer &) override
Stream an object of class TCTUB.
Definition TCTUB.cxx:152
~TCTUB() override
CTUB shape default destructor.
Definition TCTUB.cxx:93
TCTUB()
CTUB shape default constructor.
Definition TCTUB.cxx:47
Float_t fCosLow[3]
Definition TCTUB.h:32
static TClass * Class()
TClass * IsA() const override
Definition TCTUB.h:47
Double_t * fCoTab
! Table of cos(fPhi1) .... cos(fPhil+fDphi1)
Definition TTUBE.h:45
Double_t * fSiTab
! Table of sin(fPhi1) .... sin(fPhil+fDphi1)
Definition TTUBE.h:44
Float_t fRmax
Definition TTUBE.h:36
virtual Int_t GetNumberOfDivisions() const
Definition TTUBE.h:67
Float_t fAspectRatio
Definition TTUBE.h:41
Float_t fRmin
Definition TTUBE.h:35
Float_t fDz
Definition TTUBE.h:38
void Streamer(TBuffer &) override
Stream an object of class TTUBE.
void MakeTableOfCoSin() const override
Make table of sine and cosine.
Definition TTUBS.cxx:78
TTUBS()
TUBS shape default constructor.
Definition TTUBS.cxx:45
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Float_t Normalize(Float_t v[3])
Normalize a vector v in place.
Definition TMath.cxx:518