50 auto pwItr = std::find(parallelWorld.cbegin(), parallelWorld.cend(), aPW);
51 if (pwItr != parallelWorld.cend()) {
54 eM +=
"> is already registered to the user detector construction.";
55 G4Exception(
"G4VUserDetectorConstruction::RegisterParallelWorld",
"Run0051",
58 parallelWorld.push_back(aPW);
65 for (
const auto& pwItr : parallelWorld) {
75 for (
const auto& pwItr : parallelWorld) {
83 return (
G4int)parallelWorld.size();
90 return parallelWorld[i];
99 using FMtoFMmap = std::map<G4FieldManager*, G4FieldManager*>;
100 using FMpair = std::pair<G4FieldManager*, G4FieldManager*>;
102 FMtoFMmap masterToWorker;
104 for (
const auto& g4LogicalVolume : *logVolStore) {
108 if (masterFM !=
nullptr) {
109 auto fmFound = masterToWorker.find(masterFM);
110 if (fmFound == masterToWorker.cend()) {
113 auto insertedEl = masterToWorker.insert(FMpair(masterFM, masterFM->
Clone()));
114 clonedFM = (insertedEl.first)->second;
118 msg <<
"Cloning of G4FieldManager failed."
119 <<
" But derived class does not implement cloning. Cannot "
127 clonedFM = (*fmFound).second;
135 g4LogicalVolume->SetFieldManager(clonedFM,
false);
145 using SDtoSDmap = std::map<G4VSensitiveDetector*, G4VSensitiveDetector*>;
146 using SDpair = std::pair<G4VSensitiveDetector*, G4VSensitiveDetector*>;
147 SDtoSDmap masterToWorker;
149 for (
const auto& g4LogicalVolume : *logVolStore) {
153 if (masterSD !=
nullptr) {
154 auto sdFound = masterToWorker.find(masterSD);
155 if (sdFound == masterToWorker.cend()) {
158 auto insertedEl = masterToWorker.insert(SDpair(masterSD, masterSD->
Clone()));
159 clonedSD = (insertedEl.first)->second;
163 msg <<
"Cloning of G4VSensitiveDetector requested for:" << masterSD->
GetName() <<
"\n"
167 <<
" But derived class does not implement cloning. Cannot "
175 clonedSD = (*sdFound).second;
178 g4LogicalVolume->SetSensitiveDetector(clonedSD);
188 auto volmap = store->
GetMap();
189 auto pos = volmap.find(logVolName);
190 if (pos != volmap.cend()) {
191 if ((pos->second.size() > 1) && !multi) {
192 G4String eM =
"More than one logical volumes of name <";
194 eM +=
"> are found and thus the sensitive detector <";
196 eM +=
"> cannot be uniquely assigned.";
197 G4Exception(
"G4VUserDetectorConstruction::SetSensitiveDetector()",
"Run0052",
201 for (
auto& i : pos->second) {
206 G4String eM2 =
"No logical volume of name <";
208 eM2 +=
"> is found. The specified sensitive detector <";
210 eM2 +=
"> couldn't be assigned to any volume.";
211 G4Exception(
"G4VUserDetectorConstruction::SetSensitiveDetector()",
"Run0053",
220 assert(logVol !=
nullptr && aSD !=
nullptr);
230 if (originalSD == aSD) {
232 msg <<
"Attempting to add multiple times the same sensitive detector (\"";
233 msg << originalSD->
GetName() <<
"\") is not allowed, skipping.";
237 if (originalSD ==
nullptr) {
242 if (msd !=
nullptr) {
246 std::ostringstream mn;
247 mn <<
"/MultiSD_" << logVol->
GetName() <<
"_" << logVol;
252 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()
G4VSensitiveDetector * GetSensitiveDetector() const
const G4String & GetName() const
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
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()
G4int ConstructParallelGeometries()
void ConstructParallelSD()
const G4String & GetName()