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