]>
Commit | Line | Data |
---|---|---|
b9d0a01d | 1 | // Fortran |
2 | #include "TCallf77.h" | |
3 | ||
4 | // Fluka commons | |
5 | #include "Fdblprc.h" //(DBLPRC) fluka common | |
6 | #include "Fdimpar.h" //(DIMPAR) fluka parameters | |
81f1d030 | 7 | #include "Fsourcm.h" //(EPISOR) fluka common |
8 | #include "Fflkstk.h" //(FLKSTK) fluka common | |
380c2ff0 | 9 | #include "Fsumcou.h" //(SUMCOU) fluka common |
b9d0a01d | 10 | #include "Fpaprop.h" //(PAPROP) fluka common |
11 | #include "Fltclcm.h" //(LTCLCM) fluka common | |
cfd35035 | 12 | #include "Fopphst.h" //(OPPHST) fluka common |
b9d0a01d | 13 | |
14 | //Virutal MC | |
15 | #include "TFluka.h" | |
a7bb59a2 | 16 | |
b9d0a01d | 17 | #include "TVirtualMCStack.h" |
fbf08100 | 18 | //#include "TVirtualMCApplication.h" |
fbf08100 | 19 | |
b9d0a01d | 20 | #include "TParticle.h" |
21 | #include "TVector3.h" | |
22 | ||
23 | //Other | |
eae0fe66 | 24 | #include <Riostream.h> |
b9d0a01d | 25 | |
26 | #ifndef WIN32 | |
27 | # define source source_ | |
28 | # define geocrs geocrs_ | |
29 | # define georeg georeg_ | |
30 | # define geohsm geohsm_ | |
31 | # define soevsv soevsv_ | |
32 | #else | |
33 | # define source SOURCE | |
34 | # define geocrs GEOCRS | |
35 | # define georeg GEOREG | |
36 | # define geohsm GEOHSM | |
37 | # define soevsv SOEVSV | |
38 | #endif | |
39 | ||
b9d0a01d | 40 | extern "C" { |
41 | // | |
42 | // Prototypes for FLUKA functions | |
43 | // | |
44 | void type_of_call geocrs(Double_t &, Double_t &, Double_t &); | |
45 | void type_of_call georeg(Double_t &, Double_t &, Double_t &, | |
46 | Int_t &, Int_t &); | |
47 | void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &); | |
48 | void type_of_call soevsv(); | |
49 | /* | |
50 | *----------------------------------------------------------------------* | |
51 | * * | |
52 | * Created on 07 january 1990 by Alfredo Ferrari & Paola Sala * | |
53 | * Infn - Milan * | |
54 | * * | |
55 | * Last change on 21-jun-98 by Alfredo Ferrari * | |
56 | * * | |
57 | * C++ version on 27-sep-02 by Isidro Gonzalez * | |
58 | * * | |
59 | * This is just an example of a possible user written source routine. * | |
60 | * note that the beam card still has some meaning - in the scoring the * | |
61 | * maximum momentum used in deciding the binning is taken from the * | |
62 | * beam momentum. Other beam card parameters are obsolete. * | |
63 | * * | |
64 | *----------------------------------------------------------------------*/ | |
65 | ||
66 | void source(Int_t& nomore) { | |
b496f27c | 67 | // Get the pointer to TFluka |
2bc4c610 | 68 | TFluka* fluka = (TFluka*)gMC; |
b496f27c | 69 | |
2bc4c610 | 70 | Int_t verbosityLevel = fluka->GetVerbosityLevel(); |
71 | Bool_t debug = (verbosityLevel>=3)?kTRUE:kFALSE; | |
72 | if (debug) { | |
ce60a136 | 73 | cout << "==> source(" << nomore << ")" << endl; |
81f1d030 | 74 | cout << "\t* SOURCM.lsouit = " << (SOURCM.lsouit?'T':'F') << endl; |
2bc4c610 | 75 | } |
b9d0a01d | 76 | |
2bc4c610 | 77 | static Bool_t lfirst = true; |
78 | static Bool_t particleIsPrimary = true; | |
79 | static Bool_t lastParticleWasPrimary = true; | |
b9d0a01d | 80 | |
ce60a136 | 81 | nomore = 0; |
cadd9e6b | 82 | |
b496f27c | 83 | |
84 | // Get the stack | |
b9d0a01d | 85 | TVirtualMCStack* cppstack = fluka->GetStack(); |
b496f27c | 86 | |
ce60a136 | 87 | TParticle* particle; |
b9d0a01d | 88 | Int_t itrack = -1; |
ce60a136 | 89 | Int_t nprim = cppstack->GetNprimary(); |
90 | // Get the next particle from the stack | |
91 | particle = cppstack->PopNextTrack(itrack); | |
2bc4c610 | 92 | fluka->SetTrackIsNew(kTRUE); |
a32460fe | 93 | if (itrack == (nprim - 1)) lfirst = true; |
ce60a136 | 94 | // Is this a secondary not handled by Fluka, i.e. a particle added by user action ? |
95 | lastParticleWasPrimary = particleIsPrimary; | |
96 | ||
97 | if (itrack >= nprim) { | |
98 | particleIsPrimary = kFALSE; | |
99 | } else { | |
100 | particleIsPrimary = kTRUE; | |
101 | } | |
102 | ||
ce60a136 | 103 | if (lfirst) { |
81f1d030 | 104 | SOURCM.tkesum = zerzer; |
ce60a136 | 105 | lfirst = false; |
81f1d030 | 106 | SOURCM.lussrc = true; |
ce60a136 | 107 | } else { |
108 | // | |
109 | // Post-track actions for primary track | |
110 | // | |
111 | if (particleIsPrimary) { | |
112 | TVirtualMCApplication::Instance()->PostTrack(); | |
113 | TVirtualMCApplication::Instance()->FinishPrimary(); | |
b496f27c | 114 | if ((itrack%10)==0) printf("=== TRACKING PRIMARY %d ===\n", itrack); |
ce60a136 | 115 | } |
116 | } | |
b9d0a01d | 117 | |
b496f27c | 118 | // Exit if itrack is negative (-1). Set lsouit to false to mark last track for this event |
ce60a136 | 119 | |
b9d0a01d | 120 | if (itrack<0) { |
121 | nomore = 1; | |
81f1d030 | 122 | SOURCM.lsouit = false; |
2bc4c610 | 123 | if (debug) { |
81f1d030 | 124 | cout << "\t* SOURCM.lsouit = " << (SOURCM.lsouit?'T':'F') << endl; |
2bc4c610 | 125 | cout << "\t* No more particles. Exiting..." << endl; |
126 | cout << "<== source(" << nomore << ")" << endl; | |
127 | } | |
b9d0a01d | 128 | return; |
129 | } | |
ce60a136 | 130 | |
b496f27c | 131 | // |
132 | // Handle user event abortion | |
133 | if (fluka->EventIsStopped()) { | |
134 | printf("Event has been stopped by user !"); | |
135 | fluka->SetStopEvent(kFALSE); | |
136 | nomore = 1; | |
81f1d030 | 137 | SOURCM.lsouit = false; |
b496f27c | 138 | return; |
139 | } | |
140 | ||
b9d0a01d | 141 | //Get some info about the particle and print it |
ce60a136 | 142 | // |
143 | //pdg code | |
144 | Int_t pdg = particle->GetPdgCode(); | |
b9d0a01d | 145 | TVector3 polarisation; |
146 | particle->GetPolarisation(polarisation); | |
2bc4c610 | 147 | if (debug) { |
148 | cout << "\t* Particle " << itrack << " retrieved..." << endl; | |
149 | cout << "\t\t+ Name = " << particle->GetName() << endl; | |
150 | cout << "\t\t+ PDG/Fluka code = " << pdg | |
151 | << " / " << fluka->IdFromPDG(pdg) << endl; | |
152 | cout << "\t\t+ P = (" | |
153 | << particle->Px() << " , " | |
154 | << particle->Py() << " , " | |
155 | << particle->Pz() << " ) --> " | |
6b51799c | 156 | << particle->P() << " GeV " |
157 | << particle->Energy() << " GeV " | |
158 | << particle->GetMass() << " GeV " << endl; | |
2bc4c610 | 159 | } |
81f1d030 | 160 | /* Npflka is the stack counter: of course any time source is called it |
b9d0a01d | 161 | * must be =0 |
162 | */ | |
cfd35035 | 163 | /* Cosines (tx,ty,tz)*/ |
164 | Double_t cosx = particle->Px()/particle->P(); | |
165 | Double_t cosy = particle->Py()/particle->P(); | |
166 | Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy); | |
167 | if (particle->Pz() < 0.) cosz = -cosz; | |
ce60a136 | 168 | |
cfd35035 | 169 | if (pdg != 50000050 && pdg != 50000051) { |
81f1d030 | 170 | FLKSTK.npflka++; |
6b51799c | 171 | Int_t ifl = fluka-> IdFromPDG(pdg); |
81f1d030 | 172 | FLKSTK.iloflk[FLKSTK.npflka] = ifl; |
173 | /* Wtflk is the weight of the particle*/ | |
174 | FLKSTK.wtflk[FLKSTK.npflka] = oneone; | |
175 | SUMCOU.weipri += FLKSTK.wtflk[FLKSTK.npflka]; | |
cfd35035 | 176 | |
81f1d030 | 177 | FLKSTK.loflk[FLKSTK.npflka] = 1; |
cfd35035 | 178 | |
179 | /* User dependent flag:*/ | |
81f1d030 | 180 | FLKSTK.louse[FLKSTK.npflka] = 0; |
ce60a136 | 181 | |
cfd35035 | 182 | /* User dependent spare variables:*/ |
183 | Int_t ispr = 0; | |
184 | for (ispr = 0; ispr < mkbmx1; ispr++) | |
81f1d030 | 185 | FLKSTK.sparek[FLKSTK.npflka][ispr] = zerzer; |
ce60a136 | 186 | |
cfd35035 | 187 | /* User dependent spare flags:*/ |
188 | for (ispr = 0; ispr < mkbmx2; ispr++) | |
81f1d030 | 189 | FLKSTK.ispark[FLKSTK.npflka][ispr] = 0; |
ce60a136 | 190 | |
cfd35035 | 191 | /* Save the track number of the stack particle:*/ |
81f1d030 | 192 | FLKSTK.ispark[FLKSTK.npflka][mkbmx2-1] = itrack; |
193 | FLKSTK.nparma++; | |
194 | FLKSTK.numpar[FLKSTK.npflka] = FLKSTK.nparma; | |
195 | FLKSTK.nevent[FLKSTK.npflka] = 0; | |
196 | FLKSTK.dfnear[FLKSTK.npflka] = +zerzer; | |
e5e3c7b1 | 197 | |
cfd35035 | 198 | /* Particle age (s)*/ |
81f1d030 | 199 | FLKSTK.agestk[FLKSTK.npflka] = +zerzer; |
200 | FLKSTK.cmpath[FLKSTK.npflka] = +zerzer; | |
201 | FLKSTK.aknshr[FLKSTK.npflka] = -twotwo; | |
ce60a136 | 202 | |
cfd35035 | 203 | /* Group number for "low" energy neutrons, set to 0 anyway*/ |
81f1d030 | 204 | FLKSTK.igroup[FLKSTK.npflka] = 0; |
cfd35035 | 205 | |
206 | /* Kinetic energy */ | |
6b51799c | 207 | Double_t p = particle->P(); |
208 | Double_t mass = PAPROP.am[ifl + 6]; | |
81f1d030 | 209 | FLKSTK.tkeflk[FLKSTK.npflka] = TMath::Sqrt( p * p + mass * mass) - mass; |
cfd35035 | 210 | /* Particle momentum*/ |
81f1d030 | 211 | FLKSTK.pmoflk [FLKSTK.npflka] = p; |
cfd35035 | 212 | |
81f1d030 | 213 | FLKSTK.txflk [FLKSTK.npflka] = cosx; |
214 | FLKSTK.tyflk [FLKSTK.npflka] = cosy; | |
215 | FLKSTK.tzflk [FLKSTK.npflka] = cosz; | |
b9d0a01d | 216 | |
cfd35035 | 217 | /* Polarization cosines:*/ |
218 | if (polarisation.Mag()) { | |
219 | Double_t cospolx = polarisation.Px() / polarisation.Mag(); | |
220 | Double_t cospoly = polarisation.Py() / polarisation.Mag(); | |
221 | Double_t cospolz = sqrt(oneone - cospolx * cospolx - cospoly * cospoly); | |
81f1d030 | 222 | FLKSTK.txpol [FLKSTK.npflka] = cospolx; |
223 | FLKSTK.typol [FLKSTK.npflka] = cospoly; | |
224 | FLKSTK.tzpol [FLKSTK.npflka] = cospolz; | |
cfd35035 | 225 | } |
226 | else { | |
81f1d030 | 227 | FLKSTK.txpol [FLKSTK.npflka] = -twotwo; |
228 | FLKSTK.typol [FLKSTK.npflka] = +zerzer; | |
229 | FLKSTK.tzpol [FLKSTK.npflka] = +zerzer; | |
cfd35035 | 230 | } |
231 | ||
232 | /* Particle coordinates*/ | |
233 | // Vertext coordinates; | |
81f1d030 | 234 | FLKSTK.xflk [FLKSTK.npflka] = particle->Vx(); |
235 | FLKSTK.yflk [FLKSTK.npflka] = particle->Vy(); | |
236 | FLKSTK.zflk [FLKSTK.npflka] = particle->Vz(); | |
b9d0a01d | 237 | |
cfd35035 | 238 | /* Calculate the total kinetic energy of the primaries: don't change*/ |
81f1d030 | 239 | Int_t st_ilo = FLKSTK.iloflk[FLKSTK.npflka]; |
cfd35035 | 240 | if ( st_ilo != 0 ) |
81f1d030 | 241 | SOURCM.tkesum += |
242 | ((FLKSTK.tkeflk[FLKSTK.npflka] + PAPROP.amdisc[st_ilo+6]) | |
243 | * FLKSTK.wtflk[FLKSTK.npflka]); | |
cfd35035 | 244 | else |
81f1d030 | 245 | SOURCM.tkesum += (FLKSTK.tkeflk[FLKSTK.npflka] * FLKSTK.wtflk[FLKSTK.npflka]); |
cfd35035 | 246 | |
247 | /* Here we ask for the region number of the hitting point. | |
81f1d030 | 248 | * NRGFLK (LFLKSTK) = ... |
cfd35035 | 249 | * The following line makes the starting region search much more |
250 | * robust if particles are starting very close to a boundary: | |
251 | */ | |
81f1d030 | 252 | geocrs( FLKSTK.txflk[FLKSTK.npflka], |
253 | FLKSTK.tyflk[FLKSTK.npflka], | |
254 | FLKSTK.tzflk[FLKSTK.npflka] ); | |
b9d0a01d | 255 | |
cfd35035 | 256 | Int_t idisc; |
257 | ||
81f1d030 | 258 | georeg ( FLKSTK.xflk[FLKSTK.npflka], |
259 | FLKSTK.yflk[FLKSTK.npflka], | |
260 | FLKSTK.zflk[FLKSTK.npflka], | |
261 | FLKSTK.nrgflk[FLKSTK.npflka], | |
cfd35035 | 262 | idisc);//<-- dummy return variable not used |
263 | /* Do not change these cards:*/ | |
264 | Int_t igeohsm1 = 1; | |
265 | Int_t igeohsm2 = -11; | |
81f1d030 | 266 | geohsm ( FLKSTK.nhspnt[FLKSTK.npflka], igeohsm1, igeohsm2, LTCLCM.mlattc ); |
267 | FLKSTK.nlattc[FLKSTK.npflka] = LTCLCM.mlattc; | |
cfd35035 | 268 | soevsv(); |
269 | } else { | |
b496f27c | 270 | // |
cfd35035 | 271 | // Next particle is optical photon |
b496f27c | 272 | // |
cfd35035 | 273 | OPPHST.lstopp++; |
274 | OPPHST.donear [OPPHST.lstopp - 1] = 0.; | |
275 | ||
276 | OPPHST.xoptph [OPPHST.lstopp - 1] = particle->Vx(); | |
277 | OPPHST.yoptph [OPPHST.lstopp - 1] = particle->Vy(); | |
278 | OPPHST.zoptph [OPPHST.lstopp - 1] = particle->Vz(); | |
279 | ||
280 | OPPHST.txopph [OPPHST.lstopp - 1] = cosx; | |
281 | OPPHST.tyopph [OPPHST.lstopp - 1] = cosy; | |
282 | OPPHST.tzopph [OPPHST.lstopp - 1] = cosz; | |
283 | ||
284 | ||
285 | if (polarisation.Mag()) { | |
286 | Double_t cospolx = polarisation.Px() / polarisation.Mag(); | |
287 | Double_t cospoly = polarisation.Py() / polarisation.Mag(); | |
288 | Double_t cospolz = sqrt(oneone - cospolx * cospolx - cospoly * cospoly); | |
289 | OPPHST.txpopp [OPPHST.lstopp - 1] = cospolx; | |
290 | OPPHST.typopp [OPPHST.lstopp - 1] = cospoly; | |
291 | OPPHST.tzpopp [OPPHST.lstopp - 1] = cospolz; | |
292 | } | |
293 | else { | |
294 | OPPHST.txpopp [OPPHST.lstopp - 1] = -twotwo; | |
295 | OPPHST.typopp [OPPHST.lstopp - 1] = +zerzer; | |
296 | OPPHST.tzpopp [OPPHST.lstopp - 1] = +zerzer; | |
297 | } | |
298 | ||
299 | geocrs( OPPHST.txopph[OPPHST.lstopp - 1], | |
300 | OPPHST.tyopph[OPPHST.lstopp - 1], | |
301 | OPPHST.tzopph[OPPHST.lstopp - 1] ); | |
ce60a136 | 302 | |
cfd35035 | 303 | Int_t idisc; |
304 | ||
305 | georeg ( OPPHST.xoptph[OPPHST.lstopp - 1], | |
306 | OPPHST.yoptph[OPPHST.lstopp - 1], | |
307 | OPPHST.zoptph[OPPHST.lstopp - 1], | |
308 | OPPHST.nregop[OPPHST.lstopp - 1], | |
309 | idisc);//<-- dummy return variable not used | |
310 | ||
311 | OPPHST.wtopph [OPPHST.lstopp - 1] = particle->GetWeight(); | |
312 | OPPHST.poptph [OPPHST.lstopp - 1] = particle->P(); | |
313 | OPPHST.agopph [OPPHST.lstopp - 1] = particle->T(); | |
e5e3c7b1 | 314 | OPPHST.cmpopp [OPPHST.lstopp - 1] = +zerzer; |
cfd35035 | 315 | OPPHST.loopph [OPPHST.lstopp - 1] = 0; |
cfd35035 | 316 | OPPHST.louopp [OPPHST.lstopp - 1] = itrack; |
cfd35035 | 317 | } |
318 | ||
ce60a136 | 319 | // |
320 | // Pre-track actions at for primary tracks | |
321 | // | |
322 | if (particleIsPrimary) { | |
323 | TVirtualMCApplication::Instance()->BeginPrimary(); | |
324 | TVirtualMCApplication::Instance()->PreTrack(); | |
325 | } | |
326 | ||
327 | // | |
2bc4c610 | 328 | if (debug) cout << "<== source(" << nomore << ")" << endl; |
b9d0a01d | 329 | } |
330 | } |