58 if(aDataFile >> repFlag)
61 aDataFile >> targetMass;
65 aDataFile >> nDiscrete;
66 disType =
new G4int[nDiscrete];
70 for (
G4int i=0; i<nDiscrete; ++i)
72 aDataFile >> disType[i]>>energy[i];
74 theYield[i].
Init(aDataFile, eV);
79 aDataFile >> theInternalConversionFlag;
80 aDataFile >> theBaseEnergy;
82 aDataFile >> theInternalConversionFlag;
83 aDataFile >> nGammaEnergies;
84 theLevelEnergies =
new G4double[nGammaEnergies];
85 theTransitionProbabilities =
new G4double[nGammaEnergies];
86 if(theInternalConversionFlag == 2) thePhotonTransitionFraction =
new G4double[nGammaEnergies];
87 for(
G4int ii=0; ii<nGammaEnergies; ++ii)
89 if(theInternalConversionFlag == 1)
91 aDataFile >> theLevelEnergies[ii] >> theTransitionProbabilities[ii];
92 theLevelEnergies[ii]*=eV;
94 else if(theInternalConversionFlag == 2)
96 aDataFile >> theLevelEnergies[ii] >> theTransitionProbabilities[ii] >> thePhotonTransitionFraction[ii];
97 theLevelEnergies[ii]*=eV;
101 throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist: Unknown conversion flag");
107 G4cout <<
"Data representation in G4ParticleHPPhotonDist: "<<repFlag<<
G4endl;
108 throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist: This data representation is not implemented.");
122 aDataFile >> isoFlag;
125 if (repFlag == 2)
G4cout <<
"G4ParticleHPPhotonDist: repFlag == 2 && isoFlag != 1 is unexpected! If you use G4ND3.x, then please report to Geant4 HyperNews. " <<
G4endl;
126 aDataFile >> tabulationType >> nDiscrete2 >> nIso;
127 if (theGammas != NULL && nDiscrete2 != nDiscrete)
128 G4cout <<
"080731c G4ParticleHPPhotonDist nDiscrete2 != nDiscrete, It looks like something wrong in your NDL files. Please update the latest. If you still have this messages after the update, then please report to Geant4 Hyper News." <<
G4endl;
133 std::vector < G4double > vct_gammas_par;
134 std::vector < G4double > vct_shells_par;
135 std::vector < G4int > vct_primary_par;
136 std::vector < G4int > vct_distype_par;
137 std::vector < G4ParticleHPVector* > vct_pXS_par;
138 if ( theGammas !=
nullptr && theShells !=
nullptr )
141 for ( i = 0 ; i < nDiscrete ; ++i )
143 vct_gammas_par.push_back( theGammas[ i ] );
144 vct_shells_par.push_back( theShells[ i ] );
145 vct_primary_par.push_back( isPrimary[ i ] );
146 vct_distype_par.push_back( disType[ i ] );
148 *hpv = thePartialXsec[ i ];
149 vct_pXS_par.push_back( hpv );
152 if ( theGammas ==
nullptr ) theGammas =
new G4double[nDiscrete2];
153 if ( theShells ==
nullptr ) theShells =
new G4double[nDiscrete2];
155 for (i=0; i< nIso; ++i)
157 aDataFile >> theGammas[i] >> theShells[i];
161 nNeu =
new G4int [nDiscrete2-nIso];
164 for(i=nIso; i< nDiscrete2; ++i)
166 if(tabulationType==1)
168 aDataFile >> theGammas[i] >> theShells[i] >> nNeu[i-nIso];
172 theLegendreManager.
Init(aDataFile);
173 for (ii=0; ii<nNeu[i-nIso]; ++ii)
175 theLegendre[i-nIso][ii].
Init(aDataFile);
178 else if(tabulationType==2)
180 aDataFile >> theGammas[i] >> theShells[i] >> nNeu[i-nIso];
184 for (ii=0; ii<nNeu[i-nIso]; ++ii)
186 theAngular[i-nIso][ii].
Init(aDataFile);
192 throw G4HadronicException(__FILE__, __LINE__,
"cannot deal with this tabulation type for angular distributions.");
196 if ( vct_gammas_par.size() > 0 )
199 for ( i = 0 ; i < nDiscrete ; ++i )
201 for (
G4int j = 0 ; j < nDiscrete ; ++j )
204 if ( theGammas[ i ] == vct_gammas_par [ j ] && theShells [ i ] == vct_shells_par[ j ] )
206 isPrimary [ i ] = vct_primary_par [ j ];
207 disType [ i ] = vct_distype_par [ j ];
208 thePartialXsec[ i ] = ( *( vct_pXS_par[ j ] ) );
213 for (
auto it = vct_pXS_par.cbegin() ; it != vct_pXS_par.cend() ; ++it )
223 G4int i, energyDistributionsNeeded = 0;
224 for (i=0; i<nDiscrete; ++i)
226 if( disType[i]==1) energyDistributionsNeeded =1;
228 if(!energyDistributionsNeeded)
return;
229 aDataFile >> nPartials;
230 distribution =
new G4int[nPartials];
235 for (i=0; i<nPartials; ++i)
238 probs[i].
Init(aDataFile, eV);
242 partials[i]->
Init(aDataFile);
249 if (theXsec) theReactionXsec = theXsec;
251 aDataFile >> nDiscrete >> targetMass;
254 theTotalXsec.
Init(aDataFile, eV);
257 theGammas =
new G4double[nDiscrete];
258 theShells =
new G4double[nDiscrete];
259 isPrimary =
new G4int[nDiscrete];
260 disType =
new G4int[nDiscrete];
262 for(i=0; i<nDiscrete; ++i)
264 aDataFile>>theGammas[i]>>theShells[i]>>isPrimary[i]>>disType[i];
267 thePartialXsec[i].
Init(aDataFile, eV);
274 if ( actualMult.
Get() ==
nullptr ) {
275 actualMult.
Get() =
new std::vector<G4int>( nDiscrete );
278 G4int nSecondaries = 0;
283 for (i = 0; i < nDiscrete; ++i) {
284 current = theYield[i].
GetY(anEnergy);
286 if (nDiscrete == 1 && current < 1.0001) {
287 actualMult.
Get()->at(i) =
static_cast<G4int>(current);
290 actualMult.
Get()->at(i) = 0;
294 nSecondaries += actualMult.
Get()->at(i);
296 for (i = 0; i < nSecondaries; ++i) {
299 thePhotons->push_back(theOne);
304 if (nDiscrete == 1 && nPartials == 1) {
305 if (actualMult.
Get()->at(0) > 0) {
306 if (disType[0] == 1) {
309 temp = partials[ 0 ]->
GetY(anEnergy);
312 std::vector< G4double > photons_e_best( actualMult.
Get()->at(0) , 0.0 );
315 for (
G4int j = 0; j < maxTry; ++j) {
316 std::vector<G4double> photons_e(actualMult.
Get()->at(0), 0.0);
317 for (
auto it = photons_e.begin(); it < photons_e.end(); ++it) {
321 if (std::accumulate(photons_e.cbegin(), photons_e.cend(), 0.0) > maximumE) {
322 if (std::accumulate(photons_e.cbegin(), photons_e.cend(), 0.0) < best)
323 photons_e_best = photons_e;
328 for (
auto it = photons_e.cbegin(); it < photons_e.cend(); ++it) {
329 thePhotons->operator[](iphot)->SetKineticEnergy(*it);
342 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
345 if (count > nSecondaries)
346 throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist::GetPhotons inconsistency");
350 for (i=0; i<nDiscrete; ++i) {
351 for (ii=0; ii< actualMult.
Get()->at(i); ++ii) {
352 if (disType[i] == 1) {
355 for (iii = 0; iii < nPartials; ++iii)
356 sum+=probs[iii].GetY(anEnergy);
359 for (iii = 0; iii < nPartials; ++iii) {
360 run+=probs[iii].
GetY(anEnergy);
362 if(random<run/sum)
break;
365 if (theP == nPartials) theP=nPartials-1;
368 temp = partials[theP]->
GetY(anEnergy);
370 thePhotons->operator[](count)->SetKineticEnergy(eGamm);
375 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
378 if (count > nSecondaries)
379 throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist::GetPhotons inconsistency");
386 for (i=0; i< nSecondaries; ++i)
389 G4double theta = std::acos(costheta);
392 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
393 G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
394 thePhotons->operator[](i)->SetMomentum( temp ) ;
399 for(i=0; i<nSecondaries; ++i)
401 G4double currentEnergy = thePhotons->operator[](i)->GetTotalEnergy();
402 for(ii=0; ii<nDiscrete2; ++ii)
404 if (std::abs(currentEnergy-theGammas[ii])<0.1*keV)
break;
406 if(ii==nDiscrete2) --ii;
414 G4double theta = std::acos(costheta);
417 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
419 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costheta );
420 thePhotons->operator[](i)->SetMomentum( tempVector ) ;
422 else if(tabulationType==1)
426 for (iii=0; iii<nNeu[ii-nIso]; ++iii)
429 if(theLegendre[ii-nIso][iii].GetEnergy()>anEnergy)
433 aStore.
SetCoeff(1, &(theLegendre[ii-nIso][it]));
436 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][it-1]));
440 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][it]));
446 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
447 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
448 thePhotons->operator[](i)->SetMomentum( tempVector ) ;
454 for (iii=0; iii<nNeu[ii-nIso]; ++iii)
457 if(theAngular[ii-nIso][iii].GetEnergy()>anEnergy)
464 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
465 G4ThreeVector tmpVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costh );
466 thePhotons->operator[](i)->SetMomentum( tmpVector ) ;
471 }
else if (repFlag == 2) {
473 running[0]=theTransitionProbabilities[0];
474 for(i=1; i<nGammaEnergies; ++i)
476 running[i]=running[i-1]+theTransitionProbabilities[i];
480 for(i=0; i<nGammaEnergies; ++i)
483 if(random < running[i]/running[nGammaEnergies-1])
break;
486 G4double totalEnergy = theBaseEnergy - theLevelEnergies[it];
490 if(theInternalConversionFlag==2 && random>thePhotonTransitionFraction[it])
501 G4double theta = std::acos(costheta);
508 G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
514 for(ii=0; ii<nDiscrete2; ++ii)
516 if (std::abs(currentEnergy-theGammas[ii])<0.1*keV)
break;
518 if(ii==nDiscrete2) --ii;
532 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
535 else if(tabulationType==1)
539 for (iii=0; iii<nNeu[ii-nIso]; ++iii)
542 if(theLegendre[ii-nIso][iii].GetEnergy()>anEnergy)
546 aStore.
SetCoeff(1, &(theLegendre[ii-nIso][itt]));
551 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][itt-1]));
555 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][itt]));
565 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
572 for (iii=0; iii<nNeu[ii-nIso]; ++iii)
575 if(theAngular[ii-nIso][iii].GetEnergy()>anEnergy)
586 G4ThreeVector tmpVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costh );
590 thePhotons->push_back(theOne);
592 else if( repFlag==0 )
594 if ( thePartialXsec == 0 )
603 thePhotons->push_back( theOne );
608 std::vector < G4double > dif( nDiscrete , 0.0 );
609 for (
G4int j = 0 ; j < nDiscrete ; ++j )
622 for (
G4int j = 0 ; j < nDiscrete ; ++j )
634 if (theReactionXsec) {
635 if (thePartialXsec[iphoton].GetXsec(anEnergy)/theReactionXsec->
GetXsec(anEnergy) <
G4UniformRand() ) {
637 thePhotons =
nullptr;
653 if ( iphoton < nIso )
661 if ( tabulationType == 1 )
666 for (
G4int j = 0 ; j < nNeu [ iphoton - nIso ] ; ++j )
669 if ( theLegendre[ iphoton - nIso ][ j ].GetEnergy() > anEnergy )
break;
673 aStore.
SetCoeff( 1 , &( theLegendre[ iphoton - nIso ][ iangle ] ) );
674 aStore.
SetCoeff( 0 , &( theLegendre[ iphoton - nIso ][ iangle - 1 ] ) );
678 else if ( tabulationType == 2 )
683 for (
G4int j = 0 ; j < nNeu [ iphoton - nIso ] ; ++j )
686 if ( theAngular[ iphoton - nIso ][ j ].GetEnergy() > anEnergy )
break;
688 cosTheta = theAngular[iphoton-nIso][ iangle ].
GetCosTh();
696 G4double theta = std::acos( cosTheta );
697 G4double sinTheta = std::sin( theta );
699 G4double photonE = theGammas[ iphoton ];
700 G4ThreeVector direction ( sinTheta*std::cos( phi ) , sinTheta * std::sin( phi ) , cosTheta );
702 thePhotons->operator[]( 0 )->SetMomentum( photonP ) ;
707 thePhotons =
nullptr;
G4long G4Poisson(G4double mean)
std::vector< G4ReactionProduct * > G4ReactionProductVector
G4GLOB_DLL std::ostream G4cout
static G4Electron * Electron()
void Init(G4int aScheme, G4int aRange)
G4double GetPDGMass() const
G4double GetCosTh(G4int l)
void Init(std::istream &aDataFile)
void SetCoeff(G4int i, G4int l, G4double coeff)
G4double SampleMax(G4double energy)
void Init(std::istream &aDataFile)
void Init(std::istream &aDataFile)
G4double GetY(G4int i, G4int j)
void InitInterpolation(G4int i, std::istream &aDataFile)
void InitEnergies(std::istream &aDataFile)
G4ReactionProductVector * GetPhotons(G4double anEnergy)
void InitAngular(std::istream &aDataFile)
void InitPartials(std::istream &aDataFile, G4ParticleHPVector *theXsec=0)
G4bool InitMean(std::istream &aDataFile)
G4double GetXsec(G4int i)
G4double GetY(G4double x)
G4double GetX(G4int i) const
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
G4int GetVectorLength() const
void SetMomentum(const G4double x, const G4double y, const G4double z)
void SetTotalEnergy(const G4double en)
G4double GetTotalMomentum() const
G4double GetTotalEnergy() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)