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,
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,
82 : TTUBS(name,title,material,rmin,rmax,dz,phi1,phi2)
83{
84 memcpy(fCosLow, lowNormal, sizeof(fCosLow) );
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++;
128 indx++;
129 points[indx+6*n] = dz;
131 points[indx] =-dz;
133 indx++;
134 }
135 for (j = 0; j < n; j++) {
136 points[indx+6*n] = points[indx] = fRmax * fCoTab[j];
137 indx++;
139 indx++;
140 points[indx+6*n] = dz;
142 points[indx] =-dz;
144 indx++;
145 }
146 }
147}
148
149////////////////////////////////////////////////////////////////////////////////
150/// Stream an object of class TCTUB.
151
153{
154 if (R__b.IsReading()) {
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
163 R__b.ReadStaticArray(fCosLow);
164 R__b.ReadStaticArray(fCosHigh);
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}
short Version_t
Class version identifier (short)
Definition RtypesCore.h:79
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
static Double_t Product(const Double_t *x, const Float_t *y)
Product.
Definition TCTUB.cxx:100
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
char name[80]
Definition TGX11.cxx:110
Buffer base class used for serializing objects.
Definition TBuffer.h:43
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 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
void Streamer(TBuffer &) override
Stream an object of class TTUBE.
void MakeTableOfCoSin() const override
Make table of sine and cosine.
Definition TTUBS.cxx:78
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