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.");
126 aDataFile >> isoFlag;
129 if (repFlag == 2)
G4cout <<
"G4ParticleHPPhotonDist: repFlag == 2 && isoFlag != 1 is unexpected! If you use G4ND3.x, then please report to Geant4 HyperNews. " <<
G4endl;
130 aDataFile >> tabulationType >> nDiscrete2 >> nIso;
132 if (theGammas != NULL && nDiscrete2 != nDiscrete)
133 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;
138 std::vector < G4double > vct_gammas_par;
139 std::vector < G4double > vct_shells_par;
140 std::vector < G4int > vct_primary_par;
141 std::vector < G4int > vct_distype_par;
142 std::vector < G4ParticleHPVector* > vct_pXS_par;
143 if ( theGammas != NULL && theShells != NULL )
146 for ( i = 0 ; i < nDiscrete ; i++ )
148 vct_gammas_par.push_back( theGammas[ i ] );
149 vct_shells_par.push_back( theShells[ i ] );
150 vct_primary_par.push_back( isPrimary[ i ] );
151 vct_distype_par.push_back( disType[ i ] );
153 *hpv = thePartialXsec[ i ];
154 vct_pXS_par.push_back( hpv );
157 if ( theGammas == NULL ) theGammas =
new G4double[nDiscrete2];
158 if ( theShells == NULL ) theShells =
new G4double[nDiscrete2];
161 for (i=0; i< nIso; i++)
163 aDataFile >> theGammas[i] >> theShells[i];
167 nNeu =
new G4int [nDiscrete2-nIso];
170 for(i=nIso; i< nDiscrete2; i++)
172 if(tabulationType==1)
174 aDataFile >> theGammas[i] >> theShells[i] >> nNeu[i-nIso];
178 theLegendreManager.
Init(aDataFile);
179 for (ii=0; ii<nNeu[i-nIso]; ii++)
181 theLegendre[i-nIso][ii].
Init(aDataFile);
184 else if(tabulationType==2)
186 aDataFile >> theGammas[i] >> theShells[i] >> nNeu[i-nIso];
190 for (ii=0; ii<nNeu[i-nIso]; ii++)
192 theAngular[i-nIso][ii].
Init(aDataFile);
198 throw G4HadronicException(__FILE__, __LINE__,
"cannot deal with this tabulation type for angular distributions.");
202 if ( vct_gammas_par.size() > 0 )
205 for ( i = 0 ; i < nDiscrete ; i++ )
207 for (
G4int j = 0 ; j < nDiscrete ; j++ )
210 if ( theGammas[ i ] == vct_gammas_par [ j ] && theShells [ i ] == vct_shells_par[ j ] )
212 isPrimary [ i ] = vct_primary_par [ j ];
213 disType [ i ] = vct_distype_par [ j ];
214 thePartialXsec[ i ] = ( *( vct_pXS_par[ j ] ) );
219 for ( std::vector < G4ParticleHPVector* >::iterator
220 it = vct_pXS_par.begin() ; it != vct_pXS_par.end() ; it++ )
232 G4int i, energyDistributionsNeeded = 0;
233 for (i=0; i<nDiscrete; i++)
235 if( disType[i]==1) energyDistributionsNeeded =1;
237 if(!energyDistributionsNeeded)
return;
238 aDataFile >> nPartials;
239 distribution =
new G4int[nPartials];
244 for (i=0; i<nPartials; i++)
247 probs[i].
Init(aDataFile, eV);
251 partials[i]->
Init(aDataFile);
258 if (theXsec) theReactionXsec = theXsec;
260 aDataFile >> nDiscrete >> targetMass;
263 theTotalXsec.
Init(aDataFile, eV);
266 theGammas =
new G4double[nDiscrete];
267 theShells =
new G4double[nDiscrete];
268 isPrimary =
new G4int[nDiscrete];
269 disType =
new G4int[nDiscrete];
271 for(i=0; i<nDiscrete; i++)
273 aDataFile>>theGammas[i]>>theShells[i]>>isPrimary[i]>>disType[i];
276 thePartialXsec[i].
Init(aDataFile, eV);
290 if ( actualMult.
Get() == NULL ) {
291 actualMult.
Get() =
new std::vector<G4int>( nDiscrete );
294 G4int nSecondaries = 0;
299 for (i = 0; i < nDiscrete; i++) {
300 current = theYield[i].
GetY(anEnergy);
302 if (nDiscrete == 1 && current < 1.0001) {
303 actualMult.
Get()->at(i) =
static_cast<G4int>(current);
306 actualMult.
Get()->at(i) = 0;
310 nSecondaries += actualMult.
Get()->at(i);
313 for (i = 0; i < nSecondaries; i++) {
316 thePhotons->push_back(theOne);
321 if (nDiscrete == 1 && nPartials == 1) {
322 if (actualMult.
Get()->at(0) > 0) {
323 if (disType[0] == 1) {
326 temp = partials[ 0 ]->
GetY(anEnergy);
331 std::vector< G4double > photons_e_best( actualMult.
Get()->at(0) , 0.0 );
334 for (
G4int j = 0; j < maxTry; j++) {
335 std::vector<G4double> photons_e(actualMult.
Get()->at(0), 0.0);
336 for (std::vector<G4double>::iterator it = photons_e.begin(); it < photons_e.end(); it++) {
340 if (std::accumulate(photons_e.begin(), photons_e.end(), 0.0) > maximumE) {
341 if (std::accumulate(photons_e.begin(), photons_e.end(), 0.0) < best)
342 photons_e_best = photons_e;
347 for (std::vector<G4double>::iterator it = photons_e.begin(); it < photons_e.end(); it++) {
348 thePhotons->operator[](iphot)->SetKineticEnergy(*it);
369 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
372 if (count > nSecondaries)
throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist::GetPhotons inconsistency");
376 for (i=0; i<nDiscrete; i++) {
377 for (ii=0; ii< actualMult.
Get()->at(i); ii++) {
378 if (disType[i] == 1) {
381 for (iii = 0; iii < nPartials; iii++) sum+=probs[iii].GetY(anEnergy);
384 for (iii = 0; iii < nPartials; iii++) {
385 run+=probs[iii].
GetY(anEnergy);
387 if(random<run/sum)
break;
390 if (theP == nPartials) theP=nPartials-1;
393 temp = partials[theP]->
GetY(anEnergy);
395 thePhotons->operator[](count)->SetKineticEnergy(eGamm);
400 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
403 if (count > nSecondaries)
throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist::GetPhotons inconsistency");
410 for (i=0; i< nSecondaries; i++)
413 G4double theta = std::acos(costheta);
416 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
417 G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
418 thePhotons->operator[](i)->SetMomentum( temp ) ;
424 for(i=0; i<nSecondaries; i++)
426 G4double currentEnergy = thePhotons->operator[](i)->GetTotalEnergy();
427 for(ii=0; ii<nDiscrete2; ii++)
429 if (std::abs(currentEnergy-theGammas[ii])<0.1*keV)
break;
431 if(ii==nDiscrete2) ii--;
439 G4double theta = std::acos(costheta);
442 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
444 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costheta );
445 thePhotons->operator[](i)->SetMomentum( tempVector ) ;
447 else if(tabulationType==1)
451 for (iii=0; iii<nNeu[ii-nIso]; iii++)
454 if(theLegendre[ii-nIso][iii].GetEnergy()>anEnergy)
458 aStore.
SetCoeff(1, &(theLegendre[ii-nIso][it]));
463 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][it-1]));
467 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][it]));
473 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
474 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
475 thePhotons->operator[](i)->SetMomentum( tempVector ) ;
481 for (iii=0; iii<nNeu[ii-nIso]; iii++)
484 if(theAngular[ii-nIso][iii].GetEnergy()>anEnergy)
491 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
492 G4ThreeVector tmpVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costh );
493 thePhotons->operator[](i)->SetMomentum( tmpVector ) ;
498 }
else if (repFlag == 2) {
500 running[0]=theTransitionProbabilities[0];
502 for(i=1; i<nGammaEnergies; i++)
504 running[i]=running[i-1]+theTransitionProbabilities[i];
508 for(i=0; i<nGammaEnergies; i++)
511 if(random < running[i]/running[nGammaEnergies-1])
break;
514 G4double totalEnergy = theBaseEnergy - theLevelEnergies[it];
518 if(theInternalConversionFlag==2 && random>thePhotonTransitionFraction[it])
529 G4double theta = std::acos(costheta);
536 G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
542 for(ii=0; ii<nDiscrete2; ii++)
544 if (std::abs(currentEnergy-theGammas[ii])<0.1*keV)
break;
546 if(ii==nDiscrete2) ii--;
560 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
563 else if(tabulationType==1)
567 for (iii=0; iii<nNeu[ii-nIso]; iii++)
570 if(theLegendre[ii-nIso][iii].GetEnergy()>anEnergy)
574 aStore.
SetCoeff(1, &(theLegendre[ii-nIso][itt]));
579 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][itt-1]));
583 aStore.
SetCoeff(0, &(theLegendre[ii-nIso][itt]));
593 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
600 for (iii=0; iii<nNeu[ii-nIso]; iii++)
603 if(theAngular[ii-nIso][iii].GetEnergy()>anEnergy)
614 G4ThreeVector tmpVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costh );
618 thePhotons->push_back(theOne);
620 else if( repFlag==0 )
624 if ( thePartialXsec == 0 )
635 thePhotons->push_back( theOne );
641 std::vector < G4double > dif( nDiscrete , 0.0 );
642 for (
G4int j = 0 ; j < nDiscrete ; j++ )
656 for (
G4int j = 0 ; j < nDiscrete ; j++ )
670 if (theReactionXsec) {
671 if (thePartialXsec[iphoton].GetXsec(anEnergy)/theReactionXsec->
GetXsec(anEnergy) <
G4UniformRand() ) {
692 if ( iphoton < nIso )
710 if ( tabulationType == 1 )
715 for (
G4int j = 0 ; j < nNeu [ iphoton - nIso ] ; j++ )
718 if ( theLegendre[ iphoton - nIso ][ j ].GetEnergy() > anEnergy )
break;
722 aStore.
SetCoeff( 1 , &( theLegendre[ iphoton - nIso ][ iangle ] ) );
723 aStore.
SetCoeff( 0 , &( theLegendre[ iphoton - nIso ][ iangle - 1 ] ) );
728 else if ( tabulationType == 2 )
734 for (
G4int j = 0 ; j < nNeu [ iphoton - nIso ] ; j++ )
737 if ( theAngular[ iphoton - nIso ][ j ].GetEnergy() > anEnergy )
break;
740 cosTheta = theAngular[iphoton-nIso][ iangle ].
GetCosTh();
748 G4double theta = std::acos( cosTheta );
749 G4double sinTheta = std::sin( theta );
751 G4double photonE = theGammas[ iphoton ];
752 G4ThreeVector direction ( sinTheta*std::cos( phi ) , sinTheta * std::sin( phi ) , cosTheta );
754 thePhotons->operator[]( 0 )->SetMomentum( photonP ) ;
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)