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
 
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 79 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 180 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.

182  comEnergy(params.getParameter<double>("comEnergy")),
183  LHEInputFileName(params.getUntrackedParameter<std::string>("LHEInputFileName", "")),
184  fInitialState(PP),
185  UserHooksSet(false),
186  nME(-1),
187  nMEFiltered(-1),
188  nISRveto(0),
189  nFSRveto(0) {
190  ivhepmc = 2;
191  // J.Y.: the following 3 parameters are hacked "for a reason"
192  //
193  if (params.exists("PPbarInitialState")) {
194  if (fInitialState == PP) {
196  edm::LogImportant("GeneratorInterface|Pythia8Interface")
197  << "Pythia8 will be initialized for PROTON-ANTIPROTON INITIAL STATE. "
198  << "This is a user-request change from the DEFAULT PROTON-PROTON initial state.";
199  } else {
200  // probably need to throw on attempt to override ?
201  }
202  } else if (params.exists("ElectronPositronInitialState")) {
203  if (fInitialState == PP) {
205  edm::LogInfo("GeneratorInterface|Pythia8Interface")
206  << "Pythia8 will be initialized for ELECTRON-POSITRON INITIAL STATE. "
207  << "This is a user-request change from the DEFAULT PROTON-PROTON initial state.";
208  } else {
209  // probably need to throw on attempt to override ?
210  }
211  } else if (params.exists("ElectronProtonInitialState") || params.exists("PositronProtonInitialState")) {
212  // throw on unknown initial state !
213  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
214  << " UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
215  }
216 
217  // avoid filling weights twice (from v8.30x)
218  toHepMC.set_store_weights(false);
219 
220  // Reweight user hook
221  //
222  if (params.exists("reweightGen")) {
223  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGen";
224  edm::ParameterSet rgParams = params.getParameter<edm::ParameterSet>("reweightGen");
225  fReweightUserHook.reset(
226  new PtHatReweightUserHook(rgParams.getParameter<double>("pTRef"), rgParams.getParameter<double>("power")));
227  edm::LogInfo("Pythia8Interface") << "End setup for reweightGen";
228  }
229  if (params.exists("reweightGenEmp")) {
230  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGenEmp";
231  edm::ParameterSet rgeParams = params.getParameter<edm::ParameterSet>("reweightGenEmp");
232 
233  std::string tuneName = "";
234  if (rgeParams.exists("tune"))
235  tuneName = rgeParams.getParameter<std::string>("tune");
236  fReweightEmpUserHook.reset(new PtHatEmpReweightUserHook(tuneName));
237  edm::LogInfo("Pythia8Interface") << "End setup for reweightGenEmp";
238  }
239  if (params.exists("reweightGenRap")) {
240  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGenRap";
241  edm::ParameterSet rgrParams = params.getParameter<edm::ParameterSet>("reweightGenRap");
242  fReweightRapUserHook.reset(new RapReweightUserHook(rgrParams.getParameter<std::string>("yLabSigmaFunc"),
243  rgrParams.getParameter<double>("yLabPower"),
244  rgrParams.getParameter<std::string>("yCMSigmaFunc"),
245  rgrParams.getParameter<double>("yCMPower"),
246  rgrParams.getParameter<double>("pTHatMin"),
247  rgrParams.getParameter<double>("pTHatMax")));
248  edm::LogInfo("Pythia8Interface") << "End setup for reweightGenRap";
249  }
250  if (params.exists("reweightGenPtHatRap")) {
251  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGenPtHatRap";
252  edm::ParameterSet rgrParams = params.getParameter<edm::ParameterSet>("reweightGenPtHatRap");
253  fReweightPtHatRapUserHook.reset(new PtHatRapReweightUserHook(rgrParams.getParameter<std::string>("yLabSigmaFunc"),
254  rgrParams.getParameter<double>("yLabPower"),
255  rgrParams.getParameter<std::string>("yCMSigmaFunc"),
256  rgrParams.getParameter<double>("yCMPower"),
257  rgrParams.getParameter<double>("pTHatMin"),
258  rgrParams.getParameter<double>("pTHatMax")));
259  edm::LogInfo("Pythia8Interface") << "End setup for reweightGenPtHatRap";
260  }
261 
262  if (params.exists("useUserHook"))
263  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
264  << " Obsolete parameter: useUserHook \n Please use the actual one instead \n";
265 
266  // PS matching prototype
267  //
268  if (params.exists("jetMatching")) {
269  edm::ParameterSet jmParams = params.getUntrackedParameter<edm::ParameterSet>("jetMatching");
270  std::string scheme = jmParams.getParameter<std::string>("scheme");
271  if (scheme == "Madgraph" || scheme == "MadgraphFastJet") {
272  fJetMatchingHook.reset(new JetMatchingHook(jmParams, &fMasterGen->info));
273  }
274  }
275 
276  // Pythia8Interface emission veto
277  //
278  if (params.exists("emissionVeto1")) {
279  EV1_nFinal = -1;
280  if (params.exists("EV1_nFinal"))
281  EV1_nFinal = params.getParameter<int>("EV1_nFinal");
282  EV1_vetoOn = true;
283  if (params.exists("EV1_vetoOn"))
284  EV1_vetoOn = params.getParameter<bool>("EV1_vetoOn");
285  EV1_maxVetoCount = 10;
286  if (params.exists("EV1_maxVetoCount"))
287  EV1_maxVetoCount = params.getParameter<int>("EV1_maxVetoCount");
288  EV1_pThardMode = 1;
289  if (params.exists("EV1_pThardMode"))
290  EV1_pThardMode = params.getParameter<int>("EV1_pThardMode");
291  EV1_pTempMode = 0;
292  if (params.exists("EV1_pTempMode"))
293  EV1_pTempMode = params.getParameter<int>("EV1_pTempMode");
294  if (EV1_pTempMode > 2 || EV1_pTempMode < 0)
295  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface") << " Wrong value for EV1_pTempMode code\n";
296  EV1_emittedMode = 0;
297  if (params.exists("EV1_emittedMode"))
298  EV1_emittedMode = params.getParameter<int>("EV1_emittedMode");
299  EV1_pTdefMode = 1;
300  if (params.exists("EV1_pTdefMode"))
301  EV1_pTdefMode = params.getParameter<int>("EV1_pTdefMode");
302  EV1_MPIvetoOn = false;
303  if (params.exists("EV1_MPIvetoOn"))
304  EV1_MPIvetoOn = params.getParameter<bool>("EV1_MPIvetoOn");
305  EV1_QEDvetoMode = 0;
306  if (params.exists("EV1_QEDvetoMode"))
307  EV1_QEDvetoMode = params.getParameter<int>("EV1_QEDvetoMode");
308  EV1_nFinalMode = 0;
309  if (params.exists("EV1_nFinalMode"))
310  EV1_nFinalMode = params.getParameter<int>("EV1_nFinalMode");
312  EV1_vetoOn,
321  0));
322  }
323 
324  if (params.exists("UserCustomization")) {
325  fCustomHooksVector = std::make_shared<UserHooksVector>();
326  const std::vector<edm::ParameterSet> userParams =
327  params.getParameter<std::vector<edm::ParameterSet>>("UserCustomization");
328  for (const auto &pluginParams : userParams) {
329  (fCustomHooksVector->hooks)
330  .push_back(
331  CustomHookFactory::get()->create(pluginParams.getParameter<std::string>("pluginName"), pluginParams));
332  }
333  }
334 
335  if (params.exists("VinciaPlugin")) {
336  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
337  << " Obsolete parameter: VinciaPlugin \n Please use the parameter PartonShowers:model instead \n";
338  }
339  if (params.exists("DirePlugin")) {
340  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
341  << " Obsolete parameter: DirePlugin \n Please use the parameter PartonShowers:model instead \n";
342  }
343 }
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 345 of file Pythia8Hadronizer.cc.

