ROOT logo
//*-- AUTHOR : Ilse Koenig
//*-- Created : 10/11/2003

//_HADES_CLASS_DESCRIPTION 
/////////////////////////////////////////////////////////////
// HGeomCave
//
// Class for the geometry of the detector part CAVE
//
/////////////////////////////////////////////////////////////

#include "hgeomcave.h"
#include "hgeomnode.h"
#include "hgeomshapes.h"
#include "hgeombasicshape.h"
#include "hgeommedia.h"
#include "hgeommedium.h"

ClassImp(HGeomCave)

HGeomCave::HGeomCave() {
  // Constructor
  fName="cave";
  name="CAVE";
  maxModules=1;
}

Bool_t HGeomCave::read(fstream& fin,HGeomMedia* media) {
  // Reads the geometry from file
  if (!media) return kFALSE;
  const Int_t maxbuf=256;
  Char_t buf[maxbuf];
  HGeomNode* volu=0;
  HGeomMedium* medium;
  Bool_t rc=kTRUE;
  do {
    fin.getline(buf,maxbuf);
    if (buf[0]!='\0' && buf[0]!='/' && !fin.eof()) {
      if (strcmp(buf,name)==0) {
        volu=new HGeomNode;
        volu->SetName(buf);
        volu->setVolumeType(kHGeomTopNode);
        volu->setActive();
        fin.getline(buf,maxbuf);
        TString shape(buf);
        HGeomBasicShape* sh=pShapes->selectShape(shape);
        if (sh) volu->setShape(sh);
        else rc=kFALSE;
        fin.getline(buf,maxbuf);
        medium=media->getMedium(buf);
        if (!medium) {
          medium=new HGeomMedium();
          media->addMedium(medium);
        }
        volu->setMedium(medium);
        Int_t n=0;
        if (sh) n=sh->readPoints(&fin,volu);
        if (n<=0) rc=kFALSE;
      } else rc=kFALSE;
    }
  } while (rc && !volu && !fin.eof()); 
  if (volu && rc) {
    volumes->Add(volu);
    masterNodes->Add(new HGeomNode(*volu));
  } else {
    delete volu;
    volu=0;
    rc=kFALSE;
  }
  return rc;
}

void HGeomCave::addRefNodes() {
  // Adds the reference node
  HGeomNode* volu=getVolume("CAVE");
  if (volu) masterNodes->Add(new HGeomNode(*volu));
}

void HGeomCave::write(fstream& fout) {
  // Writes the geometry to file
  fout.setf(ios::fixed,ios::floatfield);
  HGeomNode* volu=getVolume(name);
  if (volu) {
    HGeomBasicShape* sh=volu->getShapePointer();
    HGeomMedium* med=volu->getMedium();
    if (sh&&med) {
      fout<<volu->GetName()<<'\n'<<sh->GetName()<<'\n'<<med->GetName()<<'\n';
      sh->writePoints(&fout,volu);
    }
  }
}

void HGeomCave::print() {
  // Prints the geometry
  HGeomNode* volu=getVolume(name);
  if (volu) {
    HGeomBasicShape* sh=volu->getShapePointer();
    HGeomMedium* med=volu->getMedium();
    if (sh&&med) {
      cout<<volu->GetName()<<'\n'<<sh->GetName()<<'\n'<<med->GetName()<<'\n';
      sh->printPoints(volu);
    }
  }
}
 hgeomcave.cc:1
 hgeomcave.cc:2
 hgeomcave.cc:3
 hgeomcave.cc:4
 hgeomcave.cc:5
 hgeomcave.cc:6
 hgeomcave.cc:7
 hgeomcave.cc:8
 hgeomcave.cc:9
 hgeomcave.cc:10
 hgeomcave.cc:11
 hgeomcave.cc:12
 hgeomcave.cc:13
 hgeomcave.cc:14
 hgeomcave.cc:15
 hgeomcave.cc:16
 hgeomcave.cc:17
 hgeomcave.cc:18
 hgeomcave.cc:19
 hgeomcave.cc:20
 hgeomcave.cc:21
 hgeomcave.cc:22
 hgeomcave.cc:23
 hgeomcave.cc:24
 hgeomcave.cc:25
 hgeomcave.cc:26
 hgeomcave.cc:27
 hgeomcave.cc:28
 hgeomcave.cc:29
 hgeomcave.cc:30
 hgeomcave.cc:31
 hgeomcave.cc:32
 hgeomcave.cc:33
 hgeomcave.cc:34
 hgeomcave.cc:35
 hgeomcave.cc:36
 hgeomcave.cc:37
 hgeomcave.cc:38
 hgeomcave.cc:39
 hgeomcave.cc:40
 hgeomcave.cc:41
 hgeomcave.cc:42
 hgeomcave.cc:43
 hgeomcave.cc:44
 hgeomcave.cc:45
 hgeomcave.cc:46
 hgeomcave.cc:47
 hgeomcave.cc:48
 hgeomcave.cc:49
 hgeomcave.cc:50
 hgeomcave.cc:51
 hgeomcave.cc:52
 hgeomcave.cc:53
 hgeomcave.cc:54
 hgeomcave.cc:55
 hgeomcave.cc:56
 hgeomcave.cc:57
 hgeomcave.cc:58
 hgeomcave.cc:59
 hgeomcave.cc:60
 hgeomcave.cc:61
 hgeomcave.cc:62
 hgeomcave.cc:63
 hgeomcave.cc:64
 hgeomcave.cc:65
 hgeomcave.cc:66
 hgeomcave.cc:67
 hgeomcave.cc:68
 hgeomcave.cc:69
 hgeomcave.cc:70
 hgeomcave.cc:71
 hgeomcave.cc:72
 hgeomcave.cc:73
 hgeomcave.cc:74
 hgeomcave.cc:75
 hgeomcave.cc:76
 hgeomcave.cc:77
 hgeomcave.cc:78
 hgeomcave.cc:79
 hgeomcave.cc:80
 hgeomcave.cc:81
 hgeomcave.cc:82
 hgeomcave.cc:83
 hgeomcave.cc:84
 hgeomcave.cc:85
 hgeomcave.cc:86
 hgeomcave.cc:87
 hgeomcave.cc:88
 hgeomcave.cc:89
 hgeomcave.cc:90
 hgeomcave.cc:91
 hgeomcave.cc:92
 hgeomcave.cc:93
 hgeomcave.cc:94
 hgeomcave.cc:95
 hgeomcave.cc:96
 hgeomcave.cc:97
 hgeomcave.cc:98
 hgeomcave.cc:99
 hgeomcave.cc:100
 hgeomcave.cc:101
 hgeomcave.cc:102
 hgeomcave.cc:103
 hgeomcave.cc:104