60 auto pwItr = std::find(parallelWorld.cbegin(), parallelWorld.cend(), aPW);
61 if (pwItr != parallelWorld.cend())
65 eM +=
"> is already registered to the user detector construction.";
66 G4Exception(
"G4VUserDetectorConstruction::RegisterParallelWorld",
69 parallelWorld.push_back(aPW);
76 for(
auto pwItr = parallelWorld.cbegin();
77 pwItr != parallelWorld.cend(); ++pwItr)
79 (*pwItr)->Construct();
88 for(
auto pwItr = parallelWorld.cbegin();
89 pwItr != parallelWorld.cend(); ++pwItr)
91 (*pwItr)->ConstructSD();
98 return (
G4int)parallelWorld.size();
107 return parallelWorld[i];
128 using FMtoFMmap = std::map<G4FieldManager*, G4FieldManager*>;
129 using FMpair = std::pair<G4FieldManager*, G4FieldManager*>;
131 FMtoFMmap masterToWorker;
133 for(
auto it = logVolStore->cbegin(); it != logVolStore->cend(); ++it)
139 if(masterFM !=
nullptr)
141 auto fmFound = masterToWorker.find(masterFM);
142 if(fmFound == masterToWorker.cend())
148 masterToWorker.insert(FMpair(masterFM, masterFM->
Clone()));
149 clonedFM = (insertedEl.first)->second;
153 msg <<
"Cloning of G4FieldManager failed."
154 <<
" But derived class does not implement cloning. Cannot "
156 G4Exception(
"G4VUserDetectorConstruction::CloneSD()",
"Run0053",
164 clonedFM = (*fmFound).second;
182 using SDtoSDmap = std::map<G4VSensitiveDetector*, G4VSensitiveDetector*>;
183 using SDpair = std::pair<G4VSensitiveDetector*, G4VSensitiveDetector*>;
184 SDtoSDmap masterToWorker;
186 for(
auto it = logVolStore->cbegin(); it != logVolStore->cend(); ++it)
192 if(masterSD !=
nullptr)
194 auto sdFound = masterToWorker.find(masterSD);
195 if(sdFound == masterToWorker.cend())
201 masterToWorker.insert(SDpair(masterSD, masterSD->
Clone()));
202 clonedSD = (insertedEl.first)->second;
206 msg <<
"Cloning of G4VSensitiveDetector requested for:"
211 <<
" But derived class does not implement cloning. Cannot "
213 G4Exception(
"G4VUserDetectorConstruction::CloneSD()",
"Run0053",
221 clonedSD = (*sdFound).second;
235 auto volmap = store->
GetMap();
236 auto pos = volmap.find(logVolName);
237 if(pos != volmap.cend())
239 if ((pos->second.size()>1) && !multi)
241 G4String eM =
"More than one logical volumes of name <";
243 eM +=
"> are found and thus the sensitive detector <";
245 eM +=
"> cannot be uniquely assigned.";
246 G4Exception(
"G4VUserDetectorConstruction::SetSensitiveDetector()",
250 for (std::size_t i = 0; i < pos->second.size(); ++i)
257 G4String eM2 =
"No logical volume of name <";
259 eM2 +=
"> is found. The specified sensitive detector <";
261 eM2 +=
"> couldn't be assigned to any volume.";
262 G4Exception(
"G4VUserDetectorConstruction::SetSensitiveDetector()",
271 assert(logVol !=
nullptr && aSD !=
nullptr);
281 if(originalSD == aSD)
284 msg <<
"Attempting to add multiple times the same sensitive detector (\"";
285 msg << originalSD->
GetName() <<
"\") is not allowed, skipping.";
286 G4Exception(
"G4VUserDetectorConstruction::SetSensitiveDetector",
"Run0054",
290 if(originalSD ==
nullptr)
304 std::ostringstream mn;
305 mn <<
"/MultiSD_" << logVol->
GetName() <<
"_" << logVol;
310 msd->
AddSD(originalSD);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
virtual G4FieldManager * Clone() const
const std::map< G4String, std::vector< G4LogicalVolume * > > & GetMap() const
static G4LogicalVolumeStore * GetInstance()
void SetFieldManager(G4FieldManager *pFieldMgr, G4bool forceToAllDaughters)
G4VSensitiveDetector * GetSensitiveDetector() const
const G4String & GetName() const
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
void AddSD(G4VSensitiveDetector *sd)
static G4SDManager * GetSDMpointer()
void AddNewDetector(G4VSensitiveDetector *aSD)
virtual G4VSensitiveDetector * Clone() const
G4String GetFullPathName() const
G4int GetNumberOfParallelWorld() const
G4VUserParallelWorld * GetParallelWorld(G4int i) const
void RegisterParallelWorld(G4VUserParallelWorld *)
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
virtual void ConstructSDandField()
virtual ~G4VUserDetectorConstruction()
G4int ConstructParallelGeometries()
void ConstructParallelSD()
G4VUserDetectorConstruction()
const G4String & GetName()