EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PndGeoCave.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PndGeoCave.cxx
1 //*-- AUTHOR : Ilse Koenig
2 //*-- Created : 10/11/2003
3 
5 // PndGeoCave
6 //
7 // Class for the geometry of the detector part CAVE
8 //
10 
11 #include "PndGeoCave.h"
12 #include "FairGeoNode.h"
13 #include "FairGeoShapes.h"
14 #include "FairGeoBasicShape.h"
15 #include "FairGeoMedium.h"
16 
17 using namespace std;
19 
20 PndGeoCave::PndGeoCave() : name("cave") {
21  // Constructor
22  fName="cave";
23  maxModules=1;
24 }
25 
26 Bool_t PndGeoCave::read(fstream& fin,FairGeoMedia* media) {
27  // Reads the geometry from file
28  if (!media) return kFALSE;
29  const Int_t maxbuf=256;
30  char buf[maxbuf];
31  FairGeoNode* volu=0;
32  FairGeoMedium* medium;
33  Bool_t rc=kTRUE;
34  do {
35  fin.getline(buf,maxbuf);
36  if (buf[0]!='\0' && buf[0]!='/' && !fin.eof()) {
37  if (strcmp(buf,name)==0) {
38  volu=new FairGeoNode;
39  volu->SetName(buf);
41  volu->setActive();
42  fin.getline(buf,maxbuf);
43  TString shape(buf);
44  FairGeoBasicShape* sh=pShapes->selectShape(shape);
45  if (sh) volu->setShape(sh);
46  else rc=kFALSE;
47  fin.getline(buf,maxbuf);
48  medium=media->getMedium(buf);
49  if (!medium) {
50  medium=new FairGeoMedium();
51  media->addMedium(medium);
52  }
53  volu->setMedium(medium);
54  Int_t n=0;
55  if (sh) n=sh->readPoints(&fin,volu);
56  if (n<=0) rc=kFALSE;
57  } else rc=kFALSE;
58  }
59  } while (rc && !volu && !fin.eof());
60  if (volu && rc) {
61  volumes->Add(volu);
62  masterNodes->Add(new FairGeoNode(*volu));
63  } else {
64  delete volu;
65  volu=0;
66  rc=kFALSE;
67  }
68  return rc;
69 }
70 
72  // Adds the reference node
73  FairGeoNode* volu=getVolume(name);
74  if (volu) masterNodes->Add(new FairGeoNode(*volu));
75 }
76 
77 void PndGeoCave::write(fstream& fout) {
78  // Writes the geometry to file
79  fout.setf(ios::fixed,ios::floatfield);
80  FairGeoNode* volu=getVolume(name);
81  if (volu) {
83  FairGeoMedium* med=volu->getMedium();
84  if (sh&&med) {
85  fout<<volu->GetName()<<'\n'<<sh->GetName()<<'\n'<<med->GetName()<<'\n';
86  sh->writePoints(&fout,volu);
87  }
88  }
89 }
90 
92  // Prints the geometry
93  FairGeoNode* volu=getVolume(name);
94  if (volu) {
96  FairGeoMedium* med=volu->getMedium();
97  if (sh&&med) {
98  cout<<volu->GetName()<<'\n'<<sh->GetName()<<'\n'<<med->GetName()<<'\n';
99  sh->printPoints(volu);
100  }
101  }
102 }