Geant4 11.2.2
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 339 of file G4MolecularConfiguration.hh.

Constructor & Destructor Documentation

◆ G4MolecularConfigurationManager()

G4MolecularConfiguration::G4MolecularConfigurationManager::G4MolecularConfigurationManager ( )
inline

Definition at line 342 of file G4MolecularConfiguration.hh.

343 {
344 fLastMoleculeID = -1;
345 }

◆ ~G4MolecularConfigurationManager()

G4MolecularConfiguration::G4MolecularConfigurationManager::~G4MolecularConfigurationManager ( )

Definition at line 147 of file G4MolecularConfiguration.cc.

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

Member Function Documentation

◆ AddUserID()

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

Definition at line 833 of file G4MolecularConfiguration.cc.

835{
836 auto it = fUserIDTable.find(userID);
837
838 if(it == fUserIDTable.end())
839 {
840 fUserIDTable[userID] = molecule;
841 }
842 else if(molecule != it->second)
843 {
844 // TODO improve exception
845 // exception
846 G4ExceptionDescription description;
847 description << "The user identifier " << userID
848 << " was already given in another configuration in the table"
849 << G4endl;
850 G4Exception("G4MolecularConfiguration::G4MolecularConfigurationManager::AddUserID",
851 "CONF_ALREADY_RECORDED",
853 description);
854 }
855}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4endl
Definition G4ios.hh:67

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

◆ FindCommonElectronOccupancy()

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

Definition at line 214 of file G4MolecularConfiguration.cc.

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

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

◆ GetAllSpecies()

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

Definition at line 406 of file G4MolecularConfiguration.hh.

407 {
408 return fMolConfPerID;
409 }

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

◆ GetMolecularConfiguration() [1/5]

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

◆ GetMolecularConfiguration() [2/5]

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

Definition at line 882 of file G4MolecularConfiguration.cc.

885{
886 //G4AutoLock lock(&fMoleculeCreationMutex);
887
888 auto it1 = fLabelTable.find(molDef);
889
890 if(it1 == fLabelTable.end()) return nullptr;
891
892 LabelTable& table2 = it1->second;
893
894 auto it2 = table2.find(label);
895
896 //lock.unlock();
897
898 if(it2 == table2.end()) return nullptr;
899 return it2->second;
900}

◆ GetMolecularConfiguration() [3/5]

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

Definition at line 301 of file G4MolecularConfiguration.cc.

304{
305 //G4AutoLock lock(&fMoleculeCreationMutex);
306
307 auto it1 = fChargeTable.find(molDef);
308
309 if(it1 == fChargeTable.end()) return nullptr;
310
311 ChargeTable& table2 = it1->second;
312 auto it = table2.find(charge);
313
314 if(it == table2.end())
315 {
316 return nullptr;
317 }
318
319 return it->second;
320
321}

◆ GetMolecularConfiguration() [4/5]

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

Definition at line 1491 of file G4MolecularConfiguration.cc.

1493{
1494 for(auto it : fMolConfPerID)
1495 {
1496 if(it->GetUserID() == userID) return it;
1497 }
1498 return nullptr;
1499}

◆ GetMolecularConfiguration() [5/5]

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

Definition at line 905 of file G4MolecularConfiguration.cc.

907{
908 if(moleculeID > (int) fMolConfPerID.size() ||
909 moleculeID < 0) return nullptr;
910
911 return fMolConfPerID[moleculeID];
912}

◆ GetNumberOfCreatedSpecies()

int G4MolecularConfiguration::G4MolecularConfigurationManager::GetNumberOfCreatedSpecies ( )
inline

Definition at line 348 of file G4MolecularConfiguration.hh.

349 {
350 return fLastMoleculeID+1;
351 }

Referenced by G4MolecularConfiguration::GetNumberOfSpecies().

◆ GetOrCreateMolecularConfiguration() [1/2]

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

Definition at line 1276 of file G4MolecularConfiguration.cc.

