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::Py8MassGun gen::Py8PtAndDxyGun gen::Py8PtAndLxyGun gen::Py8PtGun gen::Py8PtotGun

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 makeTmpSLHA (const std::string &)
 
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
 
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

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_
 

Private Attributes

P8RndmEngine p8RndmEngine_
 

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

Constructor & Destructor Documentation

◆ Py8InterfaceBase()

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

Definition at line 19 of file Py8InterfaceBase.cc.

References ascii_io, evtgenDecFile, evtgenPdlFile, evtgenUserFiles, edm::ParameterSet::exists(), ztee::fd, fParameters, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, maxEventsToPrint, MillePedeFileConverter_cfg::out, pythiaHepMCVerbosity, pythiaHepMCVerbosityParticles, pythiaPylistVerbosity, AlCaHLTBitMon_QueryRunRegistry::string, useEvtGen, and writeEcalDQMStatus::write.

20  : BaseHadronizer(ps), useEvtGen(false), evtgenDecays(nullptr) {
21  fParameters = ps;
22 
23  pythiaPylistVerbosity = ps.getUntrackedParameter<int>("pythiaPylistVerbosity", 0);
24  pythiaHepMCVerbosity = ps.getUntrackedParameter<bool>("pythiaHepMCVerbosity", false);
25  pythiaHepMCVerbosityParticles = ps.getUntrackedParameter<bool>("pythiaHepMCVerbosityParticles", false);
26  maxEventsToPrint = ps.getUntrackedParameter<int>("maxEventsToPrint", 0);
27 
29  ascii_io = new HepMC::IO_AsciiParticles("cout", std::ios::out);
30 
31  if (ps.exists("useEvtGenPlugin")) {
32  useEvtGen = true;
33  string evtgenpath(std::getenv("EVTGENDATA"));
34  evtgenDecFile = evtgenpath + string("/DECAY_2010.DEC");
35  evtgenPdlFile = evtgenpath + string("/evt.pdl");
36 
37  if (ps.exists("evtgenDecFile")) {
38  edm::FileInPath decay_table(ps.getParameter<std::string>("evtgenDecFile"));
39  evtgenDecFile = decay_table.fullPath();
40  }
41 
42  if (ps.exists("evtgenPdlFile")) {
43  edm::FileInPath pdt(ps.getParameter<std::string>("evtgenPdlFile"));
44  evtgenPdlFile = pdt.fullPath();
45  }
46 
47  if (ps.exists("evtgenUserFile")) {
48  std::vector<std::string> user_decays = ps.getParameter<std::vector<std::string> >("evtgenUserFile");
49  for (unsigned int i = 0; i < user_decays.size(); i++) {
50  edm::FileInPath user_decay(user_decays.at(i));
51  evtgenUserFiles.push_back(user_decay.fullPath());
52  }
53  //evtgenUserFiles = ps.getParameter< std::vector<std::string> >("evtgenUserFile");
54  }
55 
56  if (ps.exists("evtgenUserFileEmbedded")) {
57  std::vector<std::string> user_decay_lines =
58  ps.getParameter<std::vector<std::string> >("evtgenUserFileEmbedded");
59  char tempslhaname[] = "pythia8evtgenXXXXXX";
60  int fd = mkstemp(tempslhaname);
61 
62  for (unsigned int i = 0; i < user_decay_lines.size(); i++) {
63  user_decay_lines.at(i) += "\n";
64  write(fd, user_decay_lines.at(i).c_str(), user_decay_lines.at(i).size());
65  }
66  close(fd);
67  evtgenUserFiles.push_back(std::string(tempslhaname));
68  }
69  }
70  }
std::shared_ptr< Pythia8::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
fd
Definition: ztee.py:136

◆ ~Py8InterfaceBase()

gen::Py8InterfaceBase::~Py8InterfaceBase ( )
inlineoverride

Definition at line 30 of file Py8InterfaceBase.h.

30 {}

Member Function Documentation

◆ classname()

virtual const char* gen::Py8InterfaceBase::classname ( ) const
pure virtual

◆ decay()

bool gen::Py8InterfaceBase::decay ( )
inline

Definition at line 33 of file Py8InterfaceBase.h.

33 { return true; } // NOT used - let's call it "design imperfection"

◆ declareSpecialSettings()

bool gen::Py8InterfaceBase::declareSpecialSettings ( const std::vector< std::string > &  settings)

Definition at line 223 of file Py8InterfaceBase.cc.

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

223  {
224  for (unsigned int iss = 0; iss < settings.size(); iss++) {
225  if (settings[iss].find("QED-brem-off") != std::string::npos) {
226  fMasterGen->readString("TimeShower:QEDshowerByL=off");
227  } else {
228  size_t fnd1 = settings[iss].find("Pythia8:");
229  if (fnd1 != std::string::npos) {
230  std::string value = settings[iss].substr(fnd1 + 8);
231  fDecayer->readString(value);
232  }
233  }
234  }
235  return true;
236  }
std::unique_ptr< Pythia8::Pythia > fDecayer
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Definition: value.py:1
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ declareStableParticles()

