00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "G4NeutronHPCapture.hh"
00033 #include "G4SystemOfUnits.hh"
00034 #include "G4NeutronHPCaptureFS.hh"
00035 #include "G4NeutronHPDeExGammas.hh"
00036 #include "G4ParticleTable.hh"
00037 #include "G4IonTable.hh"
00038
00039 #include "G4NeutronHPManager.hh"
00040
00041 G4NeutronHPCapture::G4NeutronHPCapture()
00042 :G4HadronicInteraction("NeutronHPCapture")
00043 {
00044 SetMinEnergy( 0.0 );
00045 SetMaxEnergy( 20.*MeV );
00046
00047 if(!getenv("G4NEUTRONHPDATA"))
00048 throw G4HadronicException(__FILE__, __LINE__, "Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files.");
00049 dirName = getenv("G4NEUTRONHPDATA");
00050 G4String tString = "/Capture";
00051 dirName = dirName + tString;
00052 numEle = G4Element::GetNumberOfElements();
00053
00054
00055
00056
00057 G4NeutronHPCaptureFS * theFS = new G4NeutronHPCaptureFS;
00058
00059
00060
00061
00062
00063
00064 for ( G4int i = 0 ; i < numEle ; i++ )
00065 {
00066 theCapture.push_back( new G4NeutronHPChannel );
00067 (*theCapture[i]).Init((*(G4Element::GetElementTable()))[i], dirName);
00068 (*theCapture[i]).Register(theFS);
00069 }
00070 delete theFS;
00071
00072
00073 }
00074
00075 G4NeutronHPCapture::~G4NeutronHPCapture()
00076 {
00077
00078
00079 for ( std::vector<G4NeutronHPChannel*>::iterator
00080 ite = theCapture.begin() ; ite != theCapture.end() ; ite++ )
00081 {
00082 delete *ite;
00083 }
00084 theCapture.clear();
00085 }
00086
00087 #include "G4NeutronHPThermalBoost.hh"
00088 G4HadFinalState * G4NeutronHPCapture::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& aNucleus )
00089 {
00090
00091 if ( numEle < (G4int)G4Element::GetNumberOfElements() ) addChannelForNewElement();
00092
00093 G4NeutronHPManager::GetInstance()->OpenReactionWhiteBoard();
00094 if(getenv("NeutronHPCapture")) G4cout <<" ####### G4NeutronHPCapture called"<<G4endl;
00095 const G4Material * theMaterial = aTrack.GetMaterial();
00096 G4int n = theMaterial->GetNumberOfElements();
00097 G4int index = theMaterial->GetElement(0)->GetIndex();
00098 if(n!=1)
00099 {
00100 xSec = new G4double[n];
00101 G4double sum=0;
00102 G4int i;
00103 const G4double * NumAtomsPerVolume = theMaterial->GetVecNbOfAtomsPerVolume();
00104 G4double rWeight;
00105 G4NeutronHPThermalBoost aThermalE;
00106 for (i=0; i<n; i++)
00107 {
00108 index = theMaterial->GetElement(i)->GetIndex();
00109 rWeight = NumAtomsPerVolume[i];
00110
00111 xSec[i] = (*theCapture[index]).GetXsec(aThermalE.GetThermalEnergy(aTrack,
00112 theMaterial->GetElement(i),
00113 theMaterial->GetTemperature()));
00114 xSec[i] *= rWeight;
00115 sum+=xSec[i];
00116 }
00117 G4double random = G4UniformRand();
00118 G4double running = 0;
00119 for (i=0; i<n; i++)
00120 {
00121 running += xSec[i];
00122 index = theMaterial->GetElement(i)->GetIndex();
00123
00124 if( sum == 0 || random <= running/sum ) break;
00125 }
00126 if(i==n) i=std::max(0, n-1);
00127 delete [] xSec;
00128 }
00129
00130
00131
00132 G4HadFinalState* result = (*theCapture[index]).ApplyYourself(aTrack);
00133 aNucleus.SetParameters(G4NeutronHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargA(),G4NeutronHPManager::GetInstance()->GetReactionWhiteBoard()->GetTargZ());
00134 G4NeutronHPManager::GetInstance()->CloseReactionWhiteBoard();
00135 return result;
00136 }
00137
00138 const std::pair<G4double, G4double> G4NeutronHPCapture::GetFatalEnergyCheckLevels() const
00139 {
00140
00141 return std::pair<G4double, G4double>(10*perCent,DBL_MAX);
00142 }
00143
00144 void G4NeutronHPCapture::addChannelForNewElement()
00145 {
00146 G4NeutronHPCaptureFS* theFS = new G4NeutronHPCaptureFS;
00147 for ( G4int i = numEle ; i < (G4int)G4Element::GetNumberOfElements() ; i++ )
00148 {
00149 G4cout << "G4NeutronHPCapture Prepairing Data for the new element of " << (*(G4Element::GetElementTable()))[i]->GetName() << G4endl;
00150 theCapture.push_back( new G4NeutronHPChannel );
00151 (*theCapture[i]).Init((*(G4Element::GetElementTable()))[i], dirName);
00152 (*theCapture[i]).Register(theFS);
00153 }
00154 delete theFS;
00155 numEle = (G4int)G4Element::GetNumberOfElements();
00156 }