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< GenEventInfoProductgetGenEventInfo ()
 
GenRunInfoProductgetGenRunInfo ()
 
std::unique_ptr< lhef::LHEEventgetLHEEvent ()
 
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo () const
 
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 resetEventInfo (std::unique_ptr< GenEventInfoProduct > 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< GenEventInfoProduct > & eventInfo ()
 
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
std::string lheFile_
 
int randomIndex_
 

Detailed Description

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

340 {}

Member Function Documentation

◆ classname()

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 95 of file Pythia8Hadronizer.cc.

95 { return "Pythia8Hadronizer"; }

◆ doSetRandomEngine()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 100 of file Pythia8Hadronizer.cc.

References findQualityFiles::v.

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

◆ doSharedResources()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 101 of file Pythia8Hadronizer.cc.

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

◆ finalizeEvent()

void Pythia8Hadronizer::finalizeEvent ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 941 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 HLT_2022v12_cff::weights.

941  {
942  bool lhe = lheEvent() != nullptr;
943 
944  // protection against empty weight container
945  if ((event()->weights()).empty())
946  (event()->weights()).push_back(1.);
947 
948  // now create the GenEventInfo product from the GenEvent and fill
949  // the missing pieces
950  eventInfo() = std::make_unique<GenEventInfoProduct>(event().get());
951 
952  // in pythia pthat is used to subdivide samples into different bins
953  // in LHE mode the binning is done by the external ME generator
954  // which is likely not pthat, so only filling it for Py6 internal mode
955  if (!lhe) {
956  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
957  }
958 
959  eventInfo()->setDJR(DJR);
960  eventInfo()->setNMEPartons(nME);
961  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
962 
963  //******** Verbosity ********
964 
967  if (pythiaPylistVerbosity) {
968  fMasterGen->info.list();
969  fMasterGen->event.list();
970  }
971 
972  if (pythiaHepMCVerbosity) {
973  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
974  << "----------------------" << std::endl;
975  event()->print();
976  }
978  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
979  << "----------------------" << std::endl;
980  ascii_io->write_event(event().get());
981  }
982  }
983 }
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 701 of file Pythia8Hadronizer.cc.

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

701  {
702  DJR.resize(0);
703  nME = -1;
704  nMEFiltered = -1;
705 
706  if (fJetMatchingHook.get()) {
707  fJetMatchingHook->resetMatchingStatus();
708  fJetMatchingHook->beforeHadronization(lheEvent());
709  }
710 
711  if (!fMasterGen->next())
712  return false;
713 
714  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
715  if (fMergingHook.get()) {
716  mergeweight *= fMergingHook->getNormFactor();
717  }
718 
719  //protect against 0-weight from ckkw or similar
720  if (std::abs(mergeweight) == 0.) {
721  event().reset();
722  return false;
723  }
724 
725  if (fJetMatchingPy8InternalHook.get()) {
726  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
727  //cap size of djr vector to save storage space (keep only up to first 6 elements)
728  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
729  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
730  DJR.push_back(djrmatch[idjr]);
731  }
732 
733  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
734  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
735  }
736 
737  if (evtgenDecays.get())
738  evtgenDecays->decay();
739 
740  event() = std::make_unique<HepMC::GenEvent>();
741  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
742 
743  if (!py8hepmc) {
744  return false;
745  }
746 
747  // 0th weight is not filled anymore since v8.30x, pushback manually
748  event()->weights().push_back(fMasterGen->info.weight());
749 
750  //add ckkw/umeps/unlops merging weight
751  if (mergeweight != 1.) {
752  event()->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  event()->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  event()->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  event()->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< PowhegHooks > fEmissionVetoHook
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
uint16_t size_type
lhef::LHEEvent * lheEvent()
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::shared_ptr< Pythia8::JetMatchingMadgraph > fJetMatchingPy8InternalHook
std::unique_ptr< HepMC::GenEvent > & event()
std::shared_ptr< JetMatchingHook > fJetMatchingHook
std::shared_ptr< Pythia8::amcnlo_unitarised_interface > fMergingHook
vector< float > DJR
HepMC::Pythia8ToHepMC toHepMC
std::unique_ptr< Pythia8::Pythia > fMasterGen

◆ getGenLumiInfoHeader()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 985 of file Pythia8Hadronizer.cc.

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

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

◆ hadronize()

bool Pythia8Hadronizer::hadronize ( )

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

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  event().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 
860  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
861 
862  if (!py8hepmc) {
863  return false;
864  }
865 
866  // 0th weight is not filled anymore since v8.30x, pushback manually
867  event()->weights().push_back(fMasterGen->info.weight());
868 
869  //add ckkw/umeps/unlops merging weight
870  if (mergeweight != 1.) {
871  event()->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  event()->weights().push_back(wgt);
885  }
886  }
887 
888  return true;
889 }
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 514 of file Pythia8Hadronizer.cc.

