CbmRoot
CbmGeoCave.cxx
Go to the documentation of this file.
1 //*-- AUTHOR : Ilse Koenig
2 //*-- Created : 10/11/2003
3 
5 // CbmGeoCave
6 //
7 // Class for the geometry of the detector part CAVE
8 //
10 
11 #include "CbmGeoCave.h"
12 
13 #include "FairGeoBasicShape.h"
14 #include "FairGeoMedia.h"
15 #include "FairGeoMedium.h"
16 #include "FairGeoNode.h"
17 #include "FairGeoShapes.h"
18 
19 using std::cout;
20 using std::fstream;
21 using std::ios;
22 
24 
26  : FairGeoSet(), name("cave") {
27  // Constructor
28  fName = "cave";
29  // name="cave";
30  maxModules = 1;
31 }
32 
33 Bool_t CbmGeoCave::read(fstream& fin, FairGeoMedia* media) {
34  // Reads the geometry from file
35  if (!media) return kFALSE;
36  const Int_t maxbuf = 256;
37  char buf[maxbuf];
38  FairGeoNode* volu = 0;
39  FairGeoMedium* medium;
40  Bool_t rc = kTRUE;
41  do {
42  fin.getline(buf, maxbuf);
43  if (buf[0] != '\0' && buf[0] != '/' && !fin.eof()) {
44  if (strcmp(buf, name) == 0) {
45  volu = new FairGeoNode;
46  volu->SetName(buf);
47  volu->setVolumeType(kFairGeoTopNode);
48  volu->setActive();
49  fin.getline(buf, maxbuf);
50  TString shape(buf);
51  FairGeoBasicShape* sh = pShapes->selectShape(shape);
52  if (sh)
53  volu->setShape(sh);
54  else
55  rc = kFALSE;
56  fin.getline(buf, maxbuf);
57  medium = media->getMedium(buf);
58  if (!medium) {
59  medium = new FairGeoMedium();
60  media->addMedium(medium);
61  }
62  volu->setMedium(medium);
63  Int_t n = 0;
64  if (sh) n = sh->readPoints(&fin, volu);
65  if (n <= 0) rc = kFALSE;
66  } else
67  rc = kFALSE;
68  }
69  } while (rc && !volu && !fin.eof());
70  if (volu && rc) {
71  volumes->Add(volu);
72  masterNodes->Add(new FairGeoNode(*volu));
73  } else {
74  delete volu;
75  volu = 0;
76  rc = kFALSE;
77  }
78  return rc;
79 }
80 
82  // Adds the reference node
83  FairGeoNode* volu = getVolume(name);
84  if (volu) masterNodes->Add(new FairGeoNode(*volu));
85 }
86 
87 void CbmGeoCave::write(fstream& fout) {
88  // Writes the geometry to file
89  fout.setf(ios::fixed, ios::floatfield);
90  FairGeoNode* volu = getVolume(name);
91  if (volu) {
92  FairGeoBasicShape* sh = volu->getShapePointer();
93  FairGeoMedium* med = volu->getMedium();
94  if (sh && med) {
95  fout << volu->GetName() << '\n'
96  << sh->GetName() << '\n'
97  << med->GetName() << '\n';
98  sh->writePoints(&fout, volu);
99  }
100  }
101 }
102 
104  // Prints the geometry
105  FairGeoNode* volu = getVolume(name);
106  if (volu) {
107  FairGeoBasicShape* sh = volu->getShapePointer();
108  FairGeoMedium* med = volu->getMedium();
109  if (sh && med) {
110  cout << volu->GetName() << '\n'
111  << sh->GetName() << '\n'
112  << med->GetName() << '\n';
113  sh->printPoints(volu);
114  }
115  }
116 }
CbmGeoCave::CbmGeoCave
CbmGeoCave()
CbmGeoCave::read
Bool_t read(std::fstream &, FairGeoMedia *)
Definition: CbmGeoCave.cxx:33
CbmGeoCave::print
void print()
Definition: CbmGeoCave.cxx:103
CbmGeoCave::name
TString name
Definition: CbmGeoCave.h:14
CbmGeoCave.h
CbmGeoCave
Definition: CbmGeoCave.h:12
CbmGeoCave::write
void write(std::fstream &)
Definition: CbmGeoCave.cxx:87
shape
UInt_t shape
Definition: CbmMvdSensorDigiToHitTask.cxx:73
ClassImp
ClassImp(CbmGeoCave) CbmGeoCave
Definition: CbmGeoCave.cxx:23
CbmGeoCave::addRefNodes
void addRefNodes()
Definition: CbmGeoCave.cxx:81