CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
Pythia8HepMC3Hadronizer Class Reference
Inheritance diagram for Pythia8HepMC3Hadronizer:
gen::Py8HMC3InterfaceBase 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
 
 Pythia8HepMC3Hadronizer (const edm::ParameterSet &params)
 
virtual bool residualDecay ()
 
void statistics () override
 
 ~Pythia8HepMC3Hadronizer () override=default
 
- Public Member Functions inherited from gen::Py8HMC3InterfaceBase
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)
 
 Py8HMC3InterfaceBase (edm::ParameterSet const &ps)
 
P8RndmEnginerandomEngine ()
 
bool readSettings (int)
 
 ~Py8HMC3InterfaceBase () override=default
 
- 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< 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::Py8HMC3InterfaceBase
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_
 
HepMC3::Pythia8ToHepMC3 toHepMC
 
bool useEvtGen
 
- Protected Attributes inherited from gen::BaseHadronizer
unsigned int ivhepmc = 2
 
std::string lheFile_
 
int randomIndex_
 

Detailed Description

Definition at line 78 of file Pythia8HepMC3Hadronizer.cc.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Constructor & Destructor Documentation

◆ Pythia8HepMC3Hadronizer()

Pythia8HepMC3Hadronizer::Pythia8HepMC3Hadronizer ( const edm::ParameterSet params)

Definition at line 176 of file Pythia8HepMC3Hadronizer.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::Py8HMC3InterfaceBase::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::Py8HMC3InterfaceBase::toHepMC.

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

◆ ~Pythia8HepMC3Hadronizer()

Pythia8HepMC3Hadronizer::~Pythia8HepMC3Hadronizer ( )
overridedefault

Member Function Documentation

◆ classname()

const char* Pythia8HepMC3Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8HMC3InterfaceBase.

Definition at line 95 of file Pythia8HepMC3Hadronizer.cc.

95 { return "Pythia8HepMC3Hadronizer"; }

◆ doSetRandomEngine()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 100 of file Pythia8HepMC3Hadronizer.cc.

References findQualityFiles::v.

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

◆ doSharedResources()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 101 of file Pythia8HepMC3Hadronizer.cc.

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

◆ finalizeEvent()

void Pythia8HepMC3Hadronizer::finalizeEvent ( )
overridevirtual

Implements gen::Py8HMC3InterfaceBase.

Definition at line 951 of file Pythia8HepMC3Hadronizer.cc.

References gather_cfg::cout, DJR, relativeConstraints::empty, gen::BaseHadronizer::event3(), gen::BaseHadronizer::eventInfo3(), gen::Py8HMC3InterfaceBase::fMasterGen, gen::BaseHadronizer::lheEvent(), mps_splice::line, gen::Py8HMC3InterfaceBase::maxEventsToPrint, nME, nMEFiltered, AlCaHLTBitMon_ParallelJobs::p, ecalTrigSettings_cff::particles, push_back(), gen::Py8HMC3InterfaceBase::pythiaHepMCVerbosity, gen::Py8HMC3InterfaceBase::pythiaHepMCVerbosityParticles, gen::Py8HMC3InterfaceBase::pythiaPylistVerbosity, and hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights.

951  {
952  bool lhe = lheEvent() != nullptr;
953 
954  // protection against empty weight container
955  if ((event3()->weights()).empty())
956  (event3()->weights()).push_back(1.);
957 
958  // now create the GenEventInfo product from the GenEvent and fill
959  // the missing pieces
960  eventInfo3() = std::make_unique<GenEventInfoProduct3>(event3().get());
961 
962  // in pythia pthat is used to subdivide samples into different bins
963  // in LHE mode the binning is done by the external ME generator
964  // which is likely not pthat, so only filling it for Py6 internal mode
965  if (!lhe) {
966  eventInfo3()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
967  }
968 
969  eventInfo3()->setDJR(DJR);
970  eventInfo3()->setNMEPartons(nME);
971  eventInfo3()->setNMEPartonsFiltered(nMEFiltered);
972 
973  //******** Verbosity ********
974 
977  if (pythiaPylistVerbosity) {
978  fMasterGen->info.list();
979  fMasterGen->event.list();
980  }
981 
982  if (pythiaHepMCVerbosity) {
983  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
984  << "----------------------" << std::endl;
985  //event3()->print();
986  HepMC3::Print::listing(*(event3().get()));
987  }
989  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
990  << "----------------------" << std::endl;
991  //ascii_io->write_event(event().get());
992  for (const auto &p : (event3().get())->particles()) {
993  HepMC3::Print::line(p, true);
994  }
995  }
996  }
997 }
lhef::LHEEvent * lheEvent()
std::unique_ptr< GenEventInfoProduct3 > & eventInfo3()
std::unique_ptr< Pythia8::Pythia > fMasterGen
std::unique_ptr< HepMC3::GenEvent > & event3()
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})

◆ generatePartonsAndHadronize()

bool Pythia8HepMC3Hadronizer::generatePartonsAndHadronize ( )
overridevirtual

Implements gen::Py8HMC3InterfaceBase.

Definition at line 700 of file Pythia8HepMC3Hadronizer.cc.

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

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

◆ getGenLumiInfoHeader()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 999 of file Pythia8HepMC3Hadronizer.cc.

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

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

◆ hadronize()

bool Pythia8HepMC3Hadronizer::hadronize ( )

Definition at line 813 of file Pythia8HepMC3Hadronizer.cc.

References funct::abs(), lhef::LHEEvent::count(), DJR, gen::BaseHadronizer::event(), gen::BaseHadronizer::event3(), gen::Py8HMC3InterfaceBase::evtgenDecays, fEmissionVetoHook, fJetMatchingHook, fJetMatchingPy8InternalHook, gen::Py8HMC3InterfaceBase::fMasterGen, fMergingHook, mps_fire::i, lhef::LHERunInfo::kAccepted, lhef::LHERunInfo::kSelected, lhaUP, gen::BaseHadronizer::lheEvent(), LHEInputFileName, SiStripPI::min, nFSRveto, nISRveto, nME, nMEFiltered, and gen::Py8HMC3InterfaceBase::toHepMC.

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

◆ initializeForExternalPartons()

bool Pythia8HepMC3Hadronizer::initializeForExternalPartons ( )

Definition at line 513 of file Pythia8HepMC3Hadronizer.cc.

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

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

◆ initializeForInternalPartons()

bool Pythia8HepMC3Hadronizer::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8HMC3InterfaceBase.

Definition at line 341 of file Pythia8HepMC3Hadronizer.cc.

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

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

◆ residualDecay()

bool Pythia8HepMC3Hadronizer::residualDecay ( )
virtual

Definition at line 891 of file Pythia8HepMC3Hadronizer.cc.

References gen::BaseHadronizer::event(), gen::BaseHadronizer::event3(), gen::Py8HMC3InterfaceBase::fDecayer, gen::Py8HMC3InterfaceBase::fMasterGen, GenParticle::GenParticle, AlCaHLTBitMon_ParallelJobs::p, ecalTrigSettings_cff::particles, mps_fire::result, and gen::Py8HMC3InterfaceBase::toHepMC.

891  {
892  Event *pythiaEvent = &(fMasterGen->event);
893 
894  int NPartsBeforeDecays = pythiaEvent->size() - 1; // do NOT count the very 1st "system" particle
895  // in Pythia8::Event record; it does NOT even
896  // get translated by the HepMCInterface to the
897  // HepMC::GenEvent record !!!
898  //int NPartsAfterDecays = event().get()->particles_size();
899  int NPartsAfterDecays = 0;
900  for (auto p : (event3().get())->particles()) {
901  NPartsAfterDecays++;
902  }
903 
904  if (NPartsAfterDecays == NPartsBeforeDecays)
905  return true;
906 
907  bool result = true;
908 
909 // this below is to be rewritten in future development, then it will be uncommented
910 #if 0
911  for (int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
912  HepMC::GenParticle *part = event().get()->barcode_to_particle(ipart);
913 
914  if (part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id())) {
915  fDecayer->event.reset();
916  Particle py8part(part->pdg_id(),
917  93,
918  0,
919  0,
920  0,
921  0,
922  0,
923  0,
924  part->momentum().x(),
925  part->momentum().y(),
926  part->momentum().z(),
927  part->momentum().t(),
928  part->generated_mass());
929  HepMC::GenVertex *ProdVtx = part->production_vertex();
930  py8part.vProd(ProdVtx->position().x(), ProdVtx->position().y(), ProdVtx->position().z(), ProdVtx->position().t());
931  py8part.tau((fDecayer->particleData).tau0(part->pdg_id()));
932  fDecayer->event.append(py8part);
933  int nentries = fDecayer->event.size();
934  if (!fDecayer->event[nentries - 1].mayDecay())
935  continue;
936  fDecayer->next();
937  int nentries1 = fDecayer->event.size();
938  if (nentries1 <= nentries)
939  continue; //same number of particles, no decays...
940 
941  part->set_status(2);
942 
943  result = toHepMC.fill_next_event(*(fDecayer.get()), event().get(), -1, true, part);
944  }
945  }
946 #endif
947 
948  return result;
949 }
HepMC3::Pythia8ToHepMC3 toHepMC
std::unique_ptr< Pythia8::Pythia > fDecayer
std::unique_ptr< HepMC::GenEvent > & event()
std::unique_ptr< Pythia8::Pythia > fMasterGen
std::unique_ptr< HepMC3::GenEvent > & event3()
part
Definition: HCALResponse.h:20

