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