]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant3/AliGeant3.cxx
Check status code of particles in Pythia event
[u/mrichter/AliRoot.git] / TGeant3 / AliGeant3.cxx
CommitLineData
b13db077 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
d7067e4f 18Revision 1.1 2000/02/23 16:25:25 fca
19AliVMC and AliGeant3 classes introduced
20ReadEuclid moved from AliRun to AliModule
21
b13db077 22*/
23
24#include <TParticle.h>
25
26#include "AliGeant3.h"
27#include "AliRun.h"
28#include "TGeant3.h"
29#include "AliCallf77.h"
30
31#ifndef WIN32
32
33# define rxgtrak rxgtrak_
34# define rxstrak rxstrak_
35# define rxkeep rxkeep_
36# define rxouth rxouth_
37#else
38
39# define rxgtrak RXGTRAK
40# define rxstrak RXSTRAK
41# define rxkeep RXKEEP
42# define rxouth RXOUTH
43#endif
44
45ClassImp(AliGeant3)
46
47AliGeant3::AliGeant3()
48{
49 new TGeant3();
50}
51
52AliGeant3::AliGeant3(const char *title) :
53 AliVMC("ALICE Virtual MC for Geant3",title)
54{
55 new TGeant3(title);
56}
57
58void AliGeant3::FinishGeometry()
59{
60 gMC->FinishGeometry();
61 //Create the color table
62 gMC->SetColors();
63}
64
65void AliGeant3::BuildPhysics()
66{
67 ((TGeant3*)gMC)->Gphysi();
68}
69
70void AliGeant3::ProcessEvent()
71{
72 ((TGeant3*)gMC)->Gtrigi();
73 ((TGeant3*)gMC)->Gtrigc();
74 ((TGeant3*)gMC)->Gtrig();
75}
76
77//_____________________________________________________________________________
78//
79// Interfaces to Fortran
80//
81//_____________________________________________________________________________
82
83extern "C" void type_of_call rxgtrak (Int_t &mtrack, Int_t &ipart, Float_t *pmom,
84 Float_t &e, Float_t *vpos, Float_t *polar,
85 Float_t &tof)
86{
87 //
88 // Fetches next track from the ROOT stack for transport. Called by the
89 // modified version of GTREVE.
90 //
91 // Track number in the ROOT stack. If MTRACK=0 no
92 // mtrack more tracks are left in the stack to be
93 // transported.
94 // ipart Particle code in the GEANT conventions.
95 // pmom[3] Particle momentum in GeV/c
96 // e Particle energy in GeV
97 // vpos[3] Particle position
98 // tof Particle time of flight in seconds
99 //
100 Int_t pdg;
101 gAlice->GetNextTrack(mtrack, pdg, pmom, e, vpos, polar, tof);
102 ipart = gMC->IdFromPDG(pdg);
103 mtrack++;
104}
105
106//_____________________________________________________________________________
107extern "C" void type_of_call
108#ifndef WIN32
109rxstrak (Int_t &keep, Int_t &parent, Int_t &ipart, Float_t *pmom,
110 Float_t *vpos, Float_t &tof, const char* cmech, Int_t &ntr, const int cmlen)
111#else
112rxstrak (Int_t &keep, Int_t &parent, Int_t &ipart, Float_t *pmom,
113 Float_t *vpos, Float_t &tof, const char* cmech, const int cmlen,
114 Int_t &ntr)
115#endif
116{
117 //
118 // Fetches next track from the ROOT stack for transport. Called by GUKINE
119 // and GUSTEP.
120 //
121 // Status of the track. If keep=0 the track is put
122 // keep on the ROOT stack but it is not fetched for
123 // transport.
124 // parent Parent track. If parent=0 the track is a primary.
125 // In GUSTEP the routine is normally called to store
126 // secondaries generated by the current track whose
127 // ROOT stack number is MTRACK (common SCKINE.
128 // ipart Particle code in the GEANT conventions.
129 // pmom[3] Particle momentum in GeV/c
130 // vpos[3] Particle position
131 // tof Particle time of flight in seconds
132 //
133 // cmech (CHARACTER*10) Particle origin. This field is user
134 // defined and it is not used inside the GALICE code.
135 // ntr Number assigned to the particle in the ROOT stack.
136 //
137 char mecha[11];
138 Float_t polar[3]={0.,0.,0.};
139 for(int i=0; i<10 && i<cmlen; i++) mecha[i]=cmech[i];
140 mecha[10]=0;
141 Int_t pdg=gMC->PDGFromId(ipart);
142 gAlice->SetTrack(keep, parent-1, pdg, pmom, vpos, polar, tof, mecha, ntr);
143 ntr++;
144}
145
146//_____________________________________________________________________________
147extern "C" void type_of_call rxkeep(const Int_t &n)
148{
149 if( NULL==gAlice ) exit(1);
150
151 if( n<=0 || n>gAlice->Particles()->GetEntries() )
152 {
153 printf(" Bad index n=%d must be 0<n<=%d\n",
154 n,gAlice->Particles()->GetEntries());
155 exit(1);
156 }
157
158 ((TParticle*)(gAlice->Particles()->UncheckedAt(n-1)))->SetBit(Keep_Bit);
159}
160
161//_____________________________________________________________________________
162extern "C" void type_of_call rxouth ()
163{
164 //
165 // Called by Gtreve at the end of each primary track
166 //
167 gAlice->FinishPrimary();
168}
169
d7067e4f 170
171#ifndef WIN32
172# define gudigi gudigi_
173# define guhadr guhadr_
174# define guout guout_
175# define guphad guphad_
176# define gudcay gudcay_
177# define guiget guiget_
178# define guinme guinme_
179# define guinti guinti_
180# define gunear gunear_
181# define guskip guskip_
182# define guview guview_
183# define gupara gupara_
184# define gudtim gudtim_
185# define guplsh guplsh_
186# define gutrev gutrev_
187# define gutrak gutrak_
188# define guswim guswim_
189# define gufld gufld_
190# define gustep gustep_
191# define gukine gukine_
192# define uglast uglast_
193
194# define gheish gheish_
195# define flufin flufin_
196# define gfmfin gfmfin_
197# define gpghei gpghei_
198# define fldist fldist_
199# define gfmdis gfmdis_
200# define ghelx3 ghelx3_
201# define ghelix ghelix_
202# define grkuta grkuta_
203# define gtrack gtrack_
204# define gtreve_root gtreve_root_
205# define glast glast_
206
207#else
208# define gudigi GUDIGI
209# define guhadr GUHADR
210# define guout GUOUT
211# define guphad GUPHAD
212# define gudcay GUDCAY
213# define guiget GUIGET
214# define guinme GUINME
215# define guinti GUINTI
216# define gunear GUNEAR
217# define guskip GUSKIP
218# define guview GUVIEW
219# define gupara GUPARA
220# define gudtim GUDTIM
221# define guplsh GUPLSH
222# define gutrev GUTREV
223# define gutrak GUTRAK
224# define guswim GUSWIM
225# define gufld GUFLD
226# define gustep GUSTEP
227# define gukine GUKINE
228# define uglast UGLAST
229
230# define gheish GHEISH
231# define flufin FLUFIN
232# define gfmfin GFMFIN
233# define gpghei GPGHEI
234# define fldist FLDIST
235# define gfmdis GFMDIS
236# define ghelx3 GHELX3
237# define ghelix GHELIX
238# define grkuta GRKUTA
239# define gtrack GTRACK
240# define gtreve_root GTREVE_ROOT
241# define glast GLAST
242
243#endif
244
245extern "C" type_of_call void gheish();
246extern "C" type_of_call void flufin();
247extern "C" type_of_call void gfmfin();
248extern "C" type_of_call void gpghei();
249extern "C" type_of_call void fldist();
250extern "C" type_of_call void gfmdis();
251extern "C" type_of_call void ghelx3(Float_t&, Float_t&, Float_t*, Float_t*);
252extern "C" type_of_call void ghelix(Float_t&, Float_t&, Float_t*, Float_t*);
253extern "C" type_of_call void grkuta(Float_t&, Float_t&, Float_t*, Float_t*);
254extern "C" type_of_call void gtrack();
255extern "C" type_of_call void gtreve_root();
256extern "C" type_of_call void glast();
257
258extern "C" type_of_call {
259
260//______________________________________________________________________
261void gudigi()
262{
263//
264// ******************************************************************
265// * *
266// * User routine to digitize one event *
267// * *
268// * ==>Called by : GTRIG *
269// * *
270// ******************************************************************
271
272}
273
274
275//______________________________________________________________________
276void guhadr()
277{
278//
279// ******************************************************************
280// * *
281// * User routine to generate one hadronic interaction *
282// * *
283// * ==>Called by : GTHADR,GTNEUT *
284// * *
285// ******************************************************************
286//
287//
288// ------------------------------------------------------------------
289//
290 TGeant3* geant3 = (TGeant3*) gMC;
291 Int_t ihadr=geant3->Gcphys()->ihadr;
292 if (ihadr<4) gheish();
293 else if (ihadr==4) flufin();
294 else gfmfin();
295}
296
297//______________________________________________________________________
298void guout()
299{
300//
301// ******************************************************************
302// * *
303// * User routine called at the end of each event *
304// * *
305// * ==>Called by : GTRIG *
306// * *
307// ******************************************************************
308//
309//
310// ------------------------------------------------------------------
311//
312}
313
314//______________________________________________________________________
315void guphad()
316{
317//
318// ******************************************************************
319// * *
320// * User routine to compute Hadron. inter. probabilities *
321// * *
322// * ==>Called by : GTHADR,GTNEUT *
323// * *
324// ******************************************************************
325//
326//
327// ------------------------------------------------------------------
328//
329 TGeant3* geant3 = (TGeant3*) gMC;
330 Int_t ihadr=geant3->Gcphys()->ihadr;
331 if (ihadr<4) gpghei();
332 else if (ihadr==4) fldist();
333 else gfmdis();
334}
335
336//______________________________________________________________________
337void gudcay()
338{
339//
340// ******************************************************************
341// * *
342// * User routine to decay particles *
343// * *
344// * ==>Called by : GDECAY *
345// * *
346// ******************************************************************
347//
348//
349// ------------------------------------------------------------------
350//
351}
352
353//______________________________________________________________________
354void guiget(Int_t&, Int_t&, Int_t&)
355{
356//
357// ******************************************************************
358// * *
359// * User routine for interactive control of GEANT *
360// * *
361// * ==>Called by : <GXINT>, GINCOM *
362// * *
363// ******************************************************************
364//
365//
366// ------------------------------------------------------------------
367//
368}
369
370//______________________________________________________________________
371void guinme(Float_t*, Int_t&, Float_t*, Int_t& IYES)
372{
373//
374// **********************************************
375// * *
376// * USER ROUTINE TO PROVIDE GINME FUNCTION *
377// * FOR ALL USER SHAPES IDENTIFIED BY THE *
378// * SHAPE NUMBER SH. POINT IS GIVEN IN X *
379// * THE PARAMETERS ARE GIVEN IN P. IYES IS *
380// * RETURNED 1 IF POINT IS IN, 0 IF POINT *
381// * IS OUT AND LESS THAN ZERO IF SHAPE *
382// * NUMBER IS NOT SUPPORTED. *
383// * *
384// * ==>Called by : GINME *
385// * *
386// **********************************************
387//
388 IYES=-1;
389}
390
391//______________________________________________________________________
392void guinti()
393{
394//
395// ******************************************************************
396// * *
397// * User routine for interactive version *
398// * *
399// * ==>Called by : <GXINT>, GINTRI *
400// * *
401// ******************************************************************
402//
403//
404// ------------------------------------------------------------------
405//
406}
407
408//______________________________________________________________________
409void gunear(Int_t&, Int_t&, Float_t*, Int_t&)
410{
411//
412// ******************************************************************
413// * *
414// * User search *
415// * ISEARC to identify the given volume *
416// * ICALL to identify the calling routine *
417// * 1 GMEDIA like *
418// * 2 GNEXT like *
419// * X coordinates (+direction for ICALL=2) *
420// * JNEAR address of default list of neighbours *
421// * (list to be overwriten by user) *
422// * *
423// * Called by : GFTRAC, GINVOL, GTMEDI, GTNEXT, GNEXT, GMEDIA *
424// * *
425// ******************************************************************
426//
427//
428// ------------------------------------------------------------------
429//
430}
431
432//______________________________________________________________________
433void guskip(Int_t& ISKIP)
434{
435//
436// ******************************************************************
437// * *
438// * User routine to skip unwanted tracks *
439// * *
440// * Called by : GSSTAK *
441// * Author : F.Bruyant *
442// * *
443// ******************************************************************
444//
445//
446// ------------------------------------------------------------------
447//
448 ISKIP = 0;
449}
450
451//______________________________________________________________________
452void guswim(Float_t& CHARGE, Float_t& STEP, Float_t* VECT, Float_t* VOUT)
453{
454//
455// ******************************************************************
456// * *
457// * User routine to control tracking of one track *
458// * in a magnetic field *
459// * *
460// * ==>Called by : GTELEC,GTHADR,GTMUON *
461// * *
462// ******************************************************************
463//
464//
465// ------------------------------------------------------------------
466//
467 TGeant3* geant3 = (TGeant3*) gMC;
468 Int_t ifield=geant3->Gctmed()->ifield;
469 Float_t fieldm=geant3->Gctmed()->fieldm;
470
471 if (ifield==3) {
472 Float_t fldcharge = fieldm*CHARGE;
473 ghelx3(fldcharge,STEP,VECT,VOUT);
474 }
475 else if (ifield==2) ghelix(CHARGE,STEP,VECT,VOUT);
476 else grkuta(CHARGE,STEP,VECT,VOUT);
477}
478
479//______________________________________________________________________
480void guview(Int_t&, Int_t&, DEFCHARD, Int_t& DEFCHARL)
481{
482//
483// ******************************************************************
484// * *
485// * User routine for interactive version *
486// * *
487// * ==>Called by : <GXINT>, GINC1 *
488// * *
489// ******************************************************************
490//
491//
492// ------------------------------------------------------------------
493//
494}
495
496//______________________________________________________________________
497void gupara()
498{
499//
500// ******************************************************************
501// * *
502// * User routine called every time a particle falls below *
503// * parametrization threshold. This routine should create *
504// * the parametrization stack, and, when this is full, *
505// * parametrize the shower and track the geantinos. *
506// * *
507// * ==>Called by : GTRACK *
508// * *
509// ******************************************************************
510//
511//
512// ------------------------------------------------------------------
513//
514}
515
516//______________________________________________________________________
517Float_t gudtim(Float_t&, Float_t&, Int_t&, Int_t&)
518{
519//
520// ******************************************************************
521// * *
522// * User function called by GCDRIF to return drift time *
523// * *
524// * ==>Called by : GCDRIF *
525// * *
526// ******************************************************************
527//
528//
529// ------------------------------------------------------------------
530//
531 return 0;
532}
533
534
535//______________________________________________________________________
536Float_t guplsh(Int_t&, Int_t&)
537{
538//
539// ******************************************************************
540// * *
541// * *
542// * ==>Called by : GLISUR *
543// * *
544// ******************************************************************
545//
546//
547// ------------------------------------------------------------------
548//
549//
550//*** By default this defines perfect smoothness
551 return 1;
552}
553
554//______________________________________________________________________
555void gutrak()
556{
557//
558// ******************************************************************
559// * *
560// * User routine to control tracking of one track *
561// * *
562// * ==>Called by : GTREVE *
563// * *
564// ******************************************************************
565//
566//
567// ------------------------------------------------------------------
568//
569 Int_t ndet = gAlice->Modules()->GetLast();
570 TObjArray &dets = *gAlice->Modules();
571 AliModule *module;
572 Int_t i;
573
574 for(i=0; i<=ndet; i++)
575 if((module = (AliModule*)dets[i]))
576 module->PreTrack();
577
578 gtrack();
579
580 for(i=0; i<=ndet; i++)
581 if((module = (AliModule*)dets[i]))
582 module->PostTrack();
583}
584
585//______________________________________________________________________
586void gutrev()
587{
588//
589// ******************************************************************
590// * *
591// * User routine to control tracking of one event *
592// * *
593// * ==>Called by : GTRIG *
594// * *
595// ******************************************************************
596//
597//
598// ------------------------------------------------------------------
599//
600 gtreve_root();
601}
602
603
604//______________________________________________________________________
605void gufld(Float_t *x, Float_t *b)
606{
607 if(gAlice->Field()) {
608 gAlice->Field()->Field(x,b);
609 } else {
610 printf("No mag field defined!\n");
611 b[0]=b[1]=b[2]=0;
612 }
613}
614
615//______________________________________________________________________
616void gustep()
617{
618//
619// ******************************************************************
620// * *
621// * User routine called at the end of each tracking step *
622// * INWVOL is different from 0 when the track has reached *
623// * a volume boundary *
624// * ISTOP is different from 0 if the track has stopped *
625// * *
626// * ==>Called by : GTRACK *
627// * *
628// ******************************************************************
629//
630
631
632 TLorentzVector x;
633 Float_t r;
634 Int_t ipp, jk, id, nt;
635 Float_t polar[3]={0,0,0};
636 Float_t mom[3];
637 const char *chproc;
638
639 // --- Standard GEANT debug routine
640 TGeant3* geant3 = (TGeant3*) gMC;
641 if(geant3->Gcflag()->idebug) geant3->Gdebug();
642
643 // Stop particle if outside user defined tracking region
644 gMC->TrackPosition(x);
645 r=TMath::Sqrt(x[0]*x[0]+x[1]*x[1]);
646 if (r > gAlice->TrackingRmax() || TMath::Abs(x[2]) > gAlice->TrackingZmax()) {
647 gMC->StopTrack();
648 }
649 // --- Add new created particles
650 if (gMC->NSecondaries() > 0) {
651 chproc=gMC->ProdProcess();
652 for (jk = 0; jk < geant3->Gcking()->ngkine; ++jk) {
653 ipp = Int_t (geant3->Gcking()->gkin[jk][4]+0.5);
654 // --- Skip neutrinos!
655 if (ipp != 4) {
656 gAlice->SetTrack(1,gAlice->CurrentTrack(),gMC->PDGFromId(ipp), geant3->Gcking()->gkin[jk],
657 geant3->Gckin3()->gpos[jk], polar,geant3->Gctrak()->tofg, chproc, nt);
658 }
659 }
660 }
661 // Cherenkov photons here
662 if ( geant3->Gckin2()->ngphot ) {
663 for (jk = 0; jk < geant3->Gckin2()->ngphot; ++jk) {
664 mom[0]=geant3->Gckin2()->xphot[jk][3]*geant3->Gckin2()->xphot[jk][6];
665 mom[1]=geant3->Gckin2()->xphot[jk][4]*geant3->Gckin2()->xphot[jk][6];
666 mom[2]=geant3->Gckin2()->xphot[jk][5]*geant3->Gckin2()->xphot[jk][6];
667 gAlice->SetTrack(1, gAlice->CurrentTrack(), gMC->PDGFromId(50),
668 mom, //momentum
669 geant3->Gckin2()->xphot[jk], //position
670 &geant3->Gckin2()->xphot[jk][7], //polarisation
671 geant3->Gckin2()->xphot[jk][10], //time of flight
672 "Cherenkov", nt);
673 }
674 }
675 // --- Particle leaving the setup ?
676 if (!gMC->IsTrackOut())
677 if ((id=gAlice->DetFromMate(geant3->Gctmed()->numed)) >= 0) gAlice->StepManager(id);
678}
679
680//______________________________________________________________________
681void gukine ()
682{
683//
684// ******************************************************************
685// * *
686// * Read or Generates Kinematics for primary tracks *
687// * *
688// * ==>Called by : GTRIG *
689// * *
690// ******************************************************************
691//
692//
693// ------------------------------------------------------------------
694//
695 gAlice->Generator()->Generate();
696}
697
698
699//______________________________________________________________________
700void uglast()
701{
702//
703// ******************************************************************
704// * *
705// * User routine called at the end of the run *
706// * *
707// * ==>Called by : GRUN *
708// * *
709// ******************************************************************
710//
711//
712}
713}
714