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

//_HADES_CLASS_DESCRIPTION 
///////////////////////////////////////////////////////////////////////////////
//
// HGeomTubs
//
// class for the GEANT shape TUBS
// 
// The size of a TUBS is defined by 4 'points'.
//   point 0:   origin of starting circle of the tubs;
//   point 1:   inner radius of starting circle,
//              outer radius of starting circle;
//              (z-component not used)
//   point 2:   origin of ending circle of the tubs;
//   point 3:   starting angle of the segment,
//              ending angle of the segment;
//              (z-component not used)
// 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 TUBS, which sits in the CAVE and is
// not rotated, is identical with the laboratory system.
//
///////////////////////////////////////////////////////////////////////////////

#include "hgeomtubs.h"
#include "hgeomvolume.h"
#include "hgeomvector.h"

ClassImp(HGeomTubs)

HGeomTubs::HGeomTubs() {
  // constructor
  fName="TUBS";
  nPoints=4;
  nParam=5;
  param=new TArrayD(nParam);
}


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


Int_t HGeomTubs::readPoints(fstream* pFile,HGeomVolume* volu) {
  // reads the 4 '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);
    sscanf(buf,"%lf%lf%lf",&x,&y,&z);
    volu->setPoint(i,x,y,z);
    i++;
    pFile->getline(buf,maxbuf);
    sscanf(buf,"%lf%lf",&x,&y);
    volu->setPoint(i,x,y,0.0);
  }
  return nPoints;
}


Bool_t HGeomTubs::writePoints(fstream* pFile,HGeomVolume* volu) {
  // writes the 4 '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==0 || i==2) 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 HGeomTubs::printPoints(HGeomVolume* volu) {
  // prints volume points to screen
  for(Int_t i=0;i<nPoints;i++) {
    HGeomVector& v=*(volu->getPoint(i));
    if (i==0 || i==2) 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* HGeomTubs::calcVoluParam(HGeomVolume* volu) {
  // calculates the parameters needed to create the shape TUBS 
  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);
  HGeomVector& v3=*(volu->getPoint(3));
  param->AddAt(v3(0),3);
  param->AddAt(v3(1),4);
  return param;
} 


void HGeomTubs::calcVoluPosition(HGeomVolume* volu,
          const HGeomTransform& dTC,const HGeomTransform& mTR) {
  // calculates the position of the center of the 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);
}
 hgeomtubs.cc:1
 hgeomtubs.cc:2
 hgeomtubs.cc:3
 hgeomtubs.cc:4
 hgeomtubs.cc:5
 hgeomtubs.cc:6
 hgeomtubs.cc:7
 hgeomtubs.cc:8
 hgeomtubs.cc:9
 hgeomtubs.cc:10
 hgeomtubs.cc:11
 hgeomtubs.cc:12
 hgeomtubs.cc:13
 hgeomtubs.cc:14
 hgeomtubs.cc:15
 hgeomtubs.cc:16
 hgeomtubs.cc:17
 hgeomtubs.cc:18
 hgeomtubs.cc:19
 hgeomtubs.cc:20
 hgeomtubs.cc:21
 hgeomtubs.cc:22
 hgeomtubs.cc:23
 hgeomtubs.cc:24
 hgeomtubs.cc:25
 hgeomtubs.cc:26
 hgeomtubs.cc:27
 hgeomtubs.cc:28
 hgeomtubs.cc:29
 hgeomtubs.cc:30
 hgeomtubs.cc:31
 hgeomtubs.cc:32
 hgeomtubs.cc:33
 hgeomtubs.cc:34
 hgeomtubs.cc:35
 hgeomtubs.cc:36
 hgeomtubs.cc:37
 hgeomtubs.cc:38
 hgeomtubs.cc:39
 hgeomtubs.cc:40
 hgeomtubs.cc:41
 hgeomtubs.cc:42
 hgeomtubs.cc:43
 hgeomtubs.cc:44
 hgeomtubs.cc:45
 hgeomtubs.cc:46
 hgeomtubs.cc:47
 hgeomtubs.cc:48
 hgeomtubs.cc:49
 hgeomtubs.cc:50
 hgeomtubs.cc:51
 hgeomtubs.cc:52
 hgeomtubs.cc:53
 hgeomtubs.cc:54
 hgeomtubs.cc:55
 hgeomtubs.cc:56
 hgeomtubs.cc:57
 hgeomtubs.cc:58
 hgeomtubs.cc:59
 hgeomtubs.cc:60
 hgeomtubs.cc:61
 hgeomtubs.cc:62
 hgeomtubs.cc:63
 hgeomtubs.cc:64
 hgeomtubs.cc:65
 hgeomtubs.cc:66
 hgeomtubs.cc:67
 hgeomtubs.cc:68
 hgeomtubs.cc:69
 hgeomtubs.cc:70
 hgeomtubs.cc:71
 hgeomtubs.cc:72
 hgeomtubs.cc:73
 hgeomtubs.cc:74
 hgeomtubs.cc:75
 hgeomtubs.cc:76
 hgeomtubs.cc:77
 hgeomtubs.cc:78
 hgeomtubs.cc:79
 hgeomtubs.cc:80
 hgeomtubs.cc:81
 hgeomtubs.cc:82
 hgeomtubs.cc:83
 hgeomtubs.cc:84
 hgeomtubs.cc:85
 hgeomtubs.cc:86
 hgeomtubs.cc:87
 hgeomtubs.cc:88
 hgeomtubs.cc:89
 hgeomtubs.cc:90
 hgeomtubs.cc:91
 hgeomtubs.cc:92
 hgeomtubs.cc:93
 hgeomtubs.cc:94
 hgeomtubs.cc:95
 hgeomtubs.cc:96
 hgeomtubs.cc:97
 hgeomtubs.cc:98
 hgeomtubs.cc:99
 hgeomtubs.cc:100
 hgeomtubs.cc:101
 hgeomtubs.cc:102
 hgeomtubs.cc:103
 hgeomtubs.cc:104
 hgeomtubs.cc:105
 hgeomtubs.cc:106
 hgeomtubs.cc:107
 hgeomtubs.cc:108
 hgeomtubs.cc:109
 hgeomtubs.cc:110
 hgeomtubs.cc:111
 hgeomtubs.cc:112
 hgeomtubs.cc:113
 hgeomtubs.cc:114
 hgeomtubs.cc:115
 hgeomtubs.cc:116
 hgeomtubs.cc:117
 hgeomtubs.cc:118
 hgeomtubs.cc:119
 hgeomtubs.cc:120
 hgeomtubs.cc:121
 hgeomtubs.cc:122
 hgeomtubs.cc:123
 hgeomtubs.cc:124
 hgeomtubs.cc:125
 hgeomtubs.cc:126
 hgeomtubs.cc:127
 hgeomtubs.cc:128
 hgeomtubs.cc:129
 hgeomtubs.cc:130
 hgeomtubs.cc:131
 hgeomtubs.cc:132
 hgeomtubs.cc:133
 hgeomtubs.cc:134
 hgeomtubs.cc:135