Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:57

0001 //
0002 // Original Author:  Filippo Ambroglini
0003 //         Created:  Fri Sep 29 17:10:41 CEST 2006
0004 //
0005 
0006 #include "FWCore/Framework/interface/Frameworkfwd.h"
0007 #include "FWCore/Framework/interface/global/EDFilter.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/ServiceRegistry/interface/Service.h"
0011 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0012 #include "CLHEP/Random/RandomEngine.h"
0013 #include "CLHEP/Random/RandFlat.h"
0014 
0015 class MinimumBiasFilter : public edm::global::EDFilter<> {
0016 public:
0017   MinimumBiasFilter(const edm::ParameterSet&);
0018 
0019   bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0020 
0021 private:
0022   const double theEventFraction;
0023 };
0024 
0025 MinimumBiasFilter::MinimumBiasFilter(const edm::ParameterSet& iConfig)
0026     : theEventFraction(iConfig.getUntrackedParameter<double>("EventFraction")) {}
0027 
0028 bool MinimumBiasFilter::filter(edm::StreamID streamID, edm::Event&, const edm::EventSetup&) const {
0029   /**
0030    * Wainting the real trigger for the
0031    * MB we have developped
0032    * a random one
0033   */
0034   edm::Service<edm::RandomNumberGenerator> rng;
0035   CLHEP::HepRandomEngine& engine = rng->getEngine(streamID);
0036   double rnd = CLHEP::RandFlat::shoot(&engine, 0., 1.);
0037 
0038   return (rnd <= theEventFraction);
0039 }
0040 
0041 DEFINE_FWK_MODULE(MinimumBiasFilter);