CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Static Private Attributes
gen::Py8GunBase Class Reference

#include <Py8GunBase.h>

Inheritance diagram for gen::Py8GunBase:
gen::Py8InterfaceBase gen::BaseHadronizer gen::Py8EGun gen::Py8JetGun gen::Py8MassGun gen::Py8PtAndDxyGun gen::Py8PtGun gen::Py8PtotGun

Public Member Functions

void evtGenDecay ()
 
void finalizeEvent () override
 
bool initializeForInternalPartons () override
 
 Py8GunBase (edm::ParameterSet const &ps)
 
virtual bool residualDecay ()
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
void statistics () override
 
 ~Py8GunBase () override
 
- Public Member Functions inherited from gen::Py8InterfaceBase
virtual const char * classname () const =0
 
bool decay ()
 
bool declareSpecialSettings (const std::vector< std::string > &)
 
bool declareStableParticles (const std::vector< int > &)
 
virtual bool generatePartonsAndHadronize ()=0
 
void makeTmpSLHA (const std::string &)
 
void p8SetRandomEngine (CLHEP::HepRandomEngine *v)
 
 Py8InterfaceBase (edm::ParameterSet const &ps)
 
P8RndmEnginerandomEngine ()
 
bool readSettings (int)
 
 ~Py8InterfaceBase () override
 
- Public Member Functions inherited from gen::BaseHadronizer
 BaseHadronizer (edm::ParameterSet const &ps)
 
void cleanLHE ()
 
void generateLHE (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine, unsigned int ncpu)
 
edm::EventgetEDMEvent () const
 
std::unique_ptr< HepMC::GenEventgetGenEvent ()
 
std::unique_ptr< GenEventInfoProductgetGenEventInfo ()
 
virtual std::unique_ptr< GenLumiInfoHeadergetGenLumiInfoHeader () const
 
GenRunInfoProductgetGenRunInfo ()
 
std::unique_ptr< lhef::LHEEventgetLHEEvent ()
 
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo () const
 
const std::string & gridpackPath () const
 
int randomIndex () const
 
const std::string & randomInitConfigDescription () const
 
