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
 
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
 
edm::ParameterSet photonFluxParams
 
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 122 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 227 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, photonFluxParams, PP, PPbar, push_back(), generator_cfi::scheme, AlCaHLTBitMon_QueryRunRegistry::string, and gen::Py8InterfaceBase::toHepMC.

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

396 {}

Member Function Documentation

◆ classname()

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 139 of file Pythia8Hadronizer.cc.

139 { return "Pythia8Hadronizer"; }

◆ doSetRandomEngine()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 144 of file Pythia8Hadronizer.cc.

References findQualityFiles::v.

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

◆ doSharedResources()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 145 of file Pythia8Hadronizer.cc.

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

◆ finalizeEvent()

void Pythia8Hadronizer::finalizeEvent ( )
overridevirtual

Implements gen::Py8InterfaceBase.

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

1027  {
1028  bool lhe = lheEvent() != nullptr;
1029 
1030  // protection against empty weight container
1031  if ((event()->weights()).empty())
1032  (event()->weights()).push_back(1.);
1033 
1034  // now create the GenEventInfo product from the GenEvent and fill
1035  // the missing pieces
1036  eventInfo() = std::make_unique<GenEventInfoProduct>(event().get());
1037 
1038  // in pythia pthat is used to subdivide samples into different bins
1039  // in LHE mode the binning is done by the external ME generator
1040  // which is likely not pthat, so only filling it for Py6 internal mode
1041  if (!lhe) {
1042  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
1043  }
1044 
1045  eventInfo()->setDJR(DJR);
1046  eventInfo()->setNMEPartons(nME);
1047  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
1048 
1049  //******** Verbosity ********
1050 
1052  maxEventsToPrint--;
1053  if (pythiaPylistVerbosity) {
1054  fMasterGen->info.list();
1055  fMasterGen->event.list();
1056  }
1057 
1058  if (pythiaHepMCVerbosity) {
1059  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
1060  << "----------------------" << std::endl;
1061  event()->print();
1062  }
1064  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
1065  << "----------------------" << std::endl;
1066  ascii_io->write_event(event().get());
1067  }
1068  }
1069 }
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 787 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.

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

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

◆ hadronize()

bool Pythia8Hadronizer::hadronize ( )

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

899  {
900  DJR.resize(0);
901  nME = -1;
902  nMEFiltered = -1;
903  if (LHEInputFileName.empty())
904  lhaUP->loadEvent(lheEvent());
905 
906  if (fJetMatchingHook.get()) {
907  fJetMatchingHook->resetMatchingStatus();
908  fJetMatchingHook->beforeHadronization(lheEvent());
909  }
910 
911  bool py8next = fMasterGen->next();
912 
913  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
914  if (fMergingHook.get()) {
915  mergeweight *= fMergingHook->getNormFactor();
916  }
917 
918  //protect against 0-weight from ckkw or similar
919  if (!py8next || std::abs(mergeweight) == 0.) {
920  lheEvent()->count(lhef::LHERunInfo::kSelected, 1.0, mergeweight);
921  event().reset();
922  return false;
923  }
924 
925  if (fJetMatchingPy8InternalHook.get()) {
926  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
927  //cap size of djr vector to save storage space (keep only up to first 6 elements)
928  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
929  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
930  DJR.push_back(djrmatch[idjr]);
931  }
932 
933  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
934  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
935  }
936 
937  // update LHE matching statistics
938  //
939  lheEvent()->count(lhef::LHERunInfo::kAccepted, 1.0, mergeweight);
940 
941  if (evtgenDecays.get())
942  evtgenDecays->decay();
943 
944  event() = std::make_unique<HepMC::GenEvent>();
945 
946  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
947 
948  if (!py8hepmc) {
949  return false;
950  }
951 
952  // 0th weight is not filled anymore since v8.30x, pushback manually
953  event()->weights().push_back(fMasterGen->info.weight());
954 
955  //add ckkw/umeps/unlops merging weight
956  if (mergeweight != 1.) {
957  event()->weights()[0] *= mergeweight;
958  }
959 
960  if (fEmissionVetoHook.get()) {
961  nISRveto += fEmissionVetoHook->getNISRveto();
962  nFSRveto += fEmissionVetoHook->getNFSRveto();
963  }
964 
965  // fill shower weights
966  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
967  if (fMasterGen->info.nWeights() > 1) {
968  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
969  double wgt = fMasterGen->info.weight(i);
970  event()->weights().push_back(wgt);
971  }
972  }
973 
974  return true;
975 }
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 592 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.

