Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 340 of file G4MolecularConfiguration.hh.

Constructor & Destructor Documentation

◆ G4MolecularConfigurationManager()

G4MolecularConfiguration::G4MolecularConfigurationManager::G4MolecularConfigurationManager ( )
inline

Definition at line 343 of file G4MolecularConfiguration.hh.

343 :
344 fMoleculeCreationMutex()
345 {
346 fLastMoleculeID = -1;
347 }

◆ ~G4MolecularConfigurationManager()

G4MolecularConfiguration::G4MolecularConfigurationManager::~G4MolecularConfigurationManager ( )

Definition at line 148 of file G4MolecularConfiguration.cc.

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

Member Function Documentation

◆ AddUserID()

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

Definition at line 868 of file G4MolecularConfiguration.cc.

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

Referenced by G4MolecularConfiguration::CreateMolecularConfiguration(), and G4MolecularConfiguration::SetUserID().

◆ FindCommonElectronOccupancy()

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

Definition at line 215 of file G4MolecularConfiguration.cc.

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

Referenced by G4MolecularConfiguration::G4MolecularConfiguration().

◆ GetAllSpecies()

const std::vector< G4MolecularConfiguration * > & G4MolecularConfiguration::G4MolecularConfigurationManager::GetAllSpecies ( )
inline

Definition at line 408 of file G4MolecularConfiguration.hh.

409 {
410 return fMolConfPerID;
411 }

Referenced by G4MolecularConfiguration::FinalizeAll().

◆ GetMolecularConfiguration() [1/5]

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

Definition at line 246 of file G4MolecularConfiguration.cc.

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

Referenced by G4MolecularConfiguration::ChangeConfiguration(), G4MolecularConfiguration::CreateMolecularConfiguration(), G4MolecularConfiguration::GetMolecularConfiguration(), and G4MolecularConfiguration::GetOrCreateMolecularConfiguration().

◆ GetMolecularConfiguration() [2/5]

G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetMolecularConfiguration ( const G4MoleculeDefinition molDef,
const G4String label 
)

Definition at line 918 of file G4MolecularConfiguration.cc.

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

◆ GetMolecularConfiguration() [3/5]

G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetMolecularConfiguration ( const G4MoleculeDefinition molDef,
int  charge 
)

Definition at line 306 of file G4MolecularConfiguration.cc.

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

◆ GetMolecularConfiguration() [4/5]

G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetMolecularConfiguration ( const G4String userID)

Definition at line 1541 of file G4MolecularConfiguration.cc.

1543{
1544 for(auto it : fMolConfPerID)
1545 {
1546 if(it->GetUserID() == userID) return it;
1547 }
1548 return 0;
1549}

◆ GetMolecularConfiguration() [5/5]

G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetMolecularConfiguration ( int  moleculeID)

Definition at line 941 of file G4MolecularConfiguration.cc.

943{
944 if(moleculeID > (int) fMolConfPerID.size() ||
945 moleculeID < 0) return 0;
946
947 return fMolConfPerID[moleculeID];
948}

◆ GetNumberOfCreatedSpecies()

int G4MolecularConfiguration::G4MolecularConfigurationManager::GetNumberOfCreatedSpecies ( )
inline

Definition at line 350 of file G4MolecularConfiguration.hh.

351 {
352 return fLastMoleculeID+1;
353 }

Referenced by G4MolecularConfiguration::GetNumberOfSpecies().

◆ GetOrCreateMolecularConfiguration() [1/2]

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

Definition at line 1318 of file G4MolecularConfiguration.cc.

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

Referenced by G4MolecularConfiguration::GetOrCreateMolecularConfiguration().

◆ GetOrCreateMolecularConfiguration() [2/2]

G4MolecularConfiguration * G4MolecularConfiguration::G4MolecularConfigurationManager::GetOrCreateMolecularConfiguration ( const G4MoleculeDefinition molDef,
int  charge 
)

Definition at line 1350 of file G4MolecularConfiguration.cc.

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

◆ GetUserIDTable()

std::map< G4String, G4MolecularConfiguration * > & G4MolecularConfiguration::G4MolecularConfigurationManager::GetUserIDTable ( )
inline

Definition at line 413 of file G4MolecularConfiguration.hh.

414 {
415 return fUserIDTable;
416 }

Referenced by G4MolecularConfiguration::GetUserIDTable().

◆ Insert() [1/3]

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

Definition at line 175 of file G4MolecularConfiguration.cc.

180{
181 //G4AutoLock lock(&fMoleculeCreationMutex);
182
183 ElectronOccupancyTable& table2 = fElecOccTable[molDef];
184 ElectronOccupancyTable::iterator it = table2.find(eOcc);
185
186 if(it == table2.end())
187 {
188 table2[eOcc] = molConf;
189 }
190 else
191 {
193 errMsg << "The same molecular configuration seemed to be recorded twice";
194 G4Exception("G4MolecularConfigurationManager::"
195 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
196 "const G4ElectronOccupancy& eOcc,"
197 "G4MolecularConfiguration* molConf)",
198 "",
200 errMsg
201 );
202 }
203
204 fLastMoleculeID++;
205
206 fMolConfPerID.push_back(molConf);
207
208 //lock.unlock();
209 return fLastMoleculeID;
210}

Referenced by G4MolecularConfiguration::G4MolecularConfiguration().

◆ Insert() [2/3]

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

Definition at line 953 of file G4MolecularConfiguration.cc.

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

◆ Insert() [3/3]

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

Definition at line 271 of file G4MolecularConfiguration.cc.

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

◆ RecordNewlyLabeledConfiguration()

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

Definition at line 841 of file G4MolecularConfiguration.cc.

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

Referenced by G4MolecularConfiguration::G4MolecularConfiguration(), and G4MolecularConfiguration::SetLabel().

◆ RemoveMolecularConfigurationFromTable()

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

Definition at line 894 of file G4MolecularConfiguration.cc.

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

Referenced by G4MolecularConfiguration::~G4MolecularConfiguration().

Member Data Documentation

◆ fManagerCreationMutex

G4Mutex MolecularConfigurationManager::fManagerCreationMutex
static

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