Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4MolecularConfiguration::G4MolecularConfigurationManager Class Reference

#include <G4MolecularConfiguration.hh>

Public Member Functions

 G4MolecularConfigurationManager ()
 
 ~G4MolecularConfigurationManager ()
 
int GetNumberOfCreatedSpecies ()
 
G4int Insert (const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc, G4MolecularConfiguration *molConf)
 
G4int Insert (const G4MoleculeDefinition *molDef, int charge, G4MolecularConfiguration *molConf)
 
G4int Insert (const G4MoleculeDefinition *molDef, const G4String &label, G4MolecularConfiguration *molConf)
 
void AddUserID (const G4String &name, G4MolecularConfiguration *molecule)
 
void RecordNewlyLabeledConfiguration (G4MolecularConfiguration *molConf)
 
const G4ElectronOccupancyFindCommonElectronOccupancy (const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
 
G4MolecularConfigurationGetMolecularConfiguration (const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
 
G4MolecularConfigurationGetMolecularConfiguration (const G4MoleculeDefinition *molDef, int charge)
 
G4MolecularConfigurationGetMolecularConfiguration (const G4MoleculeDefinition *molDef, const G4String &label)
 
G4MolecularConfigurationGetMolecularConfiguration (int moleculeID)
 
G4MolecularConfigurationGetMolecularConfiguration (const G4String &userID)
 
G4MolecularConfigurationGetOrCreateMolecularConfiguration (const G4MoleculeDefinition *molDef, const G4ElectronOccupancy &eOcc)
 
G4MolecularConfigurationGetOrCreateMolecularConfiguration (const G4MoleculeDefinition *molDef, int charge)
 
void RemoveMolecularConfigurationFromTable (G4MolecularConfiguration *)
 
const std::vector
< G4MolecularConfiguration * > & 
GetAllSpecies ()
 
std::map< G4String,
G4MolecularConfiguration * > & 
GetUserIDTable ()
 

Static Public Attributes

static G4Mutex fManagerCreationMutex
 

Detailed Description

Definition at line 341 of file G4MolecularConfiguration.hh.

Constructor & Destructor Documentation

G4MolecularConfiguration::G4MolecularConfigurationManager::G4MolecularConfigurationManager ( )
inline

Definition at line 344 of file G4MolecularConfiguration.hh.

344  :
345  fMoleculeCreationMutex()
346  {
347  fLastMoleculeID = -1;
348  }
G4MolecularConfiguration::G4MolecularConfigurationManager::~G4MolecularConfigurationManager ( )

Definition at line 150 of file G4MolecularConfiguration.cc.

151 {
152 // G4cout << "Does G4AllocatorList exists= ";
153 // G4cout << (G4AllocatorList::GetAllocatorListIfExist() ? "true":"false")
154 // << G4endl;
155 
156  G4MolecularConfigurationManager::MolElectronConfTable::iterator it1;
157  G4MolecularConfigurationManager::ElectronOccupancyTable::
158  iterator it2;
159 
160  for (it1 = fElecOccTable.begin(); it1 != fElecOccTable.end(); it1++)
161  {
162  for (it2 = it1->second.begin(); it2 != it1->second.end(); it2++)
163  {
164  if (it2->second)
165  {
166  delete it2->second;
167  }
168  }
169  }
170  fElecOccTable.clear();
171  fgManager = 0;
172 }
static G4MolecularConfigurationManager * fgManager

Member Function Documentation

void G4MolecularConfiguration::G4MolecularConfigurationManager::AddUserID ( const G4String name,
G4MolecularConfiguration molecule 
)

Definition at line 869 of file G4MolecularConfiguration.cc.

871 {
872  UserIDTable::iterator it = fUserIDTable.find(userID);
873 
874  if(it == fUserIDTable.end())
875  {
876  fUserIDTable[userID] = molecule;
877  }
878  else if(molecule != it->second)
879  {
880  // TODO improve exception
881  // exception
882  G4ExceptionDescription description;
883  description << "The user identifier " << userID
884  << " was already given in another configuration in the table"
885  << G4endl;
886  G4Exception("G4MolecularConfiguration::G4MolecularConfigurationManager::AddUserID",
887  "CONF_ALREADY_RECORDED",
889  description);
890  }
891 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

const G4ElectronOccupancy * G4MolecularConfiguration::G4MolecularConfigurationManager::FindCommonElectronOccupancy ( const G4MoleculeDefinition molDef,
const G4ElectronOccupancy eOcc 
)

Definition at line 217 of file G4MolecularConfiguration.cc.

219 {
220  //G4AutoLock lock(&fMoleculeCreationMutex);
221 
222  MolElectronConfTable::iterator it1 = fElecOccTable.find(molDef);
223 
224  if(it1 == fElecOccTable.end())
225  {
226  // TODO = handle exception ?
227  return 0;
228  }
229 
230  ElectronOccupancyTable& table2 = it1->second;
231  ElectronOccupancyTable::iterator it2 = table2.find(eOcc);
232 
233  //lock.unlock();
234 
235  if (it2 == table2.end())
236  {
237  // TODO = handle exception ?
238  return 0;
239  }
240 
241  return &(it2->first);
242 }
const std::vector<G4MolecularConfiguration*>& G4MolecularConfiguration::G4MolecularConfigurationManager::GetAllSpecies ( )
inline

Definition at line 412 of file G4MolecularConfiguration.hh.

413  {
414  return fMolConfPerID;
415  }
G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetMolecularConfiguration ( const G4MoleculeDefinition molDef,
const G4ElectronOccupancy eOcc 
)

Definition at line 248 of file G4MolecularConfiguration.cc.

250 {
251  MolElectronConfTable::iterator it1 = fElecOccTable.find(molDef);
252 
253  if(it1 == fElecOccTable.end()) return 0;
254 
255  ElectronOccupancyTable& table2 = it1->second;
256  ElectronOccupancyTable::iterator it = table2.find(eOcc);
257 
258  if(it == table2.end())
259  {
260  return 0;
261  }
262  else
263  {
264  return it->second;
265  }
266 
267  return 0;
268 }
G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetMolecularConfiguration ( const G4MoleculeDefinition molDef,
int  charge 
)

Definition at line 308 of file G4MolecularConfiguration.cc.

310 {
311  //G4AutoLock lock(&fMoleculeCreationMutex);
312 
313  MolChargeConfTable::iterator it1 = fChargeTable.find(molDef);
314 
315  if(it1 == fChargeTable.end()) return 0;
316 
317  ChargeTable& table2 = it1->second;
318  ChargeTable::iterator it = table2.find(charge);
319 
320  if(it == table2.end())
321  {
322  return 0;
323  }
324  else
325  {
326  return it->second;
327  }
328 
329  return 0;
330 
331  //lock.unlock();
332  return 0;
333 }
G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetMolecularConfiguration ( const G4MoleculeDefinition molDef,
const G4String label 
)

Definition at line 920 of file G4MolecularConfiguration.cc.

922 {
923  //G4AutoLock lock(&fMoleculeCreationMutex);
924 
925  MolLabelConfTable::iterator it1 = fLabelTable.find(molDef);
926 
927  if(it1 == fLabelTable.end()) return 0;
928 
929  LabelTable& table2 = it1->second;
930 
931  LabelTable::iterator it2 = table2.find(label);
932 
933  //lock.unlock();
934 
935  if(it2 == table2.end()) return 0;
936  return it2->second;
937 }
G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetMolecularConfiguration ( int  moleculeID)

Definition at line 943 of file G4MolecularConfiguration.cc.

944 {
945  if(moleculeID > (int) fMolConfPerID.size() ||
946  moleculeID < 0) return 0;
947 
948  return fMolConfPerID[moleculeID];
949 }
G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetMolecularConfiguration ( const G4String userID)

Definition at line 1543 of file G4MolecularConfiguration.cc.

1544 {
1545  for(auto it : fMolConfPerID)
1546  {
1547  if(it->GetUserID() == userID) return it;
1548  }
1549  return 0;
1550 }
int G4MolecularConfiguration::G4MolecularConfigurationManager::GetNumberOfCreatedSpecies ( )
inline

Definition at line 351 of file G4MolecularConfiguration.hh.

352  {
353  return fLastMoleculeID+1;
354  }
G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetOrCreateMolecularConfiguration ( const G4MoleculeDefinition molDef,
const G4ElectronOccupancy eOcc 
)

Definition at line 1320 of file G4MolecularConfiguration.cc.

1322 {
1323  MolElectronConfTable::iterator it1 = fElecOccTable.find(molDef);
1324 
1325  if(it1 == fElecOccTable.end())
1326  {
1327  return new G4MolecularConfiguration(molDef, eOcc);
1328  }
1329 
1330  ElectronOccupancyTable& table2 = it1->second;
1331  ElectronOccupancyTable::iterator it = table2.find(eOcc);
1332 
1333  if(it == table2.end())
1334  {
1335  G4MolecularConfiguration* molConf =
1336  new G4MolecularConfiguration(molDef, eOcc);
1337 // molConf->Finalize();
1338  return molConf;
1339  }
1340  else
1341  {
1342  return it->second;
1343  }
1344 
1345  return 0;
1346 }
G4MolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &, const G4String &label="")
G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetOrCreateMolecularConfiguration ( const G4MoleculeDefinition molDef,
int  charge 
)

Definition at line 1352 of file G4MolecularConfiguration.cc.

1354 {
1355  MolChargeConfTable::iterator it1 = fChargeTable.find(molDef);
1356 
1357  if(it1 == fChargeTable.end())
1358  {
1359  G4AutoLock lock(&fMoleculeCreationMutex);
1360 
1361  G4MolecularConfiguration* newConf = new G4MolecularConfiguration(molDef, charge);
1362  return newConf ;
1363  }
1364 
1365  ChargeTable& table2 = it1->second;
1366  ChargeTable::iterator it = table2.find(charge);
1367 
1368  if(it == table2.end())
1369  {
1370  G4AutoLock lock(&fMoleculeCreationMutex);
1371 
1372  G4MolecularConfiguration* newConf =
1373  new G4MolecularConfiguration(molDef, charge);
1374 // newConf->Finalize();
1375  return newConf ;
1376  }
1377  else
1378  {
1379  return it->second;
1380  }
1381 
1382  return 0;
1383 }
G4MolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &, const G4String &label="")
std::map<G4String, G4MolecularConfiguration*>& G4MolecularConfiguration::G4MolecularConfigurationManager::GetUserIDTable ( )
inline

Definition at line 417 of file G4MolecularConfiguration.hh.

418  {
419  return fUserIDTable;
420  }

Here is the caller graph for this function:

G4int G4MolecularConfiguration::G4MolecularConfigurationManager::Insert ( const G4MoleculeDefinition molDef,
const G4ElectronOccupancy eOcc,
G4MolecularConfiguration molConf 
)

Definition at line 178 of file G4MolecularConfiguration.cc.

181 {
182  //G4AutoLock lock(&fMoleculeCreationMutex);
183 
184  ElectronOccupancyTable& table2 = fElecOccTable[molDef];
185  ElectronOccupancyTable::iterator it = table2.find(eOcc);
186 
187  if(it == table2.end())
188  {
189  table2[eOcc] = molConf;
190  }
191  else
192  {
193  G4ExceptionDescription errMsg;
194  errMsg << "The same molecular configuration seemed to be recorded twice";
195  G4Exception("G4MolecularConfigurationManager::"
196  "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
197  "const G4ElectronOccupancy& eOcc,"
198  "G4MolecularConfiguration* molConf)",
199  "",
201  errMsg
202  );
203  }
204 
205  fLastMoleculeID++;
206 
207  fMolConfPerID.push_back(molConf);
208 
209  //lock.unlock();
210  return fLastMoleculeID;
211 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

G4int G4MolecularConfiguration::G4MolecularConfigurationManager::Insert ( const G4MoleculeDefinition molDef,
int  charge,
G4MolecularConfiguration molConf 
)

Definition at line 273 of file G4MolecularConfiguration.cc.

276 {
277 
278  //G4AutoLock lock(&fMoleculeCreationMutex);
279  ChargeTable& table2 = fChargeTable[molDef];
280  ChargeTable::iterator it = table2.find(charge);
281 
282  if(it == table2.end())
283  {
284  table2[charge] = molConf;
285  }
286  else
287  {
288  //lock.unlock();
289  G4ExceptionDescription errMsg;
290  errMsg << "The same molecular configuration seemed to be recorded twice";
291  G4Exception("G4MolecularConfigurationManager::"
292  "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
293  "int charge,"
294  "G4MolecularConfiguration* molConf)",
295  "", FatalException, errMsg);
296  }
297 
298  fLastMoleculeID++;
299  fMolConfPerID.push_back(molConf);
300  //lock.unlock();
301  return fLastMoleculeID;
302 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

G4int G4MolecularConfiguration::G4MolecularConfigurationManager::Insert ( const G4MoleculeDefinition molDef,
const G4String label,
G4MolecularConfiguration molConf 
)

Definition at line 955 of file G4MolecularConfiguration.cc.

958 {
959  G4AutoLock lock(&fMoleculeCreationMutex);
960  LabelTable& tmpMap = fLabelTable[molDef];
961  LabelTable::iterator it = tmpMap.find(label);
962 
963  if(it == tmpMap.end())
964  {
965  fLastMoleculeID++;
966  tmpMap[label] = molConf;
967  lock.unlock();
968  }
969  else
970  {
971  lock.unlock();
972  G4ExceptionDescription errMsg;
973  errMsg << "The same molecular configuration seemed to be recorded twice";
974  G4Exception("G4MolecularConfigurationManager::"
975  "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
976  "const G4String& label,"
977  "G4MolecularConfiguration* molConf)",
978  "", FatalException, errMsg);
979  }
980 
981  fMolConfPerID.push_back(molConf);
982 
983  return fLastMoleculeID;
984 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

void G4MolecularConfiguration::G4MolecularConfigurationManager::RecordNewlyLabeledConfiguration ( G4MolecularConfiguration molConf)

Definition at line 843 of file G4MolecularConfiguration.cc.

844 {
845  //G4AutoLock lock(&fMoleculeCreationMutex);
846 
847  LabelTable& tmpMap = fLabelTable[molConf->fMoleculeDefinition];
848 
849  LabelTable::iterator it = tmpMap.find(*molConf->fLabel);
850 
851  if(it == tmpMap.end())
852  {
853  tmpMap[*(molConf->fLabel)] = molConf;
854  }
855  else
856  {
857  G4ExceptionDescription errMsg;
858  errMsg << "The same molecular configuration seemed to be recorded twice";
859  G4Exception("G4MolecularConfigurationManager::"
860  "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
861  "const G4String& label,"
862  "G4MolecularConfiguration* molConf)",
863  "", FatalException, errMsg);
864  }
865 
866  //lock.unlock();
867 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4MoleculeDefinition * fMoleculeDefinition

Here is the call graph for this function:

Here is the caller graph for this function:

void G4MolecularConfiguration::G4MolecularConfigurationManager::RemoveMolecularConfigurationFromTable ( G4MolecularConfiguration configuration)

Definition at line 896 of file G4MolecularConfiguration.cc.

897 {
898  MolElectronConfTable::iterator it1 =
899  fElecOccTable.find(configuration->GetDefinition());
900  MolElectronConfTable::iterator end = fElecOccTable.end();
901 
902  if (it1 == end) return;
903 
904  std::map<G4ElectronOccupancy, G4MolecularConfiguration*, comparator>::
905  iterator it2 =
906  it1->second.find(*configuration->GetElectronOccupancy());
907 
908  if (it2 == it1->second.end()) return;
909 
910  it2->second = 0;
911 // it1->second.erase(it2);
912 
913  configuration->fElectronOccupancy = 0;
914 }
const G4ElectronOccupancy * GetElectronOccupancy() const
const G4MoleculeDefinition * GetDefinition() const
const G4ElectronOccupancy * fElectronOccupancy

Here is the call graph for this function:

Member Data Documentation

G4Mutex MolecularConfigurationManager::fManagerCreationMutex
static

Definition at line 408 of file G4MolecularConfiguration.hh.


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