]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant3/AliGeant3.cxx
AliVMC and AliGeant3 classes introduced
[u/mrichter/AliRoot.git] / TGeant3 / AliGeant3.cxx
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$
18 */
19
20 #include <TParticle.h>
21
22 #include "AliGeant3.h"
23 #include "AliRun.h"
24 #include "TGeant3.h"
25 #include "AliCallf77.h" 
26
27 #ifndef WIN32
28
29 # define rxgtrak rxgtrak_
30 # define rxstrak rxstrak_
31 # define rxkeep  rxkeep_ 
32 # define rxouth  rxouth_
33 #else
34
35 # define rxgtrak RXGTRAK 
36 # define rxstrak RXSTRAK 
37 # define rxkeep  RXKEEP  
38 # define rxouth  RXOUTH
39 #endif
40
41 ClassImp(AliGeant3)
42
43 AliGeant3::AliGeant3()
44 {
45   new TGeant3();
46 }
47
48 AliGeant3::AliGeant3(const char *title) : 
49   AliVMC("ALICE Virtual MC for Geant3",title)
50 {
51   new TGeant3(title);
52 }
53
54 void AliGeant3::FinishGeometry()
55 {
56   gMC->FinishGeometry();
57   //Create the color table
58   gMC->SetColors();
59 }
60
61 void AliGeant3::BuildPhysics()
62 {
63   ((TGeant3*)gMC)->Gphysi();
64 }
65
66 void AliGeant3::ProcessEvent()
67 {
68   ((TGeant3*)gMC)->Gtrigi();
69   ((TGeant3*)gMC)->Gtrigc();
70   ((TGeant3*)gMC)->Gtrig();
71 }
72
73 //_____________________________________________________________________________
74 //
75 //                 Interfaces to Fortran
76 //
77 //_____________________________________________________________________________
78
79 extern "C" void type_of_call  rxgtrak (Int_t &mtrack, Int_t &ipart, Float_t *pmom, 
80                                        Float_t &e, Float_t *vpos, Float_t *polar,
81                                        Float_t &tof)
82 {
83   //
84   //     Fetches next track from the ROOT stack for transport. Called by the
85   //     modified version of GTREVE.
86   //
87   //              Track number in the ROOT stack. If MTRACK=0 no
88   //      mtrack  more tracks are left in the stack to be
89   //              transported.
90   //      ipart   Particle code in the GEANT conventions.
91   //      pmom[3] Particle momentum in GeV/c
92   //      e       Particle energy in GeV
93   //      vpos[3] Particle position
94   //      tof     Particle time of flight in seconds
95   //
96   Int_t pdg;
97   gAlice->GetNextTrack(mtrack, pdg, pmom, e, vpos, polar, tof);
98   ipart = gMC->IdFromPDG(pdg);
99   mtrack++;
100 }
101
102 //_____________________________________________________________________________
103 extern "C" void type_of_call 
104 #ifndef WIN32
105 rxstrak (Int_t &keep, Int_t &parent, Int_t &ipart, Float_t *pmom, 
106                Float_t *vpos, Float_t &tof, const char* cmech, Int_t &ntr, const int cmlen)
107 #else
108 rxstrak (Int_t &keep, Int_t &parent, Int_t &ipart, Float_t *pmom,
109          Float_t *vpos, Float_t &tof, const char* cmech, const int cmlen,
110          Int_t &ntr)
111 #endif
112 {
113   //
114   //     Fetches next track from the ROOT stack for transport. Called by GUKINE
115   //     and GUSTEP.
116   //
117   //              Status of the track. If keep=0 the track is put
118   //      keep    on the ROOT stack but it is not fetched for
119   //              transport.
120   //      parent  Parent track. If parent=0 the track is a primary.
121   //              In GUSTEP the routine is normally called to store
122   //              secondaries generated by the current track whose
123   //              ROOT stack number is MTRACK (common SCKINE.
124   //      ipart   Particle code in the GEANT conventions.
125   //      pmom[3] Particle momentum in GeV/c
126   //      vpos[3] Particle position
127   //      tof     Particle time of flight in seconds
128   //
129   //      cmech   (CHARACTER*10) Particle origin. This field is user
130   //              defined and it is not used inside the GALICE code.
131   //      ntr     Number assigned to the particle in the ROOT stack.
132   //
133   char mecha[11];
134   Float_t polar[3]={0.,0.,0.};
135   for(int i=0; i<10 && i<cmlen; i++) mecha[i]=cmech[i];
136   mecha[10]=0;
137   Int_t pdg=gMC->PDGFromId(ipart);
138   gAlice->SetTrack(keep, parent-1, pdg, pmom, vpos, polar, tof, mecha, ntr);
139   ntr++;
140 }
141
142 //_____________________________________________________________________________
143 extern "C" void type_of_call  rxkeep(const Int_t &n)
144 {
145   if( NULL==gAlice ) exit(1);
146   
147   if( n<=0 || n>gAlice->Particles()->GetEntries() )
148     {
149       printf("  Bad index n=%d must be 0<n<=%d\n",
150              n,gAlice->Particles()->GetEntries());
151       exit(1);
152     }
153   
154   ((TParticle*)(gAlice->Particles()->UncheckedAt(n-1)))->SetBit(Keep_Bit);
155 }
156
157 //_____________________________________________________________________________
158 extern "C" void type_of_call  rxouth ()
159 {
160   //
161   // Called by Gtreve at the end of each primary track
162   //
163   gAlice->FinishPrimary();
164 }
165