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