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:307
double comEnergy
Center-of-Mass energy.
std::shared_ptr< EmissionVetoHook1 > fEmissionVetoHook1
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string LHEInputFileName
Py8InterfaceBase(edm::ParameterSet const &ps)
std::shared_ptr< UserHooks > fReweightRapUserHook
unsigned int ivhepmc
std::shared_ptr< UserHooksVector > fCustomHooksVector
Log< level::Error, true > LogImportant
std::shared_ptr< JetMatchingHook > fJetMatchingHook
Log< level::Info, false > LogInfo
std::shared_ptr< UserHooks > fReweightUserHook
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
std::shared_ptr< UserHooks > fReweightEmpUserHook
HepMC::Pythia8ToHepMC toHepMC
std::shared_ptr< UserHooks > fReweightPtHatRapUserHook
std::unique_ptr< Pythia8::Pythia > fMasterGen
#define get

◆ ~Pythia8Hadronizer()

Pythia8Hadronizer::~Pythia8Hadronizer ( )
override

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

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

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

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

◆ getGenLumiInfoHeader()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 1006 of file Pythia8Hadronizer.cc.

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

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

◆ hadronize()

bool Pythia8Hadronizer::hadronize ( )

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

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

◆ initializeForExternalPartons()

bool Pythia8Hadronizer::initializeForExternalPartons ( )

Definition at line 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 
595  //adapted from main89.cc in pythia8 examples
596  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
597  bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void");
598 
599  if (internalMatching && internalMerging) {
600  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
601  << " Only one jet matching/merging scheme can be used at a time. \n";
602  }
603 
604  if (internalMatching) {
605  if (!fJetMatchingPy8InternalHook.get())
606  fJetMatchingPy8InternalHook.reset(new Pythia8::JetMatchingMadgraph);
608  }
609 
610  if (internalMerging) {
611  int scheme = (fMasterGen->settings.flag("Merging:doUMEPSTree") || fMasterGen->settings.flag("Merging:doUMEPSSubt"))
612  ? 1
613  : ((fMasterGen->settings.flag("Merging:doUNLOPSTree") ||
614  fMasterGen->settings.flag("Merging:doUNLOPSSubt") ||
615  fMasterGen->settings.flag("Merging:doUNLOPSLoop") ||
616  fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO"))
617  ? 2
618  : 0);
619  if (!fMergingHook.get())
620  fMergingHook.reset(new Pythia8::amcnlo_unitarised_interface(scheme));
622  }
623 
624  bool biasedTauDecayer = fMasterGen->settings.flag("BiasedTauDecayer:filter");
625  if (biasedTauDecayer) {
626  if (!fBiasedTauDecayer.get()) {
627  Pythia8::Info localInfo = fMasterGen->info;
628  fBiasedTauDecayer.reset(new BiasedTauDecayer(&localInfo, &(fMasterGen->settings)));
629  }
630  std::vector<int> handledParticles;
631  handledParticles.push_back(15);
632  fMasterGen->setDecayPtr(fBiasedTauDecayer, handledParticles);
633  }
634 
635  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
636  if (resonanceDecayFilter) {
639  }
640 
641  bool PTFilter = fMasterGen->settings.flag("PTFilter:filter");
642  if (PTFilter) {
643  fPTFilterHook.reset(new PTFilterHook);
645  }
646 
647  if (!(fUserHooksVector->hooks).empty() && !UserHooksSet) {
648  for (auto &fUserHook : fUserHooksVector->hooks) {
649  fMasterGen->addUserHooksPtr(fUserHook);
650  }
651  UserHooksSet = true;
652  }
653 
654  if (!LHEInputFileName.empty()) {
655  edm::LogInfo("Pythia8Interface") << "Initialize direct pythia8 reading from LHE file " << LHEInputFileName;
656  edm::LogInfo("Pythia8Interface") << "Some LHE information can be not stored";
657  fMasterGen->settings.mode("Beams:frameType", 4);
658  fMasterGen->settings.word("Beams:LHEF", LHEInputFileName);
659  status = fMasterGen->init();
660 
661  } else {
662  lhaUP.reset(new LHAupLesHouches());
663  lhaUP->setScalesFromLHEF(fMasterGen->settings.flag("Beams:setProductionScalesFromLHEF"));
664  lhaUP->loadRunInfo(lheRunInfo());
665 
666  if (fJetMatchingHook.get()) {
667  fJetMatchingHook->init(lheRunInfo());
668  }
669 
670  fMasterGen->settings.mode("Beams:frameType", 5);
671  fMasterGen->setLHAupPtr(lhaUP);
672  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
673  status = fMasterGen->init();
674  }
675 
676  //clean up temp file
677  if (!slhafile_.empty()) {
678  std::remove(slhafile_.c_str());
679  }
680 
681  if (pythiaPylistVerbosity > 10) {
682  if (pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13)
683  fMasterGen->settings.listAll();
684  if (pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13)
685  fMasterGen->particleData.listAll();
686  }
687 
688  // init decayer
689  fDecayer->settings.flag("ProcessLevel:all", false); // trick
690  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true);
691  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
692  status1 = fDecayer->init();
693 
694  if (useEvtGen) {
695  edm::LogInfo("Pythia8Hadronizer") << "Creating and initializing pythia8 EvtGen plugin";
696  if (!evtgenDecays.get()) {
697  evtgenDecays.reset(new EvtGenDecays(fMasterGen.get(), evtgenDecFile, evtgenPdlFile));
698  for (unsigned int i = 0; i < evtgenUserFiles.size(); i++)
699  evtgenDecays->readDecayFile(evtgenUserFiles.at(i));
700  }
701  }
702 
703  return (status && status1);
704 }
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 912 of file Pythia8Hadronizer.cc.

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

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

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

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