void randomizeIndex (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
 
void resetEvent (std::unique_ptr< HepMC::GenEvent > event)
 
void resetEventInfo (std::unique_ptr< GenEventInfoProduct > eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (std::unique_ptr< lhef::LHEEvent > event)
 
void setLHERunInfo (std::unique_ptr< lhef::LHERunInfo > runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
virtual ~BaseHadronizer () noexcept(false)
 

Protected Attributes

double fMaxPhi
 
double fMinPhi
 
std::vector< int > fPartIDs
 
- Protected Attributes inherited from gen::Py8InterfaceBase
HepMC::IO_AsciiParticles * ascii_io
 
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
 
std::string evtgenDecFile
 
std::string evtgenPdlFile
 
std::vector< std::string > evtgenUserFiles
 
std::unique_ptr< Pythia8::Pythia > fDecayer
 
std::unique_ptr< Pythia8::Pythia > fMasterGen
 
edm::ParameterSet fParameters
 
unsigned int maxEventsToPrint
 
bool pythiaHepMCVerbosity
 
bool pythiaHepMCVerbosityParticles
 
unsigned int pythiaPylistVerbosity
 
std::string slhafile_
 
HepMC::Pythia8ToHepMC toHepMC
 
bool useEvtGen
 
- Protected Attributes inherited from gen::BaseHadronizer
std::string lheFile_
 
int randomIndex_
 

Static Private Attributes

static const std::vector< std::string > p8SharedResources = {edm::SharedResourceNames::kPythia8}
 

Additional Inherited Members

- Protected Member Functions inherited from gen::BaseHadronizer
std::unique_ptr< HepMC::GenEvent > & event ()
 
std::unique_ptr< GenEventInfoProduct > & eventInfo ()
 
lhef::LHEEventlheEvent ()
 
lhef::LHERunInfolheRunInfo ()
 
GenRunInfoProductrunInfo ()
 

Detailed Description

Definition at line 40 of file Py8GunBase.h.

Constructor & Destructor Documentation

◆ Py8GunBase()

gen::Py8GunBase::Py8GunBase ( edm::ParameterSet const &  ps)

Definition at line 15 of file Py8GunBase.cc.

15  : Py8InterfaceBase(ps) {
16  // PGun specs
17  //
18  edm::ParameterSet pgun_params = ps.getParameter<edm::ParameterSet>("PGunParameters");
19 
20  // although there's the method ParameterSet::empty(),
21  // it looks like it's NOT even necessary to check if it is,
22  // before trying to extract parameters - if it is empty,
23  // the default values seem to be taken
24  //
25  fPartIDs = pgun_params.getParameter<std::vector<int> >("ParticleID");
26  fMinPhi = pgun_params.getParameter<double>("MinPhi"); // ,-3.14159265358979323846);
27  fMaxPhi = pgun_params.getParameter<double>("MaxPhi"); // , 3.14159265358979323846);
28  }

References fMaxPhi, fMinPhi, fPartIDs, and edm::ParameterSet::getParameter().

◆ ~Py8GunBase()

gen::Py8GunBase::~Py8GunBase ( )
inlineoverride

Definition at line 43 of file Py8GunBase.h.

43 {}

Member Function Documentation

◆ evtGenDecay()

void gen::Py8GunBase::evtGenDecay ( )

◆ finalizeEvent()

void gen::Py8GunBase::finalizeEvent ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 110 of file Py8GunBase.cc.

110  {
111  //******** Verbosity ********
112 
115  if (pythiaPylistVerbosity) {
116  fMasterGen->info.list();
117  fMasterGen->event.list();
118  }
119 
120  if (pythiaHepMCVerbosity) {
121  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
122  << "----------------------" << std::endl;
123  event()->print();
124  }
126  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
127  << "----------------------" << std::endl;
128  ascii_io->write_event(event().get());
129  }
130  }
131 
132  return;
133  }

References gen::Py8InterfaceBase::ascii_io, gather_cfg::cout, gen::BaseHadronizer::event(), gen::Py8InterfaceBase::fMasterGen, get, gen::Py8InterfaceBase::maxEventsToPrint, gen::Py8InterfaceBase::pythiaHepMCVerbosity, gen::Py8InterfaceBase::pythiaHepMCVerbosityParticles, and gen::Py8InterfaceBase::pythiaPylistVerbosity.

◆ initializeForInternalPartons()

bool gen::Py8GunBase::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 32 of file Py8GunBase.cc.

32  {
33  // NO MATTER what was this setting below, override it before init
34  // - this is essencial for the PGun mode
35 
36  // Key requirement: switch off ProcessLevel, and thereby also PartonLevel.
37  fMasterGen->readString("ProcessLevel:all = off");
38  fMasterGen->readString("ProcessLevel::resonanceDecays=on");
39  fMasterGen->init();
40 
41  // init decayer
42  fDecayer->readString("ProcessLevel:all = off"); // Same trick!
43  fDecayer->readString("ProcessLevel::resonanceDecays=on");
44  fDecayer->init();
45 
46  if (useEvtGen) {
47  edm::LogInfo("Pythia8Interface") << "Creating and initializing pythia8 EvtGen plugin";
48  evtgenDecays.reset(new EvtGenDecays(fMasterGen.get(), evtgenDecFile, evtgenPdlFile));
49  for (unsigned int i = 0; i < evtgenUserFiles.size(); i++)
50  evtgenDecays->readDecayFile(evtgenUserFiles.at(i));
51  }
52 
53  return true;
54  }

References gen::Py8InterfaceBase::evtgenDecays, gen::Py8InterfaceBase::evtgenDecFile, gen::Py8InterfaceBase::evtgenPdlFile, gen::Py8InterfaceBase::evtgenUserFiles, gen::Py8InterfaceBase::fDecayer, gen::Py8InterfaceBase::fMasterGen, mps_fire::i, and gen::Py8InterfaceBase::useEvtGen.

◆ residualDecay()

bool gen::Py8GunBase::residualDecay ( )
virtual

Definition at line 56 of file Py8GunBase.cc.

56  {
57  Event* pythiaEvent = &(fMasterGen->event);
58 
59  int NPartsBeforeDecays = pythiaEvent->size() - 1; // do NOT count the very 1st "system" particle
60  // in Pythia8::Event record; it does NOT even
61  // get translated by the HepMCInterface to the
62  // HepMC::GenEvent record !!!
63  int NPartsAfterDecays = event().get()->particles_size();
64 
65  if (NPartsAfterDecays == NPartsBeforeDecays)
66  return true;
67 
68  bool result = true;
69 
70  for (int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
71  HepMC::GenParticle* part = event().get()->barcode_to_particle(ipart);
72 
73  if (part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id())) {
74  fDecayer->event.reset();
75  Particle py8part(part->pdg_id(),
76  93,
77  0,
78  0,
79  0,
80  0,
81  0,
82  0,
83  part->momentum().x(),
84  part->momentum().y(),
85  part->momentum().z(),
86  part->momentum().t(),
87  part->generated_mass());
88  HepMC::GenVertex* ProdVtx = part->production_vertex();
89  py8part.vProd(
90  ProdVtx->position().x(), ProdVtx->position().y(), ProdVtx->position().z(), ProdVtx->position().t());
91  py8part.tau((fDecayer->particleData).tau0(part->pdg_id()));
92  fDecayer->event.append(py8part);
93  int nentries = fDecayer->event.size();
94  if (!fDecayer->event[nentries - 1].mayDecay())
95  continue;
96  fDecayer->next();
97  int nentries1 = fDecayer->event.size();
98  if (nentries1 <= nentries)
99  continue; //same number of particles, no decays...
100 
101  part->set_status(2);
102 
103  result = toHepMC.fill_next_event(*(fDecayer.get()), event().get(), -1, true, part);
104  }
105  }
106 
107  return result;
108  }

