60 aDataFile >> theEnergy >> nEnergies >> nDiscreteEnergies >> nAngularParameters;
63 for(
G4int i=0; i<nEnergies; i++)
69 theAngular[i].
Init(aDataFile, nAngularParameters, 1.);
106 if(Z!=2)
throw G4HadronicException(__FILE__, __LINE__,
"G4NeutronHPContAngularPar: Unknown ion case 1");
117 if( angularRep == 1 )
123 if ( nDiscreteEnergies != 0 )
132 remaining_energy = std::max ( theAngular[0].GetLabel() , theAngular[nEnergies-1].GetLabel() );
138 if ( nDiscreteEnergies == nEnergies )
140 remaining_energy = std::max ( remaining_energy , theAngular[nDiscreteEnergies-1].GetLabel() );
147 for (
G4int j = nDiscreteEnergies ; j < nEnergies ; j++ )
149 cont_min = theAngular[j].
GetLabel();
150 if ( theAngular[j].GetValue(0) != 0.0 )
break;
152 remaining_energy = std::max ( remaining_energy , std::min ( theAngular[nDiscreteEnergies-1].GetLabel() , cont_min ) );
160 for (
G4int j = 0 ; j < nDiscreteEnergies ; j++ )
163 if ( theAngular[j].GetLabel() <= remaining_energy ) delta = theAngular[i].
GetValue(0);
164 running[j+1] = running[j] + delta;
166 G4double tot_prob_DIS = running[ nDiscreteEnergies ];
168 for (
G4int j = nDiscreteEnergies ; j < nEnergies ; j++ )
173 if ( theAngular[j].GetLabel() <= remaining_energy ) delta = theAngular[j].
GetValue(0);
180 if ( theAngular[j].GetLabel() != 0 )
182 if ( j == nDiscreteEnergies ) {
185 e_low = theAngular[j-1].
GetLabel()/eV;
187 e_high = theAngular[j].
GetLabel()/eV;
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;
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)");
203 running[j+1] = running[j] + ( ( e_high - e_low ) * delta );
205 G4double tot_prob_CON = running[ nEnergies ] - running[ nDiscreteEnergies ];
219 random *= (tot_prob_DIS + tot_prob_CON);
221 if ( random <= ( tot_prob_DIS / ( tot_prob_DIS + tot_prob_CON ) ) || nDiscreteEnergies == nEnergies )
224 for (
G4int j = 0 ; j < nDiscreteEnergies ; j++ )
227 if ( random < running[ j+1 ] )
233 fsEnergy = theAngular[ it ].
GetLabel();
236 theStore.
Init(0,fsEnergy,nAngularParameters);
237 for (
G4int j=0;j<nAngularParameters;j++)
239 theStore.
SetCoeff(0,j,theAngular[it].GetValue(j));
248 for (
G4int j = nDiscreteEnergies ; j < nEnergies ; j++ )
251 if ( random < running[ j ] )
262 if ( it != nDiscreteEnergies )
270 theStore.
Init(0,y1,nAngularParameters);
271 theStore.
Init(1,y2,nAngularParameters);
273 for (
G4int j=0;j<nAngularParameters;j++)
276 if ( it == nDiscreteEnergies ) itt = it+1;
283 theStore.
SetCoeff(0,j,theAngular[itt-1].GetValue(j));
284 theStore.
SetCoeff(1,j,theAngular[itt].GetValue(j));
293 remaining_energy -= fsEnergy;
307 remaining_energy = theAngular[ nEnergies-1 ].
GetLabel();
315 for(i=1; i<nEnergies; i++)
330 running[i]=running[i-1];
331 if ( remaining_energy >= theAngular[i].GetLabel() )
343 if ( nEnergies == 1 || running[nEnergies-1] == 0 )
344 currentMeanEnergy = 0.0;
347 currentMeanEnergy = weighted/running[nEnergies-1];
351 if ( nEnergies == 1 ) it = 0;
354 if ( running[nEnergies-1] != 0 )
356 for ( i = 1 ; i < nEnergies ; i++ )
359 if ( random < running [ i ] / running [ nEnergies-1 ] )
break;
364 if ( running [ nEnergies-1 ] == 0 ) it = 0;
367 if (it<nDiscreteEnergies||it==0)
371 fsEnergy = theAngular[it].
GetLabel();
373 theStore.
Init(0,fsEnergy,nAngularParameters);
374 for(i=0;i<nAngularParameters;i++)
376 theStore.
SetCoeff(0,i,theAngular[it].GetValue(i));
388 running[it-1]/running[nEnergies-1],
389 running[it]/running[nEnergies-1],
393 theStore.
Init(0,e1,nAngularParameters);
394 theStore.
Init(1,e2,nAngularParameters);
395 for(i=0;i<nAngularParameters;i++)
397 theStore.
SetCoeff(0,i,theAngular[it-1].GetValue(i));
398 theStore.
SetCoeff(1,i,theAngular[it].GetValue(i));
407 G4double x1 = running[it-1]/running[nEnergies-1];
408 G4double x2 = running[it]/running[nEnergies-1];
414 theStore.
Init(0,y1,nAngularParameters);
415 theStore.
Init(1,y2,nAngularParameters);
417 for(i=0;i<nAngularParameters;i++)
419 theStore.
SetCoeff(0,i,theAngular[it-1].GetValue(i));
420 theStore.
SetCoeff(1,i,theAngular[it].GetValue(i));
428 remaining_energy -= fsEnergy;
432 else if(angularRep==2)
439 for(j=1; j<nEnergies; j++)
441 if(j!=0) running[j]=running[j-1];
452 if ( nEnergies == 1 )
453 currentMeanEnergy = 0.0;
455 currentMeanEnergy = weighted/running[nEnergies-1];
461 for(j=1; j<nEnergies; j++)
464 if(randkal<running[j]/running[nEnergies-1])
break;
470 x = randkal*running[nEnergies-1];
483 fsEnergy, y1, y2, cLow,cHigh);
492 G4int targetA =
G4int(theTargetCode-1000*targetZ);
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);
509 else if(angularRep>10&&angularRep<16)
515 for(i=1; i<nEnergies; i++)
517 if(i!=0) running[i]=running[i-1];
527 if ( nEnergies == 1 )
528 currentMeanEnergy = 0.0;
530 currentMeanEnergy = weighted/running[nEnergies-1];
533 if ( nEnergies == 1 ) it = 0;
535 for(i=1; i<nEnergies; i++)
538 if(random<running[i]/running[nEnergies-1])
break;
540 if(it<nDiscreteEnergies||it==0)
544 fsEnergy = theAngular[0].
GetLabel();
547 for(
G4int j=1; j<nAngularParameters; j+=2)
549 theStore.
SetX(aCounter, theAngular[0].GetValue(j));
550 theStore.
SetY(aCounter, theAngular[0].GetValue(j+1));
554 aMan.
Init(angularRep-10, nAngularParameters-1);
556 cosTh = theStore.
Sample();
560 fsEnergy = theAngular[it].
GetLabel();
563 aMan.
Init(angularRep-10, nAngularParameters-1);
567 for(
G4int j=1; j<nAngularParameters; j+=2)
569 theStore.
SetX(aCounter, theAngular[it].GetValue(j));
572 running[it-1]/running[nEnergies-1],
573 running[it]/running[nEnergies-1],
578 cosTh = theStore.
Sample();
583 G4double x1 = running[it-1]/running[nEnergies-1];
584 G4double x2 = running[it]/running[nEnergies-1];
592 aMan.
Init(angularRep-10, nAngularParameters-1);
606 for(i=0,j=1; i<nAngularParameters; i++,j+=2)
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));
622 x = theBuff1.
GetX(i);
623 y1 = theBuff1.
GetY(i);
624 y2 = theBuff2.
GetY(i);
626 fsEnergy, theAngular[it-1].
GetLabel(),
631 cosTh = theStore.
Sample();
637 throw G4HadronicException(__FILE__, __LINE__,
"G4NeutronHPContAngularPar::Sample: Unknown angular representation");
644 G4ThreeVector tempVector(mtot*sinth*std::cos(phi), mtot*sinth*std::sin(phi), mtot*std::cos(theta) );
static G4Deuteron * Deuteron()
static G4Electron * Electron()
void Init(G4int aScheme, G4int aRange)
G4InterpolationScheme GetScheme(G4int index) const
G4InterpolationScheme GetInverseScheme(G4int index)
G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass, G4int angularRep, G4int interpol)
void Init(std::ifstream &aDataFile)
G4double GetWeightedBinIntegral(const G4InterpolationScheme &aScheme, const G4double x1, const G4double x2, const G4double y1, const G4double y2)
G4double Interpolate(G4InterpolationScheme aScheme, G4double x, G4double x1, G4double x2, G4double y1, G4double y2) const
G4double GetBinIntegral(const G4InterpolationScheme &aScheme, const G4double x1, const G4double x2, const G4double y1, const G4double y2)
G4double Sample(G4double anEnergy)
void SetCoeff(G4int i, G4int l, G4double coeff)
G4double SampleMax(G4double energy)
void SetManager(G4InterpolationManager &aManager)
void Init(G4int i, G4double e, G4int n)
void SetLabel(G4double aLabel)
void Init(std::ifstream &aDataFile, G4int nPar, G4double unit=1.)
G4double GetValue(G4int i)
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()