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