Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:48:59

0001 #include "GeneratorInterface/TauolaInterface/interface/TauSpinnerFilter.h"
0002 
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "FWCore/ServiceRegistry/interface/Service.h"
0005 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 #include "FWCore/ServiceRegistry/interface/RandomEngineSentry.h"
0008 
0009 TauSpinnerFilter::TauSpinnerFilter(const edm::ParameterSet& pset)
0010     : WTToken_(consumes<double>(pset.getParameter<edm::InputTag>("src"))), fRandomEngine(nullptr), ntaus_(0) {
0011   if (pset.getParameter<int>("ntaus") == 1)
0012     ntaus_ = 1.0;
0013   if (pset.getParameter<int>("ntaus") == 2)
0014     ntaus_ = 2.0;
0015 }
0016 
0017 bool TauSpinnerFilter::filter(edm::Event& e, edm::EventSetup const& es) {
0018   edm::RandomEngineSentry<TauSpinnerFilter> randomEngineSentry(this, e.streamID());
0019   const edm::Handle<double>& WT = e.getHandle(WTToken_);
0020   if (*(WT.product()) >= 0 && *(WT.product()) <= 4.0) {
0021     double weight = (*(WT.product()));
0022     if (fRandomEngine->flat() * ntaus_ * 2.0 < weight) {
0023       return true;
0024     }
0025   }
0026   return false;
0027 }
0028 
0029 DEFINE_FWK_MODULE(TauSpinnerFilter);