bool gen::Py8InterfaceBase::declareStableParticles ( const std::vector< int > &  pdgIds)

Definition at line 196 of file Py8InterfaceBase.cc.

References fMasterGen, mps_fire::i, and CosmicGenFilterHelix_cfi::pdgIds.

196  {
197  for (size_t i = 0; i < pdgIds.size(); i++) {
198  // FIXME: need to double check if PID's are the same in Py6 & Py8,
199  // because the HepPDT translation tool is actually for **Py6**
200  //
201  // well, actually it looks like Py8 operates in PDT id's rather than Py6's
202  //
203  // int PyID = HepPID::translatePDTtoPythia( pdgIds[i] );
204  int PyID = pdgIds[i];
205  std::ostringstream pyCard;
206  pyCard << PyID << ":mayDecay=false";
207 
208  if (fMasterGen->particleData.isParticle(PyID)) {
209  fMasterGen->readString(pyCard.str());
210  } else {
211  edm::LogWarning("DataNotUnderstood") << "Pythia8 does not "
212  << "recognize particle id = " << PyID << std::endl;
213  }
214  // alternative:
215  // set the 2nd input argument warn=false
216  // - this way Py8 will NOT print warnings about unknown particle code(s)
217  // fMasterPtr->readString( pyCard.str(), false )
218  }
219 
220  return true;
221  }
std::unique_ptr< Pythia8::Pythia > fMasterGen
Log< level::Warning, false > LogWarning

◆ finalizeEvent()

virtual void gen::Py8InterfaceBase::finalizeEvent ( )
pure virtual

Implemented in Pythia8Hadronizer, and gen::Py8GunBase.

◆ generatePartonsAndHadronize()

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

◆ initializeForInternalPartons()

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

Implemented in Pythia8Hadronizer, and gen::Py8GunBase.

◆ makeTmpSLHA()

void gen::Py8InterfaceBase::makeTmpSLHA ( const std::string &  slhatable)

Definition at line 184 of file Py8InterfaceBase.cc.

References ztee::fd, fMasterGen, slhafile_, and writeEcalDQMStatus::write.

Referenced by readSettings().

184  {
185  char tempslhaname[] = "pythia8SLHAtableXXXXXX";
186  int fd = mkstemp(tempslhaname);
187  write(fd, slhatable.c_str(), slhatable.size());
188  close(fd);
189 
190  slhafile_ = tempslhaname;
191 
192  fMasterGen->settings.mode("SLHA:readFrom", 2);
193  fMasterGen->settings.word("SLHA:file", slhafile_);
194  }
std::unique_ptr< Pythia8::Pythia > fMasterGen
fd
Definition: ztee.py:136

◆ p8SetRandomEngine()

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

Definition at line 43 of file Py8InterfaceBase.h.

References p8RndmEngine_, gen::P8RndmEngine::setRandomEngine(), and gen::v.

Referenced by gen::Py8GunBase::setRandomEngine().

double v[5][pyjets_maxn]
void setRandomEngine(CLHEP::HepRandomEngine *v)
Definition: P8RndmEngine.h:34
P8RndmEngine p8RndmEngine_

◆ randomEngine()

P8RndmEngine& gen::Py8InterfaceBase::randomEngine ( )
inline

◆ readSettings()

bool gen::Py8InterfaceBase::readSettings ( int  )

Definition at line 72 of file Py8InterfaceBase.cc.

References gen::ParameterCollector::begin(), gen::ParameterCollector::end(), edm::ParameterSet::exists(), DeadROC_duringRun::f1, fDecayer, fMasterGen, fParameters, get, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_splice::line, makeTmpSLHA(), p8RndmEngine_, plotBeamSpotDB::printBanner, gen::BaseHadronizer::randomIndex(), DQM::reader, slhafile_, and AlCaHLTBitMon_QueryRunRegistry::string.

