File indexing completed on 2024-09-10 02:58:56
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 void registerLateConsumes(eventsetup::ESRecordsToProductResolverIndices const&) override;
0050
0051
0052 void produce(edm::Event& e1, const edm::EventSetup& c) override;
0053
0054 virtual void initializeEvent(const edm::Event& event, const edm::EventSetup& setup) {}
0055
0056
0057 virtual void finalizeEvent(edm::Event& event, const edm::EventSetup& setup) {}
0058
0059 void beginRun(const edm::Run& r, const edm::EventSetup& setup) override;
0060 void beginLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& setup) override;
0061
0062 void endRun(const edm::Run& r, const edm::EventSetup& setup) override;
0063 void endLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& setup) override;
0064
0065 static std::unique_ptr<MixingCache::Config> initializeGlobalCache(edm::ParameterSet const&);
0066 static void globalEndJob(MixingCache::Config*) {}
0067
0068
0069 virtual void reload(const edm::EventSetup& setup) {}
0070
0071
0072
0073
0074 double averageNumber() const { return inputSources_[0] ? inputSources_[0]->averageNumber() : 0.0; }
0075
0076 bool poisson() const { return inputSources_[0] ? inputSources_[0]->poisson() : 0.0; }
0077
0078 virtual void createnewEDProduct();
0079 virtual void checkSignal(const edm::Event& e);
0080 virtual void addSignals(const edm::Event& e, const edm::EventSetup& c) {}
0081 virtual void addPileups(
0082 const int bcr, EventPrincipal* ep, unsigned int eventId, unsigned int worker, const edm::EventSetup& c) {}
0083 virtual void setBcrOffset();
0084 virtual void setSourceOffset(const unsigned int s);
0085 virtual void put(edm::Event& e, const edm::EventSetup& c) {}
0086 virtual void doPileUp(edm::Event& e, const edm::EventSetup& c);
0087
0088 protected:
0089 void setupPileUpEvent(const edm::EventSetup& setup);
0090 void dropUnwantedBranches(std::vector<std::string> const& wantedBranches);
0091 void beginStream(edm::StreamID) override;
0092 void endStream() override;
0093
0094 int bunchSpace_;
0095 int vertexOffset_;
0096 bool checktof_;
0097 int minBunch_;
0098 int maxBunch_;
0099 bool const mixProdStep1_;
0100 bool const mixProdStep2_;
0101
0102 bool readDB_;
0103 bool playback_;
0104 const static unsigned int maxNbSources_;
0105 bool doit_[4];
0106 std::vector<float> TrueNumInteractions_;
0107
0108 unsigned int eventId_;
0109
0110
0111 std::vector<std::shared_ptr<PileUp>> inputSources_;
0112
0113 void update(edm::EventSetup const&);
0114 edm::ESWatcher<MixingRcd> parameterWatcher_;
0115 };
0116
0117 }
0118
0119 #endif