345 {}

Member Function Documentation

◆ classname()

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 96 of file Pythia8Hadronizer.cc.

96 { return "Pythia8Hadronizer"; }

◆ doSetRandomEngine()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 101 of file Pythia8Hadronizer.cc.

References findQualityFiles::v.

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

◆ doSharedResources()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 102 of file Pythia8Hadronizer.cc.

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

◆ finalizeEvent()

void Pythia8Hadronizer::finalizeEvent ( )
overridevirtual

Implements gen::Py8InterfaceBase.

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

961  {
962  bool lhe = lheEvent() != nullptr;
963 
964  // protection against empty weight container
965  if ((event()->weights()).empty())
966  (event()->weights()).push_back(1.);
967 
968  // now create the GenEventInfo product from the GenEvent and fill
969  // the missing pieces
970  eventInfo() = std::make_unique<GenEventInfoProduct>(event().get());
971 
972  // in pythia pthat is used to subdivide samples into different bins
973  // in LHE mode the binning is done by the external ME generator
974  // which is likely not pthat, so only filling it for Py6 internal mode
975  if (!lhe) {
976  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
977  }
978 
979  eventInfo()->setDJR(DJR);
980  eventInfo()->setNMEPartons(nME);
981  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
982 
983  //******** Verbosity ********
984 
987  if (pythiaPylistVerbosity) {
988  fMasterGen->info.list();
989  fMasterGen->event.list();
990  }
991 
992  if (pythiaHepMCVerbosity) {
993  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
994  << "----------------------" << std::endl;
995  event()->print();
996  }
998  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
999  << "----------------------" << std::endl;
1000  ascii_io->write_event(event().get());
1001  }
1002  }
1003 }
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 721 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.

