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:307
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 1010 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.

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

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

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

References gen::Py8InterfaceBase::fMasterGen, genWeightsTable_cfi::genLumiInfoHeader, mps_fire::i, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, submitPVResolutionJobs::key, and AlCaHLTBitMon_QueryRunRegistry::string.

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

◆ hadronize()

bool Pythia8Hadronizer::hadronize ( )

Definition at line 882 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.

882  {
883  DJR.resize(0);
884  nME = -1;
885  nMEFiltered = -1;
886  if (LHEInputFileName.empty())
887  lhaUP->loadEvent(lheEvent());
888 
889  if (fJetMatchingHook.get()) {
890  fJetMatchingHook->resetMatchingStatus();
891  fJetMatchingHook->beforeHadronization(lheEvent());
892  }
893 
894  bool py8next = fMasterGen->next();
895 
896  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
897  if (fMergingHook.get()) {
898  mergeweight *= fMergingHook->getNormFactor();
899  }
900 
901  //protect against 0-weight from ckkw or similar
902  if (!py8next || std::abs(mergeweight) == 0.) {
903  lheEvent()->count(lhef::LHERunInfo::kSelected, 1.0, mergeweight);
904  event().reset();
905  return false;
906  }
907 
908  if (fJetMatchingPy8InternalHook.get()) {
909  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
910  //cap size of djr vector to save storage space (keep only up to first 6 elements)
911  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
912  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
913  DJR.push_back(djrmatch[idjr]);
914  }
915 
916  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
917  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
918  }
919 
920  // update LHE matching statistics
921  //
922  lheEvent()->count(lhef::LHERunInfo::kAccepted, 1.0, mergeweight);
923 
924  if (evtgenDecays.get())
925  evtgenDecays->decay();
926 
927  event() = std::make_unique<HepMC::GenEvent>();
928 
929  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
930 
931  if (!py8hepmc) {
932  return false;
933  }
934 
935  // 0th weight is not filled anymore since v8.30x, pushback manually
936  event()->weights().push_back(fMasterGen->info.weight());
937 
938  //add ckkw/umeps/unlops merging weight
939  if (mergeweight != 1.) {
940  event()->weights()[0] *= mergeweight;
941  }
942 
943  if (fEmissionVetoHook.get()) {
944  nISRveto += fEmissionVetoHook->getNISRveto();
945  nFSRveto += fEmissionVetoHook->getNFSRveto();
946  }
947 
948  // fill shower weights
949  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
950  if (fMasterGen->info.nWeights() > 1) {
951  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
952  double wgt = fMasterGen->info.weight(i);
953  event()->weights().push_back(wgt);
954  }
955  }
956 
957  return true;
958 }
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:187
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 
643  //adapted from main89.cc in pythia8 examples
644  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
645  bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void");
646 
647  if (internalMatching && internalMerging) {
648  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
649  << " Only one jet matching/merging scheme can be used at a time. \n";
650  }
651 
652  if (internalMatching) {
653  if (!fJetMatchingPy8InternalHook.get())
654  fJetMatchingPy8InternalHook.reset(new Pythia8::JetMatchingMadgraph);
656  }
657 
658  if (internalMerging) {
659  int scheme = (fMasterGen->settings.flag("Merging:doUMEPSTree") || fMasterGen->settings.flag("Merging:doUMEPSSubt"))
660  ? 1
661  : ((fMasterGen->settings.flag("Merging:doUNLOPSTree") ||
662  fMasterGen->settings.flag("Merging:doUNLOPSSubt") ||
663  fMasterGen->settings.flag("Merging:doUNLOPSLoop") ||
664  fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO"))
665  ? 2
666  : 0);
667  if (!fMergingHook.get())
668  fMergingHook.reset(new Pythia8::amcnlo_unitarised_interface(scheme));
670  }
671 
672  bool biasedTauDecayer = fMasterGen->settings.flag("BiasedTauDecayer:filter");
673  if (biasedTauDecayer) {
674  if (!fBiasedTauDecayer.get()) {
675  Pythia8::Info localInfo = fMasterGen->info;
676  fBiasedTauDecayer.reset(new BiasedTauDecayer(&localInfo, &(fMasterGen->settings)));
677  }
678  std::vector<int> handledParticles;
679  handledParticles.push_back(15);
680  fMasterGen->setDecayPtr(fBiasedTauDecayer, handledParticles);
681  }
682 
683  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
684  if (resonanceDecayFilter) {
687  }
688 
689  bool PTFilter = fMasterGen->settings.flag("PTFilter:filter");
690  if (PTFilter) {
691  fPTFilterHook.reset(new PTFilterHook);
693  }
694 
695  if (!(fUserHooksVector->hooks).empty() && !UserHooksSet) {
696  for (auto &fUserHook : fUserHooksVector->hooks) {
697  fMasterGen->addUserHooksPtr(fUserHook);
698  }
699  UserHooksSet = true;
700  }
701 
702  if (!LHEInputFileName.empty()) {
703  edm::LogInfo("Pythia8Interface") << "Initialize direct pythia8 reading from LHE file " << LHEInputFileName;
704  edm::LogInfo("Pythia8Interface") << "Some LHE information can be not stored";
705  fMasterGen->settings.mode("Beams:frameType", 4);
706  fMasterGen->settings.word("Beams:LHEF", LHEInputFileName);
707  status = fMasterGen->init();
708 
709  } else {
710  lhaUP.reset(new LHAupLesHouches());
711  lhaUP->setScalesFromLHEF(fMasterGen->settings.flag("Beams:setProductionScalesFromLHEF"));
712  lhaUP->loadRunInfo(lheRunInfo());
713 
714  if (fJetMatchingHook.get()) {
715  fJetMatchingHook->init(lheRunInfo());
716  }
717 
718  fMasterGen->settings.mode("Beams:frameType", 5);
719  fMasterGen->setLHAupPtr(lhaUP);
720  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
721  status = fMasterGen->init();
722  }
723 
724  //clean up temp file
725  if (!slhafile_.empty()) {
726  std::remove(slhafile_.c_str());
727  }
728 
729  if (pythiaPylistVerbosity > 10) {
730  if (pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13)
731  fMasterGen->settings.listAll();
732  if (pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13)
733  fMasterGen->particleData.listAll();
734  }
735 
736  // init decayer
737  fDecayer->settings.flag("ProcessLevel:all", false); // trick
738  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true);
739  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
740  status1 = fDecayer->init();
741 
742  if (useEvtGen) {
743  edm::LogInfo("Pythia8Hadronizer") << "Creating and initializing pythia8 EvtGen plugin";
744  if (!evtgenDecays.get()) {
745  evtgenDecays.reset(new EvtGenDecays(fMasterGen.get(), evtgenDecFile, evtgenPdlFile));
746  for (unsigned int i = 0; i < evtgenUserFiles.size(); i++)
747  evtgenDecays->readDecayFile(evtgenUserFiles.at(i));
748  }
749  }
750 
751  return (status && status1);
752 }
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 960 of file Pythia8Hadronizer.cc.

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

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

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

754  {
755  fMasterGen->stat();
756 
757  if (fEmissionVetoHook.get()) {
758  edm::LogPrint("Pythia8Interface") << "\n"
759  << "Number of ISR vetoed = " << nISRveto;
760  edm::LogPrint("Pythia8Interface") << "Number of FSR vetoed = " << nFSRveto;
761  }
762 
763  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
764  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
765  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
766  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
768 }
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