76 {
80 if(massCode==0)
81 {
83 }
84 else if(A==0)
85 {
88 }
89 else if(A==1)
90 {
93 }
94 else if(A==2)
95 {
97 }
98 else if(A==3)
99 {
102 }
103 else if(A==4)
104 {
106 if(Z!=2)
throw G4HadronicException(__FILE__, __LINE__,
"G4NeutronHPContAngularPar: Unknown ion case 1");
107 }
108 else
109 {
111 }
116
117 if( angularRep == 1 )
118 {
119
120
121
122
123 if ( nDiscreteEnergies != 0 )
124 {
125
126
127
128 if ( fresh == true )
129 {
130
131
132 remaining_energy = std::max ( theAngular[0].GetLabel() , theAngular[nEnergies-1].GetLabel() );
133 fresh = false;
134 }
135
136
137
138 if ( nDiscreteEnergies == nEnergies )
139 {
140 remaining_energy = std::max ( remaining_energy , theAngular[nDiscreteEnergies-1].GetLabel() );
141 }
142 else
143 {
144
145
147 for (
G4int j = nDiscreteEnergies ; j < nEnergies ; j++ )
148 {
149 cont_min = theAngular[j].
GetLabel();
150 if ( theAngular[j].GetValue(0) != 0.0 ) break;
151 }
152 remaining_energy = std::max ( remaining_energy , std::min ( theAngular[nDiscreteEnergies-1].GetLabel() , cont_min ) );
153 }
154
156
158 running[0] = 0.0;
159
160 for (
G4int j = 0 ; j < nDiscreteEnergies ; j++ )
161 {
163 if ( theAngular[j].GetLabel() <= remaining_energy ) delta = theAngular[i].
GetValue(0);
164 running[j+1] = running[j] + delta;
165 }
166 G4double tot_prob_DIS = running[ nDiscreteEnergies ];
167
168 for (
G4int j = nDiscreteEnergies ; j < nEnergies ; j++ )
169 {
173 if ( theAngular[j].GetLabel() <= remaining_energy ) delta = theAngular[j].
GetValue(0);
174
175
176
177
178
179
180 if ( theAngular[j].GetLabel() != 0 )
181 {
182 if ( j == nDiscreteEnergies ) {
183 e_low = 0.0/eV;
184 } else {
185 e_low = theAngular[j-1].
GetLabel()/eV;
186 }
187 e_high = theAngular[j].
GetLabel()/eV;
188 }
189
190
191 if ( theAngular[j].GetLabel() == 0.0 ) {
192 e_low = theAngular[j].
GetLabel()/eV;
193 if ( j != nEnergies-1 ) {
194 e_high = theAngular[j+1].
GetLabel()/eV;
195 } else {
196 e_high = theAngular[j].
GetLabel()/eV;
197 if ( theAngular[j].GetValue(0) != 0.0 ) {
198 throw G4HadronicException(__FILE__, __LINE__,
"G4NeutronHPContAngularPar: Unexpected non zero value of theAngular[nEnergies-1].GetValue(0)");
199 }
200 }
201 }
202
203 running[j+1] = running[j] + ( ( e_high - e_low ) * delta );
204 }
205 G4double tot_prob_CON = running[ nEnergies ] - running[ nDiscreteEnergies ];
206
207
208
209
210
211
212
213
214
215
216
217
218
219 random *= (tot_prob_DIS + tot_prob_CON);
220
221 if ( random <= ( tot_prob_DIS / ( tot_prob_DIS + tot_prob_CON ) ) || nDiscreteEnergies == nEnergies )
222 {
223
224 for (
G4int j = 0 ; j < nDiscreteEnergies ; j++ )
225 {
226
227 if ( random < running[ j+1 ] )
228 {
229 it = j;
230 break;
231 }
232 }
233 fsEnergy = theAngular[ it ].
GetLabel();
234
236 theStore.Init(0,fsEnergy,nAngularParameters);
237 for (
G4int j=0;j<nAngularParameters;j++)
238 {
239 theStore.SetCoeff(0,j,theAngular[it].GetValue(j));
240 }
241
242 cosTh = theStore.SampleMax(fsEnergy);
243
244 }
245 else
246 {
247
248 for (
G4int j = nDiscreteEnergies ; j < nEnergies ; j++ )
249 {
250
251 if ( random < running[ j ] )
252 {
253 it = j;
254 break;
255 }
256 }
257
260
262 if ( it != nDiscreteEnergies )
265
267 random,x1,x2,y1,y2);
268
270 theStore.Init(0,y1,nAngularParameters);
271 theStore.Init(1,y2,nAngularParameters);
272 theStore.SetManager(theManager);
273 for (
G4int j=0;j<nAngularParameters;j++)
274 {
276 if ( it == nDiscreteEnergies ) itt = it+1;
277 if ( it == 0 )
278 {
279
280
281 itt = it+1;
282 }
283 theStore.SetCoeff(0,j,theAngular[itt-1].GetValue(j));
284 theStore.SetCoeff(1,j,theAngular[itt].GetValue(j));
285 }
286
287 cosTh = theStore.SampleMax(fsEnergy);
288
289
290 }
291
292
293 remaining_energy -= fsEnergy;
294
295
296
297 delete[] running;
298
299 }
300 else
301 {
302
303
304
305 if ( fresh == true )
306 {
307 remaining_energy = theAngular[ nEnergies-1 ].
GetLabel();
308 fresh = false;
309 }
310
313 running[0]=0;
315 for(i=1; i<nEnergies; i++)
316 {
317
318
319
320
321
322
323
324
325
326
327
328
329
330 running[i]=running[i-1];
331 if ( remaining_energy >= theAngular[i].GetLabel() )
332 {
334 theAngular[i-1].GetLabel(), theAngular[i].GetLabel(),
335 theAngular[i-1].GetValue(0), theAngular[i].GetValue(0));
337 theAngular[i-1].GetLabel(), theAngular[i].GetLabel(),
338 theAngular[i-1].GetValue(0), theAngular[i].GetValue(0));
339 }
340 }
341
342
343 if ( nEnergies == 1 || running[nEnergies-1] == 0 )
344 currentMeanEnergy = 0.0;
345 else
346 {
347 currentMeanEnergy = weighted/running[nEnergies-1];
348 }
349
350
351 if ( nEnergies == 1 ) it = 0;
352
353
354 if ( running[nEnergies-1] != 0 )
355 {
356 for ( i = 1 ; i < nEnergies ; i++ )
357 {
358 it = i;
359 if ( random < running [ i ] / running [ nEnergies-1 ] ) break;
360 }
361 }
362
363
364 if ( running [ nEnergies-1 ] == 0 ) it = 0;
365
366
367 if (it<nDiscreteEnergies||it==0)
368 {
369 if(it == 0)
370 {
371 fsEnergy = theAngular[it].
GetLabel();
373 theStore.Init(0,fsEnergy,nAngularParameters);
374 for(i=0;i<nAngularParameters;i++)
375 {
376 theStore.SetCoeff(0,i,theAngular[it].GetValue(i));
377 }
378
379 cosTh = theStore.SampleMax(fsEnergy);
380 }
381 else
382 {
387 random,
388 running[it-1]/running[nEnergies-1],
389 running[it]/running[nEnergies-1],
390 e1, e2);
391
393 theStore.Init(0,e1,nAngularParameters);
394 theStore.Init(1,e2,nAngularParameters);
395 for(i=0;i<nAngularParameters;i++)
396 {
397 theStore.SetCoeff(0,i,theAngular[it-1].GetValue(i));
398 theStore.SetCoeff(1,i,theAngular[it].GetValue(i));
399 }
400
401 theStore.SetManager(theManager);
402 cosTh = theStore.SampleMax(fsEnergy);
403 }
404 }
405 else
406 {
407 G4double x1 = running[it-1]/running[nEnergies-1];
408 G4double x2 = running[it]/running[nEnergies-1];
412 random,x1,x2,y1,y2);
414 theStore.Init(0,y1,nAngularParameters);
415 theStore.Init(1,y2,nAngularParameters);
416 theStore.SetManager(theManager);
417 for(i=0;i<nAngularParameters;i++)
418 {
419 theStore.SetCoeff(0,i,theAngular[it-1].GetValue(i));
420 theStore.SetCoeff(1,i,theAngular[it].GetValue(i));
421 }
422
423 cosTh = theStore.SampleMax(fsEnergy);
424 }
425 delete [] running;
426
427
428 remaining_energy -= fsEnergy;
429
430 }
431 }
432 else if(angularRep==2)
433 {
434
437 running[0]=0;
439 for(j=1; j<nEnergies; j++)
440 {
441 if(j!=0) running[j]=running[j-1];
443 theAngular[j-1].GetLabel(), theAngular[j].GetLabel(),
444 theAngular[j-1].GetValue(0), theAngular[j].GetValue(0));
446 theAngular[j-1].GetLabel(), theAngular[j].GetLabel(),
447 theAngular[j-1].GetValue(0), theAngular[j].GetValue(0));
448 }
449
450
451
452 if ( nEnergies == 1 )
453 currentMeanEnergy = 0.0;
454 else
455 currentMeanEnergy = weighted/running[nEnergies-1];
456
459
460
461 for(j=1; j<nEnergies; j++)
462 {
463 itt = j;
464 if(randkal<running[j]/running[nEnergies-1]) break;
465 }
466
467
469 if(itt==0) itt=1;
470 x = randkal*running[nEnergies-1];
471 x1 = running[itt-1];
472 x2 = running[itt];
474
478 x, x1,x2,y1,y2);
479
483 fsEnergy, y1, y2, cLow,cHigh);
484 delete [] running;
485
486
492 G4int targetA =
G4int(theTargetCode-1000*targetZ);
493
494 if ( targetA == 0 )
497 G4int residualA = targetA+1-A;
498 G4int residualZ = targetZ-Z;
503 incidentEnergy, incidentMass,
504 productEnergy, productMass,
505 residualMass, residualA, residualZ,
506 targetMass, targetA, targetZ);
507 cosTh = theKallbach.Sample(anEnergy);
508 }
509 else if(angularRep>10&&angularRep<16)
510 {
513 running[0]=0;
515 for(i=1; i<nEnergies; i++)
516 {
517 if(i!=0) running[i]=running[i-1];
519 theAngular[i-1].GetLabel(), theAngular[i].GetLabel(),
520 theAngular[i-1].GetValue(0), theAngular[i].GetValue(0));
522 theAngular[i-1].GetLabel(), theAngular[i].GetLabel(),
523 theAngular[i-1].GetValue(0), theAngular[i].GetValue(0));
524 }
525
526
527 if ( nEnergies == 1 )
528 currentMeanEnergy = 0.0;
529 else
530 currentMeanEnergy = weighted/running[nEnergies-1];
531
532
533 if ( nEnergies == 1 ) it = 0;
534
535 for(i=1; i<nEnergies; i++)
536 {
537 it = i;
538 if(random<running[i]/running[nEnergies-1]) break;
539 }
540 if(it<nDiscreteEnergies||it==0)
541 {
542 if(it==0)
543 {
544 fsEnergy = theAngular[0].
GetLabel();
547 for(
G4int j=1; j<nAngularParameters; j+=2)
548 {
549 theStore.
SetX(aCounter, theAngular[0].GetValue(j));
550 theStore.
SetY(aCounter, theAngular[0].GetValue(j+1));
551 aCounter++;
552 }
554 aMan.
Init(angularRep-10, nAngularParameters-1);
556 cosTh = theStore.
Sample();
557 }
558 else
559 {
560 fsEnergy = theAngular[it].
GetLabel();
563 aMan.
Init(angularRep-10, nAngularParameters-1);
567 for(
G4int j=1; j<nAngularParameters; j+=2)
568 {
569 theStore.
SetX(aCounter, theAngular[it].GetValue(j));
571 random,
572 running[it-1]/running[nEnergies-1],
573 running[it]/running[nEnergies-1],
574 theAngular[it-1].GetValue(j+1),
575 theAngular[it].GetValue(j+1)));
576 aCounter++;
577 }
578 cosTh = theStore.
Sample();
579 }
580 }
581 else
582 {
583 G4double x1 = running[it-1]/running[nEnergies-1];
584 G4double x2 = running[it]/running[nEnergies-1];
588 random,x1,x2,y1,y2);
592 aMan.
Init(angularRep-10, nAngularParameters-1);
593
594
595
596
597
598
599
600
601
602
603
604 {
606 for(i=0,j=1; i<nAngularParameters; i++,j+=2)
607 {
608 theBuff1.
SetX(i, theAngular[it-1].GetValue(j));
609 theBuff1.
SetY(i, theAngular[it-1].GetValue(j+1));
610 theBuff2.
SetX(i, theAngular[it].GetValue(j));
611 theBuff2.
SetY(i, theAngular[it].GetValue(j+1));
612 }
613 }
616 x1 = y1;
617 x2 = y2;
619
621 {
622 x = theBuff1.
GetX(i);
623 y1 = theBuff1.
GetY(i);
624 y2 = theBuff2.
GetY(i);
626 fsEnergy, theAngular[it-1].GetLabel(),
627 theAngular[it].GetLabel(), y1, y2);
630 }
631 cosTh = theStore.
Sample();
632 }
633 delete [] running;
634 }
635 else
636 {
637 throw G4HadronicException(__FILE__, __LINE__,
"G4NeutronHPContAngularPar::Sample: Unknown angular representation");
638 }
644 G4ThreeVector tempVector(mtot*sinth*std::cos(phi), mtot*sinth*std::sin(phi), mtot*std::cos(theta) );
646
647 return result;
648 }
static G4Deuteron * Deuteron()
static G4Electron * Electron()
void Init(G4int aScheme, G4int aRange)
G4InterpolationScheme GetScheme(G4int index) const
G4InterpolationScheme GetInverseScheme(G4int index)
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 SetX(G4int i, G4double e)
G4int GetVectorLength() const
G4double GetX(G4int i) const
G4double GetY(G4double x)
void SetInterpolationManager(const G4InterpolationManager &aManager)
void SetY(G4int i, G4double x)
static G4Neutron * Neutron()
static G4double GetBindingEnergy(const G4int A, const G4int Z)
G4double GetPDGMass() const
static G4ParticleTable * GetParticleTable()
static G4Positron * Positron()
static G4Proton * Proton()
void SetMomentum(const G4double x, const G4double y, const G4double z)
G4double GetTotalMomentum() const
void SetKineticEnergy(const G4double en)
void SetDefinition(G4ParticleDefinition *aParticleDefinition)
static G4Triton * Triton()