721  {
722  DJR.resize(0);
723  nME = -1;
724  nMEFiltered = -1;
725 
726  if (fJetMatchingHook.get()) {
727  fJetMatchingHook->resetMatchingStatus();
728  fJetMatchingHook->beforeHadronization(lheEvent());
729  }
730 
731  if (!fMasterGen->next())
732  return false;
733 
734  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
735  if (fMergingHook.get()) {
736  mergeweight *= fMergingHook->getNormFactor();
737  }
738 
739  //protect against 0-weight from ckkw or similar
740  if (std::abs(mergeweight) == 0.) {
741  event().reset();
742  return false;
743  }
744 
745  if (fJetMatchingPy8InternalHook.get()) {
746  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
747  //cap size of djr vector to save storage space (keep only up to first 6 elements)
748  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
749  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
750  DJR.push_back(djrmatch[idjr]);
751  }
752 
753  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
754  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
755  }
756 
757  if (evtgenDecays.get())
758  evtgenDecays->decay();
759 
760  event() = std::make_unique<HepMC::GenEvent>();
761  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
762 
763  if (!py8hepmc) {
764  return false;
765  }
766 
767  // 0th weight is not filled anymore since v8.30x, pushback manually
768  event()->weights().push_back(fMasterGen->info.weight());
769 
770  //add ckkw/umeps/unlops merging weight
771  if (mergeweight != 1.) {
772  event()->weights()[0] *= mergeweight;
773  }
774 
775  if (fEmissionVetoHook.get()) {
776  nISRveto += fEmissionVetoHook->getNISRveto();
777  nFSRveto += fEmissionVetoHook->getNFSRveto();
778  }
779 
780  //fill additional weights for systematic uncertainties
781  if (fMasterGen->info.getWeightsDetailedSize() > 0) {
782  for (const string &key : fMasterGen->info.initrwgt->weightsKeys) {
783  double wgt = (*fMasterGen->info.weights_detailed)[key];
784  event()->weights().push_back(wgt);
785  }
786  } else if (fMasterGen->info.getWeightsCompressedSize() > 0) {
787  for (unsigned int i = 0; i < fMasterGen->info.getWeightsCompressedSize(); i++) {
788  double wgt = fMasterGen->info.getWeightsCompressedValue(i);
789  event()->weights().push_back(wgt);
790  }
791  }
792 
793  // fill shower weights
794  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
795  if (fMasterGen->info.nWeights() > 1) {
796  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
797  double wgt = fMasterGen->info.weight(i);
798  event()->weights().push_back(wgt);
799  }
800  }
801 
802 #if 0
803  // VINCIA shower weights
804  // http://vincia.hepforge.org/current/share/Vincia/htmldoc/VinciaUncertainties.html
805  if (fvincia.get()) {
806  event()->weights()[0] *= fvincia->weight(0);
807  for (int iVar = 1; iVar < fvincia->nWeights(); iVar++) {
808  event()->weights().push_back(fvincia->weight(iVar));
809  }
810  }
811 
812  // Retrieve Dire shower weights
813  if (fDire.get()) {
814  fDire->weightsPtr->calcWeight(0.);
815  fDire->weightsPtr->reset();
816 
817  //Make sure the base weight comes first
818  event()->weights()[0] *= fDire->weightsPtr->getShowerWeight("base");
819 
820  unordered_map<string, double>::iterator it;
821  for (it = fDire->weightsPtr->getShowerWeights()->begin(); it != fDire->weightsPtr->getShowerWeights()->end();
822  it++) {
823  if (it->first == "base")
824  continue;
825  event()->weights().push_back(it->second);
826  }
827  }
828 #endif
829 
830  return true;
831 }
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 1005 of file Pythia8Hadronizer.cc.

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

