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