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::Py8PtGun

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 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
 
HepMC::GenEvent * getGenEvent ()
 
GenEventInfoProductgetGenEventInfo ()
 
virtual GenLumiInfoHeadergetGenLumiInfoHeader () const
 
GenRunInfoProductgetGenRunInfo ()
 
const boost::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 (HepMC::GenEvent *event)
 
void resetEventInfo (GenEventInfoProduct *eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (lhef::LHEEvent *event)
 
void setLHERunInfo (lhef::LHERunInfo *runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
virtual ~BaseHadronizer ()(false)
 

Protected Attributes

double fMaxPhi
 
double fMinPhi
 
std::vector< int > fPartIDs
 
- Protected Attributes inherited from gen::Py8InterfaceBase
HepMC::IO_AsciiParticles * ascii_io
 
std::auto_ptr< EvtGenDecays > evtgenDecays
 
std::string evtgenDecFile
 
std::string evtgenPdlFile
 
std::vector< std::string > evtgenUserFiles
 
std::auto_ptr< Pythia8::Pythia > fDecayer
 
std::auto_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::auto_ptr< HepMC::GenEvent > & event ()
 
std::auto_ptr< GenEventInfoProduct > & eventInfo ()
 
lhef::LHEEventlheEvent ()
 
lhef::LHERunInfolheRunInfo ()
 
GenRunInfoProductrunInfo ()
 

Detailed Description

Definition at line 42 of file Py8GunBase.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file Py8GunBase.cc.

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

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

Definition at line 45 of file Py8GunBase.h.

References myMessageLogger_cff::statistics.

45 {}

Member Function Documentation

void gen::Py8GunBase::evtGenDecay ( )

Definition at line 159 of file Py8GunBase.cc.

References gen::Py8InterfaceBase::evtgenDecays.

Referenced by gen::Py8PtGun::generatePartonsAndHadronize(), and gen::Py8EGun::generatePartonsAndHadronize().

160 {
161  if (evtgenDecays.get()) evtgenDecays->decay();
162 }
std::auto_ptr< EvtGenDecays > evtgenDecays
void gen::Py8GunBase::finalizeEvent ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 113 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.

114 {
115 
116  //******** Verbosity ********
117 
118  if (maxEventsToPrint > 0 &&
121  {
124  {
125  fMasterGen->info.list();
126  fMasterGen->event.list();
127  }
128 
130  {
131  std::cout << "Event process = "
132  << fMasterGen->info.code() << "\n"
133  << "----------------------" << std::endl;
134  event()->print();
135  }
137  std::cout << "Event process = "
138  << fMasterGen->info.code() << "\n"
139  << "----------------------" << std::endl;
140  ascii_io->write_event(event().get());
141  }
142  }
143 
144  return;
145 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
HepMC::IO_AsciiParticles * ascii_io
std::auto_ptr< HepMC::GenEvent > & event()
unsigned int pythiaPylistVerbosity
unsigned int maxEventsToPrint
bool gen::Py8GunBase::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 36 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.

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

Definition at line 62 of file Py8GunBase.cc.

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

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

Definition at line 52 of file Py8GunBase.h.

52 { p8SetRandomEngine(v); }
void p8SetRandomEngine(CLHEP::HepRandomEngine *v)
double v[5][pyjets_maxn]
std::vector<std::string> const& gen::Py8GunBase::sharedResources ( ) const
inline

Definition at line 53 of file Py8GunBase.h.

53 { return p8SharedResources; }
static const std::vector< std::string > p8SharedResources
Definition: Py8GunBase.h:64
void gen::Py8GunBase::statistics ( )
overridevirtual

Reimplemented from gen::Py8InterfaceBase.

Definition at line 147 of file Py8GunBase.cc.

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

148 {
149 
150  fMasterGen->stat();
151 
152  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
153  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
154  runInfo().setInternalXSec(xsec);
155  return;
156 
157 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()

Member Data Documentation

double gen::Py8GunBase::fMaxPhi
protected
double gen::Py8GunBase::fMinPhi
protected
std::vector<int> gen::Py8GunBase::fPartIDs
protected
const std::vector< std::string > gen::Py8GunBase::p8SharedResources = { edm::SharedResourceNames::kPythia8 }
staticprivate

Definition at line 64 of file Py8GunBase.h.