Geant4  10.02.p03
G4NuclearLevelStore Class Reference

#include <G4NuclearLevelStore.hh>

Collaboration diagram for G4NuclearLevelStore:

Public Member Functions

G4NuclearLevelManagerGetManager (G4int Z, G4int A)
 
 ~G4NuclearLevelStore ()
 
void AddUserEvaporationDataFile (G4int Z, G4int A, const G4String &filename)
 

Static Public Member Functions

static G4NuclearLevelStoreGetInstance ()
 

Private Types

typedef std::map< G4int, G4NuclearLevelManager * > ManagersMap
 

Private Member Functions

 G4NuclearLevelStore ()
 
G4int GenerateKey (G4int Z, G4int A) const
 
G4String GenerateFileName (G4int Z, G4int A) const
 

Private Attributes

ManagersMap theManagers
 
G4String dirName
 
G4bool userFiles
 
std::map< G4int, G4StringtheUserDataFiles
 

Static Private Attributes

static G4ThreadLocal G4NuclearLevelStoretheInstance = 0
 

Friends

class G4ThreadLocalSingleton< G4NuclearLevelStore >
 

Detailed Description

Definition at line 49 of file G4NuclearLevelStore.hh.

Member Typedef Documentation

◆ ManagersMap

Definition at line 75 of file G4NuclearLevelStore.hh.

Constructor & Destructor Documentation

◆ G4NuclearLevelStore()

G4NuclearLevelStore::G4NuclearLevelStore ( )
private

Definition at line 62 of file G4NuclearLevelStore.cc.

63 {
64  userFiles = false;
65  char* env = getenv("G4LEVELGAMMADATA");
66  if (env == 0)
67  {
68  G4cout << "G4NuclarLevelStore: please set the G4LEVELGAMMADATA environment variable\n";
69  dirName = "";
70  }
71  else
72  {
73  dirName = env;
74  dirName += '/';
75  }
76 }
G4GLOB_DLL std::ostream G4cout

◆ ~G4NuclearLevelStore()

G4NuclearLevelStore::~G4NuclearLevelStore ( )

Definition at line 78 of file G4NuclearLevelStore.cc.

79 {
80 #ifdef G4MULTITHREADED
81  if(this==theShadowInstance) // G4NuclearLevelManager object should be deleted only by the master
82  {
83 #endif
84  ManagersMap::iterator i;
85  for (i = theManagers.begin(); i != theManagers.end(); ++i)
86  { delete i->second; }
87 #ifdef G4MULTITHREADED
88  }
89 #endif
90 }

Member Function Documentation

◆ AddUserEvaporationDataFile()

void G4NuclearLevelStore::AddUserEvaporationDataFile ( G4int  Z,
G4int  A,
const G4String filename 
)

Definition at line 93 of file G4NuclearLevelStore.cc.

95 {
96  if (Z<1 || A<2) {
97  G4cout<<"G4NuclearLevelStore::AddUserEvaporationDataFile "
98  <<" Z= " << Z << " and A= " << A << " not valid!"<<G4endl;
99  }
100 
101  std::ifstream DecaySchemeFile(filename);
102  if (DecaySchemeFile){
103  G4int ID_ion=Z*1000+A;//A*1000+Z;
104  theUserDataFiles[ID_ion]=filename;
105  userFiles = true;
106  }
107  else {
108  G4cout<<"The file "<<filename<<" does not exist!"<<G4endl;
109  }
110 }
std::map< G4int, G4String > theUserDataFiles
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
Float_t Z
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateFileName()

G4String G4NuclearLevelStore::GenerateFileName ( G4int  Z,
G4int  A 
) const
private

Definition at line 113 of file G4NuclearLevelStore.cc.

114 {
115  std::ostringstream streamName;
116  streamName << 'z' << Z << ".a" << A;
117  G4String name(streamName.str());
118  return name;
119 }
G4String name
Definition: TRTMaterials.hh:40
double A(double temperature)
Float_t Z
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateKey()

G4int G4NuclearLevelStore::GenerateKey ( G4int  Z,
G4int  A 
) const
inlineprivate

Definition at line 71 of file G4NuclearLevelStore.hh.

71 { return Z*1000+A; }
double A(double temperature)
Float_t Z
Here is the call graph for this function:

◆ GetInstance()