1005  {
1006  auto genLumiInfoHeader = BaseHadronizer::getGenLumiInfoHeader();
1007 
1008  //fill lhe headers
1009  //*FIXME* initrwgt header is corrupt due to pythia bug
1010  for (const std::string &key : fMasterGen->info.headerKeys()) {
1011  genLumiInfoHeader->lheHeaders().emplace_back(key, fMasterGen->info.header(key));
1012  }
1013 
1014  //check, if it is not only nominal weight
1015  int weights_number = fMasterGen->info.nWeights();
1016  if (fMasterGen->info.initrwgt)
1017  weights_number += fMasterGen->info.initrwgt->weightsKeys.size();
1018  if (weights_number > 1) {
1019  genLumiInfoHeader->weightNames().reserve(weights_number + 1);
1020  genLumiInfoHeader->weightNames().push_back("nominal");
1021  }
1022 
1023  //fill weight names
1024  if (fMasterGen->info.initrwgt) {
1025  for (const std::string &key : fMasterGen->info.initrwgt->weightsKeys) {
1026  std::string weightgroupname;
1027  for (const auto &wgtgrp : fMasterGen->info.initrwgt->weightgroups) {
1028  const auto &wgtgrpwgt = wgtgrp.second.weights.find(key);
1029  if (wgtgrpwgt != wgtgrp.second.weights.end()) {
1030  weightgroupname = wgtgrp.first;
1031  }
1032  }
1033 
1034  std::ostringstream weightname;
1035  weightname << "LHE, id = " << key << ", ";
1036  if (!weightgroupname.empty()) {
1037  weightname << "group = " << weightgroupname << ", ";
1038  }
1039  weightname << fMasterGen->info.initrwgt->weights[key].contents;
1040  genLumiInfoHeader->weightNames().push_back(weightname.str());
1041  }
1042  }
1043 
1044  //fill shower labels
1045  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
1046  // http://home.thep.lu.se/~torbjorn/doxygen/classPythia8_1_1Info.html
1047  if (fMasterGen->info.nWeights() > 1) {
1048  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
1049  genLumiInfoHeader->weightNames().push_back(fMasterGen->info.weightLabel(i));
1050  }
1051  }
1052 
1053 #if 0
1054  // VINCIA shower weights
1055  // http://vincia.hepforge.org/current/share/Vincia/htmldoc/VinciaUncertainties.html
1056  if (fvincia.get()) {
1057  for (int iVar = 0; iVar < fvincia->nWeights(); iVar++) {
1058  genLumiInfoHeader->weightNames().push_back(fvincia->weightLabel(iVar));
1059  }
1060  }
1061 
1062  if (fDire.get()) {
1063  //Make sure the base weight comes first
1064  genLumiInfoHeader->weightNames().push_back("base");
1065 
1066  unordered_map<string, double>::iterator it;
1067  for (it = fDire->weightsPtr->getShowerWeights()->begin(); it != fDire->weightsPtr->getShowerWeights()->end();
1068  it++) {
1069  if (it->first == "base")
1070  continue;
1071  genLumiInfoHeader->weightNames().push_back(it->first);
1072  }
1073  }
1074 #endif
1075 
1076  return genLumiInfoHeader;
1077 }
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ hadronize()

bool Pythia8Hadronizer::hadronize ( )

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

833  {
834  DJR.resize(0);
835  nME = -1;
836  nMEFiltered = -1;
837  if (LHEInputFileName.empty())
838  lhaUP->loadEvent(lheEvent());
839 
840  if (fJetMatchingHook.get()) {
841  fJetMatchingHook->resetMatchingStatus();
842  fJetMatchingHook->beforeHadronization(lheEvent());
843  }
844 
845  bool py8next = fMasterGen->next();
846 
847  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
848  if (fMergingHook.get()) {
849  mergeweight *= fMergingHook->getNormFactor();
850  }
851 
852  //protect against 0-weight from ckkw or similar
853  if (!py8next || std::abs(mergeweight) == 0.) {
854  lheEvent()->count(lhef::LHERunInfo::kSelected, 1.0, mergeweight);
855  event().reset();
856  return false;
857  }
858 
859  if (fJetMatchingPy8InternalHook.get()) {
860  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
861  //cap size of djr vector to save storage space (keep only up to first 6 elements)
862  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
863  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
864  DJR.push_back(djrmatch[idjr]);
865  }
866 
867  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
868  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
869  }
870 
871  // update LHE matching statistics
872  //
873  lheEvent()->count(lhef::LHERunInfo::kAccepted, 1.0, mergeweight);
874 
875  if (evtgenDecays.get())
876  evtgenDecays->decay();
877 
878  event() = std::make_unique<HepMC::GenEvent>();
879 
880  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
881 
882  if (!py8hepmc) {
883  return false;
884  }
885 
886  // 0th weight is not filled anymore since v8.30x, pushback manually
887  event()->weights().push_back(fMasterGen->info.weight());
888 
889  //add ckkw/umeps/unlops merging weight
890  if (mergeweight != 1.) {
891  event()->weights()[0] *= mergeweight;
892  }
893 
894  if (fEmissionVetoHook.get()) {
895  nISRveto += fEmissionVetoHook->getNISRveto();
896  nFSRveto += fEmissionVetoHook->getNFSRveto();
897  }
898 
899  // fill shower weights
900  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
901  if (fMasterGen->info.nWeights() > 1) {
902  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
903  double wgt = fMasterGen->info.weight(i);
904  event()->weights().push_back(wgt);
905  }
906  }
907 
908  return true;
909 }
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 527 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.

527  {
528  edm::LogInfo("Pythia8Interface") << "Initializing for external partons";
529 
530  bool status = false, status1 = false;
531 
532  if (!fUserHooksVector.get())
533  fUserHooksVector.reset(new UserHooksVector);
534  (fUserHooksVector->hooks).clear();
535 
536  if (fReweightUserHook.get())
537  (fUserHooksVector->hooks).push_back(fReweightUserHook);
538  if (fReweightEmpUserHook.get())
539  (fUserHooksVector->hooks).push_back(fReweightEmpUserHook);
540  if (fReweightRapUserHook.get())
541  (fUserHooksVector->hooks).push_back(fReweightRapUserHook);
542  if (fReweightPtHatRapUserHook.get())
543  (fUserHooksVector->hooks).push_back(fReweightPtHatRapUserHook);
544  if (fJetMatchingHook.get())
545  (fUserHooksVector->hooks).push_back(fJetMatchingHook);
546  if (fEmissionVetoHook1.get()) {
547  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook 1 from CMSSW Pythia8Interface";
549  }
550 
551  if (fCustomHooksVector.get()) {
552  edm::LogInfo("Pythia8Interface") << "Adding customized user hook";
553  for (const auto &fUserHook : fCustomHooksVector->hooks) {
554  (fUserHooksVector->hooks).push_back(fUserHook);
555  }
556  }
557 
558  if (fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) {
559  if (fJetMatchingHook.get() || fEmissionVetoHook1.get())
560  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
561  << " Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible "
562  "are : jetMatching, emissionVeto1 \n";
563 
564  if (!fEmissionVetoHook.get())
565  fEmissionVetoHook.reset(new PowhegHooks());
566 
567  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook from pythia8 code";
569  }
570 
571  bool PowhegRes = fMasterGen->settings.flag("POWHEGres:calcScales");
572  if (PowhegRes) {
573  edm::LogInfo("Pythia8Interface") << "Turning on resonance scale setting from CMSSW Pythia8Interface";
574  if (!fPowhegResHook.get())
575  fPowhegResHook.reset(new PowhegResHook());
577  }
578 
579  bool PowhegBB4L = fMasterGen->settings.flag("POWHEG:bb4l");
580  if (PowhegBB4L) {
581  edm::LogInfo("Pythia8Interface") << "Turning on BB4l hook from CMSSW Pythia8Interface";
582  if (!fPowhegHooksBB4L.get())
583  fPowhegHooksBB4L.reset(new PowhegHooksBB4L());
585  }
586 
587  bool TopRecoilHook1 = fMasterGen->settings.flag("TopRecoilHook:doTopRecoilIn");
588  if (TopRecoilHook1) {
589  edm::LogInfo("Pythia8Interface") << "Turning on RecoilToTop hook from Pythia8Interface";
590  if (!fTopRecoilHook.get())
591  fTopRecoilHook.reset(new TopRecoilHook());
593  }
594  //adapted from main89.cc in pythia8 examples
595  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
596  bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void");
597 
598  if (internalMatching && internalMerging) {
599  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
600  << " Only one jet matching/merging scheme can be used at a time. \n";
601  }
602 
603  if (internalMatching) {
604  if (!fJetMatchingPy8InternalHook.get())
605  fJetMatchingPy8InternalHook.reset(new Pythia8::JetMatchingMadgraph);
607  }
608 
609  if (internalMerging) {
610  int scheme = (fMasterGen->settings.flag("Merging:doUMEPSTree") || fMasterGen->settings.flag("Merging:doUMEPSSubt"))
611  ? 1
612  : ((fMasterGen->settings.flag("Merging:doUNLOPSTree") ||
613  fMasterGen->settings.flag("Merging:doUNLOPSSubt") ||
614  fMasterGen->settings.flag("Merging:doUNLOPSLoop") ||
615  fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO"))
616  ? 2
617  : 0);
618  if (!fMergingHook.get())
619  fMergingHook.reset(new Pythia8::amcnlo_unitarised_interface(scheme));
621  }
622 
623  bool biasedTauDecayer = fMasterGen->settings.flag("BiasedTauDecayer:filter");
624  if (biasedTauDecayer) {
625  if (!fBiasedTauDecayer.get()) {
626  Pythia8::Info localInfo = fMasterGen->info;
627  fBiasedTauDecayer.reset(new BiasedTauDecayer(&localInfo, &(fMasterGen->settings)));
628  }
629  std::vector<int> handledParticles;
630  handledParticles.push_back(15);
631  fMasterGen->setDecayPtr(fBiasedTauDecayer, handledParticles);
632  }
633 
634  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
635  if (resonanceDecayFilter) {
638  }
639 
640  bool PTFilter = fMasterGen->settings.flag("PTFilter:filter");
641  if (PTFilter) {
642  fPTFilterHook.reset(new PTFilterHook);
644  }
645 
646  if (!(fUserHooksVector->hooks).empty() && !UserHooksSet) {
647  for (auto &fUserHook : fUserHooksVector->hooks) {
648  fMasterGen->addUserHooksPtr(fUserHook);
649  }
650  UserHooksSet = true;
651  }
652 
653  if (!LHEInputFileName.empty()) {
654  edm::LogInfo("Pythia8Interface") << "Initialize direct pythia8 reading from LHE file " << LHEInputFileName;
655  edm::LogInfo("Pythia8Interface") << "Some LHE information can be not stored";
656  fMasterGen->settings.mode("Beams:frameType", 4);
657  fMasterGen->settings.word("Beams:LHEF", LHEInputFileName);
658  status = fMasterGen->init();
659 
660  } else {
661  lhaUP.reset(new LHAupLesHouches());
662  lhaUP->setScalesFromLHEF(fMasterGen->settings.flag("Beams:setProductionScalesFromLHEF"));
663  lhaUP->loadRunInfo(lheRunInfo());
664 
665  if (fJetMatchingHook.get()) {
666  fJetMatchingHook->init(lheRunInfo());
667  }
668 
669  fMasterGen->settings.mode("Beams:frameType", 5);
670  fMasterGen->setLHAupPtr(lhaUP);
671  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
672  status = fMasterGen->init();
673  }
674 
675  //clean up temp file
676  if (!slhafile_.empty()) {
677  std::remove(slhafile_.c_str());
678  }
679 
680  if (pythiaPylistVerbosity > 10) {
681  if (pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13)
682  fMasterGen->settings.listAll();
683  if (pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13)
684  fMasterGen->particleData.listAll();
685  }
686 
687  // init decayer
688  fDecayer->settings.flag("ProcessLevel:all", false); // trick
689  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true);
690  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
691  status1 = fDecayer->init();
692 
693  if (useEvtGen) {
694  edm::LogInfo("Pythia8Hadronizer") << "Creating and initializing pythia8 EvtGen plugin";
695  if (!evtgenDecays.get()) {
696  evtgenDecays.reset(new EvtGenDecays(fMasterGen.get(), evtgenDecFile, evtgenPdlFile));
697  for (unsigned int i = 0; i < evtgenUserFiles.size(); i++)
698  evtgenDecays->readDecayFile(evtgenUserFiles.at(i));
699  }
700  }
701 
702  return (status && status1);
703 }
std::shared_ptr< PowhegHooksBB4L > fPowhegHooksBB4L
std::shared_ptr< PowhegHooks > fEmissionVetoHook
std::shared_ptr< EmissionVetoHook1 > fEmissionVetoHook1
std::shared_ptr< BiasedTauDecayer > fBiasedTauDecayer
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
std::unique_ptr< Pythia8::Pythia > fDecayer
std::shared_ptr< TopRecoilHook > fTopRecoilHook
std::string LHEInputFileName
std::shared_ptr< UserHooks > fReweightRapUserHook
std::shared_ptr< LHAupLesHouches > lhaUP
std::vector< std::string > evtgenUserFiles
std::shared_ptr< UserHooksVector > fCustomHooksVector
std::shared_ptr< ResonanceDecayFilterHook > fResonanceDecayFilterHook
std::shared_ptr< UserHooksVector > fUserHooksVector
unsigned int pythiaPylistVerbosity
std::shared_ptr< PTFilterHook > fPTFilterHook
std::shared_ptr< Pythia8::JetMatchingMadgraph > fJetMatchingPy8InternalHook
lhef::LHERunInfo * lheRunInfo()
std::shared_ptr< JetMatchingHook > fJetMatchingHook
Log< level::Info, false > LogInfo
std::shared_ptr< UserHooks > fReweightUserHook
std::shared_ptr< Pythia8::amcnlo_unitarised_interface > fMergingHook
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:223
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
std::shared_ptr< UserHooks > fReweightEmpUserHook
std::shared_ptr< PowhegResHook > fPowhegResHook
std::shared_ptr< UserHooks > fReweightPtHatRapUserHook
std::unique_ptr< Pythia8::Pythia > fMasterGen
void clear(EGIsoObj &c)
Definition: egamma.h:82

◆ initializeForInternalPartons()

bool Pythia8Hadronizer::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 347 of file Pythia8Hadronizer.cc.

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

347  {
348  bool status = false, status1 = false;
349 
350  if (lheFile_.empty()) {
351  if (fInitialState == PP) // default
352  {
353  fMasterGen->settings.mode("Beams:idA", 2212);
354  fMasterGen->settings.mode("Beams:idB", 2212);
355  } else if (fInitialState == PPbar) {
356  fMasterGen->settings.mode("Beams:idA", 2212);
357  fMasterGen->settings.mode("Beams:idB", -2212);
358  } else if (fInitialState == ElectronPositron) {
359  fMasterGen->settings.mode("Beams:idA", 11);
360  fMasterGen->settings.mode("Beams:idB", -11);
361  } else {
362  // throw on unknown initial state !
363  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
364  << " UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
365  }
366  fMasterGen->settings.parm("Beams:eCM", comEnergy);
367  } else {
368  fMasterGen->settings.mode("Beams:frameType", 4);
369  fMasterGen->settings.word("Beams:LHEF", lheFile_);
370  }
371 
372  if (!fUserHooksVector.get())
373  fUserHooksVector.reset(new UserHooksVector);
374  (fUserHooksVector->hooks).clear();
375 
376  if (fReweightUserHook.get())
377  (fUserHooksVector->hooks).push_back(fReweightUserHook);
378  if (fReweightEmpUserHook.get())
379  (fUserHooksVector->hooks).push_back(fReweightEmpUserHook);
380  if (fReweightRapUserHook.get())
381  (fUserHooksVector->hooks).push_back(fReweightRapUserHook);
382  if (fReweightPtHatRapUserHook.get())
383  (fUserHooksVector->hooks).push_back(fReweightPtHatRapUserHook);
384  if (fJetMatchingHook.get())
385  (fUserHooksVector->hooks).push_back(fJetMatchingHook);
386  if (fEmissionVetoHook1.get()) {
387  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook 1 from CMSSW Pythia8Interface";
389  }
390 
391  if (fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) {
392  if (fJetMatchingHook.get() || fEmissionVetoHook1.get())
393  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
394  << " Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible "
395  "are : jetMatching, emissionVeto1 \n";
396 
397  if (!fEmissionVetoHook.get())
398  fEmissionVetoHook.reset(new PowhegHooks());
399 
400  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook from pythia8 code";
402  }
403 
404  bool PowhegRes = fMasterGen->settings.flag("POWHEGres:calcScales");
405  if (PowhegRes) {
406  edm::LogInfo("Pythia8Interface") << "Turning on resonance scale setting from CMSSW Pythia8Interface";
407  if (!fPowhegResHook.get())
408  fPowhegResHook.reset(new PowhegResHook());
410  }
411 
412  bool PowhegBB4L = fMasterGen->settings.flag("POWHEG:bb4l");
413  if (PowhegBB4L) {
414  edm::LogInfo("Pythia8Interface") << "Turning on BB4l hook from CMSSW Pythia8Interface";
415  if (!fPowhegHooksBB4L.get())
416  fPowhegHooksBB4L.reset(new PowhegHooksBB4L());
418  }
419 
420  bool TopRecoilHook1 = fMasterGen->settings.flag("TopRecoilHook:doTopRecoilIn");
421  if (TopRecoilHook1) {
422  edm::LogInfo("Pythia8Interface") << "Turning on RecoilToTop hook from Pythia8Interface";
423  if (!fTopRecoilHook.get())
424  fTopRecoilHook.reset(new TopRecoilHook());
426  }
427 
428  //adapted from main89.cc in pythia8 examples
429  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
430  bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void");
431 
432  if (internalMatching && internalMerging) {
433  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
434  << " Only one jet matching/merging scheme can be used at a time. \n";
435  }
436 
437  if (internalMatching) {
438  if (!fJetMatchingPy8InternalHook.get())
439  fJetMatchingPy8InternalHook.reset(new Pythia8::JetMatchingMadgraph);
441  }
442 
443  if (internalMerging) {
444  int scheme = (fMasterGen->settings.flag("Merging:doUMEPSTree") || fMasterGen->settings.flag("Merging:doUMEPSSubt"))
445  ? 1
446  : ((fMasterGen->settings.flag("Merging:doUNLOPSTree") ||
447  fMasterGen->settings.flag("Merging:doUNLOPSSubt") ||
448  fMasterGen->settings.flag("Merging:doUNLOPSLoop") ||
449  fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO"))
450  ? 2
451  : 0);
452  if (!fMergingHook.get())
453  fMergingHook.reset(new Pythia8::amcnlo_unitarised_interface(scheme));
455  }
456 
457  bool biasedTauDecayer = fMasterGen->settings.flag("BiasedTauDecayer:filter");
458  if (biasedTauDecayer) {
459  if (!fBiasedTauDecayer.get()) {
460  Pythia8::Info localInfo = fMasterGen->info;
461  fBiasedTauDecayer.reset(new BiasedTauDecayer(&localInfo, &(fMasterGen->settings)));
462  }
463  std::vector<int> handledParticles;
464  handledParticles.push_back(15);
465  fMasterGen->setDecayPtr(fBiasedTauDecayer, handledParticles);
466  }
467 
468  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
469  if (resonanceDecayFilter) {
472  }
473 
474  bool PTFilter = fMasterGen->settings.flag("PTFilter:filter");
475  if (PTFilter) {
476  fPTFilterHook.reset(new PTFilterHook);
478  }
479 
480  if (!(fUserHooksVector->hooks).empty() && !UserHooksSet) {
481  for (auto &fUserHook : fUserHooksVector->hooks) {
482  fMasterGen->addUserHooksPtr(fUserHook);
483  }
484  UserHooksSet = true;
485  }
486 
487  if (fCustomHooksVector.get()) {
488  edm::LogInfo("Pythia8Interface") << "Adding customized user hooks";
489  for (const auto &fUserHook : fCustomHooksVector->hooks) {
490  fMasterGen->addUserHooksPtr(fUserHook);
491  }
492  }
493 
494  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
495  status = fMasterGen->init();
496 
497  //clean up temp file
498  if (!slhafile_.empty()) {
499  std::remove(slhafile_.c_str());
500  }
501 
502  if (pythiaPylistVerbosity > 10) {
503  if (pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13)
504  fMasterGen->settings.listAll();
505  if (pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13)
506  fMasterGen->particleData.listAll();
507  }
508 
509  // init decayer
510  fDecayer->settings.flag("ProcessLevel:all", false); // trick
511  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true);
512  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
513  status1 = fDecayer->init();
514 
515  if (useEvtGen) {
516  edm::LogInfo("Pythia8Hadronizer") << "Creating and initializing pythia8 EvtGen plugin";
517  if (!evtgenDecays.get()) {
518  evtgenDecays.reset(new EvtGenDecays(fMasterGen.get(), evtgenDecFile, evtgenPdlFile));
519  for (unsigned int i = 0; i < evtgenUserFiles.size(); i++)
520  evtgenDecays->readDecayFile(evtgenUserFiles.at(i));
521  }
522  }
523 
524  return (status && status1);
525 }
std::shared_ptr< PowhegHooksBB4L > fPowhegHooksBB4L
double comEnergy
Center-of-Mass energy.
std::shared_ptr< PowhegHooks > fEmissionVetoHook
std::shared_ptr< EmissionVetoHook1 > fEmissionVetoHook1
std::shared_ptr< BiasedTauDecayer > fBiasedTauDecayer
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
std::unique_ptr< Pythia8::Pythia > fDecayer
std::shared_ptr< TopRecoilHook > fTopRecoilHook
std::shared_ptr< UserHooks > fReweightRapUserHook
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 911 of file Pythia8Hadronizer.cc.

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

