CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Private Attributes
gen::Py8InterfaceBase Class Referenceabstract

#include <Py8InterfaceBase.h>

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

Public Member Functions

virtual const char * classname () const =0
 
bool decay ()
 
bool declareSpecialSettings (const std::vector< std::string > &)
 
bool declareStableParticles (const std::vector< int > &)
 
virtual void finalizeEvent ()=0
 
virtual bool generatePartonsAndHadronize ()=0
 
virtual bool initializeForInternalPartons ()=0
 
void p8SetRandomEngine (CLHEP::HepRandomEngine *v)
 
 Py8InterfaceBase (edm::ParameterSet const &ps)
 
P8RndmEnginerandomEngine ()
 
bool readSettings (int)
 
virtual void statistics ()
 
 ~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

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_
 

Private Attributes

P8RndmEngine p8RndmEngine_
 

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 25 of file Py8InterfaceBase.h.

Constructor & Destructor Documentation

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

Definition at line 14 of file Py8InterfaceBase.cc.

References ascii_io, evtgenDecFile, evtgenPdlFile, evtgenUserFiles, edm::ParameterSet::exists(), fParameters, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), maxEventsToPrint, MillePedeFileConverter_cfg::out, pythiaHepMCVerbosity, pythiaHepMCVerbosityParticles, pythiaPylistVerbosity, AlCaHLTBitMon_QueryRunRegistry::string, and useEvtGen.

14  :
15 BaseHadronizer(ps),
16 useEvtGen(false), evtgenDecays(nullptr)
17 {
18  fParameters = ps;
19 
20  pythiaPylistVerbosity = ps.getUntrackedParameter<int>("pythiaPylistVerbosity", 0);
21  pythiaHepMCVerbosity = ps.getUntrackedParameter<bool>("pythiaHepMCVerbosity", false);
22  pythiaHepMCVerbosityParticles = ps.getUntrackedParameter<bool>("pythiaHepMCVerbosityParticles", false);
23  maxEventsToPrint = ps.getUntrackedParameter<int>("maxEventsToPrint", 0);
24 
25  if(pythiaHepMCVerbosityParticles)
26  ascii_io = new HepMC::IO_AsciiParticles("cout", std::ios::out);
27 
28  if ( ps.exists("useEvtGenPlugin") ) {
29 
30  useEvtGen = true;
31 
32  string evtgenpath(getenv("EVTGENDATA"));
33  evtgenDecFile = evtgenpath + string("/DECAY_2010.DEC");
34  evtgenPdlFile = evtgenpath + string("/evt.pdl");
35 
36  if ( ps.exists( "evtgenDecFile" ) )
37  evtgenDecFile = ps.getParameter<string>("evtgenDecFile");
38 
39  if ( ps.exists( "evtgenPdlFile" ) )
40  evtgenPdlFile = ps.getParameter<string>("evtgenPdlFile");
41 
42  if ( ps.exists( "evtgenUserFile" ) )
43  evtgenUserFiles = ps.getParameter< std::vector<std::string> >("evtgenUserFile");
44 
45  }
46 
47 }
std::auto_ptr< EvtGenDecays > evtgenDecays
HepMC::IO_AsciiParticles * ascii_io
BaseHadronizer(edm::ParameterSet const &ps)
std::vector< std::string > evtgenUserFiles
unsigned int pythiaPylistVerbosity
unsigned int maxEventsToPrint
edm::ParameterSet fParameters
gen::Py8InterfaceBase::~Py8InterfaceBase ( )
inlineoverride

Definition at line 30 of file Py8InterfaceBase.h.

30 {}

Member Function Documentation

virtual const char* gen::Py8InterfaceBase::classname ( ) const
pure virtual
bool gen::Py8InterfaceBase::decay ( )
inline

Definition at line 33 of file Py8InterfaceBase.h.

References data-class-funcs::classname, and myMessageLogger_cff::statistics.

33 { return true; } // NOT used - let's call it "design imperfection"
bool gen::Py8InterfaceBase::declareSpecialSettings ( const std::vector< std::string > &  settings)

Definition at line 178 of file Py8InterfaceBase.cc.

References fDecayer, spr::find(), fMasterGen, and AlCaHLTBitMon_QueryRunRegistry::string.

