CMS 3D CMS Logo

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

#include <Py8HMC3InterfaceBase.h>

Inheritance diagram for gen::Py8HMC3InterfaceBase:
gen::BaseHadronizer Pythia8HepMC3Hadronizer

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)
 
 Py8HMC3InterfaceBase (edm::ParameterSet const &ps)
 
P8RndmEnginerandomEngine ()
 
bool readSettings (int)
 
virtual void statistics ()
 
 ~Py8HMC3InterfaceBase () override=default
 
- 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

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_
 
HepMC3::Pythia8ToHepMC3 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 24 of file Py8HMC3InterfaceBase.h.

Constructor & Destructor Documentation

◆ Py8HMC3InterfaceBase()

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

Definition at line 15 of file Py8HMC3InterfaceBase.cc.

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

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

◆ ~Py8HMC3InterfaceBase()

gen::Py8HMC3InterfaceBase::~Py8HMC3InterfaceBase ( )
overridedefault

Member Function Documentation

◆ classname()

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

Implemented in Pythia8HepMC3Hadronizer.

◆ decay()

bool gen::Py8HMC3InterfaceBase::decay ( )
inline

Definition at line 30 of file Py8HMC3InterfaceBase.h.

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

◆ declareSpecialSettings()

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

Definition at line 201 of file Py8HMC3InterfaceBase.cc.

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

201  {
202  for (unsigned int iss = 0; iss < settings.size(); iss++) {
203  if (settings[iss].find("QED-brem-off") != std::string::npos) {
204  fMasterGen->readString("TimeShower:QEDshowerByL=off");
205  } else {
206  size_t fnd1 = settings[iss].find("Pythia8:");
207  if (fnd1 != std::string::npos) {
208  std::string value = settings[iss].substr(fnd1 + 8);
209  fDecayer->readString(value);
210  }
211  }
212  }
213  return true;
214  }
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::Py8HMC3InterfaceBase::declareStableParticles ( const std::vector< int > &  pdgIds)

Definition at line 180 of file Py8HMC3InterfaceBase.cc.

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

180  {
181  for (size_t i = 0; i < pdgIds.size(); i++) {
182  int PyID = pdgIds[i];
183  std::ostringstream pyCard;
184  pyCard << PyID << ":mayDecay=false";
185 
186  if (fMasterGen->particleData.isParticle(PyID)) {
187  fMasterGen->readString(pyCard.str());
188  } else {
189  edm::LogWarning("DataNotUnderstood") << "Pythia8 does not "
190  << "recognize particle id = " << PyID << std::endl;
191  }
192  // alternative:
193  // set the 2nd input argument warn=false
194  // - this way Py8 will NOT print warnings about unknown particle code(s)
195  // fMasterPtr->readString( pyCard.str(), false )
196  }
197 
198  return true;
199  }
std::unique_ptr< Pythia8::Pythia > fMasterGen
Log< level::Warning, false > LogWarning

◆ finalizeEvent()

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

Implemented in Pythia8HepMC3Hadronizer.

◆ generatePartonsAndHadronize()

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

Implemented in Pythia8HepMC3Hadronizer.

◆ initializeForInternalPartons()

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

Implemented in Pythia8HepMC3Hadronizer.

◆ makeTmpSLHA()

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

Definition at line 168 of file Py8HMC3InterfaceBase.cc.

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

Referenced by readSettings().

168  {
169  char tempslhaname[] = "pythia8SLHAtableXXXXXX";
170  int fd = mkstemp(tempslhaname);
171  write(fd, slhatable.c_str(), slhatable.size());
172  close(fd);
173 
174  slhafile_ = tempslhaname;
175 
176  fMasterGen->settings.mode("SLHA:readFrom", 2);
177  fMasterGen->settings.word("SLHA:file", slhafile_);
178  }
std::unique_ptr< Pythia8::Pythia > fMasterGen
fd
Definition: ztee.py:136

◆ p8SetRandomEngine()

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

Definition at line 40 of file Py8HMC3InterfaceBase.h.

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

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

◆ randomEngine()

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

Definition at line 41 of file Py8HMC3InterfaceBase.h.

References p8RndmEngine_.

41 { return p8RndmEngine_; }

◆ readSettings()

bool gen::Py8HMC3InterfaceBase::readSettings ( int  )

Definition at line 67 of file Py8HMC3InterfaceBase.cc.

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

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

◆ statistics()

void gen::Py8HMC3InterfaceBase::statistics ( )
virtual

Reimplemented in Pythia8HepMC3Hadronizer.

Definition at line 216 of file Py8HMC3InterfaceBase.cc.

References fMasterGen.

216  {
217  fMasterGen->stat();
218  return;
219  }
std::unique_ptr< Pythia8::Pythia > fMasterGen

Member Data Documentation

◆ evtgenDecays

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

◆ evtgenDecFile

std::string gen::Py8HMC3InterfaceBase::evtgenDecFile
protected

◆ evtgenPdlFile

std::string gen::Py8HMC3InterfaceBase::evtgenPdlFile
protected

◆ evtgenUserFiles

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

◆ fDecayer

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

◆ fMasterGen

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

◆ fParameters

edm::ParameterSet gen::Py8HMC3InterfaceBase::fParameters
protected

Definition at line 47 of file Py8HMC3InterfaceBase.h.

Referenced by Py8HMC3InterfaceBase(), and readSettings().

◆ maxEventsToPrint

unsigned int gen::Py8HMC3InterfaceBase::maxEventsToPrint
protected

◆ p8RndmEngine_

P8RndmEngine gen::Py8HMC3InterfaceBase::p8RndmEngine_
private

Definition at line 65 of file Py8HMC3InterfaceBase.h.

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

◆ pythiaHepMCVerbosity

bool gen::Py8HMC3InterfaceBase::pythiaHepMCVerbosity
protected

◆ pythiaHepMCVerbosityParticles

bool gen::Py8HMC3InterfaceBase::pythiaHepMCVerbosityParticles
protected

◆ pythiaPylistVerbosity

unsigned int gen::Py8HMC3InterfaceBase::pythiaPylistVerbosity
protected

◆ slhafile_

std::string gen::Py8HMC3InterfaceBase::slhafile_
protected

◆ toHepMC

HepMC3::Pythia8ToHepMC3 gen::Py8HMC3InterfaceBase::toHepMC
protected

◆ useEvtGen

bool gen::Py8HMC3InterfaceBase::useEvtGen
protected