60 if (blmPlacements.empty())
66 for (
const auto& bp : blmPlacements)
68 if (!bp.geometryFile.empty())
77 std::map<G4String, BDSScorerInfo> scorerRecipes;
78 for (
const auto& scorer : scorers)
81 scorerRecipes.insert(std::make_pair(si.
name, si));
84 std::set<std::set<G4String> > scorerSetsToMake;
86 std::map<std::string, std::pair<std::set<G4String>, G4String> >blmScoringInfo;
87 for (
const auto& bp : blmPlacements)
90 std::set<G4String> requiredScorers;
91 for (
const auto& name : scorersForThisBLM)
93 auto search = scorerRecipes.find(name);
94 if (search == scorerRecipes.end())
95 {
throw BDSException(__METHOD_NAME__,
"scorerQuantity \"" + name +
"\" for blm \"" + bp.name +
"\" not found.");}
97 {requiredScorers.insert(name);}
100 if (requiredScorers.empty())
101 {G4cout <<
"Warning - no scoreQuantity specified for blm \"" << bp.name <<
"\" - it will only be passive material" << G4endl;}
102 scorerSetsToMake.insert(requiredScorers);
106 G4String combinedName =
"";
107 for (
const auto& n : requiredScorers)
109 blmScoringInfo[bp.name] = std::make_pair(requiredScorers, combinedName);
112 G4cout <<
"Unqiue combinations of scorers: " << scorerSetsToMake.size() << G4endl;
114 if (scorerSetsToMake.empty())
115 {G4cout <<
"Warning - all BLMs have no scoreQuantity specified so are only passive material." << G4endl;}
119 std::map<G4String, G4MultiFunctionalDetector*> sensitiveDetectors;
120 std::vector<G4String> uniquePrimitiveScorerNames;
121 std::vector<G4double> scorerUnits;
122 G4SDManager* SDMan = G4SDManager::GetSDMpointer();
123 for (
const auto& ssAndCombinedName : blmScoringInfo)
125 G4String combinedName = ssAndCombinedName.second.second;
127 G4cout << __METHOD_NAME__ <<
"Making unique SD " << combinedName << G4endl;
130 if (sensitiveDetectors.count(combinedName) > 0)
133 G4MultiFunctionalDetector* sd =
new G4MultiFunctionalDetector(
"blm_"+combinedName);
134 for (
const auto& name : ssAndCombinedName.second.first)
136 const auto& recipe = scorerRecipes.at(name);
138 G4VPrimitiveScorer* ps = scorerFactory.
CreateScorer(&recipe,
nullptr, &unit);
139 sd->RegisterPrimitive(ps);
143 uniquePrimitiveScorerNames.emplace_back(
"blm_"+combinedName+
"/"+name);
144 scorerUnits.push_back(unit);
146 sensitiveDetectors[combinedName] = sd;
147 SDMan->AddNewDetector(sd);
154 for (
const auto& bp : blmPlacements)
157 const auto& v = blmScoringInfo.at(bp.name);
158 std::set<G4String> requiredScorers = v.first;
159 G4String combinedName = v.second;
161 auto sdSearch = sensitiveDetectors.find(combinedName);
162 if (sdSearch == sensitiveDetectors.end())
163 {
throw BDSException(__METHOD_NAME__,
"unknown set of scorers");}
164 G4MultiFunctionalDetector* sd = sdSearch->second;
166 BDSBLM* blm = factory.CreateBLM(bp, sd);
168 G4double length = blmExtent.
DZ();
170 {
throw BDSException(__METHOD_NAME__,
"BLM: " + bp.name +
" has 0 extent");}
181 if (
BDS::IsFinite(bp.s) && transform == G4Transform3D::Identity)
183 G4String msg =
"the S coordinate (" + std::to_string(bp.s) +
" m) for blm \"" + bp.name;
184 msg +=
"\" was not found in the beam line - please check";
192 G4ThreeVector halfLengthBeg = G4ThreeVector(0,0,-length*0.5);
193 G4ThreeVector halfLengthEnd = G4ThreeVector(0,0, length*0.5);
194 G4ThreeVector midPos = transform.getTranslation();
195 G4ThreeVector startPos = midPos + transform * (HepGeom::Point3D<G4double>)halfLengthBeg;
196 G4ThreeVector endPos = midPos + transform * (HepGeom::Point3D<G4double>)halfLengthEnd;
197 G4RotationMatrix* rm =
new G4RotationMatrix(transform.getRotation());
204 new G4RotationMatrix(*rm),
205 new G4RotationMatrix(*rm),
209 new G4RotationMatrix(*rm),
210 new G4RotationMatrix(*rm),
211 new G4RotationMatrix(*rm),
BDSGeometryExternal * BuildGeometry(G4String componentName, const G4String &formatAndFilePath, std::map< G4String, G4Colour * > *colourMapping=nullptr, G4bool autoColour=true, G4double suggestedLength=0, G4double suggestedHorizontalWidth=0, std::vector< G4String > *namedVacuumVolumes=nullptr, G4bool makeSensitive=true, BDSSDType sensitivityType=BDSSDType::energydep, BDSSDType vacuumSensitivityType=BDSSDType::energydepvacuum, G4bool stripOuterVolumeAndMakeAssembly=false, G4UserLimits *userLimitsToAttachToAllLVs=nullptr, G4bool dontReloadGeometry=false)