Skip to content

Commit

Permalink
Merge pull request #25900 from makortel/pluginFactorySimMuon
Browse files Browse the repository at this point in the history
Manage PluginFactory plugins with unique_ptr in SimMuon
  • Loading branch information
cmsbuild committed Feb 13, 2019
2 parents 97b802a + 3d80b47 commit 9e776f6
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 64 deletions.
10 changes: 5 additions & 5 deletions SimMuon/DTDigitizer/src/DTDigitizer.cc
Expand Up @@ -54,7 +54,11 @@ using namespace edm;
using namespace std;

// Constructor
DTDigitizer::DTDigitizer(const ParameterSet& conf_) {
DTDigitizer::DTDigitizer(const ParameterSet& conf_):
// Sync Algo
theSync{DTDigiSyncFactory::get()->create(conf_.getParameter<string>("SyncName"),
conf_.getParameter<ParameterSet>("pset"))}
{

// Set verbose output
debug=conf_.getUntrackedParameter<bool>("debug");
Expand Down Expand Up @@ -87,10 +91,6 @@ DTDigitizer::DTDigitizer(const ParameterSet& conf_) {
// further configurable smearing
smearing=conf_.getParameter<double>("Smearing"); // 3.

// Sync Algo
syncName = conf_.getParameter<string>("SyncName");
theSync.reset( DTDigiSyncFactory::get()->create(syncName,conf_.getParameter<ParameterSet>("pset")) );

// Debug flag to switch to the Ideal model
// it uses a constant drift velocity and doesn't set any external delay
IdealModel = conf_.getParameter<bool>("IdealModel");
Expand Down
3 changes: 1 addition & 2 deletions SimMuon/GEMDigitizer/interface/GEMDigiProducer.h
Expand Up @@ -38,8 +38,7 @@ class GEMDigiProducer : public edm::stream::EDProducer<>
//Name of Collection used for create the XF
edm::EDGetTokenT<CrossingFrame<PSimHit> > cf_token;

std::string digiModelString_;
GEMDigiModel* gemDigiModel_;
std::unique_ptr<GEMDigiModel> gemDigiModel_;
};

#endif
Expand Down
2 changes: 1 addition & 1 deletion SimMuon/GEMDigitizer/interface/ME0DigiPreRecoProducer.h
Expand Up @@ -32,7 +32,7 @@ class ME0DigiPreRecoProducer : public edm::stream::EDProducer<>
edm::EDGetTokenT<CrossingFrame<PSimHit> > cf_token;

std::string digiPreRecoModelString_;
ME0DigiPreRecoModel* me0DigiPreRecoModel_;
std::unique_ptr<ME0DigiPreRecoModel> me0DigiPreRecoModel_;
};

#endif
Expand Down
3 changes: 1 addition & 2 deletions SimMuon/GEMDigitizer/interface/ME0DigiProducer.h
Expand Up @@ -38,8 +38,7 @@ class ME0DigiProducer : public edm::stream::EDProducer<>
//Name of Collection used for create the XF
edm::EDGetTokenT<CrossingFrame<PSimHit> > cf_token;

std::string me0digiModelString_;
ME0DigiModel* ME0DigiModel_;
std::unique_ptr<ME0DigiModel> ME0DigiModel_;
};

#endif
Expand Down
22 changes: 10 additions & 12 deletions SimMuon/GEMDigitizer/src/GEMDigiProducer.cc
Expand Up @@ -27,7 +27,8 @@ namespace CLHEP {
}

GEMDigiProducer::GEMDigiProducer(const edm::ParameterSet& ps)
: digiModelString_(ps.getParameter<std::string>("digiModelString"))
: gemDigiModel_{GEMDigiModelFactory::get()->create("GEM" + ps.getParameter<std::string>("digiModelString") + "Model",
ps)}
{
produces<GEMDigiCollection>();
produces<StripDigiSimLinks>("GEM");
Expand All @@ -39,8 +40,8 @@ GEMDigiProducer::GEMDigiProducer(const edm::ParameterSet& ps)
<< "GEMDigiProducer::GEMDigiProducer() - RandomNumberGeneratorService is not present in configuration file.\n"
<< "Add the service in the configuration file or remove the modules that require it.";
}
gemDigiModel_ = GEMDigiModelFactory::get()->create("GEM" + digiModelString_ + "Model", ps);
LogDebug("GEMDigiProducer") << "Using GEM" + digiModelString_ + "Model";

LogDebug("GEMDigiProducer") << "Using GEM" + ps.getParameter<std::string>("digiModelString") + "Model";

std::string mix_(ps.getParameter<std::string>("mixLabel"));
std::string collection_(ps.getParameter<std::string>("inputCollection"));
Expand All @@ -49,10 +50,7 @@ GEMDigiProducer::GEMDigiProducer(const edm::ParameterSet& ps)
}


GEMDigiProducer::~GEMDigiProducer()
{
delete gemDigiModel_;
}
GEMDigiProducer::~GEMDigiProducer() = default;


