CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 finalizeEvent ()
 
bool initializeForInternalPartons ()
 
 Py8GunBase (edm::ParameterSet const &ps)
 
virtual bool residualDecay ()
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
void statistics ()
 
 ~Py8GunBase ()
 
- 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 ()
 
- Public Member Functions inherited from gen::BaseHadronizer
 BaseHadronizer (edm::ParameterSet const &ps)
 
void cleanLHE ()
 
void generateLHE (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
 
edm::EventgetEDMEvent () const
 
HepMC::GenEventgetGenEvent ()
 
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
 
 ~BaseHadronizer ()
 

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:59
Py8InterfaceBase(edm::ParameterSet const &ps)
std::vector< int > fPartIDs
Definition: Py8GunBase.h:58
double fMaxPhi
Definition: Py8GunBase.h:60
gen::Py8GunBase::~Py8GunBase ( )
inline

Definition at line 45 of file Py8GunBase.h.

45 {}

Member Function Documentation

void gen::Py8GunBase::finalizeEvent ( )
virtual

Implements gen::Py8InterfaceBase.

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

119 {
120 
121  //******** Verbosity ********
122 
123  if (maxEventsToPrint > 0 &&
126  {
129  {
130  fMasterGen->info.list(std::cout);
131  fMasterGen->event.list(std::cout);
132  }
133 
135  {
136  std::cout << "Event process = "
137  << fMasterGen->info.code() << "\n"
138  << "----------------------" << std::endl;
139  event()->print();
140  }
142  std::cout << "Event process = "
143  << fMasterGen->info.code() << "\n"
144  << "----------------------" << std::endl;
145  ascii_io->write_event(event().get());
146  }
147  }
148 
149  return;
150 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
HepMC::IO_AsciiParticles * ascii_io
std::auto_ptr< HepMC::GenEvent > & event()
unsigned int pythiaPylistVerbosity
unsigned int maxEventsToPrint
tuple cout
Definition: gather_cfg.py:145
bool gen::Py8GunBase::initializeForInternalPartons ( )
virtual

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, 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 
55  evtgenDecays.reset(new EvtGenDecays(fMasterGen.get(), evtgenDecFile.c_str(), evtgenPdlFile.c_str()));
56 
57  for (unsigned int i=0; i<evtgenUserFiles.size(); i++) {
58  edm::FileInPath evtgenUserFile(evtgenUserFiles.at(i));
59  evtgenDecays->readDecayFile(evtgenUserFile.fullPath().c_str());
60  }
61  }
62 
63  return true;
64 
65 }
int i
Definition: DBlmapReader.cc:9
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 67 of file Py8GunBase.cc.

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

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

References gen::Py8InterfaceBase::p8SetRandomEngine().

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.

References p8SharedResources.

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

Reimplemented from gen::Py8InterfaceBase.

Definition at line 152 of file Py8GunBase.cc.

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

153 {
154 
155  fMasterGen->stat();
156 
157  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
158  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
159  runInfo().setInternalXSec(xsec);
160  return;
161 
162 }
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 63 of file Py8GunBase.h.

Referenced by sharedResources().