source: trunk/source/processes/hadronic/models/neutron_hp/src/G4NeutronHPDeExGammas.cc @ 847

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

import all except CVS

File size: 4.1 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#include "G4NeutronHPDeExGammas.hh"
31
32void G4NeutronHPDeExGammas::Init(std::ifstream & aDataFile)
33{
34  G4NeutronHPGamma ** theGammas = new G4NeutronHPGamma * [50];
35  G4int nGammas = 0;
36  G4int nBuff = 50;
37  for(;;)
38  {
39    G4NeutronHPGamma * theNew = new G4NeutronHPGamma;
40    if(!theNew->Init(aDataFile))
41    {
42      delete theNew;
43      break;
44    }
45    else
46    {
47      if(nGammas==nBuff)
48      {
49        nBuff+=50;
50        G4NeutronHPGamma ** buffer = new G4NeutronHPGamma * [nBuff];
51        for(G4int i=0;i<nGammas;i++) buffer[i] = theGammas[i];
52        delete [] theGammas;
53        theGammas = buffer;
54      }
55      theGammas[nGammas] = theNew;
56      nGammas++;
57    }
58  }
59  // all gammas are in. Now sort them into levels.
60
61  // count the levels
62
63  G4double currentE = 0;
64  G4double nextE = 0;
65  G4int i;
66  G4double epsilon = 0.01*keV;
67  for(i=0; i<nGammas; i++)
68  {
69    nextE = theGammas[i]->GetLevelEnergy();
70    if(std::abs(currentE-nextE)>epsilon) nLevels++;
71    currentE = nextE;
72  }
73
74  // Build the levels
75
76  theLevels = new G4NeutronHPLevel[nLevels];
77  levelStart = new G4int [nLevels];
78  levelSize = new G4int [nLevels];
79
80  // fill the levels
81
82  currentE = 0;
83  nextE = 0;
84  G4int levelCounter=-1;
85  for(i=0; i<nGammas; i++)
86  {
87    nextE = theGammas[i]->GetLevelEnergy();
88    if(std::abs(currentE-nextE)>epsilon) 
89    {
90      levelCounter++;
91      levelStart[levelCounter] = i;
92      levelSize[levelCounter] = 0;
93    }
94    levelSize[levelCounter]++;
95    currentE = nextE;
96  }
97
98  for(i=0; i<nLevels; i++)
99  {
100    theLevels[i].SetNumberOfGammas(levelSize[i]);
101    for(G4int ii=levelStart[i]; ii<levelStart[i]+levelSize[i]; ii++)
102    {
103      theLevels[i].SetGamma(ii-levelStart[i], theGammas[ii]);
104    }
105  }
106
107// set the next relation in the gammas.
108  G4double levelE, gammaE, currentLevelE;
109  G4double min; 
110  for(i=0; i<nGammas; i++)
111  {
112    G4int it=-1;
113    gammaE = theGammas[i]->GetGammaEnergy();
114    currentLevelE = theGammas[i]->GetLevelEnergy();
115    min = currentLevelE-gammaE-epsilon;
116    for(G4int ii=0; ii<nLevels; ii++)
117    {
118      levelE = theLevels[ii].GetLevelEnergy();
119      if(std::abs(currentLevelE-(levelE+gammaE))<min)
120      {
121        min = std::abs(currentLevelE-(levelE+gammaE));
122        it = ii;
123      }
124    }
125    if(it!=-1) theGammas[i]->SetNext(&theLevels[it]);
126  }
127  // some garbage collection
128
129  delete [] theGammas;
130
131  // and we are Done.
132}
Note: See TracBrowser for help on using the repository browser.