ROOT logo
//*-- AUTHOR : Ilse Koenig
//*-- Modified : 11/11/2003 by Ilse Koenig
//*-- Modified : 28/06/99 by Ilse Koenig

//_HADES_CLASS_DESCRIPTION 
///////////////////////////////////////////////////////////////////////////////
//
// HGeomTube
//
// class for the GEANT shape TUBE
// 
// The size of a TUBE is defined by 3 'points'.
//   point 0:   origin of starting circle of the tube;
//   point 1:   inner radius of starting circle,
//              outer radius of starting circle;
//              (z-component not used)
//   point 2:   origin of ending circle of the tube;
// Warning: The x- and y-values of point 0 and 2 have to be the same!!!!
//          A rotation has to be desribed via the rotation matrix.
//
// The intrinsic coordinate system of a TUBE, which sits in the CAVE and is
// not rotated, is identical with the laboratory system.
//
///////////////////////////////////////////////////////////////////////////////

#include "hgeomtube.h"
#include "hgeomvolume.h"
#include "hgeomvector.h"

ClassImp(HGeomTube)

HGeomTube::HGeomTube() {
  // constructor
  fName="TUBE";
  nPoints=3;
  nParam=3;
  param=new TArrayD(nParam);
}


HGeomTube::~HGeomTube() {
  // default destructor
  if (param) {
    delete param;
    param=0;
  }
  if (center) {
    delete center;
    center=0;
  }
  if (position) {
    delete position;
    position=0;
  }
}


Int_t HGeomTube::readPoints(fstream* pFile,HGeomVolume* volu) {
  // reads the 3 'points' decribed above from ascii file
  // if the array of points is not existing in the volume it is created and
  // the values are stored inside
  // returns the number of points
  if (!pFile) return 0;
  if (volu->getNumPoints()!=nPoints) volu->createPoints(nPoints);
  Double_t x,y,z;
  const Int_t maxbuf=155;
  Text_t buf[maxbuf];
  for(Int_t i=0;i<nPoints;i++) {
    pFile->getline(buf,maxbuf);
    if (i!=1) {
      sscanf(buf,"%lf%lf%lf",&x,&y,&z);
      volu->setPoint(i,x,y,z);
    } else {
      sscanf(buf,"%lf%lf",&x,&y);
      volu->setPoint(i,x,y,0.0);
    }
  }
  return nPoints;
}


Bool_t HGeomTube::writePoints(fstream* pFile,HGeomVolume* volu) {
  // writes the 3 'points' decribed above to ascii file
  if (!pFile) return kFALSE;  
  Text_t buf[155];
  for(Int_t i=0;i<nPoints;i++) {
    HGeomVector& v=*(volu->getPoint(i));
    if (i!=1) sprintf(buf,"%9.3f%10.3f%10.3f\n",v(0),v(1),v(2));
    else sprintf(buf,"%9.3f%10.3f\n",v(0),v(1));
    pFile->write(buf,strlen(buf));
  }
  return kTRUE;
}


void HGeomTube::printPoints(HGeomVolume* volu) {
  // prints volume points to screen
  for(Int_t i=0;i<nPoints;i++) {
    HGeomVector& v=*(volu->getPoint(i));
    if (i!=1) printf("%9.3f%10.3f%10.3f\n",v(0),v(1),v(2));
    else printf("%9.3f%10.3f\n",v(0),v(1));
  }
}


TArrayD* HGeomTube::calcVoluParam(HGeomVolume* volu) {
  // calculates the parameters needed to create the shape TUBE 
  Double_t fac=10.;
  HGeomVector& v1=*(volu->getPoint(1));
  param->AddAt(v1(0)/fac,0);
  param->AddAt(v1(1)/fac,1);
  HGeomVector v=*(volu->getPoint(2)) - *(volu->getPoint(0));
  param->AddAt(TMath::Abs(v(2))/fac/2.,2);
  return param;
} 