911  {
912  Event *pythiaEvent = &(fMasterGen->event);
913 
914  int NPartsBeforeDecays = pythiaEvent->size();
915  int NPartsAfterDecays = event().get()->particles_size();
916 
917  if (NPartsAfterDecays == NPartsBeforeDecays)
918  return true;
919 
920  bool result = true;
921 
922  for (int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
923  HepMC::GenParticle *part = event().get()->barcode_to_particle(ipart);
924 
925  if (part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id())) {
926  fDecayer->event.reset();
927  Particle py8part(part->pdg_id(),
928  93,
929  0,
930  0,
931  0,
932  0,
933  0,
934  0,
935  part->momentum().x(),
936  part->momentum().y(),
937  part->momentum().z(),
938  part->momentum().t(),
939  part->generated_mass());
940  HepMC::GenVertex *ProdVtx = part->production_vertex();
941  py8part.vProd(ProdVtx->position().x(), ProdVtx->position().y(), ProdVtx->position().z(), ProdVtx->position().t());
942  py8part.tau((fDecayer->particleData).tau0(part->pdg_id()));
943  fDecayer->event.append(py8part);
944  int nentries = fDecayer->event.size();
945  if (!fDecayer->event[nentries - 1].mayDecay())
946  continue;
947  fDecayer->next();
948  int nentries1 = fDecayer->event.size();
949  if (nentries1 <= nentries)
950  continue; //same number of particles, no decays...
951 
952  part->set_status(2);
953 
954  result = toHepMC.fill_next_event(*(fDecayer.get()), event().get(), -1, true, part);
955  }
956  }
957 
958  return result;
959 }
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 705 of file Pythia8Hadronizer.cc.

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

