7 #include "Fdblprc.h" //(DBLPRC) fluka common
8 #include "Fdimpar.h" //(DIMPAR) fluka parameters
9 #include "Fepisor.h" //(EPISOR) fluka common
10 #include "Fstack.h" //(STACK) fluka common
11 #include "Fstars.h" //(STARS) fluka common
12 #include "Fbeam.h" //(BEAM) fluka common
13 #include "Fpaprop.h" //(PAPROP) fluka common
14 #include "Fltclcm.h" //(LTCLCM) fluka common
16 //#include "Fcaslim.h" //(CASLIM) fluka common
19 #include "AliGenerator.h"
21 #include "../PYTHIA6/AliGenPythia.h"
23 #include "TVirtualMCStack.h"
24 #include "TParticle.h"
28 #include <Riostream.h>
31 # define source source_
32 # define geocrs geocrs_
33 # define georeg georeg_
34 # define geohsm geohsm_
35 # define soevsv soevsv_
36 # define mcihad mcihad_
37 # define source_f source_f__
39 # define source SOURCE
40 # define geocrs GEOCRS
41 # define georeg GEOREG
42 # define geohsm GEOHSM
43 # define soevsv SOEVSV
44 # define mcihad MCIHAD
45 # define source_f SOURCE_F
50 // Prototypes for FLUKA functions
52 void type_of_call geocrs(Double_t &, Double_t &, Double_t &);
53 void type_of_call georeg(Double_t &, Double_t &, Double_t &,
55 void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &);
56 void type_of_call soevsv();
57 int type_of_call mcihad(const int&);
59 *----------------------------------------------------------------------*
61 * Created on 07 january 1990 by Alfredo Ferrari & Paola Sala *
64 * Last change on 21-jun-98 by Alfredo Ferrari *
66 * C++ version on 27-sep-02 by Isidro Gonzalez *
68 * This is just an example of a possible user written source routine. *
69 * note that the beam card still has some meaning - in the scoring the *
70 * maximum momentum used in deciding the binning is taken from the *
71 * beam momentum. Other beam card parameters are obsolete. *
73 *----------------------------------------------------------------------*/
75 void source_f(Int_t& nomore) {
77 static Bool_t lfirst = true;
78 static AliGenPythia* gener = 0;
79 static AliStack* stack = 0;
85 printf("source_f first call \n");
86 EPISOR.tkesum = zerzer;
89 gener = new AliGenPythia(1);
90 gener->SetEnergyCMS(14000.);
91 gener->SetProcess(kPyMb);
92 stack = new AliStack(1000);
93 gener->SetStack(stack);
99 printf("Calling Generate() %p \n", gener);
102 Int_t npart = stack->GetNprimary();
103 printf("%d Particles on the stack \n", npart);
104 for (Int_t part=0; part<npart; part++) {
105 particle = stack->Particle(part);
106 Int_t st = particle->GetStatusCode();
107 if (st != 1) continue;
108 Int_t pdg = particle->GetPdgCode();
109 Int_t intfluka = mcihad(pdg);
110 Int_t ifl = GetFlukaKPTOIP(intfluka);
111 TVector3 polarisation;
112 particle->GetPolarisation(polarisation);
116 printf("Particle %5d %5d %5d %10s %10.3f %10.3f %10.3f \n", STACK.lstack, pdg, ifl,
117 particle->GetName(), particle->Px(), particle->Py(), particle->Pz());
121 /* Wt is the weight of the particle*/
122 STACK.wt[STACK.lstack] = oneone;
123 STARS.weipri += STACK.wt[STACK.lstack];
125 STACK.ilo[STACK.lstack] = ifl;
126 /* From this point .....
127 * Particle generation (1 for primaries)
129 STACK.lo[STACK.lstack] = 1;
131 /* User dependent flag:*/
132 STACK.louse[STACK.lstack] = 0;
134 /* User dependent spare variables:*/
136 for (ispr = 0; ispr < mkbmx1; ispr++)
137 STACK.sparek[STACK.lstack][ispr] = zerzer;
139 /* User dependent spare flags:*/
140 for (ispr = 0; ispr < mkbmx2; ispr++)
141 STACK.ispark[STACK.lstack][ispr] = 0;
143 /* Save the track number of the stack particle:*/
144 STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
146 STACK.numpar[STACK.lstack] = STACK.nparma;
147 STACK.nevent[STACK.lstack] = 0;
148 STACK.dfnear[STACK.lstack] = +zerzer;
150 /* Particle age (s)*/
151 STACK.agestk[STACK.lstack] = +zerzer;
152 STACK.aknshr[STACK.lstack] = -twotwo;
154 /* Group number for "low" energy neutrons, set to 0 anyway*/
155 STACK.igroup[STACK.lstack] = 0;
158 STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
161 /* Particle momentum*/
162 STACK.pmom [STACK.lstack] = particle->P();
164 /* Cosines (tx,ty,tz)*/
165 Double_t cosx = particle->Px()/particle->P();
166 Double_t cosy = particle->Py()/particle->P();
167 Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
168 if (particle->Pz() < 0.) cosz = -cosz;
169 STACK.tx [STACK.lstack] = cosx;
170 STACK.ty [STACK.lstack] = cosy;
171 STACK.tz [STACK.lstack] = cosz;
173 /* Polarization cosines:*/
174 if (polarisation.Mag()) {
175 Double_t cospolx = polarisation.Px()/polarisation.Mag();
176 Double_t cospoly = polarisation.Py()/polarisation.Mag();
177 Double_t cospolz = sqrt(oneone - cospolx*cospolx - cospoly*cospoly);
178 STACK.tx [STACK.lstack] = cospolx;
179 STACK.ty [STACK.lstack] = cospoly;
180 STACK.tz [STACK.lstack] = cospolz;
183 STACK.txpol [STACK.lstack] = -twotwo;
184 STACK.typol [STACK.lstack] = +zerzer;
185 STACK.tzpol [STACK.lstack] = +zerzer;
188 /* Particle coordinates*/
189 // Vertext coordinates;
190 STACK.xa [STACK.lstack] = particle->Vx();
191 STACK.ya [STACK.lstack] = particle->Vy();
192 STACK.za [STACK.lstack] = particle->Vz();
194 /* Calculate the total kinetic energy of the primaries: don't change*/
195 Int_t st_ilo = STACK.ilo[STACK.lstack];
198 ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
199 * STACK.wt[STACK.lstack]);
201 EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
203 /* Here we ask for the region number of the hitting point.
204 * NREG (LSTACK) = ...
205 * The following line makes the starting region search much more
206 * robust if particles are starting very close to a boundary:
208 geocrs( STACK.tx[STACK.lstack],
209 STACK.ty[STACK.lstack],
210 STACK.tz[STACK.lstack] );
214 georeg ( STACK.xa[STACK.lstack],
215 STACK.ya[STACK.lstack],
216 STACK.za[STACK.lstack],
217 STACK.nreg[STACK.lstack],
218 idisc);//<-- dummy return variable not used
219 /* Do not change these cards:*/
221 Int_t igeohsm2 = -11;
222 geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
223 STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
226 // Pre-track actions at for primary tracks