Geant4_10
G4NeutronHPDeExGammas.cc
Go to the documentation of this file.
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 // 080801 Prohibit level transition to oneself by T. Koi
31 //
32 #include "G4NeutronHPDeExGammas.hh"
33 #include "G4SystemOfUnits.hh"
34 
35 void G4NeutronHPDeExGammas::Init(std::istream & aDataFile)
36 {
37  G4NeutronHPGamma ** theGammas = new G4NeutronHPGamma * [50];
38  G4int nGammas = 0;
39  G4int nBuff = 50;
40  for(;;)
41  {
42  G4NeutronHPGamma * theNew = new G4NeutronHPGamma;
43  if(!theNew->Init(aDataFile))
44  {
45  delete theNew;
46  break;
47  }
48  else
49  {
50  if(nGammas==nBuff)
51  {
52  nBuff+=50;
53  G4NeutronHPGamma ** buffer = new G4NeutronHPGamma * [nBuff];
54  for(G4int i=0;i<nGammas;i++) buffer[i] = theGammas[i];
55  delete [] theGammas;
56  theGammas = buffer;
57  }
58  theGammas[nGammas] = theNew;
59  nGammas++;
60  }
61  }
62  // all gammas are in. Now sort them into levels.
63 
64  // count the levels
65 
66  G4double currentE = 0;
67  G4double nextE = 0;
68  G4int i;
69  G4double epsilon = 0.01*keV;
70  for(i=0; i<nGammas; i++)
71  {
72  nextE = theGammas[i]->GetLevelEnergy();
73  if(std::abs(currentE-nextE)>epsilon) nLevels++;
74  currentE = nextE;
75  }
76 
77  // Build the levels
78 
79  theLevels = new G4NeutronHPLevel[nLevels];
80  levelStart = new G4int [nLevels];
81  levelSize = new G4int [nLevels];
82 
83  // fill the levels
84 
85  currentE = 0;
86  nextE = 0;
87  G4int levelCounter=-1;
88  for(i=0; i<nGammas; i++)
89  {
90  nextE = theGammas[i]->GetLevelEnergy();
91  if(std::abs(currentE-nextE)>epsilon)
92  {
93  levelCounter++;
94  levelStart[levelCounter] = i;
95  levelSize[levelCounter] = 0;
96  }
97  levelSize[levelCounter]++;
98  currentE = nextE;
99  }
100 
101  for(i=0; i<nLevels; i++)
102  {
103  theLevels[i].SetNumberOfGammas(levelSize[i]);
104  for(G4int ii=levelStart[i]; ii<levelStart[i]+levelSize[i]; ii++)
105  {
106  theLevels[i].SetGamma(ii-levelStart[i], theGammas[ii]);
107  }
108  }
109 
110 // set the next relation in the gammas.
111  G4double levelE, gammaE, currentLevelE;
112  G4double min;
113  for(i=0; i<nGammas; i++)
114  {
115  G4int it=-1;
116  gammaE = theGammas[i]->GetGammaEnergy();
117  currentLevelE = theGammas[i]->GetLevelEnergy();
118  min = currentLevelE-gammaE-epsilon;
119  for(G4int ii=0; ii<nLevels; ii++)
120  {
121  levelE = theLevels[ii].GetLevelEnergy();
122  if(std::abs(currentLevelE-(levelE+gammaE))<min)
123  {
124  min = std::abs(currentLevelE-(levelE+gammaE));
125  it = ii;
126  }
127  }
128 //080728
129  if ( it != -1 && currentLevelE == theLevels[it].GetLevelEnergy() )
130  {
131  //TK Comment; Some data file in /Inelastic/Gammas has inconsistent level data (no level to transit)
132  //G4cout << "DeExGammas Transition level error: it " << it << " " << currentLevelE << " " << gammaE << " " << theLevels[it-1].GetLevelEnergy() << " " << currentLevelE - theLevels[it-1].GetLevelEnergy() << G4endl;
133  // Forced to connect the next(previous) level
134  it +=-1;
135  }
136 //080728
137  if(it!=-1) theGammas[i]->SetNext(&theLevels[it]);
138  }
139  // some garbage collection
140 
141  delete [] theGammas;
142 
143  // and we are Done.
144 }
void SetNumberOfGammas(G4int aGammas)
G4double GetGammaEnergy()
void SetNext(G4NeutronHPLevel *aLevel)
void Init(std::istream &aDataFile)
#define buffer
Definition: xmlparse.cc:611
int G4int
Definition: G4Types.hh:78
G4double GetLevelEnergy()
G4double GetLevelEnergy(G4int aLevel)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
double G4double
Definition: G4Types.hh:76
void SetGamma(G4int i, G4NeutronHPGamma *aGamma)
G4bool Init(std::istream &aDataFile)
G4double GetLevelEnergy()