G4NuclearLevelStore * G4NuclearLevelStore::GetInstance ( void  )
static

Definition at line 47 of file G4NuclearLevelStore.cc.

48 {
49  if(!theInstance) {
51  theInstance = inst.Instance();
52  }
53 #ifdef G4MULTITHREADED
54  if(!theShadowInstance) {
55  static G4NuclearLevelStore shadowInst;
56  theShadowInstance = &shadowInst;
57  }
58 #endif
59  return theInstance;
60 }
static G4ThreadLocal G4NuclearLevelStore * theInstance
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetManager()

G4NuclearLevelManager * G4NuclearLevelStore::GetManager ( G4int  Z,
G4int  A 
)

Definition at line 122 of file G4NuclearLevelStore.cc.

123 {
124  G4NuclearLevelManager * result = 0;
125  if (A < 1 || Z < 1 || A < Z)
126  {
127  //G4cout << "G4NuclearLevelStore::GetManager: Wrong values Z = " << Z
128  // << " A = " << A << '\n';
129  return result;
130  }
131 
132  // Generate the key = filename
133  G4int key = Z*1000+A; //GenerateKey(Z,A);
134 
135  // Check if already exists that key
136  ManagersMap::iterator idx = theManagers.find(key);
137 
138 #ifdef G4MULTITHREADED
139  // If doesn't exists then check the master
140  if ( idx == theManagers.end() )
141  {
142  G4MUTEXLOCK(&G4NuclearLevelStore::nuclearLevelStoreMutex);
143  ManagersMap::iterator idxS = theShadowInstance->theManagers.find(key);
144  if ( idxS == theShadowInstance->theManagers.end() )
145  {
146  // If doesn't exists then create it
148 
149  //Check if data have been provided by the user
150  if(userFiles) {
151  G4String file1 = theUserDataFiles[key];//1000*A+Z];
152  if (file1 != "") { file = file1; }
153  }
154  result = new G4NuclearLevelManager(Z,A,file);
155  theShadowInstance->theManagers.insert(std::make_pair(key,result));
156  }
157  else
158  {
159  // if it exists in the master
160  result = idxS->second;
161  }
162  // register to the local map
163  theManagers.insert(std::make_pair(key,result));
164  G4MUTEXUNLOCK(&G4NuclearLevelStore::nuclearLevelStoreMutex);
165  }
166 #else
167  // If doesn't exists then create it
168  if ( idx == theManagers.end() )
169  {
170  G4String file = dirName + GenerateFileName(Z,A);
171 
172  //Check if data have been provided by the user
173  if(userFiles) {
174  G4String file1 = theUserDataFiles[key];//1000*A+Z];
175  if (file1 != "") { file = file1; }
176  }
177  result = new G4NuclearLevelManager(Z,A,file);
178  theManagers.insert(std::make_pair(key,result));
179  }
180 #endif
181  else
182  // But if it exists...
183  {
184  result = idx->second;
185  }
186 
187  return result;
188 }
#define G4MUTEXUNLOCK
Definition: G4Threading.hh:180
std::map< G4int, G4String > theUserDataFiles
G4String GenerateFileName(G4int Z, G4int A) const
TFile * file
int G4int
Definition: G4Types.hh:78
double A(double temperature)
Float_t Z
#define G4MUTEXLOCK
Definition: G4Threading.hh:179
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ G4ThreadLocalSingleton< G4NuclearLevelStore >

Definition at line 52 of file G4NuclearLevelStore.hh.

Member Data Documentation

◆ dirName

G4String G4NuclearLevelStore::dirName
private

Definition at line 79 of file G4NuclearLevelStore.hh.

◆ theInstance

G4ThreadLocal G4NuclearLevelStore * G4NuclearLevelStore::theInstance = 0
staticprivate

Definition at line 81 of file G4NuclearLevelStore.hh.

◆ theManagers

ManagersMap G4NuclearLevelStore::theManagers
private

Definition at line 77 of file G4NuclearLevelStore.hh.

◆ theUserDataFiles

std::map<G4int, G4String> G4NuclearLevelStore::theUserDataFiles
private

Definition at line 87 of file G4NuclearLevelStore.hh.

◆ userFiles

G4bool G4NuclearLevelStore::userFiles
private

Definition at line 86 of file G4NuclearLevelStore.hh.


The documentation for this class was generated from the following files: