]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TFluka/source_pp.cxx
Removing warnings (alpha)
[u/mrichter/AliRoot.git] / TFluka / source_pp.cxx
CommitLineData
91a0cfa5 1#define METHODDEBUG
2
3// Fortran
4#include "TCallf77.h"
5
6// Fluka commons
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
15#include "Fpart.h"
16//#include "Fcaslim.h" //(CASLIM) fluka common
17
18//Virutal MC
19#include "AliGenerator.h"
20#include "AliStack.h"
21#include "../PYTHIA6/AliGenPythia.h"
22
23#include "TVirtualMCStack.h"
24#include "TParticle.h"
25#include "TVector3.h"
26
27//Other
28#include <Riostream.h>
29
30#ifndef WIN32
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_pp source_pp__
38#else
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_pp SOURCE_PP
46#endif
47
48extern "C" {
49 //
50 // Prototypes for FLUKA functions
51 //
52 void type_of_call geocrs(Double_t &, Double_t &, Double_t &);
53 void type_of_call georeg(Double_t &, Double_t &, Double_t &,
54 Int_t &, Int_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&);
58 /*
59 *----------------------------------------------------------------------*
60 * *
61 * Created on 07 january 1990 by Alfredo Ferrari & Paola Sala *
62 * Infn - Milan *
63 * *
64 * Last change on 21-jun-98 by Alfredo Ferrari *
65 * *
66 * C++ version on 27-sep-02 by Isidro Gonzalez *
67 * *
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. *
72 * *
73 *----------------------------------------------------------------------*/
74
75 void source_pp(Int_t& nomore) {
76
77 static Bool_t lfirst = true;
78 static AliGenPythia* gener = 0;
79 static AliStack* stack = 0;
80
81 nomore = 0;
82 TParticle* particle;
83 Int_t itrack = -1;
84 if (lfirst) {
85 EPISOR.tkesum = zerzer;
86 lfirst = false;
87 EPISOR.lussrc = true;
88 gener = new AliGenPythia(1);
89 gener->SetEnergyCMS(14000.);
90 gener->SetProcess(kPyMb);
91 stack = new AliStack(1000);
92 gener->SetStack(stack);
93 gener->Init();
94
95 } else {
96 //
97 // Generate event
98 stack->Reset();
99 gener->Generate();
100 Int_t npart = stack->GetNprimary();
101 for (Int_t part=0; part<npart; part++) {
102 particle = stack->Particle(part);
103 Int_t st = particle->GetStatusCode();
104 if (st != 1) continue;
105 Int_t pdg = particle->GetPdgCode();
106 Int_t intfluka = mcihad(pdg);
107 Int_t ifl = GetFlukaKPTOIP(intfluka);
108 TVector3 polarisation;
109 particle->GetPolarisation(polarisation);
110
111 STACK.lstack++;
112
113 printf("Particle %5d %5d %5d %10s %10.3f %10.3f %10.3f \n", STACK.lstack, pdg, ifl,
114 particle->GetName(), particle->Px(), particle->Py(), particle->Pz());
115
116
117
118 /* Wt is the weight of the particle*/
119 STACK.wt[STACK.lstack] = oneone;
120 STARS.weipri += STACK.wt[STACK.lstack];
121
122 STACK.ilo[STACK.lstack] = ifl;
123 /* From this point .....
124 * Particle generation (1 for primaries)
125 */
126 STACK.lo[STACK.lstack] = 1;
127
128 /* User dependent flag:*/
129 STACK.louse[STACK.lstack] = 0;
130
131 /* User dependent spare variables:*/
132 Int_t ispr = 0;
133 for (ispr = 0; ispr < mkbmx1; ispr++)
134 STACK.sparek[STACK.lstack][ispr] = zerzer;
135
136 /* User dependent spare flags:*/
137 for (ispr = 0; ispr < mkbmx2; ispr++)
138 STACK.ispark[STACK.lstack][ispr] = 0;
139
140 /* Save the track number of the stack particle:*/
141 STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
142 STACK.nparma++;
143 STACK.numpar[STACK.lstack] = STACK.nparma;
144 STACK.nevent[STACK.lstack] = 0;
145 STACK.dfnear[STACK.lstack] = +zerzer;
146
147 /* Particle age (s)*/
148 STACK.agestk[STACK.lstack] = +zerzer;
149 STACK.aknshr[STACK.lstack] = -twotwo;
150
151 /* Group number for "low" energy neutrons, set to 0 anyway*/
152 STACK.igroup[STACK.lstack] = 0;
153
154 /* Kinetic energy */
155 STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
156
157
158 /* Particle momentum*/
159 STACK.pmom [STACK.lstack] = particle->P();
160
161 /* Cosines (tx,ty,tz)*/
162 Double_t cosx = particle->Px()/particle->P();
163 Double_t cosy = particle->Py()/particle->P();
164 Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
165 if (particle->Pz() < 0.) cosz = -cosz;
166 STACK.tx [STACK.lstack] = cosx;
167 STACK.ty [STACK.lstack] = cosy;
168 STACK.tz [STACK.lstack] = cosz;
169
170 /* Polarization cosines:*/
171 if (polarisation.Mag()) {
172 Double_t cospolx = polarisation.Px()/polarisation.Mag();
173 Double_t cospoly = polarisation.Py()/polarisation.Mag();
174 Double_t cospolz = sqrt(oneone - cospolx*cospolx - cospoly*cospoly);
175 STACK.tx [STACK.lstack] = cospolx;
176 STACK.ty [STACK.lstack] = cospoly;
177 STACK.tz [STACK.lstack] = cospolz;
178 }
179 else {
180 STACK.txpol [STACK.lstack] = -twotwo;
181 STACK.typol [STACK.lstack] = +zerzer;
182 STACK.tzpol [STACK.lstack] = +zerzer;
183 }
184
185 /* Particle coordinates*/
186 // Vertext coordinates;
187 STACK.xa [STACK.lstack] = particle->Vx();
188 STACK.ya [STACK.lstack] = particle->Vy();
189 STACK.za [STACK.lstack] = particle->Vz();
190
191 /* Calculate the total kinetic energy of the primaries: don't change*/
192 Int_t st_ilo = STACK.ilo[STACK.lstack];
193 if ( st_ilo != 0 )
194 EPISOR.tkesum +=
195 ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
196 * STACK.wt[STACK.lstack]);
197 else
198 EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
199
200 /* Here we ask for the region number of the hitting point.
201 * NREG (LSTACK) = ...
202 * The following line makes the starting region search much more
203 * robust if particles are starting very close to a boundary:
204 */
205 geocrs( STACK.tx[STACK.lstack],
206 STACK.ty[STACK.lstack],
207 STACK.tz[STACK.lstack] );
208
209 Int_t idisc;
210
211 georeg ( STACK.xa[STACK.lstack],
212 STACK.ya[STACK.lstack],
213 STACK.za[STACK.lstack],
214 STACK.nreg[STACK.lstack],
215 idisc);//<-- dummy return variable not used
216 /* Do not change these cards:*/
217 Int_t igeohsm1 = 1;
218 Int_t igeohsm2 = -11;
219 geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
220 STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
221 soevsv();
222//
223// Pre-track actions at for primary tracks
224//
225 }
226 }
227 }
228}
229
230