6 #include "HepMC/GenEvent.h"
7 #include "HepMC/PdfInfo.h"
8 #include "HepMC/PythiaWrapper6_4.h"
11 #include "HepMC/HEPEVT_Wrapper.h"
12 #include "HepMC/IO_HEPEVT.h"
13 #include "HepMC/IO_GenEvent.h"
20 #include "HepPID/ParticleIDTranslations.hh"
24 #include "CLHEP/Random/RandFlat.h"
49 if(
debug && ++call < 100)
cout<<
"dcasrn from c++, call: "<<call<<
" random number: "<<rdm_nb<<endl;
65 FortranCallback::getInstance()->fillHeader();
69 FortranCallback::getInstance()->fillEvent();
82 double p[5][pyjets_maxn],
v[5][pyjets_maxn];
96 fComEnergy(pset.getParameter<double>(
"comEnergy")),
97 fextCrossSection(pset.getUntrackedParameter<double>(
"crossSection",-1.)),
98 fextCrossSectionError(pset.getUntrackedParameter<double>(
"crossSectionError",-1.)),
99 fFilterEfficiency(pset.getUntrackedParameter<double>(
"filterEfficiency",-1.)),
101 fMaxEventsToPrint(pset.getUntrackedParameter<int>(
"maxEventsToPrint",0)),
102 fHepMCVerbosity(pset.getUntrackedParameter<bool>(
"pythiaHepMCVerbosity",
false)),
103 fPythiaListVerbosity(pset.getUntrackedParameter<int>(
"pythiaPylistVerbosity",0)),
105 fDisplayPythiaBanner(pset.getUntrackedParameter<bool>(
"displayPythiaBanner",
false)),
106 fDisplayPythiaCards(pset.getUntrackedParameter<bool>(
"displayPythiaCards",
false)){
111 if(
debug)
cout<<
"seed: "<<rng->mySeed()<<endl;
112 CLHEP::HepRandomEngine& engine = rng->getEngine();
113 fFlat =
new CLHEP::RandFlat(engine);
117 if(pset.
exists(
"doPDGConvert"))
125 <<
" Pythia did not accept MSTU(12)=12345";
134 <<
" Pythia did not accept MSTU(13)=0";
151 for(
int ip=0; ip<pyjets_maxn; ip++){
152 for(
int i=0;
i<5;
i++){
166 for(
int ip=0; ip<pyjets_maxn; ip++){
167 for(
int i=0;
i<5;
i++){
182 if(
event()->signal_process_id() <= 0)
event()->set_signal_process_id(
pypars.msti[0]);
190 if(pdf.id1() <= 0) pdf.set_id1(
pyint1.mint[14] == 21 ? 0 :
pyint1.mint[14]);
191 if(pdf.id2() <= 0) pdf.set_id2(
pyint1.mint[15] == 21 ? 0 :
pyint1.mint[15]);
192 if(pdf.x1() <= 0) pdf.set_x1(
pyint1.vint[40]);
193 if(pdf.x2() <= 0) pdf.set_x2(
pyint1.vint[41]);
194 if(pdf.pdf1() <= 0) pdf.set_pdf1(
pyint1.vint[38] /
pyint1.vint[40]);
195 if(pdf.pdf2() <= 0) pdf.set_pdf2(
pyint1.vint[39] /
pyint1.vint[41]);
196 if(pdf.scalePDF() <= 0) pdf.set_scalePDF(
pyint1.vint[50]);
198 event()->set_pdf_info(pdf) ;
201 cout<<
"standard Py6 event weight: pyint1.vint[96]: "<<
pyint1.vint[96]<<endl;
202 cout<<
"event weight returned by PYEVWT: 1./(pyint1.vint[98]): "<<1./(
pyint1.vint[98])<<endl;
212 event()->weights().push_back(1.);
231 for(HepMC::GenEvent::particle_iterator
part =
event()->particles_begin();
233 (*part)->set_pdg_id(HepPID::translatePythiatoPDT((*part)->pdg_id()));
242 cout <<
"Event process = "<<
pypars.msti[0]<<endl<<
"----------------------"<<endl;
262 if(
pyint1.mint[50] != 0 ){
293 int NPartsAfterDecays =
event().get()->particles_size();
294 int barcode = NPartsAfterDecays;
304 for(
int ipart=NPartsAfterDecays; ipart>NPartsBeforeDecays; ipart-- ){
307 int status = part->status();
308 if ( status != 1 )
continue;
310 int pdgid = part->pdg_id();
313 if(pydat3.mdcy[0][py6ptr-1] != 1)
continue;
315 int py6id = HepPID::translatePDTtoPythia(pdgid);
321 if(part->momentum().t() <= part->generated_mass()){
328 for(
int i=0;
i<5;
i++){
335 pyjets.k[1][0] = py6id;
336 pyjets.p[4][0] = part->generated_mass();
337 pyjets.p[3][0] = part->momentum().t();
338 pyjets.p[0][0] = part->momentum().x();
339 pyjets.p[1][0] = part->momentum().y();
340 pyjets.p[2][0] = part->momentum().z();
341 HepMC::GenVertex* prod_vtx = part->production_vertex();
342 if ( !prod_vtx )
continue;
343 pyjets.v[0][0] = prod_vtx->position().x();
344 pyjets.v[1][0] = prod_vtx->position().y();
345 pyjets.v[2][0] = prod_vtx->position().z();
346 pyjets.v[3][0] = prod_vtx->position().t();
359 for(
int iprt1=1; iprt1<pyjets.n; iprt1++){
361 part->set_status( 2 );
363 HepMC::GenVertex* DecVtx =
new HepMC::GenVertex( HepMC::FourVector(pyjets.v[0][iprt1],
366 pyjets.v[3][iprt1]) );
367 DecVtx->add_particle_in( part );
370 HepMC::FourVector pmom(pyjets.p[0][iprt1],pyjets.p[1][iprt1],
371 pyjets.p[2][iprt1],pyjets.p[3][iprt1] );
374 if(pyjets.k[0][iprt1] >= 1 && pyjets.k[0][iprt1] <= 10) dstatus = 1;
375 else if(pyjets.k[0][iprt1] >= 11 && pyjets.k[0][iprt1] <= 20) dstatus = 2;
376 else if(pyjets.k[0][iprt1] >= 21 && pyjets.k[0][iprt1] <= 30) dstatus = 3;
377 else if(pyjets.k[0][iprt1] >= 31 && pyjets.k[0][iprt1] <= 100) dstatus = pyjets.k[0][iprt1];
380 HepPID::translatePythiatoPDT(pyjets.k[1][iprt1]),
383 daughter->suggest_barcode( barcode );
384 DecVtx->add_particle_out( daughter );
387 for(iprt2=iprt1+1; iprt2<pyjets.n; iprt2++){
389 if(pyjets.k[2][iprt2] != parent){
390 parent = pyjets.k[2][iprt2];
394 HepMC::FourVector pmomN(pyjets.p[0][iprt2],pyjets.p[1][iprt2],
395 pyjets.p[2][iprt2],pyjets.p[3][iprt2] );
398 if(pyjets.k[0][iprt2] >= 1 && pyjets.k[0][iprt2] <= 10) dstatus = 1;
399 else if(pyjets.k[0][iprt2] >= 11 && pyjets.k[0][iprt2] <= 20) dstatus = 2;
400 else if(pyjets.k[0][iprt2] >= 21 && pyjets.k[0][iprt2] <= 30) dstatus = 3;
401 else if(pyjets.k[0][iprt2] >= 31 && pyjets.k[0][iprt2] <= 100) dstatus = pyjets.k[0][iprt2];
404 HepPID::translatePythiatoPDT( pyjets.k[1][iprt2] ),
407 daughterN->suggest_barcode( barcode );
408 DecVtx->add_particle_out( daughterN );
414 event().get()->add_vertex( DecVtx );
428 for(
int i=0;
i<5;
i++){
490 for(
unsigned i=0;
i<AllSets.size();++
i) {
492 string Set = AllSets[
i];
496 for(vector<string>::const_iterator itPara = Para_Set.begin(); itPara != Para_Set.end(); ++itPara) {
500 <<
" Cascade did not accept the following parameter: \""<<*itPara<<
"\""<<endl;
530 vector<int> pdg = _pdg;
531 for(
size_t i=0;
i<pdg.size();
i++){
532 int PyID = HepPID::translatePDTtoPythia(pdg[
i]);
536 ostringstream pyCard ;
537 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
553 HepMC::GenEvent::vertex_const_iterator
vbegin =
event()->vertices_begin();
554 HepMC::GenEvent::vertex_const_iterator
vend =
event()->vertices_end();
555 HepMC::GenEvent::vertex_const_iterator vitr =
vbegin;
557 for(; vitr !=
vend; ++vitr){
559 HepMC::GenVertex::particle_iterator pbegin = (*vitr)->particles_begin(HepMC::children);
560 HepMC::GenVertex::particle_iterator pend = (*vitr)->particles_end(HepMC::children);
561 HepMC::GenVertex::particle_iterator pitr = pbegin;
563 for(; pitr != pend; ++pitr){
565 if((*pitr)->end_vertex())
continue;
566 if((*pitr)->status()!=1)
continue;
568 int pdgcode=
abs((*pitr)->pdg_id());
570 if ( pydat3.mdcy[0][
pycomp_(pdgcode)-1] !=1 )
continue;
572 double ctau = pydat2.pmas[3][
pycomp_(pdgcode)-1];
573 HepMC::FourVector mom = (*pitr)->momentum();
574 HepMC::FourVector vin = (*vitr)->position();
579 bool decayInRange =
false;
580 while(!decayInRange){
584 double proper_length = - ctau *
log(unif_rand);
585 double factor = proper_length/mom.m();
586 x = vin.x() + factor * mom.px();
587 y = vin.y() + factor * mom.py();
588 z = vin.z() + factor * mom.pz();
589 t = vin.t() + factor * mom.e();
593 if (
sqrt(x*x+y*y)>
pydat1.parj[72] || fabs(z)>
pydat1.parj[73]) decayInRange =
true;
596 else if (
pydat1.mstj[21]==3){
597 if (
sqrt(x*x+y*y+z*z)>
pydat1.parj[71]) decayInRange =
true;
605 HepMC::GenVertex* vdec =
new HepMC::GenVertex(HepMC::FourVector(x,y,z,t));
606 event()->add_vertex(vdec);
607 vdec->add_particle_in((*pitr));
621 double sigma_CMS = 0.001 *
caeffic.avgi;
622 double error_CMS = 0.001 *
caeffic.sd;
636 return "gen::Cascade2Hadronizer";
645 if(!strncmp(ParameterString.c_str(),
"KE",2))
646 caluco.ke = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
648 else if(!strncmp(ParameterString.c_str(),
"IRES(1)",7))
649 capar6.ires[0] = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
651 else if(!strncmp(ParameterString.c_str(),
"KP",2))
652 caluco.kp = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
654 else if(!strncmp(ParameterString.c_str(),
"IRES(2)",7))
655 capar6.ires[1] = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
657 else if(!strncmp(ParameterString.c_str(),
"NFRAG",5))
658 cainpu.nfrag = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
660 else if(!strncmp(ParameterString.c_str(),
"IPST",4))
661 cashower.ipst = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
663 else if(!strncmp(ParameterString.c_str(),
"IPSIPOL",7))
664 jpsi.ipsipol = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
670 else if(!strncmp(ParameterString.c_str(),
"IFPS",4))
671 cainpu.ifps = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
673 else if(!strncmp(ParameterString.c_str(),
"ITIMSHR",7))
674 casshwr.itimshr = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
676 else if(!strncmp(ParameterString.c_str(),
"IRUNAEM",7))
677 capar1.irunaem = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
679 else if(!strncmp(ParameterString.c_str(),
"IRUNA",5))
680 capar1.iruna = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
682 else if(!strncmp(ParameterString.c_str(),
"IQ2",3))
683 capar1.iq2 = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
685 else if(!strncmp(ParameterString.c_str(),
"IPRO",4))
686 capar1.ipro = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
688 else if(!strncmp(ParameterString.c_str(),
"NFLAV",5))
689 caluco.nflav = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
691 else if(!strncmp(ParameterString.c_str(),
"INTER",5))
692 cainpu.inter = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
694 else if(!strncmp(ParameterString.c_str(),
"IHFLA",5))
695 cahflav.ihfla = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
697 else if(!strncmp(ParameterString.c_str(),
"IRPA",4))
698 cascol.irpa = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
700 else if(!strncmp(ParameterString.c_str(),
"IRPB",4))
701 cascol.irpb = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
703 else if(!strncmp(ParameterString.c_str(),
"IRPC",4))
704 cascol.irpc = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
706 else if(!strncmp(ParameterString.c_str(),
"ICCFM",5))
707 casshwr.iccfm = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
709 else if(!strncmp(ParameterString.c_str(),
"IFINAL",6))
710 cainpu.ifinal = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
712 else if(!strncmp(ParameterString.c_str(),
"IGLU",4))
713 cagluon.iglu = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
715 else if(!strncmp(ParameterString.c_str(),
"IRspl",5))
716 casprre.irspl = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
718 else if(!strncmp(ParameterString.c_str(),
"PT2CUT",6))
719 captcut.pt2cut[
capar1.ipro-1] = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
721 else if(!strncmp(ParameterString.c_str(),
"NCB",3))
722 integr.ncb = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
724 else if(!strncmp(ParameterString.c_str(),
"ACC1",4))
725 integr.acc1 = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
727 else if(!strncmp(ParameterString.c_str(),
"ACC2",4))
728 integr.acc2 = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
730 else if(!strncmp(ParameterString.c_str(),
"SCALFAF",7))
731 scalf.scalfaf = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
733 else if(!strncmp(ParameterString.c_str(),
"SCALFA",6))
734 scalf.scalfa = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=")+1]);
744 cout<<
"----------------------------------"<<endl;
745 cout<<
"---- Cascade Parameters ----"<<endl;
746 cout<<
"----------------------------------"<<endl;
749 cout<<
"computation switch: "<<endl;
750 cout<<
"number of calls per iteration for bases: "<<
integr.ncb<<endl;
751 cout<<
"relative precision for grid optimisation: "<<
integr.acc1<<
" %"<<endl;
752 cout<<
"relative precision for integration: "<<
integr.acc2<<
" %"<<endl;
755 cout<<
"kinematics: "<<endl;
756 cout<<
"flavour code of beam 1: "<<
caluco.ke<<endl;
757 cout<<
"direct or resolved particle 1: "<<
capar6.ires[0]<<endl;
758 cout<<
"pz of incoming beam 1: "<<
cainpu.plepin<<
" GeV"<<endl;
759 cout<<
"flavour code of beam 2: "<<
caluco.kp<<endl;
760 cout<<
"direct or resolved particle 2: "<<
capar6.ires[1]<<endl;
761 cout<<
"pz of incoming beam 2: "<<
cainpu.ppin<<
" GeV"<<endl;
762 cout<<
"number of active flavors: "<<
caluco.nflav<<endl;
765 cout<<
"hard subprocess selection: "<<endl;
766 cout<<
"hard subprocess number (IPRO): "<<
capar1.ipro<<endl;
767 cout<<
"IPRO = 10, switch to select QCD process g* g* -> q qbar: "<<
cascol.irpa<<endl;
768 cout<<
"IPRO = 10, switch to select QCD process g* g -> g g: "<<
cascol.irpb<<endl;
769 cout<<
"IPRO = 10, switch to select QCD process g* q -> g q: "<<
cascol.irpc<<endl;
770 cout<<
"flavor of heavy quark produced (IPRO = 11, 504, 514): "<<
cahflav.ihfla<<endl;
772 cout<<
"use matrix element including J/psi (Upsilon) polarisation: "<<
jpsi.ipsipol<<endl;
773 cout<<
"pt2 cut in matrix element for massless partons: "<<
captcut.pt2cut[
capar1.ipro-1]<<
" GeV^2"<<endl;
776 cout<<
"parton shower and fragmentation: "<<endl;
777 cout<<
"switch for fragmentation: "<<
cainpu.nfrag<<endl;
778 cout<<
"switch for parton shower (0 off - 1 initial state - 2 final state - 3 initial & final state): "<<
cainpu.ifps<<endl;
779 cout<<
"switch for time like parton shower in initial state: "<<
casshwr.itimshr<<endl;
780 cout<<
"select CCFM (1) or DGLAP (0) evolution: "<<
casshwr.iccfm<<endl;
781 cout<<
"scale switch for final state parton shower: "<<
cainpu.ifinal<<endl;
782 cout<<
"scale factor for final state parton shower: "<<
scalf.scalfaf<<endl;
783 cout<<
"switch for proton remnant treatment: "<<
casprre.irspl<<endl;
784 cout<<
"keep track of intermediate state in parton shower: "<<
cashower.ipst<<endl;
785 cout<<
"mode of interaction for e p: "<<
cainpu.inter<<endl;
788 cout<<
"pdfs, couplings and scales: "<<endl;
789 cout<<
"switch for running alphaem: "<<
capar1.irunaem<<endl;
790 cout<<
"switch for running alphas: "<<
capar1.iruna<<endl;
792 cout<<
"scale factor for scale in alphas: "<<
scalf.scalfa<<endl;
794 cout<<
"path where updf are stored: "<<
caspdf.pdfpath<<endl;
797 cout<<
"center of mass energy, cross section, filter efficiency: "<<endl;
807 cout<<
"----------------------------------"<<endl;
808 cout<<
"---- Pythia6 Parameters ----"<<endl;
809 cout<<
"----------------------------------"<<endl;
812 cout<<
"charm mass: "<<pydat2.pmas[0][3]<<
" GeV (default value = 1.5 GeV)"<<endl;
813 cout<<
"bottom mass: "<<pydat2.pmas[0][4]<<
" GeV (default value = 4.8 GeV)"<<endl;
814 cout<<
"Higgs mass: "<<pydat2.pmas[0][24]<<
" GeV (default value = 115 GeV)"<<endl;
816 cout<<
"lambda QCD: "<<
pydat1.paru[111]<<
" GeV (default value = 0.25 GeV)"<<endl;
818 cout<<
"alphas behaviour: "<<
pydat1.mstu[110]<<
" (default value = 1)"<<endl;
819 cout<<
"nr of flavours wrt lambda QCD: "<<
pydat1.mstu[111]<<
" (default value = 5)"<<endl;
820 cout<<
"min nr of flavours for alphas: "<<
pydat1.mstu[112]<<
" (default value = 3)"<<endl;
821 cout<<
"max nr of flavours for alphas: "<<
pydat1.mstu[113]<<
" (default value = 5)"<<endl;
823 cout<<
"maximum angle settings: "<<
pydat1.mstj[47]<<
" (default value = 0)"<<endl;
void pythia6PrintParameters()
T getParameter(std::string const &) const
double dcasrn_(int *idummy)
Pythia6Service * fPy6Service
bool call_pygive(const std::string &line)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
bool generatePartonsAndHadronize()
void setInternalXSec(const XSec &xsec)
std::auto_ptr< HepMC::GenEvent > & event()
GenRunInfoProduct & runInfo()
void call_pylist(int mode)
CLHEP::RandFlat * fFlat_extern
Pythia6ServiceWithCallback(const edm::ParameterSet &pset)
edm::ParameterSet fParameters
void call_caend(int mode)
bool initializeForInternalPartons()
unsigned int fPythiaListVerbosity
bool fDisplayPythiaBanner
Abs< T >::type abs(const T &t)
bool declareStableParticles(const std::vector< int > &)
void setPYUPDAParams(bool afterPyinit)
const char * classname() const
bool initializeForExternalPartons()
static struct gen::@322 pyjets_local
std::auto_ptr< GenEventInfoProduct > & eventInfo()
bool cascadeReadParameters(const std::string &ParameterString)
double fextCrossSectionError
static FortranCallback * getInstance()
return(e1-e2)*(e1-e2)+dp *dp
void resetIterationsPerEvent()
volatile std::atomic< bool > shutdown_flag false
void setExternalXSecNLO(const XSec &xsec)
void cascadePrintParameters()
void setExternalXSecLO(const XSec &xsec)
HepMC::IO_HEPEVT hepevtio
unsigned int fMaxEventsToPrint