CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
Pythia8Hadronizer Class Reference
Inheritance diagram for Pythia8Hadronizer:
gen::Py8InterfaceBase gen::BaseHadronizer

Public Member Functions

const char * classname () const override
 
void finalizeEvent () override
 
bool generatePartonsAndHadronize () override
 
std::unique_ptr< GenLumiInfoHeadergetGenLumiInfoHeader () const override
 
bool hadronize ()
 
bool initializeForExternalPartons ()
 
bool initializeForInternalPartons () override
 
 Pythia8Hadronizer (const edm::ParameterSet &params)
 
virtual bool residualDecay ()
 
void statistics () override
 
 ~Pythia8Hadronizer () override
 
- Public Member Functions inherited from gen::Py8InterfaceBase
bool decay ()
 
bool declareSpecialSettings (const std::vector< std::string > &)
 
bool declareStableParticles (const std::vector< int > &)
 
void makeTmpSLHA (const std::string &)
 
void p8SetRandomEngine (CLHEP::HepRandomEngine *v)
 
 Py8InterfaceBase (edm::ParameterSet const &ps)
 
P8RndmEnginerandomEngine ()
 
bool readSettings (int)
 
 ~Py8InterfaceBase () override
 
- Public Member Functions inherited from gen::BaseHadronizer
 BaseHadronizer (edm::ParameterSet const &ps)
 
void cleanLHE ()
 
void generateLHE (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine, unsigned int ncpu)
 
edm::EventgetEDMEvent () const
 
std::unique_ptr< HepMC::GenEventgetGenEvent ()
 
std::unique_ptr< HepMC3::GenEvent > getGenEvent3 ()
 
std::unique_ptr< GenEventInfoProductgetGenEventInfo ()
 
std::unique_ptr< GenEventInfoProduct3getGenEventInfo3 ()
 
GenRunInfoProductgetGenRunInfo ()
 
std::unique_ptr< lhef::LHEEventgetLHEEvent ()
 
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo () const
 
unsigned int getVHepMC ()
 
const std::string & gridpackPath () const
 
int randomIndex () const
 
const std::string & randomInitConfigDescription () const
 
