Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions GeometryService/inc/ProductionTargetMaker.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <functional>

namespace mu2e { class SimpleConfig; }
namespace mu2e { class ProductionTarget; }
Expand All @@ -14,15 +16,20 @@ namespace mu2e {
class ProductionTargetMaker {
public:

// Registry map for model makers — allows scaling without modifying make()
using MakerFunction = std::function<std::unique_ptr<ProductionTarget>(const SimpleConfig&, double)>;
static const std::map<std::string, MakerFunction>& getMakerRegistry();

static std::unique_ptr<ProductionTarget> make(const SimpleConfig& config, double solenoidOffset);
static const int tier1{1};
// version 2 is the low density hayman
static const int hayman_v_2_0{3};
static const int stickman_v_1_0{4};


static std::unique_ptr<ProductionTarget> makeTier1(const SimpleConfig& config, double solenoidOffset);
static std::unique_ptr<ProductionTarget> makeHayman_v_2_0(const SimpleConfig& config, double solenoidOffset);
static std::unique_ptr<ProductionTarget> makeStickman_v_1_0(const SimpleConfig& config, double solenoidOffset);



Expand Down
13 changes: 2 additions & 11 deletions GeometryService/src/GeometryService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,8 @@ namespace mu2e {

addDetector(PSVacuumMaker::make(*_config, ps, pse, vacPS_TS_z));

//addDetector(PSShieldMaker::make(*_config, ps.psEndRefPoint(), prodTarget.position()));

if (_config->getString("targetPS_model") == "MDC2018"){
// std::cout << "adding Tier1 in GeometryService" << std::endl;
addDetector(PSShieldMaker::make(*_config, ps.psEndRefPoint(), prodTarget.position()));
} else
if (_config->getString("targetPS_model") == "Hayman_v_2_0"){
// std::cout << " adding Hayman in GeometryService" << std::endl;
addDetector(PSShieldMaker::make(*_config, ps.psEndRefPoint(), prodTarget.haymanProdTargetPosition()));
} else
{throw cet::exception("GEOM") << " " << static_cast<char const*>(__func__) << " illegal production target version specified in GeometryService_service = " << _config->getString("targetPS_model") << std::endl;}
// Use ProductionTarget's built-in method to get the correct position based on model type
addDetector(PSShieldMaker::make(*_config, ps.psEndRefPoint(), prodTarget.targetPositionByVersion()));



Expand Down
225 changes: 212 additions & 13 deletions GeometryService/src/ProductionTargetMaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,27 @@

namespace mu2e {

std::unique_ptr<ProductionTarget> ProductionTargetMaker::make(const SimpleConfig& c, double solenoidOffset) {


if (c.getString("targetPS_model") == "MDC2018"){
// std::cout << "making Tier1 in maker" << std::endl;
return makeTier1(c, solenoidOffset);
} else
if (c.getString("targetPS_model") == "Hayman_v_2_0"){
// std::cout << " making Hayman in Maker" << std::endl;
return makeHayman_v_2_0(c, solenoidOffset);
} else
{throw cet::exception("GEOM") << " illegal production target version specified = " << c.getInt("targetPS_version") << std::endl;}
return 0;
// Registry of target model makers
const std::map<std::string, ProductionTargetMaker::MakerFunction>& ProductionTargetMaker::getMakerRegistry() {
static const std::map<std::string, ProductionTargetMaker::MakerFunction> registry = {
{"MDC2018", [](const SimpleConfig& c, double offset) { return makeTier1(c, offset); }},
{"Hayman_v_2_0", [](const SimpleConfig& c, double offset) { return makeHayman_v_2_0(c, offset); }},
{"Stickman_v_1_0", [](const SimpleConfig& c, double offset) { return makeStickman_v_1_0(c, offset); }}
};
return registry;
}

std::unique_ptr<ProductionTarget> ProductionTargetMaker::make(const SimpleConfig& c, double solenoidOffset) {
const std::string modelName = c.getString("targetPS_model");
const auto& registry = getMakerRegistry();

auto it = registry.find(modelName);
if (it != registry.end()) {
return it->second(c, solenoidOffset);
}

throw cet::exception("GEOM")
<< "illegal production target model specified = " << modelName << std::endl;
}

std::unique_ptr<ProductionTarget> ProductionTargetMaker::makeTier1(const SimpleConfig& c, double solenoidOffset){
Expand Down Expand Up @@ -390,5 +397,197 @@ namespace mu2e {
return tgtPS;
}

std::unique_ptr<ProductionTarget> ProductionTargetMaker::makeStickman_v_1_0(const SimpleConfig& c, double solenoidOffset){

// Read the plate and fin parameters
std::vector<std::string> plateMaterial;
std::vector<double> plateROut;
std::vector<double> plateFinAngles;
std::vector<double> plateThickness;
std::vector<double> plateLugThickness;

c.getVectorString("targetPS_plateMaterial", plateMaterial);
c.getVectorDouble("targetPS_rOut", plateROut);
c.getVectorDouble("targetPS_plateFinAngles", plateFinAngles);
for_each(plateFinAngles.begin(), plateFinAngles.end(), [](double& elem){elem *= CLHEP::degree;});
c.getVectorDouble("targetPS_plateThickness", plateThickness);
c.getVectorDouble("targetPS_plateLugThickness", plateLugThickness);

Comment thread
YongyiBWu marked this conversation as resolved.
const int nPlates = c.getInt("targetPS_numberOfPlates");
const int nFins = c.getInt("targetPS_nStickmanFins");

if (plateMaterial.size() != static_cast<size_t>(nPlates)) {
throw cet::exception("GEOM")
<< "targetPS_plateMaterial size mismatch: expected " << nPlates
<< ", got " << plateMaterial.size();
}
if (plateROut.size() != static_cast<size_t>(nPlates)) {
throw cet::exception("GEOM")
<< "targetPS_rOut size mismatch: expected " << nPlates
<< ", got " << plateROut.size();
}
if (plateThickness.size() != static_cast<size_t>(nPlates)) {
throw cet::exception("GEOM")
<< "targetPS_plateThickness size mismatch: expected " << nPlates
<< ", got " << plateThickness.size();
}
if (plateLugThickness.size() != static_cast<size_t>(nPlates)) {
throw cet::exception("GEOM")
<< "targetPS_plateLugThickness size mismatch: expected " << nPlates
<< ", got " << plateLugThickness.size();
}
if (plateFinAngles.size() != static_cast<size_t>(nFins)) {
throw cet::exception("GEOM")
<< "targetPS_plateFinAngles size mismatch: expected " << nFins
<< ", got " << plateFinAngles.size();
}

// Build parameter structs for Stickman constructor
StickmanEnvelopeParams envelopeParams{
c.getDouble("targetPS_productionTargetMotherOuterRadius"),
c.getDouble("targetPS_productionTargetMotherHalfLength"),
c.getDouble("targetPS_rotX") * CLHEP::degree,
c.getDouble("targetPS_rotY") * CLHEP::degree,
c.getDouble("targetPS_rotZ") * CLHEP::degree,
c.getDouble("targetPS_halfStickmanLength"),
CLHEP::Hep3Vector(solenoidOffset,
0,
c.getDouble("productionTarget.zNominal"))
+ c.getHep3Vector("productionTarget.offset"),
c.getString("targetPS_targetVacuumMaterial")
};

StickmanPlateParams plateParams{
nPlates,
plateMaterial,
plateROut,
nFins,
plateFinAngles,
c.getDouble("targetPS_plateFinOuterRadius"),
c.getDouble("targetPS_plateFinWidth"),
c.getDouble("targetPS_plateCenterToLugCenter"),
c.getDouble("targetPS_plateLugInnerRadius"),
c.getDouble("targetPS_plateLugOuterRadius"),
plateThickness,
plateLugThickness
};

StickmanRodParams rodParams{
c.getString("targetPS_rodMaterial"),
c.getDouble("targetPS_rodRadius")
};

StickmanSpacerParams spacerParams{
c.getString("targetPS_spacerMaterial"),
c.getDouble("targetPS_spacerHalfLength"),
c.getDouble("targetPS_spacerOuterRadius"),
c.getDouble("targetPS_spacerInnerRadius")
};

StickmanSupportRingParams supportRingParams{
c.getString("targetPS_supportRingMaterial"),
c.getDouble("targetPS_supportRingLength"),
c.getDouble("targetPS_supportRingInnerRadius"),
c.getDouble("targetPS_supportRingOuterRadius"),
c.getDouble("targetPS_supportRingLugOuterRadius"),
c.getDouble("targetPS_supportRingCutoutOffset")
};

std::unique_ptr<ProductionTarget> tgtPS
(new ProductionTarget(
c.getString("targetPS_model","NULL"),
c.getInt("targetPS_version"),
envelopeParams,
plateParams,
rodParams,
spacerParams,
supportRingParams
));

// Create configuration parameters struct
StickmanConfigParams configParams;

// Configure plate fillet parameters (only if fillets will be used)
configParams.addFilletToPlateCore = c.getBool("targetPS_addFilletToPlateCore");
configParams.addFilletToPlateLug = c.getBool("targetPS_addFilletToPlateLug");
if(configParams.addFilletToPlateCore || configParams.addFilletToPlateLug) {
configParams.plateFilletRadius = c.getDouble("targetPS_plateFilletRadius");
}

// Configure support ring lug fillet parameters (only if fillets will be used)
configParams.addFilletToSupportRingLug = c.getBool("targetPS_addFilletToSupportRingLug");
if(configParams.addFilletToSupportRingLug) {
configParams.supportRingLugFilletRadius = c.getDouble("targetPS_supportRingLugFilletRadius");
}

// Configure support ring cutout parameters (only if cutouts will be used)
configParams.addCutoutToSupportRing = c.getBool("targetPS_addCutoutToSupportRing");
if(configParams.addCutoutToSupportRing) {
configParams.nSupportRingCutouts = c.getInt("targetPS_nSupportRingCutouts");
c.getVectorDouble("targetPS_supportRingCutoutAngles", configParams.supportRingCutoutAngles);
if (configParams.supportRingCutoutAngles.size() != static_cast<size_t>(configParams.nSupportRingCutouts)) {
throw cet::exception("GEOM")
<< "targetPS_supportRingCutoutAngles size mismatch: expected "
<< configParams.nSupportRingCutouts << ", got " << configParams.supportRingCutoutAngles.size();
}
std::for_each(configParams.supportRingCutoutAngles.begin(), configParams.supportRingCutoutAngles.end(), [](double& elem){elem *= CLHEP::degree;});
configParams.supportRingCutoutInnerRadius = c.getDouble("targetPS_supportRingCutoutInnerRadius");
configParams.supportRingCutoutTilt = c.getDouble("targetPS_supportRingCutoutTilt") * CLHEP::degree;
}

// Configure support wheel/bicycle wheel parameters (reused from Hayman)
configParams.supportsBuild = c.getBool("targetPS.supports.build", false);
if(configParams.supportsBuild) {
//support wheel parameters
configParams.supportWheelRIn = c.getDouble("targetPS.supports.wheel.rIn");
configParams.supportWheelROut = c.getDouble("targetPS.supports.wheel.rOut");
configParams.supportWheelHL = c.getDouble("targetPS.supports.wheel.halfLength");
configParams.supportWheelMaterial = c.getString("targetPS.supports.wheel.material");
//number of support rods and wires
configParams.nSpokesPerSide = c.getInt("targetPS.supports.nSpokes");
//features on the wheel near each support rod
c.getVectorDouble("targetPS.supports.features.angles", configParams.supportWheelFeatureAngles, configParams.nSpokesPerSide);
c.getVectorDouble("targetPS.supports.features.arcs" , configParams.supportWheelFeatureArcs , configParams.nSpokesPerSide);
c.getVectorDouble("targetPS.supports.features.rIns" , configParams.supportWheelFeatureRIns , configParams.nSpokesPerSide);
//support wheel rods parameters
c.getVectorDouble("targetPS.supports.rods.halfLength", configParams.supportWheelRodHL, configParams.nSpokesPerSide);
c.getVectorDouble("targetPS.supports.rods.offset", configParams.supportWheelRodOffset, configParams.nSpokesPerSide);
c.getVectorDouble("targetPS.supports.rods.pinOffset", configParams.supportWheelRodPinOffset, configParams.nSpokesPerSide);
c.getVectorDouble("targetPS.supports.rods.radius", configParams.supportWheelRodRadius, configParams.nSpokesPerSide);
c.getVectorDouble("targetPS.supports.rods.radialOffset", configParams.supportWheelRodRadialOffset, configParams.nSpokesPerSide);
c.getVectorDouble("targetPS.supports.rods.wireOffset.downstream", configParams.supportWheelRodWireOffsetD, configParams.nSpokesPerSide);
c.getVectorDouble("targetPS.supports.rods.wireOffset.upstream", configParams.supportWheelRodWireOffsetU, configParams.nSpokesPerSide);
c.getVectorDouble("targetPS.supports.rods.angles", configParams.supportWheelRodAngles, configParams.nSpokesPerSide);
//support wire (spokes) parameters
c.getVectorDouble("targetPS.supports.spokes.targetAngles.downstream", configParams.spokeTargetAnglesD, configParams.nSpokesPerSide);
c.getVectorDouble("targetPS.supports.spokes.targetAngles.upstream", configParams.spokeTargetAnglesU, configParams.nSpokesPerSide);
configParams.spokeRadius = 0.5*c.getDouble("targetPS.supports.spokes.diameter");
configParams.spokeMaterial = c.getString("targetPS.supports.spokes.material");
//check that all support wheel vectors are the correct size
if (configParams.supportWheelFeatureAngles.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.supportWheelFeatureArcs.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.supportWheelFeatureRIns.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.supportWheelRodHL.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.supportWheelRodOffset.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.supportWheelRodPinOffset.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.supportWheelRodRadius.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.supportWheelRodRadialOffset.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.supportWheelRodWireOffsetD.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.supportWheelRodWireOffsetU.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.supportWheelRodAngles.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.spokeTargetAnglesD.size() != static_cast<size_t>(configParams.nSpokesPerSide) ||
configParams.spokeTargetAnglesU.size() != static_cast<size_t>(configParams.nSpokesPerSide)) {
throw cet::exception("GEOM")
<< "Support configuration vector size mismatch for targetPS.supports.nSpokes="
<< configParams.nSpokesPerSide;
}
}

// Configure the target with the parameters
tgtPS->configureStickman(configParams);

return tgtPS;
}


} // namespace mu2e
Loading