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