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