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::Py8PtAndLxyGun gen::Py8PtExpGun 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< HepMC3::GenEvent > getGenEvent3 ()
 
std::unique_ptr< GenEventInfoProductgetGenEventInfo ()
 
std::unique_ptr< GenEventInfoProduct3getGenEventInfo3 ()
 
virtual std::unique_ptr< GenLumiInfoHeadergetGenLumiInfoHeader () const
 
GenRunInfoProductgetGenRunInfo ()
 
std::unique_ptr< lhef::LHEEventgetLHEEvent ()
 
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo () const
 
unsigned int getVHepMC ()
 
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 resetEvent3 (std::unique_ptr< HepMC3::GenEvent > event3)
 
void resetEventInfo (std::unique_ptr< GenEventInfoProduct > eventInfo)
 
void resetEventInfo3 (std::unique_ptr< GenEventInfoProduct3 > 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
unsigned int ivhepmc = 2
 
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< HepMC3::GenEvent > & event3 ()
 
std::unique_ptr< GenEventInfoProduct > & eventInfo ()
 
std::unique_ptr< GenEventInfoProduct3 > & eventInfo3 ()
 
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.

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

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  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
double fMinPhi
Definition: Py8GunBase.h:58
Py8InterfaceBase(edm::ParameterSet const &ps)
std::vector< int > fPartIDs
Definition: Py8GunBase.h:57
double fMaxPhi
Definition: Py8GunBase.h:59

◆ ~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.

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

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  }
HepMC::IO_AsciiParticles * ascii_io
unsigned int pythiaPylistVerbosity
std::unique_ptr< HepMC::GenEvent > & event()
unsigned int maxEventsToPrint
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ initializeForInternalPartons()

bool gen::Py8GunBase::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 32 of file Py8GunBase.cc.

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.

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  }
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
std::unique_ptr< Pythia8::Pythia > fDecayer
std::vector< std::string > evtgenUserFiles
Log< level::Info, false > LogInfo
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ residualDecay()

bool gen::Py8GunBase::residualDecay ( )
virtual

Definition at line 56 of file Py8GunBase.cc.

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

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  }
std::unique_ptr< Pythia8::Pythia > fDecayer
std::unique_ptr< HepMC::GenEvent > & event()
part
Definition: HCALResponse.h:20
HepMC::Pythia8ToHepMC toHepMC
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ setRandomEngine()

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

Definition at line 50 of file Py8GunBase.h.

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

50 { p8SetRandomEngine(v); }
void p8SetRandomEngine(CLHEP::HepRandomEngine *v)
double v[5][pyjets_maxn]

◆ sharedResources()

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

Definition at line 51 of file Py8GunBase.h.

References p8SharedResources.

51 { return p8SharedResources; }
static const std::vector< std::string > p8SharedResources
Definition: Py8GunBase.h:62

◆ statistics()

void gen::Py8GunBase::statistics ( )
overridevirtual

Reimplemented from gen::Py8InterfaceBase.

Definition at line 135 of file Py8GunBase.cc.

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

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  }
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
std::unique_ptr< Pythia8::Pythia > fMasterGen

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().