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