TCTUB.cxx

Go to the documentation of this file.
00001 // @(#)root/g3d:$Id: TCTUB.cxx 31624 2009-12-08 09:58:40Z couet $
00002 // Author: Rene Brun   26/06/97
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TCTUB.h"
00013 #include "TClass.h"
00014 #include "TMath.h"
00015 
00016 ClassImp(TCTUB)
00017 
00018 //______________________________________________________________________________
00019 // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/ctub.gif"> </P> End_Html
00020 //                                                                        //
00021 // 'CTUB' is a cut  tube with 11 parameters.  The  first 5 parameters     //
00022 //        are the same  as for the TUBS.  The  remaining 6 parameters     //
00023 //        are the director  cosines of the surfaces  cutting the tube     //
00024 //        respectively at the low and high Z values.                      //
00025 //                                                                        //
00026 //     - name       name of the shape
00027 //     - title      shape's title
00028 //     - material  (see TMaterial)
00029 //     - rmin       inside radius
00030 //     - rmax       outside radius
00031 //     - dz         half length in z
00032 //     - phi1       starting angle of the segment
00033 //     - phi2       ending angle of the segment
00034 //     - coslx      x dir cosinus at low z face
00035 //     - cosly      y dir cosinus at low z face
00036 //     - coslz      z dir cosinus at low z face
00037 //     - coshx      x dir cosinus at high z face
00038 //     - coshy      y dir cosinus at high z face
00039 //     - coshz      z dir cosinus at high z face
00040 
00041 
00042 //______________________________________________________________________________
00043 TCTUB::TCTUB()
00044 {
00045    // CTUB shape default constructor
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    // CTUB shape normal constructor
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    // CTUB shape normal constructor
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    // CTUB shape default destructor
00095 }
00096 
00097 
00098 //______________________________________________________________________________
00099 static Double_t Product(const Double_t *x, const Float_t *y)
00100 {
00101    // Product.
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    // Create TUBS points
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    // Stream an object of class TCTUB.
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       //====process old versions before automatic schema evolution
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       //====end of old versions
00170       
00171    } else {
00172       R__b.WriteClassBuffer(TCTUB::Class(),this);
00173    }
00174 }

Generated on Tue Jul 5 14:16:40 2011 for ROOT_528-00b_version by  doxygen 1.5.1