705  {
706  fMasterGen->stat();
707 
708  if (fEmissionVetoHook.get()) {
709  edm::LogPrint("Pythia8Interface") << "\n"
710  << "Number of ISR vetoed = " << nISRveto;
711  edm::LogPrint("Pythia8Interface") << "Number of FSR vetoed = " << nFSRveto;
712  }
713 
714  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
715  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
716  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
717  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
719 }
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 105 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ DJR

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 170 of file Pythia8Hadronizer.cc.

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

◆ EV1_emittedMode

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 162 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_maxVetoCount

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 159 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_MPIvetoOn

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 164 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinal

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 157 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinalMode

int Pythia8Hadronizer::EV1_nFinalMode
private

Definition at line 166 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTdefMode

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 163 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTempMode

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 161 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pThardMode

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 160 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_QEDvetoMode

int Pythia8Hadronizer::EV1_QEDvetoMode
private

Definition at line 165 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_vetoOn

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 158 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ fBeam1PZ

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 113 of file Pythia8Hadronizer.cc.

◆ fBeam2PZ

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 114 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 111 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 108 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ LHEInputFileName

std::string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 107 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ nFSRveto

int Pythia8Hadronizer::nFSRveto
private

Definition at line 175 of file Pythia8Hadronizer.cc.

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

◆ nISRveto

int Pythia8Hadronizer::nISRveto
private

Definition at line 174 of file Pythia8Hadronizer.cc.

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

◆ nME

int Pythia8Hadronizer::nME
private

Definition at line 171 of file Pythia8Hadronizer.cc.

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

◆ nMEFiltered

int Pythia8Hadronizer::nMEFiltered
private

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

◆ UserHooksSet

bool Pythia8Hadronizer::UserHooksSet
private