59 if (blmPlacements.empty())
65 for (
const auto& bp : blmPlacements)
67 if (!bp.geometryFile.empty())
76 std::map<G4String, BDSScorerInfo> scorerRecipes;
77 for (
const auto& scorer : scorers)
80 scorerRecipes.insert(std::make_pair(si.
name, si));
83 std::set<std::set<G4String> > scorerSetsToMake;
85 std::map<std::string, std::pair<std::set<G4String>, G4String> >blmScoringInfo;
86 for (
const auto& bp : blmPlacements)
89 std::set<G4String> requiredScorers;
90 for (
const auto& name : scorersForThisBLM)
92 auto search = scorerRecipes.find(name);
93 if (search == scorerRecipes.end())
94 {
throw BDSException(__METHOD_NAME__,
"scorerQuantity \"" + name +
"\" for blm \"" + bp.name +
"\" not found.");}
96 {requiredScorers.insert(name);}
99 if (requiredScorers.empty())
100 {G4cout <<
"Warning - no scoreQuantity specified for blm \"" << bp.name <<
"\" - it will only be passive material" << G4endl;}
101 scorerSetsToMake.insert(requiredScorers);
105 G4String combinedName =
"";
106 for (
const auto& n : requiredScorers)
108 blmScoringInfo[bp.name] = std::make_pair(requiredScorers, combinedName);
111 G4cout <<
"Unqiue combinations of scorers: " << scorerSetsToMake.size() << G4endl;
113 if (scorerSetsToMake.empty())
114 {G4cout <<
"Warning - all BLMs have no scoreQuantity specified so are only passive material." << G4endl;}
118 std::map<G4String, G4MultiFunctionalDetector*> sensitiveDetectors;
119 std::vector<G4String> uniquePrimitiveScorerNames;
120 std::vector<G4double> scorerUnits;
121 G4SDManager* SDMan = G4SDManager::GetSDMpointer();
122 for (
const auto& ssAndCombinedName : blmScoringInfo)
124 G4String combinedName = ssAndCombinedName.second.second;
126 G4cout << __METHOD_NAME__ <<
"Making unique SD " << combinedName << G4endl;
129 if (sensitiveDetectors.count(combinedName) > 0)
132 G4MultiFunctionalDetector* sd =
new G4MultiFunctionalDetector(
"blm_"+combinedName);
133 for (
const auto& name : ssAndCombinedName.second.first)
135 const auto& recipe = scorerRecipes.at(name);
137 G4VPrimitiveScorer* ps = scorerFactory.
CreateScorer(&recipe,
nullptr, &unit);
138 sd->RegisterPrimitive(ps);
142 uniquePrimitiveScorerNames.emplace_back(
"blm_"+combinedName+
"/"+name);
143 scorerUnits.push_back(unit);
145 sensitiveDetectors[combinedName] = sd;
146 SDMan->AddNewDetector(sd);
153 for (
const auto& bp : blmPlacements)
156 const auto& v = blmScoringInfo.at(bp.name);
157 std::set<G4String> requiredScorers = v.first;
158 G4String combinedName = v.second;
160 auto sdSearch = sensitiveDetectors.find(combinedName);
161 if (sdSearch == sensitiveDetectors.end())
162 {
throw BDSException(__METHOD_NAME__,
"unknown set of scorers");}
163 G4MultiFunctionalDetector* sd = sdSearch->second;
165 BDSBLM* blm = factory.CreateBLM(bp, sd);
167 G4double length = blmExtent.
DZ();
169 {
throw BDSException(__METHOD_NAME__,
"BLM: " + bp.name +
" has 0 extent");}
180 if (
BDS::IsFinite(bp.s) && transform == G4Transform3D::Identity)
182 G4String msg =
"the S coordinate (" + std::to_string(bp.s) +
" m) for blm \"" + bp.name;
183 msg +=
"\" was not found in the beam line - please check";
191 G4ThreeVector halfLengthBeg = G4ThreeVector(0,0,-length*0.5);
192 G4ThreeVector halfLengthEnd = G4ThreeVector(0,0, length*0.5);
193 G4ThreeVector midPos = transform.getTranslation();
194 G4ThreeVector startPos = midPos + transform * (HepGeom::Point3D<G4double>)halfLengthBeg;
195 G4ThreeVector endPos = midPos + transform * (HepGeom::Point3D<G4double>)halfLengthEnd;
196 G4RotationMatrix* rm =
new G4RotationMatrix(transform.getRotation());
203 new G4RotationMatrix(*rm),
204 new G4RotationMatrix(*rm),
208 new G4RotationMatrix(*rm),
209 new G4RotationMatrix(*rm),
210 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)