1 ///////////////////////////////////////////////////////////////////////////////
3 // Interface Class to the Geant3.21 MonteCarlo //
7 <img src="gif/TGeant3Class.gif">
12 ///////////////////////////////////////////////////////////////////////////////
18 #include "AliCallf77.h"
21 # define gzebra gzebra_
22 # define grfile grfile_
23 # define gpcxyz gpcxyz_
24 # define ggclos ggclos_
27 # define gcinit gcinit_
30 # define gtrigc gtrigc_
31 # define gtrigi gtrigi_
33 # define gzinit gzinit_
34 # define gfmate gfmate_
35 # define gfpart gfpart_
36 # define gftmed gftmed_
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_
58 # define gtrack gtrack_
59 # define gtreve gtreve_
61 # define grndmq grndmq_
63 # define glmoth glmoth_
64 # define gmedia gmedia_
67 # define gsdvn2 gsdvn2_
69 # define gsdvs2 gsdvs2_
71 # define gsdvt2 gsdvt2_
74 # define gsposp gsposp_
75 # define gsrotm gsrotm_
76 # define gprotm gprotm_
77 # define gsvolu gsvolu_
78 # define gprint gprint_
79 # define gdinit gdinit_
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_
90 # define gdcxyz gdcxyz_
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_
100 # define gfpara gfpara_
101 # define gckpar gckpar_
102 # define gckmat gckmat_
103 # define geditv geditv_
105 # define setbomb setbomb_
106 # define setclip setclip_
107 # define gcomad gcomad_
110 # define gzebra GZEBRA
111 # define grfile GRFILE
112 # define gpcxyz GPCXYZ
113 # define ggclos GGCLOS
116 # define gcinit GCINIT
119 # define gtrigc GTRIGC
120 # define gtrigi GTRIGI
122 # define gzinit GZINIT
123 # define gfmate GFMATE
124 # define gfpart GFPART
125 # define gftmed GFTMED
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
147 # define gtrack GTRACK
148 # define gtreve GTREVE
150 # define grndmq GRNDMQ
152 # define glmoth GLMOTH
153 # define gmedia GMEDIA
156 # define gsdvn2 GSDVN2
158 # define gsdvs2 GSDVS2
160 # define gsdvt2 GSDVT2
163 # define gsposp GSPOSP
164 # define gsrotm GSROTM
165 # define gprotm GPROTM
166 # define gsvolu GSVOLU
167 # define gprint GPRINT
168 # define gdinit GDINIT
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
179 # define gdcxyz GDCXYZ
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
190 # define gfpara GFPARA
191 # define gckpar GCKPAR
192 # define gckmat GCKMAT
193 # define geditv GEDITV
195 # define setbomb SETBOMB
196 # define setclip SETCLIP
197 # define gcomad GCOMAD
201 //____________________________________________________________________________
205 // Prototypes for GEANT functions
207 void type_of_call gzebra(const int&);
209 void type_of_call gpcxyz();
211 void type_of_call ggclos();
213 void type_of_call glast();
215 void type_of_call ginit();
217 void type_of_call gcinit();
219 void type_of_call grun();
221 void type_of_call gtrig();
223 void type_of_call gtrigc();
225 void type_of_call gtrigi();
227 void type_of_call gwork(const int&);
229 void type_of_call gzinit();
231 void type_of_call gmate();
233 void type_of_call gpart();
235 void type_of_call gsdk(Int_t &, Float_t *, Int_t *);
237 void type_of_call gfkine(Int_t &, Float_t *, Float_t *, Int_t &,
238 Int_t &, Float_t *, Int_t &);
240 void type_of_call gfvert(Int_t &, Float_t *, Int_t &, Int_t &,
241 Float_t &, Float_t *, Int_t &);
243 void type_of_call gskine(Float_t *,Int_t &, Int_t &, Float_t *,
246 void type_of_call gsvert(Float_t *,Int_t &, Int_t &, Float_t *,
249 void type_of_call gphysi();
251 void type_of_call gdebug();
253 void type_of_call gekbin();
255 void type_of_call gfinds();
257 void type_of_call gsking(Int_t &);
259 void type_of_call gskpho(Int_t &);
261 void type_of_call gsstak(Int_t &);
263 void type_of_call gsxyz();
265 void type_of_call gtrack();
267 void type_of_call gtreve();
269 void type_of_call grndm(Float_t *, const Int_t &);
271 void type_of_call grndmq(Int_t &, Int_t &, const Int_t &,
274 void type_of_call gdtom(Float_t *, Float_t *, Int_t &);
276 void type_of_call glmoth(DEFCHARD, Int_t &, Int_t &, Int_t *,
277 Int_t *, Int_t * DEFCHARL);
279 void type_of_call gmedia(Float_t *, Int_t &);
281 void type_of_call gmtod(Float_t *, Float_t *, Int_t &);
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 &,
287 void type_of_call gprotm(const Int_t &);
289 void type_of_call grfile(const Int_t&, DEFCHARD,
290 DEFCHARD DEFCHARL DEFCHARL);
292 void type_of_call gfmate(const Int_t&, DEFCHARD, Float_t &, Float_t &,
293 Float_t &, Float_t &, Float_t &, Float_t *,
296 void type_of_call gfpart(const Int_t&, DEFCHARD, Int_t &, Float_t &,
297 Float_t &, Float_t &, Float_t *, Int_t & DEFCHARL);
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);
303 void type_of_call gsmate(const Int_t&, DEFCHARD, Float_t &, Float_t &,
304 Float_t &, Float_t &, Float_t &, Float_t *,
307 void type_of_call gsmixt(const Int_t&, DEFCHARD, Float_t *, Float_t *,
308 Float_t &, Int_t &, Float_t * DEFCHARL);
310 void type_of_call gspart(const Int_t&, DEFCHARD, Int_t &, Float_t &,
311 Float_t &, Float_t &, Float_t *, Int_t & DEFCHARL);
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);
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);
322 void type_of_call gsdvn(DEFCHARD,DEFCHARD, Int_t &, Int_t &
325 void type_of_call gsdvn2(DEFCHARD,DEFCHARD, Int_t &, Int_t &, Float_t &,
326 Int_t & DEFCHARL DEFCHARL);
328 void type_of_call gsdvs(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Int_t &
331 void type_of_call gsdvs2(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Float_t &,
332 Int_t & DEFCHARL DEFCHARL);
334 void type_of_call gsdvt(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Int_t &,
335 Int_t & DEFCHARL DEFCHARL);
337 void type_of_call gsdvt2(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Float_t&,
338 Int_t &, Int_t & DEFCHARL DEFCHARL);
340 void type_of_call gsord(DEFCHARD, Int_t & DEFCHARL);
342 void type_of_call gspos(DEFCHARD, Int_t &, DEFCHARD, Float_t &, Float_t &,
343 Float_t &, Int_t &, DEFCHARD DEFCHARL DEFCHARL
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);
350 void type_of_call gsvolu(DEFCHARD, DEFCHARD, Int_t &, Float_t *, Int_t &,
351 Int_t & DEFCHARL DEFCHARL);
353 void type_of_call gsatt(DEFCHARD, DEFCHARD, Int_t & DEFCHARL DEFCHARL);
355 void type_of_call gfpara(DEFCHARD , Int_t&, Int_t&, Int_t&, Int_t&, Float_t*,
358 void type_of_call gckpar(Int_t&, Int_t&, Float_t*);
360 void type_of_call gckmat(Int_t&, DEFCHARD DEFCHARL);
362 void type_of_call gprint(DEFCHARD,const int& DEFCHARL);
364 void type_of_call gdinit();
366 void type_of_call gdopt(DEFCHARD,DEFCHARD DEFCHARL DEFCHARL);
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 &,
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);
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 &) {;}
395 void type_of_call dzshow(DEFCHARD,const int&,const int&,DEFCHARD,const int&,
396 const int&, const int&, const int& DEFCHARL
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);
406 // Geant3 global pointer
408 static Int_t defSize = 600;
412 //____________________________________________________________________________
413 TGeant3::TGeant3() : AliMC()
416 // Default constructor
420 //____________________________________________________________________________
421 TGeant3::TGeant3(const char *title, Int_t nwgeant)
422 :AliMC("TGeant3",title)
425 // Standard constructor for TGeant3 with ZEBRA initialisation
436 // Load Address of Geant3 commons
440 //____________________________________________________________________________
441 Int_t TGeant3::CurrentMaterial(Float_t &a, Float_t &z, Float_t &dens,
442 Float_t &radl, Float_t &absl) const
445 // Return the parameters of the current material during transport
449 dens = fGcmate->dens;
450 radl = fGcmate->radl;
451 absl = fGcmate->absl;
452 return 1; //this could be the number of elements in mixture
455 //____________________________________________________________________________
456 void TGeant3::DefaultRange()
459 // Set range of current drawing pad to 20x20 cm
465 higz->Range(0,0,20,20);
468 //____________________________________________________________________________
469 void TGeant3::InitHIGZ()
480 //____________________________________________________________________________
481 void TGeant3::LoadAddress()
484 // Assigns the address of the GEANT common blocks to the structures
485 // that allow their access from C++
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"));
508 gcomad(PASSCHARD("IQ"), addr PASSCHARL("IQ"));
510 gcomad(PASSCHARD("LQ"), addr PASSCHARL("LQ"));
515 //_____________________________________________________________________________
516 void TGeant3::GeomIter()
519 // Geometry iterator for moving upward in the geometry tree
520 // Initialise the iterator
522 fNextVol=fGcvolu->nlevel;
525 //____________________________________________________________________________
526 Int_t TGeant3::NextVolUp(Text_t *name, Int_t ©)
529 // Geometry iterator for moving upward in the geometry tree
530 // Return next volume up
535 gname=fGcvolu->names[fNextVol];
536 strncpy(name,(char *) &gname, 4);
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);
546 //_____________________________________________________________________________
547 Int_t TGeant3::CurrentVol(Text_t *name, Int_t ©) const
550 // Returns the current volume ID, name and copy number
551 // if name=0 no name is returned
554 if( (i=fGcvolu->nlevel-1) < 0 ) {
555 printf("CurrentVol: stack depth %d\n",fGcvolu->nlevel);
557 gname=fGcvolu->names[i];
559 strncpy(name,(char *) &gname, 4);
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);
570 //_____________________________________________________________________________
571 Int_t TGeant3::CurrentVolOff(Int_t off, Text_t *name, Int_t ©) const
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
579 if( (i=fGcvolu->nlevel-off-1) < 0 ) {
580 printf("CurrentVolOff: Offset requested %d but stack depth %d\n",off,fGcvolu->nlevel);
582 gname=fGcvolu->names[i];
584 strncpy(name,(char *) &gname, 4);
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);
595 //_____________________________________________________________________________
596 Int_t TGeant3::VolId(Text_t *name) const
599 // Return the unique numeric identifier for volume name
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);
609 //_____________________________________________________________________________
610 Int_t TGeant3::Nvolumes() const
613 // Return total number of volumes in the geometry
615 return fGcnum->nvolum;
618 //_____________________________________________________________________________
619 char* TGeant3::VolName(Int_t id) const
622 // Return the volume name given the volume identifier
625 if(id<1 || id > fGcnum->nvolum || fGclink->jvolum<=0)
628 strncpy(name,(char *)&fZiq[fGclink->jvolum+id],4);
633 //_____________________________________________________________________________
634 void TGeant3::TrackPosition(Float_t *xyz) const
637 // Return the current position in the master reference frame of the
638 // track being transported
640 xyz[0]=fGctrak->vect[0];
641 xyz[1]=fGctrak->vect[1];
642 xyz[2]=fGctrak->vect[2];
645 //_____________________________________________________________________________
646 Float_t TGeant3::TrackTime() const
649 // Return the current time of flight of the track being transported
651 return fGctrak->tofg;
654 //_____________________________________________________________________________
655 void TGeant3::TrackMomentum(Float_t *xyz) const
658 // Return the direction and the momentum (GeV/c) of the track
659 // currently being transported
661 xyz[0]=fGctrak->vect[3];
662 xyz[1]=fGctrak->vect[4];
663 xyz[2]=fGctrak->vect[5];
664 xyz[3]=fGctrak->vect[6];
667 //_____________________________________________________________________________
668 Float_t TGeant3::TrackCharge() const
671 // Return charge of the track currently transported
673 return fGckine->charge;
676 //_____________________________________________________________________________
677 Float_t TGeant3::TrackMass() const
680 // Return the mass of the track currently transported
682 return fGckine->amass;
685 //_____________________________________________________________________________
686 Int_t TGeant3::TrackPid() const
689 // Return the id of the particle transported
691 return fGckine->ipart;
694 //_____________________________________________________________________________
695 Float_t TGeant3::TrackStep() const
698 // Return the length in centimeters of the current step
700 return fGctrak->step;
703 //_____________________________________________________________________________
704 Float_t TGeant3::TrackLength() const
707 // Return the length of the current track from its origin
709 return fGctrak->sleng;
712 //_____________________________________________________________________________
713 Bool_t TGeant3::TrackInside() const
716 // True if the track is not at the boundary of the current volume
718 return (fGctrak->inwvol==0);
721 //_____________________________________________________________________________
722 Bool_t TGeant3::TrackEntering() const
725 // True if this is the first step of the track in the current volume
727 return (fGctrak->inwvol==1);
730 //_____________________________________________________________________________
731 Bool_t TGeant3::TrackExiting() const
734 // True if this is the last step of the track in the current volume
736 return (fGctrak->inwvol==2);
739 //_____________________________________________________________________________
740 Bool_t TGeant3::TrackOut() const
743 // True if the track is out of the setup
745 return (fGctrak->inwvol==3);
748 //_____________________________________________________________________________
749 Bool_t TGeant3::TrackStop() const
752 // True if the track energy has fallen below the threshold
754 return (fGctrak->istop==2);
757 //_____________________________________________________________________________
758 Int_t TGeant3::NSecondaries() const
761 // Number of secondary particles generated in the current step
763 return fGcking->ngkine;
766 //_____________________________________________________________________________
767 Int_t TGeant3::CurrentEvent() const
770 // Number of the current event
772 return fGcflag->idevt;
775 //_____________________________________________________________________________
776 void TGeant3::ProdProcess(char* proc) const
779 // Name of the process that has produced the secondary particles
780 // in the current step
782 const Int_t ipmec[13] = { 5,6,7,8,9,10,11,12,21,23,25,105,108 };
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);
801 } else strcpy(proc,"NONE");
804 //_____________________________________________________________________________
805 void TGeant3::GetSecondary(Int_t isec, Int_t& ipart, Float_t* x, Float_t* p)
808 // Get the parameters of the secondary track number isec produced
809 // in the current step
812 if(-1<isec && isec<fGcking->ngkine) {
813 ipart=Int_t (fGcking->gkin[isec][4] +0.5);
815 x[i]=fGckin3->gpos[isec][i];
816 p[i]=fGcking->gkin[isec][i];
818 x[3]=fGcking->tofd[isec];
819 p[3]=fGcking->gkin[isec][3];
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;
827 //_____________________________________________________________________________
828 void TGeant3::InitLego()
831 SetDEBU(0,0,0); //do not print a message
834 //_____________________________________________________________________________
835 Bool_t TGeant3::TrackDisappear() const
838 // True if the current particle has disappered
839 // either because it decayed or because it underwent
840 // an inelastic collision
842 return (fGctrak->istop==1);
845 //_____________________________________________________________________________
846 Bool_t TGeant3::TrackAlive() const
849 // True if the current particle is alive and will continue to be
852 return (fGctrak->istop==0);
855 //_____________________________________________________________________________
856 void TGeant3::StopTrack()
859 // Stop the transport of the current particle and skip to the next
864 //_____________________________________________________________________________
865 void TGeant3::StopEvent()
868 // Stop simulation of the current event and skip to the next
873 //_____________________________________________________________________________
874 Float_t TGeant3::MaxStep() const
877 // Return the maximum step length in the current medium
879 return fGctmed->stemax;
882 //_____________________________________________________________________________
883 void TGeant3::SetColors()
886 // Set the colors for all the volumes
887 // this is done sequentially for all volumes
888 // based on the number of their medium
891 Int_t jvolum=fGclink->jvolum;
892 //Int_t jtmed=fGclink->jtmed;
893 //Int_t jmate=fGclink->jmate;
894 Int_t nvolum=fGcnum->nvolum;
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]);
902 //Int_t ima=Int_t (fZq[fZlq[jtmed-itm]+6]);
904 //Float_t z=fZq[fZlq[jmate-ima]+7];
906 //icol = Int_t(z)%6+2;
907 //icol = 17+Int_t(z*150./92.);
910 strncpy(name,(char*)&fZiq[jvolum+kv],4);
912 Gsatt(name,"COLO",icol);
916 //_____________________________________________________________________________
917 void TGeant3::SetMaxStep(Float_t maxstep)
920 // Set the maximum step allowed till the particle is in the current medium
922 fGctmed->stemax=maxstep;
925 //_____________________________________________________________________________
926 void TGeant3::SetMaxNStep(Int_t maxnstp)
929 // Set the maximum number of steps till the particle is in the current medium
931 fGctrak->maxnst=maxnstp;
934 //_____________________________________________________________________________
935 Int_t TGeant3::GetMaxNStep() const
938 // Maximum number of steps allowed in current medium
940 return fGctrak->maxnst;
943 //_____________________________________________________________________________
944 void 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,
949 // Defines a Material
951 // kmat number assigned to the material
952 // name material name
953 // a atomic mass in au
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
965 Int_t jmate=fGclink->jmate;
971 for(i=1; i<=ns; i++) {
972 if(fZlq[jmate-i]==0) {
978 gsmate(kmat,PASSCHARD(name), a, z, dens, radl, absl, buf,
979 nwbuf PASSCHARL(name));
982 //_____________________________________________________________________________
983 void TGeant3::Mixture(Int_t& kmat, const char* name, Float_t* a, Float_t* z,
984 Float_t dens, Int_t nlmat, Float_t* wmat)
987 // Defines mixture OR COMPOUND IMAT as composed by
988 // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
990 // If NLMAT > 0 then wmat contains the proportion by
991 // weights of each basic material in the mixture.
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
998 Int_t jmate=fGclink->jmate;
1004 for(i=1; i<=ns; i++) {
1005 if(fZlq[jmate-i]==0) {
1011 gsmixt(kmat,PASSCHARD(name), a, z,dens, nlmat,wmat PASSCHARL(name));
1014 //_____________________________________________________________________________
1015 void 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)
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)
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.
1037 Int_t jtmed=fGclink->jtmed;
1043 for(i=1; i<=ns; i++) {
1044 if(fZlq[jtmed-i]==0) {
1050 gstmed(kmed, PASSCHARD(name), nmat, isvol, ifield, fieldm, tmaxfd, stemax,
1051 deemax, epsil, stmin, ubuf, nbuf PASSCHARL(name));
1054 //_____________________________________________________________________________
1055 void TGeant3::Matrix(Int_t& krot, Float_t thex, Float_t phix, Float_t they,
1056 Float_t phiy, Float_t thez, Float_t phiz)
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
1067 // it defines the rotation matrix number irot.
1069 Int_t jrotm=fGclink->jrotm;
1075 for(i=1; i<=ns; i++) {
1076 if(fZlq[jrotm-i]==0) {
1082 gsrotm(krot, thex, phix, they, phiy, thez, phiz);
1085 //_____________________________________________________________________________
1086 void TGeant3::GetParticle(const Int_t ipart, char *name, Float_t &mass) const
1089 // Return name and mass of particle code ipart
1090 // Geant321 conventions
1093 Int_t jpart=fGclink->jpart;
1094 Int_t jpa=fZlq[jpart-ipart];
1096 for(Int_t i=1; i<6; i++) hname[i-1]=fZiq[jpa+i];
1098 strncpy(name,(char *)hname, 21);
1102 //_____________________________________________________________________________
1103 Int_t TGeant3::GetMedium() const
1106 // Return the number of the current medium
1108 return fGctmed->numed;
1111 //_____________________________________________________________________________
1112 Float_t TGeant3::Edep() const
1115 // Return the energy lost in the current step
1117 return fGctrak->destep;
1120 //_____________________________________________________________________________
1121 Float_t TGeant3::Etot() const
1124 // Return the total energy of the current track
1126 return fGctrak->getot;
1129 //_____________________________________________________________________________
1130 void TGeant3::Rndm(Float_t* r, const Int_t n) const
1133 // Return an array of n random numbers uniformly distributed
1134 // between 0 and 1 not included
1139 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1141 // Functions from GBASE
1143 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1145 //____________________________________________________________________________
1146 void TGeant3::Gfile(const char *filename, const char *option)
1149 // Routine to open a GEANT/RZ data base.
1151 // LUN logical unit number associated to the file
1153 // CHFILE RZ file name
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
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
1171 grfile(21, PASSCHARD(filename), PASSCHARD(option) PASSCHARL(filename)
1175 //____________________________________________________________________________
1176 void TGeant3::Gpcxyz()
1179 // Print track and volume parameters at current point
1184 //_____________________________________________________________________________
1185 void TGeant3::Ggclos()
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.
1209 //_____________________________________________________________________________
1210 void TGeant3::Glast()
1213 // Finish a Geant run
1218 //_____________________________________________________________________________
1219 void TGeant3::Gprint(const char *name)
1222 // Routine to print data structures
1223 // CHNAME name of a data structure
1227 gprint(PASSCHARD(vname),0 PASSCHARL(vname));
1230 //_____________________________________________________________________________
1231 void TGeant3::Grun()
1234 // Steering function to process one run
1239 //_____________________________________________________________________________
1240 void TGeant3::Gtrig()
1243 // Steering function to process one event
1248 //_____________________________________________________________________________
1249 void TGeant3::Gtrigc()
1252 // Clear event partition
1257 //_____________________________________________________________________________
1258 void TGeant3::Gtrigi()
1261 // Initialises event partition
1266 //_____________________________________________________________________________
1267 void TGeant3::Gwork(Int_t nwork)
1270 // Allocates workspace in ZEBRA memory
1275 //_____________________________________________________________________________
1276 void TGeant3::Gzinit()
1279 // To initialise GEANT/ZEBRA data structures
1284 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1286 // Functions from GCONS
1288 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1290 //_____________________________________________________________________________
1291 void 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)
1296 // Return parameters for material IMAT
1298 gfmate(imat, PASSCHARD(name), a, z, dens, radl, absl, ubuf, nbuf
1302 //_____________________________________________________________________________
1303 void TGeant3::Gfpart(Int_t ipart, char *name, Int_t &itrtyp,
1304 Float_t &amass, Float_t &charge, Float_t &tlife)
1307 // Return parameters for particle of type IPART
1311 gfpart(ipart, PASSCHARD(name), itrtyp, amass, charge, tlife, ubuf, nbuf
1315 //_____________________________________________________________________________
1316 void 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)
1322 // Return parameters for tracking medium NUMED
1324 gftmed(numed, PASSCHARD(name), nmat, isvol, ifield, fieldm, tmaxfd, stemax,
1325 deemax, epsil, stmin, ubuf, nbuf PASSCHARL(name));
1328 //_____________________________________________________________________________
1329 void TGeant3::Gmate()
1332 // Define standard GEANT materials
1337 //_____________________________________________________________________________
1338 void TGeant3::Gpart()
1341 // Define standard GEANT particles plus selected decay modes
1342 // and branching ratios.
1347 //_____________________________________________________________________________
1348 void TGeant3::Gsdk(Int_t ipart, Float_t *bratio, Int_t *mode)
1350 // Defines branching ratios and decay modes for standard
1352 gsdk(ipart,bratio,mode);
1355 //_____________________________________________________________________________
1356 void TGeant3::Gsmate(Int_t imat, const char *name, Float_t a, Float_t z,
1357 Float_t dens, Float_t radl, Float_t absl)
1360 // Defines a Material
1362 // kmat number assigned to the material
1363 // name material name
1364 // a atomic mass in au
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
1378 gsmate(imat,PASSCHARD(name), a, z, dens, radl, absl, ubuf, nbuf
1382 //_____________________________________________________________________________
1383 void TGeant3::Gsmixt(Int_t imat, const char *name, Float_t *a, Float_t *z,
1384 Float_t dens, Int_t nlmat, Float_t *wmat)
1387 // Defines mixture OR COMPOUND IMAT as composed by
1388 // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
1390 // If NLMAT.GT.0 then WMAT contains the PROPORTION BY
1391 // WEIGTHS OF EACH BASIC MATERIAL IN THE MIXTURE.
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
1398 gsmixt(imat,PASSCHARD(name), a, z,dens, nlmat,wmat PASSCHARL(name));
1401 //_____________________________________________________________________________
1402 void TGeant3::Gspart(Int_t ipart, const char *name, Int_t itrtyp,
1403 Float_t amass, Float_t charge, Float_t tlife)
1406 // Store particle parameters
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
1417 gspart(ipart,PASSCHARD(name), itrtyp, amass, charge, tlife, ubuf, nbuf
1421 //_____________________________________________________________________________
1422 void 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,
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)
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.
1446 gstmed(numed,PASSCHARD(name), nmat, isvol, ifield, fieldm, tmaxfd, stemax,
1447 deemax, epsil, stmin, ubuf, nbuf PASSCHARL(name));
1450 //_____________________________________________________________________________
1451 void TGeant3::Gsckov(Int_t itmed, Int_t npckov, Float_t *ppckov,
1452 Float_t *absco, Float_t *effic, Float_t *rindex)
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:
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)
1469 gsckov(itmed,npckov,ppckov,absco,effic,rindex);
1472 //_____________________________________________________________________________
1473 void TGeant3::Gstpar(Int_t itmed, const char *param, Float_t parval)
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.
1487 gstpar(itmed,PASSCHARD(param), parval PASSCHARL(param));
1490 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1492 // Functions from GCONS
1494 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1496 //_____________________________________________________________________________
1497 void TGeant3::Gfkine(Int_t itra, Float_t *vert, Float_t *pvert, Int_t &ipart,
1500 // Storing/Retrieving Vertex and Track parameters
1501 // ----------------------------------------------
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
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
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)
1534 gfkine(itra,vert,pvert,ipart,nvert,ubuf,nbuf);
1537 //_____________________________________________________________________________
1538 void TGeant3::Gfvert(Int_t nvtx, Float_t *v, Int_t &ntbeam, Int_t &nttarg,
1542 // Retrieves the parameter of a vertex bank
1543 // Vertex is generated from tracks NTBEAM NTTARG
1544 // NVTX is the new vertex number
1548 gfvert(nvtx,v,ntbeam,nttarg,tofg,ubuf,nbuf);
1551 //_____________________________________________________________________________
1552 Int_t TGeant3::Gskine(Float_t *plab, Int_t ipart, Int_t nv, Float_t *buf,
1556 // Store kinematics of track NT into data structure
1557 // Track is coming from vertex NV
1560 gskine(plab, ipart, nv, buf, nwbuf, nt);
1564 //_____________________________________________________________________________
1565 Int_t TGeant3::Gsvert(Float_t *v, Int_t ntbeam, Int_t nttarg, Float_t *ubuf,
1569 // Creates a new vertex bank
1570 // Vertex is generated from tracks NTBEAM NTTARG
1571 // NVTX is the new vertex number
1574 gsvert(v, ntbeam, nttarg, ubuf, nwbuf, nwtx);
1578 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1580 // Functions from GPHYS
1582 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1584 //_____________________________________________________________________________
1585 void TGeant3::Gphysi()
1588 // Initialise material constants for all the physics
1589 // mechanisms used by GEANT
1594 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1596 // Functions from GTRAK
1598 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1600 //_____________________________________________________________________________
1601 void TGeant3::Gdebug()
1604 // Debug the current step
1609 //_____________________________________________________________________________
1610 void TGeant3::Gekbin()
1613 // To find bin number in kinetic energy table
1614 // stored in ELOW(NEKBIN)
1619 //_____________________________________________________________________________
1620 void TGeant3::Gfinds()
1623 // Returns the set/volume parameters corresponding to
1624 // the current space point in /GCTRAK/
1625 // and fill common /GCSETS/
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
1638 //_____________________________________________________________________________
1639 void TGeant3::Gsking(Int_t igk)
1642 // Stores in stack JSTAK either the IGKth track of /GCKING/,
1643 // or the NGKINE tracks when IGK is 0.
1648 //_____________________________________________________________________________
1649 void TGeant3::Gskpho(Int_t igk)
1652 // Stores in stack JSTAK either the IGKth Cherenkov photon of
1653 // /GCKIN2/, or the NPHOT tracks when IGK is 0.
1658 //_____________________________________________________________________________
1659 void TGeant3::Gsstak(Int_t iflag)
1662 // Stores in auxiliary stack JSTAK the particle currently
1663 // described in common /GCKINE/.
1665 // On request, creates also an entry in structure JKINE :
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)
1675 //_____________________________________________________________________________
1676 void TGeant3::Gsxyz()
1679 // Store space point VECT in banks JXYZ
1684 //_____________________________________________________________________________
1685 void TGeant3::Gtrack()
1688 // Controls tracking of current particle
1693 //_____________________________________________________________________________
1694 void TGeant3::Gtreve()
1697 // Controls tracking of all particles belonging to the current event
1702 //_____________________________________________________________________________
1703 void TGeant3::Grndm(Float_t *rvec, const Int_t len) const
1706 // To generate a vector RVECV of LEN random numbers
1707 // Copy of the CERN Library routine RANECU
1711 //_____________________________________________________________________________
1712 void TGeant3::Grndmq(Int_t &is1, Int_t &is2, const Int_t iseq,
1713 const Text_t *chopt)
1716 // To set/retrieve the seed of the random number generator
1718 grndmq(is1,is2,iseq,PASSCHARD(chopt) PASSCHARL(chopt));
1721 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1723 // Functions from GDRAW
1725 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1727 //_____________________________________________________________________________
1728 void TGeant3::Gdxyz(Int_t it)
1731 // Draw the points stored with Gsxyz relative to track it
1736 //_____________________________________________________________________________
1737 void TGeant3::Gdcxyz()
1740 // Draw the position of the current track
1745 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1747 // Functions from GGEOM
1749 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1751 //_____________________________________________________________________________
1752 void TGeant3::Gdtom(Float_t *xd, Float_t *xm, Int_t iflag)
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)
1762 // If IFLAG=1 convert coordinates
1763 // IFLAG=2 convert direction cosinus
1765 gdtom(xd, xm, iflag);
1768 //_____________________________________________________________________________
1769 void TGeant3::Glmoth(const char* iudet, Int_t iunum, Int_t &nlev, Int_t *lvols,
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.
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.
1781 glmoth(PASSCHARD(iudet), iunum, nlev, lvols, lindx, idum PASSCHARL(iudet));
1784 //_____________________________________________________________________________
1785 void TGeant3::Gmedia(Float_t *x, Int_t &numed)
1788 // Finds in which volume/medium the point X is, and updates the
1789 // common /GCVOLU/ and the structure JGPAR accordingly.
1791 // NUMED returns the tracking medium number, or 0 if point is
1792 // outside the experimental setup.
1797 //_____________________________________________________________________________
1798 void TGeant3::Gmtod(Float_t *xm, Float_t *xd, Int_t iflag)
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)
1809 // If IFLAG=1 convert coordinates
1810 // IFLAG=2 convert direction cosinus
1812 gmtod(xm, xd, iflag);
1815 //_____________________________________________________________________________
1816 void TGeant3::Gsdvn(const char *name, const char *mother, Int_t ndiv,
1820 // Create a new volume by dividing an existing one
1823 // MOTHER Mother volume name
1824 // NDIV Number of divisions
1827 // X,Y,Z of CAXIS will be translated to 1,2,3 for IAXIS.
1828 // It divides a previously defined volume.
1833 Vname(mother,vmother);
1834 gsdvn(PASSCHARD(vname), PASSCHARD(vmother), ndiv, iaxis PASSCHARL(vname)
1835 PASSCHARL(vmother));
1838 //_____________________________________________________________________________
1839 void TGeant3::Gsdvn2(const char *name, const char *mother, Int_t ndiv,
1840 Int_t iaxis, Float_t c0i, Int_t numed)
1843 // Create a new volume by dividing an existing one
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.
1852 Vname(mother,vmother);
1853 gsdvn2(PASSCHARD(vname), PASSCHARD(vmother), ndiv, iaxis, c0i, numed
1854 PASSCHARL(vname) PASSCHARL(vmother));
1857 //_____________________________________________________________________________
1858 void TGeant3::Gsdvs(const char *name, const char *mother, Float_t step,
1859 Int_t iaxis, Int_t numed)
1862 // Create a new volume by dividing an existing one
1867 Vname(mother,vmother);
1868 gsdvs(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, numed
1869 PASSCHARL(vname) PASSCHARL(vmother));
1872 //_____________________________________________________________________________
1873 void TGeant3::Gsdvs2(const char *name, const char *mother, Float_t step,
1874 Int_t iaxis, Float_t c0, Int_t numed)
1877 // Create a new volume by dividing an existing one
1882 Vname(mother,vmother);
1883 gsdvs2(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, c0, numed
1884 PASSCHARL(vname) PASSCHARL(vmother));
1887 //_____________________________________________________________________________
1888 void TGeant3::Gsdvt(const char *name, const char *mother, Float_t step,
1889 Int_t iaxis, Int_t numed, Int_t ndvmx)
1892 // Create a new volume by dividing an existing one
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)
1905 Vname(mother,vmother);
1906 gsdvt(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, numed, ndvmx
1907 PASSCHARL(vname) PASSCHARL(vmother));
1910 //_____________________________________________________________________________
1911 void TGeant3::Gsdvt2(const char *name, const char *mother, Float_t step,
1912 Int_t iaxis, Float_t c0, Int_t numed, Int_t ndvmx)
1915 // Create a new volume by dividing an existing one
1917 // Divides MOTHER into divisions called NAME along
1918 // axis IAXIS starting at coordinate value C0 with 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)
1928 Vname(mother,vmother);
1929 gsdvt2(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, c0,
1930 numed, ndvmx PASSCHARL(vname) PASSCHARL(vmother));
1933 //_____________________________________________________________________________
1934 void TGeant3::Gsord(const char *name, Int_t iax)
1937 // Flags volume CHNAME whose contents will have to be ordered
1938 // along axis IAX, by setting the search flag to -IAX
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)
1951 gsord(PASSCHARD(vname), iax PASSCHARL(vname));
1954 //_____________________________________________________________________________
1955 void 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)
1959 // Position a volume into an existing one
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
1970 // It positions a previously defined volume in the mother.
1975 Vname(mother,vmother);
1976 gspos(PASSCHARD(vname), nr, PASSCHARD(vmother), x, y, z, irot,
1977 PASSCHARD(konly) PASSCHARL(vname) PASSCHARL(vmother)
1981 //_____________________________________________________________________________
1982 void 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 )
1987 // Place a copy of generic volume NAME with user number
1988 // NR inside MOTHER, with its parameters UPAR(1..NP)
1993 Vname(mother,vmother);
1994 gsposp(PASSCHARD(vname), nr, PASSCHARD(vmother), x, y, z, irot,
1995 PASSCHARD(konly), upar, np PASSCHARL(vname) PASSCHARL(vmother)
1999 //_____________________________________________________________________________
2000 void TGeant3::Gsrotm(Int_t nmat, Float_t theta1, Float_t phi1, Float_t theta2,
2001 Float_t phi2, Float_t theta3, Float_t phi3)
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
2012 // It defines the rotation matrix number IROT.
2014 gsrotm(nmat, theta1, phi1, theta2, phi2, theta3, phi3);
2017 //_____________________________________________________________________________
2018 void TGeant3::Gprotm(Int_t nmat)
2021 // To print rotation matrices structure JROTM
2022 // nmat Rotation matrix number
2027 //_____________________________________________________________________________
2028 Int_t TGeant3::Gsvolu(const char *name, const char *shape, Int_t nmed,
2029 Float_t *upar, Int_t npar)
2033 // SHAPE Volume type
2034 // NUMED Tracking medium number
2035 // NPAR Number of shape parameters
2036 // UPAR Vector containing shape parameters
2038 // It creates a new volume in the JVOLUM data structure.
2044 Vname(shape,vshape);
2045 gsvolu(PASSCHARD(vname), PASSCHARD(vshape), nmed, upar, npar, ivolu
2046 PASSCHARL(vname) PASSCHARL(vshape));
2050 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
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).
2100 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2102 //_____________________________________________________________________________
2103 void TGeant3::Gsatt(const char *name, const char *att, Int_t val)
2107 // IOPT Name of the attribute to be set
2108 // IVAL Value to which the attribute is to be set
2110 // name= "*" stands for all the volumes.
2111 // iopt can be chosen among the following :
2113 // WORK 0=volume name is inactive for the tracking
2114 // 1=volume name is active for the tracking (default)
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
2121 // LSTY line style 1,2,3,... (default=1)
2122 // LSTY=7 will produce a very precise approximation for
2123 // revolution bodies.
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.
2133 // COLO colour code -166,...,1,2,..166 (default=1)
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
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=.................
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.
2183 // SET set number associated to volume name
2184 // DET detector number associated to volume name
2185 // DTYP detector type (1,2)
2192 gsatt(PASSCHARD(vname), PASSCHARD(vatt), val PASSCHARL(vname)
2196 //_____________________________________________________________________________
2197 void TGeant3::Gfpara(const char *name, Int_t number, Int_t intext, Int_t& npar,
2198 Int_t& natt, Float_t* par, Float_t* att)
2201 // Find the parameters of a volume
2203 gfpara(PASSCHARD(name), number, intext, npar, natt, par, att
2207 //_____________________________________________________________________________
2208 void TGeant3::Gckpar(Int_t ish, Int_t npar, Float_t* par)
2211 // Check the parameters of a shape
2213 gckpar(ish,npar,par);
2216 //_____________________________________________________________________________
2217 void TGeant3::Gckmat(Int_t itmed, char* natmed)
2220 // Check the parameters of a tracking medium
2222 gckmat(itmed, PASSCHARD(natmed) PASSCHARL(natmed));
2225 //_____________________________________________________________________________
2226 void TGeant3::Gdelete(Int_t iview)
2229 // IVIEW View number
2231 // It deletes a view bank from memory.
2236 //_____________________________________________________________________________
2237 void TGeant3::Gdopen(Int_t iview)
2240 // IVIEW View number
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'
2256 //_____________________________________________________________________________
2257 void TGeant3::Gdclose()
2260 // It closes the currently open view bank; it must be called after the
2261 // end of the drawing to be stored.
2266 //_____________________________________________________________________________
2267 void TGeant3::Gdshow(Int_t iview)
2270 // IVIEW View number
2272 // It shows on the screen the contents of a view bank. It
2273 // can be called after a view bank has been closed.
2278 //_____________________________________________________________________________
2279 void TGeant3::Gdopt(const char *name,const char *value)
2283 // VALUE Option value
2285 // To set/modify the drawing options.
2288 // THRZ ON Draw tracks in R vs Z
2289 // OFF (D) Draw tracks in X,Y,Z
2292 // PROJ PARA (D) Parallel projection
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.
2313 Vname(value,vvalue);
2314 gdopt(PASSCHARD(vname), PASSCHARD(vvalue) PASSCHARL(vname)
2318 //_____________________________________________________________________________
2319 void 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)
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.
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).
2360 if (fGcvdma->raytra != 1) {
2361 gdraw(PASSCHARD(vname), theta,phi,psi,u0,v0,ul,vl PASSCHARL(vname));
2363 gdrayt(PASSCHARD(vname), theta,phi,psi,u0,v0,ul,vl PASSCHARL(vname));
2367 //_____________________________________________________________________________
2368 void TGeant3::Gdrawc(const char *name,Int_t axis, Float_t cut,Float_t u0,
2369 Float_t v0,Float_t ul,Float_t vl)
2374 // CUTVAL Cut plane distance from the origin along the axis
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.
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.
2391 gdrawc(PASSCHARD(vname), axis,cut,u0,v0,ul,vl PASSCHARL(vname));
2394 //_____________________________________________________________________________
2395 void 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)
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
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.
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.
2420 gdrawx(PASSCHARD(vname), cutthe,cutphi,cutval,theta,phi,u0,v0,ul,vl
2424 //_____________________________________________________________________________
2425 void TGeant3::Gdhead(Int_t isel, const char *name, Float_t chrsiz)
2430 // ISEL Option flag D=111110
2432 // CHRSIZ Character size (cm) of title NAME D=0.6
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.
2445 gdhead(isel,PASSCHARD(name),chrsiz PASSCHARL(name));
2448 //_____________________________________________________________________________
2449 void TGeant3::Gdman(Float_t u, Float_t v, const char *type)
2452 // Draw a 2D-man at position (U0,V0)
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'
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.
2464 if (opt.Contains("WM1")) {
2466 } else if (opt.Contains("WM3")) {
2468 } else if (opt.Contains("WM2")) {
2475 //_____________________________________________________________________________
2476 void TGeant3::Gdspec(const char *name)
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
2491 gdspec(PASSCHARD(vname) PASSCHARL(vname));
2494 //_____________________________________________________________________________
2495 void TGeant3::DrawOneSpec(const char *name)
2498 // Function called when one double-clicks on a volume name
2499 // in a TPavelabel drawn by Gdtree.
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");
2512 gdspec(PASSCHARD(vname) PASSCHARL(vname));
2515 higzSave->SetName("higz");
2519 //_____________________________________________________________________________
2520 void TGeant3::Gdtree(const char *name,Int_t levmax, Int_t isel)
2524 // LEVMAX Depth level
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:
2533 // - drawing tree of parent
2539 gdtree(PASSCHARD(vname), levmax, isel PASSCHARL(vname));
2543 //_____________________________________________________________________________
2544 void TGeant3::GdtreeParent(const char *name,Int_t levmax, Int_t isel)
2548 // LEVMAX Depth level
2551 // This function draws the logical tree of the parent of name.
2555 // Scan list of volumes in JVOLUM
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++) {
2565 num = Int_t(fZq[jin+2]);
2566 if(gname == fZiq[fGclink->jvolum+num]) {
2567 strncpy(vname,(char*)&fZiq[fGclink->jvolum+i],4);
2569 gdtree(PASSCHARD(vname), levmax, isel PASSCHARL(vname));
2577 //_____________________________________________________________________________
2578 void TGeant3::SetABAN(Int_t par)
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
2586 fGcphys->dphys1 = par;
2590 //_____________________________________________________________________________
2591 void TGeant3::SetANNI(Int_t par)
2594 // To control positron annihilation.
2595 // par =0 no annihilation
2596 // =1 annihilation. Decays processed.
2597 // =2 annihilation. No decay products stored.
2599 fGcphys->ianni = par;
2603 //_____________________________________________________________________________
2604 void TGeant3::SetAUTO(Int_t par)
2607 // To control automatic calculation of tracking medium parameters:
2608 // par =0 no automatic calculation;
2609 // =1 automati calculation.
2611 fGctrak->igauto = par;
2615 //_____________________________________________________________________________
2616 void TGeant3::SetBOMB(Float_t boom)
2619 // BOOM : Exploding factor for volumes position
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
2639 //_____________________________________________________________________________
2640 void TGeant3::SetBREM(Int_t par)
2643 // To control bremstrahlung.
2644 // par =0 no bremstrahlung
2645 // =1 bremstrahlung. Photon processed.
2646 // =2 bremstrahlung. No photon stored.
2648 fGcphys->ibrem = par;
2652 //_____________________________________________________________________________
2653 void TGeant3::SetCKOV(Int_t par)
2656 // To control Cerenkov production
2657 // par =0 no Cerenkov;
2659 // =2 Cerenkov with primary stopped at each step.
2661 fGctlit->itckov = par;
2665 //_____________________________________________________________________________
2666 void TGeant3::SetClipBox(const char *name,Float_t xmin,Float_t xmax,
2667 Float_t ymin,Float_t ymax,Float_t zmin,Float_t zmax)
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.
2682 // NAME Name of volume to be clipped
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
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
2698 setclip(PASSCHARD(vname),xmin,xmax,ymin,ymax,zmin,zmax PASSCHARL(vname));
2701 //_____________________________________________________________________________
2702 void TGeant3::SetCOMP(Int_t par)
2705 // To control Compton scattering
2706 // par =0 no Compton
2707 // =1 Compton. Electron processed.
2708 // =2 Compton. No electron stored.
2711 fGcphys->icomp = par;
2714 //_____________________________________________________________________________
2715 void 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)
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
2733 // If the default values (-1.) for BCUTE ,BCUTM ,DCUTE ,DCUTM
2734 // are not modified, they will be set to CUTGAM,CUTGAM,CUTELE,CUTELE
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.
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;
2753 //_____________________________________________________________________________
2754 void TGeant3::SetDCAY(Int_t par)
2757 // To control Decay mechanism.
2758 // par =0 no decays.
2759 // =1 Decays. secondaries processed.
2760 // =2 Decays. No secondaries stored.
2762 fGcphys->idcay = par;
2766 //_____________________________________________________________________________
2767 void TGeant3::SetDEBU(Int_t emin, Int_t emax, Int_t emod)
2770 // Set the debug flag and frequency
2771 // Selected debug output will be printed from
2772 // event emin to even emax each emod event
2774 fGcflag->idemin = emin;
2775 fGcflag->idemax = emax;
2776 fGcflag->itest = emod;
2780 //_____________________________________________________________________________
2781 void TGeant3::SetDRAY(Int_t par)
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.
2789 fGcphys->idray = par;
2792 //_____________________________________________________________________________
2793 void TGeant3::SetHADR(Int_t par)
2796 // To control hadronic interactions.
2797 // par =0 no hadronic interactions.
2798 // =1 Hadronic interactions. secondaries processed.
2799 // =2 Hadronic interactions. No secondaries stored.
2801 fGcphys->ihadr = par;
2804 //_____________________________________________________________________________
2805 void 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)
2810 // Set the variables in /GCFLAG/ IKINE, PKINE(10)
2811 // Their meaning is user defined
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;
2826 //_____________________________________________________________________________
2827 void TGeant3::SetLOSS(Int_t par)
2830 // To control energy loss.
2831 // par =0 no energy loss;
2832 // =1 restricted energy loss fluctuations;
2833 // =2 complete energy loss fluctuations;
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'.
2839 fGcphys->iloss = par;
2843 //_____________________________________________________________________________
2844 void TGeant3::SetMULS(Int_t par)
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.
2853 fGcphys->imuls = par;
2857 //_____________________________________________________________________________
2858 void TGeant3::SetMUNU(Int_t par)
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.
2866 fGcphys->imunu = par;
2869 //_____________________________________________________________________________
2870 void TGeant3::SetOPTI(Int_t par)
2873 // This flag controls the tracking optimisation performed via the
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.
2880 fGcopti->ioptim = par;
2883 //_____________________________________________________________________________
2884 void TGeant3::SetPAIR(Int_t par)
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.
2892 fGcphys->ipair = par;
2896 //_____________________________________________________________________________
2897 void TGeant3::SetPFIS(Int_t par)
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.
2905 fGcphys->ipfis = par;
2908 //_____________________________________________________________________________
2909 void TGeant3::SetPHOT(Int_t par)
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.
2917 fGcphys->iphot = par;
2920 //_____________________________________________________________________________
2921 void TGeant3::SetRAYL(Int_t par)
2924 // To control Rayleigh scattering.
2925 // par =0 no Rayleigh scattering.
2928 fGcphys->irayl = par;
2931 //_____________________________________________________________________________
2932 void TGeant3::SetSWIT(Int_t sw, Int_t val)
2936 // val New switch value
2938 // Change one element of array ISWIT(10) in /GCFLAG/
2940 if (sw <= 0 || sw > 10) return;
2941 fGcflag->iswit[sw-1] = val;
2945 //_____________________________________________________________________________
2946 void TGeant3::SetTRIG(Int_t nevents)
2949 // Set number of events to be run
2951 fGcflag->nevent = nevents;
2954 //______________________________________________________________________________
2955 void TGeant3::Vname(const char *name, char *vname)
2958 // convert name to upper case. Make vname at least 4 chars
2960 Int_t l = strlen(name);
2963 for (i=0;i<l;i++) vname[i] = toupper(name[i]);
2964 for (i=l;i<4;i++) vname[i] = ' ';
2968 //_____________________________________________________________________________
2969 void TGeant3::WriteEuclid(const char* filnam, const char* topvol,
2970 Int_t number, Int_t nlevel)
2974 // ******************************************************************
2976 // * Write out the geometry of the detector in EUCLID file format *
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 *
2984 // * Author : M. Maire *
2986 // ******************************************************************
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
2997 const char shape[][5]={"BOX ","TRD1","TRD2","TRAP","TUBE","TUBS","CONE",
2998 "CONS","SPHE","PARA","PGON","PCON","ELTU","HYPE",
3000 Int_t i, end, itm, irm, jrm, k, nmed;
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];
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;
3018 Int_t iomate[100], iotmed[100];
3019 Float_t par[50], att[20], ubuf[50];
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
3029 for(i=0;i<end;i++) if(filnam[i]=='.') {
3033 filext=new char[end+4];
3034 filetme=new char[end+4];
3035 strncpy(filext,filnam,end);
3036 strncpy(filetme,filnam,end);
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");
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];
3052 nwtot=iadrot+fGcnum->nrotm;
3053 qws = new float[nwtot+1];
3054 for (i=0;i<nwtot+1;i++) qws[i]=0;
3057 if(nlevel==0) mlevel=20;
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);
3063 printf(" *** GWEUCL *** top volume : %s number : %3d can not be a valid root\n",
3068 // *** authorized shape ?
3069 strncpy((char *)&iname, topvol, 4);
3071 for(i=1; i<=fGcnum->nvolum; i++) if(fZiq[fGclink->jvolum+i]==iname) {
3075 jvo = fZlq[fGclink->jvolum-ivo];
3076 ish = Int_t (fZq[jvo+2]);
3078 printf(" *** GWEUCL *** top volume : %s number : %3d can not be a valid root\n",
3085 iws[iadvol+ivo] = level;
3088 //*** flag all volumes and fill the stak
3092 // pick the next volume in stak
3094 ivo = TMath::Abs(iws[ivstak]);
3095 jvo = fZlq[fGclink->jvolum - ivo];
3097 // flag the tracking medium
3098 numed = Int_t (fZq[jvo + 4]);
3099 iws[iadtmd + numed] = 1;
3101 // get the daughters ...
3102 level = iws[iadvol+ivo];
3103 if (level < mlevel) {
3105 nin = Int_t (fZq[jvo + 3]);
3107 // from division ...
3109 jdiv = fZlq[jvo - 1];
3110 ivin = Int_t (fZq[jdiv + 2]);
3112 iws[nvstak] = -ivin;
3113 iws[iadvol+ivin] = level;
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 ?
3124 // not yet flagged ?
3125 if (iws[iadvol+ivin]==0) {
3128 iws[iadvol+ivin] = level;
3130 // flag the rotation matrix
3131 irot = Int_t ( fZq[jin + 4 ]);
3132 if (irot > 0) iws[iadrot+irot] = 1;
3138 // next volume in stak ?
3139 if (ivstak < nvstak) goto L10;
3141 // *** restore original material and media numbers
3142 // file euc_medi.dat is needed to compare materials and medias
3144 FILE* luncor=fopen("euc_medi.dat","r");
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];
3154 printf(" *** GWEUCL *** material not defined for tracking medium %5i %s\n",itm,natmed);
3157 strncpy(namate,(char *)&fZiq[jma+1],20);
3160 //** find the material original number
3163 iret=fscanf(luncor,"%4s,%130s",key,card);
3164 if(iret<=0) goto L26;
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) {
3174 printf("*** GWEUCL *** material : %3d '%s' restored as %3d\n",imat,namate,imatc);
3176 printf("*** GWEUCL *** different definitions for material: %s\n",namate);
3180 if(strcmp(key,"END") && !flag) goto L23;
3182 printf("*** GWEUCL *** cannot restore original number for material: %s\n",namate);
3186 //*** restore original tracking medium number
3189 iret=fscanf(luncor,"%4s,%130s",key,card);
3190 if(iret<=0) goto L26;
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) {
3202 printf("*** GWEUCL *** medium : %3d '%20s' restored as %3d\n",
3205 printf("*** GWEUCL *** different definitions for tracking medium: %s\n",natmed);
3209 if(strcmp(key,"END") && !flag) goto L24;
3211 printf("cannot restore original number for medium : %s\n",natmed);
3219 L26: printf("*** GWEUCL *** cannot read the data file\n");
3221 L29: if(luncor) fclose (luncor);
3224 // *** write down the tracking medium definition
3226 strcpy(card,"! Tracking medium");
3227 fprintf(lun,f10000,card);
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);
3234 imat = Int_t (fZq[jtm+6]);
3235 jma = fZlq[fGclink->jmate-imat];
3236 //* order media from one, if comparing with database failed
3238 iotmed[itm]=++imxtmed;
3239 iomate[imat]=++imxmate;
3244 printf(" *** GWEUCL *** material not defined for tracking medium %5d %s\n",
3247 strncpy(namate,(char *)&fZiq[jma+1],20);
3250 fprintf(lun,"TMED %3d '%20s' %3d '%20s'\n",iotmed[itm],natmed,iomate[imat],namate);
3254 //* *** write down the rotation matrix
3256 strcpy(card,"! Reperes");
3257 fprintf(lun,f10000,card);
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]);
3268 //* *** write down the volume definition
3270 strcpy(card,"! Volumes");
3271 fprintf(lun,f10000,card);
3273 for(ivstak=1;ivstak<=nvstak;ivstak++) {
3276 strncpy(name,(char *)&fZiq[fGclink->jvolum+ivo],4);
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]);
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++) {
3289 for(k=0;k<(left<6?left:6);k++) fprintf(lun," %11.5f",par[i*6+k]);
3293 fprintf(lun,"VOLU '%4s' '%4s' %3d %3d\n",name,shape[ish-1],iotmed[nmed],npar);
3298 //* *** write down the division of volumes
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 ...
3309 iaxe = Int_t ( fZq[jdiv+1]);
3310 ivin = Int_t ( fZq[jdiv+2]);
3311 ndiv = Int_t ( fZq[jdiv+3]);
3314 jvin = fZlq[fGclink->jvolum-ivin];
3315 nmed = Int_t ( fZq[jvin+4]);
3316 strncpy(mother,(char *)&fZiq[fGclink->jvolum+ivo ],4);
3318 strncpy(name,(char *)&fZiq[fGclink->jvolum+ivin],4);
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);
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);
3336 //* *** write down the the positionnement of volumes
3338 fprintf(lun,f10000,"! Positionnements\n");
3340 for(ivstak = 1;ivstak<=nvstak;ivstak++) {
3341 ivo = TMath::Abs(iws[ivstak]);
3342 strncpy(mother,(char*)&fZiq[fGclink->jvolum+ivo ],4);
3344 jvo = fZlq[fGclink->jvolum-ivo];
3345 nin = Int_t( fZq[jvo+3]);
3346 //* this volume has daughters ...
3348 for (in=1;in<=nin;in++) {
3350 ivin = Int_t (fZq[jin +2]);
3351 numb = Int_t (fZq[jin +3]);
3352 irot = Int_t (fZq[jin +4]);
3356 strcpy(konly,"ONLY");
3357 if (fZq[jin+8]!=1.) strcpy(konly,"MANY");
3358 strncpy(name,(char*)&fZiq[fGclink->jvolum+ivin],4);
3360 jvin = fZlq[fGclink->jvolum-ivin];
3361 ish = Int_t (fZq[jvin+2]);
3362 //* gspos or gsposp ?
3363 ndata = fZiq[jin-1];
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);
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);
3374 for(i=0;i<npar;i++) fprintf(lun," %11.5f",par[i]);
3381 fprintf(lun,"END\n");
3384 //****** write down the materials and medias *****
3386 lun=fopen(filetme,"w");
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]);
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);
3401 for(i=0;i<npar;i++) fprintf(lun," %11.5f",par[i]);
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);
3412 for(i=0;i<npar;i++) fprintf(lun," %11.5f",par[i]);
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);
3429 //_____________________________________________________________________________
3430 void TGeant3::Streamer(TBuffer &R__b)
3433 // Stream an object of class TGeant3.
3435 if (R__b.IsReading()) {
3436 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
3437 AliMC::Streamer(R__b);
3440 R__b.WriteVersion(TGeant3::IsA());
3441 AliMC::Streamer(R__b);