72  {
73  //Pythia 8's default value for first argument to constructor
74  const string xmlDir = "../share/Pythia8/xmldoc";
75  bool printBanner = true;
76  if (fParameters.exists("printBanner")) {
77  printBanner = fParameters.getUntrackedParameter<bool>("printBanner");
78  }
79  if (!fMasterGen.get())
80  fMasterGen = std::make_unique<Pythia>(xmlDir, printBanner);
81  fDecayer = std::make_unique<Pythia>(xmlDir, printBanner);
82 
83  //add settings for resonance decay filter
84  fMasterGen->settings.addFlag("BiasedTauDecayer:filter", false);
85  fMasterGen->settings.addFlag("BiasedTauDecayer:eDecays", true);
86  fMasterGen->settings.addFlag("BiasedTauDecayer:muDecays", true);
87 
88  //add settings for resonance decay filter
89  fMasterGen->settings.addFlag("ResonanceDecayFilter:filter", false);
90  fMasterGen->settings.addFlag("ResonanceDecayFilter:exclusive", false);
91  fMasterGen->settings.addFlag("ResonanceDecayFilter:eMuAsEquivalent", false);
92  fMasterGen->settings.addFlag("ResonanceDecayFilter:eMuTauAsEquivalent", false);
93  fMasterGen->settings.addFlag("ResonanceDecayFilter:allNuAsEquivalent", false);
94  fMasterGen->settings.addFlag("ResonanceDecayFilter:udscAsEquivalent", false);
95  fMasterGen->settings.addFlag("ResonanceDecayFilter:udscbAsEquivalent", false);
96  fMasterGen->settings.addFlag("ResonanceDecayFilter:wzAsEquivalent", false);
97  fMasterGen->settings.addMVec("ResonanceDecayFilter:mothers", std::vector<int>(), false, false, 0, 0);
98  fMasterGen->settings.addMVec("ResonanceDecayFilter:daughters", std::vector<int>(), false, false, 0, 0);
99 
100  //add settings for PT filter
101  fMasterGen->settings.addFlag("PTFilter:filter", false);
102  fMasterGen->settings.addMode("PTFilter:quarkToFilter", 5, true, true, 3, 6);
103  fMasterGen->settings.addParm("PTFilter:scaleToFilter", 0.4, true, true, 0.0, 10.);
104  fMasterGen->settings.addParm("PTFilter:quarkRapidity", 10.0, true, true, 0.0, 10.);
105  fMasterGen->settings.addParm("PTFilter:quarkPt", -.1, true, true, -.1, 100.);
106 
107  //add settings for RecoilToTop tool
108  fMasterGen->settings.addFlag("TopRecoilHook:doTopRecoilIn", false);
109  fMasterGen->settings.addFlag("TopRecoilHook:useOldDipoleIn", false);
110  fMasterGen->settings.addFlag("TopRecoilHook:doListIn", false);
111 
112  //add settings for powheg resonance scale calculation
113  fMasterGen->settings.addFlag("POWHEGres:calcScales", false);
114  fMasterGen->settings.addFlag("POWHEG:bb4l", false);
115  fMasterGen->settings.addFlag("POWHEG:bb4l:FSREmission:onlyDistance1", false);
116  fMasterGen->settings.addFlag("POWHEG:bb4l:FSREmission:veto", false);
117  fMasterGen->settings.addFlag("POWHEG:bb4l:FSREmission:dryRun", false);
118  fMasterGen->settings.addFlag("POWHEG:bb4l:FSREmission:vetoAtPL", false);
119  fMasterGen->settings.addFlag("POWHEG:bb4l:FSREmission:vetoQED", false);
120  fMasterGen->settings.addFlag("POWHEG:bb4l:PartonLevel:veto", false);
121  fMasterGen->settings.addFlag("POWHEG:bb4l:PartonLevel:excludeFSRConflicting", false);
122  fMasterGen->settings.addFlag("POWHEG:bb4l:DEBUG", false);
123  fMasterGen->settings.addFlag("POWHEG:bb4l:ScaleResonance:veto", false);
124  fMasterGen->settings.addFlag("POWHEG:bb4l:FSREmission:vetoDipoleFrame", false);
125  fMasterGen->settings.addFlag("POWHEG:bb4l:FSREmission:pTpythiaVeto", false);
126  fMasterGen->settings.addParm("POWHEG:bb4l:pTminVeto", 10.0, true, true, 0.0, 10.);
127 
128  fMasterGen->setRndmEnginePtr(&p8RndmEngine_);
129  fDecayer->setRndmEnginePtr(&p8RndmEngine_);
130 
131  fMasterGen->readString("Next:numberShowEvent = 0");
132  fDecayer->readString("Next:numberShowEvent = 0");
133 
134  edm::ParameterSet currentParameters;
135  if (randomIndex() >= 0) {
136  std::vector<edm::ParameterSet> randomizedParameters =
137  fParameters.getParameter<std::vector<edm::ParameterSet> >("RandomizedParameters");
138  currentParameters = randomizedParameters[randomIndex()];
139  } else {
140  currentParameters = fParameters;
141  }
142 
143  ParameterCollector pCollector = currentParameters.getParameter<edm::ParameterSet>("PythiaParameters");
144 
145  for (ParameterCollector::const_iterator line = pCollector.begin(); line != pCollector.end(); ++line) {
146  if (line->find("Random:") != std::string::npos)
147  throw cms::Exception("PythiaError") << "Attempted to set random number "
148  "using Pythia commands. Please use "
149  "the RandomNumberGeneratorService."
150  << std::endl;
151 
152  if (!fMasterGen->readString(*line))
153  throw cms::Exception("PythiaError") << "Pythia 8 did not accept \"" << *line << "\"." << std::endl;
154 
155  if (line->find("ParticleDecays:") != std::string::npos) {
156  if (!fDecayer->readString(*line))
157  throw cms::Exception("PythiaError") << "Pythia 8 Decayer did not accept \"" << *line << "\"." << std::endl;
158  }
159  }
160 
161  slhafile_.clear();
162 
163  if (currentParameters.exists("SLHAFileForPythia8")) {
164  std::string slhafilenameshort = currentParameters.getParameter<std::string>("SLHAFileForPythia8");
165  edm::FileInPath f1(slhafilenameshort);
166 
167  fMasterGen->settings.mode("SLHA:readFrom", 2);
168  fMasterGen->settings.word("SLHA:file", f1.fullPath());
169  } else if (currentParameters.exists("SLHATableForPythia8")) {
170  std::string slhatable = currentParameters.getParameter<std::string>("SLHATableForPythia8");
171 
172  makeTmpSLHA(slhatable);
173  } else if (currentParameters.exists("SLHATreeForPythia8")) {
174  auto slhaReaderParams = currentParameters.getParameter<edm::ParameterSet>("SLHATreeForPythia8");
175  std::unique_ptr<SLHAReaderBase> reader =
176  SLHAReaderFactory::get()->create(slhaReaderParams.getParameter<std::string>("name"), slhaReaderParams);
177 
178  makeTmpSLHA(reader->getSLHA(currentParameters.getParameter<std::string>("ConfigDescription")));
179  }
180 
181  return true;
182  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< Pythia8::Pythia > fDecayer
void makeTmpSLHA(const std::string &)
bool exists(std::string const &parameterName) const
checks if a parameter exists
reader
Definition: DQM.py:105
T getUntrackedParameter(std::string const &, T const &) const
P8RndmEngine p8RndmEngine_
int randomIndex() const
std::unique_ptr< Pythia8::Pythia > fMasterGen
#define get
edm::ParameterSet fParameters

◆ statistics()

void gen::Py8InterfaceBase::statistics ( )
virtual

Reimplemented in Pythia8Hadronizer, and gen::Py8GunBase.

Definition at line 238 of file Py8InterfaceBase.cc.

References fMasterGen.

238  {
239  fMasterGen->stat();
240  return;
241  }
std::unique_ptr< Pythia8::Pythia > fMasterGen

Member Data Documentation

◆ ascii_io

HepMC::IO_AsciiParticles* gen::Py8InterfaceBase::ascii_io
protected

◆ evtgenDecays

std::shared_ptr<Pythia8::EvtGenDecays> gen::Py8InterfaceBase::evtgenDecays
protected

◆ evtgenDecFile

std::string gen::Py8InterfaceBase::evtgenDecFile
protected

◆ evtgenPdlFile

std::string gen::Py8InterfaceBase::evtgenPdlFile
protected

◆ evtgenUserFiles

std::vector<std::string> gen::Py8InterfaceBase::evtgenUserFiles
protected

◆ fDecayer

std::unique_ptr<Pythia8::Pythia> gen::Py8InterfaceBase::fDecayer
protected

◆ fMasterGen

std::unique_ptr<Pythia8::Pythia> gen::Py8InterfaceBase::fMasterGen
protected

◆ fParameters

edm::ParameterSet gen::Py8InterfaceBase::fParameters
protected

Definition at line 51 of file Py8InterfaceBase.h.

Referenced by Py8InterfaceBase(), and readSettings().

◆ maxEventsToPrint

unsigned int gen::Py8InterfaceBase::maxEventsToPrint
protected

◆ p8RndmEngine_

P8RndmEngine gen::Py8InterfaceBase::p8RndmEngine_
private

Definition at line 70 of file Py8InterfaceBase.h.

Referenced by p8SetRandomEngine(), randomEngine(), and readSettings().

◆ pythiaHepMCVerbosity

bool gen::Py8InterfaceBase::pythiaHepMCVerbosity
protected

◆ pythiaHepMCVerbosityParticles

bool gen::Py8InterfaceBase::pythiaHepMCVerbosityParticles
protected

◆ pythiaPylistVerbosity

unsigned int gen::Py8InterfaceBase::pythiaPylistVerbosity
protected

◆ slhafile_

std::string gen::Py8InterfaceBase::slhafile_
protected

◆ toHepMC

HepMC::Pythia8ToHepMC gen::Py8InterfaceBase::toHepMC
protected

◆ useEvtGen

bool gen::Py8InterfaceBase::useEvtGen
protected