592  {
593  edm::LogInfo("Pythia8Interface") << "Initializing for external partons";
594 
595  bool status = false, status1 = false;
596 
597  if (!fUserHooksVector.get())
598  fUserHooksVector.reset(new UserHooksVector);
599  (fUserHooksVector->hooks).clear();
600 
601  if (fReweightUserHook.get())
602  (fUserHooksVector->hooks).push_back(fReweightUserHook);
603  if (fReweightEmpUserHook.get())
604  (fUserHooksVector->hooks).push_back(fReweightEmpUserHook);
605  if (fReweightRapUserHook.get())
606  (fUserHooksVector->hooks).push_back(fReweightRapUserHook);
607  if (fReweightPtHatRapUserHook.get())
608  (fUserHooksVector->hooks).push_back(fReweightPtHatRapUserHook);
609  if (fJetMatchingHook.get())
610  (fUserHooksVector->hooks).push_back(fJetMatchingHook);
611  if (fEmissionVetoHook1.get()) {
612  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook 1 from CMSSW Pythia8Interface";
614  }
615 
616  if (fCustomHooksVector.get()) {
617  edm::LogInfo("Pythia8Interface") << "Adding customized user hook";
618  for (const auto &fUserHook : fCustomHooksVector->hooks) {
619  (fUserHooksVector->hooks).push_back(fUserHook);
620  }
621  }
622 
623  if (fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) {
624  if (fJetMatchingHook.get() || fEmissionVetoHook1.get())
625  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
626  << " Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible "
627  "are : jetMatching, emissionVeto1 \n";
628 
629  if (!fEmissionVetoHook.get())
630  fEmissionVetoHook.reset(new PowhegHooks());
631 
632  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook from pythia8 code";
634  }
635 
636  bool PowhegRes = fMasterGen->settings.flag("POWHEGres:calcScales");
637  if (PowhegRes) {
638  edm::LogInfo("Pythia8Interface") << "Turning on resonance scale setting from CMSSW Pythia8Interface";
639  if (!fPowhegResHook.get())
640  fPowhegResHook.reset(new PowhegResHook());
642  }
643 
644  bool PowhegBB4L = fMasterGen->settings.flag("POWHEG:bb4l");
645  if (PowhegBB4L) {
646  edm::LogInfo("Pythia8Interface") << "Turning on BB4l hook from CMSSW Pythia8Interface";
647  if (!fPowhegHooksBB4L.get())
648  fPowhegHooksBB4L.reset(new PowhegHooksBB4L());
650  }
651 
652  bool TopRecoilHook1 = fMasterGen->settings.flag("TopRecoilHook:doTopRecoilIn");
653  if (TopRecoilHook1) {
654  edm::LogInfo("Pythia8Interface") << "Turning on RecoilToTop hook from Pythia8Interface";
655  if (!fTopRecoilHook.get())
656  fTopRecoilHook.reset(new TopRecoilHook());
658  }
659 
660  //adapted from main89.cc in pythia8 examples
661  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
662  bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void");
663 
664  if (internalMatching && internalMerging) {
665  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
666  << " Only one jet matching/merging scheme can be used at a time. \n";
667  }
668 
669  if (internalMatching) {
670  if (!fJetMatchingPy8InternalHook.get())
671  fJetMatchingPy8InternalHook.reset(new Pythia8::JetMatchingMadgraph);
673  }
674 
675  if (internalMerging) {
676  int scheme = (fMasterGen->settings.flag("Merging:doUMEPSTree") || fMasterGen->settings.flag("Merging:doUMEPSSubt"))
677  ? 1
678  : ((fMasterGen->settings.flag("Merging:doUNLOPSTree") ||
679  fMasterGen->settings.flag("Merging:doUNLOPSSubt") ||
680  fMasterGen->settings.flag("Merging:doUNLOPSLoop") ||
681  fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO"))
682  ? 2
683  : 0);
684  if (!fMergingHook.get())
685  fMergingHook.reset(new Pythia8::amcnlo_unitarised_interface(scheme));
687  }
688 
689  bool biasedTauDecayer = fMasterGen->settings.flag("BiasedTauDecayer:filter");
690  if (biasedTauDecayer) {
691  if (!fBiasedTauDecayer.get()) {
692  Pythia8::Info localInfo = fMasterGen->info;
693  fBiasedTauDecayer.reset(new BiasedTauDecayer(&localInfo, &(fMasterGen->settings)));
694  }
695  std::vector<int> handledParticles;
696  handledParticles.push_back(15);
697  fMasterGen->setDecayPtr(fBiasedTauDecayer, handledParticles);
698  }
699 
700  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
701  if (resonanceDecayFilter) {
704  }
705 
706  bool PTFilter = fMasterGen->settings.flag("PTFilter:filter");
707  if (PTFilter) {
708  fPTFilterHook.reset(new PTFilterHook);
710  }
711 
712  if (!(fUserHooksVector->hooks).empty() && !UserHooksSet) {
713  for (auto &fUserHook : fUserHooksVector->hooks) {
714  fMasterGen->addUserHooksPtr(fUserHook);
715  }
716  UserHooksSet = true;
717  }
718 
719  if (!LHEInputFileName.empty()) {
720  edm::LogInfo("Pythia8Interface") << "Initialize direct pythia8 reading from LHE file " << LHEInputFileName;
721  edm::LogInfo("Pythia8Interface") << "Some LHE information can be not stored";
722  fMasterGen->settings.mode("Beams:frameType", 4);
723  fMasterGen->settings.word("Beams:LHEF", LHEInputFileName);
724  status = fMasterGen->init();
725 
726  } else {
727  lhaUP.reset(new LHAupLesHouches());
728  lhaUP->setScalesFromLHEF(fMasterGen->settings.flag("Beams:setProductionScalesFromLHEF"));
729  lhaUP->loadRunInfo(lheRunInfo());
730 
731  if (fJetMatchingHook.get()) {
732  fJetMatchingHook->init(lheRunInfo());
733  }
734 
735  fMasterGen->settings.mode("Beams:frameType", 5);
736  fMasterGen->setLHAupPtr(lhaUP);
737  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
738  status = fMasterGen->init();
739  }
740 
741  //clean up temp file
742  if (!slhafile_.empty()) {
743  std::remove(slhafile_.c_str());
744  }
745 
746  if (pythiaPylistVerbosity > 10) {
747  if (pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13)
748  fMasterGen->settings.listAll();
749  if (pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13)
750  fMasterGen->particleData.listAll();
751  }
752 
753  // init decayer
754  fDecayer->settings.flag("ProcessLevel:all", false); // trick
755  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true);
756  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
757  status1 = fDecayer->init();
758 
759  if (useEvtGen) {
760  edm::LogInfo("Pythia8Hadronizer") << "Creating and initializing pythia8 EvtGen plugin";
761  if (!evtgenDecays.get()) {
762  evtgenDecays.reset(new EvtGenDecays(fMasterGen.get(), evtgenDecFile, evtgenPdlFile));
763  for (unsigned int i = 0; i < evtgenUserFiles.size(); i++)
764  evtgenDecays->readDecayFile(evtgenUserFiles.at(i));
765  }
766  }
767 
768  return (status && status1);
769 }
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:233
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 398 of file Pythia8Hadronizer.cc.