178  {
179  for ( unsigned int iss=0; iss<settings.size(); iss++ ){
180  if ( settings[iss].find("QED-brem-off") != std::string::npos ){
181  fMasterGen->readString( "TimeShower:QEDshowerByL=off" );
182  }
183  else{
184  size_t fnd1 = settings[iss].find("Pythia8:");
185  if ( fnd1 != std::string::npos ){
186  std::string value = settings[iss].substr (fnd1+8);
187  fDecayer->readString(value);
188  }
189  }
190  }
191  return true;
192 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
Definition: value.py:1
std::auto_ptr< Pythia8::Pythia > fDecayer
bool gen::Py8InterfaceBase::declareStableParticles ( const std::vector< int > &  pdgIds)

Definition at line 145 of file Py8InterfaceBase.cc.

References fMasterGen, and mps_fire::i.

146 {
147 
148  for ( size_t i=0; i<pdgIds.size(); i++ )
149  {
150  // FIXME: need to double check if PID's are the same in Py6 & Py8,
151  // because the HepPDT translation tool is actually for **Py6**
152  //
153  // well, actually it looks like Py8 operates in PDT id's rather than Py6's
154  //
155 // int PyID = HepPID::translatePDTtoPythia( pdgIds[i] );
156  int PyID = pdgIds[i];
157  std::ostringstream pyCard ;
158  pyCard << PyID <<":mayDecay=false";
159 
160  if ( fMasterGen->particleData.isParticle( PyID ) ) {
161  fMasterGen->readString( pyCard.str() );
162  } else {
163 
164  edm::LogWarning("DataNotUnderstood") << "Pythia8 does not "
165  << "recognize particle id = "
166  << PyID << std::endl;
167  }
168  // alternative:
169  // set the 2nd input argument warn=false
170  // - this way Py8 will NOT print warnings about unknown particle code(s)
171  // fMasterPtr->readString( pyCard.str(), false )
172  }
173 
174  return true;
175 
176 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
virtual void gen::Py8InterfaceBase::finalizeEvent ( )
pure virtual

Implemented in Pythia8Hadronizer, and gen::Py8GunBase.

virtual bool gen::Py8InterfaceBase::generatePartonsAndHadronize ( )
pure virtual
virtual bool gen::Py8InterfaceBase::initializeForInternalPartons ( )
pure virtual

Implemented in Pythia8Hadronizer, and gen::Py8GunBase.

void gen::Py8InterfaceBase::p8SetRandomEngine ( CLHEP::HepRandomEngine *  v)
inline

Definition at line 42 of file Py8InterfaceBase.h.

double v[5][pyjets_maxn]
void setRandomEngine(CLHEP::HepRandomEngine *v)
Definition: P8RndmEngine.h:35
P8RndmEngine p8RndmEngine_
P8RndmEngine& gen::Py8InterfaceBase::randomEngine ( )
inline
bool gen::Py8InterfaceBase::readSettings ( int  )

Definition at line 49 of file Py8InterfaceBase.cc.

References gen::ParameterCollector::begin(), gen::ParameterCollector::end(), edm::ParameterSet::exists(), connectstrParser::f1, fDecayer, fMasterGen, fParameters, edm::ParameterSet::getParameter(), geometryCSVtoXML::line, p8RndmEngine_, gen::BaseHadronizer::randomIndex(), slhafile_, AlCaHLTBitMon_QueryRunRegistry::string, and TriggerAnalyzer::write().

50 {
51 
52  if(!fMasterGen.get()) fMasterGen.reset(new Pythia);
53  fDecayer.reset(new Pythia);
54 
55  //add settings for resonance decay filter
56  fMasterGen->settings.addFlag("ResonanceDecayFilter:filter",false);
57  fMasterGen->settings.addFlag("ResonanceDecayFilter:exclusive",false);
58  fMasterGen->settings.addFlag("ResonanceDecayFilter:eMuAsEquivalent",false);
59  fMasterGen->settings.addFlag("ResonanceDecayFilter:eMuTauAsEquivalent",false);
60  fMasterGen->settings.addFlag("ResonanceDecayFilter:allNuAsEquivalent",false);
61  fMasterGen->settings.addFlag("ResonanceDecayFilter:udscAsEquivalent",false);
62  fMasterGen->settings.addFlag("ResonanceDecayFilter:udscbAsEquivalent",false);
63  fMasterGen->settings.addFlag("ResonanceDecayFilter:wzAsEquivalent",false);
64  fMasterGen->settings.addMVec("ResonanceDecayFilter:mothers",std::vector<int>(),false,false,0,0);
65  fMasterGen->settings.addMVec("ResonanceDecayFilter:daughters",std::vector<int>(),false,false,0,0);
66 
67  //add settings for PT filter
68  fMasterGen->settings.addFlag("PTFilter:filter",false);
69  fMasterGen->settings.addMode("PTFilter:quarkToFilter", 5 ,true,true,3, 6);
70  fMasterGen->settings.addParm("PTFilter:scaleToFilter", 0.4,true,true,0.0, 10.);
71  fMasterGen->settings.addParm("PTFilter:quarkRapidity",10.0,true,true,0.0, 10.);
72  fMasterGen->settings.addParm("PTFilter:quarkPt", -.1,true,true,-.1,100.);
73 
74  //add settings for powheg resonance scale calculation
75  fMasterGen->settings.addFlag("POWHEGres:calcScales",false);
76  fMasterGen->settings.addFlag("POWHEG:bb4l",false);
77  fMasterGen->settings.addFlag("POWHEG:bb4l:onlyDistance1",false);
78  fMasterGen->settings.addFlag("POWHEG:bb4l:useScaleResonanceInstead",false);
79 
80  fMasterGen->setRndmEnginePtr( &p8RndmEngine_ );
81  fDecayer->setRndmEnginePtr( &p8RndmEngine_ );
82 
83  fMasterGen->readString("Next:numberShowEvent = 0");
84  fDecayer->readString("Next:numberShowEvent = 0");
85 
86  edm::ParameterSet currentParameters;
87  if (randomIndex()>=0) {
88  std::vector<edm::ParameterSet> randomizedParameters = fParameters.getParameter<std::vector<edm::ParameterSet> >("RandomizedParameters");
89  currentParameters = randomizedParameters[randomIndex()];
90  }
91  else {
92  currentParameters = fParameters;
93  }
94 
95  ParameterCollector pCollector = currentParameters.getParameter<edm::ParameterSet>("PythiaParameters");
96 
97  for ( ParameterCollector::const_iterator line = pCollector.begin();
98  line != pCollector.end(); ++line )
99  {
100  if (line->find("Random:") != std::string::npos)
101  throw cms::Exception("PythiaError") << "Attempted to set random number "
102  "using Pythia commands. Please use " "the RandomNumberGeneratorService."
103  << std::endl;
104 
105  if (!fMasterGen->readString(*line)) throw cms::Exception("PythiaError")
106  << "Pythia 8 did not accept \""
107  << *line << "\"." << std::endl;
108 
109  if (line->find("ParticleDecays:") != std::string::npos) {
110 
111  if (!fDecayer->readString(*line)) throw cms::Exception("PythiaError")
112  << "Pythia 8 Decayer did not accept \""
113  << *line << "\"." << std::endl;
114  }
115 
116  }
117 
118  slhafile_.clear();
119 
120  if( currentParameters.exists( "SLHAFileForPythia8" ) ) {
121  std::string slhafilenameshort = currentParameters.getParameter<std::string>("SLHAFileForPythia8");
122  edm::FileInPath f1( slhafilenameshort );
123 
124  fMasterGen->settings.mode("SLHA:readFrom", 2);
125  fMasterGen->settings.word("SLHA:file", f1.fullPath());
126  }
127  else if( currentParameters.exists( "SLHATableForPythia8" ) ) {
128  std::string slhatable = currentParameters.getParameter<std::string>("SLHATableForPythia8");
129 
130  char tempslhaname[] = "pythia8SLHAtableXXXXXX";
131  int fd = mkstemp(tempslhaname);
132  write(fd,slhatable.c_str(),slhatable.size());
133  close(fd);
134 
135  slhafile_ = tempslhaname;
136 
137  fMasterGen->settings.mode("SLHA:readFrom", 2);
138  fMasterGen->settings.word("SLHA:file", slhafile_);
139  }
140 
141  return true;
142 
143 }
T getParameter(std::string const &) const
std::auto_ptr< Pythia8::Pythia > fMasterGen
bool exists(std::string const &parameterName) const
checks if a parameter exists
P8RndmEngine p8RndmEngine_
std::auto_ptr< Pythia8::Pythia > fDecayer
int randomIndex() const
def write(self, setup)
edm::ParameterSet fParameters
void gen::Py8InterfaceBase::statistics ( )
virtual

Reimplemented in Pythia8Hadronizer, and gen::Py8GunBase.

Definition at line 195 of file Py8InterfaceBase.cc.

References fMasterGen.

196 {
197 
198  fMasterGen->stat();
199  return;
200 
201 }
std::auto_ptr< Pythia8::Pythia > fMasterGen

Member Data Documentation

HepMC::IO_AsciiParticles* gen::Py8InterfaceBase::ascii_io
protected
std::auto_ptr<EvtGenDecays> gen::Py8InterfaceBase::evtgenDecays
protected
std::string gen::Py8InterfaceBase::evtgenDecFile
protected
std::string gen::Py8InterfaceBase::evtgenPdlFile
protected
std::vector<std::string> gen::Py8InterfaceBase::evtgenUserFiles
protected
std::auto_ptr<Pythia8::Pythia> gen::Py8InterfaceBase::fDecayer
protected
std::auto_ptr<Pythia8::Pythia> gen::Py8InterfaceBase::fMasterGen
protected
edm::ParameterSet gen::Py8InterfaceBase::fParameters
protected

Definition at line 51 of file Py8InterfaceBase.h.

Referenced by Py8InterfaceBase(), and readSettings().

unsigned int gen::Py8InterfaceBase::maxEventsToPrint
protected
P8RndmEngine gen::Py8InterfaceBase::p8RndmEngine_
private

Definition at line 71 of file Py8InterfaceBase.h.

Referenced by readSettings().

bool gen::Py8InterfaceBase::pythiaHepMCVerbosity
protected
bool gen::Py8InterfaceBase::pythiaHepMCVerbosityParticles
protected
unsigned int gen::Py8InterfaceBase::pythiaPylistVerbosity
protected
std::string gen::Py8InterfaceBase::slhafile_
protected
HepMC::Pythia8ToHepMC gen::Py8InterfaceBase::toHepMC
protected
bool gen::Py8InterfaceBase::useEvtGen
protected