98{
99 using FMtoFMmap = std::map<G4FieldManager*, G4FieldManager*>;
100 using FMpair = std::pair<G4FieldManager*, G4FieldManager*>;
101
102 FMtoFMmap masterToWorker;
104 for (const auto& g4LogicalVolume : *logVolStore) {
105
106 G4FieldManager* masterFM = nullptr;
107 G4FieldManager* clonedFM = nullptr;
108 if (masterFM != nullptr) {
109 auto fmFound = masterToWorker.find(masterFM);
110 if (fmFound == masterToWorker.cend()) {
111
112 try {
113 auto insertedEl = masterToWorker.insert(FMpair(masterFM, masterFM->
Clone()));
114 clonedFM = (insertedEl.first)->second;
115 }
116 catch (...) {
118 msg << "Cloning of G4FieldManager failed."
119 << " But derived class does not implement cloning. Cannot "
120 "continue.";
122 }
123 }
124 else {
125
126
127 clonedFM = (*fmFound).second;
128 }
129 }
130
131
132
133
134
135 g4LogicalVolume->SetFieldManager(clonedFM, false);
136 }
137}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
virtual G4FieldManager * Clone() const
static G4LogicalVolumeStore * GetInstance()