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