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 Member Functions | Protected Attributes | Private Attributes | Static Private Attributes
gen::Py8GunBase Class Reference

#include <Py8GunBase.h>

Inheritance diagram for gen::Py8GunBase:
gen::Py8InterfaceBase gen::Py8EGun gen::Py8JetGun gen::Py8PtGun

Public Member Functions

void finalizeEvent ()
 
edm::EventgetEDMEvent () const
 
HepMC::GenEvent * getGenEvent ()
 
GenEventInfoProductgetGenEventInfo ()
 
GenRunInfoProductgetGenRunInfo ()
 
bool initializeForInternalPartons ()
 
 Py8GunBase (edm::ParameterSet const &ps)
 
void resetEvent (HepMC::GenEvent *event)
 
void resetEventInfo (GenEventInfoProduct *eventInfo)
 
virtual bool residualDecay ()
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
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 ()
 

Protected Member Functions

std::auto_ptr< HepMC::GenEvent > & event ()
 
std::auto_ptr
< GenEventInfoProduct > & 
eventInfo ()
 
GenRunInfoProductrunInfo ()
 

Protected Attributes

double fMaxPhi
 
double fMinPhi
 
std::vector< int > fPartIDs
 
- Protected Attributes inherited from gen::Py8InterfaceBase
HepMC::IO_AsciiParticles * ascii_io
 
EvtGenDecays * evtgenDecays
 
std::string evtgenDecFile
 
std::string evtgenPdlFile
 
std::auto_ptr< Pythia8::Pythia > fDecayer
 
std::auto_ptr< Pythia8::Pythia > fMasterGen
 
ParameterCollector fParameters
 
unsigned int maxEventsToPrint
 
bool pythiaHepMCVerbosity
 
bool pythiaHepMCVerbosityParticles
 
unsigned int pythiaPylistVerbosity
 
HepMC::Pythia8ToHepMC toHepMC
 
bool useEvtGen
 

Private Attributes

edm::EventedmEvent_
 
std::auto_ptr< HepMC::GenEvent > genEvent_
 
std::auto_ptr
< GenEventInfoProduct
genEventInfo_
 
GenRunInfoProduct genRunInfo_
 

Static Private Attributes

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

Detailed Description

Definition at line 41 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, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), runInfo(), GenRunInfoProduct::setExternalXSecLO(), GenRunInfoProduct::setExternalXSecNLO(), and GenRunInfoProduct::setFilterEfficiency().

16  : Py8InterfaceBase(ps)
17 {
18 
20  ps.getUntrackedParameter<double>("filterEfficiency", -1.) );
22  GenRunInfoProduct::XSec(ps.getUntrackedParameter<double>("crossSection", -1.)) );
24  GenRunInfoProduct::XSec(ps.getUntrackedParameter<double>("crossSectionNLO", -1.)) );
25 
26  // PGun specs
27  //
28  edm::ParameterSet pgun_params =
29  ps.getParameter<edm::ParameterSet>("PGunParameters");
30 
31  // although there's the method ParameterSet::empty(),
32  // it looks like it's NOT even necessary to check if it is,
33  // before trying to extract parameters - if it is empty,
34  // the default values seem to be taken
35  //
36  fPartIDs = pgun_params.getParameter< std::vector<int> >("ParticleID");
37  fMinPhi = pgun_params.getParameter<double>("MinPhi"); // ,-3.14159265358979323846);
38  fMaxPhi = pgun_params.getParameter<double>("MaxPhi"); // , 3.14159265358979323846);
39 
40 }
T getParameter(std::string const &) const
void setFilterEfficiency(double effic)
double fMinPhi
Definition: Py8GunBase.h:75
Py8InterfaceBase(edm::ParameterSet const &ps)
std::vector< int > fPartIDs
Definition: Py8GunBase.h:74
double fMaxPhi
Definition: Py8GunBase.h:76
void setExternalXSecNLO(const XSec &xsec)
GenRunInfoProduct & runInfo()
Definition: Py8GunBase.h:68
void setExternalXSecLO(const XSec &xsec)
gen::Py8GunBase::~Py8GunBase ( )
inline

