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