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

//_HADES_CLASS_DESCRIPTION 
///////////////////////////////////////////////////////////////////////////////
//
// HGeomPcon
//
// class for the GEANT shape PCON
// 
// The size of a PCON 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,
//              (z-component not used)
//   point 2ff: z coordinate of the section,
//              inner radius at position z,
//              outer radius at position z;
//
// The intrinsic coordinate system of a PCON, which sits in the CAVE and is
// not rotated, is identical with the laboratory system.
//
///////////////////////////////////////////////////////////////////////////////

#include "hgeompcon.h"
#include "hgeomvolume.h"
#include "hgeomvector.h"

ClassImp(HGeomPcon)

HGeomPcon::HGeomPcon() {
  // constructor
  fName="PCON";
  nPoints=0;
  nParam=0;
}


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


Int_t HGeomPcon::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);
    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 HGeomPcon::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));
    switch(i) {
      case 0:  sprintf(buf,"%3i\n",(Int_t)v(0));
      case 1:  sprintf(buf,"%9.3f%10.3f\n",v(0),v(1));
      default: sprintf(buf,"%9.3f%10.3f%10.3f\n",v(0),v(1),v(2));
    }
    pFile->write(buf,strlen(buf));
  }
  return kTRUE;
}


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


TArrayD* HGeomPcon::calcVoluParam(HGeomVolume* volu) {
  // calculates the parameters needed to create the shape PCON 
  Double_t fac=10.;
  nPoints=volu->getNumPoints();
  nParam=(nPoints-1)*3;
  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((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 HGeomPcon::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);
}
 hgeompcon.cc:1
 hgeompcon.cc:2
 hgeompcon.cc:3
 hgeompcon.cc:4
 hgeompcon.cc:5
 hgeompcon.cc:6
 hgeompcon.cc:7
 hgeompcon.cc:8
 hgeompcon.cc:9
 hgeompcon.cc:10
 hgeompcon.cc:11
 hgeompcon.cc:12
 hgeompcon.cc:13
 hgeompcon.cc:14
 hgeompcon.cc:15
 hgeompcon.cc:16
 hgeompcon.cc:17
 hgeompcon.cc:18
 hgeompcon.cc:19
 hgeompcon.cc:20
 hgeompcon.cc:21
 hgeompcon.cc:22
 hgeompcon.cc:23
 hgeompcon.cc:24
 hgeompcon.cc:25
 hgeompcon.cc:26
 hgeompcon.cc:27
 hgeompcon.cc:28
 hgeompcon.cc:29
 hgeompcon.cc:30
 hgeompcon.cc:31
 hgeompcon.cc:32
 hgeompcon.cc:33
 hgeompcon.cc:34
 hgeompcon.cc:35
 hgeompcon.cc:36
 hgeompcon.cc:37
 hgeompcon.cc:38
 hgeompcon.cc:39
 hgeompcon.cc:40
 hgeompcon.cc:41
 hgeompcon.cc:42
 hgeompcon.cc:43
 hgeompcon.cc:44
 hgeompcon.cc:45
 hgeompcon.cc:46
 hgeompcon.cc:47
 hgeompcon.cc:48
 hgeompcon.cc:49
 hgeompcon.cc:50
 hgeompcon.cc:51
 hgeompcon.cc:52
 hgeompcon.cc:53
 hgeompcon.cc:54
 hgeompcon.cc:55
 hgeompcon.cc:56
 hgeompcon.cc:57
 hgeompcon.cc:58
 hgeompcon.cc:59
 hgeompcon.cc:60
 hgeompcon.cc:61
 hgeompcon.cc:62
 hgeompcon.cc:63
 hgeompcon.cc:64
 hgeompcon.cc:65
 hgeompcon.cc:66
 hgeompcon.cc:67
 hgeompcon.cc:68
 hgeompcon.cc:69
 hgeompcon.cc:70
 hgeompcon.cc:71
 hgeompcon.cc:72
 hgeompcon.cc:73
 hgeompcon.cc:74
 hgeompcon.cc:75
 hgeompcon.cc:76
 hgeompcon.cc:77
 hgeompcon.cc:78
 hgeompcon.cc:79
 hgeompcon.cc:80
 hgeompcon.cc:81
 hgeompcon.cc:82
 hgeompcon.cc:83
 hgeompcon.cc:84
 hgeompcon.cc:85
 hgeompcon.cc:86
 hgeompcon.cc:87
 hgeompcon.cc:88
 hgeompcon.cc:89
 hgeompcon.cc:90
 hgeompcon.cc:91
 hgeompcon.cc:92
 hgeompcon.cc:93
 hgeompcon.cc:94
 hgeompcon.cc:95
 hgeompcon.cc:96
 hgeompcon.cc:97
 hgeompcon.cc:98
 hgeompcon.cc:99
 hgeompcon.cc:100
 hgeompcon.cc:101
 hgeompcon.cc:102
 hgeompcon.cc:103
 hgeompcon.cc:104
 hgeompcon.cc:105
 hgeompcon.cc:106
 hgeompcon.cc:107
 hgeompcon.cc:108
 hgeompcon.cc:109
 hgeompcon.cc:110
 hgeompcon.cc:111
 hgeompcon.cc:112
 hgeompcon.cc:113
 hgeompcon.cc:114
 hgeompcon.cc:115
 hgeompcon.cc:116
 hgeompcon.cc:117
 hgeompcon.cc:118
 hgeompcon.cc:119
 hgeompcon.cc:120
 hgeompcon.cc:121
 hgeompcon.cc:122
 hgeompcon.cc:123
 hgeompcon.cc:124
 hgeompcon.cc:125
 hgeompcon.cc:126
 hgeompcon.cc:127
 hgeompcon.cc:128
 hgeompcon.cc:129
 hgeompcon.cc:130
 hgeompcon.cc:131
 hgeompcon.cc:132
 hgeompcon.cc:133
 hgeompcon.cc:134
 hgeompcon.cc:135
 hgeompcon.cc:136
 hgeompcon.cc:137
 hgeompcon.cc:138
 hgeompcon.cc:139
 hgeompcon.cc:140
 hgeompcon.cc:141
 hgeompcon.cc:142
 hgeompcon.cc:143
 hgeompcon.cc:144
 hgeompcon.cc:145
 hgeompcon.cc:146
 hgeompcon.cc:147
 hgeompcon.cc:148