Public Member Functions | |
LHEProducer (const edm::ParameterSet ¶ms) | |
virtual | ~LHEProducer () |
Protected Member Functions | |
virtual void | beginJob () override |
virtual void | beginRun (edm::Run const &run, const edm::EventSetup &es) override |
virtual void | endJob () override |
virtual void | endRun (edm::Run const &run, const edm::EventSetup &es) override |
virtual void | endRunProduce (edm::Run &run, const edm::EventSetup &es) override |
virtual bool | filter (edm::Event &event, const edm::EventSetup &es) override |
Private Member Functions | |
double | matching (const HepMC::GenEvent *event, bool shower) const |
void | onBeforeHadronisation () |
void | onInit () |
bool | showeredEvent (const boost::shared_ptr< HepMC::GenEvent > &event) |
Private Attributes | |
BranchingRatios | branchingRatios |
unsigned int | eventsToPrint |
double | extCrossSect |
double | extFilterEff |
std::auto_ptr< Hadronisation > | hadronisation |
unsigned int | index |
std::auto_ptr< JetMatching > | jetMatching |
bool | matchingDone |
bool | matchSummary |
boost::shared_ptr< LHEEvent > | partonLevel |
std::vector< int > | removeResonances |
boost::shared_ptr< LHERunInfo > | runInfo |
double | weight |
Definition at line 33 of file LHEProducer.cc.
LHEProducer::LHEProducer | ( | const edm::ParameterSet & | params | ) | [explicit] |
Definition at line 71 of file LHEProducer.cc.
References branchingRatios, SurfaceDeformationFactory::create(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hadronisation, i, jetMatching, matchSummary, onBeforeHadronisation(), onInit(), removeResonances, lhef::BranchingRatios::set(), and showeredEvent().
: eventsToPrint(params.getUntrackedParameter<unsigned int>("eventsToPrint", 0)), extCrossSect(params.getUntrackedParameter<double>("crossSection", -1.0)), extFilterEff(params.getUntrackedParameter<double>("filterEfficiency", -1.0)), matchSummary(false) { hadronisation = Hadronisation::create( params.getParameter<edm::ParameterSet>("hadronisation")); if (params.exists("removeResonances")) removeResonances = params.getParameter<std::vector<int> >( "removeResonances"); std::set<std::string> matchingCapabilities; if (params.exists("jetMatching")) { edm::ParameterSet jetParams = params.getUntrackedParameter<edm::ParameterSet>( "jetMatching"); jetMatching = JetMatching::create(jetParams); matchingCapabilities = jetMatching->capabilities(); hadronisation->matchingCapabilities(matchingCapabilities); } produces<edm::HepMCProduct>(); produces<GenEventInfoProduct>(); produces<GenRunInfoProduct, edm::InRun>(); if (jetMatching.get()) { if (params.getUntrackedParameter<bool>( "preferShowerVetoCallback", true)) hadronisation->onShoweredEvent().connect( sigc::mem_fun(*this, &LHEProducer::showeredEvent)); hadronisation->onInit().connect( sigc::mem_fun(*this, &LHEProducer::onInit)); hadronisation->onBeforeHadronisation().connect( sigc::mem_fun(*this, &LHEProducer::onBeforeHadronisation)); matchSummary = matchingCapabilities.count("matchSummary"); if (matchSummary) { produces< std::vector<double> >("matchDeltaR"); produces< std::vector<double> >("matchDeltaPRel"); } } // force total branching ratio for QCD/QED to 1 for(int i = 0; i < 6; i++) branchingRatios.set(i); for(int i = 9; i < 23; i++) branchingRatios.set(i); }
LHEProducer::~LHEProducer | ( | ) | [virtual] |
Definition at line 126 of file LHEProducer.cc.
{ }
void LHEProducer::beginJob | ( | void | ) | [override, protected, virtual] |
Reimplemented from edm::one::EDFilterBase.
Definition at line 130 of file LHEProducer.cc.
References hadronisation.
{ hadronisation->init(); }
void LHEProducer::beginRun | ( | edm::Run const & | run, |
const edm::EventSetup & | es | ||
) | [override, protected, virtual] |
Definition at line 141 of file LHEProducer.cc.
References edm::Run::getByLabel(), index, and runInfo.
{ edm::Handle<LHERunInfoProduct> product; run.getByLabel("source", product); runInfo.reset(new LHERunInfo(*product)); index = 0; }
void LHEProducer::endJob | ( | void | ) | [override, protected, virtual] |
Reimplemented from edm::one::EDFilterBase.
Definition at line 135 of file LHEProducer.cc.
References hadronisation, and jetMatching.
{ hadronisation.reset(); jetMatching.reset(); }
void LHEProducer::endRun | ( | edm::Run const & | run, |
const edm::EventSetup & | es | ||
) | [override, protected, virtual] |
Definition at line 149 of file LHEProducer.cc.
{ }
void LHEProducer::endRunProduce | ( | edm::Run & | run, |
const edm::EventSetup & | es | ||
) | [override, protected, virtual] |
Definition at line 153 of file LHEProducer.cc.
References lhef::LHERunInfo::XSec::error, extCrossSect, extFilterEff, hadronisation, edm::Run::put(), runInfo, and lhef::LHERunInfo::XSec::value.
{ hadronisation->statistics(); LHERunInfo::XSec crossSection; if (runInfo) { crossSection = runInfo->xsec(); runInfo->statistics(); } std::auto_ptr<GenRunInfoProduct> runInfo(new GenRunInfoProduct); runInfo->setInternalXSec( GenRunInfoProduct::XSec(crossSection.value, crossSection.error)); runInfo->setExternalXSecLO(extCrossSect); runInfo->setFilterEfficiency(extFilterEff); run.put(runInfo); runInfo.reset(); }
bool LHEProducer::filter | ( | edm::Event & | event, |
const edm::EventSetup & | es | ||
) | [override, protected, virtual] |
Implements edm::one::EDFilterBase.
Definition at line 176 of file LHEProducer.cc.
References beamvalidation::br, branchingRatios, eventsToPrint, lhef::BranchingRatios::getFactor(), hadronisation, index, info, jetMatching, matching(), matchingDone, matchSummary, partonLevel, removeResonances, query::result, runInfo, and weight.
{ std::auto_ptr<edm::HepMCProduct> result(new edm::HepMCProduct); edm::Handle<LHEEventProduct> product; event.getByLabel("source", product); partonLevel.reset(new LHEEvent(runInfo, *product)); if (!removeResonances.empty()) partonLevel->removeResonances(removeResonances); if (product->pdf()) partonLevel->setPDF( std::auto_ptr<LHEEvent::PDF>( new LHEEvent::PDF(*product->pdf()))); hadronisation->setEvent(partonLevel); double br = branchingRatios.getFactor(hadronisation.get(), partonLevel); matchingDone = false; weight = 1.0; std::auto_ptr<HepMC::GenEvent> hadronLevel(hadronisation->hadronize()); if (!hadronLevel.get()) { if (matchingDone) { if (weight == 0.0) partonLevel->count(LHERunInfo::kSelected, br); else partonLevel->count(LHERunInfo::kKilled, br, weight); } else partonLevel->count(LHERunInfo::kTried, br); } if (!matchingDone && jetMatching.get() && hadronLevel.get()) weight = matching(hadronLevel.get(), false); if (weight == 0.0) { edm::LogInfo("Generator|LHEInterface") << "Event got rejected by the " "jet matching." << std::endl; if (hadronLevel.get()) { partonLevel->count(LHERunInfo::kSelected); hadronLevel.reset(); } } if (!hadronLevel.get()) { event.put(result); std::auto_ptr<GenEventInfoProduct> info( new GenEventInfoProduct); event.put(info); return false; } partonLevel->count(LHERunInfo::kAccepted, br, weight); hadronLevel->set_event_number(++index); if (eventsToPrint) { eventsToPrint--; hadronLevel->print(); } std::auto_ptr<GenEventInfoProduct> info( new GenEventInfoProduct(hadronLevel.get())); result->addHepMCData(hadronLevel.release()); event.put(result); event.put(info); if (jetMatching.get() && matchSummary) { std::auto_ptr< std::vector<double> > matchDeltaR( new std::vector<double>); std::auto_ptr< std::vector<double> > matchDeltaPRel( new std::vector<double>); typedef std::vector<JetMatching::JetPartonMatch> Matches; Matches matches = jetMatching->getMatchSummary(); for(Matches::const_iterator iter = matches.begin(); iter != matches.end(); ++iter) { if (!iter->isMatch()) continue; matchDeltaR->push_back(iter->delta); matchDeltaPRel->push_back(iter->jet.rho() / iter->parton.rho() - 1.0); } event.put(matchDeltaR, "matchDeltaR"); event.put(matchDeltaPRel, "matchDeltaPRel"); } return true; }
double LHEProducer::matching | ( | const HepMC::GenEvent * | event, |
bool | shower | ||
) | const [private] |
Definition at line 275 of file LHEProducer.cc.
References event(), jetMatching, and partonLevel.
Referenced by filter(), and showeredEvent().
{ if (!jetMatching.get()) return 1.0; return jetMatching->match(partonLevel->asHepMCEvent().get(), event, shower); }
void LHEProducer::onBeforeHadronisation | ( | ) | [private] |
Definition at line 296 of file LHEProducer.cc.
References jetMatching, and partonLevel.
Referenced by LHEProducer().
{ jetMatching->beforeHadronisation(partonLevel); }
void LHEProducer::onInit | ( | ) | [private] |
Definition at line 291 of file LHEProducer.cc.
References jetMatching, and runInfo.
Referenced by LHEProducer().
{ jetMatching->init(runInfo); }
bool LHEProducer::showeredEvent | ( | const boost::shared_ptr< HepMC::GenEvent > & | event | ) | [private] |
Definition at line 284 of file LHEProducer.cc.
References matching(), matchingDone, and weight.
Referenced by LHEProducer().
{ weight = matching(event.get(), true); matchingDone = true; return weight == 0.0; }
BranchingRatios LHEProducer::branchingRatios [private] |
Definition at line 68 of file LHEProducer.cc.
Referenced by filter(), and LHEProducer().
unsigned int LHEProducer::eventsToPrint [private] |
Definition at line 54 of file LHEProducer.cc.
Referenced by filter().
double LHEProducer::extCrossSect [private] |
Definition at line 59 of file LHEProducer.cc.
Referenced by endRunProduce().
double LHEProducer::extFilterEff [private] |
Definition at line 60 of file LHEProducer.cc.
Referenced by endRunProduce().
std::auto_ptr<Hadronisation> LHEProducer::hadronisation [private] |
Definition at line 56 of file LHEProducer.cc.
Referenced by beginJob(), endJob(), endRunProduce(), filter(), and LHEProducer().
unsigned int LHEProducer::index [private] |
Definition at line 65 of file LHEProducer.cc.
Referenced by beginRun(), and filter().
std::auto_ptr<JetMatching> LHEProducer::jetMatching [private] |
Definition at line 57 of file LHEProducer.cc.
Referenced by endJob(), filter(), LHEProducer(), matching(), onBeforeHadronisation(), and onInit().
bool LHEProducer::matchingDone [private] |
Definition at line 66 of file LHEProducer.cc.
Referenced by filter(), and showeredEvent().
bool LHEProducer::matchSummary [private] |
Definition at line 61 of file LHEProducer.cc.
Referenced by filter(), and LHEProducer().
boost::shared_ptr<LHEEvent> LHEProducer::partonLevel [private] |
Definition at line 63 of file LHEProducer.cc.
Referenced by filter(), matching(), and onBeforeHadronisation().
std::vector<int> LHEProducer::removeResonances [private] |
Definition at line 55 of file LHEProducer.cc.
Referenced by filter(), and LHEProducer().
boost::shared_ptr<LHERunInfo> LHEProducer::runInfo [private] |
Definition at line 64 of file LHEProducer.cc.
Referenced by beginRun(), endRunProduce(), filter(), and onInit().
double LHEProducer::weight [private] |
Definition at line 67 of file LHEProducer.cc.
Referenced by filter(), and showeredEvent().