source: trunk/source/processes/hadronic/models/neutron_hp/src/G4NeutronHPElastic.cc @ 819

Last change on this file since 819 was 819, checked in by garnier, 16 years ago

import all except CVS

File size: 4.3 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26// neutron_hp -- source file
27// J.P. Wellisch, Nov-1996
28// A prototype of the low energy neutron transport model.
29//
30// 070523 bug fix for G4FPE_DEBUG on by A. Howard ( and T. Koi)
31// 080319 Compilation warnings - gcc-4.3.0 fix by T. Koi
32//
33#include "G4NeutronHPElastic.hh"
34#include "G4NeutronHPElasticFS.hh"
35
36  G4NeutronHPElastic::G4NeutronHPElastic()
37    :G4HadronicInteraction("NeutronHPElastic")
38  {
39    overrideSuspension = false;
40    G4NeutronHPElasticFS * theFS = new G4NeutronHPElasticFS;
41    if(!getenv("G4NEUTRONHPDATA")) 
42       throw G4HadronicException(__FILE__, __LINE__, "Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files.");
43    dirName = getenv("G4NEUTRONHPDATA");
44    G4String tString = "/Elastic/";
45    dirName = dirName + tString;
46//    G4cout <<"G4NeutronHPElastic::G4NeutronHPElastic testit "<<dirName<<G4endl;
47    numEle = G4Element::GetNumberOfElements();
48    theElastic = new G4NeutronHPChannel[numEle];
49    for (G4int i=0; i<numEle; i++)
50    {
51      theElastic[i].Init((*(G4Element::GetElementTable()))[i], dirName);
52      while(!theElastic[i].Register(theFS)) ;
53    }
54    delete theFS;
55    SetMinEnergy(0.*eV);
56    SetMaxEnergy(20.*MeV);
57  }
58 
59  G4NeutronHPElastic::~G4NeutronHPElastic()
60  {
61    delete [] theElastic;
62  }
63 
64  #include "G4NeutronHPThermalBoost.hh"
65 
66  G4HadFinalState * G4NeutronHPElastic::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& )
67  {
68    const G4Material * theMaterial = aTrack.GetMaterial();
69    G4int n = theMaterial->GetNumberOfElements();
70    G4int index = theMaterial->GetElement(0)->GetIndex();
71    if(n!=1)
72    {
73      G4int i;
74      xSec = new G4double[n];
75      G4double sum=0;
76      const G4double * NumAtomsPerVolume = theMaterial->GetVecNbOfAtomsPerVolume();
77      G4double rWeight;   
78      G4NeutronHPThermalBoost aThermalE;
79      for (i=0; i<n; i++)
80      {
81        index = theMaterial->GetElement(i)->GetIndex();
82        rWeight = NumAtomsPerVolume[i];
83        xSec[i] = theElastic[index].GetXsec(aThermalE.GetThermalEnergy(aTrack,
84                                                                     theMaterial->GetElement(i),
85                                                                     theMaterial->GetTemperature()));
86        xSec[i] *= rWeight;
87        sum+=xSec[i];
88      }
89      G4double random = G4UniformRand();
90      G4double running = 0;
91      for (i=0; i<n; i++)
92      {
93        running += xSec[i];
94        index = theMaterial->GetElement(i)->GetIndex();
95        //if(random<=running/sum) break;
96        if( sum == 0 || random <= running/sum ) break;
97      }
98      delete [] xSec;
99      // it is element-wise initialised.
100    }
101    G4HadFinalState* finalState = theElastic[index].ApplyYourself(aTrack);
102    if (overrideSuspension) finalState->SetStatusChange(isAlive);
103    return finalState; 
104  }
Note: See TracBrowser for help on using the repository browser.