7 #include <HepMC/GenEvent.h>
8 #include <HepMC/GenParticle.h>
11 #include <HepMCInterface.h>
41 #include "HepPID/ParticleIDTranslations.hh"
46 using namespace Pythia8;
55 bool initializeForInternalPartons();
56 bool initializeForExternalPartons();
58 bool generatePartonsAndHadronize();
61 virtual bool residualDecay();
67 const char *
classname()
const {
return "Pythia8Hadronizer"; }
75 std::auto_ptr<LHAupLesHouches>
lhaUP;
77 enum { PP,
PPbar, ElectronPositron };
110 comEnergy(params.getParameter<double>(
"comEnergy")),
111 LHEInputFileName(params.getUntrackedParameter<
string>(
"LHEInputFileName",
"")),
113 fReweightUserHook(0),
115 fEmissionVetoHook(0),fEmissionVetoHook1(0)
120 if ( params.
exists(
"PPbarInitialState" ) )
126 <<
"Pythia6 will be initialized for PROTON-ANTIPROTON INITIAL STATE. "
127 <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
128 std::cout <<
"Pythia6 will be initialized for PROTON-ANTIPROTON INITIAL STATE." << std::endl;
129 std::cout <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
136 else if ( params.
exists(
"ElectronPositronInitialState" ) )
142 <<
"Pythia6 will be initialized for ELECTRON-POSITRON INITIAL STATE. "
143 <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
144 std::cout <<
"Pythia6 will be initialized for ELECTRON-POSITRON INITIAL STATE." << std::endl;
145 std::cout <<
"This is a user-request change from the DEFAULT PROTON-PROTON initial state." << std::endl;
152 else if ( params.
exists(
"ElectronProtonInitialState" ) || params.
exists(
"PositronProtonInitialState" ) )
156 <<
" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
159 if( params.
exists(
"SLHAFileForPythia8" ) ) {
167 if (
line->find(
"SLHA:file") != std::string::npos)
168 throw cms::Exception(
"PythiaError") <<
"Attempted to set SLHA file name twice, "
169 <<
"using Pythia8 card SLHA:file and Pythia8Interface card SLHAFileForPythia8"
176 if( params.
exists(
"reweightGen" ) )
179 if( params.
exists(
"useUserHook" ) )
181 <<
" Obsolete parameter: useUserHook \n Please use the actual one instead \n";
185 if ( params.
exists(
"jetMatching") )
190 if ( scheme ==
"Madgraph" || scheme ==
"MadgraphFastJet" )
198 if ( params.
exists(
"emissionVeto") )
203 if ( params.
exists(
"emissionVeto1") )
217 <<
" Wrong value for EV1_pTempMode code\n";
236 <<
" Too many User Hooks. \n Please choose one from: reweightGen, jetMatching, emissionVeto \n";
241 cout <<
"Turning on Emission Veto Hook";
244 int nversion = (int)(1000.*(
fMasterGen->settings.parm(
"Pythia:versionNumber") - 8.));
246 cout <<
"obsolete pythia8 version for this Emission Veto code" << endl;
247 cout <<
"Please update pythia8 version using the instructions here:" << endl;
248 cout <<
"https://twiki.cern.ch/twiki/bin/view/CMS/Pythia8Interface" << endl;
249 cout <<
"or try to use tag V00-01-28 of this interface" << endl;
251 <<
" Obsolete pythia8 version for this Emission Veto code\n";
288 <<
" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
302 fDecayer->readString(
"ProcessLevel:all = off");
303 fDecayer->readString(
"Standalone:allowResDec=on");
314 std::cout <<
"Initializing for external partons" << std::endl;
348 fDecayer->readString(
"ProcessLevel:all = off");
349 fDecayer->readString(
"Standalone:allowResDec=on");
363 else if (status > -30 && status < 0)
386 event().reset(
new HepMC::GenEvent);
415 event().reset(
new HepMC::GenEvent);
426 int NPartsBeforeDecays = pythiaEvent->size();
427 int NPartsAfterDecays =
event().get()->particles_size();
428 int NewBarcode = NPartsAfterDecays;
430 for (
int ipart=NPartsAfterDecays; ipart>NPartsBeforeDecays; ipart-- )
435 if ( part->status() == 1 )
438 Particle py8part( part->pdg_id(), 93, 0, 0, 0, 0, 0, 0,
439 part->momentum().x(),
440 part->momentum().y(),
441 part->momentum().z(),
442 part->momentum().t(),
443 part->generated_mass() );
444 HepMC::GenVertex* ProdVtx = part->production_vertex();
445 py8part.vProd( ProdVtx->position().x(), ProdVtx->position().y(),
446 ProdVtx->position().z(), ProdVtx->position().t() );
447 py8part.tau( (
fDecayer->particleData).tau0( part->pdg_id() ) );
449 int nentries =
fDecayer->event.size();
450 if ( !
fDecayer->event[nentries-1].mayDecay() )
continue;
452 int nentries1 =
fDecayer->event.size();
454 if ( nentries1 <= nentries )
continue;
458 Particle& py8daughter =
fDecayer->event[nentries];
459 HepMC::GenVertex* DecVtx =
new HepMC::GenVertex( HepMC::FourVector(py8daughter.xProd(),
462 py8daughter.tProd()) );
464 DecVtx->add_particle_in( part );
467 HepMC::FourVector pmom( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() );
473 daughter->suggest_barcode( NewBarcode );
474 DecVtx->add_particle_out( daughter );
476 for (
int ipart1=nentries+1; ipart1<nentries1; ipart1++ )
478 py8daughter =
fDecayer->event[ipart1];
479 HepMC::FourVector pmomN( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() );
483 daughterN->suggest_barcode( NewBarcode );
484 DecVtx->add_particle_out( daughterN );
487 event().get()->add_vertex( DecVtx );
525 <<
"----------------------" << std::endl;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual bool residualDecay()
bool initializeForInternalPartons()
ParameterCollector fParameters
double comEnergy
Center-of-Mass energy.
std::auto_ptr< Pythia8::Pythia > fMasterGen
EmissionVetoHook1 * fEmissionVetoHook1
edm::GeneratorFilter< Pythia8Hadronizer, ExternalDecayDriver > Pythia8GeneratorFilter
UserHooks * fReweightUserHook
EmissionVetoHook * fEmissionVetoHook
bool initializeForExternalPartons()
#define DEFINE_FWK_MODULE(type)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void count(LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0)
static int getStatus(const HepMC::GenParticle *p)
void setInternalXSec(const XSec &xsec)
virtual void beforeHadronization(lhef::LHEEvent *lhee)
std::auto_ptr< HepMC::GenEvent > & event()
GenRunInfoProduct & runInfo()
std::auto_ptr< LHAupLesHouches > lhaUP
lhef::LHEEvent * lheEvent()
const char * classname() const
unsigned int pythiaPylistVerbosity
std::auto_ptr< GenEventInfoProduct > & eventInfo()
lhef::LHERunInfo * lheRunInfo()
virtual void init(lhef::LHERunInfo *runInfo)
JetMatchingHook * fJetMatchingHook
unsigned int maxEventsToPrint
bool generatePartonsAndHadronize()
std::auto_ptr< Pythia8::Pythia > fDecayer
Pythia8Hadronizer(const edm::ParameterSet ¶ms)
void resetMatchingStatus()
bool pythiaHepMCVerbosity
const_iterator end() const
const_iterator begin() const
edm::HadronizerFilter< Pythia8Hadronizer, ExternalDecayDriver > Pythia8HadronizerFilter