File indexing completed on 2021-09-02 03:45:54
0001 #ifndef BMixingModule_h
0002 #define BMixingModule_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <vector>
0019 #include <memory>
0020
0021 #include "FWCore/Framework/interface/stream/EDProducer.h"
0022 #include "FWCore/Framework/interface/Frameworkfwd.h"
0023 #include "Mixing/Base/interface/PileUp.h"
0024 #include "FWCore/Framework/interface/ESWatcher.h"
0025 #include "CondFormats/DataRecord/interface/MixingRcd.h"
0026
0027 namespace edm {
0028 namespace MixingCache {
0029 struct Config {
0030 Config(edm::ParameterSet const& pset, unsigned int maxNbSources);
0031 int bunchSpace_;
0032 int minBunch_;
0033 int maxBunch_;
0034 bool playback_;
0035 bool configFromDB_ = false;
0036 std::vector<std::string> sourceNames_;
0037 std::vector<std::shared_ptr<PileUpConfig>> inputConfigs_;
0038 };
0039 }
0040
0041 class BMixingModule : public stream::EDProducer<GlobalCache<MixingCache::Config>> {
0042 public:
0043
0044 explicit BMixingModule(const edm::ParameterSet& ps, MixingCache::Config const* globalConf);
0045
0046
0047 ~BMixingModule() override;
0048
0049
0050 void produce(edm::Event& e1, const edm::EventSetup& c) override;
0051
0052 virtual void initializeEvent(const edm::Event& event, const edm::EventSetup& setup) {}
0053
0054
0055 virtual void finalizeEvent(edm::Event& event, const edm::EventSetup& setup) {}
0056
0057 void beginRun(const edm::Run& r, const edm::EventSetup& setup) override;
0058 void beginLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& setup) override;
0059
0060 void endRun(const edm::Run& r, const edm::EventSetup& setup) override;
0061 void endLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& setup) override;
0062
0063 static std::unique_ptr<MixingCache::Config> initializeGlobalCache(edm::ParameterSet const&);
0064 static void globalEndJob(MixingCache::Config*) {}
0065
0066
0067 virtual void reload(const edm::EventSetup& setup){};
0068
0069
0070
0071
0072 double averageNumber() const { return inputSources_[0] ? inputSources_[0]->averageNumber() : 0.0; }
0073
0074 bool poisson() const { return inputSources_[0] ? inputSources_[0]->poisson() : 0.0; }
0075
0076 virtual void createnewEDProduct();
0077 virtual void checkSignal(const edm::Event& e);
0078 virtual void addSignals(const edm::Event& e, const edm::EventSetup& c) {}
0079 virtual void addPileups(
0080 const int bcr, EventPrincipal* ep, unsigned int eventId, unsigned int worker, const edm::EventSetup& c) {}
0081 virtual void setBcrOffset();
0082 virtual void setSourceOffset(const unsigned int s);
0083 virtual void put(edm::Event& e, const edm::EventSetup& c) {}
0084 virtual void doPileUp(edm::Event& e, const edm::EventSetup& c);
0085
0086 protected:
0087 void setupPileUpEvent(const edm::EventSetup& setup);
0088 void dropUnwantedBranches(std::vector<std::string> const& wantedBranches);
0089 void beginStream(edm::StreamID) override;
0090 void endStream() override;
0091
0092 int bunchSpace_;
0093 int vertexOffset_;
0094 bool checktof_;
0095 int minBunch_;
0096 int maxBunch_;
0097 bool const mixProdStep1_;
0098 bool const mixProdStep2_;
0099
0100 bool readDB_;
0101 bool playback_;
0102 const static unsigned int maxNbSources_;
0103 bool doit_[4];
0104 std::vector<float> TrueNumInteractions_;
0105
0106 unsigned int eventId_;
0107
0108
0109 std::vector<std::shared_ptr<PileUp>> inputSources_;
0110
0111 void update(edm::EventSetup const&);
0112 edm::ESWatcher<MixingRcd> parameterWatcher_;
0113 };
0114
0115 }
0116
0117 #endif