113{
114
116 adjustResult = false;
117
118 if (fCache.
Get() == 0 ) cacheInit();
122 if (massCode == 0) {
138 "G4ParticleHPContAngularPar: Unknown ion case 1");
139 } else {
141 }
142
147
148 if (angularRep == 1) {
149 if (nDiscreteEnergies != 0) {
150
151
152 if (fCache.
Get()->fresh ==
true) {
153
154
155 fCache.
Get()->remaining_energy = std::max (theAngular[0].GetLabel(),
156 theAngular[nEnergies-1].GetLabel() );
157 fCache.
Get()->fresh =
false;
158 }
159
160
161
162 if (nDiscreteEnergies == nEnergies) {
163 fCache.
Get()->remaining_energy = std::max(fCache.
Get()->remaining_energy,
164 theAngular[nDiscreteEnergies-1].GetLabel() );
165 } else {
167 for (
G4int j = nDiscreteEnergies; j < nEnergies; j++) {
168 cont_min = theAngular[j].
GetLabel();
169 if (theAngular[j].GetValue(0) != 0.0 ) break;
170 }
171 fCache.
Get()->remaining_energy =
172 std::max (fCache.
Get()->remaining_energy,
173 std::min(theAngular[nDiscreteEnergies-1].GetLabel(), cont_min) );
174 }
175
178 running[0] = 0.0;
179
181 for (
G4int j = 0; j < nDiscreteEnergies; j++) {
182 delta = 0.0;
183 if (theAngular[j].GetLabel() <= fCache.
Get()->remaining_energy)
185 running[j+1] = running[j] + delta;
186 }
187
188 G4double tot_prob_DIS = std::max( running[nDiscreteEnergies], 0.0 );
189
191 for (
G4int j = nDiscreteEnergies; j < nEnergies; j++) {
192 delta1 = 0.0;
195 if (theAngular[j].GetLabel() <= fCache.
Get()->remaining_energy)
197
198
199
200
201
202
203 if (theAngular[j].GetLabel() != 0) {
204 if (j == nDiscreteEnergies) {
205 e_low = 0.0/eV;
206 } else {
207 if ( j < 1 ) j = 1;
208 e_low = theAngular[j-1].
GetLabel()/eV;
209 }
210 e_high = theAngular[j].
GetLabel()/eV;
211 }
212
213
214
215 if (theAngular[j].GetLabel() == 0.0) {
216 e_low = theAngular[j].
GetLabel()/eV;
217 if (j != nEnergies-1) {
218 e_high = theAngular[j+1].
GetLabel()/eV;
219 } else {
220 e_high = theAngular[j].
GetLabel()/eV;
221 if (theAngular[j].GetValue(0) != 0.0) {
223 "G4ParticleHPContAngularPar: Unexpected non zero value of theAngular[nEnergies-1].GetValue(0)");
224 }
225 }
226 }
227
228 running[j+1] = running[j] + ( ( e_high - e_low ) * delta1);
229 }
230 G4double tot_prob_CON = std::max( running[ nEnergies ] - running[ nDiscreteEnergies ], 0.0 );
231
232
233 if ( tot_prob_DIS == 0.0 && tot_prob_CON == 0.0 ) return result;
234
235
236 random *= (tot_prob_DIS + tot_prob_CON);
237
238
239
240 if (random <= (tot_prob_DIS/(tot_prob_DIS + tot_prob_CON) ) || nDiscreteEnergies == nEnergies) {
241
242 for (
G4int j = 0; j < nDiscreteEnergies; j++) {
243
244 if (random < running[ j+1 ] ) {
245 it = j;
246 break;
247 }
248 }
249 fsEnergy = theAngular[ it ].
GetLabel();
250
252 theStore.Init(0,fsEnergy,nAngularParameters);
253 for (
G4int j = 0; j < nAngularParameters; j++) {
254 theStore.SetCoeff(0,j,theAngular[it].GetValue(j));
255 }
256
257 cosTh = theStore.SampleMax(fsEnergy);
258
259
260 } else {
261
262 for (
G4int j = nDiscreteEnergies; j < nEnergies; j++) {
263
264 if (random < running[ j ] ) {
265 it = j;
266 break;
267 }
268 }
269
270 if ( it < 1 ) it = 1;
271
274
276 if (it != nDiscreteEnergies) y1 = theAngular[it-1].
GetLabel();
278
280 random,x1,x2,y1,y2);
281
283 theStore.Init(0, y1, nAngularParameters);
284 theStore.Init(1, y2, nAngularParameters);
285 theStore.SetManager(theManager);
287 for (
G4int j = 0; j < nAngularParameters; j++) {
288 itt = it;
289 if (it == nDiscreteEnergies) itt = it+1;
290
291 theStore.SetCoeff(0, j, theAngular[itt-1].GetValue(j) );
292 theStore.SetCoeff(1, j, theAngular[itt].GetValue(j) );
293 }
294
295 cosTh = theStore.SampleMax(fsEnergy);
296
297
298 }
299
300
301
302
303 fCache.
Get()->remaining_energy -= fsEnergy;
304 delete[] running;
305
306
307
308 } else {
309
310 if (fCache.
Get()->fresh ==
true) {
311 fCache.
Get()->remaining_energy = theAngular[ nEnergies-1 ].
GetLabel();
312 fCache.
Get()->fresh =
false;
313 }
314
317 running[0] = 0;
319 for (i = 1; i < nEnergies; i++) {
320 running[i]=running[i-1];
321 if (fCache.
Get()->remaining_energy >= theAngular[i].GetLabel() ) {
323 theAngular[i-1].GetLabel(),
324 theAngular[i].GetLabel(),
325 theAngular[i-1].GetValue(0),
326 theAngular[i].GetValue(0) );
328 theAngular[i-1].GetLabel(),
329 theAngular[i].GetLabel(),
330 theAngular[i-1].GetValue(0),
331 theAngular[i].GetValue(0));
332 }
333 }
334
335
336 if (nEnergies == 1 || running[nEnergies-1] == 0) {
337 fCache.
Get()->currentMeanEnergy = 0.0;
338 } else {
339 fCache.
Get()->currentMeanEnergy = weighted/running[nEnergies-1];
340 }
341
342 if (nEnergies == 1) it = 0;
343 if (running[nEnergies-1] != 0) {
344 for (i = 1; i < nEnergies; i++) {
345 it = i;
346 if (random < running [i]/running[nEnergies-1] ) break;
347 }
348 }
349
350 if (running[nEnergies-1] == 0) it = 0;
351 if (it < nDiscreteEnergies || it == 0) {
352 if (it == 0) {
353 fsEnergy = theAngular[it].
GetLabel();
355 theStore.Init(0,fsEnergy,nAngularParameters);
356 for (i = 0; i < nAngularParameters; i++) {
357 theStore.SetCoeff(0, i, theAngular[it].GetValue(i) );
358 }
359
360 cosTh = theStore.SampleMax(fsEnergy);
361
362 } else {
367 random,
368 running[it-1]/running[nEnergies-1],
369 running[it]/running[nEnergies-1],
370 e1, e2);
371
373 theStore.Init(0,e1,nAngularParameters);
374 theStore.Init(1,e2,nAngularParameters);
375 for (i = 0; i < nAngularParameters; i++) {
376 theStore.SetCoeff(0, i, theAngular[it-1].GetValue(i) );
377 theStore.SetCoeff(1, i, theAngular[it].GetValue(i) );
378 }
379
380 theStore.SetManager(theManager);
381 cosTh = theStore.SampleMax(fsEnergy);
382 }
383
384 } else {
385 G4double x1 = running[it-1]/running[nEnergies-1];
386 G4double x2 = running[it]/running[nEnergies-1];
390 random,x1,x2,y1,y2);
392 theStore.Init(0,y1,nAngularParameters);
393 theStore.Init(1,y2,nAngularParameters);
394 theStore.SetManager(theManager);
395 for (i = 0; i < nAngularParameters; i++) {
396 theStore.SetCoeff(0, i, theAngular[it-1].GetValue(i));
397 theStore.SetCoeff(1, i, theAngular[it].GetValue(i));
398 }
399
400 cosTh = theStore.SampleMax(fsEnergy);
401 }
402 delete [] running;
403
404
405
406
407
408 fCache.
Get()->remaining_energy -= fsEnergy;
409
410 }
411
412
413 } else if (angularRep == 2) {
414
417 running[0] = 0;
419 for (j = 1; j < nEnergies; j++) {
420 if (j != 0) running[j] = running[j-1];
422 theAngular[j-1].GetLabel(), theAngular[j].GetLabel(),
423 theAngular[j-1].GetValue(0), theAngular[j].GetValue(0));
425 theAngular[j-1].GetLabel(), theAngular[j].GetLabel(),
426 theAngular[j-1].GetValue(0), theAngular[j].GetValue(0));
427 }
428
429
430 if (nEnergies == 1)
431 fCache.
Get()->currentMeanEnergy = 0.0;
432 else
433 fCache.
Get()->currentMeanEnergy = weighted/running[nEnergies-1];
434
437 for (j = 1; j < nEnergies; j++) {
438 itt = j;
439 if (randkal < running[j]/running[nEnergies-1] ) break;
440 }
441
442
444 if (itt == 0) itt = 1;
445 x = randkal*running[nEnergies-1];
446 x1 = running[itt-1];
447 x2 = running[itt];
449
453 x, x1, x2, y1, y2);
454
455
459 fsEnergy, y1, y2, cLow, cHigh);
460
461 if (compoundFraction > 1.0) compoundFraction = 1.0;
462
463 delete [] running;
464
465
471 G4int targetA =
G4int(fCache.
Get()->theTargetCode-1000*targetZ);
472
473
474 if (targetA == 0)
475 targetA =
G4int ( fCache.
Get()->theTarget->GetMass()/amu_c2 + 0.5 );
476 G4double targetMass = fCache.
Get()->theTarget->GetMass();
477 G4int incidentA=
G4int(incidentMass/amu_c2 + 0.5 );
479 G4int residualA = targetA+incidentA-
A;
480 G4int residualZ = targetZ+incidentZ-
Z;
483 incidentEnergy, incidentMass,
484 productEnergy, productMass,
485 residualMass, residualA, residualZ,
486 targetMass, targetA, targetZ,
487 incidentA,incidentZ,
A,
Z);
488 cosTh = theKallbach.Sample(anEnergy);
489
490
491 } else if (angularRep > 10 && angularRep < 16) {
494 running[0]=0;
496 for (i = 1; i < nEnergies; i++) {
497 if (i != 0) running[i] = running[i-1];
499 theAngular[i-1].GetLabel(), theAngular[i].GetLabel(),
500 theAngular[i-1].GetValue(0), theAngular[i].GetValue(0));
502 theAngular[i-1].GetLabel(), theAngular[i].GetLabel(),
503 theAngular[i-1].GetValue(0), theAngular[i].GetValue(0));
504 }
505
506
507 if (nEnergies == 1)
508 fCache.
Get()->currentMeanEnergy = 0.0;
509 else
510 fCache.
Get()->currentMeanEnergy = weighted/running[nEnergies-1];
511
512 if (nEnergies == 1) it = 0;
513 for (i = 1; i < nEnergies; i++) {
514 it = i;
515 if(random<running[i]/running[nEnergies-1]) break;
516 }
517
518 if (it < nDiscreteEnergies || it == 0) {
519 if (it == 0) {
520 fsEnergy = theAngular[0].
GetLabel();
523 for (
G4int j=1; j<nAngularParameters; j+=2) {
524 theStore.
SetX(aCounter, theAngular[0].GetValue(j));
525 theStore.
SetY(aCounter, theAngular[0].GetValue(j+1));
526 aCounter++;
527 }
529 aMan.
Init(angularRep-10, nAngularParameters-1);
531 cosTh = theStore.
Sample();
532 } else {
533 fsEnergy = theAngular[it].
GetLabel();
536 aMan.
Init(angularRep-10, nAngularParameters-1);
540 for (
G4int j=1; j<nAngularParameters; j+=2) {
541 theStore.
SetX(aCounter, theAngular[it].GetValue(j));
542 theStore.
SetY(aCounter,
544 running[it-1]/running[nEnergies-1],
545 running[it]/running[nEnergies-1],
546 theAngular[it-1].GetValue(j+1),
547 theAngular[it].GetValue(j+1) ) );
548 aCounter++;
549 }
550 cosTh = theStore.
Sample();
551 }
552
553 } else {
554 G4double x1 = running[it-1]/running[nEnergies-1];
555 G4double x2 = running[it]/running[nEnergies-1];
559 random,x1,x2,y1,y2);
563 aMan.
Init(angularRep-10, nAngularParameters-1);
564
566 for (i = 0, j = 1; i < nAngularParameters; i++, j+=2) {
567 theBuff1.
SetX(i, theAngular[it-1].GetValue(j));
568 theBuff1.
SetY(i, theAngular[it-1].GetValue(j+1));
569 theBuff2.
SetX(i, theAngular[it].GetValue(j));
570 theBuff2.
SetY(i, theAngular[it].GetValue(j+1));
571 }
572
575 x1 = y1;
576 x2 = y2;
579 x = theBuff1.
GetX(i);
580 y1 = theBuff1.
GetY(i);
581 y2 = theBuff2.
GetY(i);
583 fsEnergy, theAngular[it-1].GetLabel(),
584 theAngular[it].GetLabel(), y1, y2);
587 }
588 cosTh = theStore.
Sample();
589 }
590 delete [] running;
591
592 } else {
594 "G4ParticleHPContAngularPar::Sample: Unknown angular representation");
595 }
596
602 G4ThreeVector tempVector(mtot*sinth*std::cos(phi), mtot*sinth*std::sin(phi), mtot*std::cos(theta) );
604 return result;
605}
static G4Deuteron * Deuteron()
static G4Electron * Electron()
void Init(G4int aScheme, G4int aRange)
G4InterpolationScheme GetInverseScheme(G4int index)
static G4IonTable * GetIonTable()
static G4Neutron * Neutron()
static G4double GetNuclearMass(const G4double A, const G4double Z)
G4double GetPDGMass() const
G4double GetPDGCharge() const
G4double GetWeightedBinIntegral(const G4InterpolationScheme &aScheme, const G4double x1, const G4double x2, const G4double y1, const G4double y2)
G4double GetBinIntegral(const G4InterpolationScheme &aScheme, const G4double x1, const G4double x2, const G4double y1, const G4double y2)
void SetY(G4int i, G4double x)
void SetX(G4int i, G4double e)
void SetInterpolationManager(const G4InterpolationManager &aManager)
G4double GetY(G4double x)
G4double GetX(G4int i) const
G4int GetVectorLength() const
static G4Positron * Positron()
static G4Proton * Proton()
void SetMomentum(const G4double x, const G4double y, const G4double z)
G4double GetTotalMomentum() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
void SetKineticEnergy(const G4double en)
static G4Triton * Triton()