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
 
std::shared_ptr< PowhegHooksVincia > fEmissionVetoHookVincia
 
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 117 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 224 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.

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

◆ ~Pythia8Hadronizer()

Pythia8Hadronizer::~Pythia8Hadronizer ( )
override

Definition at line 390 of file Pythia8Hadronizer.cc.

390 {}

Member Function Documentation

◆ classname()

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 134 of file Pythia8Hadronizer.cc.

134 { return "Pythia8Hadronizer"; }

◆ doSetRandomEngine()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 139 of file Pythia8Hadronizer.cc.

References findQualityFiles::v.

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

◆ doSharedResources()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 140 of file Pythia8Hadronizer.cc.

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

◆ finalizeEvent()

void Pythia8Hadronizer::finalizeEvent ( )
overridevirtual

Implements gen::Py8InterfaceBase.

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

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

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

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

◆ getGenLumiInfoHeader()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 1075 of file Pythia8Hadronizer.cc.

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

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

◆ hadronize()

bool Pythia8Hadronizer::hadronize ( )

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

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

◆ initializeForExternalPartons()

bool Pythia8Hadronizer::initializeForExternalPartons ( )

Definition at line 587 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, fEmissionVetoHookVincia, 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.

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

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

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

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

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

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

Referenced by initializeForInternalPartons().

◆ DJR

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 214 of file Pythia8Hadronizer.cc.

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

◆ doProtonPhotonFlux

bool Pythia8Hadronizer::doProtonPhotonFlux = false
private

Definition at line 156 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ EV1_emittedMode

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 206 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_maxVetoCount

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 203 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_MPIvetoOn

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 208 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinal

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 201 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinalMode

int Pythia8Hadronizer::EV1_nFinalMode
private

Definition at line 210 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTdefMode

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 207 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTempMode

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 205 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pThardMode

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 204 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_QEDvetoMode

int Pythia8Hadronizer::EV1_QEDvetoMode
private

Definition at line 209 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_vetoOn

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 202 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ fBeam1PZ

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 151 of file Pythia8Hadronizer.cc.

◆ fBeam2PZ

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 152 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

◆ fEmissionVetoHookVincia

std::shared_ptr<PowhegHooksVincia> Pythia8Hadronizer::fEmissionVetoHookVincia
private

◆ fInitialState

int Pythia8Hadronizer::fInitialState
private

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

Referenced by hadronize(), and initializeForExternalPartons().

◆ LHEInputFileName

std::string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 145 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ nFSRveto

int Pythia8Hadronizer::nFSRveto
private

Definition at line 219 of file Pythia8Hadronizer.cc.

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

◆ nISRveto

int Pythia8Hadronizer::nISRveto
private

Definition at line 218 of file Pythia8Hadronizer.cc.

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

◆ nME

int Pythia8Hadronizer::nME
private

Definition at line 215 of file Pythia8Hadronizer.cc.

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

◆ nMEFiltered

int Pythia8Hadronizer::nMEFiltered
private

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

◆ photonFlux

Pythia8::PDFPtr Pythia8Hadronizer::photonFlux = nullptr
private

Definition at line 157 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ UserHooksSet

bool Pythia8Hadronizer::UserHooksSet
private