]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4GeometryOutputManager.cxx
added support for MANY
[u/mrichter/AliRoot.git] / TGeant4 / TG4GeometryOutputManager.cxx
1 // $Id$
2 // Category: geometry
3 //
4 // Author: I. Hrivnacova 
5 //
6 // Class TG4GeometryOutputManager
7 // ------------------------------
8 // See the class description in the header file.
9
10 #include "TG4GeometryOutputManager.h"
11 #include <g4std/iostream>
12 #include <g4std/iomanip>
13
14 //_____________________________________________________________________________
15 TG4GeometryOutputManager::TG4GeometryOutputManager() {
16 //
17 }
18
19 //_____________________________________________________________________________
20 TG4GeometryOutputManager::~TG4GeometryOutputManager() {
21 //
22 }
23
24 // public methods
25
26 //_____________________________________________________________________________
27 void TG4GeometryOutputManager::OpenFile(G4String filePath)
28
29 // Opens output files.
30 // ---
31
32   G4cout << "TG4GeometryOutputManager::OpenFile: " << filePath << G4endl;
33   
34   //fOutFile.open(filePath, ios::out, filebuf::openprot); 
35   fOutFile.open(filePath, G4std::ios::out); //, G4std::filebuf::openprot); 
36   
37   if (!fOutFile) {
38     G4String text = "Cannot open ";
39     text = text + filePath;
40     TG4Globals::Warning(text);  
41   }
42   
43   // use FORTRAN compatibility output
44   fOutFile << G4std::setiosflags(G4std::ios::showpoint | G4std::ios::uppercase);
45 }
46
47
48 //_____________________________________________________________________________
49 void TG4GeometryOutputManager::CloseFile()
50
51 // Closes output files.
52 // ---
53
54   fOutFile.close(); 
55 }
56
57
58 //_____________________________________________________________________________
59 void TG4GeometryOutputManager::WriteGsvolu( 
60               G4String vname, G4String shape, G4int nmed, G4double* Rpar,
61               G4int npar)
62 {
63 // from fortran (g3routines.F)
64 // write(fmt,'(A,I2,A)')'(a4,1x,a6,1x,a4,1x,a4,2i5,',max(npar,1),
65 //>      '(1x,e16.8))'
66 // write(lunlist,fmt) context, rname, name, shape, nmed, npar,
67 //+      (par(k),k=1,npar)
68 // ---
69
70   G4String context("----");
71   G4String rname("GSVOLU");
72   G4String space(" "); 
73   fOutFile << context << space 
74           << rname   << space
75           << vname    << space
76           << shape
77           << G4std::setw(5) << nmed  
78           << G4std::setw(5) << npar;
79   for (G4int i=0; i<npar; i++)        
80     fOutFile << space << G4std::setw(16) << G4std::setprecision(8) << Rpar[i];
81   fOutFile << G4endl;   
82 }
83
84 //_____________________________________________________________________________
85 void TG4GeometryOutputManager::WriteGspos(
86              G4String vname, G4int num, G4String vmoth, G4double x,
87              G4double y, G4double z, G4int irot, G4String vonly)
88 {            
89 // from fortran (g3routines.F)
90 // write(lunlist,
91 //+      '(a4,1x,a6,1x,a4,i5,1x,a4,3(1x,e16.8),i5,1x,a4)')
92 //+      context, rname, name, num, moth, x, y, z, irot, only
93 // ---
94
95   G4String context("----");
96   G4String rname("GSPOS");
97   G4String space(" "); 
98   fOutFile << context << space 
99           << rname   << space
100           << vname   << space
101           << G4std::setw(5) << num << space 
102           << vmoth   << space
103           << G4std::setw(16) << G4std::setprecision(8) << x << space
104           << G4std::setw(16) << G4std::setprecision(8) << y << space
105           << G4std::setw(16) << G4std::setprecision(8) << z
106           << G4std::setw(5) << irot << space
107           << vonly 
108           << G4endl;
109 }            
110   
111 //_____________________________________________________________________________
112 void TG4GeometryOutputManager::WriteGsposp(
113               G4String vname, G4int num, G4String vmoth, G4double x,
114               G4double y, G4double z, G4int irot, G4String vonly,
115               G4double pars[], G4int npar)
116 {
117 // from fortran (g3routines.F)
118 // write(fmt,'(A,A,I2,A)')
119 //+      '(a4,1x,a6,1x,a4,i5,1x,a4,3(1x,e16.8),',       
120 //+      'i5,1x,a4,i5,',max(npar,1),'(1x,e16.8))'
121 // write(lunlist,fmt)
122 //+      context, rname, name, num, moth, x, y, z, irot, only,
123 //+      npar,
124 //+      (par(k),k=1,npar)
125 // ---
126
127   G4String context("----");
128   G4String rname("GSPOSP");
129   G4String space(" "); 
130   fOutFile << context << space 
131           << rname   << space
132           << vname   << space
133           << G4std::setw(5) << num << space 
134           << vmoth   << space
135           << G4std::setw(16) << G4std::setprecision(8) << x << space
136           << G4std::setw(16) << G4std::setprecision(8) << y << space
137           << G4std::setw(16) << G4std::setprecision(8) << z
138           << G4std::setw(5) << irot << space
139           << vonly 
140           << G4std::setw(5) << npar;
141   for (G4int i=0; i<npar; i++)        
142     fOutFile << space << G4std::setw(16) << G4std::setprecision(8) << pars[i];
143   fOutFile << G4endl;
144 }             
145
146 //_____________________________________________________________________________
147 void TG4GeometryOutputManager::WriteGsrotm(
148               G4int irot, G4double theta1, G4double phi1,
149               G4double theta2, G4double phi2, G4double theta3, G4double phi3)
150 {
151 // from fortran (g3routines.F)
152 // write(lunlist,
153 //+      '(a4,1x,a6,i5,6f11.5)')
154 //+      context, rname, irot, theta1, phi1, theta2, phi2,
155 //+      theta3, phi3
156 // ---
157   
158   G4String context("----");
159   G4String rname("GSROTM");
160   G4String space(" "); 
161   fOutFile << context << space 
162           << rname   << space
163           << G4std::setw(5) << irot
164           << G4std::setw(11) << G4std::setprecision(5) << theta1
165           << G4std::setw(11) << G4std::setprecision(5) << phi1
166           << G4std::setw(11) << G4std::setprecision(5) << theta2
167           << G4std::setw(11) << G4std::setprecision(5) << phi2
168           << G4std::setw(11) << G4std::setprecision(5) << theta3
169           << G4std::setw(11) << G4std::setprecision(5) << phi3
170           << G4endl;
171 }         
172
173 //_____________________________________________________________________________
174 void TG4GeometryOutputManager::WriteGsdvn(
175               G4String vname, G4String vmoth, G4int ndiv, G4int iaxis)
176 {
177 // from fortran (g3routines.F)
178 // write(lunlist,
179 //+      '(a4,1x,a6,1x,a4,1x,a4,i5,i3)')
180 //+      context, rname, name, moth, ndiv, iaxis
181 // ---
182
183   G4String context("----");
184   G4String rname("GSDVN");
185   G4String space(" "); 
186   fOutFile << context << space 
187           << rname   << space
188           << vname    << space
189           << vmoth   << space
190           << G4std::setw(5) << ndiv  
191           << G4std::setw(5) << iaxis
192           << G4endl;
193 }            
194
195 //_____________________________________________________________________________
196 void TG4GeometryOutputManager::WriteGsdvn2(
197                G4String vname, G4String vmoth, G4int ndiv, G4int iaxis,
198                G4double c0, G4int numed)
199 {
200 // from fortran (g3routines.F)
201 // write(lunlist,
202 //+      '(a4,1x,a6,1x,a4,1x,a4,i5,i3,(1x,e16.8),i5)')
203 //+      context, rname, name, moth, ndiv, iaxis, c0, numed
204 // ---
205
206   G4String context("----");
207   G4String rname("GSDVN2");
208   G4String space(" "); 
209   fOutFile << context << space 
210           << rname   << space
211           << vname    << space
212           << vmoth   << space
213           << G4std::setw(5) << ndiv  
214           << G4std::setw(5) << iaxis << " "
215           << G4std::setw(16) << G4std::setprecision(8) << c0
216           << G4std::setw(5) << numed
217           << G4endl;
218 }            
219
220 //_____________________________________________________________________________
221 void TG4GeometryOutputManager::WriteGsdvt(
222              G4String vname, G4String vmoth, G4double step, G4int iaxis,
223              G4int numed, G4int ndvmx) 
224 {
225 // from fortran (g3routines.F)
226 // write(lunlist,
227 // +    '(a4,1x,a6,1x,a4,1x,a4,(1x,e16.8),3i5)')
228 // +    context, rname, name, moth, step, iaxis, numed, ndvmx
229 // ---
230
231   G4String context("----");
232   G4String rname("GSDVT");
233   G4String space(" "); 
234   fOutFile << context << space 
235           << rname   << space
236           << vname    << space
237           << vmoth   << space
238           << G4std::setw(16) << G4std::setprecision(8) << step
239           << G4std::setw(5) << iaxis
240           << G4std::setw(5) << numed
241           << G4std::setw(5) << ndvmx
242           << G4endl;
243 }            
244
245 //_____________________________________________________________________________
246 void TG4GeometryOutputManager::WriteGsdvt2(
247                G4String vname, G4String vmoth, G4double step, G4int iaxis,
248                G4double c0, G4int numed, G4int ndvmx)
249 {              
250 // from fortran (g3routines.F)
251 // write(lunlist,
252 //+      '(a4,1x,a6,1x,a4,1x,a4,(1x,e16.8),i3,(1x,e16.8),2i5)')
253 //+      context, rname, name, moth, step, iaxis, c0, numed, ndvmx
254 // ---
255
256   G4String context("----");
257   G4String rname("GSDVT2");
258   G4String space(" "); 
259   fOutFile << context << space 
260           << rname   << space
261           << vname    << space
262           << vmoth   << space
263           << G4std::setw(16) << G4std::setprecision(8) << step
264           << G4std::setw(3) << iaxis << space
265           << G4std::setw(16) << G4std::setprecision(8) << c0
266           << G4std::setw(5) << numed
267           << G4std::setw(5) << ndvmx
268           << G4endl;
269 }            
270
271 //_____________________________________________________________________________
272 void TG4GeometryOutputManager::WriteGsdvx(
273              G4String name, G4String moth, G4int ndiv, G4int iaxis,
274              G4double step, G4double c0, G4int numed, G4int ndvmx)
275 {
276 // from fortran (g3routines.F)
277 // write(lunlist,
278 // +     '(a4,1x,a6,1x,a4,1x,a4,i5,i3,2(1x,e16.8),2i5)')
279 // +     context, rname, name, moth, ndiv, iaxis,step, c0,
280 // +     numed, ndvmx
281 // ---
282
283   G4String context("----");
284   G4String rname("GSDVX");
285   G4String space(" "); 
286   fOutFile << context << space 
287           << rname   << space
288           << name    << space
289           << moth    << space
290           << G4std::setw(5) << ndiv
291           << G4std::setw(3) << iaxis << space
292           << G4std::setw(16) << G4std::setprecision(8) << step << space
293           << G4std::setw(16) << G4std::setprecision(8) << c0
294           << G4std::setw(5) << numed
295           << G4std::setw(5) << ndvmx
296           << G4endl;
297 }            
298
299 //_____________________________________________________________________________
300 void TG4GeometryOutputManager::WriteGsmate(
301               G4int imate, G4String name, G4double ain, G4double zin,
302               G4double densin, G4double radl, G4int nwbf, G4double* ubuf)
303 {
304 // from fortran (g3routines.F)
305 // write(fmt,'(A,I3,A)')
306 //+      '(a4,1x,a6,i5,1x,''"'',a,''"'',4(1x,e16.8),i3,',
307 //+      max(nwbf,1),'(1x,e16.8))'
308 // write(lunlist,fmt)
309 //+      context, rname, imate, name, a, z, dens, radl,
310 //+      nwbf, (ubf(k), k=1,nwbf)
311 // ---
312
313   G4String context("----");
314   G4String rname("GSMATE");
315   G4String space(" "); 
316   fOutFile << context << space 
317           << rname   << space
318           << G4std::setw(5) << imate << space 
319           << '"' << name << '"' << space
320           << G4std::setw(16) << G4std::setprecision(8) << ain << space
321           << G4std::setw(16) << G4std::setprecision(8) << zin << space
322           << G4std::setw(16) << G4std::setprecision(8) << densin << space
323           << G4std::setw(16) << G4std::setprecision(8) << radl
324           << G4std::setw(3) << nwbf;
325   for (G4int i=0; i<nwbf; i++)        
326     fOutFile << space << G4std::setw(16) << G4std::setprecision(8) << ubuf[i];
327   fOutFile << G4endl;
328 }             
329
330 //_____________________________________________________________________________
331 void TG4GeometryOutputManager::WriteGsmixt(
332               G4int imate, G4String name, G4double* a, G4double* z,
333               G4double dens, G4int nlmat, G4double* wmat)
334 {
335 // from fortran (g3routines.F)
336 // write(fmt,'(A,I3,A,I3,A,I3,A)')
337 //+      '(a4,1x,a6,i5,1x,''"'',a,''"'',1x,e16.8,1x,i3,',
338 //+      max(nlmata,1),
339 //+      '(1x,e16.8),',max(nlmata,1),'(1x,e16.8),',
340 //+      max(nlmata,1),'(1x,e16.8))'
341 // write(lunlist,fmt)
342 //+      context, rname, imate, name, dens,
343 //+      nlmat, 
344 //+      (a(k), k=1,abs(nlmat)),
345 //+      (z(k), k=1,abs(nlmat)),
346 //+      (wmat(k), k=1,abs(nlmat))
347 // ---
348
349   G4String context("----");
350   G4String rname("GSMIXT");
351   G4String space(" "); 
352   fOutFile << context << space 
353           << rname   << space
354           << G4std::setw(5) << imate << space 
355           << '"' << name << '"' << space
356           << G4std::setw(16) << G4std::setprecision(8) << dens << space
357           << G4std::setw(3) << nlmat;
358   G4int i;        
359   for (i=0; i<abs(nlmat); i++)        
360     fOutFile << space << G4std::setw(16) << G4std::setprecision(8) << a[i];
361   for (i=0; i<abs(nlmat); i++)        
362     fOutFile << space << G4std::setw(16) << G4std::setprecision(8) << z[i];
363   for (i=0; i<abs(nlmat); i++)        
364     fOutFile << space << G4std::setw(16) << G4std::setprecision(8) << wmat[i];
365   fOutFile << G4endl;
366 }             
367
368 //_____________________________________________________________________________
369 void TG4GeometryOutputManager::WriteGstmed(
370               G4int itmed, G4String name, G4int nmat, G4int isvol,
371               G4int ifield, G4double fieldm, G4double tmaxfd,
372               G4double stemax, G4double deemax, G4double epsil,
373               G4double stmin, G4double* ubuf, G4int nwbuf)
374 {
375 // from fortran (g3routines.F)
376 // write(fmt,'(A,I3,A)') 
377 //>      '(a4,1x,a6,i5,1x,''"'',a,''"'',3i3,6(1x,e16.8),i3,',
378 //>      max(nwbuf,1),'(1x,e16.8))'
379 // write(lunlist,fmt)
380 //+      context, rname, itmed, name, nmat, isvol, ifield, fieldm,
381 //+      tmaxfd, stemax, deemax, epsil, stmin,
382 //+      nwbuf, (ubuf(k),k=1,nwbuf)
383 // ---
384
385   G4String context("----");
386   G4String rname("GSTMED");
387   G4String space(" "); 
388   fOutFile << context << space 
389           << rname   << space
390           << G4std::setw(5) << itmed << space
391           << '"' << name << '"' 
392           << G4std::setw(3) << nmat
393           << G4std::setw(3) << isvol
394           << G4std::setw(3) << ifield << space
395           << G4std::setw(16) << G4std::setprecision(8) << fieldm << space
396           << G4std::setw(16) << G4std::setprecision(8) << tmaxfd << space
397           << G4std::setw(16) << G4std::setprecision(8) << stemax << space
398           << G4std::setw(16) << G4std::setprecision(8) << deemax << space
399           << G4std::setw(16) << G4std::setprecision(8) << epsil << space
400           << G4std::setw(16) << G4std::setprecision(8) << stmin << space
401           << G4std::setw(3) << nwbuf;
402   for (G4int i=0; i<nwbuf; i++)       
403     fOutFile << space << G4std::setw(16) << G4std::setprecision(8) << ubuf[i];
404   fOutFile << G4endl;
405 }         
406
407 //_____________________________________________________________________________
408 void TG4GeometryOutputManager::WriteGstpar(
409                G4int itmed, G4String param, G4double parval)
410 {              
411 // from fortran (g3routines.F)
412 // write(lunlist,
413 //+     '(a4,1x,a6,i5,1x,a4,(1x,e16.8))')
414 //+     context, rname, itmed, chpar, parval
415 // ---
416
417   G4String context("----");
418   G4String rname("GSTPAR");
419   G4String space(" "); 
420   fOutFile << context << space 
421           << rname   << space
422           << G4std::setw(5) << itmed << space 
423           << param   << space
424           << G4std::setw(16) << G4std::setprecision(8) << parval
425           << G4endl;
426 }             
427
428 //_____________________________________________________________________________
429 void TG4GeometryOutputManager::WriteGgclos()
430 {
431 // Writes GGCLOS token
432 // ---
433
434   G4String context("----");
435   G4String rname("GGCLOS");
436   G4String space(" "); 
437   fOutFile << context << space 
438           << rname   
439           << G4endl;
440 }