References gen::BaseHadronizer::event(), gen::Py8InterfaceBase::fDecayer, gen::Py8InterfaceBase::fMasterGen, GenParticle::GenParticle, mps_fire::result, and gen::Py8InterfaceBase::toHepMC.

◆ setRandomEngine()

void gen::Py8GunBase::setRandomEngine ( CLHEP::HepRandomEngine *  v)
inline

Definition at line 50 of file Py8GunBase.h.

50 { p8SetRandomEngine(v); }

References gen::Py8InterfaceBase::p8SetRandomEngine(), and gen::v.

◆ sharedResources()

std::vector<std::string> const& gen::Py8GunBase::sharedResources ( ) const
inline

Definition at line 51 of file Py8GunBase.h.

51 { return p8SharedResources; }

References p8SharedResources.

◆ statistics()

void gen::Py8GunBase::statistics ( )
overridevirtual

Reimplemented from gen::Py8InterfaceBase.

Definition at line 135 of file Py8GunBase.cc.

135  {
136  fMasterGen->stat();
137 
138  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
139  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
140  runInfo().setInternalXSec(xsec);
141  return;
142  }

References gen::Py8InterfaceBase::fMasterGen, gen::BaseHadronizer::runInfo(), and GenRunInfoProduct::setInternalXSec().

Member Data Documentation

◆ fMaxPhi

double gen::Py8GunBase::fMaxPhi
protected

◆ fMinPhi

double gen::Py8GunBase::fMinPhi
protected

◆ fPartIDs

std::vector<int> gen::Py8GunBase::fPartIDs
protected

