#include <MCParticleReplacer.h>
Public Member Functions | |
virtual void | beginJob () |
virtual void | beginRun (const edm::Run &iRun, const edm::EventSetup &iSetup) override |
virtual void | endJob () |
virtual void | endRun (const edm::Run &iRun, const edm::EventSetup &iSetup) override |
MCParticleReplacer (const edm::ParameterSet &) | |
virtual void | produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override |
~MCParticleReplacer () | |
Private Types | |
enum | HepMcMode { kInvalid = 0, kNew, kReplace } |
Static Private Member Functions | |
static HepMcMode | stringToHepMcMode (const std::string &name) |
Private Attributes | |
HepMcMode | hepMcMode_ |
boost::shared_ptr < ParticleReplacerBase > | replacer_ |
edm::InputTag | src_ |
edm::InputTag | srcHepMC_ |
Definition at line 31 of file MCParticleReplacer.h.
enum MCParticleReplacer::HepMcMode [private] |
Definition at line 44 of file MCParticleReplacer.h.
MCParticleReplacer::MCParticleReplacer | ( | const edm::ParameterSet & | pset | ) | [explicit] |
Definition at line 14 of file MCParticleReplacer.cc.
: src_(pset.getParameter<edm::InputTag>("src")), srcHepMC_(pset.getParameter<edm::InputTag>("hepMcSrc")), hepMcMode_(stringToHepMcMode(pset.getParameter<std::string>("hepMcMode"))), replacer_(ParticleReplacerFactory::create(pset.getParameter<std::string>("algorithm"), pset)) { produces<edm::HepMCProduct>(); produces<GenFilterInfo>("minVisPtFilter"); }
MCParticleReplacer::~MCParticleReplacer | ( | ) |
Definition at line 24 of file MCParticleReplacer.cc.
{}
void MCParticleReplacer::beginJob | ( | void | ) | [virtual] |
Reimplemented from edm::EDProducer.
Definition at line 113 of file MCParticleReplacer.cc.
References replacer_.
{ replacer_->beginJob(); }
void MCParticleReplacer::beginRun | ( | const edm::Run & | iRun, |
const edm::EventSetup & | iSetup | ||
) | [override, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 101 of file MCParticleReplacer.cc.
References replacer_.
{ replacer_->beginRun(iRun, iSetup); }
void MCParticleReplacer::endJob | ( | void | ) | [virtual] |
Reimplemented from edm::EDProducer.
Definition at line 120 of file MCParticleReplacer.cc.
References replacer_.
{ replacer_->endJob(); }
void MCParticleReplacer::endRun | ( | const edm::Run & | iRun, |
const edm::EventSetup & | iSetup | ||
) | [override, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 106 of file MCParticleReplacer.cc.
References replacer_.
{ replacer_->endRun(); }
void MCParticleReplacer::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [override, virtual] |
Implements edm::EDProducer.
Definition at line 38 of file MCParticleReplacer.cc.
References DeDxDiscriminatorTools::charge(), Exception, edm::Event::getByLabel(), hepMcMode_, customizeTrackingMonitorSeedNumber::idx, info, kNew, kReplace, patZpeak::muons, p4, edm::Event::put(), replacer_, src_, srcHepMC_, and AlCaHLTBitMon_QueryRunRegistry::string.
{ std::vector<reco::Muon> muons; edm::Handle< std::vector< reco::CompositeCandidate > > combCandidatesHandle; if (iEvent.getByLabel(src_, combCandidatesHandle)) { if (combCandidatesHandle->size()==0) return; for (size_t idx = 0; idx < combCandidatesHandle->at(0).numberOfDaughters(); ++idx) { int charge = combCandidatesHandle->at(0).daughter(idx)->charge(); reco::Particle::LorentzVector p4 = combCandidatesHandle->at(0).daughter(idx)->p4(); reco::Particle::Point vtx = combCandidatesHandle->at(0).daughter(idx)->vertex(); muons.push_back( reco::Muon(charge, p4, vtx)); } } else { edm::Handle< edm::View<reco::Candidate> > candsHandle; if (iEvent.getByLabel(src_, candsHandle)) { for (size_t idx = 0; idx < candsHandle->size(); ++idx) { int charge = candsHandle->at(idx).charge(); reco::Particle::LorentzVector p4 = candsHandle->at(idx).p4(); reco::Particle::Point vtx = candsHandle->at(idx).vertex(); muons.push_back( reco::Muon(charge, p4, vtx)); } } } if (muons.size() == 0) { edm::LogError("MCParticleReplacer") << "No candidates or muons found!"; return; } std::auto_ptr<HepMC::GenEvent> evt; if(hepMcMode_ == kReplace) { edm::Handle<edm::HepMCProduct> HepMCHandle; iEvent.getByLabel(srcHepMC_, HepMCHandle); evt = replacer_->produce(muons, 0, HepMCHandle->GetEvent()); } else if(hepMcMode_ == kNew) { evt = replacer_->produce(muons); } else throw cms::Exception("LogicError") << "Invalid hepMcMode " << hepMcMode_ << std::endl; if(evt.get() != 0) { std::auto_ptr<edm::HepMCProduct> bare_product(new edm::HepMCProduct()); bare_product->addHepMCData(evt.release()); // transfer ownership of the HepMC:GenEvent to bare_product iEvent.put(bare_product); std::auto_ptr<GenFilterInfo> info(new GenFilterInfo(replacer_->tried, replacer_->passed)); iEvent.put(info, std::string("minVisPtFilter")); } }
MCParticleReplacer::HepMcMode MCParticleReplacer::stringToHepMcMode | ( | const std::string & | name | ) | [static, private] |
Definition at line 27 of file MCParticleReplacer.cc.
HepMcMode MCParticleReplacer::hepMcMode_ [private] |
Definition at line 49 of file MCParticleReplacer.h.
Referenced by produce().
boost::shared_ptr<ParticleReplacerBase> MCParticleReplacer::replacer_ [private] |
Definition at line 50 of file MCParticleReplacer.h.
Referenced by beginJob(), beginRun(), endJob(), endRun(), and produce().
edm::InputTag MCParticleReplacer::src_ [private] |
Definition at line 47 of file MCParticleReplacer.h.
Referenced by produce().
edm::InputTag MCParticleReplacer::srcHepMC_ [private] |
Definition at line 48 of file MCParticleReplacer.h.
Referenced by produce().