1279{
1280 auto it1 = fElecOccTable.find(molDef);
1281
1282 if(it1 == fElecOccTable.end())
1283 {
1284 return new G4MolecularConfiguration(molDef, eOcc);
1285 }
1286
1287 ElectronOccupancyTable& table2 = it1->second;
1288 auto it = table2.find(eOcc);
1289
1290 if(it == table2.end())
1291 {
1292 auto molConf =
1293 new G4MolecularConfiguration(molDef, eOcc);
1294// molConf->Finalize();
1295 return molConf;
1296 }
1297
1298 return it->second;
1299}
G4MolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &, const G4String &label="")

Referenced by G4MolecularConfiguration::GetOrCreateMolecularConfiguration().

◆ GetOrCreateMolecularConfiguration() [2/2]

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

Definition at line 1304 of file G4MolecularConfiguration.cc.

1307{
1308 auto it1 = fChargeTable.find(molDef);
1309
1310 if(it1 == fChargeTable.end())
1311 {
1312 G4AutoLock lock(&fMoleculeCreationMutex);
1313
1314 auto newConf = new G4MolecularConfiguration(molDef, charge);
1315 return newConf ;
1316 }
1317
1318 ChargeTable& table2 = it1->second;
1319 auto it = table2.find(charge);
1320
1321 if(it == table2.end())
1322 {
1323 G4AutoLock lock(&fMoleculeCreationMutex);
1324
1325 auto newConf =
1326 new G4MolecularConfiguration(molDef, charge);
1327// newConf->Finalize();
1328 return newConf ;
1329 }
1330
1331 return it->second;
1332}

◆ GetUserIDTable()

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

Definition at line 411 of file G4MolecularConfiguration.hh.

412 {
413 return fUserIDTable;
414 }

Referenced by G4MolecularConfiguration::GetUserIDTable().

◆ Insert() [1/3]

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

Definition at line 174 of file G4MolecularConfiguration.cc.

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

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

◆ Insert() [2/3]

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

Definition at line 917 of file G4MolecularConfiguration.cc.

921{
922 G4AutoLock lock(&fMoleculeCreationMutex);
923 LabelTable& tmpMap = fLabelTable[molDef];
924 auto it = tmpMap.find(label);
925
926 if(it == tmpMap.end())
927 {
928 fLastMoleculeID++;
929 tmpMap[label] = molConf;
930 lock.unlock();
931 }
932 else
933 {
934 lock.unlock();
936 errMsg << "The same molecular configuration seemed to be recorded twice";
937 G4Exception("G4MolecularConfigurationManager::"
938 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
939 "const G4String& label,"
940 "G4MolecularConfiguration* molConf)",
941 "", FatalException, errMsg);
942 }
943
944 fMolConfPerID.push_back(molConf);
945
946 return fLastMoleculeID;
947}

◆ Insert() [3/3]

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

Definition at line 266 of file G4MolecularConfiguration.cc.

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

◆ RecordNewlyLabeledConfiguration()

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

Definition at line 806 of file G4MolecularConfiguration.cc.

808{
809 //G4AutoLock lock(&fMoleculeCreationMutex);
810
811 LabelTable& tmpMap = fLabelTable[molConf->fMoleculeDefinition];
812
813 auto it = tmpMap.find(*molConf->fLabel);
814
815 if(it == tmpMap.end())
816 {
817 tmpMap[*(molConf->fLabel)] = molConf;
818 }
819 else
820 {
822 errMsg << "The same molecular configuration seemed to be recorded twice";
823 G4Exception("G4MolecularConfigurationManager::"
824 "SetMolecularConfiguration(const G4MoleculeDefinition* molDef,"
825 "const G4String& label,"
826 "G4MolecularConfiguration* molConf)",
827 "", FatalException, errMsg);
828 }
829
830 //lock.unlock();
831}
const G4MoleculeDefinition * fMoleculeDefinition

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

◆ RemoveMolecularConfigurationFromTable()

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

Definition at line 859 of file G4MolecularConfiguration.cc.

861{
862 auto it1 =
863 fElecOccTable.find(configuration->GetDefinition());
864 auto end = fElecOccTable.end();
865
866 if (it1 == end) return;
867
868 auto it2 =
869 it1->second.find(*configuration->GetElectronOccupancy());
870
871 if (it2 == it1->second.end()) return;
872
873 it2->second = 0;
874// it1->second.erase(it2);
875
876 configuration->fElectronOccupancy = nullptr;
877}
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: