CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
Pythia8Hadronizer Class Reference
Inheritance diagram for Pythia8Hadronizer:
gen::Py8InterfaceBase gen::BaseHadronizer

Public Member Functions

const char * classname () const override
 
void finalizeEvent () override
 
bool generatePartonsAndHadronize () override
 
std::unique_ptr< GenLumiInfoHeadergetGenLumiInfoHeader () const override
 
bool hadronize ()
 
bool initializeForExternalPartons ()
 
bool initializeForInternalPartons () override
 
 Pythia8Hadronizer (const edm::ParameterSet &params)
 
virtual bool residualDecay ()
 
void statistics () override
 
 ~Pythia8Hadronizer () override
 
- Public Member Functions inherited from gen::Py8InterfaceBase
bool decay ()
 
bool declareSpecialSettings (const std::vector< std::string > &)
 
bool declareStableParticles (const std::vector< int > &)
 
void makeTmpSLHA (const std::string &)
 
void p8SetRandomEngine (CLHEP::HepRandomEngine *v)
 
 Py8InterfaceBase (edm::ParameterSet const &ps)
 
P8RndmEnginerandomEngine ()
 
bool readSettings (int)
 
 ~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 ()
 
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)
 

Private Types

enum  { PP, PPbar, ElectronPositron }
 

Private Member Functions

void doSetRandomEngine (CLHEP::HepRandomEngine *v) override
 
std::vector< std::string > const & doSharedResources () const override
 

Private Attributes

double comEnergy
 Center-of-Mass energy. More...
 
vector< float > DJR
 
bool doProtonPhotonFlux = false
 
int EV1_emittedMode
 
int EV1_maxVetoCount
 
bool EV1_MPIvetoOn
 
int EV1_nFinal
 
int EV1_nFinalMode
 
int EV1_pTdefMode
 
int EV1_pTempMode
 
int EV1_pThardMode
 
int EV1_QEDvetoMode
 
bool EV1_vetoOn
 
double fBeam1PZ
 
double fBeam2PZ
 
std::shared_ptr< BiasedTauDecayerfBiasedTauDecayer
 
std::shared_ptr< UserHooksVector > fCustomHooksVector
 
std::shared_ptr< PowhegHooks > fEmissionVetoHook
 
std::shared_ptr< EmissionVetoHook1fEmissionVetoHook1
 
int fInitialState
 
std::shared_ptr< JetMatchingHookfJetMatchingHook
 
std::shared_ptr< Pythia8::JetMatchingMadgraph > fJetMatchingPy8InternalHook
 
std::shared_ptr< Pythia8::amcnlo_unitarised_interface > fMergingHook
 
std::shared_ptr< PowhegHooksBB4LfPowhegHooksBB4L
 
std::shared_ptr< PowhegResHookfPowhegResHook
 
std::shared_ptr< PTFilterHookfPTFilterHook
 
std::shared_ptr< ResonanceDecayFilterHookfResonanceDecayFilterHook
 
std::shared_ptr< UserHooks > fReweightEmpUserHook
 
std::shared_ptr< UserHooks > fReweightPtHatRapUserHook
 
std::shared_ptr< UserHooks > fReweightRapUserHook
 
std::shared_ptr< UserHooks > fReweightUserHook
 
std::shared_ptr< TopRecoilHookfTopRecoilHook
 
std::shared_ptr< UserHooksVector > fUserHooksVector
 
std::shared_ptr< LHAupLesHoucheslhaUP
 
std::string LHEInputFileName
 
int nFSRveto
 
int nISRveto
 
int nME
 
int nMEFiltered
 
Pythia8::PDFPtr photonFlux = nullptr
 
bool UserHooksSet
 

Static Private Attributes

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

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 ()
 
- Protected Attributes inherited from gen::Py8InterfaceBase
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_
 

Detailed Description

Definition at line 116 of file Pythia8Hadronizer.cc.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Constructor & Destructor Documentation

◆ Pythia8Hadronizer()

Pythia8Hadronizer::Pythia8Hadronizer ( const edm::ParameterSet params)

Definition at line 222 of file Pythia8Hadronizer.cc.

References edm::errors::Configuration, ElectronPositron, EV1_emittedMode, EV1_maxVetoCount, EV1_MPIvetoOn, EV1_nFinal, EV1_nFinalMode, EV1_pTdefMode, EV1_pTempMode, EV1_pThardMode, EV1_QEDvetoMode, EV1_vetoOn, Exception, edm::ParameterSet::exists(), fCustomHooksVector, fEmissionVetoHook1, fInitialState, fJetMatchingHook, gen::Py8InterfaceBase::fMasterGen, fReweightEmpUserHook, fReweightPtHatRapUserHook, fReweightRapUserHook, fReweightUserHook, get, edm::ParameterSet::getParameter(), gen::BaseHadronizer::ivhepmc, submitPVValidationJobs::params, PP, PPbar, push_back(), generator_cfi::scheme, AlCaHLTBitMon_QueryRunRegistry::string, and gen::Py8InterfaceBase::toHepMC.

