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