source: trunk/source/processes/hadronic/models/isotope_production/src/G4NeutronIsotopeProduction.cc @ 1350

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

import all except CVS

File size: 3.7 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#include "G4NeutronIsotopeProduction.hh"
27
28G4NeutronIsotopeProduction::
29G4NeutronIsotopeProduction()
30{
31  numberOfElements = G4Element::GetNumberOfElements();
32  theData = new G4ElementIsoCrossSections<G4NeutronIsoIsoCrossSections> * [numberOfElements];
33  for(G4int i=0; i< numberOfElements; i++)
34  {
35    theData[i] = new G4ElementIsoCrossSections<G4NeutronIsoIsoCrossSections>;
36    if((*(G4Element::GetElementTable()))[i]->GetZ()>12 &&
37       (*(G4Element::GetElementTable()))[i]->GetZ()<84) // @@@@@@ workaround to ne fixed in G4NeutronHPNames.
38    {
39      theData[i]->Init((*(G4Element::GetElementTable()))[i]);
40    }
41  }
42}
43
44G4NeutronIsotopeProduction::
45~G4NeutronIsotopeProduction()
46{
47  for(G4int i=0; i<numberOfElements; i++)
48  {
49    delete theData[i];
50  }
51  if(theData!=NULL) delete [] theData;
52}
53
54
55G4IsoResult * G4NeutronIsotopeProduction::
56GetIsotope(const G4Track& aTrack,
57           const G4Nucleus & )
58{
59  // is applicable?
60  if(aTrack.GetDynamicParticle()->GetDefinition() != G4Neutron::Neutron()) return NULL;
61  if(aTrack.GetKineticEnergy()>100*MeV) return NULL;
62
63  // get the isotope
64  G4Material * theMaterial = aTrack.GetMaterial();
65  G4int nEleInMat = theMaterial->GetNumberOfElements();
66  for(G4int check = 0; check<nEleInMat; check++)
67  {
68    if(theMaterial->GetElement(check)->GetZ()<13) return NULL; //@@@@@@ workaround to ne fixed in G4NeutronHPNames.
69    if(theMaterial->GetElement(check)->GetZ()>83) return NULL; //@@@@@@ workaround to ne fixed in G4NeutronHPNames.
70  }
71  G4int index(0);
72  G4double * xSec = new G4double[nEleInMat];
73  G4double sum = 0;
74  {
75  for(G4int i=0; i<nEleInMat; i++)
76  {
77    index = theMaterial->GetElement(i)->GetIndex();
78    xSec[i] = theData[index]->GetCrossSection(aTrack.GetKineticEnergy());
79    sum += xSec[i];
80  }
81  }
82  G4double random = G4UniformRand();
83  G4double running = 0;
84  {
85  for(G4int i=0; i<nEleInMat; i++)
86  {
87    running += xSec[i];
88    index = theMaterial->GetElement(i)->GetIndex();
89    if(random<=running/sum) break;
90  }
91  }
92  delete [] xSec;
93  G4IsoResult * result = theData[index]->GetProductIsotope(aTrack.GetKineticEnergy());
94  return result;
95}
96
Note: See TracBrowser for help on using the repository browser.