Definition at line 44 of file Py8GunBase.h.

44 {}

Member Function Documentation

std::auto_ptr<HepMC::GenEvent>& gen::Py8GunBase::event ( )
inlineprotected
std::auto_ptr<GenEventInfoProduct>& gen::Py8GunBase::eventInfo ( )
inlineprotected

Definition at line 70 of file Py8GunBase.h.

References genEventInfo_.

70 { return genEventInfo_; }
std::auto_ptr< GenEventInfoProduct > genEventInfo_
Definition: Py8GunBase.h:81
void gen::Py8GunBase::finalizeEvent ( )
virtual

Implements gen::Py8InterfaceBase.

Definition at line 122 of file Py8GunBase.cc.

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

123 {
124 
125  //******** Verbosity ********
126 
127  if (maxEventsToPrint > 0 &&
130  {
133  {
134  fMasterGen->info.list(std::cout);
135  fMasterGen->event.list(std::cout);
136  }
137 
139  {
140  std::cout << "Event process = "
141  << fMasterGen->info.code() << "\n"
142  << "----------------------" << std::endl;
143  event()->print();
144  }
146  std::cout << "Event process = "
147  << fMasterGen->info.code() << "\n"
148  << "----------------------" << std::endl;
149  ascii_io->write_event(event().get());
150  }
151  }
152 
153  return;
154 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
HepMC::IO_AsciiParticles * ascii_io
unsigned int pythiaPylistVerbosity
std::auto_ptr< HepMC::GenEvent > & event()
Definition: Py8GunBase.h:69
unsigned int maxEventsToPrint
tuple cout
Definition: gather_cfg.py:121
edm::Event& gen::Py8GunBase::getEDMEvent ( ) const
inline

Definition at line 56 of file Py8GunBase.h.

References edmEvent_.

56 { return *edmEvent_; }
edm::Event * edmEvent_
Definition: Py8GunBase.h:83
HepMC::GenEvent* gen::Py8GunBase::getGenEvent ( )
inline

Definition at line 48 of file Py8GunBase.h.

References genEvent_.

48 { return genEvent_.release(); }
std::auto_ptr< HepMC::GenEvent > genEvent_
Definition: Py8GunBase.h:80
GenEventInfoProduct* gen::Py8GunBase::getGenEventInfo ( )
inline

Definition at line 49 of file Py8GunBase.h.

References genEventInfo_.

49 { return genEventInfo_.release(); }
std::auto_ptr< GenEventInfoProduct > genEventInfo_
Definition: Py8GunBase.h:81
GenRunInfoProduct& gen::Py8GunBase::getGenRunInfo ( )
inline

Definition at line 47 of file Py8GunBase.h.

References genRunInfo_.

47 { return genRunInfo_; }
GenRunInfoProduct genRunInfo_
Definition: Py8GunBase.h:79
bool gen::Py8GunBase::initializeForInternalPartons ( )
virtual

Implements gen::Py8InterfaceBase.

Definition at line 44 of file Py8GunBase.cc.

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

45 {
46 
47  // NO MATTER what was this setting below, override it before init
48  // - this is essencial for the PGun mode
49 
50  // Key requirement: switch off ProcessLevel, and thereby also PartonLevel.
51  fMasterGen->readString("ProcessLevel:all = off");
52  fMasterGen->readString("ProcessLevel::resonanceDecays=on");
53  fMasterGen->init();
54 
55  // init decayer
56  fDecayer->readString("ProcessLevel:all = off"); // Same trick!
57  fDecayer->readString("ProcessLevel::resonanceDecays=on");
58  fDecayer->init();
59 
60  if (useEvtGen) {
61  edm::LogInfo("Pythia8Interface") << "Creating and initializing pythia8 EvtGen plugin";
62 
63  evtgenDecays = new EvtGenDecays(fMasterGen.get(), evtgenDecFile.c_str(), evtgenPdlFile.c_str());
64  evtgenDecays->readDecayFile("evtgen_userfile.dec");
65  }
66 
67  return true;
68 
69 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
EvtGenDecays * evtgenDecays
std::auto_ptr< Pythia8::Pythia > fDecayer
void gen::Py8GunBase::resetEvent ( HepMC::GenEvent *  event)
inline

Definition at line 51 of file Py8GunBase.h.

References genEvent_.

51 { genEvent_.reset(event); }
std::auto_ptr< HepMC::GenEvent > genEvent_
Definition: Py8GunBase.h:80
std::auto_ptr< HepMC::GenEvent > & event()
Definition: Py8GunBase.h:69
void gen::Py8GunBase::resetEventInfo ( GenEventInfoProduct eventInfo)
inline

Definition at line 52 of file Py8GunBase.h.

References genEventInfo_.

52 { genEventInfo_.reset(eventInfo); }
std::auto_ptr< GenEventInfoProduct > genEventInfo_
Definition: Py8GunBase.h:81
bool gen::Py8GunBase::residualDecay ( )
virtual

Definition at line 71 of file Py8GunBase.cc.

References event(), gen::Py8InterfaceBase::fDecayer, gen::Py8InterfaceBase::fMasterGen, configurableAnalysis::GenParticle, query::result, and gen::Py8InterfaceBase::toHepMC.

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

Definition at line 68 of file Py8GunBase.h.

References genRunInfo_.

Referenced by Py8GunBase(), and statistics().

68 { return genRunInfo_; }
GenRunInfoProduct genRunInfo_
Definition: Py8GunBase.h:79
virtual bool gen::Py8GunBase::select ( HepMC::GenEvent *  ) const
inlinevirtual

Definition at line 57 of file Py8GunBase.h.

57 { return true;}
void gen::Py8GunBase::setEDMEvent ( edm::Event event)
inline

Definition at line 55 of file Py8GunBase.h.

References edmEvent_, and event().

55 { edmEvent_ = &event; }
edm::Event * edmEvent_
Definition: Py8GunBase.h:83
std::auto_ptr< HepMC::GenEvent > & event()
Definition: Py8GunBase.h:69
void gen::Py8GunBase::setRandomEngine ( CLHEP::HepRandomEngine *  v)
inline

Definition at line 64 of file Py8GunBase.h.

References gen::Py8InterfaceBase::p8SetRandomEngine().

64 { 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 65 of file Py8GunBase.h.

References p8SharedResources.

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

Reimplemented from gen::Py8InterfaceBase.

Definition at line 156 of file Py8GunBase.cc.

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

157 {
158 
159  fMasterGen->stat();
160 
161  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
162  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
163  runInfo().setInternalXSec(xsec);
164  return;
165 
166 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
Definition: Py8GunBase.h:68

Member Data Documentation

edm::Event* gen::Py8GunBase::edmEvent_
private

Definition at line 83 of file Py8GunBase.h.

Referenced by getEDMEvent(), and setEDMEvent().

double gen::Py8GunBase::fMaxPhi
protected
double gen::Py8GunBase::fMinPhi
protected
std::vector<int> gen::Py8GunBase::fPartIDs
protected
std::auto_ptr<HepMC::GenEvent> gen::Py8GunBase::genEvent_
private

Definition at line 80 of file Py8GunBase.h.

Referenced by event(), getGenEvent(), and resetEvent().

std::auto_ptr<GenEventInfoProduct> gen::Py8GunBase::genEventInfo_
private

Definition at line 81 of file Py8GunBase.h.

Referenced by eventInfo(), getGenEventInfo(), and resetEventInfo().

GenRunInfoProduct gen::Py8GunBase::genRunInfo_
private

Definition at line 79 of file Py8GunBase.h.

Referenced by getGenRunInfo(), and runInfo().

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

Definition at line 85 of file Py8GunBase.h.

Referenced by sharedResources().