◆ p8SharedResources

const std::vector< std::string > gen::Py8GunBase::p8SharedResources = {edm::SharedResourceNames::kPythia8}
staticprivate

Definition at line 62 of file Py8GunBase.h.

Referenced by sharedResources().

gen::Py8InterfaceBase::fMasterGen
std::unique_ptr< Pythia8::Pythia > fMasterGen
Definition: Py8InterfaceBase.h:47
gen::Py8InterfaceBase::evtgenDecays
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
Definition: Py8InterfaceBase.h:62
mps_fire.i
i
Definition: mps_fire.py:428
gen::Py8GunBase::fMinPhi
double fMinPhi
Definition: Py8GunBase.h:58
gen::Py8InterfaceBase::ascii_io
HepMC::IO_AsciiParticles * ascii_io
Definition: Py8InterfaceBase.h:57
edm::Transition::Event
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GenRunInfoProduct::setInternalXSec
void setInternalXSec(const XSec &xsec)
Definition: GenRunInfoProduct.h:26
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
part
part
Definition: HCALResponse.h:20
gen::Py8GunBase::p8SharedResources
static const std::vector< std::string > p8SharedResources
Definition: Py8GunBase.h:62
gen::Py8InterfaceBase::Py8InterfaceBase
Py8InterfaceBase(edm::ParameterSet const &ps)
Definition: Py8InterfaceBase.cc:19
gen::Py8InterfaceBase::useEvtGen
bool useEvtGen
Definition: Py8InterfaceBase.h:61
gen::Py8InterfaceBase::pythiaHepMCVerbosityParticles
bool pythiaHepMCVerbosityParticles
Definition: Py8InterfaceBase.h:55
gen::Py8InterfaceBase::evtgenUserFiles
std::vector< std::string > evtgenUserFiles
Definition: Py8InterfaceBase.h:65
gen::Py8InterfaceBase::pythiaPylistVerbosity
unsigned int pythiaPylistVerbosity
Definition: Py8InterfaceBase.h:53
edm::ParameterSet
Definition: ParameterSet.h:47
gen::Py8InterfaceBase::evtgenPdlFile
std::string evtgenPdlFile
Definition: Py8InterfaceBase.h:64
gen::Py8InterfaceBase::maxEventsToPrint
unsigned int maxEventsToPrint
Definition: Py8InterfaceBase.h:56
gen::v
double v[5][pyjets_maxn]
Definition: Cascade2Hadronizer.cc:76
gen::Py8GunBase::fPartIDs
std::vector< int > fPartIDs
Definition: Py8GunBase.h:57
get
#define get
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
gen::BaseHadronizer::event
std::unique_ptr< HepMC::GenEvent > & event()
Definition: BaseHadronizer.h:86
gen::Py8InterfaceBase::pythiaHepMCVerbosity
bool pythiaHepMCVerbosity
Definition: Py8InterfaceBase.h:54
gen::Py8InterfaceBase::toHepMC
HepMC::Pythia8ToHepMC toHepMC
Definition: Py8InterfaceBase.h:49
Particle
Definition: Particle.py:1
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
mps_fire.result
result
Definition: mps_fire.py:311
gen::Py8GunBase::fMaxPhi
double fMaxPhi
Definition: Py8GunBase.h:59
gen::BaseHadronizer::runInfo
GenRunInfoProduct & runInfo()
Definition: BaseHadronizer.h:85
gen::Py8InterfaceBase::fDecayer
std::unique_ptr< Pythia8::Pythia > fDecayer
Definition: Py8InterfaceBase.h:48
gen::Py8InterfaceBase::evtgenDecFile
std::string evtgenDecFile
Definition: Py8InterfaceBase.h:63
gen::Py8InterfaceBase::p8SetRandomEngine
void p8SetRandomEngine(CLHEP::HepRandomEngine *v)
Definition: Py8InterfaceBase.h:43