References 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, 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.

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

◆ initializeForInternalPartons()

bool Pythia8Hadronizer::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 342 of file Pythia8Hadronizer.cc.

References 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, 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.

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

◆ residualDecay()

bool Pythia8Hadronizer::residualDecay ( )
virtual

Definition at line 891 of file Pythia8Hadronizer.cc.

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

891  {
892  Event *pythiaEvent = &(fMasterGen->event);
893 
894  int NPartsBeforeDecays = pythiaEvent->size();
895  int NPartsAfterDecays = event().get()->particles_size();
896 
897  if (NPartsAfterDecays == NPartsBeforeDecays)
898  return true;
899 
900  bool result = true;
901 
902  for (int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
903  HepMC::GenParticle *part = event().get()->barcode_to_particle(ipart);
904 
905  if (part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id())) {
906  fDecayer->event.reset();
907  Particle py8part(part->pdg_id(),
908  93,
909  0,
910  0,
911  0,
912  0,
913  0,
914  0,
915  part->momentum().x(),
916  part->momentum().y(),
917  part->momentum().z(),
918  part->momentum().t(),
919  part->generated_mass());
920  HepMC::GenVertex *ProdVtx = part->production_vertex();
921  py8part.vProd(ProdVtx->position().x(), ProdVtx->position().y(), ProdVtx->position().z(), ProdVtx->position().t());
922  py8part.tau((fDecayer->particleData).tau0(part->pdg_id()));
923  fDecayer->event.append(py8part);
924  int nentries = fDecayer->event.size();
925  if (!fDecayer->event[nentries - 1].mayDecay())
926  continue;
927  fDecayer->next();
928  int nentries1 = fDecayer->event.size();
929  if (nentries1 <= nentries)
930  continue; //same number of particles, no decays...
931 
932  part->set_status(2);
933 
934  result = toHepMC.fill_next_event(*(fDecayer.get()), event().get(), -1, true, part);
935  }
936  }
937 
938  return result;
939 }
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 685 of file Pythia8Hadronizer.cc.

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

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

Referenced by initializeForInternalPartons().

◆ DJR

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 166 of file Pythia8Hadronizer.cc.

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

◆ EV1_emittedMode

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 158 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_maxVetoCount

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 155 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_MPIvetoOn

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 160 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinal

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 153 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinalMode

int Pythia8Hadronizer::EV1_nFinalMode
private

Definition at line 162 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTdefMode

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 159 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTempMode

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 157 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pThardMode

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 156 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_QEDvetoMode

int Pythia8Hadronizer::EV1_QEDvetoMode
private

Definition at line 161 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_vetoOn

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 154 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ fBeam1PZ

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 112 of file Pythia8Hadronizer.cc.

◆ fBeam2PZ

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 113 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 110 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

◆ fUserHooksVector

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

◆ lhaUP

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

Definition at line 107 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ LHEInputFileName

std::string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 106 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ nFSRveto

int Pythia8Hadronizer::nFSRveto
private

Definition at line 171 of file Pythia8Hadronizer.cc.

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

◆ nISRveto

int Pythia8Hadronizer::nISRveto
private

Definition at line 170 of file Pythia8Hadronizer.cc.

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

◆ nME

int Pythia8Hadronizer::nME
private

Definition at line 167 of file Pythia8Hadronizer.cc.

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

◆ nMEFiltered

int Pythia8Hadronizer::nMEFiltered
private

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

◆ UserHooksSet

bool Pythia8Hadronizer::UserHooksSet
private