Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-02 03:45:54

0001 #ifndef BMixingModule_h
0002 #define BMixingModule_h
0003 
0004 /** \class BMixingModule
0005  *
0006  * BMixingModule is the EDProducer subclass 
0007  * which fills the CrossingFrame object
0008  * It is the baseclass for all modules mixing events
0009  *
0010  * \author Ursula Berthon, LLR Palaiseau, Bill Tanenbaum
0011  *
0012  * \version   1st Version June 2005
0013  * \version   2nd Version Sep 2005
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   }  // namespace MixingCache
0040 
0041   class BMixingModule : public stream::EDProducer<GlobalCache<MixingCache::Config>> {
0042   public:
0043     /** standard constructor*/
0044     explicit BMixingModule(const edm::ParameterSet& ps, MixingCache::Config const* globalConf);
0045 
0046     /**Default destructor*/
0047     ~BMixingModule() override;
0048 
0049     /**Cumulates the pileup events onto this event*/
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     // edm::Event is non-const because digitizers put their products into the Event.
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     // to be overloaded by dependent class
0067     virtual void reload(const edm::EventSetup& setup){};
0068 
0069     // Should 'averageNumber' return 0 or 1 if there is no mixing? It is the average number of
0070     // *crossings*, including the hard scatter, or the average number of overlapping events?
0071     // We have guessed 'overlapping events'.
0072     double averageNumber() const { return inputSources_[0] ? inputSources_[0]->averageNumber() : 0.0; }
0073     // Should 'poisson' return 0 or 1 if there is no mixing? See also averageNumber above.
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     //      std::string type_;
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];  //FIXME
0104     std::vector<float> TrueNumInteractions_;
0105 
0106     unsigned int eventId_;
0107 
0108     // input, cosmics, beamhalo_plus, beamhalo_minus
0109     std::vector<std::shared_ptr<PileUp>> inputSources_;
0110 
0111     void update(edm::EventSetup const&);
0112     edm::ESWatcher<MixingRcd> parameterWatcher_;
0113   };
0114 
0115 }  // namespace edm
0116 
0117 #endif