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