References l1ct::clear(), comEnergy, edm::errors::Configuration, ElectronPositron, edm::ParameterSet::empty(), 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, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, gen::BaseHadronizer::lheFile_, photonFluxParams, PP, PPbar, push_back(), gen::Py8InterfaceBase::pythiaPylistVerbosity, MatrixUtil::remove(), generator_cfi::scheme, gen::Py8InterfaceBase::slhafile_, mps_update::status, gen::Py8InterfaceBase::useEvtGen, and UserHooksSet.

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

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

977  {
978  Event *pythiaEvent = &(fMasterGen->event);
979 
980  int NPartsBeforeDecays = pythiaEvent->size();
981  int NPartsAfterDecays = event().get()->particles_size();
982 
983  if (NPartsAfterDecays == NPartsBeforeDecays)
984  return true;
985 
986  bool result = true;
987 
988  for (int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
989  HepMC::GenParticle *part = event().get()->barcode_to_particle(ipart);
990 
991  if (part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id())) {
992  fDecayer->event.reset();
993  Particle py8part(part->pdg_id(),
994  93,
995  0,
996  0,
997  0,
998  0,
999  0,
1000  0,
1001  part->momentum().x(),
1002  part->momentum().y(),
1003  part->momentum().z(),
1004  part->momentum().t(),
1005  part->generated_mass());
1006  HepMC::GenVertex *ProdVtx = part->production_vertex();
1007  py8part.vProd(ProdVtx->position().x(), ProdVtx->position().y(), ProdVtx->position().z(), ProdVtx->position().t());
1008  py8part.tau((fDecayer->particleData).tau0(part->pdg_id()));
1009  fDecayer->event.append(py8part);
1010  int nentries = fDecayer->event.size();
1011  if (!fDecayer->event[nentries - 1].mayDecay())
1012  continue;
1013  fDecayer->next();
1014  int nentries1 = fDecayer->event.size();
1015  if (nentries1 <= nentries)
1016  continue; //same number of particles, no decays...
1017 
1018  part->set_status(2);
1019 
1020  result = toHepMC.fill_next_event(*(fDecayer.get()), event().get(), -1, true, part);
1021  }
1022  }
1023 
1024  return result;
1025 }
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 771 of file Pythia8Hadronizer.cc.

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

