CMS 3D CMS Logo

BMixingModule.h
Go to the documentation of this file.
1 #ifndef BMixingModule_h
2 #define BMixingModule_h
3 
18 #include <vector>
19 #include <memory>
20 
26 
27 namespace edm {
28  namespace MixingCache {
29  struct Config {
30  Config(edm::ParameterSet const& pset, unsigned int maxNbSources);
32  int minBunch_;
33  int maxBunch_;
34  bool playback_;
35  bool configFromDB_ = false;
36  std::vector<std::string> sourceNames_;
37  std::vector<std::shared_ptr<PileUpConfig>> inputConfigs_;
38  };
39  } // namespace MixingCache
40 
41  class BMixingModule : public stream::EDProducer<GlobalCache<MixingCache::Config>> {
42  public:
44  explicit BMixingModule(const edm::ParameterSet& ps, MixingCache::Config const* globalConf);
45 
47  ~BMixingModule() override;
48 
50  void produce(edm::Event& e1, const edm::EventSetup& c) override;
51 
52  virtual void initializeEvent(const edm::Event& event, const edm::EventSetup& setup) {}
53 
54  // edm::Event is non-const because digitizers put their products into the Event.
56 
57  void beginRun(const edm::Run& r, const edm::EventSetup& setup) override;
58  void beginLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& setup) override;
59 
60  void endRun(const edm::Run& r, const edm::EventSetup& setup) override;
61  void endLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& setup) override;
62 
63  static std::unique_ptr<MixingCache::Config> initializeGlobalCache(edm::ParameterSet const&);
65 
66  // to be overloaded by dependent class
67  virtual void reload(const edm::EventSetup& setup){};
68 
69  // Should 'averageNumber' return 0 or 1 if there is no mixing? It is the average number of
70  // *crossings*, including the hard scatter, or the average number of overlapping events?
71  // We have guessed 'overlapping events'.
72  double averageNumber() const { return inputSources_[0] ? inputSources_[0]->averageNumber() : 0.0; }
73  // Should 'poisson' return 0 or 1 if there is no mixing? See also averageNumber above.
74  bool poisson() const { return inputSources_[0] ? inputSources_[0]->poisson() : 0.0; }
75 
76  virtual void createnewEDProduct();
77  virtual void checkSignal(const edm::Event& e);
78  virtual void addSignals(const edm::Event& e, const edm::EventSetup& c) {}
79  virtual void addPileups(
80  const int bcr, EventPrincipal* ep, unsigned int eventId, unsigned int worker, const edm::EventSetup& c) {}
81  virtual void setBcrOffset();
82  virtual void setSourceOffset(const unsigned int s);
83  virtual void put(edm::Event& e, const edm::EventSetup& c) {}
84  virtual void doPileUp(edm::Event& e, const edm::EventSetup& c);
85 
86  protected:
88  void dropUnwantedBranches(std::vector<std::string> const& wantedBranches);
89  void beginStream(edm::StreamID) override;
90  void endStream() override;
91  // std::string type_;
94  bool checktof_;
95  int minBunch_;
96  int maxBunch_;
97  bool const mixProdStep1_;
98  bool const mixProdStep2_;
99 
100  bool readDB_;
101  bool playback_;
102  const static unsigned int maxNbSources_;
103  bool doit_[4]; //FIXME
104  std::vector<float> TrueNumInteractions_;
105 
106  unsigned int eventId_;
107 
108  // input, cosmics, beamhalo_plus, beamhalo_minus
109  std::vector<std::shared_ptr<PileUp>> inputSources_;
110 
111  void update(edm::EventSetup const&);
113  };
114 
115 } // namespace edm
116 
117 #endif
edm::ESWatcher< MixingRcd > parameterWatcher_
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
virtual void addPileups(const int bcr, EventPrincipal *ep, unsigned int eventId, unsigned int worker, const edm::EventSetup &c)
Definition: BMixingModule.h:79
static std::unique_ptr< MixingCache::Config > initializeGlobalCache(edm::ParameterSet const &)
virtual void addSignals(const edm::Event &e, const edm::EventSetup &c)
Definition: BMixingModule.h:78
bool const mixProdStep2_
Definition: BMixingModule.h:98
void produce(edm::Event &e1, const edm::EventSetup &c) override
virtual void finalizeEvent(edm::Event &event, const edm::EventSetup &setup)
Definition: BMixingModule.h:55
std::vector< std::string > sourceNames_
Definition: BMixingModule.h:36
virtual void checkSignal(const edm::Event &e)
void endStream() override
virtual void put(edm::Event &e, const edm::EventSetup &c)
Definition: BMixingModule.h:83
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
virtual void setBcrOffset()
virtual void createnewEDProduct()
virtual void setSourceOffset(const unsigned int s)
virtual void doPileUp(edm::Event &e, const edm::EventSetup &c)
virtual void initializeEvent(const edm::Event &event, const edm::EventSetup &setup)
Definition: BMixingModule.h:52
Config(edm::ParameterSet const &pset, unsigned int maxNbSources)
void beginStream(edm::StreamID) override
static const unsigned int maxNbSources_
std::vector< float > TrueNumInteractions_
double averageNumber() const
Definition: BMixingModule.h:72
virtual void reload(const edm::EventSetup &setup)
Definition: BMixingModule.h:67
~BMixingModule() override
bool poisson() const
Definition: BMixingModule.h:74
bool const mixProdStep1_
Definition: BMixingModule.h:97
HLT enums.
std::vector< std::shared_ptr< PileUp > > inputSources_
Definition: Config.py:1
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
void update(edm::EventSetup const &)
std::vector< std::shared_ptr< PileUpConfig > > inputConfigs_
Definition: BMixingModule.h:37
static void globalEndJob(MixingCache::Config *)
Definition: BMixingModule.h:64
void setupPileUpEvent(const edm::EventSetup &setup)
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
Definition: event.py:1
Definition: Run.h:45
unsigned int eventId_
BMixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)