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