void GEMDigiProducer::beginRun(const edm::Run&, const edm::EventSetup& eventSetup)
Expand All @@ -72,16 +70,16 @@ void GEMDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup)
edm::Handle<CrossingFrame<PSimHit> > cf;
e.getByToken(cf_token, cf);

std::unique_ptr<MixCollection<PSimHit> > hits(new MixCollection<PSimHit>(cf.product()));
MixCollection<PSimHit> hits{cf.product()};

// Create empty output
std::unique_ptr<GEMDigiCollection> digis(new GEMDigiCollection());
std::unique_ptr<StripDigiSimLinks> stripDigiSimLinks(new StripDigiSimLinks() );
std::unique_ptr<GEMDigiSimLinks> gemDigiSimLinks(new GEMDigiSimLinks() );
auto digis = std::make_unique<GEMDigiCollection>();
auto stripDigiSimLinks = std::make_unique<StripDigiSimLinks>();
auto gemDigiSimLinks = std::make_unique<GEMDigiSimLinks>();

// arrange the hits by eta partition
std::map<uint32_t, edm::PSimHitContainer> hitMap;
for (const auto& hit: *hits){
for (const auto& hit: hits){
hitMap[hit.detUnitId()].emplace_back(hit);
}

Expand Down
14 changes: 5 additions & 9 deletions SimMuon/GEMDigitizer/src/ME0DigiPreRecoProducer.cc
Expand Up @@ -25,6 +25,7 @@ namespace CLHEP {

ME0DigiPreRecoProducer::ME0DigiPreRecoProducer(const edm::ParameterSet& ps)
: digiPreRecoModelString_(ps.getParameter<std::string>("digiPreRecoModelString"))
, me0DigiPreRecoModel_{ME0DigiPreRecoModelFactory::get()->create("ME0" + digiPreRecoModelString_ + "Model", ps)}
{
produces<ME0DigiPreRecoCollection>();

Expand All @@ -34,7 +35,6 @@ ME0DigiPreRecoProducer::ME0DigiPreRecoProducer(const edm::ParameterSet& ps)
<< "ME0DigiPreRecoProducer::ME0PreRecoDigiProducer() - RandomNumberGeneratorService is not present in configuration file.\n"
<< "Add the service in the configuration file or remove the modules that require it.";
}
me0DigiPreRecoModel_ = ME0DigiPreRecoModelFactory::get()->create("ME0" + digiPreRecoModelString_ + "Model", ps);
LogDebug("ME0DigiPreRecoProducer") << "Using ME0" + digiPreRecoModelString_ + "Model";

std::string mix_(ps.getParameter<std::string>("mixLabel"));
Expand All @@ -44,11 +44,7 @@ ME0DigiPreRecoProducer::ME0DigiPreRecoProducer(const edm::ParameterSet& ps)
}


ME0DigiPreRecoProducer::~ME0DigiPreRecoProducer()
{
delete me0DigiPreRecoModel_;
}

ME0DigiPreRecoProducer::~ME0DigiPreRecoProducer() = default;

void ME0DigiPreRecoProducer::beginRun(const edm::Run&, const edm::EventSetup& eventSetup)
{
Expand All @@ -68,14 +64,14 @@ void ME0DigiPreRecoProducer::produce(edm::Event& e, const edm::EventSetup& event
edm::Handle<CrossingFrame<PSimHit> > cf;
e.getByToken(cf_token, cf);

std::unique_ptr<MixCollection<PSimHit> > hits( new MixCollection<PSimHit>(cf.product()) );
MixCollection<PSimHit> hits{cf.product()};

// Create empty output
std::unique_ptr<ME0DigiPreRecoCollection> digis(new ME0DigiPreRecoCollection());
auto digis = std::make_unique<ME0DigiPreRecoCollection>();

// arrange the hits by eta partition
std::map<uint32_t, edm::PSimHitContainer> hitMap;
for (const auto& hit: *hits){
for (const auto& hit: hits){
hitMap[hit.detUnitId()].push_back(hit);
}

Expand Down
22 changes: 10 additions & 12 deletions SimMuon/GEMDigitizer/src/ME0DigiProducer.cc
Expand Up @@ -27,7 +27,8 @@ namespace CLHEP {
}

ME0DigiProducer::ME0DigiProducer(const edm::ParameterSet& ps)
: me0digiModelString_(ps.getParameter<std::string>("digiModelString"))
: ME0DigiModel_{ME0DigiModelFactory::get()->create("ME0" + ps.getParameter<std::string>("digiModelString") + "Model",
ps)}
{
produces<ME0DigiCollection>();
produces<StripDigiSimLinks>("ME0");
Expand All @@ -39,8 +40,8 @@ ME0DigiProducer::ME0DigiProducer(const edm::ParameterSet& ps)
<< "ME0DigiProducer::ME0DigiProducer() - RandomNumberGeneratorService is not present in configuration file.\n"
<< "Add the service in the configuration file or remove the modules that require it.";
}
ME0DigiModel_ = ME0DigiModelFactory::get()->create("ME0" + me0digiModelString_ + "Model", ps);
LogDebug("ME0DigiProducer") << "Using ME0" + me0digiModelString_ + "Model";

LogDebug("ME0DigiProducer") << "Using ME0" + ps.getParameter<std::string>("digiModelString") + "Model";

std::string mix_(ps.getParameter<std::string>("mixLabel"));
std::string collection_(ps.getParameter<std::string>("inputCollection"));
Expand All @@ -49,10 +50,7 @@ ME0DigiProducer::ME0DigiProducer(const edm::ParameterSet& ps)
}


ME0DigiProducer::~ME0DigiProducer()
{
delete ME0DigiModel_;
}
ME0DigiProducer::~ME0DigiProducer() = default;


void ME0DigiProducer::beginRun(const edm::Run&, const edm::EventSetup& eventSetup)
Expand All @@ -72,16 +70,16 @@ void ME0DigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup)
edm::Handle<CrossingFrame<PSimHit> > cf;
e.getByToken(cf_token, cf);

std::unique_ptr<MixCollection<PSimHit> > hits(new MixCollection<PSimHit>(cf.product()));
MixCollection<PSimHit> hits{cf.product()};

// Create empty output
std::unique_ptr<ME0DigiCollection> digis(new ME0DigiCollection());
std::unique_ptr<StripDigiSimLinks> stripDigiSimLinks(new StripDigiSimLinks() );
std::unique_ptr<ME0DigiSimLinks> me0DigiSimLinks(new ME0DigiSimLinks() );
auto digis = std::make_unique<ME0DigiCollection>();
auto stripDigiSimLinks = std::make_unique<StripDigiSimLinks>();
auto me0DigiSimLinks = std::make_unique<ME0DigiSimLinks>();

// arrange the hits by eta partition
std::map<uint32_t, edm::PSimHitContainer> hitMap;
for (const auto& hit: *hits){
for (const auto& hit: hits){
hitMap[hit.detUnitId()].emplace_back(hit);
}

Expand Down
13 changes: 5 additions & 8 deletions SimMuon/RPCDigitizer/src/IRPCDigitizer.cc
Expand Up @@ -9,17 +9,14 @@

// default constructor allocates default wire and strip digitizers

IRPCDigitizer::IRPCDigitizer(const edm::ParameterSet& config) {
theName = config.getParameter<std::string>("digiIRPCModel");
theRPCSim = RPCSimFactory::get()->create(theName,config.getParameter<edm::ParameterSet>("digiIRPCModelConfig"));
IRPCDigitizer::IRPCDigitizer(const edm::ParameterSet& config):
theRPCSim{RPCSimFactory::get()->create(config.getParameter<std::string>("digiIRPCModel"),
config.getParameter<edm::ParameterSet>("digiIRPCModelConfig"))}
{
theNoise=config.getParameter<bool>("doBkgNoise");
}

IRPCDigitizer::~IRPCDigitizer() {
if( theRPCSim )
delete theRPCSim;
theRPCSim = nullptr;
}
IRPCDigitizer::~IRPCDigitizer() = default;

void IRPCDigitizer::doAction(MixCollection<PSimHit> & simHits,
RPCDigiCollection & rpcDigis,
Expand Down
2 changes: 1 addition & 1 deletion SimMuon/RPCDigitizer/src/IRPCDigitizer.h
Expand Up @@ -55,7 +55,7 @@ class IRPCDigitizer

private:
const RPCGeometry * theGeometry;
RPCSim* theRPCSim;
std::unique_ptr<RPCSim> theRPCSim;
RPCSimSetUp * theSimSetUp;
std::string theName;
bool theNoise;
Expand Down
16 changes: 6 additions & 10 deletions SimMuon/RPCDigitizer/src/RPCDigitizer.cc
Expand Up @@ -9,17 +9,13 @@

// default constructor allocates default wire and strip digitizers

RPCDigitizer::RPCDigitizer(const edm::ParameterSet& config) {
theName = config.getParameter<std::string>("digiModel");
theRPCSim = RPCSimFactory::get()->create(theName,config.getParameter<edm::ParameterSet>("digiModelConfig"));
theNoise=config.getParameter<bool>("doBkgNoise");
}
RPCDigitizer::RPCDigitizer(const edm::ParameterSet& config):
theRPCSim{RPCSimFactory::get()->create(config.getParameter<std::string>("digiModel"),
config.getParameter<edm::ParameterSet>("digiModelConfig"))},
theNoise{config.getParameter<bool>("doBkgNoise")}
{}

RPCDigitizer::~RPCDigitizer() {
if( theRPCSim )
delete theRPCSim;
theRPCSim = nullptr;
}
RPCDigitizer::~RPCDigitizer() = default;

void RPCDigitizer::doAction(MixCollection<PSimHit> & simHits,
RPCDigiCollection & rpcDigis,
Expand Down
3 changes: 1 addition & 2 deletions SimMuon/RPCDigitizer/src/RPCDigitizer.h
Expand Up @@ -55,9 +55,8 @@ class RPCDigitizer

private:
const RPCGeometry * theGeometry;
RPCSim* theRPCSim;
std::unique_ptr<RPCSim> theRPCSim;
RPCSimSetUp * theSimSetUp;
std::string theName;
bool theNoise;
};

Expand Down

0 comments on commit 9e776f6

Please sign in to comment.