ROOT logo
//*-- AUTHOR : Ilse Koenig
//*-- Modified : 11/11/2003 by Ilse Koenig
//*-- Modified : 26/11/2001 by Ilse Koenig

//_HADES_CLASS_DESCRIPTION 
///////////////////////////////////////////////////////////////////////////////
//
// HGeomPgon
//
// class for the GEANT shape PGON
// 
// The size of a PGON is defined by a variable number of 'points'.
//   point 0:   number of planes perpendicular to the z axis where the
//              dimension of the section is given;
//   point 1:   azimutal angle phi at which the volume begins,
//              opening angle dphi of the volume,
//              number of sides of the cross section between the phi-limits;
//   point 2ff: z coordinate of the section,
//              inner radius at position z,
//              outer radius at position z;
//
// The intrinsic coordinate system of a PGON, which sits in the CAVE and is
// not rotated, is identical with the laboratory system.
//
///////////////////////////////////////////////////////////////////////////////

#include "hgeompgon.h"
#include "hgeomvolume.h"
#include "hgeomvector.h"

ClassImp(HGeomPgon)

HGeomPgon::HGeomPgon() {
  // constructor
  fName="PGON";
  nPoints=0;
  nParam=0;
}


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


Int_t HGeomPgon::readPoints(fstream* pFile,HGeomVolume* volu) {
  // reads the 'points' decribed above from ascii file and stores them in the
  // array 'points' of the volume
  // returns the number of points
  if (!pFile) return 0;
  Double_t x,y,z;
  const Int_t maxbuf=155;
  Text_t buf[maxbuf];
  pFile->getline(buf,maxbuf);
  Int_t n;
  sscanf(buf,"%i",&n);
  if (n<=0) return 0;
  nPoints=n+2;
  if (volu->getNumPoints()!=nPoints) volu->createPoints(nPoints);
  volu->setPoint(0,(Double_t)n,0.0,0.0);
  for(Int_t i=1;i<nPoints;i++) {
    pFile->getline(buf,maxbuf);
    sscanf(buf,"%lf%lf%lf",&x,&y,&z);
    volu->setPoint(i,x,y,z);
  }
  return nPoints;
}


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


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


TArrayD* HGeomPgon::calcVoluParam(HGeomVolume* volu) {
  // calculates the parameters needed to create the shape PGON 
  Double_t fac=10.;
  nPoints=volu->getNumPoints();
  nParam=nPoints*3-2;
  if (param && param->GetSize()!=nParam) {
    delete param;
    param=0;
  }
  if (!param) param=new TArrayD(nParam);
  HGeomVector& v1=*(volu->getPoint(1));
  Int_t k=0;
  param->AddAt(v1(0),k++);
  param->AddAt(v1(1),k++);
  param->AddAt(v1(2),k++);
  param->AddAt((nPoints-2),k++);
  for(Int_t i=2;i<nPoints;i++) {
    HGeomVector& v=*(volu->getPoint(i));
    param->AddAt(v(0)/fac,k++);
    param->AddAt(v(1)/fac,k++);
    param->AddAt(v(2)/fac,k++);
  }
  return param;
} 


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