]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant3/TGeant3.cxx
Comment inside comment removed.
[u/mrichter/AliRoot.git] / TGeant3 / TGeant3.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.33  2000/09/06 16:03:42  morsch
19 Set ExternalDecayer, Decayer  and SetForceDecay methods added.
20 Gspart calls for charmed and bottom hadrons added.
21 Decay mode definitions for charmed and beauty hadrons have been taken out.
22 They will be  handled by an external decayer.
23
24 Revision 1.32  2000/08/24 16:28:53  hristov
25 TGeant3::IsNewTrack corrected by F.Carminati
26
27 Revision 1.31  2000/07/13 16:19:10  fca
28 Mainly coding conventions + some small bug fixes
29
30 Revision 1.30  2000/07/12 08:56:30  fca
31 Coding convention correction and warning removal
32
33 Revision 1.29  2000/07/11 18:24:59  fca
34 Coding convention corrections + few minor bug fixes
35
36 Revision 1.28  2000/06/29 10:51:55  morsch
37 Add some charmed and bottom baryons to the particle list (TDatabasePDG). This
38 is needed by Hijing. Should be part of a future review of TDatabasePDG.
39
40 Revision 1.27  2000/06/21 17:40:15  fca
41 Adding possibility to set ISTRA, PAI model
42
43 Revision 1.26  2000/05/16 13:10:41  fca
44 New method IsNewTrack and fix for a problem in Father-Daughter relations
45
46 Revision 1.25  2000/04/07 11:12:35  fca
47 G4 compatibility changes
48
49 Revision 1.24  2000/02/28 21:03:57  fca
50 Some additions to improve the compatibility with G4
51
52 Revision 1.23  2000/02/23 16:25:25  fca
53 AliVMC and AliGeant3 classes introduced
54 ReadEuclid moved from AliRun to AliModule
55
56 Revision 1.22  2000/01/18 15:40:13  morsch
57 Interface to GEANT3 routines GFTMAT, GBRELM and GPRELM added
58 Define geant particle type 51: Feedback Photon with Cherenkov photon properties.
59
60 Revision 1.21  2000/01/17 19:41:17  fca
61 Add SetERAN function
62
63 Revision 1.20  2000/01/12 11:29:27  fca
64 Close material file
65
66 Revision 1.19  1999/12/17 09:03:12  fca
67 Introduce a names array
68
69 Revision 1.18  1999/11/26 16:55:39  fca
70 Reimplement CurrentVolName() to avoid memory leaks
71
72 Revision 1.17  1999/11/03 16:58:28  fca
73 Correct source of address violation in creating character string
74
75 Revision 1.16  1999/11/03 13:17:08  fca
76 Have ProdProcess return const char*
77
78 Revision 1.15  1999/10/26 06:04:50  fca
79 Introduce TLorentzVector in AliMC::GetSecondary. Thanks to I.Hrivnacova
80
81 Revision 1.14  1999/09/29 09:24:30  fca
82 Introduction of the Copyright and cvs Log
83
84 */
85
86 ///////////////////////////////////////////////////////////////////////////////
87 //                                                                           //
88 //  Interface Class to the Geant3.21 MonteCarlo                              //
89 //                                                                           //
90 //Begin_Html
91 /*
92 <img src="picts/TGeant3Class.gif">
93 */
94 //End_Html
95 //                                                                           //
96 //                                                                           //
97 ///////////////////////////////////////////////////////////////////////////////
98
99 #include "TGeant3.h" 
100 #include "TROOT.h" 
101 #include "THIGZ.h" 
102 #include "ctype.h" 
103 #include <TDatabasePDG.h>
104 #include "AliDecayer.h"
105 #include "AliDecayerPythia.h"
106 #include "AliCallf77.h" 
107  
108 #ifndef WIN32 
109 # define gzebra  gzebra_ 
110 # define grfile  grfile_ 
111 # define gpcxyz  gpcxyz_ 
112 # define ggclos  ggclos_ 
113 # define glast   glast_ 
114 # define ginit   ginit_ 
115 # define gcinit  gcinit_ 
116 # define grun    grun_ 
117 # define gtrig   gtrig_ 
118 # define gtrigc  gtrigc_ 
119 # define gtrigi  gtrigi_ 
120 # define gwork   gwork_ 
121 # define gzinit  gzinit_ 
122 # define gfmate  gfmate_ 
123 # define gfpart  gfpart_ 
124 # define gftmed  gftmed_ 
125 # define gftmat  gftmat_ 
126 # define gmate   gmate_ 
127 # define gpart   gpart_ 
128 # define gsdk    gsdk_ 
129 # define gsmate  gsmate_ 
130 # define gsmixt  gsmixt_ 
131 # define gspart  gspart_ 
132 # define gstmed  gstmed_ 
133 # define gsckov  gsckov_
134 # define gstpar  gstpar_ 
135 # define gfkine  gfkine_ 
136 # define gfvert  gfvert_ 
137 # define gskine  gskine_ 
138 # define gsvert  gsvert_ 
139 # define gphysi  gphysi_ 
140 # define gdebug  gdebug_ 
141 # define gekbin  gekbin_ 
142 # define gfinds  gfinds_ 
143 # define gsking  gsking_ 
144 # define gskpho  gskpho_ 
145 # define gsstak  gsstak_ 
146 # define gsxyz   gsxyz_ 
147 # define gtrack  gtrack_ 
148 # define gtreve  gtreve_ 
149 # define gtreveroot  gtreveroot_ 
150 # define grndm   grndm_ 
151 # define grndmq  grndmq_ 
152 # define gdtom   gdtom_ 
153 # define glmoth  glmoth_ 
154 # define gmedia  gmedia_ 
155 # define gmtod   gmtod_ 
156 # define gsdvn   gsdvn_ 
157 # define gsdvn2  gsdvn2_ 
158 # define gsdvs   gsdvs_ 
159 # define gsdvs2  gsdvs2_ 
160 # define gsdvt   gsdvt_ 
161 # define gsdvt2  gsdvt2_
162 # define gsord   gsord_ 
163 # define gspos   gspos_ 
164 # define gsposp  gsposp_ 
165 # define gsrotm  gsrotm_ 
166 # define gprotm  gprotm_ 
167 # define gsvolu  gsvolu_ 
168 # define gprint  gprint_ 
169 # define gdinit  gdinit_ 
170 # define gdopt   gdopt_ 
171 # define gdraw   gdraw_ 
172 # define gdrayt  gdrayt_
173 # define gdrawc  gdrawc_ 
174 # define gdrawx  gdrawx_ 
175 # define gdhead  gdhead_ 
176 # define gdwmn1  gdwmn1_ 
177 # define gdwmn2  gdwmn2_ 
178 # define gdwmn3  gdwmn3_ 
179 # define gdxyz   gdxyz_ 
180 # define gdcxyz  gdcxyz_ 
181 # define gdman   gdman_ 
182 # define gdspec  gdspec_ 
183 # define gdtree  gdtree_ 
184 # define gdelet  gdelet_ 
185 # define gdclos  gdclos_ 
186 # define gdshow  gdshow_ 
187 # define gdopen  gdopen_ 
188 # define dzshow  dzshow_ 
189 # define gsatt   gsatt_ 
190 # define gfpara  gfpara_
191 # define gckpar  gckpar_
192 # define gckmat  gckmat_
193 # define geditv  geditv_
194 # define mzdrop  mzdrop_
195
196 # define ertrak  ertrak_
197 # define ertrgo  ertrgo_
198  
199 # define setbomb setbomb_
200 # define setclip setclip_
201 # define gcomad gcomad_
202
203 # define gbrelm gbrelm_
204 # define gprelm gprelm_
205 #else 
206 # define gzebra  GZEBRA 
207 # define grfile  GRFILE 
208 # define gpcxyz  GPCXYZ 
209 # define ggclos  GGCLOS 
210 # define glast   GLAST 
211 # define ginit   GINIT 
212 # define gcinit  GCINIT 
213 # define grun    GRUN 
214 # define gtrig   GTRIG 
215 # define gtrigc  GTRIGC 
216 # define gtrigi  GTRIGI 
217 # define gwork   GWORK 
218 # define gzinit  GZINIT 
219 # define gfmate  GFMATE 
220 # define gfpart  GFPART 
221 # define gftmed  GFTMED 
222 # define gftmat  GFTMAT
223 # define gmate   GMATE 
224 # define gpart   GPART 
225 # define gsdk    GSDK 
226 # define gsmate  GSMATE 
227 # define gsmixt  GSMIXT 
228 # define gspart  GSPART 
229 # define gstmed  GSTMED 
230 # define gsckov  GSCKOV
231 # define gstpar  GSTPAR 
232 # define gfkine  GFKINE 
233 # define gfvert  GFVERT 
234 # define gskine  GSKINE 
235 # define gsvert  GSVERT 
236 # define gphysi  GPHYSI 
237 # define gdebug  GDEBUG 
238 # define gekbin  GEKBIN 
239 # define gfinds  GFINDS 
240 # define gsking  GSKING 
241 # define gskpho  GSKPHO 
242 # define gsstak  GSSTAK 
243 # define gsxyz   GSXYZ 
244 # define gtrack  GTRACK 
245 # define gtreve  GTREVE 
246 # define gtreveroot  GTREVEROOT
247 # define grndm   GRNDM
248 # define grndmq  GRNDMQ
249 # define gdtom   GDTOM 
250 # define glmoth  GLMOTH 
251 # define gmedia  GMEDIA 
252 # define gmtod   GMTOD 
253 # define gsdvn   GSDVN 
254 # define gsdvn2  GSDVN2 
255 # define gsdvs   GSDVS 
256 # define gsdvs2  GSDVS2 
257 # define gsdvt   GSDVT 
258 # define gsdvt2  GSDVT2
259 # define gsord   GSORD 
260 # define gspos   GSPOS 
261 # define gsposp  GSPOSP 
262 # define gsrotm  GSROTM 
263 # define gprotm  GPROTM 
264 # define gsvolu  GSVOLU 
265 # define gprint  GPRINT 
266 # define gdinit  GDINIT
267 # define gdopt   GDOPT 
268 # define gdraw   GDRAW
269 # define gdrayt  GDRAYT
270 # define gdrawc  GDRAWC
271 # define gdrawx  GDRAWX 
272 # define gdhead  GDHEAD
273 # define gdwmn1  GDWMN1
274 # define gdwmn2  GDWMN2
275 # define gdwmn3  GDWMN3
276 # define gdxyz   GDXYZ
277 # define gdcxyz  GDCXYZ
278 # define gdman   GDMAN
279 # define gdfspc  GDFSPC
280 # define gdspec  GDSPEC
281 # define gdtree  GDTREE
282 # define gdelet  GDELET
283 # define gdclos  GDCLOS
284 # define gdshow  GDSHOW
285 # define gdopen  GDOPEN
286 # define dzshow  DZSHOW 
287 # define gsatt   GSATT 
288 # define gfpara  GFPARA
289 # define gckpar  GCKPAR
290 # define gckmat  GCKMAT
291 # define geditv  GEDITV
292 # define mzdrop  MZDROP 
293
294 # define ertrak  ERTRAK
295 # define ertrgo  ERTRGO
296  
297 # define setbomb SETBOMB
298 # define setclip SETCLIP
299 # define gcomad  GCOMAD
300  
301 # define gbrelm GBRELM
302 # define gprelm GPRELM
303
304 #endif 
305
306 //____________________________________________________________________________ 
307 extern "C" 
308 {
309   //
310   // Prototypes for GEANT functions
311   //
312   void type_of_call gzebra(const int&); 
313
314   void type_of_call gpcxyz(); 
315
316   void type_of_call ggclos(); 
317
318   void type_of_call glast(); 
319
320   void type_of_call ginit(); 
321
322   void type_of_call gcinit(); 
323
324   void type_of_call grun(); 
325
326   void type_of_call gtrig(); 
327
328   void type_of_call gtrigc(); 
329
330   void type_of_call gtrigi(); 
331
332   void type_of_call gwork(const int&); 
333
334   void type_of_call gzinit(); 
335
336   void type_of_call gmate(); 
337
338   void type_of_call gpart(); 
339
340   void type_of_call gsdk(Int_t &, Float_t *, Int_t *); 
341
342   void type_of_call gfkine(Int_t &, Float_t *, Float_t *, Int_t &,
343                            Int_t &, Float_t *, Int_t &); 
344
345   void type_of_call gfvert(Int_t &, Float_t *, Int_t &, Int_t &, 
346                            Float_t &, Float_t *, Int_t &); 
347
348   void type_of_call gskine(Float_t *,Int_t &, Int_t &, Float_t *,
349                            Int_t &, Int_t &); 
350
351   void type_of_call gsvert(Float_t *,Int_t &, Int_t &, Float_t *,
352                            Int_t &, Int_t &); 
353
354   void type_of_call gphysi(); 
355
356   void type_of_call gdebug(); 
357
358   void type_of_call gekbin(); 
359
360   void type_of_call gfinds(); 
361
362   void type_of_call gsking(Int_t &); 
363
364   void type_of_call gskpho(Int_t &); 
365
366   void type_of_call gsstak(Int_t &); 
367
368   void type_of_call gsxyz(); 
369
370   void type_of_call gtrack(); 
371
372   void type_of_call gtreve(); 
373
374   void type_of_call gtreveroot(); 
375
376   void type_of_call grndm(Float_t *, const Int_t &); 
377
378   void type_of_call grndmq(Int_t &, Int_t &, const Int_t &,
379                            DEFCHARD DEFCHARL); 
380
381   void type_of_call gdtom(Float_t *, Float_t *, Int_t &); 
382
383   void type_of_call glmoth(DEFCHARD, Int_t &, Int_t &, Int_t *,
384                            Int_t *, Int_t * DEFCHARL); 
385
386   void type_of_call gmedia(Float_t *, Int_t &); 
387
388   void type_of_call gmtod(Float_t *, Float_t *, Int_t &); 
389
390   void type_of_call gsrotm(const Int_t &, const Float_t &, const Float_t &,
391                            const Float_t &, const Float_t &, const Float_t &,
392                            const Float_t &); 
393
394   void type_of_call gprotm(const Int_t &); 
395
396   void type_of_call grfile(const Int_t&, DEFCHARD, 
397                            DEFCHARD DEFCHARL DEFCHARL); 
398
399   void type_of_call gfmate(const Int_t&, DEFCHARD, Float_t &, Float_t &,
400                            Float_t &, Float_t &, Float_t &, Float_t *,
401                            Int_t& DEFCHARL); 
402
403   void type_of_call gfpart(const Int_t&, DEFCHARD, Int_t &, Float_t &,
404                            Float_t &, Float_t &, Float_t *, Int_t & DEFCHARL); 
405
406   void type_of_call gftmed(const Int_t&, DEFCHARD, Int_t &, Int_t &, Int_t &,
407                            Float_t &, Float_t &, Float_t &, Float_t &,
408                            Float_t &, Float_t &, Float_t *, Int_t * DEFCHARL); 
409
410   void type_of_call gftmat(const Int_t&, const Int_t&, DEFCHARD, const Int_t&,
411                            Float_t*, Float_t*
412                            ,Float_t *, Int_t & DEFCHARL);
413
414   void type_of_call gsmate(const Int_t&, DEFCHARD, Float_t &, Float_t &,
415                            Float_t &, Float_t &, Float_t &, Float_t *,
416                            Int_t & DEFCHARL); 
417
418   void type_of_call gsmixt(const Int_t&, DEFCHARD, Float_t *, Float_t *,
419                            Float_t &, Int_t &, Float_t * DEFCHARL); 
420
421   void type_of_call gspart(const Int_t&, DEFCHARD, Int_t &, Float_t &,
422                            Float_t &, Float_t &, Float_t *, Int_t & DEFCHARL); 
423
424
425   void type_of_call gstmed(const Int_t&, DEFCHARD, Int_t &, Int_t &, Int_t &,
426                            Float_t &, Float_t &, Float_t &, Float_t &,
427                            Float_t &, Float_t &, Float_t *, Int_t & DEFCHARL); 
428
429   void type_of_call gsckov(Int_t &itmed, Int_t &npckov, Float_t *ppckov,
430                            Float_t *absco, Float_t *effic, Float_t *rindex);
431   void type_of_call gstpar(const Int_t&, DEFCHARD, Float_t & DEFCHARL); 
432
433   void type_of_call gsdvn(DEFCHARD,DEFCHARD, Int_t &, Int_t &
434                           DEFCHARL DEFCHARL); 
435
436   void type_of_call gsdvn2(DEFCHARD,DEFCHARD, Int_t &, Int_t &, Float_t &,
437                            Int_t & DEFCHARL DEFCHARL); 
438
439   void type_of_call gsdvs(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Int_t &
440                           DEFCHARL DEFCHARL); 
441
442   void type_of_call gsdvs2(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Float_t &,
443                            Int_t & DEFCHARL DEFCHARL); 
444
445   void type_of_call gsdvt(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Int_t &,
446                           Int_t & DEFCHARL DEFCHARL); 
447
448   void type_of_call gsdvt2(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Float_t&,
449                            Int_t &, Int_t & DEFCHARL DEFCHARL); 
450
451   void type_of_call gsord(DEFCHARD, Int_t & DEFCHARL); 
452
453   void type_of_call gspos(DEFCHARD, Int_t &, DEFCHARD, Float_t &, Float_t &,
454                           Float_t &, Int_t &, DEFCHARD DEFCHARL DEFCHARL
455                           DEFCHARL); 
456
457   void type_of_call gsposp(DEFCHARD, Int_t &, DEFCHARD, Float_t &, Float_t &,
458                            Float_t &, Int_t &, DEFCHARD,  
459                            Float_t *, Int_t & DEFCHARL DEFCHARL DEFCHARL); 
460
461   void type_of_call gsvolu(DEFCHARD, DEFCHARD, Int_t &, Float_t *, Int_t &,
462                            Int_t & DEFCHARL DEFCHARL); 
463
464   void type_of_call gsatt(DEFCHARD, DEFCHARD, Int_t & DEFCHARL DEFCHARL); 
465
466   void type_of_call gfpara(DEFCHARD , Int_t&, Int_t&, Int_t&, Int_t&, Float_t*,
467                            Float_t* DEFCHARL);
468
469   void type_of_call gckpar(Int_t&, Int_t&, Float_t*);
470
471   void type_of_call gckmat(Int_t&, DEFCHARD DEFCHARL);
472
473   void type_of_call gprint(DEFCHARD,const int& DEFCHARL); 
474
475   void type_of_call gdinit(); 
476
477   void type_of_call gdopt(DEFCHARD,DEFCHARD DEFCHARL DEFCHARL); 
478   
479   void type_of_call gdraw(DEFCHARD,Float_t &,Float_t &, Float_t &,Float_t &,
480                           Float_t &, Float_t &, Float_t & DEFCHARL); 
481   void type_of_call gdrayt(DEFCHARD,Float_t &,Float_t &, Float_t &,Float_t &,
482                            Float_t &, Float_t &, Float_t & DEFCHARL); 
483   void type_of_call gdrawc(DEFCHARD,Int_t &, Float_t &, Float_t &, Float_t &,
484                           Float_t &, Float_t & DEFCHARL); 
485   void type_of_call gdrawx(DEFCHARD,Float_t &, Float_t &, Float_t &, Float_t &,
486                            Float_t &, Float_t &, Float_t &, Float_t &,
487                            Float_t & DEFCHARL); 
488   void type_of_call gdhead(Int_t &,DEFCHARD, Float_t & DEFCHARL);
489   void type_of_call gdxyz(Int_t &);
490   void type_of_call gdcxyz();
491   void type_of_call gdman(Float_t &, Float_t &);
492   void type_of_call gdwmn1(Float_t &, Float_t &);
493   void type_of_call gdwmn2(Float_t &, Float_t &);
494   void type_of_call gdwmn3(Float_t &, Float_t &);
495   void type_of_call gdspec(DEFCHARD DEFCHARL);
496   void type_of_call gdfspc(DEFCHARD, Int_t &, Int_t & DEFCHARL) {;}
497   void type_of_call gdtree(DEFCHARD, Int_t &, Int_t & DEFCHARL);
498
499   void type_of_call gdopen(Int_t &);
500   void type_of_call gdclos();
501   void type_of_call gdelet(Int_t &);
502   void type_of_call gdshow(Int_t &);
503   void type_of_call geditv(Int_t &) {;}
504
505
506   void type_of_call dzshow(DEFCHARD,const int&,const int&,DEFCHARD,const int&,
507                            const int&, const int&, const int& DEFCHARL
508                            DEFCHARL); 
509
510   void type_of_call mzdrop(Int_t&, Int_t&, DEFCHARD DEFCHARL);
511
512   void type_of_call setbomb(Float_t &);
513   void type_of_call setclip(DEFCHARD, Float_t &,Float_t &,Float_t &,Float_t &,
514                             Float_t &, Float_t & DEFCHARL); 
515   void type_of_call gcomad(DEFCHARD, Int_t*& DEFCHARL); 
516
517   void type_of_call ertrak(const Float_t *const x1, const Float_t *const p1,
518                            const Float_t *x2, const Float_t *p2,
519                            const Int_t &ipa, DEFCHARD DEFCHARL);
520
521   void type_of_call ertrgo();
522   
523     float type_of_call gbrelm(const Float_t &z, const Float_t& t, const Float_t& cut);
524     float type_of_call gprelm(const Float_t &z, const Float_t& t, const Float_t& cut);
525 }
526
527 //
528 // Geant3 global pointer
529 //
530 static const Int_t kDefSize = 600;
531
532 ClassImp(TGeant3) 
533  
534 //____________________________________________________________________________ 
535 TGeant3::TGeant3()
536
537   //
538   // Default constructor
539   //
540
541  
542 //____________________________________________________________________________ 
543 TGeant3::TGeant3(const char *title, Int_t nwgeant) 
544        :AliMC("TGeant3",title) 
545 {
546   //
547   // Standard constructor for TGeant3 with ZEBRA initialisation
548   // 
549    
550   if(nwgeant) {
551     gzebra(nwgeant); 
552     ginit(); 
553     gzinit();
554   } else {
555     gcinit();
556   }
557   //
558   // Load Address of Geant3 commons    
559   LoadAddress(); 
560   //
561   // Zero number of particles
562   fNPDGCodes=0;
563   fDecayer=new AliDecayerPythia();
564   fForceDecay = all;
565
566
567 //____________________________________________________________________________ 
568 Int_t TGeant3::CurrentMaterial(Float_t &a, Float_t &z, Float_t &dens,
569                                Float_t &radl, Float_t &absl) const
570 {
571   //
572   // Return the parameters of the current material during transport
573   //
574   z     = fGcmate->z;
575   a     = fGcmate->a;
576   dens  = fGcmate->dens;
577   radl  = fGcmate->radl;
578   absl  = fGcmate->absl;
579   return 1;  //this could be the number of elements in mixture
580 }
581    
582 //____________________________________________________________________________ 
583 void TGeant3::DefaultRange()
584
585   //
586   // Set range of current drawing pad to 20x20 cm
587   //
588   if (!gHigz) {
589     new THIGZ(kDefSize); 
590     gdinit();
591   }
592   gHigz->Range(0,0,20,20);
593 }
594
595 //____________________________________________________________________________ 
596 void TGeant3::InitHIGZ() 
597
598   //
599   // Initialise HIGZ
600   //
601   if (!gHigz) {
602     new THIGZ(kDefSize); 
603     gdinit();
604   }
605 }
606  
607 //____________________________________________________________________________ 
608 void TGeant3::LoadAddress() 
609
610   //
611   // Assigns the address of the GEANT common blocks to the structures
612   // that allow their access from C++
613   //
614   Int_t *addr;
615   gcomad(PASSCHARD("QUEST"), (int*&) fQuest PASSCHARL("QUEST"));
616   gcomad(PASSCHARD("GCBANK"),(int*&) fGcbank  PASSCHARL("GCBANK"));
617   gcomad(PASSCHARD("GCLINK"),(int*&) fGclink  PASSCHARL("GCLINK"));
618   gcomad(PASSCHARD("GCCUTS"),(int*&) fGccuts  PASSCHARL("GCCUTS"));
619   gcomad(PASSCHARD("GCMULO"),(int*&) fGcmulo  PASSCHARL("GCMULO"));
620   gcomad(PASSCHARD("GCFLAG"),(int*&) fGcflag  PASSCHARL("GCFLAG"));
621   gcomad(PASSCHARD("GCKINE"),(int*&) fGckine  PASSCHARL("GCKINE"));
622   gcomad(PASSCHARD("GCKING"),(int*&) fGcking  PASSCHARL("GCKING"));
623   gcomad(PASSCHARD("GCKIN2"),(int*&) fGckin2  PASSCHARL("GCKIN2"));
624   gcomad(PASSCHARD("GCKIN3"),(int*&) fGckin3  PASSCHARL("GCKIN3"));
625   gcomad(PASSCHARD("GCMATE"),(int*&) fGcmate  PASSCHARL("GCMATE"));
626   gcomad(PASSCHARD("GCTMED"),(int*&) fGctmed  PASSCHARL("GCTMED"));
627   gcomad(PASSCHARD("GCTRAK"),(int*&) fGctrak  PASSCHARL("GCTRAK"));
628   gcomad(PASSCHARD("GCTPOL"),(int*&) fGctpol  PASSCHARL("GCTPOL"));
629   gcomad(PASSCHARD("GCVOLU"),(int*&) fGcvolu  PASSCHARL("GCVOLU"));
630   gcomad(PASSCHARD("GCNUM"), (int*&) fGcnum   PASSCHARL("GCNUM"));
631   gcomad(PASSCHARD("GCSETS"),(int*&) fGcsets  PASSCHARL("GCSETS"));
632   gcomad(PASSCHARD("GCPHYS"),(int*&) fGcphys  PASSCHARL("GCPHYS"));
633   gcomad(PASSCHARD("GCPHLT"),(int*&) fGcphlt  PASSCHARL("GCPHLT"));
634   gcomad(PASSCHARD("GCOPTI"),(int*&) fGcopti  PASSCHARL("GCOPTI"));
635   gcomad(PASSCHARD("GCTLIT"),(int*&) fGctlit  PASSCHARL("GCTLIT"));
636   gcomad(PASSCHARD("GCVDMA"),(int*&) fGcvdma  PASSCHARL("GCVDMA"));
637
638   // Commons for GEANE
639   gcomad(PASSCHARD("ERTRIO"),(int*&) fErtrio  PASSCHARL("ERTRIO"));
640   gcomad(PASSCHARD("EROPTS"),(int*&) fEropts  PASSCHARL("EROPTS"));
641   gcomad(PASSCHARD("EROPTC"),(int*&) fEroptc  PASSCHARL("EROPTC"));
642   gcomad(PASSCHARD("ERWORK"),(int*&) fErwork  PASSCHARL("ERWORK"));
643
644   // Variables for ZEBRA store
645   gcomad(PASSCHARD("IQ"), addr  PASSCHARL("IQ"));
646   fZiq = addr;
647   gcomad(PASSCHARD("LQ"), addr  PASSCHARL("LQ"));
648   fZlq = addr;
649   fZq       = (float*)fZiq; 
650
651
652 //_____________________________________________________________________________
653 void TGeant3::GeomIter()
654 {
655   //
656   // Geometry iterator for moving upward in the geometry tree
657   // Initialise the iterator
658   //
659   fNextVol=fGcvolu->nlevel;
660 }
661
662 //____________________________________________________________________________ 
663 void TGeant3::FinishGeometry()
664 {
665   //Close the geometry structure
666   Ggclos();
667 }
668   
669 //____________________________________________________________________________ 
670 Int_t TGeant3::NextVolUp(Text_t *name, Int_t &copy)
671 {
672   //
673   // Geometry iterator for moving upward in the geometry tree
674   // Return next volume up
675   //
676   Int_t i, gname;
677   fNextVol--;
678   if(fNextVol>=0) {
679     gname=fGcvolu->names[fNextVol];
680     copy=fGcvolu->number[fNextVol];
681     i=fGcvolu->lvolum[fNextVol];
682     name = fVolNames[i-1];
683     if(gname == fZiq[fGclink->jvolum+i]) return i;
684     else printf("GeomTree: Volume %s not found in bank\n",name);
685   }
686   return 0;
687 }
688
689 //_____________________________________________________________________________
690 void TGeant3::BuildPhysics()
691 {
692   Gphysi();
693 }
694
695 //_____________________________________________________________________________
696 Int_t TGeant3::CurrentVolID(Int_t &copy) const
697 {
698   //
699   // Returns the current volume ID and copy number
700   //
701   Int_t i, gname;
702   if( (i=fGcvolu->nlevel-1) < 0 ) {
703     Warning("CurrentVolID","Stack depth only %d\n",fGcvolu->nlevel);
704   } else {
705     gname=fGcvolu->names[i];
706     copy=fGcvolu->number[i];
707     i=fGcvolu->lvolum[i];   
708     if(gname == fZiq[fGclink->jvolum+i]) return i;
709     else Warning("CurrentVolID","Volume %4s not found\n",(char*)&gname);
710   }
711   return 0;
712 }
713
714 //_____________________________________________________________________________
715 Int_t TGeant3::CurrentVolOffID(Int_t off, Int_t &copy) const
716 {
717   //
718   // Return the current volume "off" upward in the geometrical tree 
719   // ID and copy number
720   //
721   Int_t i, gname;
722   if( (i=fGcvolu->nlevel-off-1) < 0 ) {
723     Warning("CurrentVolOffID","Offset requested %d but stack depth %d\n",
724             off,fGcvolu->nlevel);
725   } else {
726     gname=fGcvolu->names[i];
727     copy=fGcvolu->number[i];          
728     i=fGcvolu->lvolum[i];    
729     if(gname == fZiq[fGclink->jvolum+i]) return i;
730     else Warning("CurrentVolOffID","Volume %4s not found\n",(char*)&gname);
731   }
732   return 0;
733 }
734
735 //_____________________________________________________________________________
736 const char* TGeant3::CurrentVolName() const
737 {
738   //
739   // Returns the current volume name
740   //
741   Int_t i, gname;
742   if( (i=fGcvolu->nlevel-1) < 0 ) {
743     Warning("CurrentVolName","Stack depth %d\n",fGcvolu->nlevel);
744   } else {
745     gname=fGcvolu->names[i];
746     i=fGcvolu->lvolum[i];   
747     if(gname == fZiq[fGclink->jvolum+i]) return fVolNames[i-1];
748     else Warning("CurrentVolName","Volume %4s not found\n",(char*) &gname);
749   }
750   return 0;
751 }
752
753 //_____________________________________________________________________________
754 const char* TGeant3::CurrentVolOffName(Int_t off) const
755 {
756   //
757   // Return the current volume "off" upward in the geometrical tree 
758   // ID, name and copy number
759   // if name=0 no name is returned
760   //
761   Int_t i, gname;
762   if( (i=fGcvolu->nlevel-off-1) < 0 ) {
763     Warning("CurrentVolOffName",
764             "Offset requested %d but stack depth %d\n",off,fGcvolu->nlevel);
765   } else {
766     gname=fGcvolu->names[i];
767     i=fGcvolu->lvolum[i];    
768     if(gname == fZiq[fGclink->jvolum+i]) return fVolNames[i-1];
769     else Warning("CurrentVolOffName","Volume %4s not found\n",(char*)&gname);
770   }
771   return 0;
772 }
773
774 //_____________________________________________________________________________
775 Int_t TGeant3::IdFromPDG(Int_t pdg) const 
776 {
777   //
778   // Return Geant3 code from PDG and pseudo ENDF code
779   //
780   for(Int_t i=0;i<fNPDGCodes;++i)
781     if(pdg==fPDGCode[i]) return i;
782   return -1;
783 }
784
785 //_____________________________________________________________________________
786 Int_t TGeant3::PDGFromId(Int_t id) const 
787 {
788   //
789   // Return PDG code and pseudo ENDF code from Geant3 code
790   //
791   if(id>0 && id<fNPDGCodes) return fPDGCode[id];
792   else return -1;
793 }
794
795 //_____________________________________________________________________________
796 void TGeant3::DefineParticles() 
797 {
798   //
799   // Define standard Geant 3 particles
800   Gpart();
801   //
802   // Load standard numbers for GEANT particles and PDG conversion
803   fPDGCode[fNPDGCodes++]=-99;   //  0 = unused location
804   fPDGCode[fNPDGCodes++]=22;    //  1 = photon
805   fPDGCode[fNPDGCodes++]=-11;   //  2 = positron
806   fPDGCode[fNPDGCodes++]=11;    //  3 = electron
807   fPDGCode[fNPDGCodes++]=12;    //  4 = neutrino e
808   fPDGCode[fNPDGCodes++]=-13;   //  5 = muon +
809   fPDGCode[fNPDGCodes++]=13;    //  6 = muon -
810   fPDGCode[fNPDGCodes++]=111;   //  7 = pi0
811   fPDGCode[fNPDGCodes++]=211;   //  8 = pi+
812   fPDGCode[fNPDGCodes++]=-211;  //  9 = pi-
813   fPDGCode[fNPDGCodes++]=130;   // 10 = Kaon Long
814   fPDGCode[fNPDGCodes++]=321;   // 11 = Kaon +
815   fPDGCode[fNPDGCodes++]=-321;  // 12 = Kaon -
816   fPDGCode[fNPDGCodes++]=2112;  // 13 = Neutron
817   fPDGCode[fNPDGCodes++]=2212;  // 14 = Proton
818   fPDGCode[fNPDGCodes++]=-2212; // 15 = Anti Proton
819   fPDGCode[fNPDGCodes++]=310;   // 16 = Kaon Short
820   fPDGCode[fNPDGCodes++]=221;   // 17 = Eta
821   fPDGCode[fNPDGCodes++]=3122;  // 18 = Lambda
822   fPDGCode[fNPDGCodes++]=3222;  // 19 = Sigma +
823   fPDGCode[fNPDGCodes++]=3212;  // 20 = Sigma 0
824   fPDGCode[fNPDGCodes++]=3112;  // 21 = Sigma -
825   fPDGCode[fNPDGCodes++]=3322;  // 22 = Xi0
826   fPDGCode[fNPDGCodes++]=3312;  // 23 = Xi-
827   fPDGCode[fNPDGCodes++]=3334;  // 24 = Omega-
828   fPDGCode[fNPDGCodes++]=-2112; // 25 = Anti Proton
829   fPDGCode[fNPDGCodes++]=-3122; // 26 = Anti Proton
830   fPDGCode[fNPDGCodes++]=-3222; // 27 = Anti Sigma -
831   fPDGCode[fNPDGCodes++]=-3212; // 28 = Anti Sigma 0
832   fPDGCode[fNPDGCodes++]=-3112; // 29 = Anti Sigma 0
833   fPDGCode[fNPDGCodes++]=-3322; // 30 = Anti Xi 0
834   fPDGCode[fNPDGCodes++]=-3312; // 31 = Anti Xi +
835   fPDGCode[fNPDGCodes++]=-3334; // 32 = Anti Omega +
836
837
838   Int_t mode[6];
839   Int_t kz, ipa;
840   Float_t bratio[6];
841
842   /* --- Define additional particles */
843   Gspart(33, "OMEGA(782)", 3, 0.782, 0., 7.836e-23);
844   fPDGCode[fNPDGCodes++]=223;   // 33 = Omega(782)
845   
846   Gspart(34, "PHI(1020)", 3, 1.019, 0., 1.486e-22);
847   fPDGCode[fNPDGCodes++]=333;   // 34 = PHI (1020)
848
849   Gspart(35, "D +", 4, 1.87, 1., 1.066e-12);
850   fPDGCode[fNPDGCodes++]=411;   // 35 = D+
851
852   Gspart(36, "D -", 4, 1.87, -1., 1.066e-12);
853   fPDGCode[fNPDGCodes++]=-411;  // 36 = D-
854
855   Gspart(37, "D 0", 3, 1.865, 0., 4.2e-13);
856   fPDGCode[fNPDGCodes++]=421;   // 37 = D0
857
858   Gspart(38, "ANTI D 0", 3, 1.865, 0., 4.2e-13);
859   fPDGCode[fNPDGCodes++]=-421;  // 38 = D0 bar
860
861   fPDGCode[fNPDGCodes++]=-99;  // 39 = unassigned
862
863   fPDGCode[fNPDGCodes++]=-99;  // 40 = unassigned
864
865   fPDGCode[fNPDGCodes++]=-99;  // 41 = unassigned
866
867   Gspart(42, "RHO +", 4, 0.768, 1., 4.353e-24);
868   fPDGCode[fNPDGCodes++]=213;   // 42 = RHO+
869
870   Gspart(43, "RHO -", 4, 0.768, -1., 4.353e-24);
871   fPDGCode[fNPDGCodes++]=-213;   // 43 = RHO-
872
873   Gspart(44, "RHO 0", 3, 0.768, 0., 4.353e-24);
874   fPDGCode[fNPDGCodes++]=113;   //  44 = RHO0
875
876   //
877   // Use ENDF-6 mapping for ions = 10000*z+10*a+iso
878   // and add 1 000 000
879   // and numbers above 5 000 000 for special applications
880   //
881
882   const Int_t kion=10000000;
883
884   const Int_t kspe=50000000;
885
886   TDatabasePDG *pdgDB = TDatabasePDG::Instance();
887
888   const Double_t kAu2Gev=0.9314943228;
889   const Double_t khSlash = 1.0545726663e-27;
890   const Double_t kErg2Gev = 1/1.6021773349e-3;
891   const Double_t khShGev = khSlash*kErg2Gev;
892   const Double_t kYear2Sec = 3600*24*365.25;
893 //
894 // Bottom mesons
895 // mass and life-time from PDG
896   pdgDB->AddParticle("B(s)*0","B(s)*0",
897                      5.4163, kTRUE, 0.047, +0.,"Meson",  533);
898
899   pdgDB->AddParticle("B(s)*0 bar","B(s)*0 bar",
900                      5.4163, kTRUE, 0.047, -0.,"Meson", -533);
901
902 // Charmed baryons
903 // 
904 // value for mass used by Hijing
905   pdgDB->AddParticle("Sigma(c)*+","Sigma(c)*+",
906                      2.4536, kTRUE, -1., +1.,"Baryon",  4214);
907
908   pdgDB->AddParticle("Sigma(c)*-","Sigma(c)*-",
909                      2.4536, kTRUE, -1., -1.,"Baryon", -4214);
910 // equivalent to 4312 ? Hijing uses m=2.55
911   pdgDB->AddParticle("Xsi(c)0","Xsi(c)0",
912                      2.4703, kTRUE, -1., +0.,"Baryon",  4132);
913
914   pdgDB->AddParticle("Xsi(c)0 bar","Xsi(c)0 bar",
915                      2.4703, kTRUE, -1., -0.,"Baryon", -4132);
916 // equivalent to 4322 ? Hijing uses m=2.55
917   pdgDB->AddParticle("Xi(c)+","Xi(c)+",
918                      2.4656, kFALSE, -1., +1.,"Baryon",  4232);
919   
920   pdgDB->AddParticle("Xi(c)-","Xi(c)-",
921                      2.4656, kFALSE, -1., -1.,"Baryon", -4232);
922 // mass values from Hijing
923
924   pdgDB->AddParticle("Xsi(c)*0","Xsi(c)*0",
925                      2.63, kTRUE, -1., +0.,"Baryon",  4314);
926
927   pdgDB->AddParticle("Xsi(c)*0 bar","Xsi(c)*0 bar",
928                      2.63, kTRUE, -1., -0.,"Baryon", -4314);
929
930   pdgDB->AddParticle("Xsi(c)*+","Xsi(c)*+",
931                      2.63, kTRUE, -1., +1.,"Baryon",  4324);
932
933   pdgDB->AddParticle("Xsi(c)*-","Xsi(c)*-",
934                      2.63, kTRUE, -1., -1.,"Baryon", -4324);
935
936 // pdg mass value, Hijing uses m=2.73.
937   pdgDB->AddParticle("Omega(c)0","Omega(c)0",
938                      2.7040, kFALSE, khShGev/0.064e-12, +0.,"Baryon",  4332);
939   
940   pdgDB->AddParticle("Omega(c)0 bar","Omega(c)0 bar",
941                      2.7040, kFALSE, khShGev/0.064e-12, -0.,"Baryon", -4332);
942 // mass value from Hijing
943   pdgDB->AddParticle("Omega(c)*0","Omega(c)*0",
944                      2.8000, kFALSE, -1., +0.,"Baryon",  4334);
945   
946   pdgDB->AddParticle("Omega(c)*0 bar","Omega(c)*0",
947                      2.8000, kFALSE, -1., -0.,"Baryon", -4334);
948
949 // Bottom baryons
950 //
951 // mass value from Hijing
952   pdgDB->AddParticle("Sigma(b)*+","Sigma(b)*+",
953                      5.8100, kFALSE, -1., +1.,"Baryon", 5224);
954
955   pdgDB->AddParticle("Sigma(b)*-","Sigma(b)*-",
956                      5.8100, kFALSE, -1., -1.,"Baryon", -5224);
957  
958 //
959 //
960   pdgDB->AddParticle("Deuteron","Deuteron",2*kAu2Gev+8.071e-3,kTRUE,
961                      0,1,"Ion",kion+10020);
962   fPDGCode[fNPDGCodes++]=kion+10020;   // 45 = Deuteron
963
964   pdgDB->AddParticle("Triton","Triton",3*kAu2Gev+14.931e-3,kFALSE,
965                      khShGev/(12.33*kYear2Sec),1,"Ion",kion+10030);
966   fPDGCode[fNPDGCodes++]=kion+10030;   // 46 = Triton
967
968   pdgDB->AddParticle("Alpha","Alpha",4*kAu2Gev+2.424e-3,kTRUE,
969                      khShGev/(12.33*kYear2Sec),2,"Ion",kion+20040);
970   fPDGCode[fNPDGCodes++]=kion+20040;   // 47 = Alpha
971
972   fPDGCode[fNPDGCodes++]=0;   // 48 = geantino mapped to rootino
973
974   pdgDB->AddParticle("HE3","HE3",3*kAu2Gev+14.931e-3,kFALSE,
975                      0,2,"Ion",kion+20030);
976   fPDGCode[fNPDGCodes++]=kion+20030;   // 49 = HE3
977
978   pdgDB->AddParticle("Cherenkov","Cherenkov",0,kFALSE,
979                      0,0,"Special",kspe+50);
980   fPDGCode[fNPDGCodes++]=kspe+50;   // 50 = Cherenkov
981
982   Gspart(51, "FeedbackPhoton", 7, 0., 0.,1.e20 );
983   pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton",0,kFALSE,
984                      0,0,"Special",kspe+51);
985   fPDGCode[fNPDGCodes++]=kspe+51;   // 51 = FeedbackPhoton
986   Gspart(52, "Lambda_c+", 4, 2.2849, +1., 2.06e-13);
987   fPDGCode[fNPDGCodes++]=4122;   //52 = Lambda_c+
988
989   Gspart(53, "Lambda_c-", 4, 2.2849, -1., 2.06e-13);
990   fPDGCode[fNPDGCodes++]=-4122; //53 = Lambda_c-  
991
992   Gspart(54, "D_s+", 4, 1.9685, +1., 4.67e-13);
993   fPDGCode[fNPDGCodes++]=431;   //54 = D_s+
994
995   Gspart(55, "D_s-", 4, 1.9685, -1., 4.67e-13);
996   fPDGCode[fNPDGCodes++]=-431; //55 = D_s-
997
998   Gspart(56, "Tau+", 5, 1.77705, +1., 2.9e-13);
999   fPDGCode[fNPDGCodes++]=15;   //56 = Tau+
1000
1001   Gspart(57, "Tau-", 5, 1.77705, -1., 2.9e-13);
1002   fPDGCode[fNPDGCodes++]=-15;  //57 = Tau-  
1003
1004   Gspart(58, "B0",     3, 5.2792, +0., 1.56e-12);
1005   fPDGCode[fNPDGCodes++]=511;   //58 = B0
1006
1007   Gspart(59, "B0 bar", 3, 5.2792, -0., 1.56e-12);
1008   fPDGCode[fNPDGCodes++]=-511;  //58 = B0bar
1009
1010   Gspart(60, "B+",     4, 5.2789, +1., 1.65e-12);
1011   fPDGCode[fNPDGCodes++]=521;   //60 = B+
1012
1013   Gspart(61, "B-",     4, 5.2789, -1., 1.65e-12);
1014   fPDGCode[fNPDGCodes++]=-521;  //61 = B-
1015
1016   Gspart(62, "Bs",     3, 5.3693, +0., 1.54e-12);
1017   fPDGCode[fNPDGCodes++]=521;   //62 = B_s
1018
1019   Gspart(63, "Bs bar", 3, 5.3693, -0., 1.54e-12);
1020   fPDGCode[fNPDGCodes++]=-521;  //63 = B_s bar
1021
1022   Gspart(64, "Lambda_b",     3, 5.624, +0., 1.24e-12);
1023   fPDGCode[fNPDGCodes++]=5122;   //64 = Lambda_b
1024
1025   Gspart(65, "Lambda_b bar", 3, 5.624, -0., 1.24e-12);
1026   fPDGCode[fNPDGCodes++]=-5122;  //65 = Lambda_b bar
1027
1028   Gspart(66, "J/Psi", 3.09688, 3, 0., 0.);
1029   fPDGCode[fNPDGCodes++]=443;       // 66 = J/Psi
1030
1031   Gspart(67, "Psi Prime", 3, 3.686, 0., 0.);
1032   fPDGCode[fNPDGCodes++]=20443;    // 67 = Psi prime
1033
1034   Gspart(68, "Upsilon(1S)", 9.46037, 3, 0., 0.);
1035   fPDGCode[fNPDGCodes++]=553;       // 68 = Upsilon(1S)
1036
1037   Gspart(69, "Upsilon(2S)", 10.0233, 3, 0., 0.);
1038   fPDGCode[fNPDGCodes++]=20553;       // 69 = Upsilon(2S)
1039
1040   Gspart(70, "Upsilon(3S)", 10.3553, 3, 0., 0.);
1041   fPDGCode[fNPDGCodes++]=30553;       // 70 = Upsilon(3S)
1042
1043 /* --- Define additional decay modes --- */
1044 /* --- omega(783) --- */
1045     for (kz = 0; kz < 6; ++kz) {
1046         bratio[kz] = 0.;
1047         mode[kz] = 0;
1048     }
1049     ipa = 33;
1050     bratio[0] = 89.;
1051     bratio[1] = 8.5;
1052     bratio[2] = 2.5;
1053     mode[0] = 70809;
1054     mode[1] = 107;
1055     mode[2] = 908;
1056     Gsdk(ipa, bratio, mode);
1057 /* --- phi(1020) --- */
1058     for (kz = 0; kz < 6; ++kz) {
1059         bratio[kz] = 0.;
1060         mode[kz] = 0;
1061     }
1062     ipa = 34;
1063     bratio[0] = 49.;
1064     bratio[1] = 34.4;
1065     bratio[2] = 12.9;
1066     bratio[3] = 2.4;
1067     bratio[4] = 1.3;
1068     mode[0] = 1112;
1069     mode[1] = 1610;
1070     mode[2] = 4407;
1071     mode[3] = 90807;
1072     mode[4] = 1701;
1073     Gsdk(ipa, bratio, mode);
1074 /* --- D+ --- */
1075     /*
1076     for (kz = 0; kz < 6; ++kz) {
1077         bratio[kz] = 0.;
1078         mode[kz] = 0;
1079     }
1080     ipa = 35;
1081     bratio[0] = 25.;
1082     bratio[1] = 25.;
1083     bratio[2] = 25.;
1084     bratio[3] = 25.;
1085     mode[0] = 80809;
1086     mode[1] = 120808;
1087     mode[2] = 111208;
1088     mode[3] = 110809;
1089     Gsdk(ipa, bratio, mode);
1090     */
1091 /* --- D- --- */
1092     /*
1093     for (kz = 0; kz < 6; ++kz) {
1094         bratio[kz] = 0.;
1095         mode[kz] = 0;
1096     }
1097     ipa = 36;
1098     bratio[0] = 25.;
1099     bratio[1] = 25.;
1100     bratio[2] = 25.;
1101     bratio[3] = 25.;
1102     mode[0] = 90908;
1103     mode[1] = 110909;
1104     mode[2] = 121109;
1105     mode[3] = 120908;
1106     Gsdk(ipa, bratio, mode);
1107     */
1108 /* --- D0 --- */
1109     /*
1110     for (kz = 0; kz < 6; ++kz) {
1111         bratio[kz] = 0.;
1112         mode[kz] = 0;
1113     }
1114     ipa = 37;
1115     bratio[0] = 33.;
1116     bratio[1] = 33.;
1117     bratio[2] = 33.;
1118     mode[0] = 809;
1119     mode[1] = 1208;
1120     mode[2] = 1112;
1121     Gsdk(ipa, bratio, mode);
1122     */
1123 /* --- Anti D0 --- */
1124     /*
1125     for (kz = 0; kz < 6; ++kz) {
1126         bratio[kz] = 0.;
1127         mode[kz] = 0;
1128     }
1129     ipa = 38;
1130     bratio[0] = 33.;
1131     bratio[1] = 33.;
1132     bratio[2] = 33.;
1133     mode[0] = 809;
1134     mode[1] = 1109;
1135     mode[2] = 1112;
1136     Gsdk(ipa, bratio, mode);
1137     */
1138 /* --- rho+ --- */
1139     for (kz = 0; kz < 6; ++kz) {
1140         bratio[kz] = 0.;
1141         mode[kz] = 0;
1142     }
1143     ipa = 42;
1144     bratio[0] = 100.;
1145     mode[0] = 807;
1146     Gsdk(ipa, bratio, mode);
1147 /* --- rho- --- */
1148     for (kz = 0; kz < 6; ++kz) {
1149         bratio[kz] = 0.;
1150         mode[kz] = 0;
1151     }
1152     ipa = 43;
1153     bratio[0] = 100.;
1154     mode[0] = 907;
1155     Gsdk(ipa, bratio, mode);
1156 /* --- rho0 --- */
1157     for (kz = 0; kz < 6; ++kz) {
1158         bratio[kz] = 0.;
1159         mode[kz] = 0;
1160     }
1161     ipa = 44;
1162     bratio[0] = 100.;
1163     mode[0] = 707;
1164     Gsdk(ipa, bratio, mode);
1165     /*
1166 // --- jpsi ---
1167     for (kz = 0; kz < 6; ++kz) {
1168         bratio[kz] = 0.;
1169         mode[kz] = 0;
1170     }
1171     ipa = 113;
1172     bratio[0] = 50.;
1173     bratio[1] = 50.;
1174     mode[0] = 506;
1175     mode[1] = 605;
1176     Gsdk(ipa, bratio, mode);
1177 // --- upsilon --- 
1178     ipa = 114;
1179     Gsdk(ipa, bratio, mode);
1180 // --- phi --- 
1181     ipa = 115;
1182     Gsdk(ipa, bratio, mode);
1183     */
1184
1185 }
1186
1187 //_____________________________________________________________________________
1188 Int_t TGeant3::VolId(const Text_t *name) const
1189 {
1190   //
1191   // Return the unique numeric identifier for volume name
1192   //
1193   Int_t gname, i;
1194   strncpy((char *) &gname, name, 4);
1195   for(i=1; i<=fGcnum->nvolum; i++)
1196     if(gname == fZiq[fGclink->jvolum+i]) return i;
1197   printf("VolId: Volume %s not found\n",name);
1198   return 0;
1199 }
1200
1201 //_____________________________________________________________________________
1202 Int_t TGeant3::NofVolumes() const 
1203 {
1204   //
1205   // Return total number of volumes in the geometry
1206   //
1207   return fGcnum->nvolum;
1208 }
1209
1210 //_____________________________________________________________________________
1211 const char* TGeant3::VolName(Int_t id) const
1212 {
1213   //
1214   // Return the volume name given the volume identifier
1215   //
1216   if(id<1 || id > fGcnum->nvolum || fGclink->jvolum<=0) 
1217     return fVolNames[fGcnum->nvolum];
1218   else
1219     return fVolNames[id-1];
1220 }
1221
1222 //_____________________________________________________________________________
1223 void    TGeant3::SetCut(const char* cutName, Float_t cutValue)
1224 {
1225   //
1226   // Set transport cuts for particles
1227   //
1228   if(!strcmp(cutName,"CUTGAM")) 
1229     fGccuts->cutgam=cutValue; 
1230   else if(!strcmp(cutName,"CUTGAM")) 
1231     fGccuts->cutele=cutValue; 
1232   else if(!strcmp(cutName,"CUTELE")) 
1233     fGccuts->cutneu=cutValue; 
1234   else if(!strcmp(cutName,"CUTHAD")) 
1235     fGccuts->cuthad=cutValue; 
1236   else if(!strcmp(cutName,"CUTMUO")) 
1237     fGccuts->cutmuo=cutValue; 
1238   else if(!strcmp(cutName,"BCUTE")) 
1239     fGccuts->bcute=cutValue; 
1240   else if(!strcmp(cutName,"BCUTM")) 
1241     fGccuts->bcutm=cutValue; 
1242   else if(!strcmp(cutName,"DCUTE")) 
1243     fGccuts->dcute=cutValue; 
1244   else if(!strcmp(cutName,"DCUTM")) 
1245     fGccuts->dcutm=cutValue; 
1246   else if(!strcmp(cutName,"PPCUTM")) 
1247     fGccuts->ppcutm=cutValue; 
1248   else if(!strcmp(cutName,"TOFMAX")) 
1249     fGccuts->tofmax=cutValue; 
1250   else Warning("SetCut","Cut %s not implemented\n",cutName);
1251 }
1252
1253 //_____________________________________________________________________________
1254 void    TGeant3::SetProcess(const char* flagName, Int_t flagValue)
1255 {
1256   //
1257   // Set thresholds for different processes
1258   //
1259   if(!strcmp(flagName,"PAIR")) 
1260     fGcphys->ipair=flagValue;
1261   else if(!strcmp(flagName,"COMP")) 
1262     fGcphys->icomp=flagValue;
1263   else if(!strcmp(flagName,"PHOT")) 
1264     fGcphys->iphot=flagValue;
1265   else if(!strcmp(flagName,"PFIS")) 
1266     fGcphys->ipfis=flagValue;
1267   else if(!strcmp(flagName,"DRAY")) 
1268     fGcphys->idray=flagValue;
1269   else if(!strcmp(flagName,"ANNI")) 
1270     fGcphys->ianni=flagValue;
1271   else if(!strcmp(flagName,"BREM")) 
1272     fGcphys->ibrem=flagValue;
1273   else if(!strcmp(flagName,"HADR")) 
1274     fGcphys->ihadr=flagValue;
1275   else if(!strcmp(flagName,"MUNU")) 
1276     fGcphys->imunu=flagValue;
1277   else if(!strcmp(flagName,"DCAY")) 
1278     fGcphys->idcay=flagValue;
1279   else if(!strcmp(flagName,"LOSS")) 
1280     fGcphys->iloss=flagValue;
1281   else if(!strcmp(flagName,"MULS")) 
1282     fGcphys->imuls=flagValue;
1283   else if(!strcmp(flagName,"RAYL")) 
1284     fGcphys->irayl=flagValue;
1285   else if(!strcmp(flagName,"STRA")) 
1286     fGcphlt->istra=flagValue;
1287   else if(!strcmp(flagName,"SYNC")) 
1288     fGcphlt->isync=flagValue;
1289   else  Warning("SetFlag","Flag %s not implemented\n",flagName);
1290 }
1291
1292 //_____________________________________________________________________________
1293 Float_t TGeant3::Xsec(char* reac, Float_t /* energy */, 
1294                       Int_t part, Int_t /* mate */)
1295 {
1296   //
1297   // Calculate X-sections -- dummy for the moment
1298   //
1299   if(!strcmp(reac,"PHOT"))
1300   {
1301     if(part!=22) {
1302       Error("Xsec","Can calculate photoelectric only for photons\n");
1303     }
1304   }
1305   return 0;
1306 }
1307
1308 //_____________________________________________________________________________
1309 void TGeant3::TrackPosition(TLorentzVector &xyz) const
1310 {
1311   //
1312   // Return the current position in the master reference frame of the
1313   // track being transported
1314   //
1315   xyz[0]=fGctrak->vect[0];
1316   xyz[1]=fGctrak->vect[1];
1317   xyz[2]=fGctrak->vect[2];
1318   xyz[3]=fGctrak->tofg;
1319 }
1320
1321 //_____________________________________________________________________________
1322 Float_t TGeant3::TrackTime() const
1323 {
1324   //
1325   // Return the current time of flight of the track being transported
1326   //
1327   return fGctrak->tofg;
1328 }
1329
1330 //_____________________________________________________________________________
1331 void TGeant3::TrackMomentum(TLorentzVector &xyz) const
1332 {
1333   //
1334   // Return the direction and the momentum (GeV/c) of the track
1335   // currently being transported
1336   //
1337   Double_t ptot=fGctrak->vect[6];
1338   xyz[0]=fGctrak->vect[3]*ptot;
1339   xyz[1]=fGctrak->vect[4]*ptot;
1340   xyz[2]=fGctrak->vect[5]*ptot;
1341   xyz[3]=fGctrak->getot;
1342 }
1343
1344 //_____________________________________________________________________________
1345 Float_t TGeant3::TrackCharge() const
1346 {
1347   //
1348   // Return charge of the track currently transported
1349   //
1350   return fGckine->charge;
1351 }
1352
1353 //_____________________________________________________________________________
1354 Float_t TGeant3::TrackMass() const
1355 {
1356   //
1357   // Return the mass of the track currently transported
1358   //
1359   return fGckine->amass;
1360 }
1361
1362 //_____________________________________________________________________________
1363 Int_t TGeant3::TrackPid() const
1364 {
1365   //
1366   // Return the id of the particle transported
1367   //
1368   return PDGFromId(fGckine->ipart);
1369 }
1370
1371 //_____________________________________________________________________________
1372 Float_t TGeant3::TrackStep() const
1373 {
1374   //
1375   // Return the length in centimeters of the current step
1376   //
1377   return fGctrak->step;
1378 }
1379
1380 //_____________________________________________________________________________
1381 Float_t TGeant3::TrackLength() const
1382 {
1383   //
1384   // Return the length of the current track from its origin
1385   //
1386   return fGctrak->sleng;
1387 }
1388
1389 //_____________________________________________________________________________
1390 Bool_t TGeant3::IsNewTrack() const
1391 {
1392   //
1393   // True if the track is not at the boundary of the current volume
1394   //
1395   return (fGctrak->sleng==0);
1396 }
1397
1398 //_____________________________________________________________________________
1399 Bool_t TGeant3::IsTrackInside() const
1400 {
1401   //
1402   // True if the track is not at the boundary of the current volume
1403   //
1404   return (fGctrak->inwvol==0);
1405 }
1406
1407 //_____________________________________________________________________________
1408 Bool_t TGeant3::IsTrackEntering() const
1409 {
1410   //
1411   // True if this is the first step of the track in the current volume
1412   //
1413   return (fGctrak->inwvol==1);
1414 }
1415
1416 //_____________________________________________________________________________
1417 Bool_t TGeant3::IsTrackExiting() const
1418 {
1419   //
1420   // True if this is the last step of the track in the current volume
1421   //
1422   return (fGctrak->inwvol==2);
1423 }
1424
1425 //_____________________________________________________________________________
1426 Bool_t TGeant3::IsTrackOut() const
1427 {
1428   //
1429   // True if the track is out of the setup
1430   //
1431   return (fGctrak->inwvol==3);
1432 }
1433
1434 //_____________________________________________________________________________
1435 Bool_t TGeant3::IsTrackStop() const
1436 {
1437   //
1438   // True if the track energy has fallen below the threshold 
1439   //
1440   return (fGctrak->istop==2);
1441 }
1442
1443 //_____________________________________________________________________________
1444 Int_t   TGeant3::NSecondaries() const
1445 {
1446   //
1447   // Number of secondary particles generated in the current step
1448   //
1449   return fGcking->ngkine;
1450 }
1451
1452 //_____________________________________________________________________________
1453 Int_t   TGeant3::CurrentEvent() const
1454 {
1455   //
1456   // Number of the current event
1457   //
1458   return fGcflag->idevt;
1459 }
1460
1461 //_____________________________________________________________________________
1462 const char* TGeant3::ProdProcess() const
1463 {
1464   //
1465   // Name of the process that has produced the secondary particles
1466   // in the current step
1467   //
1468   static char proc[5];
1469   const Int_t kIpMec[13] = { 5,6,7,8,9,10,11,12,21,23,25,105,108 };
1470   Int_t mec, km, im;
1471   //
1472   if(fGcking->ngkine>0) {
1473     for (km = 0; km < fGctrak->nmec; ++km) {
1474       for (im = 0; im < 13; ++im) {
1475         if (fGctrak->lmec[km] == kIpMec[im]) {
1476           mec = fGctrak->lmec[km];
1477           if (0 < mec && mec < 31) {
1478             strncpy(proc,(char *)&fGctrak->namec[mec - 1],4);
1479           } else if (mec - 100 <= 30 && mec - 100 > 0) {
1480             strncpy(proc,(char *)&fGctpol->namec1[mec - 101],4);
1481           }
1482           proc[4]='\0';
1483           return proc;
1484         }
1485       }
1486     }
1487     strcpy(proc,"UNKN");
1488   } else strcpy(proc,"NONE");
1489   return proc;
1490 }
1491
1492 //_____________________________________________________________________________
1493 void    TGeant3::GetSecondary(Int_t isec, Int_t& ipart, 
1494                               TLorentzVector &x, TLorentzVector &p)
1495 {
1496   //
1497   // Get the parameters of the secondary track number isec produced
1498   // in the current step
1499   //
1500   Int_t i;
1501   if(-1<isec && isec<fGcking->ngkine) {
1502     ipart=Int_t (fGcking->gkin[isec][4] +0.5);
1503     for(i=0;i<3;i++) {
1504       x[i]=fGckin3->gpos[isec][i];
1505       p[i]=fGcking->gkin[isec][i];
1506     }
1507     x[3]=fGcking->tofd[isec];
1508     p[3]=fGcking->gkin[isec][3];
1509   } else {
1510     printf(" * TGeant3::GetSecondary * Secondary %d does not exist\n",isec);
1511     x[0]=x[1]=x[2]=x[3]=p[0]=p[1]=p[2]=p[3]=0;
1512     ipart=0;
1513   }
1514 }
1515
1516 //_____________________________________________________________________________
1517 void TGeant3::InitLego()
1518 {
1519   //
1520   // Set switches for lego transport
1521   //
1522   SetSWIT(4,0);
1523   SetDEBU(0,0,0);  //do not print a message 
1524 }
1525
1526 //_____________________________________________________________________________
1527 Bool_t TGeant3::IsTrackDisappeared() const
1528 {
1529   //
1530   // True if the current particle has disappered
1531   // either because it decayed or because it underwent
1532   // an inelastic collision
1533   //
1534   return (fGctrak->istop==1);
1535 }
1536
1537 //_____________________________________________________________________________
1538 Bool_t TGeant3::IsTrackAlive() const
1539 {
1540   //
1541   // True if the current particle is alive and will continue to be
1542   // transported
1543   //
1544   return (fGctrak->istop==0);
1545 }
1546
1547 //_____________________________________________________________________________
1548 void TGeant3::StopTrack()
1549 {
1550   //
1551   // Stop the transport of the current particle and skip to the next
1552   //
1553   fGctrak->istop=1;
1554 }
1555
1556 //_____________________________________________________________________________
1557 void TGeant3::StopEvent()
1558 {
1559   //
1560   // Stop simulation of the current event and skip to the next
1561   //
1562   fGcflag->ieotri=1;
1563 }
1564
1565 //_____________________________________________________________________________
1566 Float_t TGeant3::MaxStep() const
1567 {
1568   //
1569   // Return the maximum step length in the current medium
1570   //
1571   return fGctmed->stemax;
1572 }
1573
1574 //_____________________________________________________________________________
1575 void TGeant3::SetMaxStep(Float_t maxstep)
1576 {
1577   //
1578   // Set the maximum step allowed till the particle is in the current medium
1579   //
1580   fGctmed->stemax=maxstep;
1581 }
1582
1583 //_____________________________________________________________________________
1584 void TGeant3::SetMaxNStep(Int_t maxnstp)
1585 {
1586   //
1587   // Set the maximum number of steps till the particle is in the current medium
1588   //
1589   fGctrak->maxnst=maxnstp;
1590 }
1591
1592 //_____________________________________________________________________________
1593 Int_t TGeant3::GetMaxNStep() const
1594 {
1595   //
1596   // Maximum number of steps allowed in current medium
1597   //
1598   return fGctrak->maxnst;
1599 }
1600
1601 //_____________________________________________________________________________
1602 void TGeant3::Material(Int_t& kmat, const char* name, Float_t a, Float_t z,
1603                        Float_t dens, Float_t radl, Float_t absl, Float_t* buf,
1604                        Int_t nwbuf)
1605 {
1606   //
1607   // Defines a Material
1608   // 
1609   //  kmat               number assigned to the material
1610   //  name               material name
1611   //  a                  atomic mass in au
1612   //  z                  atomic number
1613   //  dens               density in g/cm3
1614   //  absl               absorbtion length in cm
1615   //                     if >=0 it is ignored and the program 
1616   //                     calculates it, if <0. -absl is taken
1617   //  radl               radiation length in cm
1618   //                     if >=0 it is ignored and the program 
1619   //                     calculates it, if <0. -radl is taken
1620   //  buf                pointer to an array of user words
1621   //  nbuf               number of user words
1622   //
1623   Int_t jmate=fGclink->jmate;
1624   kmat=1;
1625   Int_t ns, i;
1626   if(jmate>0) {
1627     ns=fZiq[jmate-2];
1628     kmat=ns+1;
1629     for(i=1; i<=ns; i++) {
1630       if(fZlq[jmate-i]==0) {
1631         kmat=i;
1632         break;
1633       }
1634     }
1635   }
1636   gsmate(kmat,PASSCHARD(name), a, z, dens, radl, absl, buf,
1637          nwbuf PASSCHARL(name)); 
1638 }
1639
1640 //_____________________________________________________________________________
1641 void TGeant3::Mixture(Int_t& kmat, const char* name, Float_t* a, Float_t* z, 
1642                       Float_t dens, Int_t nlmat, Float_t* wmat)
1643 {
1644   //
1645   // Defines mixture OR COMPOUND IMAT as composed by 
1646   // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
1647   // 
1648   // If NLMAT > 0 then wmat contains the proportion by
1649   // weights of each basic material in the mixture. 
1650   // 
1651   // If nlmat < 0 then WMAT contains the number of atoms 
1652   // of a given kind into the molecule of the COMPOUND
1653   // In this case, WMAT in output is changed to relative
1654   // weigths.
1655   //
1656   Int_t jmate=fGclink->jmate;
1657   kmat=1;
1658   Int_t ns, i;
1659   if(jmate>0) {
1660     ns=fZiq[jmate-2];
1661     kmat=ns+1;
1662     for(i=1; i<=ns; i++) {
1663       if(fZlq[jmate-i]==0) {
1664         kmat=i;
1665         break;
1666       }
1667     }
1668   }
1669   gsmixt(kmat,PASSCHARD(name), a, z,dens, nlmat,wmat PASSCHARL(name)); 
1670 }
1671
1672 //_____________________________________________________________________________
1673 void TGeant3::Medium(Int_t& kmed, const char* name, Int_t nmat, Int_t isvol,
1674                      Int_t ifield, Float_t fieldm, Float_t tmaxfd,
1675                      Float_t stemax, Float_t deemax, Float_t epsil,
1676                      Float_t stmin, Float_t* ubuf, Int_t nbuf)
1677 {
1678   //
1679   //  kmed      tracking medium number assigned
1680   //  name      tracking medium name
1681   //  nmat      material number
1682   //  isvol     sensitive volume flag
1683   //  ifield    magnetic field
1684   //  fieldm    max. field value (kilogauss)
1685   //  tmaxfd    max. angle due to field (deg/step)
1686   //  stemax    max. step allowed
1687   //  deemax    max. fraction of energy lost in a step
1688   //  epsil     tracking precision (cm)
1689   //  stmin     min. step due to continuos processes (cm)
1690   //
1691   //  ifield = 0 if no magnetic field; ifield = -1 if user decision in guswim;
1692   //  ifield = 1 if tracking performed with grkuta; ifield = 2 if tracking
1693   //  performed with ghelix; ifield = 3 if tracking performed with ghelx3.
1694   //  
1695   Int_t jtmed=fGclink->jtmed;
1696   kmed=1;
1697   Int_t ns, i;
1698   if(jtmed>0) {
1699     ns=fZiq[jtmed-2];
1700     kmed=ns+1;
1701     for(i=1; i<=ns; i++) {
1702       if(fZlq[jtmed-i]==0) {
1703         kmed=i;
1704         break;
1705       }
1706     }
1707   }
1708   gstmed(kmed, PASSCHARD(name), nmat, isvol, ifield, fieldm, tmaxfd, stemax,
1709          deemax, epsil, stmin, ubuf, nbuf PASSCHARL(name)); 
1710 }
1711
1712 //_____________________________________________________________________________
1713 void TGeant3::Matrix(Int_t& krot, Float_t thex, Float_t phix, Float_t they,
1714                      Float_t phiy, Float_t thez, Float_t phiz)
1715 {
1716   //
1717   //  krot     rotation matrix number assigned
1718   //  theta1   polar angle for axis i
1719   //  phi1     azimuthal angle for axis i
1720   //  theta2   polar angle for axis ii
1721   //  phi2     azimuthal angle for axis ii
1722   //  theta3   polar angle for axis iii
1723   //  phi3     azimuthal angle for axis iii
1724   //
1725   //  it defines the rotation matrix number irot.
1726   //  
1727   Int_t jrotm=fGclink->jrotm;
1728   krot=1;
1729   Int_t ns, i;
1730   if(jrotm>0) {
1731     ns=fZiq[jrotm-2];
1732     krot=ns+1;
1733     for(i=1; i<=ns; i++) {
1734       if(fZlq[jrotm-i]==0) {
1735         krot=i;
1736         break;
1737       }
1738     }
1739   }
1740   gsrotm(krot, thex, phix, they, phiy, thez, phiz);
1741 }
1742
1743 //_____________________________________________________________________________
1744 Int_t TGeant3::GetMedium() const
1745 {
1746   //
1747   // Return the number of the current medium
1748   //
1749   return fGctmed->numed;
1750 }
1751
1752 //_____________________________________________________________________________
1753 Float_t TGeant3::Edep() const
1754 {
1755   //
1756   // Return the energy lost in the current step
1757   //
1758   return fGctrak->destep;
1759 }
1760
1761 //_____________________________________________________________________________
1762 Float_t TGeant3::Etot() const
1763 {
1764   //
1765   // Return the total energy of the current track
1766   //
1767   return fGctrak->getot;
1768 }
1769
1770 //_____________________________________________________________________________
1771 void TGeant3::Rndm(Float_t* r, const Int_t n) const
1772 {
1773   //
1774   // Return an array of n random numbers uniformly distributed 
1775   // between 0 and 1 not included
1776   //
1777   Grndm(r,n);
1778 }
1779
1780 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1781 //
1782 //                        Functions from GBASE
1783 //
1784 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1785
1786 //____________________________________________________________________________ 
1787 void  TGeant3::Gfile(const char *filename, const char *option) 
1788
1789   //
1790   //    Routine to open a GEANT/RZ data base. 
1791   //
1792   //    LUN logical unit number associated to the file 
1793   //
1794   //    CHFILE RZ file name   
1795   //  
1796   //    CHOPT is a character string which may be  
1797   //        N  To create a new file 
1798   //        U  to open an existing file for update 
1799   //       " " to open an existing file for read only
1800   //        Q  The initial allocation (default 1000 records) 
1801   //           is given in IQUEST(10)
1802   //        X  Open the file in exchange format
1803   //        I  Read all data structures from file to memory 
1804   //        O  Write all data structures from memory to file 
1805   // 
1806   // Note:
1807   //      If options "I"  or "O" all data structures are read or
1808   //         written from/to file and the file is closed. 
1809   //      See routine GRMDIR to create subdirectories  
1810   //      See routines GROUT,GRIN to write,read objects 
1811   //  
1812   grfile(21, PASSCHARD(filename), PASSCHARD(option) PASSCHARL(filename)
1813          PASSCHARL(option)); 
1814
1815  
1816 //____________________________________________________________________________ 
1817 void  TGeant3::Gpcxyz() 
1818
1819   //
1820   //    Print track and volume parameters at current point
1821   //
1822     
1823     gpcxyz(); 
1824
1825 //_____________________________________________________________________________
1826 void  TGeant3::Ggclos() 
1827
1828   //
1829   //   Closes off the geometry setting.
1830   //   Initializes the search list for the contents of each
1831   //   volume following the order they have been positioned, and
1832   //   inserting the content '0' when a call to GSNEXT (-1) has
1833   //   been required by the user.
1834   //   Performs the development of the JVOLUM structure for all 
1835   //   volumes with variable parameters, by calling GGDVLP. 
1836   //   Interprets the user calls to GSORD, through GGORD.
1837   //   Computes and stores in a bank (next to JVOLUM mother bank)
1838   //   the number of levels in the geometrical tree and the
1839   //   maximum number of contents per level, by calling GGNLEV.
1840   //   Sets status bit for CONCAVE volumes, through GGCAVE.
1841   //   Completes the JSET structure with the list of volume names 
1842   //   which identify uniquely a given physical detector, the
1843   //   list of bit numbers to pack the corresponding volume copy 
1844   //   numbers, and the generic path(s) in the JVOLUM tree, 
1845   //   through the routine GHCLOS. 
1846   //
1847   ggclos(); 
1848   // Create internal list of volumes
1849   fVolNames = new char[fGcnum->nvolum+1][5];
1850   Int_t i;
1851   for(i=0; i<fGcnum->nvolum; ++i) {
1852     strncpy(fVolNames[i], (char *) &fZiq[fGclink->jvolum+i+1], 4);
1853     fVolNames[i][4]='\0';
1854   }
1855   strcpy(fVolNames[fGcnum->nvolum],"NULL");
1856
1857  
1858 //_____________________________________________________________________________
1859 void  TGeant3::Glast() 
1860
1861   //
1862   // Finish a Geant run
1863   //
1864   glast(); 
1865
1866  
1867 //_____________________________________________________________________________
1868 void  TGeant3::Gprint(const char *name) 
1869
1870   //
1871   // Routine to print data structures
1872   // CHNAME   name of a data structure
1873   // 
1874   char vname[5];
1875   Vname(name,vname);
1876   gprint(PASSCHARD(vname),0 PASSCHARL(vname)); 
1877
1878
1879 //_____________________________________________________________________________
1880 void  TGeant3::Grun() 
1881
1882   //
1883   // Steering function to process one run
1884   //
1885   grun(); 
1886
1887  
1888 //_____________________________________________________________________________
1889 void  TGeant3::Gtrig() 
1890
1891   //
1892   // Steering function to process one event
1893   //  
1894
1895   fDecayer->ForceDecay(fForceDecay);
1896   gtrig(); 
1897
1898  
1899 //_____________________________________________________________________________
1900 void  TGeant3::Gtrigc() 
1901
1902   //
1903   // Clear event partition
1904   //
1905   gtrigc(); 
1906
1907  
1908 //_____________________________________________________________________________
1909 void  TGeant3::Gtrigi() 
1910
1911   //
1912   // Initialises event partition
1913   //
1914   gtrigi(); 
1915
1916  
1917 //_____________________________________________________________________________
1918 void  TGeant3::Gwork(Int_t nwork) 
1919
1920   //
1921   // Allocates workspace in ZEBRA memory
1922   //
1923   gwork(nwork); 
1924
1925  
1926 //_____________________________________________________________________________
1927 void  TGeant3::Gzinit() 
1928
1929   //
1930   // To initialise GEANT/ZEBRA data structures
1931   //
1932   gzinit(); 
1933
1934  
1935 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1936 //
1937 //                        Functions from GCONS
1938 //
1939 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1940  
1941 //_____________________________________________________________________________
1942 void  TGeant3::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,  
1943                       Float_t &dens, Float_t &radl, Float_t &absl,
1944                       Float_t* ubuf, Int_t& nbuf) 
1945
1946   //
1947   // Return parameters for material IMAT 
1948   //
1949   gfmate(imat, PASSCHARD(name), a, z, dens, radl, absl, ubuf, nbuf
1950          PASSCHARL(name)); 
1951
1952  
1953 //_____________________________________________________________________________
1954 void  TGeant3::Gfpart(Int_t ipart, char *name, Int_t &itrtyp,  
1955                    Float_t &amass, Float_t &charge, Float_t &tlife) 
1956
1957   //
1958   // Return parameters for particle of type IPART
1959   //
1960   Float_t *ubuf=0; 
1961   Int_t   nbuf; 
1962   Int_t igpart = IdFromPDG(ipart);
1963   gfpart(igpart, PASSCHARD(name), itrtyp, amass, charge, tlife, ubuf, nbuf
1964          PASSCHARL(name)); 
1965
1966  
1967 //_____________________________________________________________________________
1968 void  TGeant3::Gftmed(Int_t numed, char *name, Int_t &nmat, Int_t &isvol,  
1969                    Int_t &ifield, Float_t &fieldm, Float_t &tmaxfd, 
1970                     Float_t &stemax, Float_t &deemax, Float_t &epsil, 
1971                     Float_t &stmin, Float_t *ubuf, Int_t *nbuf) 
1972
1973   //
1974   // Return parameters for tracking medium NUMED
1975   //
1976   gftmed(numed, PASSCHARD(name), nmat, isvol, ifield, fieldm, tmaxfd, stemax,  
1977          deemax, epsil, stmin, ubuf, nbuf PASSCHARL(name)); 
1978 }
1979
1980  
1981  void  TGeant3::Gftmat(Int_t imate, Int_t ipart, char *chmeca, Int_t kdim,
1982                       Float_t* tkin, Float_t* value, Float_t* pcut,
1983                       Int_t &ixst)
1984
1985   //
1986   // Return parameters for tracking medium NUMED
1987   //
1988   gftmat(imate, ipart, PASSCHARD(chmeca), kdim,
1989          tkin, value, pcut, ixst PASSCHARL(chmeca));
1990
1991
1992
1993 //_____________________________________________________________________________
1994 Float_t TGeant3::Gbrelm(Float_t z, Float_t t, Float_t bcut)
1995 {
1996   //
1997   // To calculate energy loss due to soft muon BREMSSTRAHLUNG
1998   //
1999   return gbrelm(z,t,bcut);
2000 }
2001
2002 //_____________________________________________________________________________
2003 Float_t TGeant3::Gprelm(Float_t z, Float_t t, Float_t bcut)
2004 {
2005   //
2006   // To calculate DE/DX in GeV*barn/atom for direct pair production by muons
2007   //
2008   return gprelm(z,t,bcut);
2009 }
2010  
2011 //_____________________________________________________________________________
2012 void  TGeant3::Gmate() 
2013
2014   //
2015   // Define standard GEANT materials
2016   //
2017   gmate(); 
2018
2019  
2020 //_____________________________________________________________________________
2021 void  TGeant3::Gpart() 
2022
2023   //
2024   //  Define standard GEANT particles plus selected decay modes
2025   //  and branching ratios.
2026   //
2027   gpart(); 
2028
2029  
2030 //_____________________________________________________________________________
2031 void  TGeant3::Gsdk(Int_t ipart, Float_t *bratio, Int_t *mode) 
2032
2033 //  Defines branching ratios and decay modes for standard
2034 //  GEANT particles.
2035    gsdk(ipart,bratio,mode); 
2036
2037  
2038 //_____________________________________________________________________________
2039 void  TGeant3::Gsmate(Int_t imat, const char *name, Float_t a, Float_t z,  
2040                    Float_t dens, Float_t radl, Float_t absl) 
2041
2042   //
2043   // Defines a Material
2044   // 
2045   //  kmat               number assigned to the material
2046   //  name               material name
2047   //  a                  atomic mass in au
2048   //  z                  atomic number
2049   //  dens               density in g/cm3
2050   //  absl               absorbtion length in cm
2051   //                     if >=0 it is ignored and the program 
2052   //                     calculates it, if <0. -absl is taken
2053   //  radl               radiation length in cm
2054   //                     if >=0 it is ignored and the program 
2055   //                     calculates it, if <0. -radl is taken
2056   //  buf                pointer to an array of user words
2057   //  nbuf               number of user words
2058   //
2059   Float_t *ubuf=0; 
2060   Int_t   nbuf=0; 
2061   gsmate(imat,PASSCHARD(name), a, z, dens, radl, absl, ubuf, nbuf
2062          PASSCHARL(name)); 
2063
2064  
2065 //_____________________________________________________________________________
2066 void  TGeant3::Gsmixt(Int_t imat, const char *name, Float_t *a, Float_t *z,  
2067                    Float_t dens, Int_t nlmat, Float_t *wmat) 
2068
2069   //
2070   //       Defines mixture OR COMPOUND IMAT as composed by 
2071   //       THE BASIC NLMAT materials defined by arrays A,Z and WMAT
2072   // 
2073   //       If NLMAT.GT.0 then WMAT contains the PROPORTION BY
2074   //       WEIGTHS OF EACH BASIC MATERIAL IN THE MIXTURE. 
2075   // 
2076   //       If NLMAT.LT.0 then WMAT contains the number of atoms 
2077   //       of a given kind into the molecule of the COMPOUND
2078   //       In this case, WMAT in output is changed to relative
2079   //       weigths.
2080   //
2081   gsmixt(imat,PASSCHARD(name), a, z,dens, nlmat,wmat PASSCHARL(name)); 
2082
2083  
2084 //_____________________________________________________________________________
2085 void  TGeant3::Gspart(Int_t ipart, const char *name, Int_t itrtyp,  
2086                    Float_t amass, Float_t charge, Float_t tlife) 
2087
2088   //
2089   // Store particle parameters
2090   //
2091   // ipart           particle code
2092   // name            particle name
2093   // itrtyp          transport method (see GEANT manual)
2094   // amass           mass in GeV/c2
2095   // charge          charge in electron units
2096   // tlife           lifetime in seconds
2097   //
2098   Float_t *ubuf=0; 
2099   Int_t   nbuf=0; 
2100   gspart(ipart,PASSCHARD(name), itrtyp, amass, charge, tlife, ubuf, nbuf
2101          PASSCHARL(name)); 
2102
2103  
2104 //_____________________________________________________________________________
2105 void  TGeant3::Gstmed(Int_t numed, const char *name, Int_t nmat, Int_t isvol,  
2106                       Int_t ifield, Float_t fieldm, Float_t tmaxfd,
2107                       Float_t stemax, Float_t deemax, Float_t epsil,
2108                       Float_t stmin) 
2109
2110   //
2111   //  NTMED  Tracking medium number
2112   //  NAME   Tracking medium name
2113   //  NMAT   Material number
2114   //  ISVOL  Sensitive volume flag
2115   //  IFIELD Magnetic field
2116   //  FIELDM Max. field value (Kilogauss)
2117   //  TMAXFD Max. angle due to field (deg/step)
2118   //  STEMAX Max. step allowed
2119   //  DEEMAX Max. fraction of energy lost in a step
2120   //  EPSIL  Tracking precision (cm)
2121   //  STMIN  Min. step due to continuos processes (cm)
2122   //
2123   //  IFIELD = 0 if no magnetic field; IFIELD = -1 if user decision in GUSWIM;
2124   //  IFIELD = 1 if tracking performed with GRKUTA; IFIELD = 2 if tracking
2125   //  performed with GHELIX; IFIELD = 3 if tracking performed with GHELX3.
2126   //  
2127   Float_t *ubuf=0; 
2128   Int_t   nbuf=0; 
2129   gstmed(numed,PASSCHARD(name), nmat, isvol, ifield, fieldm, tmaxfd, stemax,
2130          deemax, epsil, stmin, ubuf, nbuf PASSCHARL(name)); 
2131
2132  
2133 //_____________________________________________________________________________
2134 void  TGeant3::Gsckov(Int_t itmed, Int_t npckov, Float_t *ppckov,
2135                       Float_t *absco, Float_t *effic, Float_t *rindex)
2136
2137   //
2138   //    Stores the tables for UV photon tracking in medium ITMED 
2139   //    Please note that it is the user's responsability to 
2140   //    provide all the coefficients:
2141   //
2142   //
2143   //       ITMED       Tracking medium number
2144   //       NPCKOV      Number of bins of each table
2145   //       PPCKOV      Value of photon momentum (in GeV)
2146   //       ABSCO       Absorbtion coefficients 
2147   //                   dielectric: absorbtion length in cm
2148   //                   metals    : absorbtion fraction (0<=x<=1)
2149   //       EFFIC       Detection efficiency for UV photons 
2150   //       RINDEX      Refraction index (if=0 metal)
2151   //
2152   gsckov(itmed,npckov,ppckov,absco,effic,rindex);
2153 }
2154
2155 //_____________________________________________________________________________
2156 void  TGeant3::Gstpar(Int_t itmed, const char *param, Float_t parval) 
2157
2158   //
2159   //  To change the value of cut  or mechanism "CHPAR"
2160   //      to a new value PARVAL  for tracking medium ITMED
2161   //    The  data   structure  JTMED   contains  the   standard  tracking
2162   //  parameters (CUTS and flags to control the physics processes)  which
2163   //  are used  by default  for all  tracking media.   It is  possible to
2164   //  redefine individually  with GSTPAR  any of  these parameters  for a
2165   //  given tracking medium. 
2166   //  ITMED     tracking medium number 
2167   //  CHPAR     is a character string (variable name) 
2168   //  PARVAL    must be given as a floating point.
2169   //
2170   gstpar(itmed,PASSCHARD(param), parval PASSCHARL(param)); 
2171
2172  
2173 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2174 //
2175 //                        Functions from GCONS
2176 //
2177 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2178  
2179 //_____________________________________________________________________________
2180 void  TGeant3::Gfkine(Int_t itra, Float_t *vert, Float_t *pvert, Int_t &ipart,
2181                       Int_t &nvert) 
2182
2183   //           Storing/Retrieving Vertex and Track parameters
2184   //           ---------------------------------------------- 
2185   //
2186   //  Stores vertex parameters. 
2187   //  VERT      array of (x,y,z) position of the vertex 
2188   //  NTBEAM    beam track number origin of the vertex 
2189   //            =0 if none exists  
2190   //  NTTARG    target track number origin of the vertex
2191   //  UBUF      user array of NUBUF floating point numbers
2192   //  NUBUF       
2193   //  NVTX      new vertex number (=0 in case of error). 
2194   //  Prints vertex parameters.
2195   //  IVTX      for vertex IVTX.
2196   //            (For all vertices if IVTX=0) 
2197   //  Stores long life track parameters.
2198   //  PLAB      components of momentum 
2199   //  IPART     type of particle (see GSPART)
2200   //  NV        vertex number origin of track
2201   //  UBUF      array of NUBUF floating point user parameters 
2202   //  NUBUF
2203   //  NT        track number (if=0 error).
2204   //  Retrieves long life track parameters.
2205   //  ITRA      track number for which parameters are requested
2206   //  VERT      vector origin of the track  
2207   //  PVERT     4 momentum components at the track origin 
2208   //  IPART     particle type (=0 if track ITRA does not exist)
2209   //  NVERT     vertex number origin of the track 
2210   //  UBUF      user words stored in GSKINE. 
2211   //  Prints initial track parameters. 
2212   //  ITRA      for track ITRA 
2213   //            (For all tracks if ITRA=0) 
2214   //
2215   Float_t *ubuf=0; 
2216   Int_t   nbuf; 
2217   gfkine(itra,vert,pvert,ipart,nvert,ubuf,nbuf); 
2218
2219
2220 //_____________________________________________________________________________
2221 void  TGeant3::Gfvert(Int_t nvtx, Float_t *v, Int_t &ntbeam, Int_t &nttarg,
2222                       Float_t &tofg) 
2223
2224   //
2225   //       Retrieves the parameter of a vertex bank
2226   //       Vertex is generated from tracks NTBEAM NTTARG
2227   //       NVTX is the new vertex number 
2228   //
2229   Float_t *ubuf=0; 
2230   Int_t   nbuf; 
2231   gfvert(nvtx,v,ntbeam,nttarg,tofg,ubuf,nbuf); 
2232
2233  
2234 //_____________________________________________________________________________
2235 Int_t TGeant3::Gskine(Float_t *plab, Int_t ipart, Int_t nv, Float_t *buf,
2236                       Int_t nwbuf) 
2237
2238   //
2239   //       Store kinematics of track NT into data structure
2240   //       Track is coming from vertex NV
2241   //
2242   Int_t nt = 0; 
2243   gskine(plab, ipart, nv, buf, nwbuf, nt); 
2244   return nt; 
2245
2246  
2247 //_____________________________________________________________________________
2248 Int_t TGeant3::Gsvert(Float_t *v, Int_t ntbeam, Int_t nttarg, Float_t *ubuf,
2249                       Int_t nwbuf) 
2250
2251   //
2252   //       Creates a new vertex bank 
2253   //       Vertex is generated from tracks NTBEAM NTTARG 
2254   //       NVTX is the new vertex number
2255   //
2256   Int_t nwtx = 0; 
2257   gsvert(v, ntbeam, nttarg, ubuf, nwbuf, nwtx); 
2258   return nwtx; 
2259
2260  
2261 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2262 //
2263 //                        Functions from GPHYS
2264 //
2265 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2266
2267 //_____________________________________________________________________________
2268 void  TGeant3::Gphysi() 
2269
2270   //
2271   //       Initialise material constants for all the physics
2272   //       mechanisms used by GEANT
2273   //
2274   gphysi(); 
2275
2276  
2277 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2278 //
2279 //                        Functions from GTRAK
2280 //
2281 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2282  
2283 //_____________________________________________________________________________
2284 void  TGeant3::Gdebug() 
2285
2286   //
2287   // Debug the current step
2288   //
2289   gdebug(); 
2290
2291  
2292 //_____________________________________________________________________________
2293 void  TGeant3::Gekbin() 
2294
2295   //
2296   //       To find bin number in kinetic energy table
2297   //       stored in ELOW(NEKBIN)
2298   //
2299   gekbin(); 
2300
2301  
2302 //_____________________________________________________________________________
2303 void  TGeant3::Gfinds() 
2304
2305   //
2306   //       Returns the set/volume parameters corresponding to 
2307   //       the current space point in /GCTRAK/
2308   //       and fill common /GCSETS/
2309   // 
2310   //       IHSET  user set identifier 
2311   //       IHDET  user detector identifier 
2312   //       ISET set number in JSET  
2313   //       IDET   detector number in JS=LQ(JSET-ISET) 
2314   //       IDTYPE detector type (1,2)  
2315   //       NUMBV  detector volume numbers (array of length NVNAME)
2316   //       NVNAME number of volume levels
2317   //
2318   gfinds(); 
2319
2320  
2321 //_____________________________________________________________________________
2322 void  TGeant3::Gsking(Int_t igk) 
2323
2324   //
2325   //   Stores in stack JSTAK either the IGKth track of /GCKING/,
2326   //    or the NGKINE tracks when IGK is 0.
2327   //
2328   gsking(igk); 
2329
2330  
2331 //_____________________________________________________________________________
2332 void  TGeant3::Gskpho(Int_t igk) 
2333
2334   //
2335   //  Stores in stack JSTAK either the IGKth Cherenkov photon of  
2336   //  /GCKIN2/, or the NPHOT tracks when IGK is 0.                
2337   //
2338   gskpho(igk); 
2339
2340  
2341 //_____________________________________________________________________________
2342 void  TGeant3::Gsstak(Int_t iflag) 
2343
2344   //
2345   //   Stores in auxiliary stack JSTAK the particle currently 
2346   //    described in common /GCKINE/. 
2347   // 
2348   //   On request, creates also an entry in structure JKINE :
2349   //    IFLAG =
2350   //     0 : No entry in JKINE structure required (user) 
2351   //     1 : New entry in JVERTX / JKINE structures required (user)
2352   //    <0 : New entry in JKINE structure at vertex -IFLAG (user)
2353   //     2 : Entry in JKINE structure exists already (from GTREVE)
2354   //
2355   gsstak(iflag); 
2356
2357  
2358 //_____________________________________________________________________________
2359 void  TGeant3::Gsxyz() 
2360
2361   //
2362   //   Store space point VECT in banks JXYZ 
2363   //
2364   gsxyz(); 
2365
2366  
2367 //_____________________________________________________________________________
2368 void  TGeant3::Gtrack() 
2369
2370   //
2371   //   Controls tracking of current particle 
2372   //
2373   gtrack(); 
2374
2375  
2376 //_____________________________________________________________________________
2377 void  TGeant3::Gtreve() 
2378
2379   //
2380   //   Controls tracking of all particles belonging to the current event
2381   //
2382   gtreve(); 
2383
2384
2385 //_____________________________________________________________________________
2386 void  TGeant3::GtreveRoot() 
2387
2388   //
2389   //   Controls tracking of all particles belonging to the current event
2390   //
2391   gtreveroot(); 
2392
2393
2394 //_____________________________________________________________________________
2395 void  TGeant3::Grndm(Float_t *rvec, const Int_t len) const
2396 {
2397   //
2398   //   To generate a vector RVECV of LEN random numbers 
2399   //   Copy of the CERN Library routine RANECU 
2400   grndm(rvec,len);
2401 }
2402
2403 //_____________________________________________________________________________
2404 void  TGeant3::Grndmq(Int_t &is1, Int_t &is2, const Int_t iseq,
2405                       const Text_t *chopt)
2406 {
2407   //
2408   //  To set/retrieve the seed of the random number generator
2409   //
2410   grndmq(is1,is2,iseq,PASSCHARD(chopt) PASSCHARL(chopt));
2411 }
2412
2413 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2414 //
2415 //                        Functions from GDRAW
2416 //
2417 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2418
2419 //_____________________________________________________________________________
2420 void  TGeant3::Gdxyz(Int_t it)
2421 {
2422   //
2423   // Draw the points stored with Gsxyz relative to track it
2424   //
2425   gdxyz(it);
2426 }
2427
2428 //_____________________________________________________________________________
2429 void  TGeant3::Gdcxyz()
2430 {
2431   //
2432   // Draw the position of the current track
2433   //
2434   gdcxyz();
2435 }
2436
2437 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2438 //
2439 //                        Functions from GGEOM
2440 //
2441 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2442
2443 //_____________________________________________________________________________
2444 void  TGeant3::Gdtom(Float_t *xd, Float_t *xm, Int_t iflag) 
2445
2446   //
2447   //  Computes coordinates XM (Master Reference System
2448   //  knowing the coordinates XD (Detector Ref System)
2449   //  The local reference system can be initialized by
2450   //    - the tracking routines and GDTOM used in GUSTEP
2451   //    - a call to GSCMED(NLEVEL,NAMES,NUMBER)
2452   //        (inverse routine is GMTOD)
2453   // 
2454   //   If IFLAG=1  convert coordinates
2455   //      IFLAG=2  convert direction cosinus
2456   //
2457   gdtom(xd, xm, iflag); 
2458
2459  
2460 //_____________________________________________________________________________
2461 void  TGeant3::Glmoth(const char* iudet, Int_t iunum, Int_t &nlev, Int_t *lvols,
2462                       Int_t *lindx) 
2463
2464   //
2465   //   Loads the top part of the Volume tree in LVOLS (IVO's),
2466   //   LINDX (IN indices) for a given volume defined through
2467   //   its name IUDET and number IUNUM.
2468   // 
2469   //   The routine stores only upto the last level where JVOLUM
2470   //   data structure is developed. If there is no development
2471   //   above the current level, it returns NLEV zero.
2472   Int_t *idum=0; 
2473   glmoth(PASSCHARD(iudet), iunum, nlev, lvols, lindx, idum PASSCHARL(iudet)); 
2474
2475
2476 //_____________________________________________________________________________
2477 void  TGeant3::Gmedia(Float_t *x, Int_t &numed) 
2478
2479   //
2480   //   Finds in which volume/medium the point X is, and updates the
2481   //    common /GCVOLU/ and the structure JGPAR accordingly. 
2482   // 
2483   //   NUMED returns the tracking medium number, or 0 if point is
2484   //         outside the experimental setup.
2485   //
2486   gmedia(x,numed); 
2487
2488  
2489 //_____________________________________________________________________________
2490 void  TGeant3::Gmtod(Float_t *xm, Float_t *xd, Int_t iflag) 
2491
2492   //
2493   //       Computes coordinates XD (in DRS) 
2494   //       from known coordinates XM in MRS 
2495   //       The local reference system can be initialized by
2496   //         - the tracking routines and GMTOD used in GUSTEP
2497   //         - a call to GMEDIA(XM,NUMED)
2498   //         - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER) 
2499   //             (inverse routine is GDTOM) 
2500   //
2501   //        If IFLAG=1  convert coordinates 
2502   //           IFLAG=2  convert direction cosinus
2503   //
2504   gmtod(xm, xd, iflag); 
2505
2506  
2507 //_____________________________________________________________________________
2508 void  TGeant3::Gsdvn(const char *name, const char *mother, Int_t ndiv,
2509                      Int_t iaxis) 
2510
2511   //
2512   // Create a new volume by dividing an existing one
2513   // 
2514   //  NAME   Volume name
2515   //  MOTHER Mother volume name
2516   //  NDIV   Number of divisions
2517   //  IAXIS  Axis value
2518   //
2519   //  X,Y,Z of CAXIS will be translated to 1,2,3 for IAXIS.
2520   //  It divides a previously defined volume.
2521   //  
2522   char vname[5];
2523   Vname(name,vname);
2524   char vmother[5];
2525   Vname(mother,vmother);
2526   gsdvn(PASSCHARD(vname), PASSCHARD(vmother), ndiv, iaxis PASSCHARL(vname)
2527         PASSCHARL(vmother)); 
2528
2529  
2530 //_____________________________________________________________________________
2531 void  TGeant3::Gsdvn2(const char *name, const char *mother, Int_t ndiv,
2532                       Int_t iaxis, Float_t c0i, Int_t numed) 
2533
2534   //
2535   // Create a new volume by dividing an existing one
2536   // 
2537   // Divides mother into ndiv divisions called name
2538   // along axis iaxis starting at coordinate value c0.
2539   // the new volume created will be medium number numed.
2540   //
2541   char vname[5];
2542   Vname(name,vname);
2543   char vmother[5];
2544   Vname(mother,vmother);
2545   gsdvn2(PASSCHARD(vname), PASSCHARD(vmother), ndiv, iaxis, c0i, numed
2546          PASSCHARL(vname) PASSCHARL(vmother)); 
2547
2548  
2549 //_____________________________________________________________________________
2550 void  TGeant3::Gsdvs(const char *name, const char *mother, Float_t step,
2551                      Int_t iaxis, Int_t numed) 
2552
2553   //
2554   // Create a new volume by dividing an existing one
2555   // 
2556   char vname[5];
2557   Vname(name,vname);
2558   char vmother[5];
2559   Vname(mother,vmother);
2560   gsdvs(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, numed
2561         PASSCHARL(vname) PASSCHARL(vmother)); 
2562
2563  
2564 //_____________________________________________________________________________
2565 void  TGeant3::Gsdvs2(const char *name, const char *mother, Float_t step,
2566                       Int_t iaxis, Float_t c0, Int_t numed) 
2567
2568   //
2569   // Create a new volume by dividing an existing one
2570   // 
2571   char vname[5];
2572   Vname(name,vname);
2573   char vmother[5];
2574   Vname(mother,vmother);
2575   gsdvs2(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, c0, numed
2576          PASSCHARL(vname) PASSCHARL(vmother)); 
2577
2578  
2579 //_____________________________________________________________________________
2580 void  TGeant3::Gsdvt(const char *name, const char *mother, Float_t step,
2581                      Int_t iaxis, Int_t numed, Int_t ndvmx) 
2582
2583   //
2584   // Create a new volume by dividing an existing one
2585   // 
2586   //       Divides MOTHER into divisions called NAME along
2587   //       axis IAXIS in steps of STEP. If not exactly divisible 
2588   //       will make as many as possible and will centre them 
2589   //       with respect to the mother. Divisions will have medium 
2590   //       number NUMED. If NUMED is 0, NUMED of MOTHER is taken.
2591   //       NDVMX is the expected maximum number of divisions
2592   //          (If 0, no protection tests are performed) 
2593   //
2594   char vname[5];
2595   Vname(name,vname);
2596   char vmother[5];
2597   Vname(mother,vmother);
2598   gsdvt(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, numed, ndvmx
2599         PASSCHARL(vname) PASSCHARL(vmother)); 
2600
2601
2602 //_____________________________________________________________________________
2603 void  TGeant3::Gsdvt2(const char *name, const char *mother, Float_t step,
2604                       Int_t iaxis, Float_t c0, Int_t numed, Int_t ndvmx) 
2605
2606   //
2607   // Create a new volume by dividing an existing one
2608   //                                                                    
2609   //           Divides MOTHER into divisions called NAME along          
2610   //            axis IAXIS starting at coordinate value C0 with step    
2611   //            size STEP.                                              
2612   //           The new volume created will have medium number NUMED.    
2613   //           If NUMED is 0, NUMED of mother is taken.                 
2614   //           NDVMX is the expected maximum number of divisions        
2615   //             (If 0, no protection tests are performed)              
2616   //
2617   char vname[5];
2618   Vname(name,vname);
2619   char vmother[5];
2620   Vname(mother,vmother);
2621   gsdvt2(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, c0,
2622          numed, ndvmx PASSCHARL(vname) PASSCHARL(vmother)); 
2623
2624
2625 //_____________________________________________________________________________
2626 void  TGeant3::Gsord(const char *name, Int_t iax) 
2627
2628   //
2629   //    Flags volume CHNAME whose contents will have to be ordered 
2630   //    along axis IAX, by setting the search flag to -IAX
2631   //           IAX = 1    X axis 
2632   //           IAX = 2    Y axis 
2633   //           IAX = 3    Z axis 
2634   //           IAX = 4    Rxy (static ordering only  -> GTMEDI)
2635   //           IAX = 14   Rxy (also dynamic ordering -> GTNEXT)
2636   //           IAX = 5    Rxyz (static ordering only -> GTMEDI)
2637   //           IAX = 15   Rxyz (also dynamic ordering -> GTNEXT)
2638   //           IAX = 6    PHI   (PHI=0 => X axis)
2639   //           IAX = 7    THETA (THETA=0 => Z axis)
2640   //
2641   char vname[5];
2642   Vname(name,vname);
2643   gsord(PASSCHARD(vname), iax PASSCHARL(vname)); 
2644
2645  
2646 //_____________________________________________________________________________
2647 void  TGeant3::Gspos(const char *name, Int_t nr, const char *mother, Float_t x,
2648                      Float_t y, Float_t z, Int_t irot, const char *konly) 
2649
2650   //
2651   // Position a volume into an existing one
2652   //
2653   //  NAME   Volume name
2654   //  NUMBER Copy number of the volume
2655   //  MOTHER Mother volume name
2656   //  X      X coord. of the volume in mother ref. sys.
2657   //  Y      Y coord. of the volume in mother ref. sys.
2658   //  Z      Z coord. of the volume in mother ref. sys.
2659   //  IROT   Rotation matrix number w.r.t. mother ref. sys.
2660   //  ONLY   ONLY/MANY flag
2661   //
2662   //  It positions a previously defined volume in the mother.
2663   //  
2664   char vname[5];
2665   Vname(name,vname);
2666   char vmother[5];
2667   Vname(mother,vmother);
2668   gspos(PASSCHARD(vname), nr, PASSCHARD(vmother), x, y, z, irot,
2669         PASSCHARD(konly) PASSCHARL(vname) PASSCHARL(vmother)
2670         PASSCHARL(konly)); 
2671
2672  
2673 //_____________________________________________________________________________
2674 void  TGeant3::Gsposp(const char *name, Int_t nr, const char *mother,  
2675                    Float_t x, Float_t y, Float_t z, Int_t irot,
2676                       const char *konly, Float_t *upar, Int_t np ) 
2677
2678   //
2679   //      Place a copy of generic volume NAME with user number
2680   //      NR inside MOTHER, with its parameters UPAR(1..NP)
2681   //
2682   char vname[5];
2683   Vname(name,vname);
2684   char vmother[5];
2685   Vname(mother,vmother);
2686   gsposp(PASSCHARD(vname), nr, PASSCHARD(vmother), x, y, z, irot,
2687          PASSCHARD(konly), upar, np PASSCHARL(vname) PASSCHARL(vmother)
2688          PASSCHARL(konly)); 
2689
2690  
2691 //_____________________________________________________________________________
2692 void  TGeant3::Gsrotm(Int_t nmat, Float_t theta1, Float_t phi1, Float_t theta2,
2693                       Float_t phi2, Float_t theta3, Float_t phi3) 
2694
2695   //
2696   //  nmat   Rotation matrix number
2697   //  THETA1 Polar angle for axis I
2698   //  PHI1   Azimuthal angle for axis I
2699   //  THETA2 Polar angle for axis II
2700   //  PHI2   Azimuthal angle for axis II
2701   //  THETA3 Polar angle for axis III
2702   //  PHI3   Azimuthal angle for axis III
2703   //
2704   //  It defines the rotation matrix number IROT.
2705   //  
2706   gsrotm(nmat, theta1, phi1, theta2, phi2, theta3, phi3); 
2707
2708  
2709 //_____________________________________________________________________________
2710 void  TGeant3::Gprotm(Int_t nmat) 
2711
2712   //
2713   //    To print rotation matrices structure JROTM
2714   //     nmat     Rotation matrix number
2715   //
2716   gprotm(nmat); 
2717
2718  
2719 //_____________________________________________________________________________
2720 Int_t TGeant3::Gsvolu(const char *name, const char *shape, Int_t nmed,  
2721                       Float_t *upar, Int_t npar) 
2722
2723   //
2724   //  NAME   Volume name
2725   //  SHAPE  Volume type
2726   //  NUMED  Tracking medium number
2727   //  NPAR   Number of shape parameters
2728   //  UPAR   Vector containing shape parameters
2729   //
2730   //  It creates a new volume in the JVOLUM data structure.
2731   //  
2732   Int_t ivolu = 0; 
2733   char vname[5];
2734   Vname(name,vname);
2735   char vshape[5];
2736   Vname(shape,vshape);
2737   gsvolu(PASSCHARD(vname), PASSCHARD(vshape), nmed, upar, npar, ivolu
2738          PASSCHARL(vname) PASSCHARL(vshape)); 
2739   return ivolu; 
2740
2741  
2742 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2743 //
2744 //           T H E    D R A W I N G   P A C K A G E
2745 //           ======================================
2746 //  Drawing functions. These functions allow the visualization in several ways
2747 //  of the volumes defined in the geometrical data structure. It is possible
2748 //  to draw the logical tree of volumes belonging to the detector (DTREE),
2749 //  to show their geometrical specification (DSPEC,DFSPC), to draw them
2750 //  and their cut views (DRAW, DCUT). Moreover, it is possible to execute
2751 //  these commands when the hidden line removal option is activated; in
2752 //  this case, the volumes can be also either translated in the space
2753 //  (SHIFT), or clipped by boolean operation (CVOL). In addition, it is
2754 //  possible to fill the surfaces of the volumes
2755 //  with solid colours when the shading option (SHAD) is activated.
2756 //  Several tools (ZOOM, LENS) have been developed to zoom detailed parts
2757 //  of the detectors or to scan physical events as well.
2758 //  Finally, the command MOVE will allow the rotation, translation and zooming
2759 //  on real time parts of the detectors or tracks and hits of a simulated event.
2760 //  Ray-tracing commands. In case the command (DOPT RAYT ON) is executed,
2761 //  the drawing is performed by the Geant ray-tracing;
2762 //  automatically, the color is assigned according to the tracking medium of each
2763 //  volume and the volumes with a density lower/equal than the air are considered
2764 //  transparent; if the option (USER) is set (ON) (again via the command (DOPT)),
2765 //  the user can set color and visibility for the desired volumes via the command
2766 //  (SATT), as usual, relatively to the attributes (COLO) and (SEEN).
2767 //  The resolution can be set via the command (SATT * FILL VALUE), where (VALUE)
2768 //  is the ratio between the number of pixels drawn and 20 (user coordinates).
2769 //  Parallel view and perspective view are possible (DOPT PROJ PARA/PERS); in the
2770 //  first case, we assume that the first mother volume of the tree is a box with
2771 //  dimensions 10000 X 10000 X 10000 cm and the view point (infinetely far) is
2772 //  5000 cm far from the origin along the Z axis of the user coordinates; in the
2773 //  second case, the distance between the observer and the origin of the world
2774 //  reference system is set in cm by the command (PERSP NAME VALUE); grand-angle
2775 //  or telescopic effects can be achieved changing the scale factors in the command
2776 //  (DRAW). When the final picture does not occupy the full window,
2777 //  mapping the space before tracing can speed up the drawing, but can also
2778 //  produce less precise results; values from 1 to 4 are allowed in the command
2779 //  (DOPT MAPP VALUE), the mapping being more precise for increasing (VALUE); for
2780 //  (VALUE = 0) no mapping is performed (therefore max precision and lowest speed).
2781 //  The command (VALCUT) allows the cutting of the detector by three planes
2782 //  ortogonal to the x,y,z axis. The attribute (LSTY) can be set by the command
2783 //  SATT for any desired volume and can assume values from 0 to 7; it determines
2784 //  the different light processing to be performed for different materials:
2785 //  0 = dark-matt, 1 = bright-matt, 2 = plastic, 3 = ceramic, 4 = rough-metals,
2786 //  5 = shiny-metals, 6 = glass, 7 = mirror. The detector is assumed to be in the
2787 //  dark, the ambient light luminosity is 0.2 for each basic hue (the saturation
2788 //  is 0.9) and the observer is assumed to have a light source (therefore he will
2789 //  produce parallel light in the case of parallel view and point-like-source
2790 //  light in the case of perspective view).
2791 //
2792 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2793
2794 //_____________________________________________________________________________
2795 void TGeant3::Gsatt(const char *name, const char *att, Int_t val)
2796
2797   //
2798   //  NAME   Volume name
2799   //  IOPT   Name of the attribute to be set
2800   //  IVAL   Value to which the attribute is to be set
2801   //
2802   //  name= "*" stands for all the volumes.
2803   //  iopt can be chosen among the following :
2804   //  
2805   //     WORK   0=volume name is inactive for the tracking
2806   //            1=volume name is active for the tracking (default)
2807   //  
2808   //     SEEN   0=volume name is invisible
2809   //            1=volume name is visible (default)
2810   //           -1=volume invisible with all its descendants in the tree
2811   //           -2=volume visible but not its descendants in the tree
2812   //  
2813   //     LSTY   line style 1,2,3,... (default=1)
2814   //            LSTY=7 will produce a very precise approximation for
2815   //            revolution bodies.
2816   //  
2817   //     LWID   line width -7,...,1,2,3,..7 (default=1)
2818   //            LWID<0 will act as abs(LWID) was set for the volume
2819   //            and for all the levels below it. When SHAD is 'ON', LWID
2820   //            represent the linewidth of the scan lines filling the surfaces
2821   //            (whereas the FILL value represent their number). Therefore
2822   //            tuning this parameter will help to obtain the desired
2823   //            quality/performance ratio.
2824   //  
2825   //     COLO   colour code -166,...,1,2,..166 (default=1)
2826   //            n=1=black
2827   //            n=2=red;    n=17+m, m=0,25, increasing luminosity according to 'm';
2828   //            n=3=green;  n=67+m, m=0,25, increasing luminosity according to 'm';
2829   //            n=4=blue;   n=117+m, m=0,25, increasing luminosity according to 'm';
2830   //            n=5=yellow; n=42+m, m=0,25, increasing luminosity according to 'm';
2831   //            n=6=violet; n=142+m, m=0,25, increasing luminosity according to 'm';
2832   //            n=7=lightblue; n=92+m, m=0,25, increasing luminosity according to 'm';
2833   //            colour=n*10+m, m=1,2,...9, will produce the same colour
2834   //            as 'n', but with increasing luminosity according to 'm';
2835   //            COLO<0 will act as if abs(COLO) was set for the volume
2836   //            and for all the levels below it.
2837   //            When for a volume the attribute FILL is > 1 (and the
2838   //            option SHAD is on), the ABS of its colour code must be < 8
2839   //            because an automatic shading of its faces will be
2840   //            performed.
2841   //  
2842   //     FILL  (1992) fill area  -7,...,0,1,...7 (default=0)
2843   //            when option SHAD is "on" the FILL attribute of any
2844   //            volume can be set different from 0 (normal drawing);
2845   //            if it is set to 1, the faces of such volume will be filled
2846   //            with solid colours; if ABS(FILL) is > 1, then a light
2847   //            source is placed along the observer line, and the faces of
2848   //            such volumes will be painted by colours whose luminosity
2849   //            will depend on the amount of light reflected;
2850   //            if ABS(FILL) = 1, then it is possible to use all the 166
2851   //            colours of the colour table, becouse the automatic shading
2852   //            is not performed;
2853   //            for increasing values of FILL the drawing will be performed
2854   //            with higher and higher resolution improving the quality (the
2855   //            number of scan lines used to fill the faces increases with FILL);
2856   //            it is possible to set different values of FILL
2857   //            for different volumes, in order to optimize at the same time
2858   //            the performance and the quality of the picture;
2859   //            FILL<0 will act as if abs(FILL) was set for the volume
2860   //            and for all the levels below it.
2861   //            This kind of drawing can be saved in 'picture files'
2862   //            or in view banks.
2863   //            0=drawing without fill area
2864   //            1=faces filled with solid colours and resolution = 6
2865   //            2=lowest resolution (very fast)
2866   //            3=default resolution
2867   //            4=.................
2868   //            5=.................
2869   //            6=.................
2870   //            7=max resolution
2871   //            Finally, if a coloured background is desired, the FILL
2872   //            attribute for the first volume of the tree must be set
2873   //            equal to -abs(colo), colo being >0 and <166.
2874   //  
2875   //     SET   set number associated to volume name
2876   //     DET   detector number associated to volume name
2877   //     DTYP  detector type (1,2)
2878   //  
2879   InitHIGZ();
2880   char vname[5];
2881   Vname(name,vname);
2882   char vatt[5];
2883   Vname(att,vatt);
2884   gsatt(PASSCHARD(vname), PASSCHARD(vatt), val PASSCHARL(vname)
2885         PASSCHARL(vatt)); 
2886
2887
2888 //_____________________________________________________________________________
2889 void TGeant3::Gfpara(const char *name, Int_t number, Int_t intext, Int_t& npar,
2890                          Int_t& natt, Float_t* par, Float_t* att)
2891 {
2892   //
2893   // Find the parameters of a volume
2894   //
2895   gfpara(PASSCHARD(name), number, intext, npar, natt, par, att
2896          PASSCHARL(name));
2897 }
2898
2899 //_____________________________________________________________________________
2900 void TGeant3::Gckpar(Int_t ish, Int_t npar, Float_t* par)
2901 {
2902   //
2903   // Check the parameters of a shape
2904   //
2905   gckpar(ish,npar,par);
2906 }
2907
2908 //_____________________________________________________________________________
2909 void TGeant3::Gckmat(Int_t itmed, char* natmed)
2910 {
2911   //
2912   // Check the parameters of a tracking medium
2913   //
2914   gckmat(itmed, PASSCHARD(natmed) PASSCHARL(natmed));
2915 }
2916
2917 //_____________________________________________________________________________
2918 void TGeant3::Gdelete(Int_t iview)
2919
2920   //
2921   //  IVIEW  View number
2922   //
2923   //  It deletes a view bank from memory.
2924   //
2925   gdelet(iview);
2926 }
2927  
2928 //_____________________________________________________________________________
2929 void TGeant3::Gdopen(Int_t iview)
2930
2931   //
2932   //  IVIEW  View number
2933   //
2934   //  When a drawing is very complex and requires a long time to be
2935   //  executed, it can be useful to store it in a view bank: after a
2936   //  call to DOPEN and the execution of the drawing (nothing will
2937   //  appear on the screen), and after a necessary call to DCLOSE,
2938   //  the contents of the bank can be displayed in a very fast way
2939   //  through a call to DSHOW; therefore, the detector can be easily
2940   //  zoomed many times in different ways. Please note that the pictures
2941   //  with solid colours can now be stored in a view bank or in 'PICTURE FILES'
2942   //
2943   InitHIGZ();
2944   gHigz->Clear();
2945   gdopen(iview);
2946 }
2947  
2948 //_____________________________________________________________________________
2949 void TGeant3::Gdclose()
2950
2951   //
2952   //  It closes the currently open view bank; it must be called after the
2953   //  end of the drawing to be stored.
2954   //
2955   gdclos();
2956 }
2957  
2958 //_____________________________________________________________________________
2959 void TGeant3::Gdshow(Int_t iview)
2960
2961   //
2962   //  IVIEW  View number
2963   //
2964   //  It shows on the screen the contents of a view bank. It
2965   //  can be called after a view bank has been closed.
2966   //
2967   gdshow(iview);
2968
2969
2970 //_____________________________________________________________________________
2971 void TGeant3::Gdopt(const char *name,const char *value)
2972
2973   //
2974   //  NAME   Option name
2975   //  VALUE  Option value
2976   //
2977   //  To set/modify the drawing options.
2978   //     IOPT   IVAL      Action
2979   //  
2980   //     THRZ    ON       Draw tracks in R vs Z
2981   //             OFF (D)  Draw tracks in X,Y,Z
2982   //             180
2983   //             360
2984   //     PROJ    PARA (D) Parallel projection
2985   //             PERS     Perspective
2986   //     TRAK    LINE (D) Trajectory drawn with lines
2987   //             POIN       " " with markers
2988   //     HIDE    ON       Hidden line removal using the CG package
2989   //             OFF (D)  No hidden line removal
2990   //     SHAD    ON       Fill area and shading of surfaces.
2991   //             OFF (D)  Normal hidden line removal.
2992   //     RAYT    ON       Ray-tracing on.
2993   //             OFF (D)  Ray-tracing off.
2994   //     EDGE    OFF      Does not draw contours when shad is on.
2995   //             ON  (D)  Normal shading.
2996   //     MAPP    1,2,3,4  Mapping before ray-tracing.
2997   //             0   (D)  No mapping.
2998   //     USER    ON       User graphics options in the raytracing.
2999   //             OFF (D)  Automatic graphics options.
3000   //  
3001   InitHIGZ();
3002   char vname[5];
3003   Vname(name,vname);
3004   char vvalue[5];
3005   Vname(value,vvalue);
3006   gdopt(PASSCHARD(vname), PASSCHARD(vvalue) PASSCHARL(vname)
3007         PASSCHARL(vvalue)); 
3008
3009  
3010 //_____________________________________________________________________________
3011 void TGeant3::Gdraw(const char *name,Float_t theta, Float_t phi, Float_t psi,
3012                     Float_t u0,Float_t v0,Float_t ul,Float_t vl)
3013
3014   //
3015   //  NAME   Volume name
3016   //  +
3017   //  THETA  Viewing angle theta (for 3D projection)
3018   //  PHI    Viewing angle phi (for 3D projection)
3019   //  PSI    Viewing angle psi (for 2D rotation)
3020   //  U0     U-coord. (horizontal) of volume origin
3021   //  V0     V-coord. (vertical) of volume origin
3022   //  SU     Scale factor for U-coord.
3023   //  SV     Scale factor for V-coord.
3024   //
3025   //  This function will draw the volumes,
3026   //  selected with their graphical attributes, set by the Gsatt
3027   //  facility. The drawing may be performed with hidden line removal
3028   //  and with shading effects according to the value of the options HIDE
3029   //  and SHAD; if the option SHAD is ON, the contour's edges can be
3030   //  drawn or not. If the option HIDE is ON, the detector can be
3031   //  exploded (BOMB), clipped with different shapes (CVOL), and some
3032   //  of its parts can be shifted from their original
3033   //  position (SHIFT). When HIDE is ON, if
3034   //  the drawing requires more than the available memory, the program
3035   //  will evaluate and display the number of missing words
3036   //  (so that the user can increase the
3037   //  size of its ZEBRA store). Finally, at the end of each drawing (with HIDE on),
3038   //  the program will print messages about the memory used and
3039   //  statistics on the volumes' visibility.
3040   //  The following commands will produce the drawing of a green
3041   //  volume, specified by NAME, without using the hidden line removal
3042   //  technique, using the hidden line removal technique,
3043   //  with different linewidth and colour (red), with
3044   //  solid colour, with shading of surfaces, and without edges.
3045   //  Finally, some examples are given for the ray-tracing. (A possible
3046   //  string for the NAME of the volume can be found using the command DTREE).
3047   //
3048   InitHIGZ();
3049   gHigz->Clear();
3050   char vname[5];
3051   Vname(name,vname);
3052   if (fGcvdma->raytra != 1) {
3053     gdraw(PASSCHARD(vname), theta,phi,psi,u0,v0,ul,vl PASSCHARL(vname)); 
3054   } else {
3055     gdrayt(PASSCHARD(vname), theta,phi,psi,u0,v0,ul,vl PASSCHARL(vname)); 
3056   }
3057
3058  
3059 //_____________________________________________________________________________
3060 void TGeant3::Gdrawc(const char *name,Int_t axis, Float_t cut,Float_t u0,
3061                      Float_t v0,Float_t ul,Float_t vl)
3062
3063   //
3064   //  NAME   Volume name
3065   //  CAXIS  Axis value
3066   //  CUTVAL Cut plane distance from the origin along the axis
3067   //  +
3068   //  U0     U-coord. (horizontal) of volume origin
3069   //  V0     V-coord. (vertical) of volume origin
3070   //  SU     Scale factor for U-coord.
3071   //  SV     Scale factor for V-coord.
3072   //
3073   //  The cut plane is normal to caxis (X,Y,Z), corresponding to iaxis (1,2,3),
3074   //  and placed at the distance cutval from the origin.
3075   //  The resulting picture is seen from the the same axis.
3076   //  When HIDE Mode is ON, it is possible to get the same effect with
3077   //  the CVOL/BOX function.
3078   //  
3079   InitHIGZ();
3080   gHigz->Clear();
3081   char vname[5];
3082   Vname(name,vname);
3083   gdrawc(PASSCHARD(vname), axis,cut,u0,v0,ul,vl PASSCHARL(vname)); 
3084
3085  
3086 //_____________________________________________________________________________
3087 void TGeant3::Gdrawx(const char *name,Float_t cutthe, Float_t cutphi,
3088                      Float_t cutval, Float_t theta, Float_t phi, Float_t u0,
3089                      Float_t v0,Float_t ul,Float_t vl)
3090
3091   //
3092   //  NAME   Volume name
3093   //  CUTTHE Theta angle of the line normal to cut plane
3094   //  CUTPHI Phi angle of the line normal to cut plane
3095   //  CUTVAL Cut plane distance from the origin along the axis
3096   //  +
3097   //  THETA  Viewing angle theta (for 3D projection)
3098   //  PHI    Viewing angle phi (for 3D projection)
3099   //  U0     U-coord. (horizontal) of volume origin
3100   //  V0     V-coord. (vertical) of volume origin
3101   //  SU     Scale factor for U-coord.
3102   //  SV     Scale factor for V-coord.
3103   //
3104   //  The cut plane is normal to the line given by the cut angles
3105   //  cutthe and cutphi and placed at the distance cutval from the origin.
3106   //  The resulting picture is seen from the viewing angles theta,phi.
3107   //
3108   InitHIGZ();
3109   gHigz->Clear();
3110   char vname[5];
3111   Vname(name,vname);
3112   gdrawx(PASSCHARD(vname), cutthe,cutphi,cutval,theta,phi,u0,v0,ul,vl
3113          PASSCHARL(vname)); 
3114 }
3115  
3116 //_____________________________________________________________________________
3117 void TGeant3::Gdhead(Int_t isel, const char *name, Float_t chrsiz)
3118
3119   //
3120   //  Parameters
3121   //  +
3122   //  ISEL   Option flag  D=111110
3123   //  NAME   Title
3124   //  CHRSIZ Character size (cm) of title NAME D=0.6
3125   //
3126   //  ISEL =
3127   //   0      to have only the header lines
3128   //   xxxxx1 to add the text name centered on top of header
3129   //   xxxx1x to add global detector name (first volume) on left
3130   //   xxx1xx to add date on right
3131   //   xx1xxx to select thick characters for text on top of header
3132   //   x1xxxx to add the text 'EVENT NR x' on top of header
3133   //   1xxxxx to add the text 'RUN NR x' on top of header
3134   //  NOTE that ISEL=x1xxx1 or ISEL=1xxxx1 are illegal choices,
3135   //  i.e. they generate overwritten text.
3136   //
3137   gdhead(isel,PASSCHARD(name),chrsiz PASSCHARL(name));
3138 }
3139
3140 //_____________________________________________________________________________
3141 void TGeant3::Gdman(Float_t u, Float_t v, const char *type)
3142
3143   //
3144   //  Draw a 2D-man at position (U0,V0)
3145   //  Parameters
3146   //  U      U-coord. (horizontal) of the centre of man' R
3147   //  V      V-coord. (vertical) of the centre of man' R
3148   //  TYPE   D='MAN' possible values: 'MAN,WM1,WM2,WM3'
3149   // 
3150   //   CALL GDMAN(u,v),CALL GDWMN1(u,v),CALL GDWMN2(u,v),CALL GDWMN2(u,v)
3151   //  It superimposes the picure of a man or of a woman, chosen among
3152   //  three different ones, with the same scale factors as the detector
3153   //  in the current drawing.
3154   //
3155   TString opt = type;
3156    if (opt.Contains("WM1")) {
3157      gdwmn1(u,v);
3158    } else if (opt.Contains("WM3")) {
3159      gdwmn3(u,v);
3160    } else if (opt.Contains("WM2")) {
3161      gdwmn2(u,v);
3162    } else {
3163      gdman(u,v);
3164    }
3165 }
3166  
3167 //_____________________________________________________________________________
3168 void TGeant3::Gdspec(const char *name)
3169
3170   //
3171   //  NAME   Volume name
3172   //
3173   //  Shows 3 views of the volume (two cut-views and a 3D view), together with
3174   //  its geometrical specifications. The 3D drawing will
3175   //  be performed according the current values of the options HIDE and
3176   //  SHAD and according the current SetClipBox clipping parameters for that
3177   //  volume.
3178   //  
3179   InitHIGZ();
3180   gHigz->Clear();
3181   char vname[5];
3182   Vname(name,vname);
3183   gdspec(PASSCHARD(vname) PASSCHARL(vname)); 
3184
3185  
3186 //_____________________________________________________________________________
3187 void TGeant3::DrawOneSpec(const char *name)
3188
3189   //
3190   //  Function called when one double-clicks on a volume name
3191   //  in a TPavelabel drawn by Gdtree.
3192   //
3193   THIGZ *higzSave = gHigz;
3194   higzSave->SetName("higzSave");
3195   THIGZ *higzSpec = (THIGZ*)gROOT->FindObject("higzSpec");
3196   //printf("DrawOneSpec, gHigz=%x, higzSpec=%x\n",gHigz,higzSpec);
3197   if (higzSpec) gHigz     = higzSpec;
3198   else          higzSpec = new THIGZ(kDefSize);
3199   higzSpec->SetName("higzSpec");
3200   higzSpec->cd();
3201   higzSpec->Clear();
3202   char vname[5];
3203   Vname(name,vname);
3204   gdspec(PASSCHARD(vname) PASSCHARL(vname)); 
3205   higzSpec->Update();
3206   higzSave->cd();
3207   higzSave->SetName("higz");
3208   gHigz = higzSave;
3209
3210
3211 //_____________________________________________________________________________
3212 void TGeant3::Gdtree(const char *name,Int_t levmax, Int_t isel)
3213
3214   //
3215   //  NAME   Volume name
3216   //  LEVMAX Depth level
3217   //  ISELT  Options
3218   //
3219   //  This function draws the logical tree,
3220   //  Each volume in the tree is represented by a TPaveTree object.
3221   //  Double-clicking on a TPaveTree draws the specs of the corresponding volume.
3222   //  Use TPaveTree pop-up menu to select:
3223   //    - drawing specs
3224   //    - drawing tree
3225   //    - drawing tree of parent
3226   //  
3227   InitHIGZ();
3228   gHigz->Clear();
3229   char vname[5];
3230   Vname(name,vname);
3231   gdtree(PASSCHARD(vname), levmax, isel PASSCHARL(vname)); 
3232   gHigz->SetPname("");
3233
3234
3235 //_____________________________________________________________________________
3236 void TGeant3::GdtreeParent(const char *name,Int_t levmax, Int_t isel)
3237
3238   //
3239   //  NAME   Volume name
3240   //  LEVMAX Depth level
3241   //  ISELT  Options
3242   //
3243   //  This function draws the logical tree of the parent of name.
3244   //  
3245   InitHIGZ();
3246   gHigz->Clear();
3247   // Scan list of volumes in JVOLUM
3248   char vname[5];
3249   Int_t gname, i, jvo, in, nin, jin, num;
3250   strncpy((char *) &gname, name, 4);
3251   for(i=1; i<=fGcnum->nvolum; i++) {
3252     jvo = fZlq[fGclink->jvolum-i];
3253     nin = Int_t(fZq[jvo+3]);
3254     if (nin == -1) nin = 1;
3255     for (in=1;in<=nin;in++) {
3256       jin = fZlq[jvo-in];
3257       num = Int_t(fZq[jin+2]);
3258       if(gname == fZiq[fGclink->jvolum+num]) {
3259         strncpy(vname,(char*)&fZiq[fGclink->jvolum+i],4);
3260         vname[4] = 0;           
3261         gdtree(PASSCHARD(vname), levmax, isel PASSCHARL(vname)); 
3262         gHigz->SetPname("");
3263         return;
3264       }
3265     }
3266   }
3267
3268  
3269 //_____________________________________________________________________________
3270 void TGeant3::SetABAN(Int_t par)
3271 {
3272   //
3273   // par = 1 particles will be stopped according to their residual
3274   //         range if they are not in a sensitive material and are
3275   //         far enough from the boundary
3276   //       0 particles are transported normally
3277   //
3278   fGcphys->dphys1 = par;
3279 }
3280  
3281  
3282 //_____________________________________________________________________________
3283 void TGeant3::SetANNI(Int_t par)
3284 {
3285   //
3286   //   To control positron annihilation.
3287   //    par =0 no annihilation
3288   //        =1 annihilation. Decays processed.
3289   //        =2 annihilation. No decay products stored.
3290   //
3291   fGcphys->ianni = par;
3292 }
3293  
3294  
3295 //_____________________________________________________________________________
3296 void TGeant3::SetAUTO(Int_t par)
3297 {
3298   //
3299   //  To control automatic calculation of tracking medium parameters:
3300   //   par =0 no automatic calculation;
3301   //       =1 automati calculation.
3302   //  
3303   fGctrak->igauto = par;
3304 }
3305  
3306  
3307 //_____________________________________________________________________________
3308 void TGeant3::SetBOMB(Float_t boom)
3309 {
3310   //
3311   //  BOOM  : Exploding factor for volumes position 
3312   // 
3313   //  To 'explode' the detector. If BOOM is positive (values smaller
3314   //  than 1. are suggested, but any value is possible)
3315   //  all the volumes are shifted by a distance
3316   //  proportional to BOOM along the direction between their centre
3317   //  and the origin of the MARS; the volumes which are symmetric
3318   //  with respect to this origin are simply not shown.
3319   //  BOOM equal to 0 resets the normal mode.
3320   //  A negative (greater than -1.) value of
3321   //  BOOM will cause an 'implosion'; for even lower values of BOOM
3322   //  the volumes' positions will be reflected respect to the origin.
3323   //  This command can be useful to improve the 3D effect for very
3324   //  complex detectors. The following commands will make explode the
3325   //  detector:
3326   //
3327   InitHIGZ();
3328   setbomb(boom);
3329 }
3330  
3331 //_____________________________________________________________________________
3332 void TGeant3::SetBREM(Int_t par)
3333 {
3334   //
3335   //  To control bremstrahlung.
3336   //   par =0 no bremstrahlung
3337   //       =1 bremstrahlung. Photon processed.
3338   //       =2 bremstrahlung. No photon stored.
3339   //  
3340   fGcphys->ibrem = par;
3341 }
3342  
3343  
3344 //_____________________________________________________________________________
3345 void TGeant3::SetCKOV(Int_t par)
3346 {
3347   //
3348   //  To control Cerenkov production
3349   //   par =0 no Cerenkov;
3350   //       =1 Cerenkov;
3351   //       =2 Cerenkov with primary stopped at each step.
3352   //  
3353   fGctlit->itckov = par;
3354 }
3355  
3356  
3357 //_____________________________________________________________________________
3358 void  TGeant3::SetClipBox(const char *name,Float_t xmin,Float_t xmax,
3359                           Float_t ymin,Float_t ymax,Float_t zmin,Float_t zmax)
3360 {
3361   //
3362   //  The hidden line removal technique is necessary to visualize properly
3363   //  very complex detectors. At the same time, it can be useful to visualize
3364   //  the inner elements of a detector in detail. This function allows
3365   //  subtractions (via boolean operation) of BOX shape from any part of
3366   //  the detector, therefore showing its inner contents.
3367   //  If "*" is given as the name of the
3368   //  volume to be clipped, all volumes are clipped by the given box.
3369   //  A volume can be clipped at most twice.
3370   //  if a volume is explicitely clipped twice,
3371   //  the "*" will not act on it anymore. Giving "." as the name
3372   //  of the volume to be clipped will reset the clipping.
3373   //  Parameters
3374   //  NAME   Name of volume to be clipped 
3375   //  +
3376   //  XMIN   Lower limit of the Shape X coordinate
3377   //  XMAX   Upper limit of the Shape X coordinate
3378   //  YMIN   Lower limit of the Shape Y coordinate
3379   //  YMAX   Upper limit of the Shape Y coordinate
3380   //  ZMIN   Lower limit of the Shape Z coordinate
3381   //  ZMAX   Upper limit of the Shape Z coordinate
3382   //
3383   //  This function performs a boolean subtraction between the volume
3384   //  NAME and a box placed in the MARS according the values of the given
3385   //  coordinates.
3386   
3387   InitHIGZ();
3388   char vname[5];
3389   Vname(name,vname);
3390   setclip(PASSCHARD(vname),xmin,xmax,ymin,ymax,zmin,zmax PASSCHARL(vname));   
3391
3392
3393 //_____________________________________________________________________________
3394 void TGeant3::SetCOMP(Int_t par)
3395 {
3396   //
3397   //  To control Compton scattering
3398   //   par =0 no Compton
3399   //       =1 Compton. Electron processed.
3400   //       =2 Compton. No electron stored.
3401   //  
3402   //
3403   fGcphys->icomp = par;
3404 }
3405   
3406 //_____________________________________________________________________________
3407 void TGeant3::SetCUTS(Float_t cutgam,Float_t cutele,Float_t cutneu,
3408                       Float_t cuthad,Float_t cutmuo ,Float_t bcute ,
3409                       Float_t bcutm ,Float_t dcute ,Float_t dcutm ,
3410                       Float_t ppcutm, Float_t tofmax)
3411 {
3412   //
3413   //  CUTGAM   Cut for gammas              D=0.001
3414   //  CUTELE   Cut for electrons           D=0.001
3415   //  CUTHAD   Cut for charged hadrons     D=0.01
3416   //  CUTNEU   Cut for neutral hadrons     D=0.01
3417   //  CUTMUO   Cut for muons               D=0.01
3418   //  BCUTE    Cut for electron brems.     D=-1.
3419   //  BCUTM    Cut for muon brems.         D=-1.
3420   //  DCUTE    Cut for electron delta-rays D=-1.
3421   //  DCUTM    Cut for muon delta-rays     D=-1.
3422   //  PPCUTM   Cut for e+e- pairs by muons D=0.01
3423   //  TOFMAX   Time of flight cut          D=1.E+10
3424   //
3425   //   If the default values (-1.) for       BCUTE ,BCUTM ,DCUTE ,DCUTM
3426   //   are not modified, they will be set to CUTGAM,CUTGAM,CUTELE,CUTELE
3427   //   respectively.
3428   //  If one of the parameters from CUTGAM to PPCUTM included
3429   //  is modified, cross-sections and energy loss tables must be
3430   //  recomputed via the function Gphysi.
3431   //
3432   fGccuts->cutgam = cutgam;
3433   fGccuts->cutele = cutele;
3434   fGccuts->cutneu = cutneu;
3435   fGccuts->cuthad = cuthad;
3436   fGccuts->cutmuo = cutmuo;
3437   fGccuts->bcute  = bcute;
3438   fGccuts->bcutm  = bcutm;
3439   fGccuts->dcute  = dcute;
3440   fGccuts->dcutm  = dcutm;
3441   fGccuts->ppcutm = ppcutm;
3442   fGccuts->tofmax = tofmax;   
3443 }
3444
3445 //_____________________________________________________________________________
3446 void TGeant3::SetDCAY(Int_t par)
3447 {
3448   //
3449   //  To control Decay mechanism.
3450   //   par =0 no decays.
3451   //       =1 Decays. secondaries processed.
3452   //       =2 Decays. No secondaries stored.
3453   //  
3454   fGcphys->idcay = par;
3455 }
3456  
3457  
3458 //_____________________________________________________________________________
3459 void TGeant3::SetDEBU(Int_t emin, Int_t emax, Int_t emod)
3460 {
3461   //
3462   // Set the debug flag and frequency
3463   // Selected debug output will be printed from
3464   // event emin to even emax each emod event
3465   //
3466   fGcflag->idemin = emin;
3467   fGcflag->idemax = emax;
3468   fGcflag->itest  = emod;
3469 }
3470  
3471  
3472 //_____________________________________________________________________________
3473 void TGeant3::SetDRAY(Int_t par)
3474 {
3475   //
3476   //  To control delta rays mechanism.
3477   //   par =0 no delta rays.
3478   //       =1 Delta rays. secondaries processed.
3479   //       =2 Delta rays. No secondaries stored.
3480   //  
3481   fGcphys->idray = par;
3482 }
3483  
3484 //_____________________________________________________________________________
3485 void TGeant3::SetERAN(Float_t ekmin, Float_t ekmax, Int_t nekbin)
3486 {
3487   //
3488   //  To control cross section tabulations
3489   //   ekmin = minimum kinetic energy in GeV
3490   //   ekmax = maximum kinetic energy in GeV
3491   //   nekbin = number of logatithmic bins (<200)
3492   //  
3493   fGcmulo->ekmin = ekmin;
3494   fGcmulo->ekmax = ekmax;
3495   fGcmulo->nekbin = nekbin;
3496 }
3497  
3498 //_____________________________________________________________________________
3499 void TGeant3::SetHADR(Int_t par)
3500 {
3501   //
3502   //  To control hadronic interactions.
3503   //   par =0 no hadronic interactions.
3504   //       =1 Hadronic interactions. secondaries processed.
3505   //       =2 Hadronic interactions. No secondaries stored.
3506   //  
3507   fGcphys->ihadr = par;
3508 }
3509  
3510 //_____________________________________________________________________________
3511 void TGeant3::SetKINE(Int_t kine, Float_t xk1, Float_t xk2, Float_t xk3,
3512                       Float_t xk4, Float_t xk5, Float_t xk6, Float_t xk7,
3513                       Float_t xk8, Float_t xk9, Float_t xk10)
3514 {
3515   //
3516   // Set the variables in /GCFLAG/ IKINE, PKINE(10)
3517   // Their meaning is user defined
3518   //
3519   fGckine->ikine    = kine;
3520   fGckine->pkine[0] = xk1;
3521   fGckine->pkine[1] = xk2;
3522   fGckine->pkine[2] = xk3;
3523   fGckine->pkine[3] = xk4;
3524   fGckine->pkine[4] = xk5;
3525   fGckine->pkine[5] = xk6;
3526   fGckine->pkine[6] = xk7;
3527   fGckine->pkine[7] = xk8;
3528   fGckine->pkine[8] = xk9;
3529   fGckine->pkine[9] = xk10;
3530 }
3531  
3532 //_____________________________________________________________________________
3533 void TGeant3::SetLOSS(Int_t par)
3534 {
3535   //
3536   //  To control energy loss.
3537   //   par =0 no energy loss;
3538   //       =1 restricted energy loss fluctuations;
3539   //       =2 complete energy loss fluctuations;
3540   //       =3 same as 1;
3541   //       =4 no energy loss fluctuations.
3542   //  If the value ILOSS is changed, then cross-sections and energy loss
3543   //  tables must be recomputed via the command 'PHYSI'.
3544   //  
3545   fGcphys->iloss = par;
3546 }
3547  
3548  
3549 //_____________________________________________________________________________
3550 void TGeant3::SetMULS(Int_t par)
3551 {
3552   //
3553   //  To control multiple scattering.
3554   //   par =0 no multiple scattering.
3555   //       =1 Moliere or Coulomb scattering.
3556   //       =2 Moliere or Coulomb scattering.
3557   //       =3 Gaussian scattering.
3558   //  
3559   fGcphys->imuls = par;
3560 }
3561  
3562  
3563 //_____________________________________________________________________________
3564 void TGeant3::SetMUNU(Int_t par)
3565 {
3566   //
3567   //  To control muon nuclear interactions.
3568   //   par =0 no muon-nuclear interactions.
3569   //       =1 Nuclear interactions. Secondaries processed.
3570   //       =2 Nuclear interactions. Secondaries not processed.
3571   //  
3572   fGcphys->imunu = par;
3573 }
3574  
3575 //_____________________________________________________________________________
3576 void TGeant3::SetOPTI(Int_t par)
3577 {
3578   //
3579   //  This flag controls the tracking optimisation performed via the
3580   //  GSORD routine:
3581   //      1 no optimisation at all; GSORD calls disabled;
3582   //      0 no optimisation; only user calls to GSORD kept;
3583   //      1 all non-GSORDered volumes are ordered along the best axis;
3584   //      2 all volumes are ordered along the best axis.
3585   //  
3586   fGcopti->ioptim = par;
3587 }
3588  
3589 //_____________________________________________________________________________
3590 void TGeant3::SetPAIR(Int_t par)
3591 {
3592   //
3593   //  To control pair production mechanism.
3594   //   par =0 no pair production.
3595   //       =1 Pair production. secondaries processed.
3596   //       =2 Pair production. No secondaries stored.
3597   //  
3598   fGcphys->ipair = par;
3599 }
3600  
3601  
3602 //_____________________________________________________________________________
3603 void TGeant3::SetPFIS(Int_t par)
3604 {
3605   //
3606   //  To control photo fission mechanism.
3607   //   par =0 no photo fission.
3608   //       =1 Photo fission. secondaries processed.
3609   //       =2 Photo fission. No secondaries stored.
3610   //  
3611   fGcphys->ipfis = par;
3612 }
3613   
3614 //_____________________________________________________________________________
3615 void TGeant3::SetPHOT(Int_t par)
3616 {
3617   //
3618   //  To control Photo effect.
3619   //   par =0 no photo electric effect.
3620   //       =1 Photo effect. Electron processed.
3621   //       =2 Photo effect. No electron stored.
3622   //  
3623   fGcphys->iphot = par;
3624 }
3625  
3626 //_____________________________________________________________________________
3627 void TGeant3::SetRAYL(Int_t par)
3628 {
3629   //
3630   //  To control Rayleigh scattering.
3631   //   par =0 no Rayleigh scattering.
3632   //       =1 Rayleigh.
3633   //  
3634   fGcphys->irayl = par;
3635 }
3636  
3637 //_____________________________________________________________________________
3638 void TGeant3::SetSTRA(Int_t par)
3639 {
3640   //
3641   //  To control energy loss fluctuations
3642   //  with the PhotoAbsorption Ionisation model.
3643   //   par =0 no Straggling.
3644   //       =1 Straggling yes => no Delta rays.
3645   //  
3646   fGcphlt->istra = par;
3647 }
3648  
3649 //_____________________________________________________________________________
3650 void TGeant3::SetSWIT(Int_t sw, Int_t val)
3651 {
3652   //
3653   //  sw    Switch number
3654   //  val   New switch value
3655   //
3656   //  Change one element of array ISWIT(10) in /GCFLAG/
3657   //  
3658   if (sw <= 0 || sw > 10) return;
3659   fGcflag->iswit[sw-1] = val;
3660 }
3661  
3662  
3663 //_____________________________________________________________________________
3664 void TGeant3::SetTRIG(Int_t nevents)
3665 {
3666   //
3667   // Set number of events to be run
3668   //
3669   fGcflag->nevent = nevents;
3670 }
3671  
3672 //_____________________________________________________________________________
3673 void TGeant3::SetUserDecay(Int_t pdg)
3674 {
3675   //
3676   // Force the decays of particles to be done with Pythia
3677   // and not with the Geant routines. 
3678   // just kill pointers doing mzdrop
3679   //
3680   Int_t ipart = IdFromPDG(pdg);
3681   if(ipart<0) {
3682     printf("Particle %d not in geant\n",pdg);
3683     return;
3684   }
3685   Int_t jpart=fGclink->jpart;
3686   Int_t jpa=fZlq[jpart-ipart];
3687   //
3688   if(jpart && jpa) {
3689     Int_t jpa1=fZlq[jpa-1];
3690     if(jpa1)
3691       mzdrop(fGcbank->ixcons,jpa1,PASSCHARD(" ") PASSCHARL(" "));
3692     Int_t jpa2=fZlq[jpa-2];
3693     if(jpa2)
3694       mzdrop(fGcbank->ixcons,jpa2,PASSCHARD(" ") PASSCHARL(" "));
3695   }
3696 }
3697
3698 //______________________________________________________________________________
3699 void TGeant3::Vname(const char *name, char *vname)
3700 {
3701   //
3702   //  convert name to upper case. Make vname at least 4 chars
3703   //
3704   Int_t l = strlen(name);
3705   Int_t i;
3706   l = l < 4 ? l : 4;
3707   for (i=0;i<l;i++) vname[i] = toupper(name[i]);
3708   for (i=l;i<4;i++) vname[i] = ' ';
3709   vname[4] = 0;      
3710 }
3711  
3712 //______________________________________________________________________________
3713 void TGeant3::Ertrgo()
3714 {
3715   //
3716   // Perform the tracking of the track Track parameters are in VECT
3717   //
3718   ertrgo();
3719 }
3720
3721 //______________________________________________________________________________
3722 void TGeant3::Ertrak(const Float_t *const x1, const Float_t *const p1, 
3723                         const Float_t *x2, const Float_t *p2,
3724                         Int_t ipa,  Option_t *chopt)
3725 {
3726   //************************************************************************
3727   //*                                                                      *
3728   //*          Perform the tracking of the track from point X1 to          *
3729   //*                    point X2                                          *
3730   //*          (Before calling this routine the user should also provide   *
3731   //*                    the input informations in /EROPTS/ and /ERTRIO/   *
3732   //*                    using subroutine EUFIL(L/P/V)                     *
3733   //*                 X1       - Starting coordinates (Cartesian)          *
3734   //*                 P1       - Starting 3-momentum  (Cartesian)          *
3735   //*                 X2       - Final coordinates    (Cartesian)          *
3736   //*                 P2       - Final 3-momentum     (Cartesian)          *
3737   //*                 IPA      - Particle code (a la GEANT) of the track   *
3738   //*                                                                      *
3739   //*                 CHOPT                                                *
3740   //*                     'B'   'Backward tracking' - i.e. energy loss     *
3741   //*                                        added to the current energy   *
3742   //*                     'E'   'Exact' calculation of errors assuming     *
3743   //*                                        helix (i.e. pathlength not    *
3744   //*                                        assumed as infinitesimal)     *
3745   //*                     'L'   Tracking upto prescribed Lengths reached   *
3746   //*                     'M'   'Mixed' prediction (not yet coded)         *
3747   //*                     'O'   Tracking 'Only' without calculating errors *
3748   //*                     'P'   Tracking upto prescribed Planes reached    *
3749   //*                     'V'   Tracking upto prescribed Volumes reached   *
3750   //*                     'X'   Tracking upto prescribed Point approached  *
3751   //*                                                                      *
3752   //*                Interface with GEANT :                                *
3753   //*             Track parameters are in /CGKINE/ and /GCTRAK/            *
3754   //*                                                                      *
3755   //*          ==>Called by : USER                                         *
3756   //*             Authors   M.Maire, E.Nagy  ********//*                     *
3757   //*                                                                      *
3758   //************************************************************************
3759   ertrak(x1,p1,x2,p2,ipa,PASSCHARD(chopt) PASSCHARL(chopt));
3760 }
3761         
3762 //_____________________________________________________________________________
3763 void TGeant3::WriteEuclid(const char* filnam, const char* topvol,
3764                           Int_t number, Int_t nlevel)
3765 {
3766   //
3767   //
3768   //     ******************************************************************
3769   //     *                                                                *
3770   //     *  Write out the geometry of the detector in EUCLID file format  *
3771   //     *                                                                *
3772   //     *       filnam : will be with the extension .euc                 *
3773   //     *       topvol : volume name of the starting node                *
3774   //     *       number : copy number of topvol (relevant for gsposp)     *
3775   //     *       nlevel : number of  levels in the tree structure         *
3776   //     *                to be written out, starting from topvol         *
3777   //     *                                                                *
3778   //     *       Author : M. Maire                                        *
3779   //     *                                                                *
3780   //     ******************************************************************
3781   //
3782   //     File filnam.tme is written out with the definitions of tracking
3783   //     medias and materials.
3784   //     As to restore original numbers for materials and medias, program
3785   //     searches in the file euc_medi.dat and comparing main parameters of
3786   //     the mat. defined inside geant and the one in file recognizes them
3787   //     and is able to take number from file. If for any material or medium,
3788   //     this procedure fails, ordering starts from 1.
3789   //     Arrays IOTMED and IOMATE are used for this procedure
3790   //
3791   const char kShape[][5]={"BOX ","TRD1","TRD2","TRAP","TUBE","TUBS","CONE",
3792                          "CONS","SPHE","PARA","PGON","PCON","ELTU","HYPE",
3793                          "GTRA","CTUB"};
3794   Int_t i, end, itm, irm, jrm, k, nmed;
3795   Int_t imxtmed=0;
3796   Int_t imxmate=0;
3797   FILE *lun;
3798   char *filext, *filetme;
3799   char natmed[21], namate[21];
3800   char natmedc[21], namatec[21];
3801   char key[5], name[5], mother[5], konly[5];
3802   char card[133];
3803   Int_t iadvol, iadtmd, iadrot, nwtot, iret;
3804   Int_t mlevel, numbr, natt, numed, nin, ndata;
3805   Int_t iname, ivo, ish, jvo, nvstak, ivstak;
3806   Int_t jdiv, ivin, in, jin, jvin, irot;
3807   Int_t jtm, imat, jma, flag=0, imatc;
3808   Float_t az, dens, radl, absl, a, step, x, y, z;
3809   Int_t npar, ndvmx, left;
3810   Float_t zc, densc, radlc, abslc, c0, tmaxfd;
3811   Int_t nparc, numb;
3812   Int_t iomate[100], iotmed[100];
3813   Float_t par[50], att[20], ubuf[50];
3814   Float_t *qws;
3815   Int_t   *iws;
3816   Int_t level, ndiv, iaxe;
3817   Int_t itmedc, nmatc, isvolc, ifieldc, nwbufc, isvol, nmat, ifield, nwbuf;
3818   Float_t fieldmc, tmaxfdc, stemaxc, deemaxc, epsilc, stminc, fieldm;
3819   Float_t tmaxf, stemax, deemax, epsil, stmin;
3820   const char *k10000="!\n%s\n!\n";
3821   //Open the input file
3822   end=strlen(filnam);
3823   for(i=0;i<end;i++) if(filnam[i]=='.') {
3824     end=i;
3825     break;
3826   }
3827   filext=new char[end+5];
3828   filetme=new char[end+5];
3829   strncpy(filext,filnam,end);
3830   strncpy(filetme,filnam,end);
3831   //
3832   // *** The output filnam name will be with extension '.euc'
3833   strcpy(&filext[end],".euc");
3834   strcpy(&filetme[end],".tme");
3835   lun=fopen(filext,"w");
3836   //
3837   // *** Initialisation of the working space
3838   iadvol=fGcnum->nvolum;
3839   iadtmd=iadvol+fGcnum->nvolum;
3840   iadrot=iadtmd+fGcnum->ntmed;
3841   if(fGclink->jrotm) {
3842     fGcnum->nrotm=fZiq[fGclink->jrotm-2];
3843   } else {
3844     fGcnum->nrotm=0;
3845   }
3846   nwtot=iadrot+fGcnum->nrotm;
3847   qws = new float[nwtot+1];
3848   for (i=0;i<nwtot+1;i++) qws[i]=0;
3849   iws = (Int_t*) qws;
3850   mlevel=nlevel;
3851   if(nlevel==0) mlevel=20;
3852   //
3853   // *** find the top volume and put it in the stak
3854   numbr = number>0 ? number : 1;
3855   Gfpara(topvol,numbr,1,npar,natt,par,att);
3856   if(npar <= 0) {
3857     printf(" *** GWEUCL *** top volume : %s number : %3d can not be a valid root\n",
3858            topvol, numbr);
3859     return;
3860   }
3861   //
3862   // ***  authorized shape ?
3863   strncpy((char *)&iname, topvol, 4);
3864   ivo=0;
3865   for(i=1; i<=fGcnum->nvolum; i++) if(fZiq[fGclink->jvolum+i]==iname) {
3866     ivo=i;
3867     break;
3868   }
3869   jvo = fZlq[fGclink->jvolum-ivo];
3870   ish = Int_t (fZq[jvo+2]);
3871   if(ish > 12) {
3872     printf(" *** GWEUCL *** top volume : %s number : %3d can not be a valid root\n",
3873            topvol, numbr);
3874   }
3875   //
3876   level = 1;
3877   nvstak = 1;
3878   iws[nvstak]     = ivo;
3879   iws[iadvol+ivo] = level;
3880   ivstak = 0;
3881   //
3882   //*** flag all volumes and fill the stak
3883   //
3884  L10:
3885   //
3886   //    pick the next volume in stak
3887   ivstak += 1;
3888   ivo   = TMath::Abs(iws[ivstak]);
3889   jvo   = fZlq[fGclink->jvolum - ivo];
3890   //
3891   //     flag the tracking medium
3892   numed =  Int_t (fZq[jvo + 4]);
3893   iws[iadtmd + numed] = 1;
3894   //
3895   //    get the daughters ...
3896   level = iws[iadvol+ivo];
3897   if (level < mlevel) {
3898     level +=  1;
3899     nin = Int_t (fZq[jvo + 3]);
3900     //
3901     //       from division ...
3902     if (nin < 0) {
3903       jdiv = fZlq[jvo  - 1];
3904       ivin =  Int_t (fZq[jdiv + 2]);
3905       nvstak += 1;
3906       iws[nvstak]      = -ivin;
3907       iws[iadvol+ivin] =  level;
3908       //
3909       //       from position ...
3910     } else if (nin > 0) {
3911       for(in=1; in<=nin; in++) {
3912         jin  = fZlq[jvo - in];
3913         ivin =  Int_t (fZq[jin + 2 ]);
3914         jvin = fZlq[fGclink->jvolum - ivin];
3915         ish  =  Int_t (fZq[jvin + 2]);
3916         //              authorized shape ?
3917         if (ish <= 12) {
3918           //                 not yet flagged ?
3919           if (iws[iadvol+ivin]==0) {
3920             nvstak += 1;
3921             iws[nvstak]      = ivin;
3922             iws[iadvol+ivin] = level;
3923           }
3924           //                 flag the rotation matrix
3925           irot = Int_t ( fZq[jin + 4 ]);
3926           if (irot > 0) iws[iadrot+irot] = 1;
3927         }
3928       }
3929     }
3930   }
3931   //
3932   //     next volume in stak ?
3933   if (ivstak < nvstak) goto L10;
3934   //
3935   // *** restore original material and media numbers
3936   // file euc_medi.dat is needed to compare materials and medias
3937   //
3938   FILE* luncor=fopen("euc_medi.dat","r");
3939   //
3940   if(luncor) {
3941     for(itm=1; itm<=fGcnum->ntmed; itm++) {
3942       if (iws[iadtmd+itm] > 0) {
3943         jtm = fZlq[fGclink->jtmed-itm];
3944         strncpy(natmed,(char *)&fZiq[jtm+1],20);
3945         imat =  Int_t (fZq[jtm+6]);
3946         jma  = fZlq[fGclink->jmate-imat];
3947         if (jma <= 0) {
3948           printf(" *** GWEUCL *** material not defined for tracking medium %5i %s\n",itm,natmed);
3949           flag=1;
3950         } else {
3951           strncpy(namate,(char *)&fZiq[jma+1],20);
3952         }
3953         //*
3954         //** find the material original number
3955         rewind(luncor);
3956       L23:
3957         iret=fscanf(luncor,"%4s,%130s",key,card);
3958         if(iret<=0) goto L26;
3959         flag=0;
3960         if(!strcmp(key,"MATE")) {
3961           sscanf(card,"%d %s %f %f %f %f %f %d",&imatc,namatec,&az,&zc,&densc,&radlc,&abslc,&nparc);
3962           Gfmate(imat,namate,a,z,dens,radl,absl,par,npar);
3963           if(!strcmp(namatec,namate)) {
3964             if(az==a && zc==z && densc==dens && radlc==radl 
3965                && abslc==absl && nparc==nparc) {
3966               iomate[imat]=imatc;
3967               flag=1;
3968               printf("*** GWEUCL *** material : %3d '%s' restored as %3d\n",imat,namate,imatc);
3969             } else {
3970               printf("*** GWEUCL *** different definitions for material: %s\n",namate);
3971             }
3972           }
3973         }
3974         if(strcmp(key,"END") && !flag) goto L23;
3975         if (!flag) {
3976           printf("*** GWEUCL *** cannot restore original number for material: %s\n",namate);
3977         }
3978         //*
3979         //*
3980         //***  restore original tracking medium number
3981         rewind(luncor);
3982       L24:
3983         iret=fscanf(luncor,"%4s,%130s",key,card);
3984         if(iret<=0) goto L26;
3985         flag=0;
3986         if (!strcmp(key,"TMED")) {
3987           sscanf(card,"%d %s %d %d %d %f %f %f %f %f %f %d\n",
3988                  &itmedc,natmedc,&nmatc,&isvolc,&ifieldc,&fieldmc,
3989                  &tmaxfdc,&stemaxc,&deemaxc,&epsilc,&stminc,&nwbufc);
3990           Gftmed(itm,natmed,nmat,isvol,ifield,fieldm,tmaxf,stemax,deemax,
3991                         epsil,stmin,ubuf,&nwbuf);
3992           if(!strcmp(natmedc,natmed)) {
3993             if (iomate[nmat]==nmatc && nwbuf==nwbufc) {
3994               iotmed[itm]=itmedc;
3995               flag=1;
3996               printf("*** GWEUCL *** medium   : %3d '%20s' restored as %3d\n",
3997                      itm,natmed,itmedc);
3998             } else {
3999               printf("*** GWEUCL *** different definitions for tracking medium: %s\n",natmed);
4000             }
4001           }
4002         }
4003         if(strcmp(key,"END") && !flag) goto L24;
4004         if(!flag) {
4005           printf("cannot restore original number for medium : %s\n",natmed);
4006           goto L27;
4007         }
4008       }
4009     }
4010     goto L29;
4011     //*
4012   }
4013  L26:   printf("*** GWEUCL *** cannot read the data file\n");
4014  L27:   flag=2;
4015  L29:   if(luncor) fclose (luncor);
4016   //
4017   //
4018   // *** write down the tracking medium definition
4019   //
4020   strcpy(card,"!       Tracking medium");
4021   fprintf(lun,k10000,card);
4022   //
4023   for(itm=1;itm<=fGcnum->ntmed;itm++) {
4024     if (iws[iadtmd+itm]>0) {
4025       jtm  = fZlq[fGclink->jtmed-itm];
4026       strncpy(natmed,(char *)&fZiq[jtm+1],20);
4027       natmed[20]='\0';
4028       imat =  Int_t (fZq[jtm+6]);
4029       jma  = fZlq[fGclink->jmate-imat];
4030       //*  order media from one, if comparing with database failed
4031       if (flag==2) {
4032         iotmed[itm]=++imxtmed;
4033         iomate[imat]=++imxmate;
4034       }
4035       //*
4036       if(jma<=0) {
4037         strcpy(namate,"                  ");
4038         printf(" *** GWEUCL *** material not defined for tracking medium %5d %s\n",
4039                itm,natmed);
4040       } else {
4041         strncpy(namate,(char *)&fZiq[jma+1],20);
4042         namate[20]='\0';
4043       }
4044       fprintf(lun,"TMED %3d '%20s' %3d '%20s'\n",iotmed[itm],natmed,iomate[imat],namate);
4045     }
4046   }
4047   //*
4048       //* *** write down the rotation matrix
4049   //*
4050   strcpy(card,"!       Reperes");
4051   fprintf(lun,k10000,card);
4052   //
4053   for(irm=1;irm<=fGcnum->nrotm;irm++) {
4054     if (iws[iadrot+irm]>0) {
4055       jrm  = fZlq[fGclink->jrotm-irm];
4056       fprintf(lun,"ROTM %3d",irm);
4057       for(k=11;k<=16;k++) fprintf(lun," %8.3f",fZq[jrm+k]);
4058       fprintf(lun,"\n");
4059     }
4060   }
4061   //*
4062   //* *** write down the volume definition
4063   //*
4064   strcpy(card,"!       Volumes");
4065   fprintf(lun,k10000,card);
4066   //*
4067   for(ivstak=1;ivstak<=nvstak;ivstak++) {
4068     ivo = iws[ivstak];
4069     if (ivo>0) {
4070       strncpy(name,(char *)&fZiq[fGclink->jvolum+ivo],4);
4071       name[4]='\0';
4072       jvo  = fZlq[fGclink->jvolum-ivo];
4073       ish   = Int_t (fZq[jvo+2]);
4074       nmed  = Int_t (fZq[jvo+4]);
4075       npar  = Int_t (fZq[jvo+5]);
4076       if (npar>0) {
4077         if (ivstak>1) for(i=0;i<npar;i++) par[i]=fZq[jvo+7+i];
4078         Gckpar (ish,npar,par);
4079         fprintf(lun,"VOLU '%4s' '%4s' %3d %3d\n",name,kShape[ish-1],iotmed[nmed],npar);
4080         for(i=0;i<(npar-1)/6+1;i++) {
4081           fprintf(lun,"     ");
4082           left=npar-i*6;
4083           for(k=0;k<(left<6?left:6);k++) fprintf(lun," %11.5f",par[i*6+k]);
4084           fprintf(lun,"\n");
4085         }
4086       } else {
4087         fprintf(lun,"VOLU '%4s' '%4s' %3d %3d\n",name,kShape[ish-1],iotmed[nmed],npar);
4088       }
4089     }
4090   }
4091   //*
4092   //* *** write down the division of volumes
4093   //*
4094   fprintf(lun,k10000,"!       Divisions");
4095   for(ivstak=1;ivstak<=nvstak;ivstak++) {
4096     ivo = TMath::Abs(iws[ivstak]);
4097     jvo  = fZlq[fGclink->jvolum-ivo];
4098     ish  = Int_t (fZq[jvo+2]);
4099     nin  = Int_t (fZq[jvo+3]);
4100     //*        this volume is divided ...
4101     if (nin<0) {
4102       jdiv = fZlq[jvo-1];
4103       iaxe = Int_t ( fZq[jdiv+1]);
4104       ivin = Int_t ( fZq[jdiv+2]);
4105       ndiv = Int_t ( fZq[jdiv+3]);
4106       c0   =  fZq[jdiv+4];
4107       step =  fZq[jdiv+5];
4108       jvin = fZlq[fGclink->jvolum-ivin];
4109       nmed = Int_t ( fZq[jvin+4]);
4110       strncpy(mother,(char *)&fZiq[fGclink->jvolum+ivo ],4);
4111       mother[4]='\0';
4112       strncpy(name,(char *)&fZiq[fGclink->jvolum+ivin],4);
4113       name[4]='\0';
4114       if ((step<=0.)||(ish>=11)) {
4115         //*              volume with negative parameter or gsposp or pgon ...
4116         fprintf(lun,"DIVN '%4s' '%4s' %3d %3d\n",name,mother,ndiv,iaxe);
4117       } else if ((ndiv<=0)||(ish==10)) {
4118         //*              volume with negative parameter or gsposp or para ...
4119         ndvmx = TMath::Abs(ndiv);
4120         fprintf(lun,"DIVT '%4s' '%4s' %11.5f %3d %3d %3d\n",
4121                 name,mother,step,iaxe,iotmed[nmed],ndvmx);
4122       } else {
4123         //*              normal volume : all kind of division are equivalent
4124         fprintf(lun,"DVT2 '%4s' '%4s' %11.5f %3d %11.5f %3d %3d\n",
4125                 name,mother,step,iaxe,c0,iotmed[nmed],ndiv);
4126       }
4127     }
4128   }
4129   //*
4130   //* *** write down the the positionnement of volumes
4131   //*
4132   fprintf(lun,k10000,"!       Positionnements\n");
4133   //
4134   for(ivstak = 1;ivstak<=nvstak;ivstak++) {
4135     ivo = TMath::Abs(iws[ivstak]);
4136     strncpy(mother,(char*)&fZiq[fGclink->jvolum+ivo ],4);
4137     mother[4]='\0';
4138     jvo  = fZlq[fGclink->jvolum-ivo];
4139     nin  = Int_t( fZq[jvo+3]);
4140     //*        this volume has daughters ...
4141     if (nin>0) {
4142       for (in=1;in<=nin;in++) {
4143         jin  = fZlq[jvo-in];
4144         ivin =  Int_t (fZq[jin +2]);
4145         numb =  Int_t (fZq[jin +3]);
4146         irot =  Int_t (fZq[jin +4]);
4147         x    =  fZq[jin +5];
4148         y    =  fZq[jin +6];
4149         z    =  fZq[jin +7];
4150         strcpy(konly,"ONLY");
4151         if (fZq[jin+8]!=1.) strcpy(konly,"MANY");
4152         strncpy(name,(char*)&fZiq[fGclink->jvolum+ivin],4);
4153         name[4]='\0';
4154         jvin = fZlq[fGclink->jvolum-ivin];
4155         ish  = Int_t (fZq[jvin+2]);
4156         //*              gspos or gsposp ?
4157         ndata = fZiq[jin-1];
4158         if (ndata==8) {
4159           fprintf(lun,"POSI '%4s' %4d '%4s' %11.5f %11.5f %11.5f %3d '%4s'\n",
4160                   name,numb,mother,x,y,z,irot,konly);
4161         } else {
4162           npar =  Int_t (fZq[jin+9]);
4163           for(i=0;i<npar;i++) par[i]=fZq[jin+10+i];
4164           Gckpar (ish,npar,par);
4165           fprintf(lun,"POSP '%4s' %4d '%4s' %11.5f %11.5f %11.5f %3d '%4s' %3d\n",
4166                   name,numb,mother,x,y,z,irot,konly,npar);
4167           fprintf(lun,"     ");
4168           for(i=0;i<npar;i++) fprintf(lun," %11.5f",par[i]);
4169           fprintf(lun,"\n");
4170         }
4171       }
4172     }
4173   }
4174   //*
4175   fprintf(lun,"END\n");
4176   fclose(lun);
4177   //*
4178   //****** write down the materials and medias *****
4179   //*
4180   lun=fopen(filetme,"w");
4181   //*
4182   for(itm=1;itm<=fGcnum->ntmed;itm++) {
4183     if (iws[iadtmd+itm]>0) {
4184       jtm  = fZlq[fGclink->jtmed-itm];
4185       strncpy(natmed,(char*)&fZiq[jtm+1],4);
4186       imat =  Int_t (fZq[jtm+6]);
4187       jma  =  Int_t (fZlq[fGclink->jmate-imat]);
4188       //*  material
4189       Gfmate (imat,namate,a,z,dens,radl,absl,par,npar);
4190       fprintf(lun,"MATE %4d '%20s'%11.5E %11.5E %11.5E %11.5E %11.5E %3d\n",
4191              iomate[imat],namate,a,z,dens,radl,absl,npar);
4192       //*
4193       if (npar>0) {
4194           fprintf(lun,"     ");
4195           for(i=0;i<npar;i++) fprintf(lun," %11.5f",par[i]);
4196           fprintf(lun,"\n");
4197       }
4198       //*  medium
4199       Gftmed(itm,natmed,nmat,isvol,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin,par,&npar);
4200       fprintf(lun,"TMED %4d '%20s' %3d %1d %3d %11.5f %11.5f %11.5f %11.5f %11.5f %11.5f %3d\n",
4201               iotmed[itm],natmed,iomate[nmat],isvol,ifield,
4202               fieldm,tmaxfd,stemax,deemax,epsil,stmin,npar);
4203       //*
4204       if (npar>0) {
4205           fprintf(lun,"     ");
4206           for(i=0;i<npar;i++) fprintf(lun," %11.5f",par[i]);
4207           fprintf(lun,"\n");
4208       }
4209       
4210     }
4211   }
4212   fprintf(lun,"END\n");
4213   fclose(lun);
4214   printf(" *** GWEUCL *** file: %s is now written out\n",filext);
4215   printf(" *** GWEUCL *** file: %s is now written out\n",filetme);
4216   // Clean up
4217   delete [] filext;
4218   delete [] filetme;
4219   delete [] qws;
4220   iws=0;
4221   return;
4222 }
4223
4224 //_____________________________________________________________________________
4225 void TGeant3::Streamer(TBuffer &R__b)
4226 {
4227   //
4228   // Stream an object of class TGeant3.
4229   //
4230   if (R__b.IsReading()) {
4231     Version_t R__v = R__b.ReadVersion(); if (R__v) { }
4232     AliMC::Streamer(R__b);
4233     R__b >> fNextVol;
4234     R__b >> fNPDGCodes;
4235     R__b.ReadStaticArray(fPDGCode);
4236   } else {
4237     R__b.WriteVersion(TGeant3::IsA());
4238     AliMC::Streamer(R__b);
4239     R__b << fNextVol;
4240     R__b << fNPDGCodes;
4241     R__b.WriteArray(fPDGCode, fNPDGCodes);
4242   }
4243 }
4244
4245