CP3-llbb Framework
Framework.h
1 #ifndef FRAMEWORK_H
2 #define FRAMEWORK_H
3 
4 #include "FWCore/Framework/interface/Frameworkfwd.h"
5 #include "FWCore/Framework/interface/EDProducer.h"
6 #include <FWCore/Framework/interface/ConsumesCollector.h>
7 #include "FWCore/Framework/interface/Event.h"
8 #include "FWCore/Framework/interface/MakerMacros.h"
9 
10 #include "FWCore/ParameterSet/interface/ParameterSet.h"
11 
12 #include "cp3_llbb/Framework/interface/Analyzer.h"
13 #include "cp3_llbb/Framework/interface/Producer.h"
14 #include "cp3_llbb/Framework/interface/Filter.h"
15 #include "cp3_llbb/Framework/interface/Category.h"
16 #include "cp3_llbb/Framework/interface/ProducerGetter.h"
17 #include "cp3_llbb/Framework/interface/ProducersManager.h"
18 #include "cp3_llbb/Framework/interface/AnalyzerGetter.h"
19 #include "cp3_llbb/Framework/interface/AnalyzersManager.h"
20 
21 class ExTreeMaker: public edm::EDProducer, ProducerGetter, AnalyzerGetter {
22  friend class ProducersManager;
23  friend class AnalyzersManager;
24 
25  struct AnalyzerWrapper {
26  std::shared_ptr<Framework::Analyzer> analyzer;
27  std::string name;
28  std::string prefix;
29  };
30 
31  public:
32  explicit ExTreeMaker(const edm::ParameterSet&);
33  ~ExTreeMaker();
34 
35  private:
36  virtual void beginJob() override;
37  virtual void produce(edm::Event&, const edm::EventSetup&) override;
38  virtual void endJob() override;
39 
40  virtual void beginRun(const edm::Run&, const edm::EventSetup&) override;
41  virtual void endRun(const edm::Run&, const edm::EventSetup&) override;
42 
43  virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override;
44  virtual void endLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override;
45 
46  // From ProducerGetter
47  virtual const Framework::Producer& getProducer(const std::string& name) const override;
48  virtual bool producerExists(const std::string& name) const override;
49  std::unique_ptr<ProducersManager> m_producers_manager;
50 
51  // From AnalyzerGetter
52  virtual const Framework::Analyzer& getAnalyzer(const std::string& name) const override;
53  virtual bool analyzerExists(const std::string& name) const override;
54  std::unique_ptr<AnalyzersManager> m_analyzers_manager;
55 
56  TTree* m_raw_tree;
57  std::unique_ptr<ROOT::TreeWrapper> m_wrapper;
58  size_t m_flush_size;
59  size_t m_filled_size = 0;
60  bool m_baskets_optimized = false;
61 
62  std::unordered_map<std::string, std::shared_ptr<Framework::Filter>> m_filters;
63 
64  // Order is important, we can't use a map here
65  std::vector<std::pair<std::string, std::shared_ptr<Framework::Producer>>> m_producers;
66  std::vector<AnalyzerWrapper> m_analyzers;
67  std::vector<std::string> m_analyzers_name;
68 
69  // Categories
70  std::unique_ptr<CategoryManager> m_categories;
71 
72  // Metadata
73  std::unique_ptr<MetadataManager> m_metadata;
74 
75  // Timing
76  typedef std::chrono::system_clock clock;
77  typedef std::chrono::milliseconds ms;
78  typedef std::chrono::seconds seconds;
79 
80  clock::time_point m_start_time;
81 };
82 
83 
84 #endif
Definition: AnalyzerGetter.h:9
Definition: AnalyzersManager.h:10
Definition: Framework.h:21
Definition: Analyzer.h:28
Base class for Framework producers.
Definition: Producer.h:33
Definition: ProducerGetter.h:9
Definition: ProducersManager.h:10