]>
Commit | Line | Data |
---|---|---|
b9d0a01d | 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 "Fcaslim.h" //(CASLIM) fluka common | |
16 | ||
17 | //Virutal MC | |
a7bb59a2 | 18 | #ifndef WITH_ROOT |
b9d0a01d | 19 | #include "TFluka.h" |
a7bb59a2 | 20 | #else |
21 | #include "TFlukaGeo.h" | |
22 | #endif | |
23 | ||
b9d0a01d | 24 | #include "TVirtualMCStack.h" |
fbf08100 | 25 | //#include "TVirtualMCApplication.h" |
26 | #ifndef WITH_ROOT | |
27 | #include "TFluka.h" | |
28 | #else | |
29 | #include "TFlukaGeo.h" | |
30 | #endif | |
31 | ||
b9d0a01d | 32 | #include "TParticle.h" |
33 | #include "TVector3.h" | |
34 | ||
35 | //Other | |
eae0fe66 | 36 | #include <Riostream.h> |
b9d0a01d | 37 | |
38 | #ifndef WIN32 | |
39 | # define source source_ | |
40 | # define geocrs geocrs_ | |
41 | # define georeg georeg_ | |
42 | # define geohsm geohsm_ | |
43 | # define soevsv soevsv_ | |
44 | #else | |
45 | # define source SOURCE | |
46 | # define geocrs GEOCRS | |
47 | # define georeg GEOREG | |
48 | # define geohsm GEOHSM | |
49 | # define soevsv SOEVSV | |
50 | #endif | |
51 | ||
b9d0a01d | 52 | extern "C" { |
53 | // | |
54 | // Prototypes for FLUKA functions | |
55 | // | |
56 | void type_of_call geocrs(Double_t &, Double_t &, Double_t &); | |
57 | void type_of_call georeg(Double_t &, Double_t &, Double_t &, | |
58 | Int_t &, Int_t &); | |
59 | void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &); | |
60 | void type_of_call soevsv(); | |
61 | /* | |
62 | *----------------------------------------------------------------------* | |
63 | * * | |
64 | * Created on 07 january 1990 by Alfredo Ferrari & Paola Sala * | |
65 | * Infn - Milan * | |
66 | * * | |
67 | * Last change on 21-jun-98 by Alfredo Ferrari * | |
68 | * * | |
69 | * C++ version on 27-sep-02 by Isidro Gonzalez * | |
70 | * * | |
71 | * This is just an example of a possible user written source routine. * | |
72 | * note that the beam card still has some meaning - in the scoring the * | |
73 | * maximum momentum used in deciding the binning is taken from the * | |
74 | * beam momentum. Other beam card parameters are obsolete. * | |
75 | * * | |
76 | *----------------------------------------------------------------------*/ | |
77 | ||
78 | void source(Int_t& nomore) { | |
79 | #ifdef METHODDEBUG | |
ce60a136 | 80 | cout << "==> source(" << nomore << ")" << endl; |
b9d0a01d | 81 | #endif |
82 | ||
ce60a136 | 83 | cout << "\t* EPISOR.lsouit = " << (EPISOR.lsouit?'T':'F') << endl; |
b9d0a01d | 84 | |
ce60a136 | 85 | static Bool_t lfirst = true; |
86 | static Bool_t particleIsPrimary = true; | |
87 | static Bool_t lastParticleWasPrimary = true; | |
88 | ||
89 | /* +-------------------------------------------------------------------* | |
90 | * First call initializations for FLUKA: */ | |
b9d0a01d | 91 | |
b9d0a01d | 92 | |
ce60a136 | 93 | nomore = 0; |
b9d0a01d | 94 | // Get the pointer to the VMC |
95 | TVirtualMC* fluka = TFluka::GetMC(); | |
ce60a136 | 96 | // Get the stack |
b9d0a01d | 97 | TVirtualMCStack* cppstack = fluka->GetStack(); |
ce60a136 | 98 | TParticle* particle; |
b9d0a01d | 99 | Int_t itrack = -1; |
ce60a136 | 100 | Int_t nprim = cppstack->GetNprimary(); |
101 | // Get the next particle from the stack | |
102 | particle = cppstack->PopNextTrack(itrack); | |
fbf08100 | 103 | ((TFluka*)fluka)->SetTrackIsNew(kTRUE); |
ce60a136 | 104 | |
105 | // Is this a secondary not handled by Fluka, i.e. a particle added by user action ? | |
106 | lastParticleWasPrimary = particleIsPrimary; | |
107 | ||
108 | if (itrack >= nprim) { | |
109 | particleIsPrimary = kFALSE; | |
110 | } else { | |
111 | particleIsPrimary = kTRUE; | |
112 | } | |
113 | ||
114 | // printf("--->Got Particle %d %d %d\n", itrack, particleIsPrimary, lastParticleWasPrimary); | |
115 | ||
116 | if (lfirst) { | |
117 | EPISOR.tkesum = zerzer; | |
118 | lfirst = false; | |
119 | EPISOR.lussrc = true; | |
120 | } else { | |
121 | // | |
122 | // Post-track actions for primary track | |
123 | // | |
124 | if (particleIsPrimary) { | |
125 | TVirtualMCApplication::Instance()->PostTrack(); | |
126 | TVirtualMCApplication::Instance()->FinishPrimary(); | |
127 | } | |
128 | } | |
b9d0a01d | 129 | |
130 | //Exit if itrack is negative (-1). Set lsouit to false to mark last track for | |
131 | //this event | |
ce60a136 | 132 | |
b9d0a01d | 133 | if (itrack<0) { |
134 | nomore = 1; | |
135 | EPISOR.lsouit = false; | |
136 | cout << "\t* EPISOR.lsouit = " << (EPISOR.lsouit?'T':'F') << endl; | |
137 | cout << "\t* No more particles. Exiting..." << endl; | |
138 | #ifdef METHODDEBUG | |
139 | cout << "<== source(" << nomore << ")" << endl; | |
140 | #endif | |
141 | return; | |
142 | } | |
ce60a136 | 143 | |
b9d0a01d | 144 | //Get some info about the particle and print it |
ce60a136 | 145 | // |
146 | //pdg code | |
147 | Int_t pdg = particle->GetPdgCode(); | |
148 | ||
b9d0a01d | 149 | TVector3 polarisation; |
150 | particle->GetPolarisation(polarisation); | |
151 | cout << "\t* Particle " << itrack << " retrieved..." << endl; | |
152 | cout << "\t\t+ Name = " << particle->GetName() << endl; | |
ce60a136 | 153 | cout << "\t\t+ PDG/Fluka code = " << pdg |
154 | << " / " << fluka->IdFromPDG(pdg) << endl; | |
b9d0a01d | 155 | cout << "\t\t+ P = (" |
156 | << particle->Px() << " , " | |
157 | << particle->Py() << " , " | |
158 | << particle->Pz() << " ) --> " | |
159 | << particle->P() << " GeV" << endl; | |
b9d0a01d | 160 | /* Lstack is the stack counter: of course any time source is called it |
161 | * must be =0 | |
162 | */ | |
45dc600a | 163 | |
b9d0a01d | 164 | STACK.lstack++; |
ce60a136 | 165 | |
b9d0a01d | 166 | /* Wt is the weight of the particle*/ |
167 | STACK.wt[STACK.lstack] = oneone; | |
168 | STARS.weipri += STACK.wt[STACK.lstack]; | |
ce60a136 | 169 | |
b9d0a01d | 170 | /* Particle type (1=proton.....). Ijbeam is the type set by the BEAM |
171 | * card | |
172 | */ | |
ce60a136 | 173 | |
b9d0a01d | 174 | //STACK.ilo[STACK.lstack] = BEAM.ijbeam; |
ce60a136 | 175 | if (pdg == 50000050 || pdg == 50000051) { |
176 | STACK.ilo[STACK.lstack] = fluka-> IdFromPDG(22); | |
177 | } else { | |
178 | STACK.ilo[STACK.lstack] = fluka-> IdFromPDG(pdg); | |
179 | } | |
180 | ||
181 | ||
182 | ||
183 | ||
b9d0a01d | 184 | /* From this point ..... |
185 | * Particle generation (1 for primaries) | |
ce60a136 | 186 | */ |
b9d0a01d | 187 | STACK.lo[STACK.lstack] = 1; |
ce60a136 | 188 | |
b9d0a01d | 189 | /* User dependent flag:*/ |
190 | STACK.louse[STACK.lstack] = 0; | |
ce60a136 | 191 | |
b9d0a01d | 192 | /* User dependent spare variables:*/ |
148ba0b4 | 193 | Int_t ispr = 0; |
194 | for (ispr = 0; ispr < mkbmx1; ispr++) | |
b9d0a01d | 195 | STACK.sparek[STACK.lstack][ispr] = zerzer; |
ce60a136 | 196 | |
b9d0a01d | 197 | /* User dependent spare flags:*/ |
148ba0b4 | 198 | for (ispr = 0; ispr < mkbmx2; ispr++) |
b9d0a01d | 199 | STACK.ispark[STACK.lstack][ispr] = 0; |
ce60a136 | 200 | |
b9d0a01d | 201 | /* Save the track number of the stack particle:*/ |
5d298556 | 202 | STACK.ispark[STACK.lstack][mkbmx2-1] = itrack; |
b9d0a01d | 203 | STACK.nparma++; |
204 | STACK.numpar[STACK.lstack] = STACK.nparma; | |
205 | STACK.nevent[STACK.lstack] = 0; | |
206 | STACK.dfnear[STACK.lstack] = +zerzer; | |
ce60a136 | 207 | |
208 | /* Particle age (s)*/ | |
b9d0a01d | 209 | STACK.agestk[STACK.lstack] = +zerzer; |
210 | STACK.aknshr[STACK.lstack] = -twotwo; | |
ce60a136 | 211 | |
b9d0a01d | 212 | /* Group number for "low" energy neutrons, set to 0 anyway*/ |
213 | STACK.igroup[STACK.lstack] = 0; | |
ce60a136 | 214 | |
215 | /* Kinetic energy */ | |
216 | if (pdg == 50000050 || pdg == 50000051) { | |
217 | // | |
218 | // Special case for optical photons | |
219 | STACK.tke[STACK.lstack] = particle->Energy(); | |
220 | } else { | |
221 | STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass(); | |
222 | } | |
223 | ||
b9d0a01d | 224 | |
225 | /* Particle momentum*/ | |
b9d0a01d | 226 | STACK.pmom [STACK.lstack] = particle->P(); |
227 | ||
ce60a136 | 228 | /* Cosines (tx,ty,tz)*/ |
b9d0a01d | 229 | Double_t cosx = particle->Px()/particle->P(); |
230 | Double_t cosy = particle->Py()/particle->P(); | |
57dd4539 | 231 | Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy); |
232 | if (particle->Pz() < 0.) cosz = -cosz; | |
b9d0a01d | 233 | STACK.tx [STACK.lstack] = cosx; |
234 | STACK.ty [STACK.lstack] = cosy; | |
235 | STACK.tz [STACK.lstack] = cosz; | |
236 | ||
ce60a136 | 237 | /* Polarization cosines:*/ |
b9d0a01d | 238 | if (polarisation.Mag()) { |
ce60a136 | 239 | Double_t cospolx = polarisation.Px()/polarisation.Mag(); |
240 | Double_t cospoly = polarisation.Py()/polarisation.Mag(); | |
241 | Double_t cospolz = sqrt(oneone - cospolx*cospolx - cospoly*cospoly); | |
242 | STACK.tx [STACK.lstack] = cospolx; | |
243 | STACK.ty [STACK.lstack] = cospoly; | |
244 | STACK.tz [STACK.lstack] = cospolz; | |
b9d0a01d | 245 | } |
246 | else { | |
ce60a136 | 247 | STACK.txpol [STACK.lstack] = -twotwo; |
248 | STACK.typol [STACK.lstack] = +zerzer; | |
249 | STACK.tzpol [STACK.lstack] = +zerzer; | |
b9d0a01d | 250 | } |
251 | ||
252 | /* Particle coordinates*/ | |
ce60a136 | 253 | // Vertext coordinates; |
b9d0a01d | 254 | STACK.xa [STACK.lstack] = particle->Vx(); |
255 | STACK.ya [STACK.lstack] = particle->Vy(); | |
256 | STACK.za [STACK.lstack] = particle->Vz(); | |
257 | ||
b9d0a01d | 258 | /* Calculate the total kinetic energy of the primaries: don't change*/ |
259 | Int_t st_ilo = STACK.ilo[STACK.lstack]; | |
260 | if ( st_ilo != 0 ) | |
ce60a136 | 261 | EPISOR.tkesum += |
262 | ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6]) | |
263 | * STACK.wt[STACK.lstack]); | |
b9d0a01d | 264 | else |
ce60a136 | 265 | EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]); |
b9d0a01d | 266 | |
267 | /* Here we ask for the region number of the hitting point. | |
268 | * NREG (LSTACK) = ... | |
269 | * The following line makes the starting region search much more | |
270 | * robust if particles are starting very close to a boundary: | |
271 | */ | |
272 | geocrs( STACK.tx[STACK.lstack], | |
273 | STACK.ty[STACK.lstack], | |
274 | STACK.tz[STACK.lstack] ); | |
ce60a136 | 275 | |
b9d0a01d | 276 | Int_t idisc; |
ce60a136 | 277 | |
b9d0a01d | 278 | georeg ( STACK.xa[STACK.lstack], |
279 | STACK.ya[STACK.lstack], | |
280 | STACK.za[STACK.lstack], | |
281 | STACK.nreg[STACK.lstack], | |
282 | idisc);//<-- dummy return variable not used | |
b9d0a01d | 283 | /* Do not change these cards:*/ |
284 | Int_t igeohsm1 = 1; | |
285 | Int_t igeohsm2 = -11; | |
286 | geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc ); | |
287 | STACK.nlattc[STACK.lstack] = LTCLCM.mlattc; | |
288 | soevsv(); | |
ce60a136 | 289 | // |
290 | // Pre-track actions at for primary tracks | |
291 | // | |
292 | if (particleIsPrimary) { | |
293 | TVirtualMCApplication::Instance()->BeginPrimary(); | |
294 | TVirtualMCApplication::Instance()->PreTrack(); | |
295 | } | |
296 | ||
297 | // | |
298 | ||
b9d0a01d | 299 | #ifdef METHODDEBUG |
300 | cout << "<== source(" << nomore << ")" << endl; | |
301 | #endif | |
302 | } | |
303 | } |