CMS 3D CMS Logo

RandomFilter.cc
Go to the documentation of this file.
1 
3 
9 
10 #include "CLHEP/Random/RandomEngine.h"
11 
12 using namespace edm;
13 
15  acceptRate_(ps.getUntrackedParameter<double>("acceptRate")) {
17  if(!rng.isAvailable()) {
18  throw cms::Exception("Configuration")
19  << "RandomFilter requires the RandomNumberGeneratorService,\n"
20  "which is not present in the configuration file. You must add\n"
21  "the service in the configuration file or remove the modules that\n"
22  "require it.\n";
23  }
24 }
25 
27 }
28 
31  CLHEP::HepRandomEngine& engine = rng->getEngine(event.streamID());
32  if (engine.flat() < acceptRate_) return true;
33  return false;
34 }
bool filter(edm::Event &e, edm::EventSetup const &c) override
Definition: RandomFilter.cc:29
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
~RandomFilter() override
Definition: RandomFilter.cc:26
bool isAvailable() const
Definition: Service.h:40
HLT enums.
StreamID streamID() const
Definition: Event.h:95
RandomFilter(edm::ParameterSet const &ps)
Definition: RandomFilter.cc:14
Definition: event.py:1