Public Member Functions | |
LHEProducer (const edm::ParameterSet ¶ms) | |
virtual | ~LHEProducer () |
Protected Member Functions | |
virtual void | beginJob (const edm::EventSetup &es) |
virtual bool | beginRun (edm::Run &run, const edm::EventSetup &es) |
virtual void | endJob () |
virtual bool | endRun (edm::Run &run, const edm::EventSetup &es) |
virtual bool | filter (edm::Event &event, const edm::EventSetup &es) |
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 32 of file LHEProducer.cc.
LHEProducer::LHEProducer | ( | const edm::ParameterSet & | params | ) | [explicit] |
Definition at line 68 of file LHEProducer.cc.
References branchingRatios, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hadronisation, i, jetMatching, matchSummary, onBeforeHadronisation(), onInit(), removeResonances, lhef::BranchingRatios::set(), and showeredEvent().
00068 : 00069 eventsToPrint(params.getUntrackedParameter<unsigned int>("eventsToPrint", 0)), 00070 extCrossSect(params.getUntrackedParameter<double>("crossSection", -1.0)), 00071 extFilterEff(params.getUntrackedParameter<double>("filterEfficiency", -1.0)), 00072 matchSummary(false) 00073 { 00074 hadronisation = Hadronisation::create( 00075 params.getParameter<edm::ParameterSet>("hadronisation")); 00076 00077 if (params.exists("removeResonances")) 00078 removeResonances = 00079 params.getParameter<std::vector<int> >( 00080 "removeResonances"); 00081 00082 std::set<std::string> matchingCapabilities; 00083 if (params.exists("jetMatching")) { 00084 edm::ParameterSet jetParams = 00085 params.getUntrackedParameter<edm::ParameterSet>( 00086 "jetMatching"); 00087 jetMatching = JetMatching::create(jetParams); 00088 00089 matchingCapabilities = jetMatching->capabilities(); 00090 hadronisation->matchingCapabilities(matchingCapabilities); 00091 } 00092 00093 produces<edm::HepMCProduct>(); 00094 produces<edm::GenInfoProduct, edm::InRun>(); 00095 00096 if (jetMatching.get()) { 00097 if (params.getUntrackedParameter<bool>( 00098 "preferShowerVetoCallback", true)) 00099 hadronisation->onShoweredEvent().connect( 00100 sigc::mem_fun(*this, 00101 &LHEProducer::showeredEvent)); 00102 hadronisation->onInit().connect( 00103 sigc::mem_fun(*this, &LHEProducer::onInit)); 00104 hadronisation->onBeforeHadronisation().connect( 00105 sigc::mem_fun(*this, 00106 &LHEProducer::onBeforeHadronisation)); 00107 00108 matchSummary = matchingCapabilities.count("matchSummary"); 00109 if (matchSummary) { 00110 produces< std::vector<double> >("matchDeltaR"); 00111 produces< std::vector<double> >("matchDeltaPRel"); 00112 } 00113 } 00114 00115 // force total branching ratio for QCD/QED to 1 00116 for(int i = 0; i < 6; i++) 00117 branchingRatios.set(i); 00118 for(int i = 9; i < 23; i++) 00119 branchingRatios.set(i); 00120 }
LHEProducer::~LHEProducer | ( | ) | [virtual] |
void LHEProducer::beginJob | ( | const edm::EventSetup & | es | ) | [protected, virtual] |
Reimplemented from edm::EDFilter.
Definition at line 126 of file LHEProducer.cc.
References hadronisation.
00127 { 00128 hadronisation->init(); 00129 }
bool LHEProducer::beginRun | ( | edm::Run & | run, | |
const edm::EventSetup & | es | |||
) | [protected, virtual] |
Reimplemented from edm::EDFilter.
Definition at line 137 of file LHEProducer.cc.
References edm::DataViewImpl::getByLabel(), index, and runInfo.
00138 { 00139 edm::Handle<LHERunInfoProduct> product; 00140 run.getByLabel("source", product); 00141 00142 runInfo.reset(new LHERunInfo(*product)); 00143 index = 0; 00144 00145 return true; 00146 }
Reimplemented from edm::EDFilter.
Definition at line 131 of file LHEProducer.cc.
References hadronisation, and jetMatching.
00132 { 00133 hadronisation.reset(); 00134 jetMatching.reset(); 00135 }
bool LHEProducer::endRun | ( | edm::Run & | run, | |
const edm::EventSetup & | es | |||
) | [protected, virtual] |
Reimplemented from edm::EDFilter.
Definition at line 148 of file LHEProducer.cc.
References PYTHIA8_PhotonJetpt20_30_10TeV_cff_py__GEN::crossSection, extCrossSect, extFilterEff, hadronisation, edm::Run::put(), runInfo, and lhef::LHERunInfo::XSec::value.
00149 { 00150 hadronisation->statistics(); 00151 00152 LHERunInfo::XSec crossSection; 00153 if (runInfo) { 00154 crossSection = runInfo->xsec(); 00155 runInfo->statistics(); 00156 } 00157 00158 std::auto_ptr<edm::GenInfoProduct> genInfoProd(new edm::GenInfoProduct); 00159 00160 genInfoProd->set_cross_section(crossSection.value); 00161 genInfoProd->set_external_cross_section(extCrossSect); 00162 genInfoProd->set_filter_efficiency(extFilterEff); 00163 00164 run.put(genInfoProd); 00165 00166 runInfo.reset(); 00167 00168 return true; 00169 }
bool LHEProducer::filter | ( | edm::Event & | event, | |
const edm::EventSetup & | es | |||
) | [protected, virtual] |
Implements edm::EDFilter.
Definition at line 171 of file LHEProducer.cc.
References branchingRatios, lat::endl(), eventsToPrint, lhef::BranchingRatios::getFactor(), hadronisation, index, iter, jetMatching, matching(), matchingDone, matchSummary, partonLevel, removeResonances, HLT_VtxMuL3::result, runInfo, and weight.
00172 { 00173 std::auto_ptr<edm::HepMCProduct> result(new edm::HepMCProduct); 00174 00175 edm::Handle<LHEEventProduct> product; 00176 event.getByLabel("source", product); 00177 00178 partonLevel.reset(new LHEEvent(runInfo, *product)); 00179 if (!removeResonances.empty()) 00180 partonLevel->removeResonances(removeResonances); 00181 00182 if (product->pdf()) 00183 partonLevel->setPDF( 00184 std::auto_ptr<LHEEvent::PDF>( 00185 new LHEEvent::PDF(*product->pdf()))); 00186 00187 hadronisation->setEvent(partonLevel); 00188 00189 double br = branchingRatios.getFactor(hadronisation.get(), 00190 partonLevel); 00191 00192 matchingDone = false; 00193 weight = 1.0; 00194 std::auto_ptr<HepMC::GenEvent> hadronLevel(hadronisation->hadronize()); 00195 00196 if (!hadronLevel.get()) { 00197 if (matchingDone) { 00198 if (weight == 0.0) 00199 partonLevel->count(LHERunInfo::kSelected, br); 00200 else 00201 partonLevel->count(LHERunInfo::kKilled, 00202 br, weight); 00203 } else 00204 partonLevel->count(LHERunInfo::kTried, br); 00205 } 00206 00207 if (!matchingDone && jetMatching.get() && hadronLevel.get()) 00208 weight = matching(hadronLevel.get(), false); 00209 00210 if (weight == 0.0) { 00211 edm::LogInfo("Generator|LHEInterface") 00212 << "Event got rejected by the " 00213 "jet matching." << std::endl; 00214 00215 if (hadronLevel.get()) { 00216 partonLevel->count(LHERunInfo::kSelected); 00217 hadronLevel.reset(); 00218 } 00219 } 00220 00221 if (!hadronLevel.get()) { 00222 event.put(result); 00223 return false; 00224 } 00225 00226 partonLevel->count(LHERunInfo::kAccepted, br, weight); 00227 00228 hadronLevel->set_event_number(++index); 00229 00230 if (eventsToPrint) { 00231 eventsToPrint--; 00232 hadronLevel->print(); 00233 } 00234 00235 result->addHepMCData(hadronLevel.release()); 00236 event.put(result); 00237 00238 if (jetMatching.get() && matchSummary) { 00239 std::auto_ptr< std::vector<double> > matchDeltaR( 00240 new std::vector<double>); 00241 std::auto_ptr< std::vector<double> > matchDeltaPRel( 00242 new std::vector<double>); 00243 00244 typedef std::vector<JetMatching::JetPartonMatch> Matches; 00245 Matches matches = jetMatching->getMatchSummary(); 00246 00247 for(Matches::const_iterator iter = matches.begin(); 00248 iter != matches.end(); ++iter) { 00249 if (!iter->isMatch()) 00250 continue; 00251 00252 matchDeltaR->push_back(iter->delta); 00253 matchDeltaPRel->push_back(iter->jet.mag() / 00254 iter->parton.mag() - 1.0); 00255 } 00256 00257 event.put(matchDeltaR, "matchDeltaR"); 00258 event.put(matchDeltaPRel, "matchDeltaPRel"); 00259 } 00260 00261 return true; 00262 }
double LHEProducer::matching | ( | const HepMC::GenEvent * | event, | |
bool | shower | |||
) | const [private] |
Definition at line 264 of file LHEProducer.cc.
References jetMatching, and partonLevel.
Referenced by filter(), and showeredEvent().
00265 { 00266 if (!jetMatching.get()) 00267 return 1.0; 00268 00269 return jetMatching->match(partonLevel->asHepMCEvent().get(), 00270 event, shower); 00271 }
void LHEProducer::onBeforeHadronisation | ( | ) | [private] |
Definition at line 285 of file LHEProducer.cc.
References jetMatching, and partonLevel.
Referenced by LHEProducer().
00286 { 00287 jetMatching->beforeHadronisation(partonLevel); 00288 }
void LHEProducer::onInit | ( | ) | [private] |
Definition at line 280 of file LHEProducer.cc.
References jetMatching, and runInfo.
Referenced by LHEProducer().
00281 { 00282 jetMatching->init(runInfo); 00283 }
bool LHEProducer::showeredEvent | ( | const boost::shared_ptr< HepMC::GenEvent > & | event | ) | [private] |
Definition at line 273 of file LHEProducer.cc.
References matching(), matchingDone, and weight.
Referenced by LHEProducer().
00274 { 00275 weight = matching(event.get(), true); 00276 matchingDone = true; 00277 return weight == 0.0; 00278 }
BranchingRatios LHEProducer::branchingRatios [private] |
unsigned int LHEProducer::eventsToPrint [private] |
double LHEProducer::extCrossSect [private] |
double LHEProducer::extFilterEff [private] |
std::auto_ptr<Hadronisation> LHEProducer::hadronisation [private] |
Definition at line 53 of file LHEProducer.cc.
Referenced by beginJob(), endJob(), endRun(), filter(), and LHEProducer().
unsigned int LHEProducer::index [private] |
std::auto_ptr<JetMatching> LHEProducer::jetMatching [private] |
Definition at line 54 of file LHEProducer.cc.
Referenced by endJob(), filter(), LHEProducer(), matching(), onBeforeHadronisation(), and onInit().
bool LHEProducer::matchingDone [private] |
bool LHEProducer::matchSummary [private] |
boost::shared_ptr<LHEEvent> LHEProducer::partonLevel [private] |
Definition at line 60 of file LHEProducer.cc.
Referenced by filter(), matching(), and onBeforeHadronisation().
std::vector<int> LHEProducer::removeResonances [private] |
boost::shared_ptr<LHERunInfo> LHEProducer::runInfo [private] |
Definition at line 61 of file LHEProducer.cc.
Referenced by beginRun(), endRun(), filter(), and onInit().
double LHEProducer::weight [private] |