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< TopRecoilHookfTopRecoilHook
 
std::shared_ptr< UserHooksVector > fUserHooksVector
 
std::shared_ptr< LHAupLesHoucheslhaUP
 
std::string LHEInputFileName
 
int nFSRveto
 
int nISRveto
 
int nME
 
int nMEFiltered
 
bool UserHooksSet
 

Static Private Attributes

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

Additional Inherited Members

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

Detailed Description

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

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

347 {}

Member Function Documentation

◆ classname()

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 97 of file Pythia8Hadronizer.cc.

97 { return "Pythia8Hadronizer"; }

◆ doSetRandomEngine()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 102 of file Pythia8Hadronizer.cc.

References findQualityFiles::v.

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

◆ doSharedResources()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 103 of file Pythia8Hadronizer.cc.

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

◆ finalizeEvent()

void Pythia8Hadronizer::finalizeEvent ( )
overridevirtual

Implements gen::Py8InterfaceBase.

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

983  {
984  bool lhe = lheEvent() != nullptr;
985 
986  // protection against empty weight container
987  if ((event()->weights()).empty())
988  (event()->weights()).push_back(1.);
989 
990  // now create the GenEventInfo product from the GenEvent and fill
991  // the missing pieces
992  eventInfo() = std::make_unique<GenEventInfoProduct>(event().get());
993 
994  // in pythia pthat is used to subdivide samples into different bins
995  // in LHE mode the binning is done by the external ME generator
996  // which is likely not pthat, so only filling it for Py6 internal mode
997  if (!lhe) {
998  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
999  }
1000 
1001  eventInfo()->setDJR(DJR);
1002  eventInfo()->setNMEPartons(nME);
1003  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
1004 
1005  //******** Verbosity ********
1006 
1008  maxEventsToPrint--;
1009  if (pythiaPylistVerbosity) {
1010  fMasterGen->info.list();
1011  fMasterGen->event.list();
1012  }
1013 
1014  if (pythiaHepMCVerbosity) {
1015  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
1016  << "----------------------" << std::endl;
1017  event()->print();
1018  }
1020  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
1021  << "----------------------" << std::endl;
1022  ascii_io->write_event(event().get());
1023  }
1024  }
1025 }
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 743 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.

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

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

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

◆ hadronize()

bool Pythia8Hadronizer::hadronize ( )

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

855  {
856  DJR.resize(0);
857  nME = -1;
858  nMEFiltered = -1;
859  if (LHEInputFileName.empty())
860  lhaUP->loadEvent(lheEvent());
861 
862  if (fJetMatchingHook.get()) {
863  fJetMatchingHook->resetMatchingStatus();
864  fJetMatchingHook->beforeHadronization(lheEvent());
865  }
866 
867  bool py8next = fMasterGen->next();
868 
869  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
870  if (fMergingHook.get()) {
871  mergeweight *= fMergingHook->getNormFactor();
872  }
873 
874  //protect against 0-weight from ckkw or similar
875  if (!py8next || std::abs(mergeweight) == 0.) {
876  lheEvent()->count(lhef::LHERunInfo::kSelected, 1.0, mergeweight);
877  event().reset();
878  return false;
879  }
880 
881  if (fJetMatchingPy8InternalHook.get()) {
882  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
883  //cap size of djr vector to save storage space (keep only up to first 6 elements)
884  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
885  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
886  DJR.push_back(djrmatch[idjr]);
887  }
888 
889  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
890  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
891  }
892 
893  // update LHE matching statistics
894  //
895  lheEvent()->count(lhef::LHERunInfo::kAccepted, 1.0, mergeweight);
896 
897  if (evtgenDecays.get())
898  evtgenDecays->decay();
899 
900  event() = std::make_unique<HepMC::GenEvent>();
901 
902  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
903 
904  if (!py8hepmc) {
905  return false;
906  }
907 
908  // 0th weight is not filled anymore since v8.30x, pushback manually
909  event()->weights().push_back(fMasterGen->info.weight());
910 
911  //add ckkw/umeps/unlops merging weight
912  if (mergeweight != 1.) {
913  event()->weights()[0] *= mergeweight;
914  }
915 
916  if (fEmissionVetoHook.get()) {
917  nISRveto += fEmissionVetoHook->getNISRveto();
918  nFSRveto += fEmissionVetoHook->getNFSRveto();
919  }
920 
921  // fill shower weights
922  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
923  if (fMasterGen->info.nWeights() > 1) {
924  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
925  double wgt = fMasterGen->info.weight(i);
926  event()->weights().push_back(wgt);
927  }
928  }
929 
930  return true;
931 }
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 539 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, fTopRecoilHook, fUserHooksVector, mps_fire::i, lhaUP, LHEInputFileName, gen::BaseHadronizer::lheRunInfo(), push_back(), gen::Py8InterfaceBase::pythiaPylistVerbosity, MatrixUtil::remove(), generator_cfi::scheme, gen::Py8InterfaceBase::slhafile_, mps_update::status, gen::Py8InterfaceBase::useEvtGen, and UserHooksSet.

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

◆ initializeForInternalPartons()

bool Pythia8Hadronizer::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 349 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, fTopRecoilHook, fUserHooksVector, mps_fire::i, gen::BaseHadronizer::lheFile_, PP, PPbar, push_back(), gen::Py8InterfaceBase::pythiaPylistVerbosity, MatrixUtil::remove(), generator_cfi::scheme, gen::Py8InterfaceBase::slhafile_, mps_update::status, gen::Py8InterfaceBase::useEvtGen, and UserHooksSet.

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

◆ residualDecay()

bool Pythia8Hadronizer::residualDecay ( )
virtual

Definition at line 933 of file Pythia8Hadronizer.cc.

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

933  {
934  Event *pythiaEvent = &(fMasterGen->event);
935 
936  int NPartsBeforeDecays = pythiaEvent->size();
937  int NPartsAfterDecays = event().get()->particles_size();
938 
939  if (NPartsAfterDecays == NPartsBeforeDecays)
940  return true;
941 
942  bool result = true;
943 
944  for (int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
945  HepMC::GenParticle *part = event().get()->barcode_to_particle(ipart);
946 
947  if (part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id())) {
948  fDecayer->event.reset();
949  Particle py8part(part->pdg_id(),
950  93,
951  0,
952  0,
953  0,
954  0,
955  0,
956  0,
957  part->momentum().x(),
958  part->momentum().y(),
959  part->momentum().z(),
960  part->momentum().t(),
961  part->generated_mass());
962  HepMC::GenVertex *ProdVtx = part->production_vertex();
963  py8part.vProd(ProdVtx->position().x(), ProdVtx->position().y(), ProdVtx->position().z(), ProdVtx->position().t());
964  py8part.tau((fDecayer->particleData).tau0(part->pdg_id()));
965  fDecayer->event.append(py8part);
966  int nentries = fDecayer->event.size();
967  if (!fDecayer->event[nentries - 1].mayDecay())
968  continue;
969  fDecayer->next();
970  int nentries1 = fDecayer->event.size();
971  if (nentries1 <= nentries)
972  continue; //same number of particles, no decays...
973 
974  part->set_status(2);
975 
976  result = toHepMC.fill_next_event(*(fDecayer.get()), event().get(), -1, true, part);
977  }
978  }
979 
980  return result;
981 }
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 727 of file Pythia8Hadronizer.cc.

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

727  {
728  fMasterGen->stat();
729 
730  if (fEmissionVetoHook.get()) {
731  edm::LogPrint("Pythia8Interface") << "\n"
732  << "Number of ISR vetoed = " << nISRveto;
733  edm::LogPrint("Pythia8Interface") << "Number of FSR vetoed = " << nFSRveto;
734  }
735 
736  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
737  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
738  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
739  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
741 }
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 106 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ DJR

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 172 of file Pythia8Hadronizer.cc.

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

◆ EV1_emittedMode

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 164 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_maxVetoCount

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 161 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_MPIvetoOn

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 166 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinal

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 159 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_nFinalMode

int Pythia8Hadronizer::EV1_nFinalMode
private

Definition at line 168 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTdefMode

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 165 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pTempMode

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 163 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_pThardMode

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 162 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_QEDvetoMode

int Pythia8Hadronizer::EV1_QEDvetoMode
private

Definition at line 167 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ EV1_vetoOn

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 160 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

◆ fBeam1PZ

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 114 of file Pythia8Hadronizer.cc.

◆ fBeam2PZ

double Pythia8Hadronizer::fBeam2PZ
private

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

Referenced by initializeForInternalPartons(), and Pythia8Hadronizer().

◆ fJetMatchingHook

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

◆ fJetMatchingPy8InternalHook

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

◆ fMergingHook

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

◆ fPowhegHooksBB4L

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

◆ fPowhegResHook

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

◆ fPTFilterHook

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

◆ fResonanceDecayFilterHook

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

◆ fReweightEmpUserHook

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

◆ fReweightPtHatRapUserHook

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

◆ fReweightRapUserHook

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

◆ fReweightUserHook

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

◆ fTopRecoilHook

std::shared_ptr<TopRecoilHook> Pythia8Hadronizer::fTopRecoilHook
private

◆ fUserHooksVector

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

◆ lhaUP

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

Definition at line 109 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ LHEInputFileName

std::string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 108 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

◆ nFSRveto

int Pythia8Hadronizer::nFSRveto
private

Definition at line 177 of file Pythia8Hadronizer.cc.

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

◆ nISRveto

int Pythia8Hadronizer::nISRveto
private

Definition at line 176 of file Pythia8Hadronizer.cc.

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

◆ nME

int Pythia8Hadronizer::nME
private

Definition at line 173 of file Pythia8Hadronizer.cc.

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

◆ nMEFiltered

int Pythia8Hadronizer::nMEFiltered
private

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

◆ UserHooksSet

bool Pythia8Hadronizer::UserHooksSet
private