6 #include "HepMC/GenEvent.h" 7 #include "HepMC/PdfInfo.h" 8 #include "HepMC/PythiaWrapper6_4.h" 9 #include "HepMC/HEPEVT_Wrapper.h" 10 #include "HepMC/IO_HEPEVT.h" 26 #include "HepPID/ParticleIDTranslations.hh" 89 double p[5][pyjets_maxn],
v[5][pyjets_maxn];
101 fCOMEnergy(ps.getParameter<double>(
"comEnergy")),
102 fHepMCVerbosity(ps.getUntrackedParameter<
bool>(
"pythiaHepMCVerbosity",
false)),
103 fMaxEventsToPrint(ps.getUntrackedParameter<
int>(
"maxEventsToPrint", 0)),
104 fPythiaListVerbosity(ps.getUntrackedParameter<
int>(
"pythiaPylistVerbosity", 0)),
105 fDisplayPythiaBanner(ps.getUntrackedParameter<
bool>(
"displayPythiaBanner",
false)),
106 fDisplayPythiaCards(ps.getUntrackedParameter<
bool>(
"displayPythiaCards",
false)) {
109 if (ps.
exists(
"PPbarInitialState")) {
113 <<
"Pythia6 will be initialized for PROTON-ANTIPROTON INITIAL STATE. " 114 <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
115 std::cout <<
"Pythia6 will be initialized for PROTON-ANTIPROTON INITIAL STATE." << std::endl;
116 std::cout <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
120 }
else if (ps.
exists(
"ElectronPositronInitialState")) {
124 <<
"Pythia6 will be initialized for ELECTRON-POSITRON INITIAL STATE. " 125 <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
126 std::cout <<
"Pythia6 will be initialized for ELECTRON-POSITRON INITIAL STATE." << std::endl;
127 std::cout <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
131 }
else if (ps.
exists(
"ElectronProtonInitialState")) {
139 <<
"Pythia6 will be initialized for ELECTRON-PROTON INITIAL STATE. " 140 <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
141 std::cout <<
"Pythia6 will be initialized for ELECTRON-PROTON INITIAL STATE." << std::endl;
142 std::cout <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
146 }
else if (ps.
exists(
"PositronProtonInitialState")) {
154 <<
"Pythia6 will be initialized for POSITRON-PROTON INITIAL STATE. " 155 <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
156 std::cout <<
"Pythia6 will be initialized for POSITRON-PROTON INITIAL STATE." << std::endl;
157 std::cout <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
161 <<
" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron, " 162 "ElectronProton, and PositronProton \n";
172 if (ps.
exists(
"stopHadrons"))
176 if (ps.
exists(
"gluinoHadrons"))
180 if (ps.
exists(
"imposeProperTime")) {
185 if (ps.
exists(
"doPDGConvert"))
188 if (ps.
exists(
"jetMatching")) {
227 for (
int ip = 0; ip < pyjets_maxn; ip++) {
228 for (
int i = 0;
i < 5;
i++) {
240 for (
int ip = 0; ip < pyjets_maxn; ip++) {
241 for (
int i = 0;
i < 5;
i++) {
265 if (
event()->signal_process_id() <= 0)
267 if (
event()->event_scale() <= 0)
269 if (
event()->alphaQED() <= 0)
271 if (
event()->alphaQCD() <= 0)
278 pdf.set_id1(
pyint1.mint[14] == 21 ? 0 :
pyint1.mint[14]);
280 pdf.set_id2(
pyint1.mint[15] == 21 ? 0 :
pyint1.mint[15]);
282 pdf.set_x1(
pyint1.vint[40]);
284 pdf.set_x2(
pyint1.vint[41]);
289 if (pdf.scalePDF() <= 0)
290 pdf.set_scalePDF(
pyint1.vint[50]);
319 event()->set_pdf_info(pdf);
321 HepMC::GenCrossSection xsec;
325 xsec.set_cross_section(
cs, cserr);
326 event()->set_cross_section(xsec);
332 event()->weights().push_back(
pyint1.vint[96] * 1.0e9);
338 event()->weights().push_back(1. / (
pyint1.vint[98]));
343 eventInfo() = std::make_unique<GenEventInfoProduct>(
event().get());
349 eventInfo()->setBinningValues(std::vector<double>(1,
pypars.pari[16]));
359 for (HepMC::GenEvent::particle_iterator
part =
event()->particles_begin();
part !=
event()->particles_end();
361 (*part)->set_pdg_id(HepPID::translatePythiatoPDT((*part)->pdg_id()));
372 std::cout <<
"Event process = " <<
pypars.msti[0] << std::endl <<
"----------------------" << std::endl;
382 std::cout <<
"\n PYPARS \n" << std::endl;
385 <<
"PARI(I)" << std::endl;
386 for (
unsigned int ind = 0; ind < 200; ind++) {
519 int NPartsAfterDecays =
event().get()->particles_size();
520 int barcode = NPartsAfterDecays;
530 for (
int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
538 if (pydat3.mdcy[0][py6ptr - 1] != 1)
540 int py6id = HepPID::translatePDTtoPythia(
pdgid);
546 if (
part->momentum().t() <=
part->generated_mass()) {
550 for (
int i = 0;
i < 5;
i++) {
556 pyjets.k[1][0] = py6id;
557 pyjets.p[4][0] =
part->generated_mass();
558 pyjets.p[3][0] =
part->momentum().t();
559 pyjets.p[0][0] =
part->momentum().x();
560 pyjets.p[1][0] =
part->momentum().y();
561 pyjets.p[2][0] =
part->momentum().z();
562 HepMC::GenVertex* prod_vtx =
part->production_vertex();
565 pyjets.v[0][0] = prod_vtx->position().x();
566 pyjets.v[1][0] = prod_vtx->position().y();
567 pyjets.v[2][0] = prod_vtx->position().z();
568 pyjets.v[3][0] = prod_vtx->position().t();
581 for (
int iprt1 = 1; iprt1 < pyjets.n; iprt1++) {
584 HepMC::GenVertex* DecVtx =
new HepMC::GenVertex(
585 HepMC::FourVector(pyjets.v[0][iprt1], pyjets.v[1][iprt1], pyjets.v[2][iprt1], pyjets.v[3][iprt1]));
586 DecVtx->add_particle_in(
part);
589 HepMC::FourVector pmom(pyjets.p[0][iprt1], pyjets.p[1][iprt1], pyjets.p[2][iprt1], pyjets.p[3][iprt1]);
592 if (pyjets.k[0][iprt1] >= 1 && pyjets.k[0][iprt1] <= 10) {
594 }
else if (pyjets.k[0][iprt1] >= 11 && pyjets.k[0][iprt1] <= 20) {
596 }
else if (pyjets.k[0][iprt1] >= 21 && pyjets.k[0][iprt1] <= 30) {
598 }
else if (pyjets.k[0][iprt1] >= 31 && pyjets.k[0][iprt1] <= 100) {
599 dstatus = pyjets.k[0][iprt1];
602 new HepMC::GenParticle(pmom, HepPID::translatePythiatoPDT(pyjets.k[1][iprt1]), dstatus);
604 daughter->suggest_barcode(barcode);
605 DecVtx->add_particle_out(daughter);
608 for (iprt2 = iprt1 + 1; iprt2 < pyjets.n; iprt2++)
610 if (pyjets.k[2][iprt2] !=
parent) {
611 parent = pyjets.k[2][iprt2];
615 HepMC::FourVector pmomN(pyjets.p[0][iprt2], pyjets.p[1][iprt2], pyjets.p[2][iprt2], pyjets.p[3][iprt2]);
618 if (pyjets.k[0][iprt2] >= 1 && pyjets.k[0][iprt2] <= 10) {
620 }
else if (pyjets.k[0][iprt2] >= 11 && pyjets.k[0][iprt2] <= 20) {
622 }
else if (pyjets.k[0][iprt2] >= 21 && pyjets.k[0][iprt2] <= 30) {
624 }
else if (pyjets.k[0][iprt2] >= 31 && pyjets.k[0][iprt2] <= 100) {
625 dstatus = pyjets.k[0][iprt2];
628 new HepMC::GenParticle(pmomN, HepPID::translatePythiatoPDT(pyjets.k[1][iprt2]), dstatus);
630 daughterN->suggest_barcode(barcode);
631 DecVtx->add_particle_out(daughterN);
637 event().get()->add_vertex(DecVtx);
649 for (
int i = 0;
i < 5;
i++) {
699 call_pyinit(
"USER",
"",
"", 0.0);
705 edm::LogInfo(
"Generator|LHEInterface") <<
"Pythia6 hadronisation found an SLHA header, " 706 <<
"will be passed on to Pythia." << std::endl;
753 call_pyinit(
"3mom",
"e-",
"p", 0.0);
763 call_pyinit(
"3mom",
"e+",
"p", 0.0);
767 <<
" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron, ElectronProton, " 768 "and PositronProton \n";
779 for (
unsigned int i = 0;
i <
pdg.size();
i++) {
780 int PyID = HepPID::translatePDTtoPythia(
pdg[
i]);
784 std::ostringstream pyCard;
785 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
797 for (
unsigned int iss = 0; iss < settings.size(); iss++) {
798 if (settings[iss].
find(
"QED-brem-off") == std::string::npos)
800 size_t fnd1 = settings[iss].find(
':');
801 if (fnd1 == std::string::npos)
806 if (
value ==
"all") {
810 int PyID = HepPID::translatePDTtoPythia(
number);
818 <<
" Fatal conflict: \n mandatory internal directive to set MSTJ(39)=" << pyCode
819 <<
" overrides user setting MSTJ(39)=" <<
pydat1_.mstj[38]
820 <<
" - user will not get expected behaviour \n";
822 std::ostringstream pyCard;
823 pyCard <<
"MSTJ(39)=" << pyCode;
837 HepMC::GenEvent::vertex_const_iterator vbegin =
event()->vertices_begin();
838 HepMC::GenEvent::vertex_const_iterator vend =
event()->vertices_end();
839 HepMC::GenEvent::vertex_const_iterator vitr = vbegin;
840 for (; vitr != vend; ++vitr) {
841 HepMC::GenVertex::particle_iterator pbegin = (*vitr)->particles_begin(
HepMC::children);
842 HepMC::GenVertex::particle_iterator pend = (*vitr)->particles_end(
HepMC::children);
843 HepMC::GenVertex::particle_iterator pitr = pbegin;
844 for (; pitr != pend; ++pitr) {
845 if ((*pitr)->end_vertex())
847 if ((*pitr)->status() != 1)
850 int pdgcode =
abs((*pitr)->pdg_id());
852 if (pydat3.mdcy[0][
pycomp_(pdgcode) - 1] != 1)
855 double ctau = pydat2.pmas[3][
pycomp_(pdgcode) - 1];
856 HepMC::FourVector mom = (*pitr)->momentum();
857 HepMC::FourVector vin = (*vitr)->position();
862 bool decayInRange =
false;
863 while (!decayInRange) {
866 double proper_length = -ctau *
log(unif_rand);
867 double factor = proper_length / mom.m();
868 x = vin.x() +
factor * mom.px();
869 y = vin.y() +
factor * mom.py();
870 z = vin.z() +
factor * mom.pz();
871 t = vin.t() +
factor * mom.e();
873 if (
pydat1.mstj[21] == 4) {
877 }
else if (
pydat1.mstj[21] == 3) {
887 HepMC::GenVertex* vdec =
new HepMC::GenVertex(HepMC::FourVector(
x, y, z,
t));
888 event()->add_vertex(vdec);
889 vdec->add_particle_in((*pitr));
897 if (!
runInfo().internalXSec()) {
~Pythia6Hadronizer() override
T getParameter(std::string const &) const
unsigned int fPythiaListVerbosity
bool fDisplayPythiaBanner
Pythia6ServiceWithCallback(const edm::ParameterSet &ps)
unsigned int fMaxEventsToPrint
static struct gen::@751 pyjets_local
static JetMatching * getJetMatching()
bool exists(std::string const ¶meterName) const
checks if a parameter exists
HepMC::IO_HEPEVT pythia6_conv
bool call_pygive(const std::string &line)
void setLHERunInfo(lhef::LHERunInfo *lheri)
void count(LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0)
virtual void beforeHadronisation(const lhef::LHEEvent *event)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void setInternalXSec(const XSec &xsec)
void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
bool initializeForInternalPartons()
virtual int match(const lhef::LHEEvent *partonLevel, const std::vector< fastjet::PseudoJet > *jetInput)=0
T getUntrackedParameter(std::string const &, T const &) const
static const std::string kPythia6
GenRunInfoProduct & runInfo()
bool declareStableParticles(const std::vector< int > &)
void call_pylist(int mode)
void fillEventInfo(HepMC::GenEvent *hepmc) const
void resetMatchingStatus()
lhef::LHEEvent * lheEvent()
static const std::vector< std::string > theSharedResources
void setSLHAFromHeader(const std::vector< std::string > &lines)
std::vector< std::string > findHeader(const std::string &tag) const
Abs< T >::type abs(const T &t)
key
prepare the HTCondor submission files and eventually submit them
void setPYUPDAParams(bool afterPyinit)
bool initializeForExternalPartons()
Pythia6Hadronizer(edm::ParameterSet const &ps)
std::unique_ptr< HepMC::GenEvent > & event()
lhef::LHERunInfo * lheRunInfo()
Log< level::Info, false > LogInfo
static const std::string kFortranInstance
static FortranCallback * getInstance()
Pythia6Service * fPy6Service
void fillPdfInfo(HepMC::PdfInfo *info) const
void setLHEEvent(lhef::LHEEvent *lhee)
const char * classname() const
bool generatePartonsAndHadronize()
std::unique_ptr< GenEventInfoProduct > & eventInfo()
virtual void beforeHadronisationExec()
void setRandomEngine(CLHEP::HepRandomEngine *v)
void resetIterationsPerEvent()
bool fGluinoHadronsEnabled
bool declareSpecialSettings(const std::vector< std::string > &)
virtual void init(const lhef::LHERunInfo *runInfo)
static std::unique_ptr< JetMatching > create(const edm::ParameterSet ¶ms)
static JetMatching * fJetMatching