#include <LHEEvent.h>
Public Types | |
typedef LHEEventProduct::PDF | |
Public Member Functions | |
void | addComment (const std::string &line) |
std::auto_ptr< HepMC::GenEvent > | asHepMCEvent () const |
void | attempted () |
void | count (LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0) |
void | fillEventInfo (HepMC::GenEvent *hepmc) const |
void | fillPdfInfo (HepMC::PdfInfo *info) const |
const std::vector< std::string > & | getComments () const |
const HEPEUP * | getHEPEUP () const |
const HEPRUP * | getHEPRUP () const |
const PDF * | getPDF () const |
const int | getReadAttempts () |
const boost::shared_ptr < LHERunInfo > & | getRunInfo () const |
LHEEvent (const boost::shared_ptr< LHERunInfo > &runInfo, std::istream &in) | |
LHEEvent (const boost::shared_ptr< LHERunInfo > &runInfo, const LHEEventProduct &product) | |
LHEEvent (const boost::shared_ptr< LHERunInfo > &runInfo, const HEPEUP &hepeup, const LHEEventProduct::PDF *pdf, const std::vector< std::string > &comments) | |
LHEEvent (const boost::shared_ptr< LHERunInfo > &runInfo, const HEPEUP &hepeup) | |
void | removeResonances (const std::vector< int > &ids) |
void | setPDF (std::auto_ptr< PDF > pdf) |
~LHEEvent () | |
Static Public Member Functions | |
static const HepMC::GenVertex * | findSignalVertex (const HepMC::GenEvent *event, bool status3=true) |
static void | fixHepMCEventTimeOrdering (HepMC::GenEvent *event) |
static void | removeParticle (lhef::HEPEUP &hepeup, int index) |
Private Member Functions | |
HepMC::GenParticle * | makeHepMCParticle (unsigned int i) const |
Static Private Member Functions | |
static bool | checkHepMCTree (const HepMC::GenEvent *event) |
Private Attributes | |
std::vector< std::string > | comments |
bool | counted |
HEPEUP | hepeup |
std::auto_ptr< PDF > | |
int | readAttemptCounter |
const boost::shared_ptr < LHERunInfo > | runInfo |
Definition at line 25 of file LHEEvent.h.
Definition at line 39 of file LHEEvent.h.
lhef::LHEEvent::LHEEvent | ( | const boost::shared_ptr< LHERunInfo > & | runInfo, |
std::istream & | in | ||
) |
Definition at line 36 of file LHEEvent.cc.
References abs, lhef::HEPEUP::AQCDUP, lhef::HEPEUP::AQEDUP, comments, hepeup, i, lhef::HEPEUP::ICOLUP, lhef::HEPEUP::IDPRUP, lhef::HEPEUP::IDUP, lhef::HEPEUP::ISTUP, geometryCSVtoXML::line, lhef::HEPEUP::MOTHUP, lhef::HEPEUP::NUP, pdf, lhef::HEPEUP::PUP, lhef::HEPEUP::resize(), lhef::HEPEUP::SCALUP, skipWhitespace(), lhef::HEPEUP::SPINUP, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, lhef::HEPEUP::VTIMUP, lhef::HEPEUP::XPDWUP, and lhef::HEPEUP::XWGTUP.
: runInfo(runInfo), counted(false), readAttemptCounter(0) { hepeup.NUP = 0; hepeup.XPDWUP.first = hepeup.XPDWUP.second = 0.0; in >> hepeup.NUP >> hepeup.IDPRUP >> hepeup.XWGTUP >> hepeup.SCALUP >> hepeup.AQEDUP >> hepeup.AQCDUP; if (!in.good()) throw cms::Exception("InvalidFormat") << "Les Houches file contained invalid" " event header." << std::endl; int idwtup = runInfo->getHEPRUP()->IDWTUP; if (idwtup >= 0 && hepeup.XWGTUP < 0) { edm::LogWarning("Generator|LHEInterface") << "Non-allowed egative event weight encountered." << std::endl; hepeup.XWGTUP = std::abs(hepeup.XWGTUP); } if (std::abs(idwtup) == 3 && std::abs(hepeup.XWGTUP) != 1.) { edm::LogInfo("Generator|LHEInterface") << "Event weight not set to one for abs(IDWTUP) == 3" << std::endl; hepeup.XWGTUP = hepeup.XWGTUP > 0. ? 1.0 : -1.0; } hepeup.resize(); for(int i = 0; i < hepeup.NUP; i++) { in >> hepeup.IDUP[i] >> hepeup.ISTUP[i] >> hepeup.MOTHUP[i].first >> hepeup.MOTHUP[i].second >> hepeup.ICOLUP[i].first >> hepeup.ICOLUP[i].second >> hepeup.PUP[i][0] >> hepeup.PUP[i][1] >> hepeup.PUP[i][2] >> hepeup.PUP[i][3] >> hepeup.PUP[i][4] >> hepeup.VTIMUP[i] >> hepeup.SPINUP[i]; if (!in.good()) throw cms::Exception("InvalidFormat") << "Les Houches file contained invalid event" " in particle line " << (i + 1) << "." << std::endl; } while(skipWhitespace(in) == '#') { std::string line; std::getline(in, line); std::istringstream ss(line); std::string tag; ss >> tag; if (tag == "#pdf") { pdf.reset(new PDF); ss >> pdf->id.first >> pdf->id.second >> pdf->x.first >> pdf->x.second >> pdf->scalePDF >> pdf->xPDF.first >> pdf->xPDF.second; if (ss.bad()) { edm::LogWarning("Generator|LHEInterface") << "Les Houches event contained" " unparseable PDF information." << std::endl; pdf.reset(); } else continue; } comments.push_back(line + "\n"); } if (!in.eof()) edm::LogWarning("Generator|LHEInterface") << "Les Houches file contained spurious" " content after event data." << std::endl; }
lhef::LHEEvent::LHEEvent | ( | const boost::shared_ptr< LHERunInfo > & | runInfo, |
const HEPEUP & | hepeup | ||
) |
Definition at line 112 of file LHEEvent.cc.
lhef::LHEEvent::LHEEvent | ( | const boost::shared_ptr< LHERunInfo > & | runInfo, |
const HEPEUP & | hepeup, | ||
const LHEEventProduct::PDF * | pdf, | ||
const std::vector< std::string > & | comments | ||
) |
lhef::LHEEvent::LHEEvent | ( | const boost::shared_ptr< LHERunInfo > & | runInfo, |
const LHEEventProduct & | product | ||
) |
Definition at line 127 of file LHEEvent.cc.
: runInfo(runInfo), hepeup(product.hepeup()), pdf(product.pdf() ? new PDF(*product.pdf()) : 0), comments(product.comments_begin(), product.comments_end()), counted(false), readAttemptCounter(0) { }
lhef::LHEEvent::~LHEEvent | ( | ) |
Definition at line 136 of file LHEEvent.cc.
{ }
void lhef::LHEEvent::addComment | ( | const std::string & | line | ) | [inline] |
Definition at line 50 of file LHEEvent.h.
std::auto_ptr< HepMC::GenEvent > lhef::LHEEvent::asHepMCEvent | ( | ) | const |
Definition at line 248 of file LHEEvent.cc.
References lhef::HEPEUP::AQCDUP, lhef::HEPEUP::AQEDUP, checkHepMCTree(), findSignalVertex(), configurableAnalysis::GenParticle, genParticleCandidates2GenParticles_cfi::genParticles, getHEPRUP(), hepeup, i, lhef::HEPEUP::IDPRUP, j, makeHepMCParticle(), lhef::HEPEUP::MOTHUP, lhef::HEPEUP::NUP, lhef::HEPEUP::SCALUP, and lhef::HEPEUP::VTIMUP.
{ std::auto_ptr<HepMC::GenEvent> hepmc(new HepMC::GenEvent); hepmc->set_signal_process_id(hepeup.IDPRUP); hepmc->set_event_scale(hepeup.SCALUP); hepmc->set_alphaQED(hepeup.AQEDUP); hepmc->set_alphaQCD(hepeup.AQCDUP); unsigned int nup = hepeup.NUP; // particles in event // any particles in HEPEUP block? if (!nup) { edm::LogWarning("Generator|LHEInterface") << "Les Houches Event does not contain any partons. " << "Not much to convert." ; return hepmc; } // stores (pointers to) converted particles std::vector<HepMC::GenParticle*> genParticles; std::vector<HepMC::GenVertex*> genVertices; // I. convert particles for(unsigned int i = 0; i < nup; i++) genParticles.push_back(makeHepMCParticle(i)); // II. loop again to build vertices for(unsigned int i = 0; i < nup; i++) { unsigned int mother1 = hepeup.MOTHUP.at(i).first; unsigned int mother2 = hepeup.MOTHUP.at(i).second; double cTau = hepeup.VTIMUP.at(i); // decay time // current particle has a mother? --- Sorry, parent! We're PC. if (mother1) { mother1--; // FORTRAN notation! if (mother2) mother2--; else mother2 = mother1; HepMC::GenParticle *in_par = genParticles.at(mother1); HepMC::GenVertex *current_vtx = in_par->end_vertex(); // vertex of first mother if (!current_vtx) { current_vtx = new HepMC::GenVertex( HepMC::FourVector(0, 0, 0, cTau)); // add vertex to event genVertices.push_back(current_vtx); } for(unsigned int j = mother1; j <= mother2; j++) // set mother-daughter relations if (!genParticles.at(j)->end_vertex()) current_vtx->add_particle_in(genParticles.at(j)); // connect THIS outgoing particle to current vertex current_vtx->add_particle_out(genParticles.at(i)); } } checkHepMCTree(hepmc.get()); // III. restore color flow // ok, nobody knows how to do it so far... // IV. fill run information const HEPRUP *heprup = getHEPRUP(); // set beam particles HepMC::GenParticle *b1 = new HepMC::GenParticle( HepMC::FourVector(0.0, 0.0, +heprup->EBMUP.first, heprup->EBMUP.first), heprup->IDBMUP.first); HepMC::GenParticle *b2 = new HepMC::GenParticle( HepMC::FourVector(0.0, 0.0, -heprup->EBMUP.second, heprup->EBMUP.second), heprup->IDBMUP.second); b1->set_status(3); b2->set_status(3); HepMC::GenVertex *v1 = new HepMC::GenVertex(); HepMC::GenVertex *v2 = new HepMC::GenVertex(); v1->add_particle_in(b1); v2->add_particle_in(b2); hepmc->add_vertex(v1); hepmc->add_vertex(v2); hepmc->set_beam_particles(b1, b2); // first two particles have to be the hard partons going into the interaction if (genParticles.size() >= 2) { if (!genParticles.at(0)->production_vertex() && !genParticles.at(1)->production_vertex()) { v1->add_particle_out(genParticles.at(0)); v2->add_particle_out(genParticles.at(1)); } else edm::LogWarning("Generator|LHEInterface") << "Initial partons do already have a" " production vertex. " << std::endl << "Beam particles not connected."; } else edm::LogWarning("Generator|LHEInterface") << "Can't find any initial partons to be" " connected to the beam particles."; for(std::vector<HepMC::GenVertex*>::const_iterator iter = genVertices.begin(); iter != genVertices.end(); ++iter) hepmc->add_vertex(*iter); // do some more consistency checks for(unsigned int i = 0; i < nup; i++) { if (!genParticles.at(i)->parent_event()) { edm::LogWarning("Generator|LHEInterface") << "Not all LHE particles could be stored" " stored in the HepMC event. " << std::endl << "Check the mother-daughter relations" " in the given LHE input file."; break; } } hepmc->set_signal_process_vertex( const_cast<HepMC::GenVertex*>( findSignalVertex(hepmc.get(), false))); return hepmc; }
void lhef::LHEEvent::attempted | ( | ) | [inline] |
Definition at line 58 of file LHEEvent.h.
References readAttemptCounter.
{ readAttemptCounter++; return; }
bool lhef::LHEEvent::checkHepMCTree | ( | const HepMC::GenEvent * | event | ) | [static, private] |
Definition at line 395 of file LHEEvent.cc.
References ntuplemaker::status.
Referenced by asHepMCEvent().
{ double px = 0, py = 0, pz = 0, E = 0; for(HepMC::GenEvent::particle_const_iterator iter = event->particles_begin(); iter != event->particles_end(); iter++) { int status = (*iter)->status(); HepMC::FourVector fv = (*iter)->momentum(); // incoming particles if (status == 3 && *iter != event->beam_particles().first && *iter != event->beam_particles().second) { px -= fv.px(); py -= fv.py(); pz -= fv.pz(); E -= fv.e(); } // outgoing particles if (status == 1) { px += fv.px(); py += fv.py(); pz += fv.pz(); E += fv.e(); } } if (px*px + py*py + pz*pz + E*E > 0.1) { edm::LogWarning("Generator|LHEInterface") << "Energy-momentum badly conserved. " << std::setprecision(3) << "sum p_i = [" << std::setw(7) << E << ", " << std::setw(7) << px << ", " << std::setw(7) << py << ", " << std::setw(7) << pz << "]"; return false; } return true; }
void lhef::LHEEvent::count | ( | LHERunInfo::CountMode | count, |
double | weight = 1.0 , |
||
double | matchWeight = 1.0 |
||
) |
Definition at line 198 of file LHEEvent.cc.
References counted, hepeup, lhef::HEPEUP::IDPRUP, runInfo, and lhef::HEPEUP::XWGTUP.
Referenced by Herwig6Hadronizer::hadronize(), gen::Pythia6Hadronizer::hadronize(), and Pythia8Hadronizer::hadronize().
void lhef::LHEEvent::fillEventInfo | ( | HepMC::GenEvent * | hepmc | ) | const |
Definition at line 240 of file LHEEvent.cc.
References lhef::HEPEUP::AQCDUP, lhef::HEPEUP::AQEDUP, hepeup, lhef::HEPEUP::IDPRUP, and lhef::HEPEUP::SCALUP.
Referenced by gen::Pythia6Hadronizer::finalizeEvent(), and Herwig6Hadronizer::finalizeEvent().
void lhef::LHEEvent::fillPdfInfo | ( | HepMC::PdfInfo * | info | ) | const |
Definition at line 212 of file LHEEvent.cc.
References abs, lhef::HEPRUP::EBMUP, getHEPRUP(), hepeup, lhef::HEPEUP::IDUP, lhef::HEPEUP::NUP, pdf, lhef::HEPEUP::PUP, and lhef::HEPEUP::SCALUP.
Referenced by gen::Pythia6Hadronizer::finalizeEvent(), and Herwig6Hadronizer::finalizeEvent().
{ if (pdf.get()) { info->set_id1(pdf->id.first); info->set_id2(pdf->id.second); info->set_x1(pdf->x.first); info->set_x2(pdf->x.second); info->set_pdf1(pdf->xPDF.first); info->set_pdf2(pdf->xPDF.second); info->set_scalePDF(pdf->scalePDF); } else if (hepeup.NUP >= 2) { const HEPRUP *heprup = getHEPRUP(); info->set_id1(hepeup.IDUP[0] == 21 ? 0 : hepeup.IDUP[0]); info->set_id2(hepeup.IDUP[1] == 21 ? 0 : hepeup.IDUP[1]); info->set_x1(std::abs(hepeup.PUP[0][2] / heprup->EBMUP.first)); info->set_x2(std::abs(hepeup.PUP[1][2] / heprup->EBMUP.second)); info->set_pdf1(-1.0); info->set_pdf2(-1.0); info->set_scalePDF(hepeup.SCALUP); } else { info->set_x1(-1.0); info->set_x2(-1.0); info->set_pdf1(-1.0); info->set_pdf2(-1.0); info->set_scalePDF(hepeup.SCALUP); } }
const HepMC::GenVertex * lhef::LHEEvent::findSignalVertex | ( | const HepMC::GenEvent * | event, |
bool | status3 = true |
||
) | [static] |
Definition at line 439 of file LHEEvent.cc.
Referenced by asHepMCEvent(), lhef::Hadronisation::hadronize(), and lhef::Hadronisation::showeredEvent().
{ double largestMass2 = -9.0e-30; const HepMC::GenVertex *vertex = 0; for(HepMC::GenEvent::vertex_const_iterator iter = event->vertices_begin(); iter != event->vertices_end(); ++iter) { if ((*iter)->particles_in_size() < 2) continue; if ((*iter)->particles_out_size() < 1 || ((*iter)->particles_out_size() == 1 && (!(*(*iter)->particles_out_const_begin())->end_vertex() || !(*(*iter)->particles_out_const_begin()) ->end_vertex()->particles_out_size()))) continue; double px = 0.0, py = 0.0, pz = 0.0, E = 0.0; bool hadStatus3 = false; for(HepMC::GenVertex::particles_out_const_iterator iter2 = (*iter)->particles_out_const_begin(); iter2 != (*iter)->particles_out_const_end(); ++iter2) { hadStatus3 = hadStatus3 || (*iter2)->status() == 3; px += (*iter2)->momentum().px(); py += (*iter2)->momentum().py(); pz += (*iter2)->momentum().pz(); E += (*iter2)->momentum().e(); } if (status3 && !hadStatus3) continue; double mass2 = E * E - (px * px + py * py + pz * pz); if (mass2 > largestMass2) { vertex = *iter; largestMass2 = mass2; } } return vertex; }
void lhef::LHEEvent::fixHepMCEventTimeOrdering | ( | HepMC::GenEvent * | event | ) | [static] |
Definition at line 503 of file LHEEvent.cc.
References lhef::fixSubTree().
Referenced by Herwig6Hadronizer::finalizeEvent(), and gen::PomwigHadronizer::finalizeEvent().
{ std::set<const HepMC::GenVertex*> visited; HepMC::FourVector zeroTime; for(HepMC::GenEvent::vertex_iterator iter = event->vertices_begin(); iter != event->vertices_end(); ++iter) fixSubTree(*iter, zeroTime, visited); }
const std::vector<std::string>& lhef::LHEEvent::getComments | ( | ) | const [inline] |
Definition at line 45 of file LHEEvent.h.
References comments.
Referenced by Herwig6Hadronizer::upEvnt().
{ return comments; }
const HEPEUP* lhef::LHEEvent::getHEPEUP | ( | ) | const [inline] |
Definition at line 42 of file LHEEvent.h.
References hepeup.
Referenced by gen::FortranCallback::fillEvent(), JetMatchingHook::setHEPEVT(), and JetMatchingHook::setLHEEvent().
{ return &hepeup; }
const HEPRUP* lhef::LHEEvent::getHEPRUP | ( | ) | const [inline] |
Definition at line 43 of file LHEEvent.h.
Referenced by asHepMCEvent(), and fillPdfInfo().
{ return runInfo->getHEPRUP(); }
const PDF* lhef::LHEEvent::getPDF | ( | ) | const [inline] |
Definition at line 44 of file LHEEvent.h.
{ return pdf.get(); }
const int lhef::LHEEvent::getReadAttempts | ( | ) | [inline] |
Definition at line 46 of file LHEEvent.h.
References readAttemptCounter.
{ return readAttemptCounter; }
const boost::shared_ptr<LHERunInfo>& lhef::LHEEvent::getRunInfo | ( | ) | const [inline] |
HepMC::GenParticle * lhef::LHEEvent::makeHepMCParticle | ( | unsigned int | i | ) | const [private] |
Definition at line 378 of file LHEEvent.cc.
References configurableAnalysis::GenParticle, hepeup, lhef::HEPEUP::IDUP, lhef::HEPEUP::ISTUP, lhef::HEPEUP::PUP, and ntuplemaker::status.
Referenced by asHepMCEvent().
{ HepMC::GenParticle *particle = new HepMC::GenParticle( HepMC::FourVector(hepeup.PUP.at(i)[0], hepeup.PUP.at(i)[1], hepeup.PUP.at(i)[2], hepeup.PUP.at(i)[3]), hepeup.IDUP.at(i)); int status = hepeup.ISTUP.at(i); particle->set_generated_mass(hepeup.PUP.at(i)[4]); particle->set_status(status > 0 ? (status == 2 ? 3 : status) : 3); return particle; }
void lhef::LHEEvent::removeParticle | ( | lhef::HEPEUP & | hepeup, |
int | index | ||
) | [static] |
Definition at line 147 of file LHEEvent.cc.
References i, lhef::HEPEUP::ICOLUP, lhef::HEPEUP::IDUP, getHLTprescales::index, lhef::HEPEUP::ISTUP, lhef::HEPEUP::MOTHUP, lhef::HEPEUP::NUP, lhef::pop(), lhef::HEPEUP::PUP, lhef::HEPEUP::resize(), lhef::HEPEUP::SPINUP, and lhef::HEPEUP::VTIMUP.
Referenced by removeResonances().
{ index--; if (index < 0 || index >= hepeup.NUP) { edm::LogError("Generator|LHEInterface") << "removeParticle: Index " << (index + 1) << " out of bounds." << std::endl; return; } std::pair<int, int> mo = hepeup.MOTHUP[index]; pop(hepeup.IDUP, index); pop(hepeup.ISTUP, index); pop(hepeup.MOTHUP, index); pop(hepeup.ICOLUP, index); pop(hepeup.PUP, index); pop(hepeup.VTIMUP, index); pop(hepeup.SPINUP, index); hepeup.NUP--; hepeup.resize(); index++; for(int i = 0; i < hepeup.NUP; i++) { if (hepeup.MOTHUP[i].first == index) { if (hepeup.MOTHUP[i].second > 0) edm::LogError("Generator|LHEInterface") << "removeParticle: Particle " << (i + 2) << " has two mothers." << std::endl; hepeup.MOTHUP[i] = mo; } if (hepeup.MOTHUP[i].first > index) hepeup.MOTHUP[i].first--; if (hepeup.MOTHUP[i].second > index) hepeup.MOTHUP[i].second--; } }
void lhef::LHEEvent::removeResonances | ( | const std::vector< int > & | ids | ) |
Definition at line 187 of file LHEEvent.cc.
References abs, spr::find(), hepeup, i, lhef::HEPEUP::IDUP, lhef::HEPEUP::MOTHUP, lhef::HEPEUP::NUP, and removeParticle().
void lhef::LHEEvent::setPDF | ( | std::auto_ptr< PDF > | ) | [inline] |
std::vector<std::string> lhef::LHEEvent::comments [private] |
Definition at line 78 of file LHEEvent.h.
Referenced by getComments(), and LHEEvent().
bool lhef::LHEEvent::counted [private] |
Definition at line 79 of file LHEEvent.h.
Referenced by count().
HEPEUP lhef::LHEEvent::hepeup [private] |
Definition at line 76 of file LHEEvent.h.
Referenced by asHepMCEvent(), count(), fillEventInfo(), fillPdfInfo(), getHEPEUP(), LHEEvent(), makeHepMCParticle(), and removeResonances().
std::auto_ptr<PDF> lhef::LHEEvent::pdf [private] |
Definition at line 77 of file LHEEvent.h.
Referenced by fillPdfInfo(), LHEEvent(), and setPDF().
int lhef::LHEEvent::readAttemptCounter [private] |
Definition at line 80 of file LHEEvent.h.
Referenced by attempted(), and getReadAttempts().
const boost::shared_ptr<LHERunInfo> lhef::LHEEvent::runInfo [private] |
Definition at line 74 of file LHEEvent.h.
Referenced by count(), and getRunInfo().