00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TCTUB.h"
00013 #include "TClass.h"
00014 #include "TMath.h"
00015
00016 ClassImp(TCTUB)
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 TCTUB::TCTUB()
00044 {
00045
00046
00047 fCosLow[0] = 0.;
00048 fCosLow[1] = 0.;
00049 fCosLow[2] = 0.;
00050 fCosHigh[0] = 0.;
00051 fCosHigh[1] = 0.;
00052 fCosHigh[2] = 0.;
00053 }
00054
00055
00056
00057 TCTUB::TCTUB(const char *name, const char *title, const char *material, Float_t rmin,
00058 Float_t rmax, Float_t dz, Float_t phi1, Float_t phi2,
00059 Float_t coslx, Float_t cosly, Float_t coslz,
00060 Float_t coshx, Float_t coshy, Float_t coshz)
00061 : TTUBS(name,title,material,rmin,rmax,dz,phi1,phi2)
00062 {
00063
00064
00065 fCosLow[0] = coslx;
00066 fCosLow[1] = cosly;
00067 fCosLow[2] = coslz;
00068 fCosHigh[0] = coshx;
00069 fCosHigh[1] = coshy;
00070 fCosHigh[2] = coshz;
00071 TMath::Normalize(fCosLow);
00072 TMath::Normalize(fCosHigh);
00073 }
00074
00075
00076
00077 TCTUB::TCTUB(const char *name, const char *title, const char *material, Float_t rmin,
00078 Float_t rmax, Float_t dz, Float_t phi1, Float_t phi2,
00079 Float_t *lowNormal, Float_t *highNormal)
00080 : TTUBS(name,title,material,rmin,rmax,dz,phi1,phi2)
00081 {
00082
00083
00084 memcpy(fCosLow, lowNormal, sizeof(fCosLow) );
00085 memcpy(fCosHigh,highNormal,sizeof(fCosHigh));
00086 TMath::Normalize(fCosLow);
00087 TMath::Normalize(fCosHigh);
00088 }
00089
00090
00091
00092 TCTUB::~TCTUB()
00093 {
00094
00095 }
00096
00097
00098
00099 static Double_t Product(const Double_t *x, const Float_t *y)
00100 {
00101
00102
00103 Double_t s = 0;
00104 for (int i= 0 ; i <2 ; i++ ) s += x[i]*y[i];
00105 return s;
00106 }
00107
00108
00109
00110 void TCTUB::SetPoints(Double_t *points) const
00111 {
00112
00113
00114 Float_t dz;
00115 Int_t j, n;
00116
00117 n = GetNumberOfDivisions()+1;
00118
00119 dz = TTUBE::fDz;
00120
00121 if (points) {
00122 Int_t indx = 0;
00123
00124 if (!fCoTab) MakeTableOfCoSin();
00125
00126 for (j = 0; j < n; j++) {
00127 points[indx+6*n] = points[indx] = fRmin * fCoTab[j];
00128 indx++;
00129 points[indx+6*n] = points[indx] = fAspectRatio*fRmin * fSiTab[j];
00130 indx++;
00131 points[indx+6*n] = dz;
00132 points[indx+6*n]-= Product(&points[indx+6*n-2],fCosHigh)/fCosHigh[2];
00133 points[indx] =-dz;
00134 points[indx] -= Product(&points[indx-2],fCosLow)/fCosLow[2];
00135 indx++;
00136 }
00137 for (j = 0; j < n; j++) {
00138 points[indx+6*n] = points[indx] = fRmax * fCoTab[j];
00139 indx++;
00140 points[indx+6*n] = points[indx] = fAspectRatio*fRmax * fSiTab[j];
00141 indx++;
00142 points[indx+6*n] = dz;
00143 points[indx+6*n]-= Product(&points[indx+6*n-2],fCosHigh)/fCosHigh[2];
00144 points[indx] =-dz;
00145 points[indx] -= Product(&points[indx-2],fCosLow)/fCosLow[2];
00146 indx++;
00147 }
00148 }
00149 }
00150
00151
00152
00153 void TCTUB::Streamer(TBuffer &R__b)
00154 {
00155
00156
00157 if (R__b.IsReading()) {
00158 UInt_t R__s, R__c;
00159 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
00160 if (R__v > 1) {
00161 R__b.ReadClassBuffer(TCTUB::Class(), this, R__v, R__s, R__c);
00162 return;
00163 }
00164
00165 TTUBS::Streamer(R__b);
00166 R__b.ReadStaticArray(fCosLow);
00167 R__b.ReadStaticArray(fCosHigh);
00168 R__b.CheckByteCount(R__s, R__c, TCTUB::IsA());
00169
00170
00171 } else {
00172 R__b.WriteClassBuffer(TCTUB::Class(),this);
00173 }
00174 }