void randomizeIndex (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
 
void resetEvent (std::unique_ptr< HepMC::GenEvent > event)
 
void resetEvent3 (std::unique_ptr< HepMC3::GenEvent > event3)
 
void resetEventInfo (std::unique_ptr< GenEventInfoProduct > eventInfo)
 
void resetEventInfo3 (std::unique_ptr< GenEventInfoProduct3 > eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (std::unique_ptr< lhef::LHEEvent > event)
 
void setLHERunInfo (std::unique_ptr< lhef::LHERunInfo > runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
virtual ~BaseHadronizer () noexcept(false)
 

Private Types

enum  { PP, PPbar, ElectronPositron }
 

Private Member Functions

void doSetRandomEngine (CLHEP::HepRandomEngine *v) override
 
std::vector< std::string > const & doSharedResources () const override
 

Private Attributes

double comEnergy
 Center-of-Mass energy. More...
 
vector< float > DJR
 
int EV1_emittedMode
 
int EV1_maxVetoCount
 
bool EV1_MPIvetoOn
 
int EV1_nFinal
 
int EV1_nFinalMode
 
int EV1_pTdefMode
 
int EV1_pTempMode
 
int EV1_pThardMode
 
int EV1_QEDvetoMode
 
bool EV1_vetoOn
 
double fBeam1PZ
 
double fBeam2PZ
 
std::shared_ptr< BiasedTauDecayerfBiasedTauDecayer
 
std::shared_ptr< UserHooksVector > fCustomHooksVector
 
std::shared_ptr< PowhegHooks > fEmissionVetoHook
 
std::shared_ptr< EmissionVetoHook1fEmissionVetoHook1
 
std::shared_ptr< PowhegHooksVincia > fEmissionVetoHookVincia
 
int fInitialState
 
std::shared_ptr< JetMatchingHookfJetMatchingHook
 
std::shared_ptr< Pythia8::JetMatchingMadgraph > fJetMatchingPy8InternalHook
 
std::shared_ptr< Pythia8::amcnlo_unitarised_interface > fMergingHook
 
std::shared_ptr< PowhegHooksBB4LfPowhegHooksBB4L
 
std::shared_ptr< PowhegResHookfPowhegResHook
 
std::shared_ptr< PTFilterHookfPTFilterHook
 
std::shared_ptr< ResonanceDecayFilterHookfResonanceDecayFilterHook
 
std::shared_ptr< UserHooks > fReweightEmpUserHook
 
std::shared_ptr< UserHooks > fReweightPtHatRapUserHook
 
std::shared_ptr< UserHooks > fReweightRapUserHook
 
std::shared_ptr< UserHooks > fReweightUserHook
 
std::shared_ptr< UserHooksVector > fUserHooksVector
 
std::shared_ptr< LHAupLesHoucheslhaUP
 
std::string LHEInputFileName
 
int nFSRveto
 
int nISRveto
 
int nME
 
int nMEFiltered
 
bool UserHooksSet
 

Static Private Attributes

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

Additional Inherited Members

- Protected Member Functions inherited from gen::BaseHadronizer
std::unique_ptr< HepMC::GenEvent > & event ()
 
std::unique_ptr< HepMC3::GenEvent > & event3 ()
 
std::unique_ptr< GenEventInfoProduct > & eventInfo ()
 
std::unique_ptr< GenEventInfoProduct3 > & eventInfo3 ()
 
lhef::LHEEventlheEvent ()
 
lhef::LHERunInfolheRunInfo ()
 
GenRunInfoProductrunInfo ()
 
- Protected Attributes inherited from gen::Py8InterfaceBase
HepMC::IO_AsciiParticles * ascii_io
 
std::shared_ptr< Pythia8::EvtGenDecays > evtgenDecays
 
std::string evtgenDecFile
 
std::string evtgenPdlFile
 
std::vector< std::string > evtgenUserFiles
 
std::unique_ptr< Pythia8::Pythia > fDecayer
 
std::unique_ptr< Pythia8::Pythia > fMasterGen
 
edm::ParameterSet fParameters
 
unsigned int maxEventsToPrint
 
bool pythiaHepMCVerbosity
 
bool pythiaHepMCVerbosityParticles
 
unsigned int pythiaPylistVerbosity
 
std::string slhafile_
 
HepMC::Pythia8ToHepMC toHepMC
 
bool useEvtGen
 
- Protected Attributes inherited from gen::BaseHadronizer
unsigned int ivhepmc = 2
 
std::string lheFile_
 
int randomIndex_
 

Detailed Description

Definition at line 79 of file Pythia8Hadronizer.cc.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Constructor & Destructor Documentation

◆ Pythia8Hadronizer()

Pythia8Hadronizer::Pythia8Hadronizer ( const edm::ParameterSet params)

Definition at line 178 of file Pythia8Hadronizer.cc.

References edm::errors::Configuration, ElectronPositron, EV1_emittedMode, EV1_maxVetoCount, EV1_MPIvetoOn, EV1_nFinal, EV1_nFinalMode, EV1_pTdefMode, EV1_pTempMode, EV1_pThardMode, EV1_QEDvetoMode, EV1_vetoOn, Exception, edm::ParameterSet::exists(), fCustomHooksVector, fEmissionVetoHook1, fInitialState, fJetMatchingHook, gen::Py8InterfaceBase::fMasterGen, fReweightEmpUserHook, fReweightPtHatRapUserHook, fReweightRapUserHook, fReweightUserHook, get, edm::ParameterSet::getParameter(), gen::BaseHadronizer::ivhepmc, submitPVValidationJobs::params, PP, PPbar, push_back(), generator_cfi::scheme, AlCaHLTBitMon_QueryRunRegistry::string, and gen::Py8InterfaceBase::toHepMC.

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

◆ ~Pythia8Hadronizer()

Pythia8Hadronizer::~Pythia8Hadronizer ( )
override

Definition at line 343 of file Pythia8Hadronizer.cc.

343 {}

Member Function Documentation

◆ classname()

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 96 of file Pythia8Hadronizer.cc.

96 { return "Pythia8Hadronizer"; }

◆ doSetRandomEngine()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 101 of file Pythia8Hadronizer.cc.

References findQualityFiles::v.

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

◆ doSharedResources()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 102 of file Pythia8Hadronizer.cc.

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

◆ finalizeEvent()

void Pythia8Hadronizer::finalizeEvent ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 964 of file Pythia8Hadronizer.cc.

References gen::Py8InterfaceBase::ascii_io, gather_cfg::cout, DJR, relativeConstraints::empty, gen::BaseHadronizer::event(), gen::BaseHadronizer::eventInfo(), gen::Py8InterfaceBase::fMasterGen, gen::BaseHadronizer::lheEvent(), gen::Py8InterfaceBase::maxEventsToPrint, nME, nMEFiltered, push_back(), gen::Py8InterfaceBase::pythiaHepMCVerbosity, gen::Py8InterfaceBase::pythiaHepMCVerbosityParticles, gen::Py8InterfaceBase::pythiaPylistVerbosity, and hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights.

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

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

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

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

◆ hadronize()

bool Pythia8Hadronizer::hadronize ( )

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

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

◆ initializeForExternalPartons()

bool Pythia8Hadronizer::initializeForExternalPartons ( )

Definition at line 527 of file Pythia8Hadronizer.cc.

References l1ct::clear(), edm::errors::Configuration, gen::Py8InterfaceBase::evtgenDecays, gen::Py8InterfaceBase::evtgenDecFile, gen::Py8InterfaceBase::evtgenPdlFile, gen::Py8InterfaceBase::evtgenUserFiles, Exception, fBiasedTauDecayer, fCustomHooksVector, gen::Py8InterfaceBase::fDecayer, fEmissionVetoHook, fEmissionVetoHook1, fEmissionVetoHookVincia, 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.

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

◆ initializeForInternalPartons()

bool Pythia8Hadronizer::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 345 of file Pythia8Hadronizer.cc.

References l1ct::clear(), comEnergy, edm::errors::Configuration, ElectronPositron, gen::Py8InterfaceBase::evtgenDecays, gen::Py8InterfaceBase::evtgenDecFile, gen::Py8InterfaceBase::evtgenPdlFile, gen::Py8InterfaceBase::evtgenUserFiles, Exception, fBiasedTauDecayer, fCustomHooksVector, gen::Py8InterfaceBase::fDecayer, fEmissionVetoHook, fEmissionVetoHook1, fEmissionVetoHookVincia, 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.

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

◆ residualDecay()

bool Pythia8Hadronizer::residualDecay ( )
virtual

Definition at line 914 of file Pythia8Hadronizer.cc.

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

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

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

708  {
709  fMasterGen->stat();
710 
711  if (fEmissionVetoHook.get()) {
712  edm::LogPrint("Pythia8Interface") << "\n"
713  << "Number of ISR vetoed = " << nISRveto;
714  edm::LogPrint("Pythia8Interface") << "Number of FSR vetoed = " << nFSRveto;
715  }
716 
717  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
718  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
719  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
720  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
722 }
std::shared_ptr< PowhegHooks > fEmissionVetoHook
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
Log< level::Warning, true > LogPrint
std::unique_ptr< Pythia8::Pythia > fMasterGen

Member Data Documentation

◆ comEnergy

double Pythia8Hadronizer::comEnergy
private

Center-of-Mass energy.

Definition at line 105 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ DJR

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 168 of file Pythia8Hadronizer.cc.

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

◆ EV1_emittedMode

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 160 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_maxVetoCount

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 157 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_MPIvetoOn

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 162 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinal

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 155 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinalMode

int Pythia8Hadronizer::EV1_nFinalMode
private

Definition at line 164 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTdefMode

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 161 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTempMode

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 159 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pThardMode

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 158 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_QEDvetoMode

int Pythia8Hadronizer::EV1_QEDvetoMode
private

Definition at line 163 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_vetoOn

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 156 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ fBeam1PZ

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 113 of file Pythia8Hadronizer.cc.

◆ fBeam2PZ

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 114 of file Pythia8Hadronizer.cc.

◆ fBiasedTauDecayer

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

◆ fCustomHooksVector

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

◆ fEmissionVetoHook

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

◆ fEmissionVetoHook1

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

◆ fEmissionVetoHookVincia

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

◆ fInitialState

int Pythia8Hadronizer::fInitialState
private

Definition at line 111 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons(), and Pythia8Hadronizer().

◆ fJetMatchingHook

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

◆ fJetMatchingPy8InternalHook

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

◆ fMergingHook

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

◆ fPowhegHooksBB4L

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

◆ fPowhegResHook

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

◆ fPTFilterHook

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

◆ fResonanceDecayFilterHook

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

◆ fReweightEmpUserHook

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

◆ fReweightPtHatRapUserHook

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

◆ fReweightRapUserHook

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

◆ fReweightUserHook

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

◆ fUserHooksVector

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

◆ lhaUP

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

Definition at line 108 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ LHEInputFileName

std::string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 107 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ nFSRveto

int Pythia8Hadronizer::nFSRveto
private

Definition at line 173 of file Pythia8Hadronizer.cc.

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

◆ nISRveto

int Pythia8Hadronizer::nISRveto
private

Definition at line 172 of file Pythia8Hadronizer.cc.

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

◆ nME

int Pythia8Hadronizer::nME
private

Definition at line 169 of file Pythia8Hadronizer.cc.

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

◆ nMEFiltered

int Pythia8Hadronizer::nMEFiltered
private

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

◆ UserHooksSet

bool Pythia8Hadronizer::UserHooksSet
private