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