1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 Revision 1.35 2000/09/12 14:27:10 morsch
19 No instance of AliDecayer created to initialize fDecayer.
21 Revision 1.34 2000/09/07 12:12:01 morsch
22 Comment inside comment removed.
24 Revision 1.33 2000/09/06 16:03:42 morsch
25 Set ExternalDecayer, Decayer and SetForceDecay methods added.
26 Gspart calls for charmed and bottom hadrons added.
27 Decay mode definitions for charmed and beauty hadrons have been taken out.
28 They will be handled by an external decayer.
30 Revision 1.32 2000/08/24 16:28:53 hristov
31 TGeant3::IsNewTrack corrected by F.Carminati
33 Revision 1.31 2000/07/13 16:19:10 fca
34 Mainly coding conventions + some small bug fixes
36 Revision 1.30 2000/07/12 08:56:30 fca
37 Coding convention correction and warning removal
39 Revision 1.29 2000/07/11 18:24:59 fca
40 Coding convention corrections + few minor bug fixes
42 Revision 1.28 2000/06/29 10:51:55 morsch
43 Add some charmed and bottom baryons to the particle list (TDatabasePDG). This
44 is needed by Hijing. Should be part of a future review of TDatabasePDG.
46 Revision 1.27 2000/06/21 17:40:15 fca
47 Adding possibility to set ISTRA, PAI model
49 Revision 1.26 2000/05/16 13:10:41 fca
50 New method IsNewTrack and fix for a problem in Father-Daughter relations
52 Revision 1.25 2000/04/07 11:12:35 fca
53 G4 compatibility changes
55 Revision 1.24 2000/02/28 21:03:57 fca
56 Some additions to improve the compatibility with G4
58 Revision 1.23 2000/02/23 16:25:25 fca
59 AliVMC and AliGeant3 classes introduced
60 ReadEuclid moved from AliRun to AliModule
62 Revision 1.22 2000/01/18 15:40:13 morsch
63 Interface to GEANT3 routines GFTMAT, GBRELM and GPRELM added
64 Define geant particle type 51: Feedback Photon with Cherenkov photon properties.
66 Revision 1.21 2000/01/17 19:41:17 fca
69 Revision 1.20 2000/01/12 11:29:27 fca
72 Revision 1.19 1999/12/17 09:03:12 fca
73 Introduce a names array
75 Revision 1.18 1999/11/26 16:55:39 fca
76 Reimplement CurrentVolName() to avoid memory leaks
78 Revision 1.17 1999/11/03 16:58:28 fca
79 Correct source of address violation in creating character string
81 Revision 1.16 1999/11/03 13:17:08 fca
82 Have ProdProcess return const char*
84 Revision 1.15 1999/10/26 06:04:50 fca
85 Introduce TLorentzVector in AliMC::GetSecondary. Thanks to I.Hrivnacova
87 Revision 1.14 1999/09/29 09:24:30 fca
88 Introduction of the Copyright and cvs Log
92 ///////////////////////////////////////////////////////////////////////////////
94 // Interface Class to the Geant3.21 MonteCarlo //
98 <img src="picts/TGeant3Class.gif">
103 ///////////////////////////////////////////////////////////////////////////////
109 #include <TDatabasePDG.h>
110 #include "AliCallf77.h"
111 #include "AliDecayer.h"
114 # define gzebra gzebra_
115 # define grfile grfile_
116 # define gpcxyz gpcxyz_
117 # define ggclos ggclos_
118 # define glast glast_
119 # define ginit ginit_
120 # define gcinit gcinit_
122 # define gtrig gtrig_
123 # define gtrigc gtrigc_
124 # define gtrigi gtrigi_
125 # define gwork gwork_
126 # define gzinit gzinit_
127 # define gfmate gfmate_
128 # define gfpart gfpart_
129 # define gftmed gftmed_
130 # define gftmat gftmat_
131 # define gmate gmate_
132 # define gpart gpart_
134 # define gsmate gsmate_
135 # define gsmixt gsmixt_
136 # define gspart gspart_
137 # define gstmed gstmed_
138 # define gsckov gsckov_
139 # define gstpar gstpar_
140 # define gfkine gfkine_
141 # define gfvert gfvert_
142 # define gskine gskine_
143 # define gsvert gsvert_
144 # define gphysi gphysi_
145 # define gdebug gdebug_
146 # define gekbin gekbin_
147 # define gfinds gfinds_
148 # define gsking gsking_
149 # define gskpho gskpho_
150 # define gsstak gsstak_
151 # define gsxyz gsxyz_
152 # define gtrack gtrack_
153 # define gtreve gtreve_
154 # define gtreveroot gtreveroot_
155 # define grndm grndm_
156 # define grndmq grndmq_
157 # define gdtom gdtom_
158 # define glmoth glmoth_
159 # define gmedia gmedia_
160 # define gmtod gmtod_
161 # define gsdvn gsdvn_
162 # define gsdvn2 gsdvn2_
163 # define gsdvs gsdvs_
164 # define gsdvs2 gsdvs2_
165 # define gsdvt gsdvt_
166 # define gsdvt2 gsdvt2_
167 # define gsord gsord_
168 # define gspos gspos_
169 # define gsposp gsposp_
170 # define gsrotm gsrotm_
171 # define gprotm gprotm_
172 # define gsvolu gsvolu_
173 # define gprint gprint_
174 # define gdinit gdinit_
175 # define gdopt gdopt_
176 # define gdraw gdraw_
177 # define gdrayt gdrayt_
178 # define gdrawc gdrawc_
179 # define gdrawx gdrawx_
180 # define gdhead gdhead_
181 # define gdwmn1 gdwmn1_
182 # define gdwmn2 gdwmn2_
183 # define gdwmn3 gdwmn3_
184 # define gdxyz gdxyz_
185 # define gdcxyz gdcxyz_
186 # define gdman gdman_
187 # define gdspec gdspec_
188 # define gdtree gdtree_
189 # define gdelet gdelet_
190 # define gdclos gdclos_
191 # define gdshow gdshow_
192 # define gdopen gdopen_
193 # define dzshow dzshow_
194 # define gsatt gsatt_
195 # define gfpara gfpara_
196 # define gckpar gckpar_
197 # define gckmat gckmat_
198 # define glvolu glvolu_
199 # define geditv geditv_
200 # define mzdrop mzdrop_
202 # define ertrak ertrak_
203 # define ertrgo ertrgo_
205 # define setbomb setbomb_
206 # define setclip setclip_
207 # define gcomad gcomad_
209 # define gbrelm gbrelm_
210 # define gprelm gprelm_
212 # define gzebra GZEBRA
213 # define grfile GRFILE
214 # define gpcxyz GPCXYZ
215 # define ggclos GGCLOS
218 # define gcinit GCINIT
221 # define gtrigc GTRIGC
222 # define gtrigi GTRIGI
224 # define gzinit GZINIT
225 # define gfmate GFMATE
226 # define gfpart GFPART
227 # define gftmed GFTMED
228 # define gftmat GFTMAT
232 # define gsmate GSMATE
233 # define gsmixt GSMIXT
234 # define gspart GSPART
235 # define gstmed GSTMED
236 # define gsckov GSCKOV
237 # define gstpar GSTPAR
238 # define gfkine GFKINE
239 # define gfvert GFVERT
240 # define gskine GSKINE
241 # define gsvert GSVERT
242 # define gphysi GPHYSI
243 # define gdebug GDEBUG
244 # define gekbin GEKBIN
245 # define gfinds GFINDS
246 # define gsking GSKING
247 # define gskpho GSKPHO
248 # define gsstak GSSTAK
250 # define gtrack GTRACK
251 # define gtreve GTREVE
252 # define gtreveroot GTREVEROOT
254 # define grndmq GRNDMQ
256 # define glmoth GLMOTH
257 # define gmedia GMEDIA
260 # define gsdvn2 GSDVN2
262 # define gsdvs2 GSDVS2
264 # define gsdvt2 GSDVT2
267 # define gsposp GSPOSP
268 # define gsrotm GSROTM
269 # define gprotm GPROTM
270 # define gsvolu GSVOLU
271 # define gprint GPRINT
272 # define gdinit GDINIT
275 # define gdrayt GDRAYT
276 # define gdrawc GDRAWC
277 # define gdrawx GDRAWX
278 # define gdhead GDHEAD
279 # define gdwmn1 GDWMN1
280 # define gdwmn2 GDWMN2
281 # define gdwmn3 GDWMN3
283 # define gdcxyz GDCXYZ
285 # define gdfspc GDFSPC
286 # define gdspec GDSPEC
287 # define gdtree GDTREE
288 # define gdelet GDELET
289 # define gdclos GDCLOS
290 # define gdshow GDSHOW
291 # define gdopen GDOPEN
292 # define dzshow DZSHOW
294 # define gfpara GFPARA
295 # define gckpar GCKPAR
296 # define gckmat GCKMAT
297 # define glvolu GLVOLU
298 # define geditv GEDITV
299 # define mzdrop MZDROP
301 # define ertrak ERTRAK
302 # define ertrgo ERTRGO
304 # define setbomb SETBOMB
305 # define setclip SETCLIP
306 # define gcomad GCOMAD
308 # define gbrelm GBRELM
309 # define gprelm GPRELM
313 //____________________________________________________________________________
317 // Prototypes for GEANT functions
319 void type_of_call gzebra(const int&);
321 void type_of_call gpcxyz();
323 void type_of_call ggclos();
325 void type_of_call glast();
327 void type_of_call ginit();
329 void type_of_call gcinit();
331 void type_of_call grun();
333 void type_of_call gtrig();
335 void type_of_call gtrigc();
337 void type_of_call gtrigi();
339 void type_of_call gwork(const int&);
341 void type_of_call gzinit();
343 void type_of_call gmate();
345 void type_of_call gpart();
347 void type_of_call gsdk(Int_t &, Float_t *, Int_t *);
349 void type_of_call gfkine(Int_t &, Float_t *, Float_t *, Int_t &,
350 Int_t &, Float_t *, Int_t &);
352 void type_of_call gfvert(Int_t &, Float_t *, Int_t &, Int_t &,
353 Float_t &, Float_t *, Int_t &);
355 void type_of_call gskine(Float_t *,Int_t &, Int_t &, Float_t *,
358 void type_of_call gsvert(Float_t *,Int_t &, Int_t &, Float_t *,
361 void type_of_call gphysi();
363 void type_of_call gdebug();
365 void type_of_call gekbin();
367 void type_of_call gfinds();
369 void type_of_call gsking(Int_t &);
371 void type_of_call gskpho(Int_t &);
373 void type_of_call gsstak(Int_t &);
375 void type_of_call gsxyz();
377 void type_of_call gtrack();
379 void type_of_call gtreve();
381 void type_of_call gtreveroot();
383 void type_of_call grndm(Float_t *, const Int_t &);
385 void type_of_call grndmq(Int_t &, Int_t &, const Int_t &,
388 void type_of_call gdtom(Float_t *, Float_t *, Int_t &);
390 void type_of_call glmoth(DEFCHARD, Int_t &, Int_t &, Int_t *,
391 Int_t *, Int_t * DEFCHARL);
393 void type_of_call gmedia(Float_t *, Int_t &);
395 void type_of_call gmtod(Float_t *, Float_t *, Int_t &);
397 void type_of_call gsrotm(const Int_t &, const Float_t &, const Float_t &,
398 const Float_t &, const Float_t &, const Float_t &,
401 void type_of_call gprotm(const Int_t &);
403 void type_of_call grfile(const Int_t&, DEFCHARD,
404 DEFCHARD DEFCHARL DEFCHARL);
406 void type_of_call gfmate(const Int_t&, DEFCHARD, Float_t &, Float_t &,
407 Float_t &, Float_t &, Float_t &, Float_t *,
410 void type_of_call gfpart(const Int_t&, DEFCHARD, Int_t &, Float_t &,
411 Float_t &, Float_t &, Float_t *, Int_t & DEFCHARL);
413 void type_of_call gftmed(const Int_t&, DEFCHARD, Int_t &, Int_t &, Int_t &,
414 Float_t &, Float_t &, Float_t &, Float_t &,
415 Float_t &, Float_t &, Float_t *, Int_t * DEFCHARL);
417 void type_of_call gftmat(const Int_t&, const Int_t&, DEFCHARD, const Int_t&,
419 ,Float_t *, Int_t & DEFCHARL);
421 void type_of_call gsmate(const Int_t&, DEFCHARD, Float_t &, Float_t &,
422 Float_t &, Float_t &, Float_t &, Float_t *,
425 void type_of_call gsmixt(const Int_t&, DEFCHARD, Float_t *, Float_t *,
426 Float_t &, Int_t &, Float_t * DEFCHARL);
428 void type_of_call gspart(const Int_t&, DEFCHARD, Int_t &, Float_t &,
429 Float_t &, Float_t &, Float_t *, Int_t & DEFCHARL);
432 void type_of_call gstmed(const Int_t&, DEFCHARD, Int_t &, Int_t &, Int_t &,
433 Float_t &, Float_t &, Float_t &, Float_t &,
434 Float_t &, Float_t &, Float_t *, Int_t & DEFCHARL);
436 void type_of_call gsckov(Int_t &itmed, Int_t &npckov, Float_t *ppckov,
437 Float_t *absco, Float_t *effic, Float_t *rindex);
438 void type_of_call gstpar(const Int_t&, DEFCHARD, Float_t & DEFCHARL);
440 void type_of_call gsdvn(DEFCHARD,DEFCHARD, Int_t &, Int_t &
443 void type_of_call gsdvn2(DEFCHARD,DEFCHARD, Int_t &, Int_t &, Float_t &,
444 Int_t & DEFCHARL DEFCHARL);
446 void type_of_call gsdvs(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Int_t &
449 void type_of_call gsdvs2(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Float_t &,
450 Int_t & DEFCHARL DEFCHARL);
452 void type_of_call gsdvt(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Int_t &,
453 Int_t & DEFCHARL DEFCHARL);
455 void type_of_call gsdvt2(DEFCHARD,DEFCHARD, Float_t &, Int_t &, Float_t&,
456 Int_t &, Int_t & DEFCHARL DEFCHARL);
458 void type_of_call gsord(DEFCHARD, Int_t & DEFCHARL);
460 void type_of_call gspos(DEFCHARD, Int_t &, DEFCHARD, Float_t &, Float_t &,
461 Float_t &, Int_t &, DEFCHARD DEFCHARL DEFCHARL
464 void type_of_call gsposp(DEFCHARD, Int_t &, DEFCHARD, Float_t &, Float_t &,
465 Float_t &, Int_t &, DEFCHARD,
466 Float_t *, Int_t & DEFCHARL DEFCHARL DEFCHARL);
468 void type_of_call gsvolu(DEFCHARD, DEFCHARD, Int_t &, Float_t *, Int_t &,
469 Int_t & DEFCHARL DEFCHARL);
471 void type_of_call gsatt(DEFCHARD, DEFCHARD, Int_t & DEFCHARL DEFCHARL);
473 void type_of_call gfpara(DEFCHARD , Int_t&, Int_t&, Int_t&, Int_t&, Float_t*,
476 void type_of_call gckpar(Int_t&, Int_t&, Float_t*);
478 void type_of_call gckmat(Int_t&, DEFCHARD DEFCHARL);
480 void type_of_call glvolu(Int_t&, Int_t*, Int_t*, Int_t&);
482 void type_of_call gprint(DEFCHARD,const int& DEFCHARL);
484 void type_of_call gdinit();
486 void type_of_call gdopt(DEFCHARD,DEFCHARD DEFCHARL DEFCHARL);
488 void type_of_call gdraw(DEFCHARD,Float_t &,Float_t &, Float_t &,Float_t &,
489 Float_t &, Float_t &, Float_t & DEFCHARL);
490 void type_of_call gdrayt(DEFCHARD,Float_t &,Float_t &, Float_t &,Float_t &,
491 Float_t &, Float_t &, Float_t & DEFCHARL);
492 void type_of_call gdrawc(DEFCHARD,Int_t &, Float_t &, Float_t &, Float_t &,
493 Float_t &, Float_t & DEFCHARL);
494 void type_of_call gdrawx(DEFCHARD,Float_t &, Float_t &, Float_t &, Float_t &,
495 Float_t &, Float_t &, Float_t &, Float_t &,
497 void type_of_call gdhead(Int_t &,DEFCHARD, Float_t & DEFCHARL);
498 void type_of_call gdxyz(Int_t &);
499 void type_of_call gdcxyz();
500 void type_of_call gdman(Float_t &, Float_t &);
501 void type_of_call gdwmn1(Float_t &, Float_t &);
502 void type_of_call gdwmn2(Float_t &, Float_t &);
503 void type_of_call gdwmn3(Float_t &, Float_t &);
504 void type_of_call gdspec(DEFCHARD DEFCHARL);
505 void type_of_call gdfspc(DEFCHARD, Int_t &, Int_t & DEFCHARL) {;}
506 void type_of_call gdtree(DEFCHARD, Int_t &, Int_t & DEFCHARL);
508 void type_of_call gdopen(Int_t &);
509 void type_of_call gdclos();
510 void type_of_call gdelet(Int_t &);
511 void type_of_call gdshow(Int_t &);
512 void type_of_call geditv(Int_t &) {;}
515 void type_of_call dzshow(DEFCHARD,const int&,const int&,DEFCHARD,const int&,
516 const int&, const int&, const int& DEFCHARL
519 void type_of_call mzdrop(Int_t&, Int_t&, DEFCHARD DEFCHARL);
521 void type_of_call setbomb(Float_t &);
522 void type_of_call setclip(DEFCHARD, Float_t &,Float_t &,Float_t &,Float_t &,
523 Float_t &, Float_t & DEFCHARL);
524 void type_of_call gcomad(DEFCHARD, Int_t*& DEFCHARL);
526 void type_of_call ertrak(const Float_t *const x1, const Float_t *const p1,
527 const Float_t *x2, const Float_t *p2,
528 const Int_t &ipa, DEFCHARD DEFCHARL);
530 void type_of_call ertrgo();
532 float type_of_call gbrelm(const Float_t &z, const Float_t& t, const Float_t& cut);
533 float type_of_call gprelm(const Float_t &z, const Float_t& t, const Float_t& cut);
537 // Geant3 global pointer
539 static const Int_t kDefSize = 600;
543 //____________________________________________________________________________
547 // Default constructor
551 //____________________________________________________________________________
552 TGeant3::TGeant3(const char *title, Int_t nwgeant)
553 :AliMC("TGeant3",title)
556 // Standard constructor for TGeant3 with ZEBRA initialisation
567 // Load Address of Geant3 commons
570 // Zero number of particles
575 //____________________________________________________________________________
576 Int_t TGeant3::CurrentMaterial(Float_t &a, Float_t &z, Float_t &dens,
577 Float_t &radl, Float_t &absl) const
580 // Return the parameters of the current material during transport
584 dens = fGcmate->dens;
585 radl = fGcmate->radl;
586 absl = fGcmate->absl;
587 return 1; //this could be the number of elements in mixture
590 //____________________________________________________________________________
591 void TGeant3::DefaultRange()
594 // Set range of current drawing pad to 20x20 cm
600 gHigz->Range(0,0,20,20);
603 //____________________________________________________________________________
604 void TGeant3::InitHIGZ()
615 //____________________________________________________________________________
616 void TGeant3::LoadAddress()
619 // Assigns the address of the GEANT common blocks to the structures
620 // that allow their access from C++
623 gcomad(PASSCHARD("QUEST"), (int*&) fQuest PASSCHARL("QUEST"));
624 gcomad(PASSCHARD("GCBANK"),(int*&) fGcbank PASSCHARL("GCBANK"));
625 gcomad(PASSCHARD("GCLINK"),(int*&) fGclink PASSCHARL("GCLINK"));
626 gcomad(PASSCHARD("GCCUTS"),(int*&) fGccuts PASSCHARL("GCCUTS"));
627 gcomad(PASSCHARD("GCMULO"),(int*&) fGcmulo PASSCHARL("GCMULO"));
628 gcomad(PASSCHARD("GCFLAG"),(int*&) fGcflag PASSCHARL("GCFLAG"));
629 gcomad(PASSCHARD("GCKINE"),(int*&) fGckine PASSCHARL("GCKINE"));
630 gcomad(PASSCHARD("GCKING"),(int*&) fGcking PASSCHARL("GCKING"));
631 gcomad(PASSCHARD("GCKIN2"),(int*&) fGckin2 PASSCHARL("GCKIN2"));
632 gcomad(PASSCHARD("GCKIN3"),(int*&) fGckin3 PASSCHARL("GCKIN3"));
633 gcomad(PASSCHARD("GCMATE"),(int*&) fGcmate PASSCHARL("GCMATE"));
634 gcomad(PASSCHARD("GCTMED"),(int*&) fGctmed PASSCHARL("GCTMED"));
635 gcomad(PASSCHARD("GCTRAK"),(int*&) fGctrak PASSCHARL("GCTRAK"));
636 gcomad(PASSCHARD("GCTPOL"),(int*&) fGctpol PASSCHARL("GCTPOL"));
637 gcomad(PASSCHARD("GCVOLU"),(int*&) fGcvolu PASSCHARL("GCVOLU"));
638 gcomad(PASSCHARD("GCNUM"), (int*&) fGcnum PASSCHARL("GCNUM"));
639 gcomad(PASSCHARD("GCSETS"),(int*&) fGcsets PASSCHARL("GCSETS"));
640 gcomad(PASSCHARD("GCPHYS"),(int*&) fGcphys PASSCHARL("GCPHYS"));
641 gcomad(PASSCHARD("GCPHLT"),(int*&) fGcphlt PASSCHARL("GCPHLT"));
642 gcomad(PASSCHARD("GCOPTI"),(int*&) fGcopti PASSCHARL("GCOPTI"));
643 gcomad(PASSCHARD("GCTLIT"),(int*&) fGctlit PASSCHARL("GCTLIT"));
644 gcomad(PASSCHARD("GCVDMA"),(int*&) fGcvdma PASSCHARL("GCVDMA"));
647 gcomad(PASSCHARD("ERTRIO"),(int*&) fErtrio PASSCHARL("ERTRIO"));
648 gcomad(PASSCHARD("EROPTS"),(int*&) fEropts PASSCHARL("EROPTS"));
649 gcomad(PASSCHARD("EROPTC"),(int*&) fEroptc PASSCHARL("EROPTC"));
650 gcomad(PASSCHARD("ERWORK"),(int*&) fErwork PASSCHARL("ERWORK"));
652 // Variables for ZEBRA store
653 gcomad(PASSCHARD("IQ"), addr PASSCHARL("IQ"));
655 gcomad(PASSCHARD("LQ"), addr PASSCHARL("LQ"));
660 //_____________________________________________________________________________
661 void TGeant3::GeomIter()
664 // Geometry iterator for moving upward in the geometry tree
665 // Initialise the iterator
667 fNextVol=fGcvolu->nlevel;
670 //____________________________________________________________________________
671 void TGeant3::FinishGeometry()
673 //Close the geometry structure
677 //____________________________________________________________________________
678 Int_t TGeant3::NextVolUp(Text_t *name, Int_t ©)
681 // Geometry iterator for moving upward in the geometry tree
682 // Return next volume up
687 gname=fGcvolu->names[fNextVol];
688 copy=fGcvolu->number[fNextVol];
689 i=fGcvolu->lvolum[fNextVol];
690 name = fVolNames[i-1];
691 if(gname == fZiq[fGclink->jvolum+i]) return i;
692 else printf("GeomTree: Volume %s not found in bank\n",name);
697 //_____________________________________________________________________________
698 void TGeant3::BuildPhysics()
703 //_____________________________________________________________________________
704 Int_t TGeant3::CurrentVolID(Int_t ©) const
707 // Returns the current volume ID and copy number
710 if( (i=fGcvolu->nlevel-1) < 0 ) {
711 Warning("CurrentVolID","Stack depth only %d\n",fGcvolu->nlevel);
713 gname=fGcvolu->names[i];
714 copy=fGcvolu->number[i];
715 i=fGcvolu->lvolum[i];
716 if(gname == fZiq[fGclink->jvolum+i]) return i;
717 else Warning("CurrentVolID","Volume %4s not found\n",(char*)&gname);
722 //_____________________________________________________________________________
723 Int_t TGeant3::CurrentVolOffID(Int_t off, Int_t ©) const
726 // Return the current volume "off" upward in the geometrical tree
727 // ID and copy number
730 if( (i=fGcvolu->nlevel-off-1) < 0 ) {
731 Warning("CurrentVolOffID","Offset requested %d but stack depth %d\n",
732 off,fGcvolu->nlevel);
734 gname=fGcvolu->names[i];
735 copy=fGcvolu->number[i];
736 i=fGcvolu->lvolum[i];
737 if(gname == fZiq[fGclink->jvolum+i]) return i;
738 else Warning("CurrentVolOffID","Volume %4s not found\n",(char*)&gname);
743 //_____________________________________________________________________________
744 const char* TGeant3::CurrentVolName() const
747 // Returns the current volume name
750 if( (i=fGcvolu->nlevel-1) < 0 ) {
751 Warning("CurrentVolName","Stack depth %d\n",fGcvolu->nlevel);
753 gname=fGcvolu->names[i];
754 i=fGcvolu->lvolum[i];
755 if(gname == fZiq[fGclink->jvolum+i]) return fVolNames[i-1];
756 else Warning("CurrentVolName","Volume %4s not found\n",(char*) &gname);
761 //_____________________________________________________________________________
762 const char* TGeant3::CurrentVolOffName(Int_t off) const
765 // Return the current volume "off" upward in the geometrical tree
766 // ID, name and copy number
767 // if name=0 no name is returned
770 if( (i=fGcvolu->nlevel-off-1) < 0 ) {
771 Warning("CurrentVolOffName",
772 "Offset requested %d but stack depth %d\n",off,fGcvolu->nlevel);
774 gname=fGcvolu->names[i];
775 i=fGcvolu->lvolum[i];
776 if(gname == fZiq[fGclink->jvolum+i]) return fVolNames[i-1];
777 else Warning("CurrentVolOffName","Volume %4s not found\n",(char*)&gname);
782 //_____________________________________________________________________________
783 Int_t TGeant3::IdFromPDG(Int_t pdg) const
786 // Return Geant3 code from PDG and pseudo ENDF code
788 for(Int_t i=0;i<fNPDGCodes;++i)
789 if(pdg==fPDGCode[i]) return i;
793 //_____________________________________________________________________________
794 Int_t TGeant3::PDGFromId(Int_t id) const
797 // Return PDG code and pseudo ENDF code from Geant3 code
799 if(id>0 && id<fNPDGCodes) return fPDGCode[id];
803 //_____________________________________________________________________________
804 void TGeant3::DefineParticles()
807 // Define standard Geant 3 particles
810 // Load standard numbers for GEANT particles and PDG conversion
811 fPDGCode[fNPDGCodes++]=-99; // 0 = unused location
812 fPDGCode[fNPDGCodes++]=22; // 1 = photon
813 fPDGCode[fNPDGCodes++]=-11; // 2 = positron
814 fPDGCode[fNPDGCodes++]=11; // 3 = electron
815 fPDGCode[fNPDGCodes++]=12; // 4 = neutrino e
816 fPDGCode[fNPDGCodes++]=-13; // 5 = muon +
817 fPDGCode[fNPDGCodes++]=13; // 6 = muon -
818 fPDGCode[fNPDGCodes++]=111; // 7 = pi0
819 fPDGCode[fNPDGCodes++]=211; // 8 = pi+
820 fPDGCode[fNPDGCodes++]=-211; // 9 = pi-
821 fPDGCode[fNPDGCodes++]=130; // 10 = Kaon Long
822 fPDGCode[fNPDGCodes++]=321; // 11 = Kaon +
823 fPDGCode[fNPDGCodes++]=-321; // 12 = Kaon -
824 fPDGCode[fNPDGCodes++]=2112; // 13 = Neutron
825 fPDGCode[fNPDGCodes++]=2212; // 14 = Proton
826 fPDGCode[fNPDGCodes++]=-2212; // 15 = Anti Proton
827 fPDGCode[fNPDGCodes++]=310; // 16 = Kaon Short
828 fPDGCode[fNPDGCodes++]=221; // 17 = Eta
829 fPDGCode[fNPDGCodes++]=3122; // 18 = Lambda
830 fPDGCode[fNPDGCodes++]=3222; // 19 = Sigma +
831 fPDGCode[fNPDGCodes++]=3212; // 20 = Sigma 0
832 fPDGCode[fNPDGCodes++]=3112; // 21 = Sigma -
833 fPDGCode[fNPDGCodes++]=3322; // 22 = Xi0
834 fPDGCode[fNPDGCodes++]=3312; // 23 = Xi-
835 fPDGCode[fNPDGCodes++]=3334; // 24 = Omega-
836 fPDGCode[fNPDGCodes++]=-2112; // 25 = Anti Proton
837 fPDGCode[fNPDGCodes++]=-3122; // 26 = Anti Proton
838 fPDGCode[fNPDGCodes++]=-3222; // 27 = Anti Sigma -
839 fPDGCode[fNPDGCodes++]=-3212; // 28 = Anti Sigma 0
840 fPDGCode[fNPDGCodes++]=-3112; // 29 = Anti Sigma 0
841 fPDGCode[fNPDGCodes++]=-3322; // 30 = Anti Xi 0
842 fPDGCode[fNPDGCodes++]=-3312; // 31 = Anti Xi +
843 fPDGCode[fNPDGCodes++]=-3334; // 32 = Anti Omega +
850 /* --- Define additional particles */
851 Gspart(33, "OMEGA(782)", 3, 0.782, 0., 7.836e-23);
852 fPDGCode[fNPDGCodes++]=223; // 33 = Omega(782)
854 Gspart(34, "PHI(1020)", 3, 1.019, 0., 1.486e-22);
855 fPDGCode[fNPDGCodes++]=333; // 34 = PHI (1020)
857 Gspart(35, "D +", 4, 1.87, 1., 1.066e-12);
858 fPDGCode[fNPDGCodes++]=411; // 35 = D+
860 Gspart(36, "D -", 4, 1.87, -1., 1.066e-12);
861 fPDGCode[fNPDGCodes++]=-411; // 36 = D-
863 Gspart(37, "D 0", 3, 1.865, 0., 4.2e-13);
864 fPDGCode[fNPDGCodes++]=421; // 37 = D0
866 Gspart(38, "ANTI D 0", 3, 1.865, 0., 4.2e-13);
867 fPDGCode[fNPDGCodes++]=-421; // 38 = D0 bar
869 fPDGCode[fNPDGCodes++]=-99; // 39 = unassigned
871 fPDGCode[fNPDGCodes++]=-99; // 40 = unassigned
873 fPDGCode[fNPDGCodes++]=-99; // 41 = unassigned
875 Gspart(42, "RHO +", 4, 0.768, 1., 4.353e-24);
876 fPDGCode[fNPDGCodes++]=213; // 42 = RHO+
878 Gspart(43, "RHO -", 4, 0.768, -1., 4.353e-24);
879 fPDGCode[fNPDGCodes++]=-213; // 43 = RHO-
881 Gspart(44, "RHO 0", 3, 0.768, 0., 4.353e-24);
882 fPDGCode[fNPDGCodes++]=113; // 44 = RHO0
885 // Use ENDF-6 mapping for ions = 10000*z+10*a+iso
887 // and numbers above 5 000 000 for special applications
890 const Int_t kion=10000000;
892 const Int_t kspe=50000000;
894 TDatabasePDG *pdgDB = TDatabasePDG::Instance();
896 const Double_t kAu2Gev=0.9314943228;
897 const Double_t khSlash = 1.0545726663e-27;
898 const Double_t kErg2Gev = 1/1.6021773349e-3;
899 const Double_t khShGev = khSlash*kErg2Gev;
900 const Double_t kYear2Sec = 3600*24*365.25;
903 // mass and life-time from PDG
904 pdgDB->AddParticle("B(s)*0","B(s)*0",
905 5.4163, kTRUE, 0.047, +0.,"Meson", 533);
907 pdgDB->AddParticle("B(s)*0 bar","B(s)*0 bar",
908 5.4163, kTRUE, 0.047, -0.,"Meson", -533);
912 // value for mass used by Hijing
913 pdgDB->AddParticle("Sigma(c)*+","Sigma(c)*+",
914 2.4536, kTRUE, -1., +1.,"Baryon", 4214);
916 pdgDB->AddParticle("Sigma(c)*-","Sigma(c)*-",
917 2.4536, kTRUE, -1., -1.,"Baryon", -4214);
918 // equivalent to 4312 ? Hijing uses m=2.55
919 pdgDB->AddParticle("Xsi(c)0","Xsi(c)0",
920 2.4703, kTRUE, -1., +0.,"Baryon", 4132);
922 pdgDB->AddParticle("Xsi(c)0 bar","Xsi(c)0 bar",
923 2.4703, kTRUE, -1., -0.,"Baryon", -4132);
924 // equivalent to 4322 ? Hijing uses m=2.55
925 pdgDB->AddParticle("Xi(c)+","Xi(c)+",
926 2.4656, kFALSE, -1., +1.,"Baryon", 4232);
928 pdgDB->AddParticle("Xi(c)-","Xi(c)-",
929 2.4656, kFALSE, -1., -1.,"Baryon", -4232);
930 // mass values from Hijing
932 pdgDB->AddParticle("Xsi(c)*0","Xsi(c)*0",
933 2.63, kTRUE, -1., +0.,"Baryon", 4314);
935 pdgDB->AddParticle("Xsi(c)*0 bar","Xsi(c)*0 bar",
936 2.63, kTRUE, -1., -0.,"Baryon", -4314);
938 pdgDB->AddParticle("Xsi(c)*+","Xsi(c)*+",
939 2.63, kTRUE, -1., +1.,"Baryon", 4324);
941 pdgDB->AddParticle("Xsi(c)*-","Xsi(c)*-",
942 2.63, kTRUE, -1., -1.,"Baryon", -4324);
944 // pdg mass value, Hijing uses m=2.73.
945 pdgDB->AddParticle("Omega(c)0","Omega(c)0",
946 2.7040, kFALSE, khShGev/0.064e-12, +0.,"Baryon", 4332);
948 pdgDB->AddParticle("Omega(c)0 bar","Omega(c)0 bar",
949 2.7040, kFALSE, khShGev/0.064e-12, -0.,"Baryon", -4332);
950 // mass value from Hijing
951 pdgDB->AddParticle("Omega(c)*0","Omega(c)*0",
952 2.8000, kFALSE, -1., +0.,"Baryon", 4334);
954 pdgDB->AddParticle("Omega(c)*0 bar","Omega(c)*0",
955 2.8000, kFALSE, -1., -0.,"Baryon", -4334);
959 // mass value from Hijing
960 pdgDB->AddParticle("Sigma(b)*+","Sigma(b)*+",
961 5.8100, kFALSE, -1., +1.,"Baryon", 5224);
963 pdgDB->AddParticle("Sigma(b)*-","Sigma(b)*-",
964 5.8100, kFALSE, -1., -1.,"Baryon", -5224);
968 pdgDB->AddParticle("Deuteron","Deuteron",2*kAu2Gev+8.071e-3,kTRUE,
969 0,1,"Ion",kion+10020);
970 fPDGCode[fNPDGCodes++]=kion+10020; // 45 = Deuteron
972 pdgDB->AddParticle("Triton","Triton",3*kAu2Gev+14.931e-3,kFALSE,
973 khShGev/(12.33*kYear2Sec),1,"Ion",kion+10030);
974 fPDGCode[fNPDGCodes++]=kion+10030; // 46 = Triton
976 pdgDB->AddParticle("Alpha","Alpha",4*kAu2Gev+2.424e-3,kTRUE,
977 khShGev/(12.33*kYear2Sec),2,"Ion",kion+20040);
978 fPDGCode[fNPDGCodes++]=kion+20040; // 47 = Alpha
980 fPDGCode[fNPDGCodes++]=0; // 48 = geantino mapped to rootino
982 pdgDB->AddParticle("HE3","HE3",3*kAu2Gev+14.931e-3,kFALSE,
983 0,2,"Ion",kion+20030);
984 fPDGCode[fNPDGCodes++]=kion+20030; // 49 = HE3
986 pdgDB->AddParticle("Cherenkov","Cherenkov",0,kFALSE,
987 0,0,"Special",kspe+50);
988 fPDGCode[fNPDGCodes++]=kspe+50; // 50 = Cherenkov
990 Gspart(51, "FeedbackPhoton", 7, 0., 0.,1.e20 );
991 pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton",0,kFALSE,
992 0,0,"Special",kspe+51);
993 fPDGCode[fNPDGCodes++]=kspe+51; // 51 = FeedbackPhoton
994 Gspart(52, "Lambda_c+", 4, 2.2849, +1., 2.06e-13);
995 fPDGCode[fNPDGCodes++]=4122; //52 = Lambda_c+
997 Gspart(53, "Lambda_c-", 4, 2.2849, -1., 2.06e-13);
998 fPDGCode[fNPDGCodes++]=-4122; //53 = Lambda_c-
1000 Gspart(54, "D_s+", 4, 1.9685, +1., 4.67e-13);
1001 fPDGCode[fNPDGCodes++]=431; //54 = D_s+
1003 Gspart(55, "D_s-", 4, 1.9685, -1., 4.67e-13);
1004 fPDGCode[fNPDGCodes++]=-431; //55 = D_s-
1006 Gspart(56, "Tau+", 5, 1.77705, +1., 2.9e-13);
1007 fPDGCode[fNPDGCodes++]=15; //56 = Tau+
1009 Gspart(57, "Tau-", 5, 1.77705, -1., 2.9e-13);
1010 fPDGCode[fNPDGCodes++]=-15; //57 = Tau-
1012 Gspart(58, "B0", 3, 5.2792, +0., 1.56e-12);
1013 fPDGCode[fNPDGCodes++]=511; //58 = B0
1015 Gspart(59, "B0 bar", 3, 5.2792, -0., 1.56e-12);
1016 fPDGCode[fNPDGCodes++]=-511; //58 = B0bar
1018 Gspart(60, "B+", 4, 5.2789, +1., 1.65e-12);
1019 fPDGCode[fNPDGCodes++]=521; //60 = B+
1021 Gspart(61, "B-", 4, 5.2789, -1., 1.65e-12);
1022 fPDGCode[fNPDGCodes++]=-521; //61 = B-
1024 Gspart(62, "Bs", 3, 5.3693, +0., 1.54e-12);
1025 fPDGCode[fNPDGCodes++]=521; //62 = B_s
1027 Gspart(63, "Bs bar", 3, 5.3693, -0., 1.54e-12);
1028 fPDGCode[fNPDGCodes++]=-521; //63 = B_s bar
1030 Gspart(64, "Lambda_b", 3, 5.624, +0., 1.24e-12);
1031 fPDGCode[fNPDGCodes++]=5122; //64 = Lambda_b
1033 Gspart(65, "Lambda_b bar", 3, 5.624, -0., 1.24e-12);
1034 fPDGCode[fNPDGCodes++]=-5122; //65 = Lambda_b bar
1036 Gspart(66, "J/Psi", 3.09688, 3, 0., 0.);
1037 fPDGCode[fNPDGCodes++]=443; // 66 = J/Psi
1039 Gspart(67, "Psi Prime", 3, 3.686, 0., 0.);
1040 fPDGCode[fNPDGCodes++]=20443; // 67 = Psi prime
1042 Gspart(68, "Upsilon(1S)", 9.46037, 3, 0., 0.);
1043 fPDGCode[fNPDGCodes++]=553; // 68 = Upsilon(1S)
1045 Gspart(69, "Upsilon(2S)", 10.0233, 3, 0., 0.);
1046 fPDGCode[fNPDGCodes++]=20553; // 69 = Upsilon(2S)
1048 Gspart(70, "Upsilon(3S)", 10.3553, 3, 0., 0.);
1049 fPDGCode[fNPDGCodes++]=30553; // 70 = Upsilon(3S)
1051 /* --- Define additional decay modes --- */
1052 /* --- omega(783) --- */
1053 for (kz = 0; kz < 6; ++kz) {
1064 Gsdk(ipa, bratio, mode);
1065 /* --- phi(1020) --- */
1066 for (kz = 0; kz < 6; ++kz) {
1081 Gsdk(ipa, bratio, mode);
1084 for (kz = 0; kz < 6; ++kz) {
1097 Gsdk(ipa, bratio, mode);
1101 for (kz = 0; kz < 6; ++kz) {
1114 Gsdk(ipa, bratio, mode);
1118 for (kz = 0; kz < 6; ++kz) {
1129 Gsdk(ipa, bratio, mode);
1131 /* --- Anti D0 --- */
1133 for (kz = 0; kz < 6; ++kz) {
1144 Gsdk(ipa, bratio, mode);
1147 for (kz = 0; kz < 6; ++kz) {
1154 Gsdk(ipa, bratio, mode);
1156 for (kz = 0; kz < 6; ++kz) {
1163 Gsdk(ipa, bratio, mode);
1165 for (kz = 0; kz < 6; ++kz) {
1172 Gsdk(ipa, bratio, mode);
1175 for (kz = 0; kz < 6; ++kz) {
1184 Gsdk(ipa, bratio, mode);
1187 Gsdk(ipa, bratio, mode);
1190 Gsdk(ipa, bratio, mode);
1195 //_____________________________________________________________________________
1196 Int_t TGeant3::VolId(const Text_t *name) const
1199 // Return the unique numeric identifier for volume name
1202 strncpy((char *) &gname, name, 4);
1203 for(i=1; i<=fGcnum->nvolum; i++)
1204 if(gname == fZiq[fGclink->jvolum+i]) return i;
1205 printf("VolId: Volume %s not found\n",name);
1209 //_____________________________________________________________________________
1210 Int_t TGeant3::NofVolumes() const
1213 // Return total number of volumes in the geometry
1215 return fGcnum->nvolum;
1218 //_____________________________________________________________________________
1219 const char* TGeant3::VolName(Int_t id) const
1222 // Return the volume name given the volume identifier
1224 if(id<1 || id > fGcnum->nvolum || fGclink->jvolum<=0)
1225 return fVolNames[fGcnum->nvolum];
1227 return fVolNames[id-1];
1230 //_____________________________________________________________________________
1231 void TGeant3::SetCut(const char* cutName, Float_t cutValue)
1234 // Set transport cuts for particles
1236 if(!strcmp(cutName,"CUTGAM"))
1237 fGccuts->cutgam=cutValue;
1238 else if(!strcmp(cutName,"CUTGAM"))
1239 fGccuts->cutele=cutValue;
1240 else if(!strcmp(cutName,"CUTELE"))
1241 fGccuts->cutneu=cutValue;
1242 else if(!strcmp(cutName,"CUTHAD"))
1243 fGccuts->cuthad=cutValue;
1244 else if(!strcmp(cutName,"CUTMUO"))
1245 fGccuts->cutmuo=cutValue;
1246 else if(!strcmp(cutName,"BCUTE"))
1247 fGccuts->bcute=cutValue;
1248 else if(!strcmp(cutName,"BCUTM"))
1249 fGccuts->bcutm=cutValue;
1250 else if(!strcmp(cutName,"DCUTE"))
1251 fGccuts->dcute=cutValue;
1252 else if(!strcmp(cutName,"DCUTM"))
1253 fGccuts->dcutm=cutValue;
1254 else if(!strcmp(cutName,"PPCUTM"))
1255 fGccuts->ppcutm=cutValue;
1256 else if(!strcmp(cutName,"TOFMAX"))
1257 fGccuts->tofmax=cutValue;
1258 else Warning("SetCut","Cut %s not implemented\n",cutName);
1261 //_____________________________________________________________________________
1262 void TGeant3::SetProcess(const char* flagName, Int_t flagValue)
1265 // Set thresholds for different processes
1267 if(!strcmp(flagName,"PAIR"))
1268 fGcphys->ipair=flagValue;
1269 else if(!strcmp(flagName,"COMP"))
1270 fGcphys->icomp=flagValue;
1271 else if(!strcmp(flagName,"PHOT"))
1272 fGcphys->iphot=flagValue;
1273 else if(!strcmp(flagName,"PFIS"))
1274 fGcphys->ipfis=flagValue;
1275 else if(!strcmp(flagName,"DRAY"))
1276 fGcphys->idray=flagValue;
1277 else if(!strcmp(flagName,"ANNI"))
1278 fGcphys->ianni=flagValue;
1279 else if(!strcmp(flagName,"BREM"))
1280 fGcphys->ibrem=flagValue;
1281 else if(!strcmp(flagName,"HADR"))
1282 fGcphys->ihadr=flagValue;
1283 else if(!strcmp(flagName,"MUNU"))
1284 fGcphys->imunu=flagValue;
1285 else if(!strcmp(flagName,"DCAY"))
1286 fGcphys->idcay=flagValue;
1287 else if(!strcmp(flagName,"LOSS"))
1288 fGcphys->iloss=flagValue;
1289 else if(!strcmp(flagName,"MULS"))
1290 fGcphys->imuls=flagValue;
1291 else if(!strcmp(flagName,"RAYL"))
1292 fGcphys->irayl=flagValue;
1293 else if(!strcmp(flagName,"STRA"))
1294 fGcphlt->istra=flagValue;
1295 else if(!strcmp(flagName,"SYNC"))
1296 fGcphlt->isync=flagValue;
1297 else Warning("SetFlag","Flag %s not implemented\n",flagName);
1300 //_____________________________________________________________________________
1301 Float_t TGeant3::Xsec(char* reac, Float_t /* energy */,
1302 Int_t part, Int_t /* mate */)
1305 // Calculate X-sections -- dummy for the moment
1307 if(!strcmp(reac,"PHOT"))
1310 Error("Xsec","Can calculate photoelectric only for photons\n");
1316 //_____________________________________________________________________________
1317 void TGeant3::TrackPosition(TLorentzVector &xyz) const
1320 // Return the current position in the master reference frame of the
1321 // track being transported
1323 xyz[0]=fGctrak->vect[0];
1324 xyz[1]=fGctrak->vect[1];
1325 xyz[2]=fGctrak->vect[2];
1326 xyz[3]=fGctrak->tofg;
1329 //_____________________________________________________________________________
1330 Float_t TGeant3::TrackTime() const
1333 // Return the current time of flight of the track being transported
1335 return fGctrak->tofg;
1338 //_____________________________________________________________________________
1339 void TGeant3::TrackMomentum(TLorentzVector &xyz) const
1342 // Return the direction and the momentum (GeV/c) of the track
1343 // currently being transported
1345 Double_t ptot=fGctrak->vect[6];
1346 xyz[0]=fGctrak->vect[3]*ptot;
1347 xyz[1]=fGctrak->vect[4]*ptot;
1348 xyz[2]=fGctrak->vect[5]*ptot;
1349 xyz[3]=fGctrak->getot;
1352 //_____________________________________________________________________________
1353 Float_t TGeant3::TrackCharge() const
1356 // Return charge of the track currently transported
1358 return fGckine->charge;
1361 //_____________________________________________________________________________
1362 Float_t TGeant3::TrackMass() const
1365 // Return the mass of the track currently transported
1367 return fGckine->amass;
1370 //_____________________________________________________________________________
1371 Int_t TGeant3::TrackPid() const
1374 // Return the id of the particle transported
1376 return PDGFromId(fGckine->ipart);
1379 //_____________________________________________________________________________
1380 Float_t TGeant3::TrackStep() const
1383 // Return the length in centimeters of the current step
1385 return fGctrak->step;
1388 //_____________________________________________________________________________
1389 Float_t TGeant3::TrackLength() const
1392 // Return the length of the current track from its origin
1394 return fGctrak->sleng;
1397 //_____________________________________________________________________________
1398 Bool_t TGeant3::IsNewTrack() const
1401 // True if the track is not at the boundary of the current volume
1403 return (fGctrak->sleng==0);
1406 //_____________________________________________________________________________
1407 Bool_t TGeant3::IsTrackInside() const
1410 // True if the track is not at the boundary of the current volume
1412 return (fGctrak->inwvol==0);
1415 //_____________________________________________________________________________
1416 Bool_t TGeant3::IsTrackEntering() const
1419 // True if this is the first step of the track in the current volume
1421 return (fGctrak->inwvol==1);
1424 //_____________________________________________________________________________
1425 Bool_t TGeant3::IsTrackExiting() const
1428 // True if this is the last step of the track in the current volume
1430 return (fGctrak->inwvol==2);
1433 //_____________________________________________________________________________
1434 Bool_t TGeant3::IsTrackOut() const
1437 // True if the track is out of the setup
1439 return (fGctrak->inwvol==3);
1442 //_____________________________________________________________________________
1443 Bool_t TGeant3::IsTrackStop() const
1446 // True if the track energy has fallen below the threshold
1448 return (fGctrak->istop==2);
1451 //_____________________________________________________________________________
1452 Int_t TGeant3::NSecondaries() const
1455 // Number of secondary particles generated in the current step
1457 return fGcking->ngkine;
1460 //_____________________________________________________________________________
1461 Int_t TGeant3::CurrentEvent() const
1464 // Number of the current event
1466 return fGcflag->idevt;
1469 //_____________________________________________________________________________
1470 const char* TGeant3::ProdProcess() const
1473 // Name of the process that has produced the secondary particles
1474 // in the current step
1476 static char proc[5];
1477 const Int_t kIpMec[13] = { 5,6,7,8,9,10,11,12,21,23,25,105,108 };
1480 if(fGcking->ngkine>0) {
1481 for (km = 0; km < fGctrak->nmec; ++km) {
1482 for (im = 0; im < 13; ++im) {
1483 if (fGctrak->lmec[km] == kIpMec[im]) {
1484 mec = fGctrak->lmec[km];
1485 if (0 < mec && mec < 31) {
1486 strncpy(proc,(char *)&fGctrak->namec[mec - 1],4);
1487 } else if (mec - 100 <= 30 && mec - 100 > 0) {
1488 strncpy(proc,(char *)&fGctpol->namec1[mec - 101],4);
1495 strcpy(proc,"UNKN");
1496 } else strcpy(proc,"NONE");
1500 //_____________________________________________________________________________
1501 void TGeant3::GetSecondary(Int_t isec, Int_t& ipart,
1502 TLorentzVector &x, TLorentzVector &p)
1505 // Get the parameters of the secondary track number isec produced
1506 // in the current step
1509 if(-1<isec && isec<fGcking->ngkine) {
1510 ipart=Int_t (fGcking->gkin[isec][4] +0.5);
1512 x[i]=fGckin3->gpos[isec][i];
1513 p[i]=fGcking->gkin[isec][i];
1515 x[3]=fGcking->tofd[isec];
1516 p[3]=fGcking->gkin[isec][3];
1518 printf(" * TGeant3::GetSecondary * Secondary %d does not exist\n",isec);
1519 x[0]=x[1]=x[2]=x[3]=p[0]=p[1]=p[2]=p[3]=0;
1524 //_____________________________________________________________________________
1525 void TGeant3::InitLego()
1528 // Set switches for lego transport
1531 SetDEBU(0,0,0); //do not print a message
1534 //_____________________________________________________________________________
1535 Bool_t TGeant3::IsTrackDisappeared() const
1538 // True if the current particle has disappered
1539 // either because it decayed or because it underwent
1540 // an inelastic collision
1542 return (fGctrak->istop==1);
1545 //_____________________________________________________________________________
1546 Bool_t TGeant3::IsTrackAlive() const
1549 // True if the current particle is alive and will continue to be
1552 return (fGctrak->istop==0);
1555 //_____________________________________________________________________________
1556 void TGeant3::StopTrack()
1559 // Stop the transport of the current particle and skip to the next
1564 //_____________________________________________________________________________
1565 void TGeant3::StopEvent()
1568 // Stop simulation of the current event and skip to the next
1573 //_____________________________________________________________________________
1574 Float_t TGeant3::MaxStep() const
1577 // Return the maximum step length in the current medium
1579 return fGctmed->stemax;
1582 //_____________________________________________________________________________
1583 void TGeant3::SetMaxStep(Float_t maxstep)
1586 // Set the maximum step allowed till the particle is in the current medium
1588 fGctmed->stemax=maxstep;
1591 //_____________________________________________________________________________
1592 void TGeant3::SetMaxNStep(Int_t maxnstp)
1595 // Set the maximum number of steps till the particle is in the current medium
1597 fGctrak->maxnst=maxnstp;
1600 //_____________________________________________________________________________
1601 Int_t TGeant3::GetMaxNStep() const
1604 // Maximum number of steps allowed in current medium
1606 return fGctrak->maxnst;
1609 //_____________________________________________________________________________
1610 void TGeant3::Material(Int_t& kmat, const char* name, Float_t a, Float_t z,
1611 Float_t dens, Float_t radl, Float_t absl, Float_t* buf,
1615 // Defines a Material
1617 // kmat number assigned to the material
1618 // name material name
1619 // a atomic mass in au
1621 // dens density in g/cm3
1622 // absl absorbtion length in cm
1623 // if >=0 it is ignored and the program
1624 // calculates it, if <0. -absl is taken
1625 // radl radiation length in cm
1626 // if >=0 it is ignored and the program
1627 // calculates it, if <0. -radl is taken
1628 // buf pointer to an array of user words
1629 // nbuf number of user words
1631 Int_t jmate=fGclink->jmate;
1637 for(i=1; i<=ns; i++) {
1638 if(fZlq[jmate-i]==0) {
1644 gsmate(kmat,PASSCHARD(name), a, z, dens, radl, absl, buf,
1645 nwbuf PASSCHARL(name));
1648 //_____________________________________________________________________________
1649 void TGeant3::Mixture(Int_t& kmat, const char* name, Float_t* a, Float_t* z,
1650 Float_t dens, Int_t nlmat, Float_t* wmat)
1653 // Defines mixture OR COMPOUND IMAT as composed by
1654 // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
1656 // If NLMAT > 0 then wmat contains the proportion by
1657 // weights of each basic material in the mixture.
1659 // If nlmat < 0 then WMAT contains the number of atoms
1660 // of a given kind into the molecule of the COMPOUND
1661 // In this case, WMAT in output is changed to relative
1664 Int_t jmate=fGclink->jmate;
1670 for(i=1; i<=ns; i++) {
1671 if(fZlq[jmate-i]==0) {
1677 gsmixt(kmat,PASSCHARD(name), a, z,dens, nlmat,wmat PASSCHARL(name));
1680 //_____________________________________________________________________________
1681 void TGeant3::Medium(Int_t& kmed, const char* name, Int_t nmat, Int_t isvol,
1682 Int_t ifield, Float_t fieldm, Float_t tmaxfd,
1683 Float_t stemax, Float_t deemax, Float_t epsil,
1684 Float_t stmin, Float_t* ubuf, Int_t nbuf)
1687 // kmed tracking medium number assigned
1688 // name tracking medium name
1689 // nmat material number
1690 // isvol sensitive volume flag
1691 // ifield magnetic field
1692 // fieldm max. field value (kilogauss)
1693 // tmaxfd max. angle due to field (deg/step)
1694 // stemax max. step allowed
1695 // deemax max. fraction of energy lost in a step
1696 // epsil tracking precision (cm)
1697 // stmin min. step due to continuos processes (cm)
1699 // ifield = 0 if no magnetic field; ifield = -1 if user decision in guswim;
1700 // ifield = 1 if tracking performed with grkuta; ifield = 2 if tracking
1701 // performed with ghelix; ifield = 3 if tracking performed with ghelx3.
1703 Int_t jtmed=fGclink->jtmed;
1709 for(i=1; i<=ns; i++) {
1710 if(fZlq[jtmed-i]==0) {
1716 gstmed(kmed, PASSCHARD(name), nmat, isvol, ifield, fieldm, tmaxfd, stemax,
1717 deemax, epsil, stmin, ubuf, nbuf PASSCHARL(name));
1720 //_____________________________________________________________________________
1721 void TGeant3::Matrix(Int_t& krot, Float_t thex, Float_t phix, Float_t they,
1722 Float_t phiy, Float_t thez, Float_t phiz)
1725 // krot rotation matrix number assigned
1726 // theta1 polar angle for axis i
1727 // phi1 azimuthal angle for axis i
1728 // theta2 polar angle for axis ii
1729 // phi2 azimuthal angle for axis ii
1730 // theta3 polar angle for axis iii
1731 // phi3 azimuthal angle for axis iii
1733 // it defines the rotation matrix number irot.
1735 Int_t jrotm=fGclink->jrotm;
1741 for(i=1; i<=ns; i++) {
1742 if(fZlq[jrotm-i]==0) {
1748 gsrotm(krot, thex, phix, they, phiy, thez, phiz);
1751 //_____________________________________________________________________________
1752 Int_t TGeant3::GetMedium() const
1755 // Return the number of the current medium
1757 return fGctmed->numed;
1760 //_____________________________________________________________________________
1761 Float_t TGeant3::Edep() const
1764 // Return the energy lost in the current step
1766 return fGctrak->destep;
1769 //_____________________________________________________________________________
1770 Float_t TGeant3::Etot() const
1773 // Return the total energy of the current track
1775 return fGctrak->getot;
1778 //_____________________________________________________________________________
1779 void TGeant3::Rndm(Float_t* r, const Int_t n) const
1782 // Return an array of n random numbers uniformly distributed
1783 // between 0 and 1 not included
1788 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1790 // Functions from GBASE
1792 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1794 //____________________________________________________________________________
1795 void TGeant3::Gfile(const char *filename, const char *option)
1798 // Routine to open a GEANT/RZ data base.
1800 // LUN logical unit number associated to the file
1802 // CHFILE RZ file name
1804 // CHOPT is a character string which may be
1805 // N To create a new file
1806 // U to open an existing file for update
1807 // " " to open an existing file for read only
1808 // Q The initial allocation (default 1000 records)
1809 // is given in IQUEST(10)
1810 // X Open the file in exchange format
1811 // I Read all data structures from file to memory
1812 // O Write all data structures from memory to file
1815 // If options "I" or "O" all data structures are read or
1816 // written from/to file and the file is closed.
1817 // See routine GRMDIR to create subdirectories
1818 // See routines GROUT,GRIN to write,read objects
1820 grfile(21, PASSCHARD(filename), PASSCHARD(option) PASSCHARL(filename)
1824 //____________________________________________________________________________
1825 void TGeant3::Gpcxyz()
1828 // Print track and volume parameters at current point
1833 //_____________________________________________________________________________
1834 void TGeant3::Ggclos()
1837 // Closes off the geometry setting.
1838 // Initializes the search list for the contents of each
1839 // volume following the order they have been positioned, and
1840 // inserting the content '0' when a call to GSNEXT (-1) has
1841 // been required by the user.
1842 // Performs the development of the JVOLUM structure for all
1843 // volumes with variable parameters, by calling GGDVLP.
1844 // Interprets the user calls to GSORD, through GGORD.
1845 // Computes and stores in a bank (next to JVOLUM mother bank)
1846 // the number of levels in the geometrical tree and the
1847 // maximum number of contents per level, by calling GGNLEV.
1848 // Sets status bit for CONCAVE volumes, through GGCAVE.
1849 // Completes the JSET structure with the list of volume names
1850 // which identify uniquely a given physical detector, the
1851 // list of bit numbers to pack the corresponding volume copy
1852 // numbers, and the generic path(s) in the JVOLUM tree,
1853 // through the routine GHCLOS.
1856 // Create internal list of volumes
1857 fVolNames = new char[fGcnum->nvolum+1][5];
1859 for(i=0; i<fGcnum->nvolum; ++i) {
1860 strncpy(fVolNames[i], (char *) &fZiq[fGclink->jvolum+i+1], 4);
1861 fVolNames[i][4]='\0';
1863 strcpy(fVolNames[fGcnum->nvolum],"NULL");
1866 //_____________________________________________________________________________
1867 void TGeant3::Glast()
1870 // Finish a Geant run
1875 //_____________________________________________________________________________
1876 void TGeant3::Gprint(const char *name)
1879 // Routine to print data structures
1880 // CHNAME name of a data structure
1884 gprint(PASSCHARD(vname),0 PASSCHARL(vname));
1887 //_____________________________________________________________________________
1888 void TGeant3::Grun()
1891 // Steering function to process one run
1896 //_____________________________________________________________________________
1897 void TGeant3::Gtrig()
1900 // Steering function to process one event
1905 //_____________________________________________________________________________
1906 void TGeant3::Gtrigc()
1909 // Clear event partition
1914 //_____________________________________________________________________________
1915 void TGeant3::Gtrigi()
1918 // Initialises event partition
1923 //_____________________________________________________________________________
1924 void TGeant3::Gwork(Int_t nwork)
1927 // Allocates workspace in ZEBRA memory
1932 //_____________________________________________________________________________
1933 void TGeant3::Gzinit()
1936 // To initialise GEANT/ZEBRA data structures
1941 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1943 // Functions from GCONS
1945 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1947 //_____________________________________________________________________________
1948 void TGeant3::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,
1949 Float_t &dens, Float_t &radl, Float_t &absl,
1950 Float_t* ubuf, Int_t& nbuf)
1953 // Return parameters for material IMAT
1955 gfmate(imat, PASSCHARD(name), a, z, dens, radl, absl, ubuf, nbuf
1959 //_____________________________________________________________________________
1960 void TGeant3::Gfpart(Int_t ipart, char *name, Int_t &itrtyp,
1961 Float_t &amass, Float_t &charge, Float_t &tlife)
1964 // Return parameters for particle of type IPART
1968 Int_t igpart = IdFromPDG(ipart);
1969 gfpart(igpart, PASSCHARD(name), itrtyp, amass, charge, tlife, ubuf, nbuf
1973 //_____________________________________________________________________________
1974 void TGeant3::Gftmed(Int_t numed, char *name, Int_t &nmat, Int_t &isvol,
1975 Int_t &ifield, Float_t &fieldm, Float_t &tmaxfd,
1976 Float_t &stemax, Float_t &deemax, Float_t &epsil,
1977 Float_t &stmin, Float_t *ubuf, Int_t *nbuf)
1980 // Return parameters for tracking medium NUMED
1982 gftmed(numed, PASSCHARD(name), nmat, isvol, ifield, fieldm, tmaxfd, stemax,
1983 deemax, epsil, stmin, ubuf, nbuf PASSCHARL(name));
1987 void TGeant3::Gftmat(Int_t imate, Int_t ipart, char *chmeca, Int_t kdim,
1988 Float_t* tkin, Float_t* value, Float_t* pcut,
1992 // Return parameters for tracking medium NUMED
1994 gftmat(imate, ipart, PASSCHARD(chmeca), kdim,
1995 tkin, value, pcut, ixst PASSCHARL(chmeca));
1999 //_____________________________________________________________________________
2000 Float_t TGeant3::Gbrelm(Float_t z, Float_t t, Float_t bcut)
2003 // To calculate energy loss due to soft muon BREMSSTRAHLUNG
2005 return gbrelm(z,t,bcut);
2008 //_____________________________________________________________________________
2009 Float_t TGeant3::Gprelm(Float_t z, Float_t t, Float_t bcut)
2012 // To calculate DE/DX in GeV*barn/atom for direct pair production by muons
2014 return gprelm(z,t,bcut);
2017 //_____________________________________________________________________________
2018 void TGeant3::Gmate()
2021 // Define standard GEANT materials
2026 //_____________________________________________________________________________
2027 void TGeant3::Gpart()
2030 // Define standard GEANT particles plus selected decay modes
2031 // and branching ratios.
2036 //_____________________________________________________________________________
2037 void TGeant3::Gsdk(Int_t ipart, Float_t *bratio, Int_t *mode)
2039 // Defines branching ratios and decay modes for standard
2041 gsdk(ipart,bratio,mode);
2044 //_____________________________________________________________________________
2045 void TGeant3::Gsmate(Int_t imat, const char *name, Float_t a, Float_t z,
2046 Float_t dens, Float_t radl, Float_t absl)
2049 // Defines a Material
2051 // kmat number assigned to the material
2052 // name material name
2053 // a atomic mass in au
2055 // dens density in g/cm3
2056 // absl absorbtion length in cm
2057 // if >=0 it is ignored and the program
2058 // calculates it, if <0. -absl is taken
2059 // radl radiation length in cm
2060 // if >=0 it is ignored and the program
2061 // calculates it, if <0. -radl is taken
2062 // buf pointer to an array of user words
2063 // nbuf number of user words
2067 gsmate(imat,PASSCHARD(name), a, z, dens, radl, absl, ubuf, nbuf
2071 //_____________________________________________________________________________
2072 void TGeant3::Gsmixt(Int_t imat, const char *name, Float_t *a, Float_t *z,
2073 Float_t dens, Int_t nlmat, Float_t *wmat)
2076 // Defines mixture OR COMPOUND IMAT as composed by
2077 // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
2079 // If NLMAT.GT.0 then WMAT contains the PROPORTION BY
2080 // WEIGTHS OF EACH BASIC MATERIAL IN THE MIXTURE.
2082 // If NLMAT.LT.0 then WMAT contains the number of atoms
2083 // of a given kind into the molecule of the COMPOUND
2084 // In this case, WMAT in output is changed to relative
2087 gsmixt(imat,PASSCHARD(name), a, z,dens, nlmat,wmat PASSCHARL(name));
2090 //_____________________________________________________________________________
2091 void TGeant3::Gspart(Int_t ipart, const char *name, Int_t itrtyp,
2092 Float_t amass, Float_t charge, Float_t tlife)
2095 // Store particle parameters
2097 // ipart particle code
2098 // name particle name
2099 // itrtyp transport method (see GEANT manual)
2100 // amass mass in GeV/c2
2101 // charge charge in electron units
2102 // tlife lifetime in seconds
2106 gspart(ipart,PASSCHARD(name), itrtyp, amass, charge, tlife, ubuf, nbuf
2110 //_____________________________________________________________________________
2111 void TGeant3::Gstmed(Int_t numed, const char *name, Int_t nmat, Int_t isvol,
2112 Int_t ifield, Float_t fieldm, Float_t tmaxfd,
2113 Float_t stemax, Float_t deemax, Float_t epsil,
2117 // NTMED Tracking medium number
2118 // NAME Tracking medium name
2119 // NMAT Material number
2120 // ISVOL Sensitive volume flag
2121 // IFIELD Magnetic field
2122 // FIELDM Max. field value (Kilogauss)
2123 // TMAXFD Max. angle due to field (deg/step)
2124 // STEMAX Max. step allowed
2125 // DEEMAX Max. fraction of energy lost in a step
2126 // EPSIL Tracking precision (cm)
2127 // STMIN Min. step due to continuos processes (cm)
2129 // IFIELD = 0 if no magnetic field; IFIELD = -1 if user decision in GUSWIM;
2130 // IFIELD = 1 if tracking performed with GRKUTA; IFIELD = 2 if tracking
2131 // performed with GHELIX; IFIELD = 3 if tracking performed with GHELX3.
2135 gstmed(numed,PASSCHARD(name), nmat, isvol, ifield, fieldm, tmaxfd, stemax,
2136 deemax, epsil, stmin, ubuf, nbuf PASSCHARL(name));
2139 //_____________________________________________________________________________
2140 void TGeant3::Gsckov(Int_t itmed, Int_t npckov, Float_t *ppckov,
2141 Float_t *absco, Float_t *effic, Float_t *rindex)
2144 // Stores the tables for UV photon tracking in medium ITMED
2145 // Please note that it is the user's responsability to
2146 // provide all the coefficients:
2149 // ITMED Tracking medium number
2150 // NPCKOV Number of bins of each table
2151 // PPCKOV Value of photon momentum (in GeV)
2152 // ABSCO Absorbtion coefficients
2153 // dielectric: absorbtion length in cm
2154 // metals : absorbtion fraction (0<=x<=1)
2155 // EFFIC Detection efficiency for UV photons
2156 // RINDEX Refraction index (if=0 metal)
2158 gsckov(itmed,npckov,ppckov,absco,effic,rindex);
2161 //_____________________________________________________________________________
2162 void TGeant3::Gstpar(Int_t itmed, const char *param, Float_t parval)
2165 // To change the value of cut or mechanism "CHPAR"
2166 // to a new value PARVAL for tracking medium ITMED
2167 // The data structure JTMED contains the standard tracking
2168 // parameters (CUTS and flags to control the physics processes) which
2169 // are used by default for all tracking media. It is possible to
2170 // redefine individually with GSTPAR any of these parameters for a
2171 // given tracking medium.
2172 // ITMED tracking medium number
2173 // CHPAR is a character string (variable name)
2174 // PARVAL must be given as a floating point.
2176 gstpar(itmed,PASSCHARD(param), parval PASSCHARL(param));
2179 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2181 // Functions from GCONS
2183 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2185 //_____________________________________________________________________________
2186 void TGeant3::Gfkine(Int_t itra, Float_t *vert, Float_t *pvert, Int_t &ipart,
2189 // Storing/Retrieving Vertex and Track parameters
2190 // ----------------------------------------------
2192 // Stores vertex parameters.
2193 // VERT array of (x,y,z) position of the vertex
2194 // NTBEAM beam track number origin of the vertex
2195 // =0 if none exists
2196 // NTTARG target track number origin of the vertex
2197 // UBUF user array of NUBUF floating point numbers
2199 // NVTX new vertex number (=0 in case of error).
2200 // Prints vertex parameters.
2201 // IVTX for vertex IVTX.
2202 // (For all vertices if IVTX=0)
2203 // Stores long life track parameters.
2204 // PLAB components of momentum
2205 // IPART type of particle (see GSPART)
2206 // NV vertex number origin of track
2207 // UBUF array of NUBUF floating point user parameters
2209 // NT track number (if=0 error).
2210 // Retrieves long life track parameters.
2211 // ITRA track number for which parameters are requested
2212 // VERT vector origin of the track
2213 // PVERT 4 momentum components at the track origin
2214 // IPART particle type (=0 if track ITRA does not exist)
2215 // NVERT vertex number origin of the track
2216 // UBUF user words stored in GSKINE.
2217 // Prints initial track parameters.
2218 // ITRA for track ITRA
2219 // (For all tracks if ITRA=0)
2223 gfkine(itra,vert,pvert,ipart,nvert,ubuf,nbuf);
2226 //_____________________________________________________________________________
2227 void TGeant3::Gfvert(Int_t nvtx, Float_t *v, Int_t &ntbeam, Int_t &nttarg,
2231 // Retrieves the parameter of a vertex bank
2232 // Vertex is generated from tracks NTBEAM NTTARG
2233 // NVTX is the new vertex number
2237 gfvert(nvtx,v,ntbeam,nttarg,tofg,ubuf,nbuf);
2240 //_____________________________________________________________________________
2241 Int_t TGeant3::Gskine(Float_t *plab, Int_t ipart, Int_t nv, Float_t *buf,
2245 // Store kinematics of track NT into data structure
2246 // Track is coming from vertex NV
2249 gskine(plab, ipart, nv, buf, nwbuf, nt);
2253 //_____________________________________________________________________________
2254 Int_t TGeant3::Gsvert(Float_t *v, Int_t ntbeam, Int_t nttarg, Float_t *ubuf,
2258 // Creates a new vertex bank
2259 // Vertex is generated from tracks NTBEAM NTTARG
2260 // NVTX is the new vertex number
2263 gsvert(v, ntbeam, nttarg, ubuf, nwbuf, nwtx);
2267 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2269 // Functions from GPHYS
2271 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2273 //_____________________________________________________________________________
2274 void TGeant3::Gphysi()
2277 // Initialise material constants for all the physics
2278 // mechanisms used by GEANT
2283 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2285 // Functions from GTRAK
2287 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2289 //_____________________________________________________________________________
2290 void TGeant3::Gdebug()
2293 // Debug the current step
2298 //_____________________________________________________________________________
2299 void TGeant3::Gekbin()
2302 // To find bin number in kinetic energy table
2303 // stored in ELOW(NEKBIN)
2308 //_____________________________________________________________________________
2309 void TGeant3::Gfinds()
2312 // Returns the set/volume parameters corresponding to
2313 // the current space point in /GCTRAK/
2314 // and fill common /GCSETS/
2316 // IHSET user set identifier
2317 // IHDET user detector identifier
2318 // ISET set number in JSET
2319 // IDET detector number in JS=LQ(JSET-ISET)
2320 // IDTYPE detector type (1,2)
2321 // NUMBV detector volume numbers (array of length NVNAME)
2322 // NVNAME number of volume levels
2327 //_____________________________________________________________________________
2328 void TGeant3::Gsking(Int_t igk)
2331 // Stores in stack JSTAK either the IGKth track of /GCKING/,
2332 // or the NGKINE tracks when IGK is 0.
2337 //_____________________________________________________________________________
2338 void TGeant3::Gskpho(Int_t igk)
2341 // Stores in stack JSTAK either the IGKth Cherenkov photon of
2342 // /GCKIN2/, or the NPHOT tracks when IGK is 0.
2347 //_____________________________________________________________________________
2348 void TGeant3::Gsstak(Int_t iflag)
2351 // Stores in auxiliary stack JSTAK the particle currently
2352 // described in common /GCKINE/.
2354 // On request, creates also an entry in structure JKINE :
2356 // 0 : No entry in JKINE structure required (user)
2357 // 1 : New entry in JVERTX / JKINE structures required (user)
2358 // <0 : New entry in JKINE structure at vertex -IFLAG (user)
2359 // 2 : Entry in JKINE structure exists already (from GTREVE)
2364 //_____________________________________________________________________________
2365 void TGeant3::Gsxyz()
2368 // Store space point VECT in banks JXYZ
2373 //_____________________________________________________________________________
2374 void TGeant3::Gtrack()
2377 // Controls tracking of current particle
2382 //_____________________________________________________________________________
2383 void TGeant3::Gtreve()
2386 // Controls tracking of all particles belonging to the current event
2391 //_____________________________________________________________________________
2392 void TGeant3::GtreveRoot()
2395 // Controls tracking of all particles belonging to the current event
2400 //_____________________________________________________________________________
2401 void TGeant3::Grndm(Float_t *rvec, const Int_t len) const
2404 // To generate a vector RVECV of LEN random numbers
2405 // Copy of the CERN Library routine RANECU
2409 //_____________________________________________________________________________
2410 void TGeant3::Grndmq(Int_t &is1, Int_t &is2, const Int_t iseq,
2411 const Text_t *chopt)
2414 // To set/retrieve the seed of the random number generator
2416 grndmq(is1,is2,iseq,PASSCHARD(chopt) PASSCHARL(chopt));
2419 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2421 // Functions from GDRAW
2423 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2425 //_____________________________________________________________________________
2426 void TGeant3::Gdxyz(Int_t it)
2429 // Draw the points stored with Gsxyz relative to track it
2434 //_____________________________________________________________________________
2435 void TGeant3::Gdcxyz()
2438 // Draw the position of the current track
2443 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2445 // Functions from GGEOM
2447 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2449 //_____________________________________________________________________________
2450 void TGeant3::Gdtom(Float_t *xd, Float_t *xm, Int_t iflag)
2453 // Computes coordinates XM (Master Reference System
2454 // knowing the coordinates XD (Detector Ref System)
2455 // The local reference system can be initialized by
2456 // - the tracking routines and GDTOM used in GUSTEP
2457 // - a call to GSCMED(NLEVEL,NAMES,NUMBER)
2458 // (inverse routine is GMTOD)
2460 // If IFLAG=1 convert coordinates
2461 // IFLAG=2 convert direction cosinus
2463 gdtom(xd, xm, iflag);
2466 //_____________________________________________________________________________
2467 void TGeant3::Glmoth(const char* iudet, Int_t iunum, Int_t &nlev, Int_t *lvols,
2471 // Loads the top part of the Volume tree in LVOLS (IVO's),
2472 // LINDX (IN indices) for a given volume defined through
2473 // its name IUDET and number IUNUM.
2475 // The routine stores only upto the last level where JVOLUM
2476 // data structure is developed. If there is no development
2477 // above the current level, it returns NLEV zero.
2479 glmoth(PASSCHARD(iudet), iunum, nlev, lvols, lindx, idum PASSCHARL(iudet));
2482 //_____________________________________________________________________________
2483 void TGeant3::Gmedia(Float_t *x, Int_t &numed)
2486 // Finds in which volume/medium the point X is, and updates the
2487 // common /GCVOLU/ and the structure JGPAR accordingly.
2489 // NUMED returns the tracking medium number, or 0 if point is
2490 // outside the experimental setup.
2495 //_____________________________________________________________________________
2496 void TGeant3::Gmtod(Float_t *xm, Float_t *xd, Int_t iflag)
2499 // Computes coordinates XD (in DRS)
2500 // from known coordinates XM in MRS
2501 // The local reference system can be initialized by
2502 // - the tracking routines and GMTOD used in GUSTEP
2503 // - a call to GMEDIA(XM,NUMED)
2504 // - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER)
2505 // (inverse routine is GDTOM)
2507 // If IFLAG=1 convert coordinates
2508 // IFLAG=2 convert direction cosinus
2510 gmtod(xm, xd, iflag);
2513 //_____________________________________________________________________________
2514 void TGeant3::Gsdvn(const char *name, const char *mother, Int_t ndiv,
2518 // Create a new volume by dividing an existing one
2521 // MOTHER Mother volume name
2522 // NDIV Number of divisions
2525 // X,Y,Z of CAXIS will be translated to 1,2,3 for IAXIS.
2526 // It divides a previously defined volume.
2531 Vname(mother,vmother);
2532 gsdvn(PASSCHARD(vname), PASSCHARD(vmother), ndiv, iaxis PASSCHARL(vname)
2533 PASSCHARL(vmother));
2536 //_____________________________________________________________________________
2537 void TGeant3::Gsdvn2(const char *name, const char *mother, Int_t ndiv,
2538 Int_t iaxis, Float_t c0i, Int_t numed)
2541 // Create a new volume by dividing an existing one
2543 // Divides mother into ndiv divisions called name
2544 // along axis iaxis starting at coordinate value c0.
2545 // the new volume created will be medium number numed.
2550 Vname(mother,vmother);
2551 gsdvn2(PASSCHARD(vname), PASSCHARD(vmother), ndiv, iaxis, c0i, numed
2552 PASSCHARL(vname) PASSCHARL(vmother));
2555 //_____________________________________________________________________________
2556 void TGeant3::Gsdvs(const char *name, const char *mother, Float_t step,
2557 Int_t iaxis, Int_t numed)
2560 // Create a new volume by dividing an existing one
2565 Vname(mother,vmother);
2566 gsdvs(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, numed
2567 PASSCHARL(vname) PASSCHARL(vmother));
2570 //_____________________________________________________________________________
2571 void TGeant3::Gsdvs2(const char *name, const char *mother, Float_t step,
2572 Int_t iaxis, Float_t c0, Int_t numed)
2575 // Create a new volume by dividing an existing one
2580 Vname(mother,vmother);
2581 gsdvs2(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, c0, numed
2582 PASSCHARL(vname) PASSCHARL(vmother));
2585 //_____________________________________________________________________________
2586 void TGeant3::Gsdvt(const char *name, const char *mother, Float_t step,
2587 Int_t iaxis, Int_t numed, Int_t ndvmx)
2590 // Create a new volume by dividing an existing one
2592 // Divides MOTHER into divisions called NAME along
2593 // axis IAXIS in steps of STEP. If not exactly divisible
2594 // will make as many as possible and will centre them
2595 // with respect to the mother. Divisions will have medium
2596 // number NUMED. If NUMED is 0, NUMED of MOTHER is taken.
2597 // NDVMX is the expected maximum number of divisions
2598 // (If 0, no protection tests are performed)
2603 Vname(mother,vmother);
2604 gsdvt(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, numed, ndvmx
2605 PASSCHARL(vname) PASSCHARL(vmother));
2608 //_____________________________________________________________________________
2609 void TGeant3::Gsdvt2(const char *name, const char *mother, Float_t step,
2610 Int_t iaxis, Float_t c0, Int_t numed, Int_t ndvmx)
2613 // Create a new volume by dividing an existing one
2615 // Divides MOTHER into divisions called NAME along
2616 // axis IAXIS starting at coordinate value C0 with step
2618 // The new volume created will have medium number NUMED.
2619 // If NUMED is 0, NUMED of mother is taken.
2620 // NDVMX is the expected maximum number of divisions
2621 // (If 0, no protection tests are performed)
2626 Vname(mother,vmother);
2627 gsdvt2(PASSCHARD(vname), PASSCHARD(vmother), step, iaxis, c0,
2628 numed, ndvmx PASSCHARL(vname) PASSCHARL(vmother));
2631 //_____________________________________________________________________________
2632 void TGeant3::Gsord(const char *name, Int_t iax)
2635 // Flags volume CHNAME whose contents will have to be ordered
2636 // along axis IAX, by setting the search flag to -IAX
2640 // IAX = 4 Rxy (static ordering only -> GTMEDI)
2641 // IAX = 14 Rxy (also dynamic ordering -> GTNEXT)
2642 // IAX = 5 Rxyz (static ordering only -> GTMEDI)
2643 // IAX = 15 Rxyz (also dynamic ordering -> GTNEXT)
2644 // IAX = 6 PHI (PHI=0 => X axis)
2645 // IAX = 7 THETA (THETA=0 => Z axis)
2649 gsord(PASSCHARD(vname), iax PASSCHARL(vname));
2652 //_____________________________________________________________________________
2653 void TGeant3::Gspos(const char *name, Int_t nr, const char *mother, Float_t x,
2654 Float_t y, Float_t z, Int_t irot, const char *konly)
2657 // Position a volume into an existing one
2660 // NUMBER Copy number of the volume
2661 // MOTHER Mother volume name
2662 // X X coord. of the volume in mother ref. sys.
2663 // Y Y coord. of the volume in mother ref. sys.
2664 // Z Z coord. of the volume in mother ref. sys.
2665 // IROT Rotation matrix number w.r.t. mother ref. sys.
2666 // ONLY ONLY/MANY flag
2668 // It positions a previously defined volume in the mother.
2673 Vname(mother,vmother);
2674 gspos(PASSCHARD(vname), nr, PASSCHARD(vmother), x, y, z, irot,
2675 PASSCHARD(konly) PASSCHARL(vname) PASSCHARL(vmother)
2679 //_____________________________________________________________________________
2680 void TGeant3::Gsposp(const char *name, Int_t nr, const char *mother,
2681 Float_t x, Float_t y, Float_t z, Int_t irot,
2682 const char *konly, Float_t *upar, Int_t np )
2685 // Place a copy of generic volume NAME with user number
2686 // NR inside MOTHER, with its parameters UPAR(1..NP)
2691 Vname(mother,vmother);
2692 gsposp(PASSCHARD(vname), nr, PASSCHARD(vmother), x, y, z, irot,
2693 PASSCHARD(konly), upar, np PASSCHARL(vname) PASSCHARL(vmother)
2697 //_____________________________________________________________________________
2698 void TGeant3::Gsrotm(Int_t nmat, Float_t theta1, Float_t phi1, Float_t theta2,
2699 Float_t phi2, Float_t theta3, Float_t phi3)
2702 // nmat Rotation matrix number
2703 // THETA1 Polar angle for axis I
2704 // PHI1 Azimuthal angle for axis I
2705 // THETA2 Polar angle for axis II
2706 // PHI2 Azimuthal angle for axis II
2707 // THETA3 Polar angle for axis III
2708 // PHI3 Azimuthal angle for axis III
2710 // It defines the rotation matrix number IROT.
2712 gsrotm(nmat, theta1, phi1, theta2, phi2, theta3, phi3);
2715 //_____________________________________________________________________________
2716 void TGeant3::Gprotm(Int_t nmat)
2719 // To print rotation matrices structure JROTM
2720 // nmat Rotation matrix number
2725 //_____________________________________________________________________________
2726 Int_t TGeant3::Gsvolu(const char *name, const char *shape, Int_t nmed,
2727 Float_t *upar, Int_t npar)
2731 // SHAPE Volume type
2732 // NUMED Tracking medium number
2733 // NPAR Number of shape parameters
2734 // UPAR Vector containing shape parameters
2736 // It creates a new volume in the JVOLUM data structure.
2742 Vname(shape,vshape);
2743 gsvolu(PASSCHARD(vname), PASSCHARD(vshape), nmed, upar, npar, ivolu
2744 PASSCHARL(vname) PASSCHARL(vshape));
2748 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2750 // T H E D R A W I N G P A C K A G E
2751 // ======================================
2752 // Drawing functions. These functions allow the visualization in several ways
2753 // of the volumes defined in the geometrical data structure. It is possible
2754 // to draw the logical tree of volumes belonging to the detector (DTREE),
2755 // to show their geometrical specification (DSPEC,DFSPC), to draw them
2756 // and their cut views (DRAW, DCUT). Moreover, it is possible to execute
2757 // these commands when the hidden line removal option is activated; in
2758 // this case, the volumes can be also either translated in the space
2759 // (SHIFT), or clipped by boolean operation (CVOL). In addition, it is
2760 // possible to fill the surfaces of the volumes
2761 // with solid colours when the shading option (SHAD) is activated.
2762 // Several tools (ZOOM, LENS) have been developed to zoom detailed parts
2763 // of the detectors or to scan physical events as well.
2764 // Finally, the command MOVE will allow the rotation, translation and zooming
2765 // on real time parts of the detectors or tracks and hits of a simulated event.
2766 // Ray-tracing commands. In case the command (DOPT RAYT ON) is executed,
2767 // the drawing is performed by the Geant ray-tracing;
2768 // automatically, the color is assigned according to the tracking medium of each
2769 // volume and the volumes with a density lower/equal than the air are considered
2770 // transparent; if the option (USER) is set (ON) (again via the command (DOPT)),
2771 // the user can set color and visibility for the desired volumes via the command
2772 // (SATT), as usual, relatively to the attributes (COLO) and (SEEN).
2773 // The resolution can be set via the command (SATT * FILL VALUE), where (VALUE)
2774 // is the ratio between the number of pixels drawn and 20 (user coordinates).
2775 // Parallel view and perspective view are possible (DOPT PROJ PARA/PERS); in the
2776 // first case, we assume that the first mother volume of the tree is a box with
2777 // dimensions 10000 X 10000 X 10000 cm and the view point (infinetely far) is
2778 // 5000 cm far from the origin along the Z axis of the user coordinates; in the
2779 // second case, the distance between the observer and the origin of the world
2780 // reference system is set in cm by the command (PERSP NAME VALUE); grand-angle
2781 // or telescopic effects can be achieved changing the scale factors in the command
2782 // (DRAW). When the final picture does not occupy the full window,
2783 // mapping the space before tracing can speed up the drawing, but can also
2784 // produce less precise results; values from 1 to 4 are allowed in the command
2785 // (DOPT MAPP VALUE), the mapping being more precise for increasing (VALUE); for
2786 // (VALUE = 0) no mapping is performed (therefore max precision and lowest speed).
2787 // The command (VALCUT) allows the cutting of the detector by three planes
2788 // ortogonal to the x,y,z axis. The attribute (LSTY) can be set by the command
2789 // SATT for any desired volume and can assume values from 0 to 7; it determines
2790 // the different light processing to be performed for different materials:
2791 // 0 = dark-matt, 1 = bright-matt, 2 = plastic, 3 = ceramic, 4 = rough-metals,
2792 // 5 = shiny-metals, 6 = glass, 7 = mirror. The detector is assumed to be in the
2793 // dark, the ambient light luminosity is 0.2 for each basic hue (the saturation
2794 // is 0.9) and the observer is assumed to have a light source (therefore he will
2795 // produce parallel light in the case of parallel view and point-like-source
2796 // light in the case of perspective view).
2798 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
2800 //_____________________________________________________________________________
2801 void TGeant3::Gsatt(const char *name, const char *att, Int_t val)
2805 // IOPT Name of the attribute to be set
2806 // IVAL Value to which the attribute is to be set
2808 // name= "*" stands for all the volumes.
2809 // iopt can be chosen among the following :
2811 // WORK 0=volume name is inactive for the tracking
2812 // 1=volume name is active for the tracking (default)
2814 // SEEN 0=volume name is invisible
2815 // 1=volume name is visible (default)
2816 // -1=volume invisible with all its descendants in the tree
2817 // -2=volume visible but not its descendants in the tree
2819 // LSTY line style 1,2,3,... (default=1)
2820 // LSTY=7 will produce a very precise approximation for
2821 // revolution bodies.
2823 // LWID line width -7,...,1,2,3,..7 (default=1)
2824 // LWID<0 will act as abs(LWID) was set for the volume
2825 // and for all the levels below it. When SHAD is 'ON', LWID
2826 // represent the linewidth of the scan lines filling the surfaces
2827 // (whereas the FILL value represent their number). Therefore
2828 // tuning this parameter will help to obtain the desired
2829 // quality/performance ratio.
2831 // COLO colour code -166,...,1,2,..166 (default=1)
2833 // n=2=red; n=17+m, m=0,25, increasing luminosity according to 'm';
2834 // n=3=green; n=67+m, m=0,25, increasing luminosity according to 'm';
2835 // n=4=blue; n=117+m, m=0,25, increasing luminosity according to 'm';
2836 // n=5=yellow; n=42+m, m=0,25, increasing luminosity according to 'm';
2837 // n=6=violet; n=142+m, m=0,25, increasing luminosity according to 'm';
2838 // n=7=lightblue; n=92+m, m=0,25, increasing luminosity according to 'm';
2839 // colour=n*10+m, m=1,2,...9, will produce the same colour
2840 // as 'n', but with increasing luminosity according to 'm';
2841 // COLO<0 will act as if abs(COLO) was set for the volume
2842 // and for all the levels below it.
2843 // When for a volume the attribute FILL is > 1 (and the
2844 // option SHAD is on), the ABS of its colour code must be < 8
2845 // because an automatic shading of its faces will be
2848 // FILL (1992) fill area -7,...,0,1,...7 (default=0)
2849 // when option SHAD is "on" the FILL attribute of any
2850 // volume can be set different from 0 (normal drawing);
2851 // if it is set to 1, the faces of such volume will be filled
2852 // with solid colours; if ABS(FILL) is > 1, then a light
2853 // source is placed along the observer line, and the faces of
2854 // such volumes will be painted by colours whose luminosity
2855 // will depend on the amount of light reflected;
2856 // if ABS(FILL) = 1, then it is possible to use all the 166
2857 // colours of the colour table, becouse the automatic shading
2858 // is not performed;
2859 // for increasing values of FILL the drawing will be performed
2860 // with higher and higher resolution improving the quality (the
2861 // number of scan lines used to fill the faces increases with FILL);
2862 // it is possible to set different values of FILL
2863 // for different volumes, in order to optimize at the same time
2864 // the performance and the quality of the picture;
2865 // FILL<0 will act as if abs(FILL) was set for the volume
2866 // and for all the levels below it.
2867 // This kind of drawing can be saved in 'picture files'
2868 // or in view banks.
2869 // 0=drawing without fill area
2870 // 1=faces filled with solid colours and resolution = 6
2871 // 2=lowest resolution (very fast)
2872 // 3=default resolution
2873 // 4=.................
2874 // 5=.................
2875 // 6=.................
2877 // Finally, if a coloured background is desired, the FILL
2878 // attribute for the first volume of the tree must be set
2879 // equal to -abs(colo), colo being >0 and <166.
2881 // SET set number associated to volume name
2882 // DET detector number associated to volume name
2883 // DTYP detector type (1,2)
2890 gsatt(PASSCHARD(vname), PASSCHARD(vatt), val PASSCHARL(vname)
2894 //_____________________________________________________________________________
2895 void TGeant3::Gfpara(const char *name, Int_t number, Int_t intext, Int_t& npar,
2896 Int_t& natt, Float_t* par, Float_t* att)
2899 // Find the parameters of a volume
2901 gfpara(PASSCHARD(name), number, intext, npar, natt, par, att
2905 //_____________________________________________________________________________
2906 void TGeant3::Gckpar(Int_t ish, Int_t npar, Float_t* par)
2909 // Check the parameters of a shape
2911 gckpar(ish,npar,par);
2914 //_____________________________________________________________________________
2915 void TGeant3::Gckmat(Int_t itmed, char* natmed)
2918 // Check the parameters of a tracking medium
2920 gckmat(itmed, PASSCHARD(natmed) PASSCHARL(natmed));
2923 //_____________________________________________________________________________
2924 Int_t TGeant3::Glvolu(Int_t nlev, Int_t *lnam,Int_t *lnum)
2927 // nlev number of leveles deap into the volume tree
2928 // size of the arrays lnam and lnum
2929 // lnam an integer array whos 4 bytes contain the askii code for the
2931 // lnum an integer array containing the copy numbers for that specific
2934 // This routine fills the volulme paramters in common /gcvolu/ for a
2935 // physical tree, specified by the list lnam and lnum of volume names
2936 // and numbers, and for all its ascendants up to level 1. This routine
2937 // is optimsed and does not re-compute the part of the history already
2938 // available in GCVOLU. This means that if it is used in user programs
2939 // outside the usual framwork of the tracking, the user has to initilise
2940 // to zero NLEVEL in the common GCVOLU. It return 0 if there were no
2941 // problems in make the call.
2944 glvolu(nlev, lnam, lnum, ier);
2948 //_____________________________________________________________________________
2949 void TGeant3::Gdelete(Int_t iview)
2952 // IVIEW View number
2954 // It deletes a view bank from memory.
2959 //_____________________________________________________________________________
2960 void TGeant3::Gdopen(Int_t iview)
2963 // IVIEW View number
2965 // When a drawing is very complex and requires a long time to be
2966 // executed, it can be useful to store it in a view bank: after a
2967 // call to DOPEN and the execution of the drawing (nothing will
2968 // appear on the screen), and after a necessary call to DCLOSE,
2969 // the contents of the bank can be displayed in a very fast way
2970 // through a call to DSHOW; therefore, the detector can be easily
2971 // zoomed many times in different ways. Please note that the pictures
2972 // with solid colours can now be stored in a view bank or in 'PICTURE FILES'
2979 //_____________________________________________________________________________
2980 void TGeant3::Gdclose()
2983 // It closes the currently open view bank; it must be called after the
2984 // end of the drawing to be stored.
2989 //_____________________________________________________________________________
2990 void TGeant3::Gdshow(Int_t iview)
2993 // IVIEW View number
2995 // It shows on the screen the contents of a view bank. It
2996 // can be called after a view bank has been closed.
3001 //_____________________________________________________________________________
3002 void TGeant3::Gdopt(const char *name,const char *value)
3006 // VALUE Option value
3008 // To set/modify the drawing options.
3011 // THRZ ON Draw tracks in R vs Z
3012 // OFF (D) Draw tracks in X,Y,Z
3015 // PROJ PARA (D) Parallel projection
3017 // TRAK LINE (D) Trajectory drawn with lines
3018 // POIN " " with markers
3019 // HIDE ON Hidden line removal using the CG package
3020 // OFF (D) No hidden line removal
3021 // SHAD ON Fill area and shading of surfaces.
3022 // OFF (D) Normal hidden line removal.
3023 // RAYT ON Ray-tracing on.
3024 // OFF (D) Ray-tracing off.
3025 // EDGE OFF Does not draw contours when shad is on.
3026 // ON (D) Normal shading.
3027 // MAPP 1,2,3,4 Mapping before ray-tracing.
3028 // 0 (D) No mapping.
3029 // USER ON User graphics options in the raytracing.
3030 // OFF (D) Automatic graphics options.
3036 Vname(value,vvalue);
3037 gdopt(PASSCHARD(vname), PASSCHARD(vvalue) PASSCHARL(vname)
3041 //_____________________________________________________________________________
3042 void TGeant3::Gdraw(const char *name,Float_t theta, Float_t phi, Float_t psi,
3043 Float_t u0,Float_t v0,Float_t ul,Float_t vl)
3048 // THETA Viewing angle theta (for 3D projection)
3049 // PHI Viewing angle phi (for 3D projection)
3050 // PSI Viewing angle psi (for 2D rotation)
3051 // U0 U-coord. (horizontal) of volume origin
3052 // V0 V-coord. (vertical) of volume origin
3053 // SU Scale factor for U-coord.
3054 // SV Scale factor for V-coord.
3056 // This function will draw the volumes,
3057 // selected with their graphical attributes, set by the Gsatt
3058 // facility. The drawing may be performed with hidden line removal
3059 // and with shading effects according to the value of the options HIDE
3060 // and SHAD; if the option SHAD is ON, the contour's edges can be
3061 // drawn or not. If the option HIDE is ON, the detector can be
3062 // exploded (BOMB), clipped with different shapes (CVOL), and some
3063 // of its parts can be shifted from their original
3064 // position (SHIFT). When HIDE is ON, if
3065 // the drawing requires more than the available memory, the program
3066 // will evaluate and display the number of missing words
3067 // (so that the user can increase the
3068 // size of its ZEBRA store). Finally, at the end of each drawing (with HIDE on),
3069 // the program will print messages about the memory used and
3070 // statistics on the volumes' visibility.
3071 // The following commands will produce the drawing of a green
3072 // volume, specified by NAME, without using the hidden line removal
3073 // technique, using the hidden line removal technique,
3074 // with different linewidth and colour (red), with
3075 // solid colour, with shading of surfaces, and without edges.
3076 // Finally, some examples are given for the ray-tracing. (A possible
3077 // string for the NAME of the volume can be found using the command DTREE).
3083 if (fGcvdma->raytra != 1) {
3084 gdraw(PASSCHARD(vname), theta,phi,psi,u0,v0,ul,vl PASSCHARL(vname));
3086 gdrayt(PASSCHARD(vname), theta,phi,psi,u0,v0,ul,vl PASSCHARL(vname));
3090 //_____________________________________________________________________________
3091 void TGeant3::Gdrawc(const char *name,Int_t axis, Float_t cut,Float_t u0,
3092 Float_t v0,Float_t ul,Float_t vl)
3097 // CUTVAL Cut plane distance from the origin along the axis
3099 // U0 U-coord. (horizontal) of volume origin
3100 // V0 V-coord. (vertical) of volume origin
3101 // SU Scale factor for U-coord.
3102 // SV Scale factor for V-coord.
3104 // The cut plane is normal to caxis (X,Y,Z), corresponding to iaxis (1,2,3),
3105 // and placed at the distance cutval from the origin.
3106 // The resulting picture is seen from the the same axis.
3107 // When HIDE Mode is ON, it is possible to get the same effect with
3108 // the CVOL/BOX function.
3114 gdrawc(PASSCHARD(vname), axis,cut,u0,v0,ul,vl PASSCHARL(vname));
3117 //_____________________________________________________________________________
3118 void TGeant3::Gdrawx(const char *name,Float_t cutthe, Float_t cutphi,
3119 Float_t cutval, Float_t theta, Float_t phi, Float_t u0,
3120 Float_t v0,Float_t ul,Float_t vl)
3124 // CUTTHE Theta angle of the line normal to cut plane
3125 // CUTPHI Phi angle of the line normal to cut plane
3126 // CUTVAL Cut plane distance from the origin along the axis
3128 // THETA Viewing angle theta (for 3D projection)
3129 // PHI Viewing angle phi (for 3D projection)
3130 // U0 U-coord. (horizontal) of volume origin
3131 // V0 V-coord. (vertical) of volume origin
3132 // SU Scale factor for U-coord.
3133 // SV Scale factor for V-coord.
3135 // The cut plane is normal to the line given by the cut angles
3136 // cutthe and cutphi and placed at the distance cutval from the origin.
3137 // The resulting picture is seen from the viewing angles theta,phi.
3143 gdrawx(PASSCHARD(vname), cutthe,cutphi,cutval,theta,phi,u0,v0,ul,vl
3147 //_____________________________________________________________________________
3148 void TGeant3::Gdhead(Int_t isel, const char *name, Float_t chrsiz)
3153 // ISEL Option flag D=111110
3155 // CHRSIZ Character size (cm) of title NAME D=0.6
3158 // 0 to have only the header lines
3159 // xxxxx1 to add the text name centered on top of header
3160 // xxxx1x to add global detector name (first volume) on left
3161 // xxx1xx to add date on right
3162 // xx1xxx to select thick characters for text on top of header
3163 // x1xxxx to add the text 'EVENT NR x' on top of header
3164 // 1xxxxx to add the text 'RUN NR x' on top of header
3165 // NOTE that ISEL=x1xxx1 or ISEL=1xxxx1 are illegal choices,
3166 // i.e. they generate overwritten text.
3168 gdhead(isel,PASSCHARD(name),chrsiz PASSCHARL(name));
3171 //_____________________________________________________________________________
3172 void TGeant3::Gdman(Float_t u, Float_t v, const char *type)
3175 // Draw a 2D-man at position (U0,V0)
3177 // U U-coord. (horizontal) of the centre of man' R
3178 // V V-coord. (vertical) of the centre of man' R
3179 // TYPE D='MAN' possible values: 'MAN,WM1,WM2,WM3'
3181 // CALL GDMAN(u,v),CALL GDWMN1(u,v),CALL GDWMN2(u,v),CALL GDWMN2(u,v)
3182 // It superimposes the picure of a man or of a woman, chosen among
3183 // three different ones, with the same scale factors as the detector
3184 // in the current drawing.
3187 if (opt.Contains("WM1")) {
3189 } else if (opt.Contains("WM3")) {
3191 } else if (opt.Contains("WM2")) {
3198 //_____________________________________________________________________________
3199 void TGeant3::Gdspec(const char *name)
3204 // Shows 3 views of the volume (two cut-views and a 3D view), together with
3205 // its geometrical specifications. The 3D drawing will
3206 // be performed according the current values of the options HIDE and
3207 // SHAD and according the current SetClipBox clipping parameters for that
3214 gdspec(PASSCHARD(vname) PASSCHARL(vname));
3217 //_____________________________________________________________________________
3218 void TGeant3::DrawOneSpec(const char *name)
3221 // Function called when one double-clicks on a volume name
3222 // in a TPavelabel drawn by Gdtree.
3224 THIGZ *higzSave = gHigz;
3225 higzSave->SetName("higzSave");
3226 THIGZ *higzSpec = (THIGZ*)gROOT->FindObject("higzSpec");
3227 //printf("DrawOneSpec, gHigz=%x, higzSpec=%x\n",gHigz,higzSpec);
3228 if (higzSpec) gHigz = higzSpec;
3229 else higzSpec = new THIGZ(kDefSize);
3230 higzSpec->SetName("higzSpec");
3235 gdspec(PASSCHARD(vname) PASSCHARL(vname));
3238 higzSave->SetName("higz");
3242 //_____________________________________________________________________________
3243 void TGeant3::Gdtree(const char *name,Int_t levmax, Int_t isel)
3247 // LEVMAX Depth level
3250 // This function draws the logical tree,
3251 // Each volume in the tree is represented by a TPaveTree object.
3252 // Double-clicking on a TPaveTree draws the specs of the corresponding volume.
3253 // Use TPaveTree pop-up menu to select:
3256 // - drawing tree of parent
3262 gdtree(PASSCHARD(vname), levmax, isel PASSCHARL(vname));
3263 gHigz->SetPname("");
3266 //_____________________________________________________________________________
3267 void TGeant3::GdtreeParent(const char *name,Int_t levmax, Int_t isel)
3271 // LEVMAX Depth level
3274 // This function draws the logical tree of the parent of name.
3278 // Scan list of volumes in JVOLUM
3280 Int_t gname, i, jvo, in, nin, jin, num;
3281 strncpy((char *) &gname, name, 4);
3282 for(i=1; i<=fGcnum->nvolum; i++) {
3283 jvo = fZlq[fGclink->jvolum-i];
3284 nin = Int_t(fZq[jvo+3]);
3285 if (nin == -1) nin = 1;
3286 for (in=1;in<=nin;in++) {
3288 num = Int_t(fZq[jin+2]);
3289 if(gname == fZiq[fGclink->jvolum+num]) {
3290 strncpy(vname,(char*)&fZiq[fGclink->jvolum+i],4);
3292 gdtree(PASSCHARD(vname), levmax, isel PASSCHARL(vname));
3293 gHigz->SetPname("");
3300 //_____________________________________________________________________________
3301 void TGeant3::SetABAN(Int_t par)
3304 // par = 1 particles will be stopped according to their residual
3305 // range if they are not in a sensitive material and are
3306 // far enough from the boundary
3307 // 0 particles are transported normally
3309 fGcphys->dphys1 = par;
3313 //_____________________________________________________________________________
3314 void TGeant3::SetANNI(Int_t par)
3317 // To control positron annihilation.
3318 // par =0 no annihilation
3319 // =1 annihilation. Decays processed.
3320 // =2 annihilation. No decay products stored.
3322 fGcphys->ianni = par;
3326 //_____________________________________________________________________________
3327 void TGeant3::SetAUTO(Int_t par)
3330 // To control automatic calculation of tracking medium parameters:
3331 // par =0 no automatic calculation;
3332 // =1 automati calculation.
3334 fGctrak->igauto = par;
3338 //_____________________________________________________________________________
3339 void TGeant3::SetBOMB(Float_t boom)
3342 // BOOM : Exploding factor for volumes position
3344 // To 'explode' the detector. If BOOM is positive (values smaller
3345 // than 1. are suggested, but any value is possible)
3346 // all the volumes are shifted by a distance
3347 // proportional to BOOM along the direction between their centre
3348 // and the origin of the MARS; the volumes which are symmetric
3349 // with respect to this origin are simply not shown.
3350 // BOOM equal to 0 resets the normal mode.
3351 // A negative (greater than -1.) value of
3352 // BOOM will cause an 'implosion'; for even lower values of BOOM
3353 // the volumes' positions will be reflected respect to the origin.
3354 // This command can be useful to improve the 3D effect for very
3355 // complex detectors. The following commands will make explode the
3362 //_____________________________________________________________________________
3363 void TGeant3::SetBREM(Int_t par)
3366 // To control bremstrahlung.
3367 // par =0 no bremstrahlung
3368 // =1 bremstrahlung. Photon processed.
3369 // =2 bremstrahlung. No photon stored.
3371 fGcphys->ibrem = par;
3375 //_____________________________________________________________________________
3376 void TGeant3::SetCKOV(Int_t par)
3379 // To control Cerenkov production
3380 // par =0 no Cerenkov;
3382 // =2 Cerenkov with primary stopped at each step.
3384 fGctlit->itckov = par;
3388 //_____________________________________________________________________________
3389 void TGeant3::SetClipBox(const char *name,Float_t xmin,Float_t xmax,
3390 Float_t ymin,Float_t ymax,Float_t zmin,Float_t zmax)
3393 // The hidden line removal technique is necessary to visualize properly
3394 // very complex detectors. At the same time, it can be useful to visualize
3395 // the inner elements of a detector in detail. This function allows
3396 // subtractions (via boolean operation) of BOX shape from any part of
3397 // the detector, therefore showing its inner contents.
3398 // If "*" is given as the name of the
3399 // volume to be clipped, all volumes are clipped by the given box.
3400 // A volume can be clipped at most twice.
3401 // if a volume is explicitely clipped twice,
3402 // the "*" will not act on it anymore. Giving "." as the name
3403 // of the volume to be clipped will reset the clipping.
3405 // NAME Name of volume to be clipped
3407 // XMIN Lower limit of the Shape X coordinate
3408 // XMAX Upper limit of the Shape X coordinate
3409 // YMIN Lower limit of the Shape Y coordinate
3410 // YMAX Upper limit of the Shape Y coordinate
3411 // ZMIN Lower limit of the Shape Z coordinate
3412 // ZMAX Upper limit of the Shape Z coordinate
3414 // This function performs a boolean subtraction between the volume
3415 // NAME and a box placed in the MARS according the values of the given
3421 setclip(PASSCHARD(vname),xmin,xmax,ymin,ymax,zmin,zmax PASSCHARL(vname));
3424 //_____________________________________________________________________________
3425 void TGeant3::SetCOMP(Int_t par)
3428 // To control Compton scattering
3429 // par =0 no Compton
3430 // =1 Compton. Electron processed.
3431 // =2 Compton. No electron stored.
3434 fGcphys->icomp = par;
3437 //_____________________________________________________________________________
3438 void TGeant3::SetCUTS(Float_t cutgam,Float_t cutele,Float_t cutneu,
3439 Float_t cuthad,Float_t cutmuo ,Float_t bcute ,
3440 Float_t bcutm ,Float_t dcute ,Float_t dcutm ,
3441 Float_t ppcutm, Float_t tofmax)
3444 // CUTGAM Cut for gammas D=0.001
3445 // CUTELE Cut for electrons D=0.001
3446 // CUTHAD Cut for charged hadrons D=0.01
3447 // CUTNEU Cut for neutral hadrons D=0.01
3448 // CUTMUO Cut for muons D=0.01
3449 // BCUTE Cut for electron brems. D=-1.
3450 // BCUTM Cut for muon brems. D=-1.
3451 // DCUTE Cut for electron delta-rays D=-1.
3452 // DCUTM Cut for muon delta-rays D=-1.
3453 // PPCUTM Cut for e+e- pairs by muons D=0.01
3454 // TOFMAX Time of flight cut D=1.E+10
3456 // If the default values (-1.) for BCUTE ,BCUTM ,DCUTE ,DCUTM
3457 // are not modified, they will be set to CUTGAM,CUTGAM,CUTELE,CUTELE
3459 // If one of the parameters from CUTGAM to PPCUTM included
3460 // is modified, cross-sections and energy loss tables must be
3461 // recomputed via the function Gphysi.
3463 fGccuts->cutgam = cutgam;
3464 fGccuts->cutele = cutele;
3465 fGccuts->cutneu = cutneu;
3466 fGccuts->cuthad = cuthad;
3467 fGccuts->cutmuo = cutmuo;
3468 fGccuts->bcute = bcute;
3469 fGccuts->bcutm = bcutm;
3470 fGccuts->dcute = dcute;
3471 fGccuts->dcutm = dcutm;
3472 fGccuts->ppcutm = ppcutm;
3473 fGccuts->tofmax = tofmax;
3476 //_____________________________________________________________________________
3477 void TGeant3::SetDCAY(Int_t par)
3480 // To control Decay mechanism.
3481 // par =0 no decays.
3482 // =1 Decays. secondaries processed.
3483 // =2 Decays. No secondaries stored.
3485 fGcphys->idcay = par;
3489 //_____________________________________________________________________________
3490 void TGeant3::SetDEBU(Int_t emin, Int_t emax, Int_t emod)
3493 // Set the debug flag and frequency
3494 // Selected debug output will be printed from
3495 // event emin to even emax each emod event
3497 fGcflag->idemin = emin;
3498 fGcflag->idemax = emax;
3499 fGcflag->itest = emod;
3503 //_____________________________________________________________________________
3504 void TGeant3::SetDRAY(Int_t par)
3507 // To control delta rays mechanism.
3508 // par =0 no delta rays.
3509 // =1 Delta rays. secondaries processed.
3510 // =2 Delta rays. No secondaries stored.
3512 fGcphys->idray = par;
3515 //_____________________________________________________________________________
3516 void TGeant3::SetERAN(Float_t ekmin, Float_t ekmax, Int_t nekbin)
3519 // To control cross section tabulations
3520 // ekmin = minimum kinetic energy in GeV
3521 // ekmax = maximum kinetic energy in GeV
3522 // nekbin = number of logatithmic bins (<200)
3524 fGcmulo->ekmin = ekmin;
3525 fGcmulo->ekmax = ekmax;
3526 fGcmulo->nekbin = nekbin;
3529 //_____________________________________________________________________________
3530 void TGeant3::SetHADR(Int_t par)
3533 // To control hadronic interactions.
3534 // par =0 no hadronic interactions.
3535 // =1 Hadronic interactions. secondaries processed.
3536 // =2 Hadronic interactions. No secondaries stored.
3538 fGcphys->ihadr = par;
3541 //_____________________________________________________________________________
3542 void TGeant3::SetKINE(Int_t kine, Float_t xk1, Float_t xk2, Float_t xk3,
3543 Float_t xk4, Float_t xk5, Float_t xk6, Float_t xk7,
3544 Float_t xk8, Float_t xk9, Float_t xk10)
3547 // Set the variables in /GCFLAG/ IKINE, PKINE(10)
3548 // Their meaning is user defined
3550 fGckine->ikine = kine;
3551 fGckine->pkine[0] = xk1;
3552 fGckine->pkine[1] = xk2;
3553 fGckine->pkine[2] = xk3;
3554 fGckine->pkine[3] = xk4;
3555 fGckine->pkine[4] = xk5;
3556 fGckine->pkine[5] = xk6;
3557 fGckine->pkine[6] = xk7;
3558 fGckine->pkine[7] = xk8;
3559 fGckine->pkine[8] = xk9;
3560 fGckine->pkine[9] = xk10;
3563 //_____________________________________________________________________________
3564 void TGeant3::SetLOSS(Int_t par)
3567 // To control energy loss.
3568 // par =0 no energy loss;
3569 // =1 restricted energy loss fluctuations;
3570 // =2 complete energy loss fluctuations;
3572 // =4 no energy loss fluctuations.
3573 // If the value ILOSS is changed, then cross-sections and energy loss
3574 // tables must be recomputed via the command 'PHYSI'.
3576 fGcphys->iloss = par;
3580 //_____________________________________________________________________________
3581 void TGeant3::SetMULS(Int_t par)
3584 // To control multiple scattering.
3585 // par =0 no multiple scattering.
3586 // =1 Moliere or Coulomb scattering.
3587 // =2 Moliere or Coulomb scattering.
3588 // =3 Gaussian scattering.
3590 fGcphys->imuls = par;
3594 //_____________________________________________________________________________
3595 void TGeant3::SetMUNU(Int_t par)
3598 // To control muon nuclear interactions.
3599 // par =0 no muon-nuclear interactions.
3600 // =1 Nuclear interactions. Secondaries processed.
3601 // =2 Nuclear interactions. Secondaries not processed.
3603 fGcphys->imunu = par;
3606 //_____________________________________________________________________________
3607 void TGeant3::SetOPTI(Int_t par)
3610 // This flag controls the tracking optimisation performed via the
3612 // 1 no optimisation at all; GSORD calls disabled;
3613 // 0 no optimisation; only user calls to GSORD kept;
3614 // 1 all non-GSORDered volumes are ordered along the best axis;
3615 // 2 all volumes are ordered along the best axis.
3617 fGcopti->ioptim = par;
3620 //_____________________________________________________________________________
3621 void TGeant3::SetPAIR(Int_t par)
3624 // To control pair production mechanism.
3625 // par =0 no pair production.
3626 // =1 Pair production. secondaries processed.
3627 // =2 Pair production. No secondaries stored.
3629 fGcphys->ipair = par;
3633 //_____________________________________________________________________________
3634 void TGeant3::SetPFIS(Int_t par)
3637 // To control photo fission mechanism.
3638 // par =0 no photo fission.
3639 // =1 Photo fission. secondaries processed.
3640 // =2 Photo fission. No secondaries stored.
3642 fGcphys->ipfis = par;
3645 //_____________________________________________________________________________
3646 void TGeant3::SetPHOT(Int_t par)
3649 // To control Photo effect.
3650 // par =0 no photo electric effect.
3651 // =1 Photo effect. Electron processed.
3652 // =2 Photo effect. No electron stored.
3654 fGcphys->iphot = par;
3657 //_____________________________________________________________________________
3658 void TGeant3::SetRAYL(Int_t par)
3661 // To control Rayleigh scattering.
3662 // par =0 no Rayleigh scattering.
3665 fGcphys->irayl = par;
3668 //_____________________________________________________________________________
3669 void TGeant3::SetSTRA(Int_t par)
3672 // To control energy loss fluctuations
3673 // with the PhotoAbsorption Ionisation model.
3674 // par =0 no Straggling.
3675 // =1 Straggling yes => no Delta rays.
3677 fGcphlt->istra = par;
3680 //_____________________________________________________________________________
3681 void TGeant3::SetSWIT(Int_t sw, Int_t val)
3685 // val New switch value
3687 // Change one element of array ISWIT(10) in /GCFLAG/
3689 if (sw <= 0 || sw > 10) return;
3690 fGcflag->iswit[sw-1] = val;
3694 //_____________________________________________________________________________
3695 void TGeant3::SetTRIG(Int_t nevents)
3698 // Set number of events to be run
3700 fGcflag->nevent = nevents;
3703 //_____________________________________________________________________________
3704 void TGeant3::SetUserDecay(Int_t pdg)
3707 // Force the decays of particles to be done with Pythia
3708 // and not with the Geant routines.
3709 // just kill pointers doing mzdrop
3711 Int_t ipart = IdFromPDG(pdg);
3713 printf("Particle %d not in geant\n",pdg);
3716 Int_t jpart=fGclink->jpart;
3717 Int_t jpa=fZlq[jpart-ipart];
3720 Int_t jpa1=fZlq[jpa-1];
3722 mzdrop(fGcbank->ixcons,jpa1,PASSCHARD(" ") PASSCHARL(" "));
3723 Int_t jpa2=fZlq[jpa-2];
3725 mzdrop(fGcbank->ixcons,jpa2,PASSCHARD(" ") PASSCHARL(" "));
3729 //______________________________________________________________________________
3730 void TGeant3::Vname(const char *name, char *vname)
3733 // convert name to upper case. Make vname at least 4 chars
3735 Int_t l = strlen(name);
3738 for (i=0;i<l;i++) vname[i] = toupper(name[i]);
3739 for (i=l;i<4;i++) vname[i] = ' ';
3743 //______________________________________________________________________________
3744 void TGeant3::Ertrgo()
3747 // Perform the tracking of the track Track parameters are in VECT
3752 //______________________________________________________________________________
3753 void TGeant3::Ertrak(const Float_t *const x1, const Float_t *const p1,
3754 const Float_t *x2, const Float_t *p2,
3755 Int_t ipa, Option_t *chopt)
3757 //************************************************************************
3759 //* Perform the tracking of the track from point X1 to *
3761 //* (Before calling this routine the user should also provide *
3762 //* the input informations in /EROPTS/ and /ERTRIO/ *
3763 //* using subroutine EUFIL(L/P/V) *
3764 //* X1 - Starting coordinates (Cartesian) *
3765 //* P1 - Starting 3-momentum (Cartesian) *
3766 //* X2 - Final coordinates (Cartesian) *
3767 //* P2 - Final 3-momentum (Cartesian) *
3768 //* IPA - Particle code (a la GEANT) of the track *
3771 //* 'B' 'Backward tracking' - i.e. energy loss *
3772 //* added to the current energy *
3773 //* 'E' 'Exact' calculation of errors assuming *
3774 //* helix (i.e. pathlength not *
3775 //* assumed as infinitesimal) *
3776 //* 'L' Tracking upto prescribed Lengths reached *
3777 //* 'M' 'Mixed' prediction (not yet coded) *
3778 //* 'O' Tracking 'Only' without calculating errors *
3779 //* 'P' Tracking upto prescribed Planes reached *
3780 //* 'V' Tracking upto prescribed Volumes reached *
3781 //* 'X' Tracking upto prescribed Point approached *
3783 //* Interface with GEANT : *
3784 //* Track parameters are in /CGKINE/ and /GCTRAK/ *
3786 //* ==>Called by : USER *
3787 //* Authors M.Maire, E.Nagy ********//* *
3789 //************************************************************************
3790 ertrak(x1,p1,x2,p2,ipa,PASSCHARD(chopt) PASSCHARL(chopt));
3793 //_____________________________________________________________________________
3794 void TGeant3::WriteEuclid(const char* filnam, const char* topvol,
3795 Int_t number, Int_t nlevel)
3799 // ******************************************************************
3801 // * Write out the geometry of the detector in EUCLID file format *
3803 // * filnam : will be with the extension .euc *
3804 // * topvol : volume name of the starting node *
3805 // * number : copy number of topvol (relevant for gsposp) *
3806 // * nlevel : number of levels in the tree structure *
3807 // * to be written out, starting from topvol *
3809 // * Author : M. Maire *
3811 // ******************************************************************
3813 // File filnam.tme is written out with the definitions of tracking
3814 // medias and materials.
3815 // As to restore original numbers for materials and medias, program
3816 // searches in the file euc_medi.dat and comparing main parameters of
3817 // the mat. defined inside geant and the one in file recognizes them
3818 // and is able to take number from file. If for any material or medium,
3819 // this procedure fails, ordering starts from 1.
3820 // Arrays IOTMED and IOMATE are used for this procedure
3822 const char kShape[][5]={"BOX ","TRD1","TRD2","TRAP","TUBE","TUBS","CONE",
3823 "CONS","SPHE","PARA","PGON","PCON","ELTU","HYPE",
3825 Int_t i, end, itm, irm, jrm, k, nmed;
3829 char *filext, *filetme;
3830 char natmed[21], namate[21];
3831 char natmedc[21], namatec[21];
3832 char key[5], name[5], mother[5], konly[5];
3834 Int_t iadvol, iadtmd, iadrot, nwtot, iret;
3835 Int_t mlevel, numbr, natt, numed, nin, ndata;
3836 Int_t iname, ivo, ish, jvo, nvstak, ivstak;
3837 Int_t jdiv, ivin, in, jin, jvin, irot;
3838 Int_t jtm, imat, jma, flag=0, imatc;
3839 Float_t az, dens, radl, absl, a, step, x, y, z;
3840 Int_t npar, ndvmx, left;
3841 Float_t zc, densc, radlc, abslc, c0, tmaxfd;
3843 Int_t iomate[100], iotmed[100];
3844 Float_t par[50], att[20], ubuf[50];
3847 Int_t level, ndiv, iaxe;
3848 Int_t itmedc, nmatc, isvolc, ifieldc, nwbufc, isvol, nmat, ifield, nwbuf;
3849 Float_t fieldmc, tmaxfdc, stemaxc, deemaxc, epsilc, stminc, fieldm;
3850 Float_t tmaxf, stemax, deemax, epsil, stmin;
3851 const char *k10000="!\n%s\n!\n";
3852 //Open the input file
3854 for(i=0;i<end;i++) if(filnam[i]=='.') {
3858 filext=new char[end+5];
3859 filetme=new char[end+5];
3860 strncpy(filext,filnam,end);
3861 strncpy(filetme,filnam,end);
3863 // *** The output filnam name will be with extension '.euc'
3864 strcpy(&filext[end],".euc");
3865 strcpy(&filetme[end],".tme");
3866 lun=fopen(filext,"w");
3868 // *** Initialisation of the working space
3869 iadvol=fGcnum->nvolum;
3870 iadtmd=iadvol+fGcnum->nvolum;
3871 iadrot=iadtmd+fGcnum->ntmed;
3872 if(fGclink->jrotm) {
3873 fGcnum->nrotm=fZiq[fGclink->jrotm-2];
3877 nwtot=iadrot+fGcnum->nrotm;
3878 qws = new float[nwtot+1];
3879 for (i=0;i<nwtot+1;i++) qws[i]=0;
3882 if(nlevel==0) mlevel=20;
3884 // *** find the top volume and put it in the stak
3885 numbr = number>0 ? number : 1;
3886 Gfpara(topvol,numbr,1,npar,natt,par,att);
3888 printf(" *** GWEUCL *** top volume : %s number : %3d can not be a valid root\n",
3893 // *** authorized shape ?
3894 strncpy((char *)&iname, topvol, 4);
3896 for(i=1; i<=fGcnum->nvolum; i++) if(fZiq[fGclink->jvolum+i]==iname) {
3900 jvo = fZlq[fGclink->jvolum-ivo];
3901 ish = Int_t (fZq[jvo+2]);
3903 printf(" *** GWEUCL *** top volume : %s number : %3d can not be a valid root\n",
3910 iws[iadvol+ivo] = level;
3913 //*** flag all volumes and fill the stak
3917 // pick the next volume in stak
3919 ivo = TMath::Abs(iws[ivstak]);
3920 jvo = fZlq[fGclink->jvolum - ivo];
3922 // flag the tracking medium
3923 numed = Int_t (fZq[jvo + 4]);
3924 iws[iadtmd + numed] = 1;
3926 // get the daughters ...
3927 level = iws[iadvol+ivo];
3928 if (level < mlevel) {
3930 nin = Int_t (fZq[jvo + 3]);
3932 // from division ...
3934 jdiv = fZlq[jvo - 1];
3935 ivin = Int_t (fZq[jdiv + 2]);
3937 iws[nvstak] = -ivin;
3938 iws[iadvol+ivin] = level;
3940 // from position ...
3941 } else if (nin > 0) {
3942 for(in=1; in<=nin; in++) {
3943 jin = fZlq[jvo - in];
3944 ivin = Int_t (fZq[jin + 2 ]);
3945 jvin = fZlq[fGclink->jvolum - ivin];
3946 ish = Int_t (fZq[jvin + 2]);
3947 // authorized shape ?
3949 // not yet flagged ?
3950 if (iws[iadvol+ivin]==0) {
3953 iws[iadvol+ivin] = level;
3955 // flag the rotation matrix
3956 irot = Int_t ( fZq[jin + 4 ]);
3957 if (irot > 0) iws[iadrot+irot] = 1;
3963 // next volume in stak ?
3964 if (ivstak < nvstak) goto L10;
3966 // *** restore original material and media numbers
3967 // file euc_medi.dat is needed to compare materials and medias
3969 FILE* luncor=fopen("euc_medi.dat","r");
3972 for(itm=1; itm<=fGcnum->ntmed; itm++) {
3973 if (iws[iadtmd+itm] > 0) {
3974 jtm = fZlq[fGclink->jtmed-itm];
3975 strncpy(natmed,(char *)&fZiq[jtm+1],20);
3976 imat = Int_t (fZq[jtm+6]);
3977 jma = fZlq[fGclink->jmate-imat];
3979 printf(" *** GWEUCL *** material not defined for tracking medium %5i %s\n",itm,natmed);
3982 strncpy(namate,(char *)&fZiq[jma+1],20);
3985 //** find the material original number
3988 iret=fscanf(luncor,"%4s,%130s",key,card);
3989 if(iret<=0) goto L26;
3991 if(!strcmp(key,"MATE")) {
3992 sscanf(card,"%d %s %f %f %f %f %f %d",&imatc,namatec,&az,&zc,&densc,&radlc,&abslc,&nparc);
3993 Gfmate(imat,namate,a,z,dens,radl,absl,par,npar);
3994 if(!strcmp(namatec,namate)) {
3995 if(az==a && zc==z && densc==dens && radlc==radl
3996 && abslc==absl && nparc==nparc) {
3999 printf("*** GWEUCL *** material : %3d '%s' restored as %3d\n",imat,namate,imatc);
4001 printf("*** GWEUCL *** different definitions for material: %s\n",namate);
4005 if(strcmp(key,"END") && !flag) goto L23;
4007 printf("*** GWEUCL *** cannot restore original number for material: %s\n",namate);
4011 //*** restore original tracking medium number
4014 iret=fscanf(luncor,"%4s,%130s",key,card);
4015 if(iret<=0) goto L26;
4017 if (!strcmp(key,"TMED")) {
4018 sscanf(card,"%d %s %d %d %d %f %f %f %f %f %f %d\n",
4019 &itmedc,natmedc,&nmatc,&isvolc,&ifieldc,&fieldmc,
4020 &tmaxfdc,&stemaxc,&deemaxc,&epsilc,&stminc,&nwbufc);
4021 Gftmed(itm,natmed,nmat,isvol,ifield,fieldm,tmaxf,stemax,deemax,
4022 epsil,stmin,ubuf,&nwbuf);
4023 if(!strcmp(natmedc,natmed)) {
4024 if (iomate[nmat]==nmatc && nwbuf==nwbufc) {
4027 printf("*** GWEUCL *** medium : %3d '%20s' restored as %3d\n",
4030 printf("*** GWEUCL *** different definitions for tracking medium: %s\n",natmed);
4034 if(strcmp(key,"END") && !flag) goto L24;
4036 printf("cannot restore original number for medium : %s\n",natmed);
4044 L26: printf("*** GWEUCL *** cannot read the data file\n");
4046 L29: if(luncor) fclose (luncor);
4049 // *** write down the tracking medium definition
4051 strcpy(card,"! Tracking medium");
4052 fprintf(lun,k10000,card);
4054 for(itm=1;itm<=fGcnum->ntmed;itm++) {
4055 if (iws[iadtmd+itm]>0) {
4056 jtm = fZlq[fGclink->jtmed-itm];
4057 strncpy(natmed,(char *)&fZiq[jtm+1],20);
4059 imat = Int_t (fZq[jtm+6]);
4060 jma = fZlq[fGclink->jmate-imat];
4061 //* order media from one, if comparing with database failed
4063 iotmed[itm]=++imxtmed;
4064 iomate[imat]=++imxmate;
4069 printf(" *** GWEUCL *** material not defined for tracking medium %5d %s\n",
4072 strncpy(namate,(char *)&fZiq[jma+1],20);
4075 fprintf(lun,"TMED %3d '%20s' %3d '%20s'\n",iotmed[itm],natmed,iomate[imat],namate);
4079 //* *** write down the rotation matrix
4081 strcpy(card,"! Reperes");
4082 fprintf(lun,k10000,card);
4084 for(irm=1;irm<=fGcnum->nrotm;irm++) {
4085 if (iws[iadrot+irm]>0) {
4086 jrm = fZlq[fGclink->jrotm-irm];
4087 fprintf(lun,"ROTM %3d",irm);
4088 for(k=11;k<=16;k++) fprintf(lun," %8.3f",fZq[jrm+k]);
4093 //* *** write down the volume definition
4095 strcpy(card,"! Volumes");
4096 fprintf(lun,k10000,card);
4098 for(ivstak=1;ivstak<=nvstak;ivstak++) {
4101 strncpy(name,(char *)&fZiq[fGclink->jvolum+ivo],4);
4103 jvo = fZlq[fGclink->jvolum-ivo];
4104 ish = Int_t (fZq[jvo+2]);
4105 nmed = Int_t (fZq[jvo+4]);
4106 npar = Int_t (fZq[jvo+5]);
4108 if (ivstak>1) for(i=0;i<npar;i++) par[i]=fZq[jvo+7+i];
4109 Gckpar (ish,npar,par);
4110 fprintf(lun,"VOLU '%4s' '%4s' %3d %3d\n",name,kShape[ish-1],iotmed[nmed],npar);
4111 for(i=0;i<(npar-1)/6+1;i++) {
4114 for(k=0;k<(left<6?left:6);k++) fprintf(lun," %11.5f",par[i*6+k]);
4118 fprintf(lun,"VOLU '%4s' '%4s' %3d %3d\n",name,kShape[ish-1],iotmed[nmed],npar);
4123 //* *** write down the division of volumes
4125 fprintf(lun,k10000,"! Divisions");
4126 for(ivstak=1;ivstak<=nvstak;ivstak++) {
4127 ivo = TMath::Abs(iws[ivstak]);
4128 jvo = fZlq[fGclink->jvolum-ivo];
4129 ish = Int_t (fZq[jvo+2]);
4130 nin = Int_t (fZq[jvo+3]);
4131 //* this volume is divided ...
4134 iaxe = Int_t ( fZq[jdiv+1]);
4135 ivin = Int_t ( fZq[jdiv+2]);
4136 ndiv = Int_t ( fZq[jdiv+3]);
4139 jvin = fZlq[fGclink->jvolum-ivin];
4140 nmed = Int_t ( fZq[jvin+4]);
4141 strncpy(mother,(char *)&fZiq[fGclink->jvolum+ivo ],4);
4143 strncpy(name,(char *)&fZiq[fGclink->jvolum+ivin],4);
4145 if ((step<=0.)||(ish>=11)) {
4146 //* volume with negative parameter or gsposp or pgon ...
4147 fprintf(lun,"DIVN '%4s' '%4s' %3d %3d\n",name,mother,ndiv,iaxe);
4148 } else if ((ndiv<=0)||(ish==10)) {
4149 //* volume with negative parameter or gsposp or para ...
4150 ndvmx = TMath::Abs(ndiv);
4151 fprintf(lun,"DIVT '%4s' '%4s' %11.5f %3d %3d %3d\n",
4152 name,mother,step,iaxe,iotmed[nmed],ndvmx);
4154 //* normal volume : all kind of division are equivalent
4155 fprintf(lun,"DVT2 '%4s' '%4s' %11.5f %3d %11.5f %3d %3d\n",
4156 name,mother,step,iaxe,c0,iotmed[nmed],ndiv);
4161 //* *** write down the the positionnement of volumes
4163 fprintf(lun,k10000,"! Positionnements\n");
4165 for(ivstak = 1;ivstak<=nvstak;ivstak++) {
4166 ivo = TMath::Abs(iws[ivstak]);
4167 strncpy(mother,(char*)&fZiq[fGclink->jvolum+ivo ],4);
4169 jvo = fZlq[fGclink->jvolum-ivo];
4170 nin = Int_t( fZq[jvo+3]);
4171 //* this volume has daughters ...
4173 for (in=1;in<=nin;in++) {
4175 ivin = Int_t (fZq[jin +2]);
4176 numb = Int_t (fZq[jin +3]);
4177 irot = Int_t (fZq[jin +4]);
4181 strcpy(konly,"ONLY");
4182 if (fZq[jin+8]!=1.) strcpy(konly,"MANY");
4183 strncpy(name,(char*)&fZiq[fGclink->jvolum+ivin],4);
4185 jvin = fZlq[fGclink->jvolum-ivin];
4186 ish = Int_t (fZq[jvin+2]);
4187 //* gspos or gsposp ?
4188 ndata = fZiq[jin-1];
4190 fprintf(lun,"POSI '%4s' %4d '%4s' %11.5f %11.5f %11.5f %3d '%4s'\n",
4191 name,numb,mother,x,y,z,irot,konly);
4193 npar = Int_t (fZq[jin+9]);
4194 for(i=0;i<npar;i++) par[i]=fZq[jin+10+i];
4195 Gckpar (ish,npar,par);
4196 fprintf(lun,"POSP '%4s' %4d '%4s' %11.5f %11.5f %11.5f %3d '%4s' %3d\n",
4197 name,numb,mother,x,y,z,irot,konly,npar);
4199 for(i=0;i<npar;i++) fprintf(lun," %11.5f",par[i]);
4206 fprintf(lun,"END\n");
4209 //****** write down the materials and medias *****
4211 lun=fopen(filetme,"w");
4213 for(itm=1;itm<=fGcnum->ntmed;itm++) {
4214 if (iws[iadtmd+itm]>0) {
4215 jtm = fZlq[fGclink->jtmed-itm];
4216 strncpy(natmed,(char*)&fZiq[jtm+1],4);
4217 imat = Int_t (fZq[jtm+6]);
4218 jma = Int_t (fZlq[fGclink->jmate-imat]);
4220 Gfmate (imat,namate,a,z,dens,radl,absl,par,npar);
4221 fprintf(lun,"MATE %4d '%20s'%11.5E %11.5E %11.5E %11.5E %11.5E %3d\n",
4222 iomate[imat],namate,a,z,dens,radl,absl,npar);
4226 for(i=0;i<npar;i++) fprintf(lun," %11.5f",par[i]);
4230 Gftmed(itm,natmed,nmat,isvol,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin,par,&npar);
4231 fprintf(lun,"TMED %4d '%20s' %3d %1d %3d %11.5f %11.5f %11.5f %11.5f %11.5f %11.5f %3d\n",
4232 iotmed[itm],natmed,iomate[nmat],isvol,ifield,
4233 fieldm,tmaxfd,stemax,deemax,epsil,stmin,npar);
4237 for(i=0;i<npar;i++) fprintf(lun," %11.5f",par[i]);
4243 fprintf(lun,"END\n");
4245 printf(" *** GWEUCL *** file: %s is now written out\n",filext);
4246 printf(" *** GWEUCL *** file: %s is now written out\n",filetme);
4255 //_____________________________________________________________________________
4256 void TGeant3::Streamer(TBuffer &R__b)
4259 // Stream an object of class TGeant3.
4261 if (R__b.IsReading()) {
4262 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
4263 AliMC::Streamer(R__b);
4266 R__b.ReadStaticArray(fPDGCode);
4268 R__b.WriteVersion(TGeant3::IsA());
4269 AliMC::Streamer(R__b);
4272 R__b.WriteArray(fPDGCode, fNPDGCodes);