Logo ROOT  
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 "TMath.h"
15 
17 
18 /** \class TCTUB
19 \ingroup g3d
20 A cut tube with 11 parameters.
21 
22 \image html g3d_ctub.png
23 
24 The first 5 parameters
25 are the same as for the TUBS. The remaining 6 parameters
26 are the director cosines of the surfaces cutting the tube
27 respectively 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 
61 TCTUB::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 
80 TCTUB::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 
101 static 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 
116  n = GetNumberOfDivisions()+1;
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 
153 void 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);
164  R__b.ReadStaticArray(fCosLow);
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 }
n
const Int_t n
Definition: legend1.C:16
Version_t
short Version_t
Definition: RtypesCore.h:65
TTUBE::fDz
Float_t fDz
Definition: TTUBE.h:38
TCTUB::~TCTUB
virtual ~TCTUB()
CTUB shape default destructor.
Definition: TCTUB.cxx:94
TTUBE::fCoTab
Double_t * fCoTab
Table of sin(fPhi1) .... sin(fPhil+fDphi1)
Definition: TTUBE.h:45
TBuffer::ReadStaticArray
virtual Int_t ReadStaticArray(Bool_t *b)=0
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TCTUB::fCosLow
Float_t fCosLow[3]
Definition: TCTUB.h:38
TBuffer::ReadClassBuffer
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
TCTUB::SetPoints
virtual void SetPoints(Double_t *points) const
Create TUBS points.
Definition: TCTUB.cxx:111
Float_t
float Float_t
Definition: RtypesCore.h:57
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
TTUBE::GetNumberOfDivisions
virtual Int_t GetNumberOfDivisions() const
Definition: TTUBE.h:67
x
Double_t x[n]
Definition: legend1.C:17
TCTUB.h
TTUBS
Definition: TTUBS.h:29
TBuffer
Definition: TBuffer.h:43
TBuffer::CheckByteCount
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
TTUBE::fRmax
Float_t fRmax
Definition: TTUBE.h:36
TCTUB::TCTUB
TCTUB()
CTUB shape default constructor.
Definition: TCTUB.cxx:48
TBuffer.h
TBuffer::WriteClassBuffer
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
TMath::Normalize
Float_t Normalize(Float_t v[3])
Normalize a vector v in place.
Definition: TMath.cxx:495
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
y
Double_t y[n]
Definition: legend1.C:17
TTUBE::fAspectRatio
Float_t fAspectRatio
Definition: TTUBE.h:41
TBuffer::ReadVersion
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
TTUBE::fRmin
Float_t fRmin
Definition: TTUBE.h:35
TBuffer::IsReading
Bool_t IsReading() const
Definition: TBuffer.h:86
Double_t
double Double_t
Definition: RtypesCore.h:59
Product
static Double_t Product(const Double_t *x, const Float_t *y)
Product.
Definition: TCTUB.cxx:101
points
point * points
Definition: X3DBuffer.c:22
TTUBE::fSiTab
Double_t * fSiTab
Definition: TTUBE.h:44
TCTUB
Definition: TCTUB.h:29
name
char name[80]
Definition: TGX11.cxx:110
Class
void Class()
Definition: Class.C:29
TTUBS::MakeTableOfCoSin
virtual void MakeTableOfCoSin() const
Make table of sine and cosine.
Definition: TTUBS.cxx:79
TCTUB::fCosHigh
Float_t fCosHigh[3]
Definition: TCTUB.h:39
TMath.h
int