◆ statistics()

void Pythia8HepMC3Hadronizer::statistics ( )
overridevirtual

Reimplemented from gen::Py8HMC3InterfaceBase.

Definition at line 684 of file Pythia8HepMC3Hadronizer.cc.

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

684  {
685  fMasterGen->stat();
686 
687  if (fEmissionVetoHook.get()) {
688  edm::LogPrint("Pythia8Interface") << "\n"
689  << "Number of ISR vetoed = " << nISRveto;
690  edm::LogPrint("Pythia8Interface") << "Number of FSR vetoed = " << nFSRveto;
691  }
692 
693  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
694  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
695  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
696  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
698 }
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 Pythia8HepMC3Hadronizer::comEnergy
private

Center-of-Mass energy.

Definition at line 104 of file Pythia8HepMC3Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ DJR

vector<float> Pythia8HepMC3Hadronizer::DJR
private

◆ EV1_emittedMode

int Pythia8HepMC3Hadronizer::EV1_emittedMode
private

Definition at line 158 of file Pythia8HepMC3Hadronizer.cc.

Referenced by Pythia8HepMC3Hadronizer().

◆ EV1_maxVetoCount

int Pythia8HepMC3Hadronizer::EV1_maxVetoCount
private

Definition at line 155 of file Pythia8HepMC3Hadronizer.cc.

Referenced by Pythia8HepMC3Hadronizer().

◆ EV1_MPIvetoOn

bool Pythia8HepMC3Hadronizer::EV1_MPIvetoOn
private

Definition at line 160 of file Pythia8HepMC3Hadronizer.cc.

Referenced by Pythia8HepMC3Hadronizer().

◆ EV1_nFinal

int Pythia8HepMC3Hadronizer::EV1_nFinal
private

Definition at line 153 of file Pythia8HepMC3Hadronizer.cc.

Referenced by Pythia8HepMC3Hadronizer().

◆ EV1_nFinalMode

int Pythia8HepMC3Hadronizer::EV1_nFinalMode
private

Definition at line 162 of file Pythia8HepMC3Hadronizer.cc.

Referenced by Pythia8HepMC3Hadronizer().

◆ EV1_pTdefMode

int Pythia8HepMC3Hadronizer::EV1_pTdefMode
private

Definition at line 159 of file Pythia8HepMC3Hadronizer.cc.

Referenced by Pythia8HepMC3Hadronizer().

◆ EV1_pTempMode

int Pythia8HepMC3Hadronizer::EV1_pTempMode
private

Definition at line 157 of file Pythia8HepMC3Hadronizer.cc.

Referenced by Pythia8HepMC3Hadronizer().

◆ EV1_pThardMode

int Pythia8HepMC3Hadronizer::EV1_pThardMode
private

Definition at line 156 of file Pythia8HepMC3Hadronizer.cc.

Referenced by Pythia8HepMC3Hadronizer().

◆ EV1_QEDvetoMode

int Pythia8HepMC3Hadronizer::EV1_QEDvetoMode
private

Definition at line 161 of file Pythia8HepMC3Hadronizer.cc.

Referenced by Pythia8HepMC3Hadronizer().

◆ EV1_vetoOn

bool Pythia8HepMC3Hadronizer::EV1_vetoOn
private

Definition at line 154 of file Pythia8HepMC3Hadronizer.cc.

