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