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