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 
52  void produce(edm::Event& e1, const edm::EventSetup& c) override;
53 
54  virtual void initializeEvent(const edm::Event& event, const edm::EventSetup& setup) {}
55 
56  // edm::Event is non-const because digitizers put their products into the Event.
58 
59  void beginRun(const edm::Run& r, const edm::EventSetup& setup) override;
60  void beginLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& setup) override;
61 
62  void endRun(const edm::Run& r, const edm::EventSetup& setup) override;
63  void endLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& setup) override;
64 
65  static std::unique_ptr<MixingCache::Config> initializeGlobalCache(edm::ParameterSet const&);
67 
68  // to be overloaded by dependent class
69  virtual void reload(const edm::EventSetup& setup){};
70 
71  // Should 'averageNumber' return 0 or 1 if there is no mixing? It is the average number of
72  // *crossings*, including the hard scatter, or the average number of overlapping events?
73  // We have guessed 'overlapping events'.
74  double averageNumber() const { return inputSources_[0] ? inputSources_[0]->averageNumber() : 0.0; }
75  // Should 'poisson' return 0 or 1 if there is no mixing? See also averageNumber above.
76  bool poisson() const { return inputSources_[0] ? inputSources_[0]->poisson() : 0.0; }
77 
78  virtual void createnewEDProduct();
79  virtual void checkSignal(const edm::Event& e);
80  virtual void addSignals(const edm::Event& e, const edm::EventSetup& c) {}
81  virtual void addPileups(
82  const int bcr, EventPrincipal* ep, unsigned int eventId, unsigned int worker, const edm::EventSetup& c) {}
83  virtual void setBcrOffset();
84  virtual void setSourceOffset(const unsigned int s);
85  virtual void put(edm::Event& e, const edm::EventSetup& c) {}
86  virtual void doPileUp(edm::Event& e, const edm::EventSetup& c);
87 
88  protected:
90  void dropUnwantedBranches(std::vector<std::string> const& wantedBranches);
91  void beginStream(edm::StreamID) override;
92  void endStream() override;
93  // std::string type_;
96  bool checktof_;
97  int minBunch_;
98  int maxBunch_;
99  bool const mixProdStep1_;
100  bool const mixProdStep2_;
101 
102  bool readDB_;
103  bool playback_;
104  const static unsigned int maxNbSources_;
105  bool doit_[4]; //FIXME
106  std::vector<float> TrueNumInteractions_;
107 
108  unsigned int eventId_;
109 
110  // input, cosmics, beamhalo_plus, beamhalo_minus
111  std::vector<std::shared_ptr<PileUp>> inputSources_;
112 
113  void update(edm::EventSetup const&);
115  };
116 
117 } // namespace edm
118 
119 #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:81
static std::unique_ptr< MixingCache::Config > initializeGlobalCache(edm::ParameterSet const &)
virtual void addSignals(const edm::Event &e, const edm::EventSetup &c)
Definition: BMixingModule.h:80
bool const mixProdStep2_
void produce(edm::Event &e1, const edm::EventSetup &c) override
virtual void finalizeEvent(edm::Event &event, const edm::EventSetup &setup)
Definition: BMixingModule.h:57
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:85
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)
void registerLateConsumes(eventsetup::ESRecordsToProductResolverIndices const &) override
virtual void initializeEvent(const edm::Event &event, const edm::EventSetup &setup)
Definition: BMixingModule.h:54
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:74
virtual void reload(const edm::EventSetup &setup)
Definition: BMixingModule.h:69
~BMixingModule() override
bool poisson() const
Definition: BMixingModule.h:76
bool const mixProdStep1_
Definition: BMixingModule.h:99
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:66
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)