Skip to content

Commit

Permalink
Merge pull request #27185 from makortel/pluginFactoryCleanupAlignment
Browse files Browse the repository at this point in the history
Remove redundant unique_ptr constructor calls from AlCa
  • Loading branch information
cmsbuild committed Jun 17, 2019
2 parents 8a7f0b6 + 6bc05eb commit 2ad2627
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 45 deletions.
Expand Up @@ -204,9 +204,6 @@ class AlignmentProducerBase {
/// Takes over ownership of AlignmentSurfaceDeformations.
void writeDB(AlignmentSurfaceDeformations*, const std::string&, cond::Time_t) const;

template <typename T>
bool hasParameter(const edm::ParameterSet&, const std::string& name);

//========================== PRIVATE DATA ====================================
//============================================================================

Expand Down
42 changes: 6 additions & 36 deletions Alignment/CommonAlignmentProducer/src/AlignmentProducerBase.cc
Expand Up @@ -56,16 +56,16 @@ AlignmentProducerBase::AlignmentProducerBase(const edm::ParameterSet& config)
edm::LogInfo("Alignment") << "@SUB=AlignmentProducerBase::AlignmentProducerBase";

const auto& algoConfig = config_.getParameterSet("algoConfig");
if (hasParameter<bool>(config_, "runAtPCL")) {
if (config_.existsAs<bool>("runAtPCL")) {
// configured in main config?
runAtPCL_ = config_.getParameter<bool>("runAtPCL");

if (hasParameter<bool>(algoConfig, "runAtPCL") && (runAtPCL_ != algoConfig.getParameter<bool>("runAtPCL"))) {
if (algoConfig.existsAs<bool>("runAtPCL") && (runAtPCL_ != algoConfig.getParameter<bool>("runAtPCL"))) {
throw cms::Exception("BadConfig") << "Inconsistent settings for 'runAtPCL' in configuration of the "
<< "alignment producer and the alignment algorithm.";
}

} else if (hasParameter<bool>(algoConfig, "runAtPCL")) {
} else if (algoConfig.existsAs<bool>("runAtPCL")) {
// configured in algo config?
runAtPCL_ = algoConfig.getParameter<bool>("runAtPCL");

Expand Down Expand Up @@ -266,26 +266,16 @@ void AlignmentProducerBase::createAlignmentAlgorithm() {
algoConfig.addUntrackedParameter("enableAlignableUpdates", enableAlignableUpdates_);

const auto& algoName = algoConfig.getParameter<std::string>("algoName");
alignmentAlgo_ =
std::unique_ptr<AlignmentAlgorithmBase>{AlignmentAlgorithmPluginFactory::get()->create(algoName, algoConfig)};

if (!alignmentAlgo_) {
throw cms::Exception("BadConfig") << "Couldn't find the called alignment algorithm: " << algoName;
}
alignmentAlgo_ = AlignmentAlgorithmPluginFactory::get()->create(algoName, algoConfig);
}

//------------------------------------------------------------------------------
void AlignmentProducerBase::createMonitors() {
const auto& monitorConfig = config_.getParameter<edm::ParameterSet>("monitorConfig");
auto monitors = monitorConfig.getUntrackedParameter<std::vector<std::string> >("monitors");
for (const auto& miter : monitors) {
std::unique_ptr<AlignmentMonitorBase> newMonitor{
AlignmentMonitorPluginFactory::get()->create(miter, monitorConfig.getUntrackedParameterSet(miter))};

if (!newMonitor) {
throw cms::Exception("BadConfig") << "Couldn't find monitor named " << miter;
}
monitors_.emplace_back(std::move(newMonitor));
monitors_.emplace_back(
AlignmentMonitorPluginFactory::get()->create(miter, monitorConfig.getUntrackedParameterSet(miter)));
}
}

Expand Down Expand Up @@ -942,23 +932,3 @@ void AlignmentProducerBase::writeDB(AlignmentSurfaceDeformations* alignmentSurfa
delete alignmentSurfaceDeformations; // ...otherwise we have to delete, as promised!
}
}

//------------------------------------------------------------------------------
template <typename T>
bool AlignmentProducerBase::hasParameter(const edm::ParameterSet& config, const std::string& name) {
try {
config.getParameter<T>(name);
} catch (const edm::Exception& e) {
if (e.categoryCode() == edm::errors::Configuration) {
if (e.message().find("MissingParameter") != std::string::npos) {
return false;
} else {
throw;
}
} else {
throw;
}
}

return true;
}
Expand Up @@ -282,8 +282,7 @@ void MillePedeAlignmentAlgorithm::initialize(const edm::EventSetup &setup,
// Get trajectory factory. In case nothing found, FrameWork will throw...
const edm::ParameterSet fctCfg(theConfig.getParameter<edm::ParameterSet>("TrajectoryFactory"));
const std::string fctName(fctCfg.getParameter<std::string>("TrajectoryFactoryName"));
theTrajectoryFactory =
std::unique_ptr<TrajectoryFactoryBase>(TrajectoryFactoryPlugin::get()->create(fctName, fctCfg));
theTrajectoryFactory = TrajectoryFactoryPlugin::get()->create(fctName, fctCfg);
}

if (this->isMode(myPedeSteerBit)) {
Expand Down
4 changes: 2 additions & 2 deletions CalibMuon/DTCalibration/plugins/DTTPAnalyzer.cc
Expand Up @@ -74,8 +74,8 @@ DTTPAnalyzer::DTTPAnalyzer(const edm::ParameterSet& pset):
rootFile_->cd();

if(subtractT0_)
tTrigSync_ = std::unique_ptr<DTTTrigBaseSync>{DTTTrigSyncFactory::get()->create(pset.getParameter<std::string>("tTrigMode"),
pset.getParameter<edm::ParameterSet>("tTrigModeConfig"))};
tTrigSync_ = DTTTrigSyncFactory::get()->create(pset.getParameter<std::string>("tTrigMode"),
pset.getParameter<edm::ParameterSet>("tTrigModeConfig"));

}

Expand Down
4 changes: 2 additions & 2 deletions CalibMuon/DTCalibration/plugins/DTTTrigCalibration.cc
Expand Up @@ -70,8 +70,8 @@ DTTTrigCalibration::DTTTrigCalibration(const edm::ParameterSet& pset) {
doSubtractT0 = pset.getUntrackedParameter<bool>("doSubtractT0","false");
// Get the synchronizer
if(doSubtractT0) {
theSync = std::unique_ptr<DTTTrigBaseSync>{DTTTrigSyncFactory::get()->create(pset.getUntrackedParameter<string>("tTrigMode"),
pset.getUntrackedParameter<ParameterSet>("tTrigModeConfig"))};
theSync = DTTTrigSyncFactory::get()->create(pset.getUntrackedParameter<string>("tTrigMode"),
pset.getUntrackedParameter<ParameterSet>("tTrigModeConfig"));
}

checkNoisyChannels = pset.getUntrackedParameter<bool>("checkNoisyChannels","false");
Expand Down

0 comments on commit 2ad2627

Please sign in to comment.