SND@LHC Software
Loading...
Searching...
No Matches
ShipGeoCave.cxx
Go to the documentation of this file.
1
2// ShipGeoCave
3//
4// Class for the geometry of the detector part CAVE
5//
7
8#include "ShipGeoCave.h"
9
10#include "FairGeoBasicShape.h" // for FairGeoBasicShape
11#include "FairGeoMedia.h" // for FairGeoMedia
12#include "FairGeoMedium.h" // for FairGeoMedium
13#include "FairGeoNode.h" // for FairGeoNode, etc
14#include "FairGeoShapes.h" // for FairGeoShapes
15
16#include "TList.h" // for TList
17
18#include <string.h> // for strcmp
19#include <iostream> // for cout
20
21using namespace std;
23
25 : FairGeoSet(),
26 name("cave")
27{
28 // Constructor
29 fName="cave";
30 name="cave";
31 maxModules=1;
32}
33
34Bool_t ShipGeoCave::read(fstream& fin,FairGeoMedia* media)
35{
36 // Reads the geometry from file
37 if (!media) { return kFALSE; }
38 const Int_t maxbuf=256;
39 char buf[maxbuf];
40 FairGeoNode* volu=0;
41 FairGeoMedium* medium;
42 Bool_t rc=kTRUE;
43 do {
44 fin.getline(buf,maxbuf);
45 if (buf[0]!='\0' && buf[0]!='/' && !fin.eof()) {
46 if (strcmp(buf,name)==0) {
47 volu=new FairGeoNode;
48 volu->SetName(buf);
49 volu->setVolumeType(kFairGeoTopNode);
50 volu->setActive();
51 fin.getline(buf,maxbuf);
52 TString shape(buf);
53 FairGeoBasicShape* sh=pShapes->selectShape(shape);
54 if (sh) { volu->setShape(sh); }
55 else { 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 { rc=kFALSE; }
67 }
68 } while (rc && !volu && !fin.eof());
69 if (volu && rc) {
70 volumes->Add(volu);
71 masterNodes->Add(new FairGeoNode(*volu));
72 } else {
73 delete volu;
74 volu=0;
75 rc=kFALSE;
76 }
77 return rc;
78}
79
81{
82 // Adds the reference node
83 FairGeoNode* volu=getVolume(name);
84 if (volu) { masterNodes->Add(new FairGeoNode(*volu)); }
85}
86
87void ShipGeoCave::write(fstream& fout)
88{
89 // Writes the geometry to file
90 fout.setf(ios::fixed,ios::floatfield);
91 FairGeoNode* volu=getVolume(name);
92 if (volu) {
93 FairGeoBasicShape* sh=volu->getShapePointer();
94 FairGeoMedium* med=volu->getMedium();
95 if (sh&&med) {
96 fout<<volu->GetName()<<'\n'<<sh->GetName()<<'\n'<<med->GetName()<<'\n';
97 sh->writePoints(&fout,volu);
98 }
99 }
100}
101
103{
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'<<sh->GetName()<<'\n'<<med->GetName()<<'\n';
111 sh->printPoints(volu);
112 }
113 }
114}
ClassImp(ShipGeoCave) ShipGeoCave
void addRefNodes()
Bool_t read(std::fstream &, FairGeoMedia *)
TString name
Definition ShipGeoCave.h:17
void write(std::fstream &)