Geant4  10.02.p02
G4NuclearLevelData.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 // $Id: G4NuclearLevelData.cc 86536 2014-11-13 19:05:21Z vnivanch $
27 //
28 // -------------------------------------------------------------------
29 //
30 // GEANT4 source file
31 //
32 // File name: G4NuclearLevelData
33 //
34 // Author: V.Ivanchenko
35 //
36 // Creation date: 10 February 2015
37 //
38 // Modifications:
39 //
40 // -------------------------------------------------------------------
41 
42 #include "G4NuclearLevelData.hh"
43 #include "G4LevelReader.hh"
44 #include "G4LevelManager.hh"
45 #include "G4Element.hh"
46 #include "G4ElementTable.hh"
47 
49 
50 const G4int G4NuclearLevelData::AMIN[] = {0,
51  1,3,6,7,8,10,12,14,17,18, // Z= 1-10
52  21,22,23,26,27,28,32,32,36,36, // Z= 11-20
53  41,42,45,45,48,49,53,54,57,59, // Z= 21-30
54  61,62,66,68,70,72,74,76,78,80, // Z= 31-40
55  82,84,86,88,92,93,95,98,101,101, // Z= 41-50
56  105,105,109,110,114,118,121,122,125,128, // Z= 51-60
57  131,130,137,138,140,140,141,144,145,151, // Z= 61-70
58  151,154,159,160,161,162,168,168,172,172, // Z= 71-80
59  181,180,187,189,196,196,206,206,212,214, // Z= 81-90
60  229,230,233,236,241,240,240,245,243,249, // Z= 91-100
61  251,251};
62 const G4int G4NuclearLevelData::AMAX[] = {0,
63  3,8,9,12,13,16,21,22,27,32, // Z= 1-10
64  32,36,35,42,43,46,45,48,50,53, // Z= 11-20
65  56,58,60,64,64,68,68,76,73,78, // Z= 21-30
66  81,84,84,88,88,96,96,102,102,108, // Z= 31-40
67  105,110,111,114,115,121,120,130,130,134, // Z= 41-50
68  135,139,139,144,145,148,149,152,151,156, // Z= 51-60
69  155,160,159,164,166,170,169,172,175,178, // Z= 61-70
70  180,184,190,190,190,198,198,204,201,208, // Z= 71-80,
71  210,212,215,218,217,222,227,232,232,234, // Z= 81-90,
72  236,240,242,246,246,249,251,253,254,256, // Z= 91-100
73  251,254};
74 
75 #ifdef G4MULTITHREADED
76 G4Mutex G4NuclearLevelData::nuclearLevelDataMutex = G4MUTEX_INITIALIZER;
77 #endif
78 
80 {
81  if (!theInstance) {
82  static G4NuclearLevelData theData;
83  theInstance = &theData;
84  }
85  return theInstance;
86 }
87 
89 {
91  for(G4int Z=0; Z<ZMAX; ++Z) {
92  (fLevelManagers[Z]).resize(AMAX[Z]-AMIN[Z]+1,nullptr);
93  (fLevelManagerFlags[Z]).resize(AMAX[Z]-AMIN[Z]+1,false);
94  }
95 }
96 
98 {
99  delete fLevelReader;
100  for(G4int Z=1; Z<ZMAX; ++Z) {
101  size_t nn = (fLevelManagers[Z]).size();
102  for(size_t j=0; j<nn; ++j) {
103  //G4cout << " G4NuclearLevelData delete Z= " << Z
104  // << " A= " << AMIN[Z]+j << G4endl;
105  delete (fLevelManagers[Z])[j];
106  }
107  }
108 }
109 
110 const G4LevelManager*
112 {
113  const G4LevelManager* man = nullptr;
114  //G4cout << "G4NuclearLevelData: Z= " << Z << " A= " << A << G4endl;
115  if(0 < Z && Z < ZMAX && A >= AMIN[Z] && A <= AMAX[Z]) {
116  if(!(fLevelManagerFlags[Z])[A - AMIN[Z]]) {
117  InitialiseForIsotope(Z, A);
118  }
119  man = (fLevelManagers[Z])[A - AMIN[Z]];
120  }
121  //G4cout << man << G4endl;
122  return man;
123 }
124 
125 G4bool
127 {
128  G4bool res = false;
129  if(A >= AMIN[Z] && A <= AMAX[Z]) {
130  const G4LevelManager* newman =
131  fLevelReader->MakeLevelManager(Z, A, filename);
132  if(newman) {
133  delete (fLevelManagers[Z])[A - AMIN[Z]];
134  (fLevelManagers[Z])[A - AMIN[Z]] = newman;
135  (fLevelManagerFlags[Z])[A - AMIN[Z]] = true;
136  res = true;
137  }
138  }
139  return res;
140 }
141 
143 {
144 #ifdef G4MULTITHREADED
145  G4MUTEXLOCK(&G4NuclearLevelData::nuclearLevelDataMutex);
146 #endif
147  if(!(fLevelManagerFlags[Z])[A - AMIN[Z]]) {
148  (fLevelManagers[Z])[A - AMIN[Z]] =
150  (fLevelManagerFlags[Z])[A - AMIN[Z]] = true;
151  }
152 #ifdef G4MULTITHREADED
153  G4MUTEXUNLOCK(&G4NuclearLevelData::nuclearLevelDataMutex);
154 #endif
155 }
#define G4MUTEXUNLOCK
Definition: G4Threading.hh:180
const G4LevelManager * GetLevelManager(G4int Z, G4int A)
G4LevelReader * fLevelReader
void InitialiseForIsotope(G4int Z, G4int A)
const G4LevelManager * MakeLevelManager(G4int Z, G4int A, const G4String &filename)
std::vector< G4bool > fLevelManagerFlags[ZMAX]
G4bool AddPrivateData(G4int Z, G4int A, const G4String &filename)
std::vector< const G4LevelManager * > fLevelManagers[ZMAX]
int G4int
Definition: G4Types.hh:78
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:175
static const G4int AMAX[ZMAX]
double A(double temperature)
bool G4bool
Definition: G4Types.hh:79
#define G4MUTEXLOCK
Definition: G4Threading.hh:179
static G4NuclearLevelData * theInstance
G4int G4Mutex
Definition: G4Threading.hh:173
static const G4int AMIN[ZMAX]
const G4LevelManager * CreateLevelManager(G4int Z, G4int A)
static const G4int ZMAX
static G4NuclearLevelData * GetInstance()