771  {
772  fMasterGen->stat();
773 
774  if (fEmissionVetoHook.get()) {
775  edm::LogPrint("Pythia8Interface") << "\n"
776  << "Number of ISR vetoed = " << nISRveto;
777  edm::LogPrint("Pythia8Interface") << "Number of FSR vetoed = " << nFSRveto;
778  }
779 
780  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
781  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
782  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
783  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
785 }
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 148 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ DJR

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 217 of file Pythia8Hadronizer.cc.

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

◆ EV1_emittedMode

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 209 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_maxVetoCount

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 206 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_MPIvetoOn

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 211 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinal

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 204 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinalMode

int Pythia8Hadronizer::EV1_nFinalMode
private

Definition at line 213 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTdefMode

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 210 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTempMode

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 208 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pThardMode

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 207 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_QEDvetoMode

int Pythia8Hadronizer::EV1_QEDvetoMode
private

Definition at line 212 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_vetoOn

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 205 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ fBeam1PZ

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 156 of file Pythia8Hadronizer.cc.

◆ fBeam2PZ

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 157 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 154 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 151 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ LHEInputFileName

std::string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 150 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ nFSRveto

int Pythia8Hadronizer::nFSRveto
private

Definition at line 222 of file Pythia8Hadronizer.cc.

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

◆ nISRveto

int Pythia8Hadronizer::nISRveto
private

Definition at line 221 of file Pythia8Hadronizer.cc.

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

◆ nME

int Pythia8Hadronizer::nME
private

Definition at line 218 of file Pythia8Hadronizer.cc.

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

◆ nMEFiltered

int Pythia8Hadronizer::nMEFiltered
private

Definition at line 219 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 215 of file Pythia8Hadronizer.cc.

◆ photonFluxParams

edm::ParameterSet Pythia8Hadronizer::photonFluxParams
private

Definition at line 161 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons(), and Pythia8Hadronizer().

◆ UserHooksSet

bool Pythia8Hadronizer::UserHooksSet
private