diff --git a/RecoParticleFlow/PFSimProducer/plugins/BuildFile.xml b/RecoParticleFlow/PFSimProducer/plugins/BuildFile.xml index 1e928a525ad9b..a81770913d136 100644 --- a/RecoParticleFlow/PFSimProducer/plugins/BuildFile.xml +++ b/RecoParticleFlow/PFSimProducer/plugins/BuildFile.xml @@ -1,4 +1,4 @@ - + diff --git a/RecoParticleFlow/PFSimProducer/plugins/ConfigurableFlatResolutionModel.cc b/RecoParticleFlow/PFSimProducer/plugins/ConfigurableFlatResolutionModel.cc new file mode 100644 index 0000000000000..ab0a8f9c42328 --- /dev/null +++ b/RecoParticleFlow/PFSimProducer/plugins/ConfigurableFlatResolutionModel.cc @@ -0,0 +1,19 @@ +#include "ResolutionModel.h" + +class ConfigurableFlatResolutionModel : public ResolutionModel { +public: + ConfigurableFlatResolutionModel( const edm::ParameterSet& conf ) : + ResolutionModel( conf ), + reso_( conf.getParameter("resolutionInNs") ) { + } + + virtual float getTimeResolution(const reco::Track&) const override { return reso_; } + virtual float getTimeResolution(const reco::PFCluster&) const override { return reso_; } + +private: + const float reso_; +}; + +DEFINE_EDM_PLUGIN(ResolutionModelFactory, + ConfigurableFlatResolutionModel, + "ConfigurableFlatResolutionModel"); diff --git a/RecoParticleFlow/PFSimProducer/plugins/EcalBarrelClusterFastTimer.cc b/RecoParticleFlow/PFSimProducer/plugins/EcalBarrelClusterFastTimer.cc index b5bfd80c961c6..c3faa5d6bc898 100644 --- a/RecoParticleFlow/PFSimProducer/plugins/EcalBarrelClusterFastTimer.cc +++ b/RecoParticleFlow/PFSimProducer/plugins/EcalBarrelClusterFastTimer.cc @@ -3,7 +3,7 @@ // assign a reasonable time guess #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -34,12 +34,12 @@ #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/RandomNumberGenerator.h" -class EcalBarrelClusterFastTimer : public edm::EDProducer { +class EcalBarrelClusterFastTimer : public edm::global::EDProducer<> { public: EcalBarrelClusterFastTimer(const edm::ParameterSet&); ~EcalBarrelClusterFastTimer() { } - virtual void produce(edm::Event&, const edm::EventSetup&) override; + virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; private: // inputs @@ -54,8 +54,6 @@ class EcalBarrelClusterFastTimer : public edm::EDProducer { std::pair getTimeForECALPFCluster(const EcalRecHitCollection&,const reco::PFCluster&) const; float correctTimeToVertex(const float intime, const DetId& timeDet, const reco::Vertex& vtx, const CaloSubdetectorGeometry* ecalGeom) const; - // RNG - CLHEP::HepRandomEngine* _rng_engine; }; DEFINE_FWK_MODULE(EcalBarrelClusterFastTimer); @@ -104,10 +102,13 @@ EcalBarrelClusterFastTimer::EcalBarrelClusterFastTimer(const edm::ParameterSet& << "EcalBarrelClusterFastTimer::EcalBarrelClusterFastTimer() - RandomNumberGeneratorService is not present in configuration file.\n" << "Add the service in the configuration file or remove the modules that require it."; } - _rng_engine = &(rng->getEngine()); } -void EcalBarrelClusterFastTimer::produce(edm::Event& evt, const edm::EventSetup& es) { +void EcalBarrelClusterFastTimer::produce(edm::StreamID sid, edm::Event& evt, const edm::EventSetup& es) const { + // get RNG engine + edm::Service rng; + auto rng_engine = &(rng->getEngine(sid)); + edm::Handle > clustersH; edm::Handle timehitsH; edm::Handle verticesH; @@ -145,7 +146,7 @@ void EcalBarrelClusterFastTimer::produce(edm::Event& evt, const edm::EventSetup& for( unsigned i = 0 ; i < clusters.size(); ++i ) { const float theresolution = reso->getTimeResolution(clusters[i]); - smeared_times.emplace_back( CLHEP::RandGauss::shoot(_rng_engine, times[i].first, theresolution), times[i].second ); + smeared_times.emplace_back( CLHEP::RandGauss::shoot(rng_engine, times[i].first, theresolution), times[i].second ); resolutions.push_back( theresolution ); } diff --git a/RecoParticleFlow/PFSimProducer/plugins/PerfectResolutionModel.cc b/RecoParticleFlow/PFSimProducer/plugins/PerfectResolutionModel.cc new file mode 100644 index 0000000000000..26829f734c91b --- /dev/null +++ b/RecoParticleFlow/PFSimProducer/plugins/PerfectResolutionModel.cc @@ -0,0 +1,14 @@ +#include "ResolutionModel.h" + +class PerfectResolutionModel : public ResolutionModel { +public: + PerfectResolutionModel( const edm::ParameterSet& conf ) : ResolutionModel( conf ) {} + + virtual float getTimeResolution(const reco::Track&) const override { return 1e-6; } + virtual float getTimeResolution(const reco::PFCluster&) const override { return 1e-6; } + +}; + +DEFINE_EDM_PLUGIN(ResolutionModelFactory, + PerfectResolutionModel, + "PerfectResolutionModel"); diff --git a/RecoParticleFlow/PFSimProducer/plugins/ResolutionModel.cc b/RecoParticleFlow/PFSimProducer/plugins/ResolutionModel.cc new file mode 100644 index 0000000000000..7b47fd80b0de7 --- /dev/null +++ b/RecoParticleFlow/PFSimProducer/plugins/ResolutionModel.cc @@ -0,0 +1,4 @@ +#include "ResolutionModel.h" + +EDM_REGISTER_PLUGINFACTORY(ResolutionModelFactory, + "ResolutionModelFactory"); diff --git a/RecoParticleFlow/PFSimProducer/plugins/ResolutionModel.h b/RecoParticleFlow/PFSimProducer/plugins/ResolutionModel.h new file mode 100644 index 0000000000000..101507a844f68 --- /dev/null +++ b/RecoParticleFlow/PFSimProducer/plugins/ResolutionModel.h @@ -0,0 +1,33 @@ +#ifndef __RecoFTL_FastTimingKludge_ResolutionModel_h__ +#define __RecoFTL_FastTimingKludge_ResolutionModel_h__ + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/ParticleFlowReco/interface/PFCluster.h" + +#include +#include + +class ResolutionModel { + public: + ResolutionModel(const edm::ParameterSet& conf): + _modelName(conf.getParameter("modelName")) { + } + virtual ~ResolutionModel() { } + // get rid of things we should never use... + ResolutionModel(const ResolutionModel&) = delete; + ResolutionModel& operator=(const ResolutionModel&) = delete; + + virtual float getTimeResolution(const reco::Track&) const { return -1.f; } + virtual float getTimeResolution(const reco::PFCluster&) const { return -1.f; } + + const std::string& name() const { return _modelName; } + + private: + const std::string _modelName; +}; + +#include "FWCore/PluginManager/interface/PluginFactory.h" +typedef edmplugin::PluginFactory< ResolutionModel* (const edm::ParameterSet&) > ResolutionModelFactory; + +#endif diff --git a/RecoParticleFlow/PFSimProducer/python/ecalBarrelClusterFastTimer_cfi.py b/RecoParticleFlow/PFSimProducer/python/ecalBarrelClusterFastTimer_cfi.py new file mode 100644 index 0000000000000..fe4f8d09bf791 --- /dev/null +++ b/RecoParticleFlow/PFSimProducer/python/ecalBarrelClusterFastTimer_cfi.py @@ -0,0 +1,12 @@ +import FWCore.ParameterSet.Config as cms + +ecalBarrelClusterFastTimer = cms.EDProducer( + 'EcalBarrelClusterFastTimer', + ebTimeHits = cms.InputTag('ecalDetailedTimeRecHit:EcalRecHitsEB'), + ebClusters = cms.InputTag('particleFlowClusterECAL'), + timedVertices = cms.InputTag('offlinePrimaryVertices4D'), + minFractionToConsider = cms.double(0.1), + minEnergyToConsider = cms.double(0.0), + ecalDepth = cms.double(7.0), + resolutionModels = cms.VPSet( cms.PSet( modelName = cms.string('PerfectResolutionModel') ) ) + )