G4NeutronHPorLCapture.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // 05-11-21 NeutronHP or Low Energy Parameterization Models 
00028 //          Implemented by T. Koi (SLAC/SCCS)
00029 //          If NeutronHP data do not available for an element, then Low Energy 
00030 //          Parameterization models handle the interactions of the element.
00031 //
00032 // 080319 Compilation warnings - gcc-4.3.0 fix by T. Koi
00033 //
00034 
00035 // neutron_hp -- source file
00036 // J.P. Wellisch, Nov-1996
00037 // A prototype of the low energy neutron transport model.
00038 //
00039 #include "G4NeutronHPorLCapture.hh"
00040 #include "G4SystemOfUnits.hh"
00041 #include "G4NeutronHPCaptureFS.hh"
00042 
00043 G4NeutronHPorLCapture::G4NeutronHPorLCapture()
00044   :G4HadronicInteraction("NeutronHPorLCapture")
00045 {
00046    G4NeutronHPCaptureFS * theFS = new G4NeutronHPCaptureFS;
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 //    G4cout <<"G4NeutronHPorLCapture::G4NeutronHPorLCapture testit "<<dirName<<G4endl;
00053    numEle = G4Element::GetNumberOfElements();
00054    theCapture = new G4NeutronHPChannel[numEle];
00055    unavailable_elements.clear();
00056    for (G4int i=0; i<numEle; i++)
00057    {
00058       theCapture[i].Init((*(G4Element::GetElementTable()))[i], dirName);
00059       //G4cout << (*(G4Element::GetElementTable()))[i] -> GetName()  << G4endl;
00060       //while(!theCapture[i].Register(theFS));
00061       try { while(!theCapture[i].Register(theFS)) ; }
00062       catch ( G4HadronicException )
00063       {
00064           unavailable_elements.insert ( (*(G4Element::GetElementTable()))[i]->GetName() ); 
00065       }
00066    }
00067    delete theFS;
00068    SetMinEnergy(0.*eV);
00069    SetMaxEnergy(20.*MeV);
00070    if ( unavailable_elements.size() > 0 )
00071    {
00072       std::set< G4String>::iterator it;
00073       G4cout << "HP Capture data are not available for thess  elements "<< G4endl;
00074       for ( it = unavailable_elements.begin() ; it != unavailable_elements.end() ; it++ )
00075          G4cout << *it << G4endl;
00076       G4cout << "Low Energy Parameterization Models will be used."<< G4endl;
00077    }
00078 
00079    createXSectionDataSet();
00080 }
00081   
00082 G4NeutronHPorLCapture::~G4NeutronHPorLCapture()
00083 {
00084    delete [] theCapture;
00085    delete theDataSet; 
00086 }
00087   
00088 #include "G4NeutronHPThermalBoost.hh"
00089   
00090 G4HadFinalState * G4NeutronHPorLCapture::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& )
00091 {
00092    const G4Material * theMaterial = aTrack.GetMaterial();
00093    G4int n = theMaterial->GetNumberOfElements();
00094    G4int index = theMaterial->GetElement(0)->GetIndex();
00095    if(n!=1)
00096    {
00097       G4int i;
00098       xSec = new G4double[n];
00099       G4double sum=0;
00100       const G4double * NumAtomsPerVolume = theMaterial->GetVecNbOfAtomsPerVolume();
00101       G4double rWeight;    
00102       G4NeutronHPThermalBoost aThermalE;
00103       for (i=0; i<n; i++)
00104       {
00105         index = theMaterial->GetElement(i)->GetIndex();
00106         rWeight = NumAtomsPerVolume[i];
00107         G4double x = aThermalE.GetThermalEnergy(aTrack, theMaterial->GetElement(i), theMaterial->GetTemperature());
00108 
00109         //xSec[i] = theCapture[index].GetXsec(aThermalE.GetThermalEnergy(aTrack,
00110         //                                                                   theMaterial->GetElement(i),
00111         //                                                                   theMaterial->GetTemperature()));
00112         xSec[i] = theCapture[index].GetXsec(x);
00113 
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         if(random<=running/sum) break;
00124       }
00125       delete [] xSec;
00126       // it is element-wise initialised.
00127     }
00128     return theCapture[index].ApplyYourself(aTrack); 
00129 }
00130 
00131 
00132 
00133 G4bool G4NeutronHPorLCapture::IsThisElementOK( G4String name )
00134 {
00135    if ( unavailable_elements.find( name ) == unavailable_elements.end() ) 
00136       return TRUE;
00137    else 
00138       return FALSE; 
00139 }
00140 
00141 
00142 
00143 void G4NeutronHPorLCapture::createXSectionDataSet()
00144 {
00145    theDataSet = new G4NeutronHPorLCaptureData ( theCapture , &unavailable_elements );
00146 }
00147 const std::pair<G4double, G4double> G4NeutronHPorLCapture::GetFatalEnergyCheckLevels() const
00148 {
00149    //return std::pair<G4double, G4double>(10*perCent,10*GeV);
00150    return std::pair<G4double, G4double>(10*perCent,DBL_MAX);
00151 }

Generated on Mon May 27 17:49:03 2013 for Geant4 by  doxygen 1.4.7