Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4LevelManager.cc
이 파일의 문서화 페이지로 가기
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 // $Id: G4LevelManager.cc 88375 2015-02-16 17:31:21Z vnivanch $
27 //
28 // -------------------------------------------------------------------
29 //
30 // GEANT4 source file
31 //
32 // File name: G4LevelManager
33 //
34 // Author: V.Ivanchenko
35 //
36 // Creation date: 4 January 2012
37 //
38 // Modifications:
39 // 13.02.2015 Design change for gamma de-excitation
40 //
41 // -------------------------------------------------------------------
42 
43 #include "G4LevelManager.hh"
44 #include "G4HadronicException.hh"
45 #include <iomanip>
46 
48  "-", "+X", "+Y", "+Z", "+U", "+V", "+W", "+R", "+S", "+T", "+A", "+B", "+C"};
49 
51  const std::vector<G4double>& energies,
52  const std::vector<G4int>& spin,
53  const std::vector<const G4NucLevel*>& levels)
54  : nTransitions(0)
55 {
56  if(0 < ntrans) {
57  nTransitions = ntrans - 1;
58  fLevelEnergy.reserve(ntrans);
59  fSpin.reserve(ntrans);
60  fLevels.reserve(ntrans);
61  for(size_t i=0; i<ntrans; ++i) {
62  fLevelEnergy.push_back(energies[i]);
63  fSpin.push_back(spin[i]);
64  fLevels.push_back(levels[i]);
65  }
66  //G4cout << "New G4LevelManager N= " << nTransitions << " "
67  //<< fLevelEnergy.size() << " <" << this << ">" << G4endl;
68  }
69 }
70 
72 {
73  for(size_t i=0; i<=nTransitions; ++i) { delete fLevels[i]; }
74 }
75 
76 size_t
78 {
79  //G4cout<< "index= " << index << " max= " << nTransitions << " exc= " << ener
80  // << " Emax= " << fLevelEnergy[nTransitions] << G4endl;
81  size_t idx = std::min(index, nTransitions);
82  static const G4double tolerance = 1.0f-6;
83  if(0 == nTransitions || std::abs(energy - fLevelEnergy[idx]) <= tolerance) {
84  return idx;
85  }
86  // ground state
87  if(energy <= fLevelEnergy[1]*0.5)
88  { idx = 0; }
89  // take top level
90  else if((fLevelEnergy[nTransitions] + fLevelEnergy[nTransitions-1])*0.5 <= energy)
91  { idx = nTransitions; }
92 
93  // if shortcuts are not working, make binary search
94  else {
95  idx = std::lower_bound(fLevelEnergy.begin(), fLevelEnergy.end(), energy)
96  - fLevelEnergy.begin() - 1;
97  if(energy - fLevelEnergy[idx] > fLevelEnergy[idx+1] - energy) { ++idx; }
98  //G4cout << "E= " << energy << " " << fLevelEnergy[idx-1]
99  //<< " " << fLevelEnergy[idx] << G4endl;
100  }
101  return idx;
102 }
103 
105 {
106 #ifdef G4VERBOSE
107  if(i > nTransitions) { PrintError(i, "Meta"); }
108 #endif
109  return fFloatingLevels[fSpin[i]/100000];
110 }
111 
112 #ifdef G4VERBOSE
113 void G4LevelManager::PrintError(size_t idx, const G4String& ss) const
114 {
115  G4String sss = "G4LevelManager::"+ss+"()";
117  ed << "Index of a level " << idx << " > "
118  << nTransitions << " (number of levels)";
119  G4Exception(sss,"had061",JustWarning,ed,"stop run");
120  throw G4HadronicException(__FILE__, __LINE__,"FATAL Hadronic Exception");
121 }
122 #endif
123 
124 void G4LevelManager::StreamInfo(std::ostream& out) const
125 {
126  for(size_t i=0; i<=nTransitions; ++i) {
127  G4int prec = out.precision(6);
128  out << std::setw(6) << i << ". "
129  << std::setw(8) << fLevelEnergy[i];
130  if(fLevels[i]) {
131  out << std::setw(8) << fLevels[i]->GetTimeGamma()
132  << std::setw(4) << fLevels[i]->NumberOfTransitions()
133  << std::setw(4) << SpinTwo(i)
134  << std::setw(4) << Parity(i)
135  << std::setw(4) << FloatingLevel(i);
136  }
137  out << "\n";
138  out.precision(prec);
139  if(fLevels[i]) { fLevels[i]->StreamInfo(out); }
140  }
141 }
void StreamInfo(std::ostream &os) const
static const double prec
Definition: RanecuEngine.cc:58
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
G4int Parity(size_t i) const
std::vector< G4double > fLevelEnergy
static const char sss[MAX_N_PAR+2]
Definition: Evaluator.cc:64
G4int FloatingLevel(size_t i) const
double G4double
Definition: G4Types.hh:76
static G4String fFloatingLevels[nfloting]
double energy
Definition: plottest35.C:25
const G4String & FloatingType(size_t i) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
G4int SpinTwo(size_t i) const
G4LevelManager(size_t ntrans, const std::vector< G4double > &energies, const std::vector< G4int > &spin, const std::vector< const G4NucLevel * > &levels)
std::vector< G4int > fSpin
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
size_t NearestLevelIndex(G4double energy, size_t index=0) const
std::vector< const G4NucLevel * > fLevels