224  comEnergy(params.getParameter<double>("comEnergy")),
225  LHEInputFileName(params.getUntrackedParameter<std::string>("LHEInputFileName", "")),
226  fInitialState(PP),
227  doProtonPhotonFlux(params.getUntrackedParameter<bool>("doProtonPhotonFlux", false)),
228  UserHooksSet(false),
229  nME(-1),
230  nMEFiltered(-1),
231  nISRveto(0),
232  nFSRveto(0) {
233  ivhepmc = 2;
234  // J.Y.: the following 3 parameters are hacked "for a reason"
235  //
236  if (params.exists("PPbarInitialState")) {
237  if (fInitialState == PP) {
239  edm::LogImportant("GeneratorInterface|Pythia8Interface")
240  << "Pythia8 will be initialized for PROTON-ANTIPROTON INITIAL STATE. "
241  << "This is a user-request change from the DEFAULT PROTON-PROTON initial state.";
242  } else {
243  // probably need to throw on attempt to override ?
244  }
245  } else if (params.exists("ElectronPositronInitialState")) {
246  if (fInitialState == PP) {
248  edm::LogInfo("GeneratorInterface|Pythia8Interface")
249  << "Pythia8 will be initialized for ELECTRON-POSITRON INITIAL STATE. "
250  << "This is a user-request change from the DEFAULT PROTON-PROTON initial state.";
251  } else {
252  // probably need to throw on attempt to override ?
253  }
254  } else if (params.exists("ElectronProtonInitialState") || params.exists("PositronProtonInitialState")) {
255  // throw on unknown initial state !
256  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
257  << " UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
258  }
259 
260  // avoid filling weights twice (from v8.30x)
261  toHepMC.set_store_weights(false);
262 
263  // Reweight user hook
264  //
265  if (params.exists("reweightGen")) {
266  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGen";
267  edm::ParameterSet rgParams = params.getParameter<edm::ParameterSet>("reweightGen");
268  fReweightUserHook.reset(
269  new PtHatReweightUserHook(rgParams.getParameter<double>("pTRef"), rgParams.getParameter<double>("power")));
270  edm::LogInfo("Pythia8Interface") << "End setup for reweightGen";
271  }
272  if (params.exists("reweightGenEmp")) {
273  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGenEmp";
274  edm::ParameterSet rgeParams = params.getParameter<edm::ParameterSet>("reweightGenEmp");
275 
276  std::string tuneName = "";
277  if (rgeParams.exists("tune"))
278  tuneName = rgeParams.getParameter<std::string>("tune");
279  fReweightEmpUserHook.reset(new PtHatEmpReweightUserHook(tuneName));
280  edm::LogInfo("Pythia8Interface") << "End setup for reweightGenEmp";
281  }
282  if (params.exists("reweightGenRap")) {
283  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGenRap";
284  edm::ParameterSet rgrParams = params.getParameter<edm::ParameterSet>("reweightGenRap");
285  fReweightRapUserHook.reset(new RapReweightUserHook(rgrParams.getParameter<std::string>("yLabSigmaFunc"),
286  rgrParams.getParameter<double>("yLabPower"),
287  rgrParams.getParameter<std::string>("yCMSigmaFunc"),
288  rgrParams.getParameter<double>("yCMPower"),
289  rgrParams.getParameter<double>("pTHatMin"),
290  rgrParams.getParameter<double>("pTHatMax")));
291  edm::LogInfo("Pythia8Interface") << "End setup for reweightGenRap";
292  }
293  if (params.exists("reweightGenPtHatRap")) {
294  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGenPtHatRap";
295  edm::ParameterSet rgrParams = params.getParameter<edm::ParameterSet>("reweightGenPtHatRap");
296  fReweightPtHatRapUserHook.reset(new PtHatRapReweightUserHook(rgrParams.getParameter<std::string>("yLabSigmaFunc"),
297  rgrParams.getParameter<double>("yLabPower"),
298  rgrParams.getParameter<std::string>("yCMSigmaFunc"),
299  rgrParams.getParameter<double>("yCMPower"),
300  rgrParams.getParameter<double>("pTHatMin"),
301  rgrParams.getParameter<double>("pTHatMax")));
302  edm::LogInfo("Pythia8Interface") << "End setup for reweightGenPtHatRap";
303  }
304 
305  if (params.exists("useUserHook"))
306  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
307  << " Obsolete parameter: useUserHook \n Please use the actual one instead \n";
308 
309  // PS matching prototype
310  //
311  if (params.exists("jetMatching")) {
312  edm::ParameterSet jmParams = params.getUntrackedParameter<edm::ParameterSet>("jetMatching");
313  std::string scheme = jmParams.getParameter<std::string>("scheme");
314  if (scheme == "Madgraph" || scheme == "MadgraphFastJet") {
315  fJetMatchingHook.reset(new JetMatchingHook(jmParams, &fMasterGen->info));
316  }
317  }
318 
319  // Pythia8Interface emission veto
320  //
321  if (params.exists("emissionVeto1")) {
322  EV1_nFinal = -1;
323  if (params.exists("EV1_nFinal"))
324  EV1_nFinal = params.getParameter<int>("EV1_nFinal");
325  EV1_vetoOn = true;
326  if (params.exists("EV1_vetoOn"))
327  EV1_vetoOn = params.getParameter<bool>("EV1_vetoOn");
328  EV1_maxVetoCount = 10;
329  if (params.exists("EV1_maxVetoCount"))
330  EV1_maxVetoCount = params.getParameter<int>("EV1_maxVetoCount");
331  EV1_pThardMode = 1;
332  if (params.exists("EV1_pThardMode"))
333  EV1_pThardMode = params.getParameter<int>("EV1_pThardMode");
334  EV1_pTempMode = 0;
335  if (params.exists("EV1_pTempMode"))
336  EV1_pTempMode = params.getParameter<int>("EV1_pTempMode");
337  if (EV1_pTempMode > 2 || EV1_pTempMode < 0)
338  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface") << " Wrong value for EV1_pTempMode code\n";
339  EV1_emittedMode = 0;
340  if (params.exists("EV1_emittedMode"))
341  EV1_emittedMode = params.getParameter<int>("EV1_emittedMode");
342  EV1_pTdefMode = 1;
343  if (params.exists("EV1_pTdefMode"))
344  EV1_pTdefMode = params.getParameter<int>("EV1_pTdefMode");
345  EV1_MPIvetoOn = false;
346  if (params.exists("EV1_MPIvetoOn"))
347  EV1_MPIvetoOn = params.getParameter<bool>("EV1_MPIvetoOn");
348  EV1_QEDvetoMode = 0;
349  if (params.exists("EV1_QEDvetoMode"))
350  EV1_QEDvetoMode = params.getParameter<int>("EV1_QEDvetoMode");
351  EV1_nFinalMode = 0;
352  if (params.exists("EV1_nFinalMode"))
353  EV1_nFinalMode = params.getParameter<int>("EV1_nFinalMode");
355  EV1_vetoOn,
364  0));
365  }
366 
367  if (params.exists("UserCustomization")) {
368  fCustomHooksVector = std::make_shared<UserHooksVector>();
369  const std::vector<edm::ParameterSet> userParams =
370  params.getParameter<std::vector<edm::ParameterSet>>("UserCustomization");
371  for (const auto &pluginParams : userParams) {
372  (fCustomHooksVector->hooks)
373  .push_back(
374  CustomHookFactory::get()->create(pluginParams.getParameter<std::string>("pluginName"), pluginParams));
375  }
376  }
377 
378  if (params.exists("VinciaPlugin")) {
379  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
380  << " Obsolete parameter: VinciaPlugin \n Please use the parameter PartonShowers:model instead \n";
381  }
382  if (params.exists("DirePlugin")) {
383  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
384  << " Obsolete parameter: DirePlugin \n Please use the parameter PartonShowers:model instead \n";
385  }
386 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double comEnergy
Center-of-Mass energy.
std::shared_ptr< EmissionVetoHook1 > fEmissionVetoHook1
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string LHEInputFileName
Py8InterfaceBase(edm::ParameterSet const &ps)
std::shared_ptr< UserHooks > fReweightRapUserHook
unsigned int ivhepmc
std::shared_ptr< UserHooksVector > fCustomHooksVector
Log< level::Error, true > LogImportant
std::shared_ptr< JetMatchingHook > fJetMatchingHook
Log< level::Info, false > LogInfo
std::shared_ptr< UserHooks > fReweightUserHook
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
std::shared_ptr< UserHooks > fReweightEmpUserHook
HepMC::Pythia8ToHepMC toHepMC
std::shared_ptr< UserHooks > fReweightPtHatRapUserHook
std::unique_ptr< Pythia8::Pythia > fMasterGen
#define get

◆ ~Pythia8Hadronizer()

Pythia8Hadronizer::~Pythia8Hadronizer ( )
override

Definition at line 388 of file Pythia8Hadronizer.cc.

388 {}

Member Function Documentation

◆ classname()

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 133 of file Pythia8Hadronizer.cc.

133 { return "Pythia8Hadronizer"; }

◆ doSetRandomEngine()

void Pythia8Hadronizer::doSetRandomEngine ( CLHEP::HepRandomEngine *  v)
inlineoverrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 138 of file Pythia8Hadronizer.cc.

References findQualityFiles::v.

138 { p8SetRandomEngine(v); }
void p8SetRandomEngine(CLHEP::HepRandomEngine *v)

◆ doSharedResources()

