]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TFluka/stupre.cxx
Some bug fixes (A. Gheata)
[u/mrichter/AliRoot.git] / TFluka / stupre.cxx
CommitLineData
f827183d 1#include <Riostream.h>
2#include "AliRun.h"
3#include "TFluka.h"
4#ifndef WIN32
5# define stupre stupre_
6#else
7# define stupre STUPRE
8#endif
9//
10// Fluka include
11#include "Fdimpar.h" //(DIMPAR) fluka include
12// Fluka commons
13#include "Fdblprc.h" //(DBLPRC) fluka common
14#include "Femfstk.h" //(EMFSTK) fluka common
15#include "Fevtflg.h" //(EVTFLG) fluka common
16#include "Fpaprop.h" //(PAPROP) fluka common
17#include "Ftrackr.h" //(TRACKR) fluka common
18
19//Virtual MC
a7bb59a2 20#ifndef WITH_ROOT
f827183d 21#include "TFluka.h"
a7bb59a2 22#else
23#include "TFlukaGeo.h"
24#endif
25
f827183d 26#include "TVirtualMCStack.h"
27#include "TVirtualMCApplication.h"
28#include "TParticle.h"
29#include "TVector3.h"
30
31extern "C" {
32void stupre()
33{
34//*----------------------------------------------------------------------*
35//* *
36//* SeT User PRoperties for Emf particles *
37//* *
38//*----------------------------------------------------------------------*
39
40 Int_t lbhabh = 0;
41 if (EVTFLG.ldltry == 1) {
7dac99f1 42 if (EMFSTK.ichemf[EMFSTK.npemf-1] * EMFSTK.ichemf[EMFSTK.npemf-2] < 0) lbhabh = 1;
f827183d 43 }
44
45// mkbmx1 = dimension for kwb real spare array in fluka stack in DIMPAR
46// mkbmx2 = dimension for kwb int. spare array in fluka stack in DIMPAR
47// EMFSTK.espark = spare real variables available for
48// EMFSTK.iespak = spare integer variables available for
49// TRACKR.spausr = user defined spare variables for the current particle
50// TRACKR.ispusr = user defined spare flags for the current particle
51// EMFSTK.louemf = user flag
52// TRACKR.llouse = user defined flag for the current particle
53
54 Int_t npnw, ispr;
7dac99f1 55 for (npnw=EMFSTK.npstrt-1; npnw<=EMFSTK.npemf-1; npnw++) {
f827183d 56
57 for (ispr=0; ispr<=mkbmx1-1; ispr++)
58 EMFSTK.espark[npnw][ispr] = TRACKR.spausr[ispr];
59
60 for (ispr=0; ispr<=mkbmx2-1; ispr++)
61 EMFSTK.iespak[npnw][ispr] = TRACKR.ispusr[ispr];
62
63 EMFSTK.louemf[npnw] = TRACKR.llouse;
64 }
65
66// Get the pointer to the VMC
67 TVirtualMC* fluka = TFluka::GetMC();
68// Get the stack produced from the generator
69 TVirtualMCStack* cppstack = fluka->GetStack();
70
71// EVTFLG.ntrcks = track number
72// Increment the track number and put it into the last flag
73
74 Int_t kp;
7dac99f1 75 for (kp = EMFSTK.npstrt - 1; kp <= EMFSTK.npemf - 1; kp++) {
f827183d 76
77//* save the parent track number and reset it at each loop
610cd189 78 Int_t done = 0;
81ee7392 79
80 Int_t parent = TRACKR.ispusr[mkbmx2-1];
f827183d 81
f827183d 82 Int_t flukaid = 0;
7dac99f1 83
84 if (EMFSTK.ichemf[kp] == -1) flukaid = 3;
85 else if (EMFSTK.ichemf[kp] == 0) flukaid = 7;
86 else if (EMFSTK.ichemf[kp] == 0) flukaid = 4;
d15554e0 87 Int_t pdg = fluka->PDGFromId(flukaid);
7dac99f1 88 Double_t e = EMFSTK.etemf[kp] * emvgev;
d15554e0 89 Double_t p = sqrt(e * e - PAPROP.am[flukaid+6] * PAPROP.am[flukaid+6]);
90 Double_t px = p * EMFSTK.u[kp];
91 Double_t pz = p * EMFSTK.v[kp];
92 Double_t py = p * EMFSTK.w[kp];
93 Double_t tof = EMFSTK.agemf[kp];
94 Double_t polx = EMFSTK.upol[kp];
95 Double_t poly = EMFSTK.vpol[kp];
96 Double_t polz = EMFSTK.wpol[kp];
97 Double_t vx = EMFSTK.x[kp];
98 Double_t vy = EMFSTK.y[kp];
99 Double_t vz = EMFSTK.z[kp];
7dac99f1 100 Double_t weight = EMFSTK.wtemf[kp];
101
f827183d 102 Int_t ntr;
103 TMCProcess mech;
104 Int_t is = 0;
105
106//* case of no parent left (pair, photoelectric, annihilation):
107//* all secondaries are true
108 if ((EVTFLG.lpairp == 1) || (EVTFLG.lphoel == 1) ||
109 (EVTFLG.lannfl == 1) || (EVTFLG.lannrs == 1)) {
81ee7392 110
111 if (EVTFLG.lpairp == 1) mech = kPPair;
112 else if (EVTFLG.lphoel == 1) mech = kPPhotoelectric;
113 else mech = kPAnnihilation;
642f15cf 114 cppstack->PushTrack(done, parent, pdg,
81ee7392 115 px, py, pz, e, vx, vy, vz, tof,
116 polx, poly, polz, mech, ntr, weight, is);
d15554e0 117 cout << endl << " !!! stupre (PAIR, ..) : ntr=" << ntr << "pdg " << pdg << " parent=" << parent << endl;
118
81ee7392 119 EMFSTK.iespak[kp][mkbmx2-1] = ntr;
f827183d 120 } // end of lpairp, lphoel, lannfl, lannrs
121
122//* Compton: secondary is true only if charged (e+, e-)
123 else if ((EVTFLG.lcmptn == 1)) {
7dac99f1 124
125 if (EMFSTK.ichemf[kp] != 0) {
81ee7392 126 mech = kPCompton;
642f15cf 127 cppstack->PushTrack(done, parent, pdg,
81ee7392 128 px, py, pz, e, vx, vy, vz, tof,
129 polx, poly, polz, mech, ntr, weight, is);
d15554e0 130 cout << endl << " !!! stupre (COMPTON) : ntr=" << ntr << "pdg " << pdg << " parent=" << parent << endl;
81ee7392 131 EMFSTK.iespak[kp][mkbmx2-1] = ntr;
132 }
f827183d 133 } // end of lcmptn
81ee7392 134
f827183d 135//* Bremsstrahlung: true secondary only if charge = 0 (photon)
136 else if ((EVTFLG.lbrmsp == 1)) {
7dac99f1 137 if (EMFSTK.ichemf[kp] == 0) {
81ee7392 138 mech = kPBrem;
642f15cf 139 cppstack->PushTrack(done, parent, pdg,
81ee7392 140 px, py, pz, e, vx, vy, vz, tof,
141 polx, poly, polz, mech, ntr, weight, is);
d15554e0 142 cout << endl << " !!! stupre (BREMS) : ntr=" << ntr << "pdg " << pdg << " parent=" << parent << endl;
81ee7392 143 EMFSTK.iespak[kp][mkbmx2-1] = ntr;
144 }
f827183d 145 } // end of lbrmsp
81ee7392 146
f827183d 147//* Delta ray: If Bhabha, true secondary only if negative (electron)
148 else if ((EVTFLG.ldltry == 1)) {
81ee7392 149 if (lbhabh == 1) {
7dac99f1 150 if (EMFSTK.ichemf[kp] == -1) {
81ee7392 151 mech = kPDeltaRay;
642f15cf 152 cppstack->PushTrack(done, parent, pdg,
81ee7392 153 px, py, pz, e, vx, vy, vz, tof,
154 polx, poly, polz, mech, ntr, weight, is);
155 EMFSTK.iespak[kp][mkbmx2-1] = ntr;
d15554e0 156 cout << endl << " !!! stupre (BHABA) : ntr=" << ntr << "pdg " << pdg << " parent=" << parent << endl;
81ee7392 157 } // end of Bhabha
d15554e0 158 } // lbhabh == 1
81ee7392 159
f827183d 160//* Delta ray: Otherwise Moller: true secondary is the electron with
161//* lower energy, which has been put higher in the stack
7dac99f1 162 else if (kp == EMFSTK.npemf-1) {
81ee7392 163 mech = kPDeltaRay;
642f15cf 164 cppstack->PushTrack(done, parent, pdg,
81ee7392 165 px, py, pz, e, vx, vy, vz, tof,
166 polx, poly, polz, mech, ntr, weight, is);
d15554e0 167 cout << endl << " !!! stupre (Moller) : ntr=" << ntr << "pdg " << pdg << " parent=" << parent << endl;
81ee7392 168 EMFSTK.iespak[kp][mkbmx2-1] = ntr;
169 } // end of Delta ray
f827183d 170 } // end of ldltry
81ee7392 171
f827183d 172 } // end of loop
81ee7392 173
f827183d 174// !!! TO BE CONFIRMED !!!
f827183d 175} // end of stupre
176} // end of extern "C"
177