Project
Loading...
Searching...
No Matches
FairGeoShapes.cxx
Go to the documentation of this file.
1/********************************************************************************
2 * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3 * *
4 * This software is distributed under the terms of the *
5 * GNU Lesser General Public Licence (LGPL) version 3, *
6 * copied verbatim in the file "LICENSE" *
7 ********************************************************************************/
8//*-- AUTHOR : Ilse Koenig
9//*-- Modified : 22/06/2003 by Ilse Koenig
10
12//
13// FairGeoShapes
14//
15// Class to manage the GEANT/ROOT geometry shapes
16//
17// The 3D geometry in ROOT uses the ROOT library geom.
18//
19// This class holds a list of shape classes (type FairGeoBasicShape). They are
20// used by all detectors when reading or writing geometry parameter containers
21// to ascii files or to create an event display. This class is instantiated in
22// the class HSpectrometer inside the function createDetGeomPar(Text_t* name).
23// Every geometry parameter container gets a pointer to it.
24//
25// The individual shape classes are accessible with the selectShape(...)
26// functions. The functions readPoints(...) and writePoints(...) use it
27// internally.
28//
29// In the current version the following shapes are implemented:
30// BOX TRAP TRD1 PGON PCON TUBE TUBS CONE CONS SPHE ELTU
31// TORUS is added 06.11.06 m.al-turany
32//
34
35#include "FairGeoShapes.h"
36
37#include "FairGeoAssembly.h"
38#include "FairGeoBasicShape.h"
39#include "FairGeoBrik.h"
40#include "FairGeoCone.h"
41#include "FairGeoCons.h"
42#include "FairGeoEltu.h"
43#include "FairGeoPcon.h"
44#include "FairGeoPgon.h"
45#include "FairGeoSphe.h"
46#include "FairGeoTorus.h"
47#include "FairGeoTrap.h"
48#include "FairGeoTrd1.h"
49#include "FairGeoTube.h"
50#include "FairGeoTubs.h"
51#include "FairGeoVolume.h"
52
53#include <TList.h>
54#include <fstream> // for fstream
55
57
59 : TObject()
60 , shapes(new TList())
61{
62 // constructor creates empty list of shapes
63}
64
66{
67 // destructor deletes all shapes
68 shapes->Delete();
69 delete shapes;
70}
71
73{
74 // returns a pointer to the shape used in the given volume
75 // calls internally selectShape(TString&) with the name of the shape
76 // returns NULL if the corresponding shape class is not implemented
77 const TString& name(volu->getShape());
78 return selectShape(name);
79}
80
82{
83 // returns a pointer to the shape given by name
84 // creates a shape object and adds it to the list of shapes if
85 // not existing
86 // returns NULL if the corresponding shape class is not implemented
87 TString allShapes[13] = {
88 "BOX ", "TRAP", "TRD1", "PGON", "PCON", "TUBE", "TUBS", "CONE", "CONS", "SPHE", "ELTU", "TORUS", "ASSEMBLY"};
89 TString sName(name);
90 if (sName.Length() == 3) {
91 sName += " ";
92 }
93 FairGeoBasicShape* s = static_cast<FairGeoBasicShape*>(shapes->FindObject(sName));
94 if (s) {
95 return s;
96 }
97 Int_t no = -1;
98 for (Int_t i = 0; i < 13; i++) {
99 if (sName.CompareTo(allShapes[i]) == 0) {
100 no = i;
101 }
102 }
103 switch (no) {
104 case 0: {
105 s = new FairGeoBrik();
106 break;
107 }
108 case 1: {
109 s = new FairGeoTrap();
110 break;
111 }
112 case 2: {
113 s = new FairGeoTrd1();
114 break;
115 }
116 case 3: {
117 s = new FairGeoPgon();
118 break;
119 }
120 case 4: {
121 s = new FairGeoPcon();
122 break;
123 }
124 case 5: {
125 s = new FairGeoTube();
126 break;
127 }
128 case 6: {
129 s = new FairGeoTubs();
130 break;
131 }
132 case 7: {
133 s = new FairGeoCone();
134 break;
135 }
136 case 8: {
137 s = new FairGeoCons();
138 break;
139 }
140 case 9: {
141 s = new FairGeoSphe();
142 break;
143 }
144 case 10: {
145 s = new FairGeoEltu();
146 break;
147 }
148 case 11: {
149 s = new FairGeoTorus();
150 break;
151 }
152 case 12: {
153 s = new FairGeoAssembly();
154 break;
155 }
156 default: {
157 Error("selectShape", "shape %s not implemented", name.Data());
158 }
159 }
160 if (s) {
161 shapes->Add(s);
162 }
163 return s;
164}
165
166Int_t FairGeoShapes::readPoints(std::fstream* pFile, FairGeoVolume* volu)
167{
168 // reads the points of the given volume from the Ascii file
169 // returns the number of points read
170 // returns 0 if if the corresponding shape class is not implemented
172 if (s) {
173 return s->readPoints(pFile, volu);
174 } else {
175 return 0;
176 }
177}
178
179Bool_t FairGeoShapes::writePoints(std::fstream* pFile, FairGeoVolume* volu)
180{
181 // writes the points of the given volume to the Ascii file
182 // return kFALSE if the corresponding shape class is not implemented
184 if (s) {
185 return s->writePoints(pFile, volu);
186 } else {
187 return kFALSE;
188 }
189}
190
192{
193 // writes the points of the given volume to the Ascii file
194 // return kFALSE if the corresponding shape class is not implemented
196 if (s) {
197 return s->printPoints(volu);
198 }
199}
ClassImp(FairGeoShapes)
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Bool_t writePoints(std::fstream *, FairGeoVolume *)
FairGeoBasicShape * selectShape(FairGeoVolume *)
void printPoints(FairGeoVolume *volu)
Int_t readPoints(std::fstream *, FairGeoVolume *)
const TString & getShape() const
GLuint const GLchar * name
Definition glcorearb.h:781