std::vector<std::string> const& Pythia8Hadronizer::doSharedResources ( ) const
inlineoverrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 139 of file Pythia8Hadronizer.cc.

139 { return p8SharedResources; }
static const std::vector< std::string > p8SharedResources

◆ finalizeEvent()

void Pythia8Hadronizer::finalizeEvent ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 1009 of file Pythia8Hadronizer.cc.

References gen::Py8InterfaceBase::ascii_io, gather_cfg::cout, DJR, relativeConstraints::empty, gen::BaseHadronizer::event(), gen::BaseHadronizer::eventInfo(), gen::Py8InterfaceBase::fMasterGen, gen::BaseHadronizer::lheEvent(), gen::Py8InterfaceBase::maxEventsToPrint, nME, nMEFiltered, push_back(), gen::Py8InterfaceBase::pythiaHepMCVerbosity, gen::Py8InterfaceBase::pythiaHepMCVerbosityParticles, gen::Py8InterfaceBase::pythiaPylistVerbosity, and hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights.

1009  {
1010  bool lhe = lheEvent() != nullptr;
1011 
1012  // protection against empty weight container
1013  if ((event()->weights()).empty())
1014  (event()->weights()).push_back(1.);
1015 
1016  // now create the GenEventInfo product from the GenEvent and fill
1017  // the missing pieces
1018  eventInfo() = std::make_unique<GenEventInfoProduct>(event().get());
1019 
1020  // in pythia pthat is used to subdivide samples into different bins
1021  // in LHE mode the binning is done by the external ME generator
1022  // which is likely not pthat, so only filling it for Py6 internal mode
1023  if (!lhe) {
1024  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
1025  }
1026 
1027  eventInfo()->setDJR(DJR);
1028  eventInfo()->setNMEPartons(nME);
1029  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
1030 
1031  //******** Verbosity ********
1032 
1034  maxEventsToPrint--;
1035  if (pythiaPylistVerbosity) {
1036  fMasterGen->info.list();
1037  fMasterGen->event.list();
1038  }
1039 
1040  if (pythiaHepMCVerbosity) {
1041  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
1042  << "----------------------" << std::endl;
1043  event()->print();
1044  }
1046  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
1047  << "----------------------" << std::endl;
1048  ascii_io->write_event(event().get());
1049  }
1050  }
1051 }
HepMC::IO_AsciiParticles * ascii_io
lhef::LHEEvent * lheEvent()
unsigned int pythiaPylistVerbosity
std::unique_ptr< HepMC::GenEvent > & event()
std::unique_ptr< GenEventInfoProduct > & eventInfo()
unsigned int maxEventsToPrint
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
vector< float > DJR
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ generatePartonsAndHadronize()

bool Pythia8Hadronizer::generatePartonsAndHadronize ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 769 of file Pythia8Hadronizer.cc.

References funct::abs(), DJR, gen::BaseHadronizer::event(), gen::Py8InterfaceBase::evtgenDecays, fEmissionVetoHook, fJetMatchingHook, fJetMatchingPy8InternalHook, gen::Py8InterfaceBase::fMasterGen, fMergingHook, mps_fire::i, crabWrapper::key, gen::BaseHadronizer::lheEvent(), SiStripPI::min, nFSRveto, nISRveto, nME, nMEFiltered, and gen::Py8InterfaceBase::toHepMC.

769  {
770  DJR.resize(0);
771  nME = -1;
772  nMEFiltered = -1;
773 
774  if (fJetMatchingHook.get()) {
775  fJetMatchingHook->resetMatchingStatus();
776  fJetMatchingHook->beforeHadronization(lheEvent());
777  }
778 
779  if (!fMasterGen->next())
780  return false;
781 
782  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
783  if (fMergingHook.get()) {
784  mergeweight *= fMergingHook->getNormFactor();
785  }
786 
787  //protect against 0-weight from ckkw or similar
788  if (std::abs(mergeweight) == 0.) {
789  event().reset();
790  return false;
791  }
792 
793  if (fJetMatchingPy8InternalHook.get()) {
794  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
795  //cap size of djr vector to save storage space (keep only up to first 6 elements)
796  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
797  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
798  DJR.push_back(djrmatch[idjr]);
799  }
800 
801  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
802  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
803  }
804 
805  if (evtgenDecays.get())
806  evtgenDecays->decay();
807 
808  event() = std::make_unique<HepMC::GenEvent>();
809  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
810 
811  if (!py8hepmc) {
812  return false;
813  }
814 
815  // 0th weight is not filled anymore since v8.30x, pushback manually
816  event()->weights().push_back(fMasterGen->info.weight());
817 
818  //add ckkw/umeps/unlops merging weight
819  if (mergeweight != 1.) {
820  event()->weights()[0] *= mergeweight;
821  }
822 
823  if (fEmissionVetoHook.get()) {
824  nISRveto += fEmissionVetoHook->getNISRveto();
825  nFSRveto += fEmissionVetoHook->getNFSRveto();
826  }
827 
828  //fill additional weights for systematic uncertainties
829  if (fMasterGen->info.getWeightsDetailedSize() > 0) {
830  for (const string &key : fMasterGen->info.initrwgt->weightsKeys) {
831  double wgt = (*fMasterGen->info.weights_detailed)[key];
832  event()->weights().push_back(wgt);
833  }
834  } else if (fMasterGen->info.getWeightsCompressedSize() > 0) {
835  for (unsigned int i = 0; i < fMasterGen->info.getWeightsCompressedSize(); i++) {
836  double wgt = fMasterGen->info.getWeightsCompressedValue(i);
837  event()->weights().push_back(wgt);
838  }
839  }
840 
841  // fill shower weights
842  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
843  if (fMasterGen->info.nWeights() > 1) {
844  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
845  double wgt = fMasterGen->info.weight(i);
846  event()->weights().push_back(wgt);
847  }
848  }
849 
850 #if 0
851  // VINCIA shower weights
852  // http://vincia.hepforge.org/current/share/Vincia/htmldoc/VinciaUncertainties.html
853  if (fvincia.get()) {
854  event()->weights()[0] *= fvincia->weight(0);
855  for (int iVar = 1; iVar < fvincia->nWeights(); iVar++) {
856  event()->weights().push_back(fvincia->weight(iVar));
857  }
858  }
859 
860  // Retrieve Dire shower weights
861  if (fDire.get()) {
862  fDire->weightsPtr->calcWeight(0.);
863  fDire->weightsPtr->reset();
864 
865  //Make sure the base weight comes first
866  event()->weights()[0] *= fDire->weightsPtr->getShowerWeight("base");
867 
868  unordered_map<string, double>::iterator it;
869  for (it = fDire->weightsPtr->getShowerWeights()->begin(); it != fDire->weightsPtr->getShowerWeights()->end();
870  it++) {
871  if (it->first == "base")
872  continue;
873  event()->weights().push_back(it->second);
874  }
875  }
876 #endif
877 
878  return true;
879 }
std::shared_ptr< PowhegHooks > fEmissionVetoHook
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
uint16_t size_type
lhef::LHEEvent * lheEvent()
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::shared_ptr< Pythia8::JetMatchingMadgraph > fJetMatchingPy8InternalHook
std::unique_ptr< HepMC::GenEvent > & event()
std::shared_ptr< JetMatchingHook > fJetMatchingHook
std::shared_ptr< Pythia8::amcnlo_unitarised_interface > fMergingHook
vector< float > DJR
HepMC::Pythia8ToHepMC toHepMC
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ getGenLumiInfoHeader()

std::unique_ptr< GenLumiInfoHeader > Pythia8Hadronizer::getGenLumiInfoHeader ( ) const
overridevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 1053 of file Pythia8Hadronizer.cc.

References gen::Py8InterfaceBase::fMasterGen, genWeightsTable_cfi::genLumiInfoHeader, mps_fire::i, crabWrapper::key, and AlCaHLTBitMon_QueryRunRegistry::string.

1053  {
1054  auto genLumiInfoHeader = BaseHadronizer::getGenLumiInfoHeader();
1055 
1056  //fill lhe headers
1057  //*FIXME* initrwgt header is corrupt due to pythia bug
1058  for (const std::string &key : fMasterGen->info.headerKeys()) {
1059  genLumiInfoHeader->lheHeaders().emplace_back(key, fMasterGen->info.header(key));
1060  }
1061 
1062  //check, if it is not only nominal weight
1063  int weights_number = fMasterGen->info.nWeights();
1064  if (fMasterGen->info.initrwgt)
1065  weights_number += fMasterGen->info.initrwgt->weightsKeys.size();
1066  if (weights_number > 1) {
1067  genLumiInfoHeader->weightNames().reserve(weights_number + 1);
1068  genLumiInfoHeader->weightNames().push_back("nominal");
1069  }
1070 
1071  //fill weight names
1072  if (fMasterGen->info.initrwgt) {
1073  for (const std::string &key : fMasterGen->info.initrwgt->weightsKeys) {
1074  std::string weightgroupname;
1075  for (const auto &wgtgrp : fMasterGen->info.initrwgt->weightgroups) {
1076  const auto &wgtgrpwgt = wgtgrp.second.weights.find(key);
1077  if (wgtgrpwgt != wgtgrp.second.weights.end()) {
1078  weightgroupname = wgtgrp.first;
1079  }
1080  }
1081 
1082  std::ostringstream weightname;
1083  weightname << "LHE, id = " << key << ", ";
1084  if (!weightgroupname.empty()) {
1085  weightname << "group = " << weightgroupname << ", ";
1086  }
1087  weightname << fMasterGen->info.initrwgt->weights[key].contents;
1088  genLumiInfoHeader->weightNames().push_back(weightname.str());
1089  }
1090  }
1091 
1092  //fill shower labels
1093  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
1094  // http://home.thep.lu.se/~torbjorn/doxygen/classPythia8_1_1Info.html
1095  if (fMasterGen->info.nWeights() > 1) {
1096  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
1097  genLumiInfoHeader->weightNames().push_back(fMasterGen->info.weightLabel(i));
1098  }
1099  }
1100 
1101 #if 0
1102  // VINCIA shower weights
1103  // http://vincia.hepforge.org/current/share/Vincia/htmldoc/VinciaUncertainties.html
1104  if (fvincia.get()) {
1105  for (int iVar = 0; iVar < fvincia->nWeights(); iVar++) {
1106  genLumiInfoHeader->weightNames().push_back(fvincia->weightLabel(iVar));
1107  }
1108  }
1109 
1110  if (fDire.get()) {
1111  //Make sure the base weight comes first
1112  genLumiInfoHeader->weightNames().push_back("base");
1113 
1114  unordered_map<string, double>::iterator it;
1115  for (it = fDire->weightsPtr->getShowerWeights()->begin(); it != fDire->weightsPtr->getShowerWeights()->end();
1116  it++) {
1117  if (it->first == "base")
1118  continue;
1119  genLumiInfoHeader->weightNames().push_back(it->first);
1120  }
1121  }
1122 #endif
1123 
1124  return genLumiInfoHeader;
1125 }
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ hadronize()

bool Pythia8Hadronizer::hadronize ( )

Definition at line 881 of file Pythia8Hadronizer.cc.

References funct::abs(), lhef::LHEEvent::count(), DJR, gen::BaseHadronizer::event(), gen::Py8InterfaceBase::evtgenDecays, fEmissionVetoHook, fJetMatchingHook, fJetMatchingPy8InternalHook, gen::Py8InterfaceBase::fMasterGen, fMergingHook, mps_fire::i, lhef::LHERunInfo::kAccepted, lhef::LHERunInfo::kSelected, lhaUP, gen::BaseHadronizer::lheEvent(), LHEInputFileName, SiStripPI::min, nFSRveto, nISRveto, nME, nMEFiltered, and gen::Py8InterfaceBase::toHepMC.

881  {
882  DJR.resize(0);
883  nME = -1;
884  nMEFiltered = -1;
885  if (LHEInputFileName.empty())
886  lhaUP->loadEvent(lheEvent());
887 
888  if (fJetMatchingHook.get()) {
889  fJetMatchingHook->resetMatchingStatus();
890  fJetMatchingHook->beforeHadronization(lheEvent());
891  }
892 
893  bool py8next = fMasterGen->next();
894 
895  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
896  if (fMergingHook.get()) {
897  mergeweight *= fMergingHook->getNormFactor();
898  }
899 
900  //protect against 0-weight from ckkw or similar
901  if (!py8next || std::abs(mergeweight) == 0.) {
902  lheEvent()->count(lhef::LHERunInfo::kSelected, 1.0, mergeweight);
903  event().reset();
904  return false;
905  }
906 
907  if (fJetMatchingPy8InternalHook.get()) {
908  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
909  //cap size of djr vector to save storage space (keep only up to first 6 elements)
910  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
911  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
912  DJR.push_back(djrmatch[idjr]);
913  }
914 
915  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
916  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
917  }
918 
919  // update LHE matching statistics
920  //
921  lheEvent()->count(lhef::LHERunInfo::kAccepted, 1.0, mergeweight);
922 
923  if (evtgenDecays.get())
924  evtgenDecays->decay();
925 
926  event() = std::make_unique<HepMC::GenEvent>();
927 
928  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
929 
930  if (!py8hepmc) {
931  return false;
932  }
933 
934  // 0th weight is not filled anymore since v8.30x, pushback manually
935  event()->weights().push_back(fMasterGen->info.weight());
936 
937  //add ckkw/umeps/unlops merging weight
938  if (mergeweight != 1.) {
939  event()->weights()[0] *= mergeweight;
940  }
941 
942  if (fEmissionVetoHook.get()) {
943  nISRveto += fEmissionVetoHook->getNISRveto();
944  nFSRveto += fEmissionVetoHook->getNFSRveto();
945  }
946 
947  // fill shower weights
948  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
949  if (fMasterGen->info.nWeights() > 1) {
950  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
951  double wgt = fMasterGen->info.weight(i);
952  event()->weights().push_back(wgt);
953  }
954  }
955 
956  return true;
957 }
std::shared_ptr< PowhegHooks > fEmissionVetoHook
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
std::string LHEInputFileName
void count(LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0)
Definition: LHEEvent.cc:184
uint16_t size_type
std::shared_ptr< LHAupLesHouches > lhaUP
lhef::LHEEvent * lheEvent()
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::shared_ptr< Pythia8::JetMatchingMadgraph > fJetMatchingPy8InternalHook
std::unique_ptr< HepMC::GenEvent > & event()
std::shared_ptr< JetMatchingHook > fJetMatchingHook
std::shared_ptr< Pythia8::amcnlo_unitarised_interface > fMergingHook
vector< float > DJR
HepMC::Pythia8ToHepMC toHepMC
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ initializeForExternalPartons()

