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