void HGeomTube::calcVoluPosition(HGeomVolume* volu,
          const HGeomTransform& dTC,const HGeomTransform& mTR) {
  // calculates the position of the center of the ROOT volume in the intrinsic
  // coordinate system and stores it in the data element 'center'
  // calls the function posInMother(...) to calculate the position of the
  // volume in its mother 
  Double_t t[3]={0.,0.,0.};
  HGeomVector v=*(volu->getPoint(2)) + *(volu->getPoint(0));
  t[2]=v(2)/2.;  
  center->clear();
  center->setTransVector(t);
  posInMother(dTC,mTR);
}
 hgeomtube.cc:1
 hgeomtube.cc:2
 hgeomtube.cc:3
 hgeomtube.cc:4
 hgeomtube.cc:5
 hgeomtube.cc:6
 hgeomtube.cc:7
 hgeomtube.cc:8
 hgeomtube.cc:9
 hgeomtube.cc:10
 hgeomtube.cc:11
 hgeomtube.cc:12
 hgeomtube.cc:13
 hgeomtube.cc:14
 hgeomtube.cc:15
 hgeomtube.cc:16
 hgeomtube.cc:17
 hgeomtube.cc:18
 hgeomtube.cc:19
 hgeomtube.cc:20
 hgeomtube.cc:21
 hgeomtube.cc:22
 hgeomtube.cc:23
 hgeomtube.cc:24
 hgeomtube.cc:25
 hgeomtube.cc:26
 hgeomtube.cc:27
 hgeomtube.cc:28
 hgeomtube.cc:29
 hgeomtube.cc:30
 hgeomtube.cc:31
 hgeomtube.cc:32
 hgeomtube.cc:33
 hgeomtube.cc:34
 hgeomtube.cc:35
 hgeomtube.cc:36
 hgeomtube.cc:37
 hgeomtube.cc:38
 hgeomtube.cc:39
 hgeomtube.cc:40
 hgeomtube.cc:41
 hgeomtube.cc:42
 hgeomtube.cc:43
 hgeomtube.cc:44
 hgeomtube.cc:45
 hgeomtube.cc:46
 hgeomtube.cc:47
 hgeomtube.cc:48
 hgeomtube.cc:49
 hgeomtube.cc:50
 hgeomtube.cc:51
 hgeomtube.cc:52
 hgeomtube.cc:53
 hgeomtube.cc:54
 hgeomtube.cc:55
 hgeomtube.cc:56
 hgeomtube.cc:57
 hgeomtube.cc:58
 hgeomtube.cc:59
 hgeomtube.cc:60
 hgeomtube.cc:61
 hgeomtube.cc:62
 hgeomtube.cc:63
 hgeomtube.cc:64
 hgeomtube.cc:65
 hgeomtube.cc:66
 hgeomtube.cc:67
 hgeomtube.cc:68
 hgeomtube.cc:69
 hgeomtube.cc:70
 hgeomtube.cc:71
 hgeomtube.cc:72
 hgeomtube.cc:73
 hgeomtube.cc:74
 hgeomtube.cc:75
 hgeomtube.cc:76
 hgeomtube.cc:77
 hgeomtube.cc:78
 hgeomtube.cc:79
 hgeomtube.cc:80
 hgeomtube.cc:81
 hgeomtube.cc:82
 hgeomtube.cc:83
 hgeomtube.cc:84
 hgeomtube.cc:85
 hgeomtube.cc:86
 hgeomtube.cc:87
 hgeomtube.cc:88
 hgeomtube.cc:89
 hgeomtube.cc:90
 hgeomtube.cc:91
 hgeomtube.cc:92
 hgeomtube.cc:93
 hgeomtube.cc:94
 hgeomtube.cc:95
 hgeomtube.cc:96
 hgeomtube.cc:97
 hgeomtube.cc:98
 hgeomtube.cc:99
 hgeomtube.cc:100
 hgeomtube.cc:101
 hgeomtube.cc:102
 hgeomtube.cc:103
 hgeomtube.cc:104
 hgeomtube.cc:105
 hgeomtube.cc:106
 hgeomtube.cc:107
 hgeomtube.cc:108
 hgeomtube.cc:109
 hgeomtube.cc:110
 hgeomtube.cc:111
 hgeomtube.cc:112
 hgeomtube.cc:113
 hgeomtube.cc:114
 hgeomtube.cc:115
 hgeomtube.cc:116
 hgeomtube.cc:117
 hgeomtube.cc:118
 hgeomtube.cc:119
 hgeomtube.cc:120
 hgeomtube.cc:121
 hgeomtube.cc:122
 hgeomtube.cc:123
 hgeomtube.cc:124
 hgeomtube.cc:125
 hgeomtube.cc:126
 hgeomtube.cc:127
 hgeomtube.cc:128
 hgeomtube.cc:129
 hgeomtube.cc:130