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