bool Pythia8Hadronizer::initializeForExternalPartons ( )

Definition at line 575 of file Pythia8Hadronizer.cc.

References l1ct::clear(), edm::errors::Configuration, gen::Py8InterfaceBase::evtgenDecays, gen::Py8InterfaceBase::evtgenDecFile, gen::Py8InterfaceBase::evtgenPdlFile, gen::Py8InterfaceBase::evtgenUserFiles, Exception, fBiasedTauDecayer, fCustomHooksVector, gen::Py8InterfaceBase::fDecayer, fEmissionVetoHook, fEmissionVetoHook1, fJetMatchingHook, fJetMatchingPy8InternalHook, gen::Py8InterfaceBase::fMasterGen, fMergingHook, fPowhegHooksBB4L, fPowhegResHook, fPTFilterHook, fResonanceDecayFilterHook, fReweightEmpUserHook, fReweightPtHatRapUserHook, fReweightRapUserHook, fReweightUserHook, fTopRecoilHook, fUserHooksVector, mps_fire::i, lhaUP, LHEInputFileName, gen::BaseHadronizer::lheRunInfo(), push_back(), gen::Py8InterfaceBase::pythiaPylistVerbosity, MatrixUtil::remove(), generator_cfi::scheme, gen::Py8InterfaceBase::slhafile_, mps_update::status, gen::Py8InterfaceBase::useEvtGen, and UserHooksSet.

575  {
576  edm::LogInfo("Pythia8Interface") << "Initializing for external partons";
577 
578  bool status = false, status1 = false;
579 
580  if (!fUserHooksVector.get())
581  fUserHooksVector.reset(new UserHooksVector);
582  (fUserHooksVector->hooks).clear();
583 
584  if (fReweightUserHook.get())
585  (fUserHooksVector->hooks).push_back(fReweightUserHook);
586  if (fReweightEmpUserHook.get())
587  (fUserHooksVector->hooks).push_back(fReweightEmpUserHook);
588  if (fReweightRapUserHook.get())
589  (fUserHooksVector->hooks).push_back(fReweightRapUserHook);
590  if (fReweightPtHatRapUserHook.get())
591  (fUserHooksVector->hooks).push_back(fReweightPtHatRapUserHook);
592  if (fJetMatchingHook.get())
593  (fUserHooksVector->hooks).push_back(fJetMatchingHook);
594  if (fEmissionVetoHook1.get()) {
595  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook 1 from CMSSW Pythia8Interface";
597  }
598 
599  if (fCustomHooksVector.get()) {
600  edm::LogInfo("Pythia8Interface") << "Adding customized user hook";
601  for (const auto &fUserHook : fCustomHooksVector->hooks) {
602  (fUserHooksVector->hooks).push_back(fUserHook);
603  }
604  }
605 
606  if (fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) {
607  if (fJetMatchingHook.get() || fEmissionVetoHook1.get())
608  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
609  << " Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible "
610  "are : jetMatching, emissionVeto1 \n";
611 
612  if (!fEmissionVetoHook.get())
613  fEmissionVetoHook.reset(new PowhegHooks());
614 
615  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook from pythia8 code";
617  }
618 
619  bool PowhegRes = fMasterGen->settings.flag("POWHEGres:calcScales");
620  if (PowhegRes) {
621  edm::LogInfo("Pythia8Interface") << "Turning on resonance scale setting from CMSSW Pythia8Interface";
622  if (!fPowhegResHook.get())
623  fPowhegResHook.reset(new PowhegResHook());
625  }
626 
627  bool PowhegBB4L = fMasterGen->settings.flag("POWHEG:bb4l");
628  if (PowhegBB4L) {
629  edm::LogInfo("Pythia8Interface") << "Turning on BB4l hook from CMSSW Pythia8Interface";
630  if (!fPowhegHooksBB4L.get())
631  fPowhegHooksBB4L.reset(new PowhegHooksBB4L());
633  }
634 
635  bool TopRecoilHook1 = fMasterGen->settings.flag("TopRecoilHook:doTopRecoilIn");
636  if (TopRecoilHook1) {
637  edm::LogInfo("Pythia8Interface") << "Turning on RecoilToTop hook from Pythia8Interface";
638  if (!fTopRecoilHook.get())
639  fTopRecoilHook.reset(new TopRecoilHook());
641  }
642  //adapted from main89.cc in pythia8 examples
643  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
644  bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void");
645 
646  if (internalMatching && internalMerging) {
647  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
648  << " Only one jet matching/merging scheme can be used at a time. \n";
649  }
650 
651  if (internalMatching) {
652  if (!fJetMatchingPy8InternalHook.get())
653  fJetMatchingPy8InternalHook.reset(new Pythia8::JetMatchingMadgraph);
655  }
656 
657  if (internalMerging) {
658  int scheme = (fMasterGen->settings.flag("Merging:doUMEPSTree") || fMasterGen->settings.flag("Merging:doUMEPSSubt"))
659  ? 1
660  : ((fMasterGen->settings.flag("Merging:doUNLOPSTree") ||
661  fMasterGen->settings.flag("Merging:doUNLOPSSubt") ||
662  fMasterGen->settings.flag("Merging:doUNLOPSLoop") ||
663  fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO"))
664  ? 2
665  : 0);
666  if (!fMergingHook.get())
667  fMergingHook.reset(new Pythia8::amcnlo_unitarised_interface(scheme));
669  }
670 
671  bool biasedTauDecayer = fMasterGen->settings.flag("BiasedTauDecayer:filter");
672  if (biasedTauDecayer) {
673  if (!fBiasedTauDecayer.get()) {
674  Pythia8::Info localInfo = fMasterGen->info;
675  fBiasedTauDecayer.reset(new BiasedTauDecayer(&localInfo, &(fMasterGen->settings)));
676  }
677  std::vector<int> handledParticles;
678  handledParticles.push_back(15);
679  fMasterGen->setDecayPtr(fBiasedTauDecayer, handledParticles);
680  }
681 
682  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
683  if (resonanceDecayFilter) {
686  }
687 
688  bool PTFilter = fMasterGen->settings.flag("PTFilter:filter");
689  if (PTFilter) {
690  fPTFilterHook.reset(new PTFilterHook);
692  }
693 
694  if (!(fUserHooksVector->hooks).empty() && !UserHooksSet) {
695  for (auto &fUserHook : fUserHooksVector->hooks) {
696  fMasterGen->addUserHooksPtr(fUserHook);
697  }
698  UserHooksSet = true;
699  }
700 
701  if (!LHEInputFileName.empty()) {
702  edm::LogInfo("Pythia8Interface") << "Initialize direct pythia8 reading from LHE file " << LHEInputFileName;
703  edm::LogInfo("Pythia8Interface") << "Some LHE information can be not stored";
704  fMasterGen->settings.mode("Beams:frameType", 4);
705  fMasterGen->settings.word("Beams:LHEF", LHEInputFileName);
706  status = fMasterGen->init();
707 
708  } else {
709  lhaUP.reset(new LHAupLesHouches());
710  lhaUP->setScalesFromLHEF(fMasterGen->settings.flag("Beams:setProductionScalesFromLHEF"));
711  lhaUP->loadRunInfo(lheRunInfo());
712 
713  if (fJetMatchingHook.get()) {
714  fJetMatchingHook->init(lheRunInfo());
715  }
716 
717  fMasterGen->settings.mode("Beams:frameType", 5);
718  fMasterGen->setLHAupPtr(lhaUP);
719  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
720  status = fMasterGen->init();
721  }
722 
723  //clean up temp file
724  if (!slhafile_.empty()) {
725  std::remove(slhafile_.c_str());
726  }
727 
728  if (pythiaPylistVerbosity > 10) {
729  if (pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13)
730  fMasterGen->settings.listAll();
731  if (pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13)
732  fMasterGen->particleData.listAll();
733  }
734 
735  // init decayer
736  fDecayer->settings.flag("ProcessLevel:all", false); // trick
737  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true);
738  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
739  status1 = fDecayer->init();
740 
741  if (useEvtGen) {
742  edm::LogInfo("Pythia8Hadronizer") << "Creating and initializing pythia8 EvtGen plugin";
743  if (!evtgenDecays.get()) {
744  evtgenDecays.reset(new EvtGenDecays(fMasterGen.get(), evtgenDecFile, evtgenPdlFile));
745  for (unsigned int i = 0; i < evtgenUserFiles.size(); i++)
746  evtgenDecays->readDecayFile(evtgenUserFiles.at(i));
747  }
748  }
749 
750  return (status && status1);
751 }
std::shared_ptr< PowhegHooksBB4L > fPowhegHooksBB4L
std::shared_ptr< PowhegHooks > fEmissionVetoHook
std::shared_ptr< EmissionVetoHook1 > fEmissionVetoHook1
std::shared_ptr< BiasedTauDecayer > fBiasedTauDecayer
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
std::unique_ptr< Pythia8::Pythia > fDecayer
std::shared_ptr< TopRecoilHook > fTopRecoilHook
std::string LHEInputFileName
std::shared_ptr< UserHooks > fReweightRapUserHook
std::shared_ptr< LHAupLesHouches > lhaUP
std::vector< std::string > evtgenUserFiles
std::shared_ptr< UserHooksVector > fCustomHooksVector
std::shared_ptr< ResonanceDecayFilterHook > fResonanceDecayFilterHook
std::shared_ptr< UserHooksVector > fUserHooksVector
unsigned int pythiaPylistVerbosity
std::shared_ptr< PTFilterHook > fPTFilterHook
std::shared_ptr< Pythia8::JetMatchingMadgraph > fJetMatchingPy8InternalHook
lhef::LHERunInfo * lheRunInfo()
std::shared_ptr< JetMatchingHook > fJetMatchingHook
Log< level::Info, false > LogInfo
std::shared_ptr< UserHooks > fReweightUserHook
std::shared_ptr< Pythia8::amcnlo_unitarised_interface > fMergingHook
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:223
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
std::shared_ptr< UserHooks > fReweightEmpUserHook
std::shared_ptr< PowhegResHook > fPowhegResHook
std::shared_ptr< UserHooks > fReweightPtHatRapUserHook
std::unique_ptr< Pythia8::Pythia > fMasterGen
void clear(EGIsoObj &c)
Definition: egamma.h:82

