Geant4 11.1.1
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 342 of file G4MolecularConfiguration.hh.

Constructor & Destructor Documentation

◆ G4MolecularConfigurationManager()

G4MolecularConfiguration::G4MolecularConfigurationManager::G4MolecularConfigurationManager ( )
inline

Definition at line 345 of file G4MolecularConfiguration.hh.

345 :
346 fMoleculeCreationMutex()
347 {
348 fLastMoleculeID = -1;
349 }

◆ ~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 852 of file G4MolecularConfiguration.cc.

854{
855 UserIDTable::iterator it = fUserIDTable.find(userID);
856
857 if(it == fUserIDTable.end())
858 {
859 fUserIDTable[userID] = molecule;
860 }
861 else if(molecule != it->second)
862 {
863 // TODO improve exception
864 // exception
865 G4ExceptionDescription description;
866 description << "The user identifier " << userID
867 << " was already given in another configuration in the table"
868 << G4endl;
869 G4Exception("G4MolecularConfiguration::G4MolecularConfigurationManager::AddUserID",
870 "CONF_ALREADY_RECORDED",
872 description);
873 }
874}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
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 410 of file G4MolecularConfiguration.hh.

411 {
412 return fMolConfPerID;
413 }

Referenced by G4MolecularConfiguration::FinalizeAll(), and G4MolecularConfiguration::PrintAll().

◆ 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 902 of file G4MolecularConfiguration.cc.

905{
906 //G4AutoLock lock(&fMoleculeCreationMutex);
907
908 MolLabelConfTable::iterator it1 = fLabelTable.find(molDef);
909
910 if(it1 == fLabelTable.end()) return 0;
911
912 LabelTable& table2 = it1->second;
913
914 LabelTable::iterator it2 = table2.find(label);
915
916 //lock.unlock();
917
918 if(it2 == table2.end()) return 0;
919 return it2->second;
920}

◆ 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 1525 of file G4MolecularConfiguration.cc.

1527{
1528 for(auto it : fMolConfPerID)
1529 {
1530 if(it->GetUserID() == userID) return it;
1531 }
1532 return 0;
1533}

◆ GetMolecularConfiguration() [5/5]

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

Definition at line 925 of file G4MolecularConfiguration.cc.

927{
928 if(moleculeID > (int) fMolConfPerID.size() ||
929 moleculeID < 0) return 0;
930
931 return fMolConfPerID[moleculeID];
932}

◆ GetNumberOfCreatedSpecies()

int G4MolecularConfiguration::G4MolecularConfigurationManager::GetNumberOfCreatedSpecies ( )
inline

Definition at line 352 of file G4MolecularConfiguration.hh.

353 {
354 return fLastMoleculeID+1;
355 }

Referenced by G4MolecularConfiguration::GetNumberOfSpecies().

◆ GetOrCreateMolecularConfiguration() [1/2]

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

Definition at line 1302 of file G4MolecularConfiguration.cc.

1305{
1306 MolElectronConfTable::iterator it1 = fElecOccTable.find(molDef);
1307
1308 if(it1 == fElecOccTable.end())
1309 {
1310 return new G4MolecularConfiguration(molDef, eOcc);
1311 }
1312
1313 ElectronOccupancyTable& table2 = it1->second;
1314 ElectronOccupancyTable::iterator it = table2.find(eOcc);
1315
1316 if(it == table2.end())
1317 {
1318 G4MolecularConfiguration* molConf =
1319 new G4MolecularConfiguration(molDef, eOcc);
1320// molConf->Finalize();
1321 return molConf;
1322 }
1323 else
1324 {
1325 return it->second;
1326 }
1327
1328 return 0;
1329}

Referenced by G4MolecularConfiguration::GetOrCreateMolecularConfiguration().

◆ GetOrCreateMolecularConfiguration() [2/2]

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

Definition at line 1334 of file G4MolecularConfiguration.cc.

1337{
1338 MolChargeConfTable::iterator it1 = fChargeTable.find(molDef);
1339
1340 if(it1 == fChargeTable.end())
1341 {
1342 G4AutoLock lock(&fMoleculeCreationMutex);
1343
1344 G4MolecularConfiguration* newConf = new G4MolecularConfiguration(molDef, charge);
1345 return newConf ;
1346 }
1347
1348 ChargeTable& table2 = it1->second;
1349 ChargeTable::iterator it = table2.find(charge);
1350
1351 if(it == table2.end())
1352 {
1353 G4AutoLock lock(&fMoleculeCreationMutex);
1354
1355 G4MolecularConfiguration* newConf =
1356 new G4MolecularConfiguration(molDef, charge);
1357// newConf->Finalize();
1358 return newConf ;
1359 }
1360 else
1361 {
1362 return it->second;
1363 }
1364
1365 return 0;
1366}

◆ GetUserIDTable()

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

Definition at line 415 of file G4MolecularConfiguration.hh.

416 {
417 return fUserIDTable;
418 }

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 937 of file G4MolecularConfiguration.cc.

941{
942 G4AutoLock lock(&fMoleculeCreationMutex);
943 LabelTable& tmpMap = fLabelTable[molDef];
944 LabelTable::iterator it = tmpMap.find(label);
945
946 if(it == tmpMap.end())
947 {
948 fLastMoleculeID++;
949 tmpMap[label] = molConf;
950 lock.unlock();
951 }
952 else
953 {
954 lock.unlock();
956 errMsg << "The same molecular configuration seemed to be recorded twice";
957 G4Exception("G4MolecularConfigurationManager::"
958 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
959 "const G4String& label,"
960 "G4MolecularConfiguration* molConf)",
961 "", FatalException, errMsg);
962 }
963
964 fMolConfPerID.push_back(molConf);
965
966 return fLastMoleculeID;
967}

◆ 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 825 of file G4MolecularConfiguration.cc.

827{
828 //G4AutoLock lock(&fMoleculeCreationMutex);
829
830 LabelTable& tmpMap = fLabelTable[molConf->fMoleculeDefinition];
831
832 LabelTable::iterator it = tmpMap.find(*molConf->fLabel);
833
834 if(it == tmpMap.end())
835 {
836 tmpMap[*(molConf->fLabel)] = molConf;
837 }
838 else
839 {
841 errMsg << "The same molecular configuration seemed to be recorded twice";
842 G4Exception("G4MolecularConfigurationManager::"
843 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
844 "const G4String& label,"
845 "G4MolecularConfiguration* molConf)",
846 "", FatalException, errMsg);
847 }
848
849 //lock.unlock();
850}
const G4MoleculeDefinition * fMoleculeDefinition

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

◆ RemoveMolecularConfigurationFromTable()

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

Definition at line 878 of file G4MolecularConfiguration.cc.

880{
881 MolElectronConfTable::iterator it1 =
882 fElecOccTable.find(configuration->GetDefinition());
883 MolElectronConfTable::iterator end = fElecOccTable.end();
884
885 if (it1 == end) return;
886
887 std::map<G4ElectronOccupancy, G4MolecularConfiguration*, comparator>::
888 iterator it2 =
889 it1->second.find(*configuration->GetElectronOccupancy());
890
891 if (it2 == it1->second.end()) return;
892
893 it2->second = 0;
894// it1->second.erase(it2);
895
896 configuration->fElectronOccupancy = 0;
897}
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: