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
17
18/** \class TCTUB
19\ingroup g3d
20A cut tube with 11 parameters.
21
22\image html g3d_ctub.png
23
24The first 5 parameters
25are the same as for the TUBS. The remaining 6 parameters
26are the director cosines of the surfaces cutting the tube
27respectively at the low and high Z values.
28
29 - name: name of the shape
30 - title: shape's title
31 - material: (see TMaterial)
32 - rmin: inside radius
33 - rmax: outside radius
34 - dz: half length in z
35 - phi1: starting angle of the segment
36 - phi2: ending angle of the segment
37 - coslx: x dir cosinus at low z face
38 - cosly: y dir cosinus at low z face
39 - coslz: z dir cosinus at low z face
40 - coshx: x dir cosinus at high z face
41 - coshy: y dir cosinus at high z face
42 - coshz: z dir cosinus at high z face
43*/
44
45////////////////////////////////////////////////////////////////////////////////
46/// CTUB shape default constructor
47
49{
50 fCosLow[0] = 0.;
51 fCosLow[1] = 0.;
52 fCosLow[2] = 0.;
53 fCosHigh[0] = 0.;
54 fCosHigh[1] = 0.;
55 fCosHigh[2] = 0.;
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// CTUB shape normal constructor
60
61TCTUB::TCTUB(const char *name, const char *title, const char *material, Float_t rmin,
62 Float_t rmax, Float_t dz, Float_t phi1, Float_t phi2,
63 Float_t coslx, Float_t cosly, Float_t coslz,
64 Float_t coshx, Float_t coshy, Float_t coshz)
65 : TTUBS(name,title,material,rmin,rmax,dz,phi1,phi2)
66{
67 fCosLow[0] = coslx;
68 fCosLow[1] = cosly;
69 fCosLow[2] = coslz;
70 fCosHigh[0] = coshx;
71 fCosHigh[1] = coshy;
72 fCosHigh[2] = coshz;
75}
76
77////////////////////////////////////////////////////////////////////////////////
78/// CTUB shape normal constructor
79
80TCTUB::TCTUB(const char *name, const char *title, const char *material, Float_t rmin,
81 Float_t rmax, Float_t dz, Float_t phi1, Float_t phi2,
82 Float_t *lowNormal, Float_t *highNormal)
83 : TTUBS(name,title,material,rmin,rmax,dz,phi1,phi2)
84{
85 memcpy(fCosLow, lowNormal, sizeof(fCosLow) );
86 memcpy(fCosHigh,highNormal,sizeof(fCosHigh));
89}
90
91////////////////////////////////////////////////////////////////////////////////
92/// CTUB shape default destructor
93
95{
96}
97
98////////////////////////////////////////////////////////////////////////////////
99/// Product.
100
101static Double_t Product(const Double_t *x, const Float_t *y)
102{
103 Double_t s = 0;
104 for (int i= 0 ; i <2 ; i++ ) s += x[i]*y[i];
105 return s;
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Create TUBS points
110
112{
113 Float_t dz;
114 Int_t j, n;
115
117
118 dz = TTUBE::fDz;
119
120 if (points) {
121 Int_t indx = 0;
122
123 if (!fCoTab) MakeTableOfCoSin();
124
125 for (j = 0; j < n; j++) {
126 points[indx+6*n] = points[indx] = fRmin * fCoTab[j];
127 indx++;
128 points[indx+6*n] = points[indx] = fAspectRatio*fRmin * fSiTab[j];
129 indx++;
130 points[indx+6*n] = dz;
131 points[indx+6*n]-= Product(&points[indx+6*n-2],fCosHigh)/fCosHigh[2];
132 points[indx] =-dz;
133 points[indx] -= Product(&points[indx-2],fCosLow)/fCosLow[2];
134 indx++;
135 }
136 for (j = 0; j < n; j++) {
137 points[indx+6*n] = points[indx] = fRmax * fCoTab[j];
138 indx++;
139 points[indx+6*n] = points[indx] = fAspectRatio*fRmax * fSiTab[j];
140 indx++;
141 points[indx+6*n] = dz;
142 points[indx+6*n]-= Product(&points[indx+6*n-2],fCosHigh)/fCosHigh[2];
143 points[indx] =-dz;
144 points[indx] -= Product(&points[indx-2],fCosLow)/fCosLow[2];
145 indx++;
146 }
147 }
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Stream an object of class TCTUB.
152
153void TCTUB::Streamer(TBuffer &R__b)
154{
155 if (R__b.IsReading()) {
156 UInt_t R__s, R__c;
157 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
158 if (R__v > 1) {
159 R__b.ReadClassBuffer(TCTUB::Class(), this, R__v, R__s, R__c);
160 return;
161 }
162 //====process old versions before automatic schema evolution
163 TTUBS::Streamer(R__b);
166 R__b.CheckByteCount(R__s, R__c, TCTUB::IsA());
167 //====end of old versions
168
169 } else {
170 R__b.WriteClassBuffer(TCTUB::Class(),this);
171 }
172}
short Version_t
Definition RtypesCore.h:65
unsigned int UInt_t
Definition RtypesCore.h:46
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
#define ClassImp(name)
Definition Rtypes.h:364
static Double_t Product(const Double_t *x, const Float_t *y)
Product.
Definition TCTUB.cxx:101
char name[80]
Definition TGX11.cxx:110
point * points
Definition X3DBuffer.c:22
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=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
A cut tube with 11 parameters.
Definition TCTUB.h:29
virtual void SetPoints(Double_t *points) const
Create TUBS points.
Definition TCTUB.cxx:111
Float_t fCosHigh[3]
Definition TCTUB.h:33
virtual ~TCTUB()
CTUB shape default destructor.
Definition TCTUB.cxx:94
TCTUB()
CTUB shape default constructor.
Definition TCTUB.cxx:48
Float_t fCosLow[3]
Definition TCTUB.h:32
Double_t * fCoTab
Table of sin(fPhi1) .... sin(fPhil+fDphi1)
Definition TTUBE.h:45
Double_t * fSiTab
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
A segment of a tube.
Definition TTUBS.h:29
virtual void MakeTableOfCoSin() const
Make table of sine and cosine.
Definition TTUBS.cxx:79
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:495