59 if(aDataFile >> repFlag)
62 aDataFile >> targetMass;
66 aDataFile >> nDiscrete;
67 disType =
new G4int[nDiscrete];
71 for (
G4int i=0; i<nDiscrete; i++)
73 aDataFile >> disType[i]>>energy[i];
75 theYield[i].
Init(aDataFile,
eV);
80 aDataFile >> theInternalConversionFlag;
81 aDataFile >> theBaseEnergy;
83 aDataFile >> theInternalConversionFlag;
85 aDataFile >> nGammaEnergies;
86 theLevelEnergies =
new G4double[nGammaEnergies];
87 theTransitionProbabilities =
new G4double[nGammaEnergies];
88 if(theInternalConversionFlag == 2) thePhotonTransitionFraction =
new G4double[nGammaEnergies];
89 for(
G4int ii=0; ii<nGammaEnergies; ii++)
91 if(theInternalConversionFlag == 1)
93 aDataFile >> theLevelEnergies[ii] >> theTransitionProbabilities[ii];
94 theLevelEnergies[ii]*=
eV;
96 else if(theInternalConversionFlag == 2)
98 aDataFile >> theLevelEnergies[ii] >> theTransitionProbabilities[ii] >> thePhotonTransitionFraction[ii];
99 theLevelEnergies[ii]*=
eV;
103 throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist: Unknown conversion flag");
111 G4cout <<
"Data representation in G4ParticleHPPhotonDist: "<<repFlag<<
G4endl;
112 throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist: This data representation is not implemented.");
127 aDataFile >> isoFlag;
130 if ( repFlag == 2 )
G4cout <<
"G4ParticleHPPhotonDist: repFlag == 2 && isoFlag != 1 is unexpected! If you use G4ND3.x, then please report to Geant4 Hyper News. Thanks." <<
G4endl;
131 aDataFile >> tabulationType >> nDiscrete2 >> nIso;
133 if ( theGammas != NULL && nDiscrete2 != nDiscrete )
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;
136 std::vector < G4double > vct_gammas_par;
137 std::vector < G4double > vct_shells_par;
138 std::vector < G4int > vct_primary_par;
139 std::vector < G4int > vct_distype_par;
140 std::vector < G4ParticleHPVector* > vct_pXS_par;
141 if ( theGammas != NULL && theShells != NULL )
144 for ( i = 0 ; i < nDiscrete ; i++ )
146 vct_gammas_par.push_back( theGammas[ i ] );
147 vct_shells_par.push_back( theShells[ i ] );
148 vct_primary_par.push_back( isPrimary[ i ] );
149 vct_distype_par.push_back( disType[ i ] );
151 *hpv = thePartialXsec[ i ];
152 vct_pXS_par.push_back( hpv );
155 if ( theGammas == NULL ) theGammas =
new G4double[nDiscrete2];
156 if ( theShells == NULL ) theShells =
new G4double[nDiscrete2];
159 for (i=0; i< nIso; i++)
161 aDataFile >> theGammas[i] >> theShells[i];
165 nNeu =
new G4int [nDiscrete2-nIso];
168 for(i=nIso; i< nDiscrete2; i++)
170 if(tabulationType==1)
172 aDataFile >> theGammas[i] >> theShells[i] >> nNeu[i-nIso];
176 theLegendreManager.
Init(aDataFile);
177 for (ii=0; ii<nNeu[i-nIso]; ii++)
179 theLegendre[i-nIso][ii].
Init(aDataFile);
182 else if(tabulationType==2)
184 aDataFile >> theGammas[i] >> theShells[i] >> nNeu[i-nIso];
188 for (ii=0; ii<nNeu[i-nIso]; ii++)
190 theAngular[i-nIso][ii].
Init(aDataFile);
196 throw G4HadronicException(__FILE__, __LINE__,
"cannot deal with this tabulation type for angular distributions.");
200 if ( vct_gammas_par.size() > 0 )
203 for ( i = 0 ; i < nDiscrete ; i++ )
205 for (
G4int j = 0 ; j < nDiscrete ; j++ )
208 if ( theGammas[ i ] == vct_gammas_par [ j ] && theShells [ i ] == vct_shells_par[ j ] )
210 isPrimary [ i ] = vct_primary_par [ j ];
211 disType [ i ] = vct_distype_par [ j ];
212 thePartialXsec[ i ] = ( *( vct_pXS_par[ j ] ) );
217 for ( std::vector < G4ParticleHPVector* >::iterator
218 it = vct_pXS_par.begin() ; it != vct_pXS_par.end() ; it++ )
230 G4int i, energyDistributionsNeeded = 0;
231 for (i=0; i<nDiscrete; i++)
233 if( disType[i]==1) energyDistributionsNeeded =1;
235 if(!energyDistributionsNeeded)
return;
236 aDataFile >> nPartials;
237 distribution =
new G4int[nPartials];
242 for (i=0; i<nPartials; i++)
245 probs[i].
Init(aDataFile,
eV);
249 partials[i]->
Init(aDataFile);
257 aDataFile >> nDiscrete >> targetMass;
260 theTotalXsec.
Init(aDataFile,
eV);
263 theGammas =
new G4double[nDiscrete];
264 theShells =
new G4double[nDiscrete];
265 isPrimary =
new G4int[nDiscrete];
266 disType =
new G4int[nDiscrete];
268 for(i=0; i<nDiscrete; i++)
270 aDataFile>>theGammas[i]>>theShells[i]>>isPrimary[i]>>disType[i];
273 thePartialXsec[i].
Init(aDataFile,
eV);
287 if ( actualMult.
Get() == NULL ) {
288 actualMult.
Get() =
new std::vector<G4int>( nDiscrete );
291 G4int nSecondaries = 0;
296 for(i=0; i<nDiscrete; i++)
298 current = theYield[i].
GetY(anEnergy);
300 if(nDiscrete==1&¤t<1.0001)
302 actualMult.
Get()->at(i) =
static_cast<G4int>(current);
305 actualMult.
Get()->at(i) = 0;
309 nSecondaries += actualMult.
Get()->at(i);
312 for(i=0;i<nSecondaries;i++)
316 thePhotons->push_back(theOne);
328 if ( nDiscrete == 1 && nPartials == 1 )
330 if ( actualMult.
Get()->at(0) > 0 )
332 if ( disType[0] == 1 )
369 temp = partials[ 0 ]->
GetY(anEnergy);
374 std::vector< G4double > photons_e_best( actualMult.
Get()->at(0) , 0.0 );
377 for (
G4int j = 0 ; j < maxTry ; j++ )
379 std::vector< G4double > photons_e( actualMult.
Get()->at(0) , 0.0 );
380 for ( std::vector< G4double >::iterator
381 it = photons_e.begin() ; it < photons_e.end() ; it++ )
385 if ( std::accumulate( photons_e.begin() , photons_e.end() , 0.0 ) > maximumE )
387 if ( std::accumulate( photons_e.begin() , photons_e.end() , 0.0 ) < best )
388 photons_e_best = photons_e;
393 for ( std::vector< G4double >::iterator
394 it = photons_e.begin() ; it < photons_e.end() ; it++ )
396 thePhotons->operator[](count)->SetKineticEnergy( *it );
423 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
426 if(count > nSecondaries)
throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist::GetPhotons inconsistancy");
432 for(i=0; i<nDiscrete; i++)
434 for(ii=0; ii< actualMult.
Get()->at(i); ii++)
439 for(iii=0; iii<nPartials; iii++) sum+=probs[iii].GetY(anEnergy);
442 for(iii=0; iii<nPartials; iii++)
444 run+=probs[iii].
GetY(anEnergy);
446 if(random<run/sum)
break;
448 if(theP==nPartials) theP=nPartials-1;
451 temp = partials[theP]->
GetY(anEnergy);
453 thePhotons->operator[](count)->SetKineticEnergy(eGamm);
458 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
461 if(count > nSecondaries)
throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist::GetPhotons inconsistancy");
468 for (i=0; i< nSecondaries; i++)
471 G4double theta = std::acos(costheta);
474 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
475 G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
476 thePhotons->operator[](i)->SetMomentum( temp ) ;
482 for(i=0; i<nSecondaries; i++)
484 G4double currentEnergy = thePhotons->operator[](i)->GetTotalEnergy();
485 for(ii=0; ii<nDiscrete2; ii++)
487 if (std::abs(currentEnergy-theGammas[ii])<0.1*
keV)
break;
489 if(ii==nDiscrete2) ii--;
497 G4double theta = std::acos(costheta);
500 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
501 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
502 thePhotons->operator[](i)->SetMomentum( tempVector ) ;
504 else if(tabulationType==1)
508 for (iii=0; iii<nNeu[ii-nIso]; iii++)
511 if(theLegendre[ii-nIso][iii].GetEnergy()>anEnergy)
515 aStore.
SetCoeff(1, &(theLegendre[ii-nIso][it]));
520 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][it-1]));
524 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][it]));
530 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
531 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
532 thePhotons->operator[](i)->SetMomentum( tempVector ) ;
538 for (iii=0; iii<nNeu[ii-nIso]; iii++)
541 if(theAngular[ii-nIso][iii].GetEnergy()>anEnergy)
548 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
549 G4ThreeVector tmpVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costh );
550 thePhotons->operator[](i)->SetMomentum( tmpVector ) ;
555 else if(repFlag == 2)
558 running[0]=theTransitionProbabilities[0];
560 for(i=1; i<nGammaEnergies; i++)
562 running[i]=running[i-1]+theTransitionProbabilities[i];
566 for(i=0; i<nGammaEnergies; i++)
569 if(random < running[i]/running[nGammaEnergies-1])
break;
572 G4double totalEnergy = theBaseEnergy - theLevelEnergies[it];
576 if(theInternalConversionFlag==2 && random>thePhotonTransitionFraction[it])
587 G4double theta = std::acos(costheta);
594 G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
600 for(ii=0; ii<nDiscrete2; ii++)
602 if (std::abs(currentEnergy-theGammas[ii])<0.1*
keV)
break;
604 if(ii==nDiscrete2) ii--;
618 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
621 else if(tabulationType==1)
625 for (iii=0; iii<nNeu[ii-nIso]; iii++)
628 if(theLegendre[ii-nIso][iii].GetEnergy()>anEnergy)
632 aStore.
SetCoeff(1, &(theLegendre[ii-nIso][itt]));
637 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][itt-1]));
641 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][itt]));
651 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
658 for (iii=0; iii<nNeu[ii-nIso]; iii++)
661 if(theAngular[ii-nIso][iii].GetEnergy()>anEnergy)
672 G4ThreeVector tmpVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costh );
676 thePhotons->push_back(theOne);
678 else if( repFlag==0 )
682 if ( thePartialXsec == 0 )
693 thePhotons->push_back( theOne );
699 std::vector < G4double > dif( nDiscrete , 0.0 );
700 for (
G4int j = 0 ; j < nDiscrete ; j++ )
714 for (
G4int j = 0 ; j < nDiscrete ; j++ )
740 if ( iphoton < nIso )
758 if ( tabulationType == 1 )
763 for (
G4int j = 0 ; j < nNeu [ iphoton - nIso ] ; j++ )
766 if ( theLegendre[ iphoton - nIso ][ j ].GetEnergy() > anEnergy )
break;
770 aStore.
SetCoeff( 1 , &( theLegendre[ iphoton - nIso ][ iangle ] ) );
771 aStore.
SetCoeff( 0 , &( theLegendre[ iphoton - nIso ][ iangle - 1 ] ) );
776 else if ( tabulationType == 2 )
782 for (
G4int j = 0 ; j < nNeu [ iphoton - nIso ] ; j++ )
785 if ( theAngular[ iphoton - nIso ][ j ].GetEnergy() > anEnergy )
break;
788 cosTheta = theAngular[iphoton-nIso][ iangle ].
GetCosTh();
796 G4double theta = std::acos( cosTheta );
797 G4double sinTheta = std::sin( theta );
799 G4double photonE = theGammas[ iphoton ];
800 G4ThreeVector direction ( sinTheta*std::cos( phi ) , sinTheta * std::sin( phi ) , cosTheta );
802 thePhotons->operator[]( 0 )->SetMomentum( photonP ) ;
G4double G4ParticleHPJENDLHEData::G4double result
G4long G4Poisson(G4double mean)
G4int GetVectorLength() const
G4double GetTotalMomentum() const
void Init(std::istream &aDataFile)
void InitInterpolation(G4int i, std::istream &aDataFile)
void Init(G4int aScheme, G4int aRange)
void SetMomentum(const G4double x, const G4double y, const G4double z)
G4double SampleMax(G4double energy)
void Init(std::istream &aDataFile)
G4double GetCosTh(G4int l)
G4double GetXsec(G4int i)
void InitPartials(std::istream &aDataFile)
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
static constexpr double twopi
std::vector< G4ReactionProduct * > G4ReactionProductVector
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
G4GLOB_DLL std::ostream G4cout
G4bool InitMean(std::istream &aDataFile)
void SetTotalEnergy(const G4double en)
static constexpr double eV
G4double GetX(G4int i) const
G4double GetY(G4double x)
G4double GetTotalEnergy() const
G4double GetPDGMass() const
void SetCoeff(G4int i, G4int l, G4double coeff)
G4ReactionProductVector * GetPhotons(G4double anEnergy)
static G4Electron * Electron()
void InitEnergies(std::istream &aDataFile)
void Init(std::istream &aDataFile)
void InitAngular(std::istream &aDataFile)
static constexpr double keV
G4double GetY(G4int i, G4int j)