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

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

#include "hgeomcone.h"
#include "hgeomvolume.h"
#include "hgeomvector.h"

ClassImp(HGeomCone)

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


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


Int_t HGeomCone::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 HGeomCone::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 HGeomCone::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* HGeomCone::calcVoluParam(HGeomVolume* volu) {
  // calculates the parameters needed to create the shape CONE 
  Double_t fac=10.;
  HGeomVector v=*(volu->getPoint(2)) - *(volu->getPoint(0));
  param->AddAt(TMath::Abs(v(2))/fac/2.,0);
  HGeomVector& v1=*(volu->getPoint(1));
  param->AddAt(v1(0)/fac,1);
  param->AddAt(v1(1)/fac,2);
  HGeomVector& v3=*(volu->getPoint(3));
  param->AddAt(v3(0)/fac,3);
  param->AddAt(v3(1)/fac,4);
  return param;
} 


void HGeomCone::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);
}

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