◆ initializeForInternalPartons()

bool Pythia8Hadronizer::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 390 of file Pythia8Hadronizer.cc.

References l1ct::clear(), comEnergy, edm::errors::Configuration, doProtonPhotonFlux, ElectronPositron, gen::Py8InterfaceBase::evtgenDecays, gen::Py8InterfaceBase::evtgenDecFile, gen::Py8InterfaceBase::evtgenPdlFile, gen::Py8InterfaceBase::evtgenUserFiles, Exception, fBiasedTauDecayer, fCustomHooksVector, gen::Py8InterfaceBase::fDecayer, fEmissionVetoHook, fEmissionVetoHook1, fInitialState, fJetMatchingHook, fJetMatchingPy8InternalHook, gen::Py8InterfaceBase::fMasterGen, fMergingHook, fPowhegHooksBB4L, fPowhegResHook, fPTFilterHook, fResonanceDecayFilterHook, fReweightEmpUserHook, fReweightPtHatRapUserHook, fReweightRapUserHook, fReweightUserHook, fTopRecoilHook, fUserHooksVector, mps_fire::i, gen::BaseHadronizer::lheFile_, photonFlux, PP, PPbar, push_back(), gen::Py8InterfaceBase::pythiaPylistVerbosity, MatrixUtil::remove(), generator_cfi::scheme, gen::Py8InterfaceBase::slhafile_, mps_update::status, gen::Py8InterfaceBase::useEvtGen, and UserHooksSet.

