Skip to content

Commit

Permalink
Merge pull request #57 from blinkseb/cat_fix
Browse files Browse the repository at this point in the history
Ensure that categories and cuts are unique. Fix #56
  • Loading branch information
swertz committed Sep 17, 2015
2 parents db126a9 + e30c675 commit cb910ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions interface/Category.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class CategoryManager {
public:
template<class T>
void new_category(const std::string& name, const std::string& description, const edm::ParameterSet& config) {
if (m_categories.count(name) > 0) {
throw edm::Exception(edm::errors::InsertFailure, "A category named '" + name + "' already exists.");
}

std::unique_ptr<Category> category(new T());
category->configure(config);
m_categories.emplace(name, CategoryData(name, description, std::move(category), m_tree));
Expand Down
3 changes: 3 additions & 0 deletions src/Cut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include <cp3_llbb/Framework/interface/Category.h>

void CutManager::new_cut(const std::string& name, const std::string& description) {
if (m_cuts.count(name) > 0) {
throw edm::Exception(edm::errors::InsertFailure, "A cut named '" + name + "' already exists.");
}
m_cuts.emplace(name, Cut(name, description, m_category.tree));
}

Expand Down

0 comments on commit cb910ff

Please sign in to comment.