8 #include <cp3_llbb/Framework/interface/Cut.h>
9 #include <cp3_llbb/Framework/interface/ProducersManager.h>
10 #include <cp3_llbb/Framework/interface/AnalyzersManager.h>
12 #include <cp3_llbb/TreeWrapper/interface/TreeWrapper.h>
22 virtual void configure(
const edm::ParameterSet& config) {};
24 virtual bool event_in_category_pre_analyzers(
const ProducersManager& producers)
const = 0;
27 virtual void register_cuts(
CutManager& manager) {};
32 virtual std::shared_ptr<CategoryMetadata> get_metadata()
final {
37 std::shared_ptr<CategoryMetadata> metadata;
42 std::string description;
43 std::unique_ptr<Category> callback;
50 bool in_category_pre =
false;
51 bool in_category_post =
false;
54 CategoryData(
const std::string& name_,
const std::string& description_, std::unique_ptr<Category> category, ROOT::TreeWrapper& tree_):
56 description(description_),
57 callback(std::move(category)),
58 tree(tree_.group(name_ +
"_")),
60 in_category(tree[
"category"].write<bool>())
62 callback->register_cuts(cut_manager);
72 bool in_category()
const {
73 return data.in_category_pre;
76 bool cut_passed(
const std::string& cut_name)
const {
77 return data.cut_manager.cut_passed(cut_name);
80 std::shared_ptr<CategoryMetadata> get_metadata()
const {
81 return data.callback->get_metadata();
93 void new_category(
const std::string& name,
const std::string& description,
const edm::ParameterSet& config) {
94 std::string internal_name = m_current_prefix + name;
95 if (m_categories.count(internal_name) > 0) {
96 throw edm::Exception(edm::errors::InsertFailure,
"A category named '" + internal_name +
"' already exists for this analyzer.");
99 std::unique_ptr<Category> category(
new T());
100 category->configure(config);
101 m_categories.emplace(internal_name,
CategoryData(internal_name, description, std::move(category), m_tree));
104 bool in_category(
const std::string& name)
const {
106 std::string internal_name = m_current_prefix + name;
107 const auto& category = m_categories.find(internal_name);
108 if (category == m_categories.end()) {
109 std::stringstream details;
110 details <<
"Category '" << name <<
"' not found.";
111 throw edm::Exception(edm::errors::NotFound, details.str());
114 return category->second.in_category_pre;
119 std::string internal_name = m_current_prefix + name;
120 const auto& category = m_categories.find(internal_name);
121 if (category == m_categories.end()) {
122 std::stringstream details;
123 details <<
"Category '" << name <<
"' not found.";
124 throw edm::Exception(edm::errors::NotFound, details.str());
137 void set_prefix(
const std::string& prefix);
144 void print_summary();
146 std::unordered_map<std::string, CategoryData> m_categories;
147 ROOT::TreeWrapper& m_tree;
149 uint64_t processed_events = 0;
150 uint64_t selected_events = 0;
152 std::string m_current_prefix;
Definition: AnalyzersManager.h:10
Definition: Category.h:88
Definition: Category.h:20
Definition: Framework.h:21
Definition: ProducersManager.h:10
Definition: Category.h:40
Definition: Category.h:66