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

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

#include "hgeomcons.h"
#include "hgeomvolume.h"
#include "hgeomvector.h"

ClassImp(HGeomCons)

HGeomCons::HGeomCons() {
  // constructor
  fName="CONS";
  nPoints=5;
  nParam=7;
  param=new TArrayD(nParam);
}


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


Int_t HGeomCons::readPoints(fstream* pFile,HGeomVolume* volu) {
  // reads the 5 '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==0 || i==2) {
      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 HGeomCons::writePoints(fstream* pFile,HGeomVolume* volu) {
  // writes the 5 '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 HGeomCons::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* HGeomCons::calcVoluParam(HGeomVolume* volu) {
  // calculates the parameters needed to create the shape CONS 
  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);
  HGeomVector& v4=*(volu->getPoint(4));
  param->AddAt(v4(0),5);
  param->AddAt(v4(1),6);
  return param;
} 


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