CP3-llbb Framework
Analyzer.h
1 #ifndef ANALYZER_H
2 #define ANALYZER_H
3 
4 #include <FWCore/PluginManager/interface/PluginFactory.h>
5 #include <FWCore/ParameterSet/interface/ParameterSet.h>
6 #include <FWCore/Framework/interface/Event.h>
7 #include <FWCore/Framework/interface/Run.h>
8 #include <FWCore/Framework/interface/LuminosityBlock.h>
9 #include <FWCore/Framework/interface/EventSetup.h>
10 #include <FWCore/Framework/interface/ConsumesCollector.h>
11 #include <FWCore/Utilities/interface/InputTag.h>
12 
13 #include <cp3_llbb/Framework/interface/ProducersManager.h>
14 #include <cp3_llbb/Framework/interface/MetadataManager.h>
15 #include <cp3_llbb/TreeWrapper/interface/TreeWrapper.h>
16 
17 #include <cp3_llbb/Framework/interface/Types.h>
18 
19 #include <vector>
20 #include <map>
21 
22 class CategoryManager;
23 class AnalyzersManager;
24 class ExTreeMaker;
25 
26 namespace Framework {
27 
28  class Analyzer {
29  friend class ::ExTreeMaker;
30 
31  public:
32 
33  Analyzer(const std::string& name, const ROOT::TreeGroup& tree_, const edm::ParameterSet& config):
34  m_name(name),
35  tree(tree_),
36  m_systematics(config.getUntrackedParameter<bool>("systematics", false)) {
37  }
38 
39  virtual void analyze(const edm::Event&, const edm::EventSetup&, const ProducersManager&, const AnalyzersManager&, const CategoryManager&) = 0;
40  virtual void doConsumes(const edm::ParameterSet&, edm::ConsumesCollector&& collector) {}
41 
42  virtual void registerCategories(CategoryManager& manager, const edm::ParameterSet& config) {}
43 
44  virtual void beginJob(MetadataManager&) {}
45  virtual void endJob(MetadataManager&) {}
46 
47  virtual void beginRun(const edm::Run&, const edm::EventSetup&) {}
48  virtual void endRun(const edm::Run&, const edm::EventSetup&) {}
49 
50  virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) {}
51  virtual void endLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) {}
52 
53  // Disable copy of analyzer
54  Analyzer(const Analyzer&) = delete;
55  Analyzer& operator=(const Analyzer&) = delete;
56 
57  protected:
58  std::string m_name;
59 
60  ROOT::TreeGroup tree;
61 
62  inline bool doingSystematics() const {
63  return m_systematics;
64  }
65 
66  private:
67  bool hasRun() const {
68  return m_run;
69  }
70 
71  void setRun(bool run) {
72  m_run = run;
73  }
74 
75  bool m_run; //< A flag indicating if the analyzer has already been run for this event
76 
77  // If true, this analyzer is producing systematics related quantities
78  bool m_systematics;
79  };
80 
81 }
82 
83 typedef edmplugin::PluginFactory<Framework::Analyzer* (const std::string&, const ROOT::TreeGroup&, const edm::ParameterSet&)> ExTreeMakerAnalyzerFactory;
84 
85 #endif
Definition: AnalyzersManager.h:10
Definition: Category.h:88
Definition: Framework.h:21
Definition: Analyzer.h:28
Definition: MetadataManager.h:9
Definition: ProducersManager.h:10