Referenced by Pythia8HepMC3Hadronizer().

◆ fBeam1PZ

double Pythia8HepMC3Hadronizer::fBeam1PZ
private

Definition at line 112 of file Pythia8HepMC3Hadronizer.cc.

◆ fBeam2PZ

double Pythia8HepMC3Hadronizer::fBeam2PZ
private

Definition at line 113 of file Pythia8HepMC3Hadronizer.cc.

◆ fBiasedTauDecayer

std::shared_ptr<BiasedTauDecayer> Pythia8HepMC3Hadronizer::fBiasedTauDecayer
private

◆ fCustomHooksVector

std::shared_ptr<UserHooksVector> Pythia8HepMC3Hadronizer::fCustomHooksVector
private

◆ fEmissionVetoHook

std::shared_ptr<PowhegHooks> Pythia8HepMC3Hadronizer::fEmissionVetoHook
private

◆ fEmissionVetoHook1

std::shared_ptr<EmissionVetoHook1> Pythia8HepMC3Hadronizer::fEmissionVetoHook1
private

◆ fInitialState

int Pythia8HepMC3Hadronizer::fInitialState
private

◆ fJetMatchingHook

std::shared_ptr<JetMatchingHook> Pythia8HepMC3Hadronizer::fJetMatchingHook
private

◆ fJetMatchingPy8InternalHook

std::shared_ptr<Pythia8::JetMatchingMadgraph> Pythia8HepMC3Hadronizer::fJetMatchingPy8InternalHook
private

◆ fMergingHook

std::shared_ptr<Pythia8::amcnlo_unitarised_interface> Pythia8HepMC3Hadronizer::fMergingHook
private

◆ fPowhegHooksBB4L

std::shared_ptr<PowhegHooksBB4L> Pythia8HepMC3Hadronizer::fPowhegHooksBB4L
private

◆ fPowhegResHook

std::shared_ptr<PowhegResHook> Pythia8HepMC3Hadronizer::fPowhegResHook
private

◆ fPTFilterHook

std::shared_ptr<PTFilterHook> Pythia8HepMC3Hadronizer::fPTFilterHook
private

◆ fResonanceDecayFilterHook

std::shared_ptr<ResonanceDecayFilterHook> Pythia8HepMC3Hadronizer::fResonanceDecayFilterHook
private

◆ fReweightEmpUserHook

std::shared_ptr<UserHooks> Pythia8HepMC3Hadronizer::fReweightEmpUserHook
private

◆ fReweightPtHatRapUserHook

std::shared_ptr<UserHooks> Pythia8HepMC3Hadronizer::fReweightPtHatRapUserHook
private

◆ fReweightRapUserHook

std::shared_ptr<UserHooks> Pythia8HepMC3Hadronizer::fReweightRapUserHook
private

◆ fReweightUserHook

std::shared_ptr<UserHooks> Pythia8HepMC3Hadronizer::fReweightUserHook
private

◆ fUserHooksVector

std::shared_ptr<UserHooksVector> Pythia8HepMC3Hadronizer::fUserHooksVector
private

◆ lhaUP

std::shared_ptr<LHAupLesHouches> Pythia8HepMC3Hadronizer::lhaUP
private

Definition at line 107 of file Pythia8HepMC3Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ LHEInputFileName

std::string Pythia8HepMC3Hadronizer::LHEInputFileName
private

Definition at line 106 of file Pythia8HepMC3Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ nFSRveto

int Pythia8HepMC3Hadronizer::nFSRveto
private

Definition at line 171 of file Pythia8HepMC3Hadronizer.cc.

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

◆ nISRveto

int Pythia8HepMC3Hadronizer::nISRveto
private

Definition at line 170 of file Pythia8HepMC3Hadronizer.cc.

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

◆ nME

int Pythia8HepMC3Hadronizer::nME
private

◆ nMEFiltered

int Pythia8HepMC3Hadronizer::nMEFiltered
private

◆ p8SharedResources

const std::vector< std::string > Pythia8HepMC3Hadronizer::p8SharedResources = {edm::SharedResourceNames::kPythia8}
staticprivate

Definition at line 164 of file Pythia8HepMC3Hadronizer.cc.

◆ UserHooksSet

bool Pythia8HepMC3Hadronizer::UserHooksSet
private