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