390  {
391  bool status = false, status1 = false;
392 
393  if (lheFile_.empty()) {
394  if (fInitialState == PP) // default
395  {
396  fMasterGen->settings.mode("Beams:idA", 2212);
397  fMasterGen->settings.mode("Beams:idB", 2212);
398  } else if (fInitialState == PPbar) {
399  fMasterGen->settings.mode("Beams:idA", 2212);
400  fMasterGen->settings.mode("Beams:idB", -2212);
401  } else if (fInitialState == ElectronPositron) {
402  fMasterGen->settings.mode("Beams:idA", 11);
403  fMasterGen->settings.mode("Beams:idB", -11);
404  } else {
405  // throw on unknown initial state !
406  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
407  << " UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
408  }
409  fMasterGen->settings.parm("Beams:eCM", comEnergy);
410  } else {
411  fMasterGen->settings.mode("Beams:frameType", 4);
412  fMasterGen->settings.word("Beams:LHEF", lheFile_);
413  }
414 
415  if (doProtonPhotonFlux) {
416  photonFlux = make_shared<Nucleus2gamma2>(1000822080);
417  fMasterGen->setPhotonFluxPtr(photonFlux, nullptr);
418  }
419 
420  if (!fUserHooksVector.get())
421  fUserHooksVector.reset(new UserHooksVector);
422  (fUserHooksVector->hooks).clear();
423 
424  if (fReweightUserHook.get())
425  (fUserHooksVector->hooks).push_back(fReweightUserHook);
426  if (fReweightEmpUserHook.get())
427  (fUserHooksVector->hooks).push_back(fReweightEmpUserHook);
428  if (fReweightRapUserHook.get())
429  (fUserHooksVector->hooks).push_back(fReweightRapUserHook);
430  if (fReweightPtHatRapUserHook.get())
431  (fUserHooksVector->hooks).push_back(fReweightPtHatRapUserHook);
432  if (fJetMatchingHook.get())
433  (fUserHooksVector->hooks).push_back(fJetMatchingHook);
434  if (fEmissionVetoHook1.get()) {
435  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook 1 from CMSSW Pythia8Interface";
437  }
438 
439  if (fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) {
440  if (fJetMatchingHook.get() || fEmissionVetoHook1.get())
441  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
442  << " Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible "
443  "are : jetMatching, emissionVeto1 \n";
444 
445  if (!fEmissionVetoHook.get())
446  fEmissionVetoHook.reset(new PowhegHooks());
447 
448  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook from pythia8 code";
450  }
451 
452  bool PowhegRes = fMasterGen->settings.flag("POWHEGres:calcScales");
453  if (PowhegRes) {
454  edm::LogInfo("Pythia8Interface") << "Turning on resonance scale setting from CMSSW Pythia8Interface";
455  if (!fPowhegResHook.get())
456  fPowhegResHook.reset(new PowhegResHook());
458  }
459 
460  bool PowhegBB4L = fMasterGen->settings.flag("POWHEG:bb4l");
461  if (PowhegBB4L) {
462  edm::LogInfo("Pythia8Interface") << "Turning on BB4l hook from CMSSW Pythia8Interface";
463  if (!fPowhegHooksBB4L.get())
464  fPowhegHooksBB4L.reset(new PowhegHooksBB4L());
466  }
467 
468  bool TopRecoilHook1 = fMasterGen->settings.flag("TopRecoilHook:doTopRecoilIn");
469  if (TopRecoilHook1) {
470  edm::LogInfo("Pythia8Interface") << "Turning on RecoilToTop hook from Pythia8Interface";
471  if (!fTopRecoilHook.get())
472  fTopRecoilHook.reset(new TopRecoilHook());
474  }
475 
476  //adapted from main89.cc in pythia8 examples
477  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
478  bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void");
479 
480  if (internalMatching && internalMerging) {
481  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
482  << " Only one jet matching/merging scheme can be used at a time. \n";
483  }
484 
485  if (internalMatching) {
486  if (!fJetMatchingPy8InternalHook.get())
487  fJetMatchingPy8InternalHook.reset(new Pythia8::JetMatchingMadgraph);
489  }
490 
491  if (internalMerging) {
492  int scheme = (fMasterGen->settings.flag("Merging:doUMEPSTree") || fMasterGen->settings.flag("Merging:doUMEPSSubt"))
493  ? 1
494  : ((fMasterGen->settings.flag("Merging:doUNLOPSTree") ||
495  fMasterGen->settings.flag("Merging:doUNLOPSSubt") ||
496  fMasterGen->settings.flag("Merging:doUNLOPSLoop") ||
497  fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO"))
498  ? 2
499  : 0);
500  if (!fMergingHook.get())
501  fMergingHook.reset(new Pythia8::amcnlo_unitarised_interface(scheme));
503  }
504 
505  bool biasedTauDecayer = fMasterGen->settings.flag("BiasedTauDecayer:filter");
506  if (biasedTauDecayer) {
507  if (!fBiasedTauDecayer.get()) {
508  Pythia8::Info localInfo = fMasterGen->info;
509  fBiasedTauDecayer.reset(new BiasedTauDecayer(&localInfo, &(fMasterGen->settings)));
510  }
511  std::vector<int> handledParticles;
512  handledParticles.push_back(15);
513  fMasterGen->setDecayPtr(fBiasedTauDecayer, handledParticles);
514  }
515 
516  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
517  if (resonanceDecayFilter) {
520  }
521 
522  bool PTFilter = fMasterGen->settings.flag("PTFilter:filter");
523  if (PTFilter) {
524  fPTFilterHook.reset(new PTFilterHook);
526  }
527 
528  if (!(fUserHooksVector->hooks).empty() && !UserHooksSet) {
529  for (auto &fUserHook : fUserHooksVector->hooks) {
530  fMasterGen->addUserHooksPtr(fUserHook);
531  }
532  UserHooksSet = true;
533  }
534 
535  if (fCustomHooksVector.get()) {
536  edm::LogInfo("Pythia8Interface") << "Adding customized user hooks";
537  for (const auto &fUserHook : fCustomHooksVector->hooks) {
538  fMasterGen->addUserHooksPtr(fUserHook);
539  }
540  }
541 
542  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
543  status = fMasterGen->init();
544 
545  //clean up temp file
546  if (!slhafile_.empty()) {
547  std::remove(slhafile_.c_str());
548  }
549 
550  if (pythiaPylistVerbosity > 10) {
551  if (pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13)
552  fMasterGen->settings.listAll();
553  if (pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13)
554  fMasterGen->particleData.listAll();
555  }
556 
557  // init decayer
558  fDecayer->settings.flag("ProcessLevel:all", false); // trick
559  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true);
560  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
561  status1 = fDecayer->init();
562 
563  if (useEvtGen) {
564  edm::LogInfo("Pythia8Hadronizer") << "Creating and initializing pythia8 EvtGen plugin";
565  if (!evtgenDecays.get()) {
566  evtgenDecays.reset(new EvtGenDecays(fMasterGen.get(), evtgenDecFile, evtgenPdlFile));
567  for (unsigned int i = 0; i < evtgenUserFiles.size(); i++)
568  evtgenDecays->readDecayFile(evtgenUserFiles.at(i));
569  }
570  }
571 
572  return (status && status1);
573 }
std::shared_ptr< PowhegHooksBB4L > fPowhegHooksBB4L
double comEnergy
Center-of-Mass energy.
std::shared_ptr< PowhegHooks > fEmissionVetoHook
std::shared_ptr< EmissionVetoHook1 > fEmissionVetoHook1
std::shared_ptr< BiasedTauDecayer > fBiasedTauDecayer
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
std::unique_ptr< Pythia8::Pythia > fDecayer
std::shared_ptr< TopRecoilHook > fTopRecoilHook
std::shared_ptr< UserHooks > fReweightRapUserHook
Pythia8::PDFPtr photonFlux
std::vector< std::string > evtgenUserFiles
std::shared_ptr< UserHooksVector > fCustomHooksVector
std::shared_ptr< ResonanceDecayFilterHook > fResonanceDecayFilterHook
std::shared_ptr< UserHooksVector > fUserHooksVector
unsigned int pythiaPylistVerbosity
std::shared_ptr< PTFilterHook > fPTFilterHook
std::shared_ptr< Pythia8::JetMatchingMadgraph > fJetMatchingPy8InternalHook
std::shared_ptr< JetMatchingHook > fJetMatchingHook
Log< level::Info, false > LogInfo
std::shared_ptr< UserHooks > fReweightUserHook
std::shared_ptr< Pythia8::amcnlo_unitarised_interface > fMergingHook
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:223
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
std::shared_ptr< UserHooks > fReweightEmpUserHook
std::shared_ptr< PowhegResHook > fPowhegResHook
std::shared_ptr< UserHooks > fReweightPtHatRapUserHook
std::unique_ptr< Pythia8::Pythia > fMasterGen
void clear(EGIsoObj &c)
Definition: egamma.h:82

◆ residualDecay()

bool Pythia8Hadronizer::residualDecay ( )
virtual

Definition at line 959 of file Pythia8Hadronizer.cc.

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

