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