959  {
960  Event *pythiaEvent = &(fMasterGen->event);
961 
962  int NPartsBeforeDecays = pythiaEvent->size();
963  int NPartsAfterDecays = event().get()->particles_size();
964 
965  if (NPartsAfterDecays == NPartsBeforeDecays)
966  return true;
967 
968  bool result = true;
969 
970  for (int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
971  HepMC::GenParticle *part = event().get()->barcode_to_particle(ipart);
972 
973  if (part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id())) {
974  fDecayer->event.reset();
975  Particle py8part(part->pdg_id(),
976  93,
977  0,
978  0,
979  0,
980  0,
981  0,
982  0,
983  part->momentum().x(),
984  part->momentum().y(),
985  part->momentum().z(),
986  part->momentum().t(),
987  part->generated_mass());
988  HepMC::GenVertex *ProdVtx = part->production_vertex();
989  py8part.vProd(ProdVtx->position().x(), ProdVtx->position().y(), ProdVtx->position().z(), ProdVtx->position().t());
990  py8part.tau((fDecayer->particleData).tau0(part->pdg_id()));
991  fDecayer->event.append(py8part);
992  int nentries = fDecayer->event.size();
993  if (!fDecayer->event[nentries - 1].mayDecay())
994  continue;
995  fDecayer->next();
996  int nentries1 = fDecayer->event.size();
997  if (nentries1 <= nentries)
998  continue; //same number of particles, no decays...
999 
1000  part->set_status(2);
1001 
1002  result = toHepMC.fill_next_event(*(fDecayer.get()), event().get(), -1, true, part);
1003  }
1004  }
1005 
1006  return result;
1007 }
std::unique_ptr< Pythia8::Pythia > fDecayer
std::unique_ptr< HepMC::GenEvent > & event()
part
Definition: HCALResponse.h:20
HepMC::Pythia8ToHepMC toHepMC
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ statistics()

void Pythia8Hadronizer::statistics ( )
overridevirtual

Reimplemented from gen::Py8InterfaceBase.

Definition at line 753 of file Pythia8Hadronizer.cc.

References submitPVResolutionJobs::err, fEmissionVetoHook, gen::Py8InterfaceBase::fMasterGen, nFSRveto, nISRveto, gen::BaseHadronizer::runInfo(), and GenRunInfoProduct::setInternalXSec().

753  {
754  fMasterGen->stat();
755 
756  if (fEmissionVetoHook.get()) {
757  edm::LogPrint("Pythia8Interface") << "\n"
758  << "Number of ISR vetoed = " << nISRveto;
759  edm::LogPrint("Pythia8Interface") << "Number of FSR vetoed = " << nFSRveto;
760  }
761 
762  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
763  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
764  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
765  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
767 }
std::shared_ptr< PowhegHooks > fEmissionVetoHook
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
Log< level::Warning, true > LogPrint
std::unique_ptr< Pythia8::Pythia > fMasterGen

Member Data Documentation

◆ comEnergy

double Pythia8Hadronizer::comEnergy
private

Center-of-Mass energy.

Definition at line 142 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ DJR

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 212 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), generatePartonsAndHadronize(), and hadronize().

◆ doProtonPhotonFlux

bool Pythia8Hadronizer::doProtonPhotonFlux = false
private

Definition at line 155 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ EV1_emittedMode

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 204 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_maxVetoCount

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 201 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_MPIvetoOn

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 206 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinal

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 199 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinalMode

int Pythia8Hadronizer::EV1_nFinalMode
private

Definition at line 208 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTdefMode

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 205 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTempMode

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 203 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pThardMode

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 202 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_QEDvetoMode

int Pythia8Hadronizer::EV1_QEDvetoMode
private

Definition at line 207 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_vetoOn

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 200 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ fBeam1PZ

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 150 of file Pythia8Hadronizer.cc.

◆ fBeam2PZ

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 151 of file Pythia8Hadronizer.cc.

◆ fBiasedTauDecayer

std::shared_ptr<BiasedTauDecayer> Pythia8Hadronizer::fBiasedTauDecayer
private

◆ fCustomHooksVector

std::shared_ptr<UserHooksVector> Pythia8Hadronizer::fCustomHooksVector
private

◆ fEmissionVetoHook

std::shared_ptr<PowhegHooks> Pythia8Hadronizer::fEmissionVetoHook
private

◆ fEmissionVetoHook1

std::shared_ptr<EmissionVetoHook1> Pythia8Hadronizer::fEmissionVetoHook1
private

◆ fInitialState

int Pythia8Hadronizer::fInitialState
private

Definition at line 148 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons(), and Pythia8Hadronizer().

◆ fJetMatchingHook

std::shared_ptr<JetMatchingHook> Pythia8Hadronizer::fJetMatchingHook
private

◆ fJetMatchingPy8InternalHook

std::shared_ptr<Pythia8::JetMatchingMadgraph> Pythia8Hadronizer::fJetMatchingPy8InternalHook
private

◆ fMergingHook

std::shared_ptr<Pythia8::amcnlo_unitarised_interface> Pythia8Hadronizer::fMergingHook
private

◆ fPowhegHooksBB4L

std::shared_ptr<PowhegHooksBB4L> Pythia8Hadronizer::fPowhegHooksBB4L
private

◆ fPowhegResHook

std::shared_ptr<PowhegResHook> Pythia8Hadronizer::fPowhegResHook
private

◆ fPTFilterHook

std::shared_ptr<PTFilterHook> Pythia8Hadronizer::fPTFilterHook
private

◆ fResonanceDecayFilterHook

std::shared_ptr<ResonanceDecayFilterHook> Pythia8Hadronizer::fResonanceDecayFilterHook
private

◆ fReweightEmpUserHook

std::shared_ptr<UserHooks> Pythia8Hadronizer::fReweightEmpUserHook
private

◆ fReweightPtHatRapUserHook

std::shared_ptr<UserHooks> Pythia8Hadronizer::fReweightPtHatRapUserHook
private

◆ fReweightRapUserHook

std::shared_ptr<UserHooks> Pythia8Hadronizer::fReweightRapUserHook
private

◆ fReweightUserHook

std::shared_ptr<UserHooks> Pythia8Hadronizer::fReweightUserHook
private

◆ fTopRecoilHook

std::shared_ptr<TopRecoilHook> Pythia8Hadronizer::fTopRecoilHook
private

◆ fUserHooksVector

std::shared_ptr<UserHooksVector> Pythia8Hadronizer::fUserHooksVector
private

◆ lhaUP

std::shared_ptr<LHAupLesHouches> Pythia8Hadronizer::lhaUP
private

Definition at line 145 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ LHEInputFileName

std::string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 144 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ nFSRveto

int Pythia8Hadronizer::nFSRveto
private

Definition at line 217 of file Pythia8Hadronizer.cc.

Referenced by generatePartonsAndHadronize(), hadronize(), and statistics().

◆ nISRveto

int Pythia8Hadronizer::nISRveto
private

Definition at line 216 of file Pythia8Hadronizer.cc.

Referenced by generatePartonsAndHadronize(), hadronize(), and statistics().

◆ nME

int Pythia8Hadronizer::nME
private

Definition at line 213 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), generatePartonsAndHadronize(), and hadronize().

◆ nMEFiltered

int Pythia8Hadronizer::nMEFiltered
private

Definition at line 214 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), generatePartonsAndHadronize(), and hadronize().

◆ p8SharedResources

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

Definition at line 210 of file Pythia8Hadronizer.cc.

◆ photonFlux

Pythia8::PDFPtr Pythia8Hadronizer::photonFlux = nullptr
private

Definition at line 156 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ UserHooksSet

bool Pythia8Hadronizer::UserHooksSet
private