CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
< GenLumiInfoHeader
getGenLumiInfoHeader () 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
< GenEventInfoProduct
getGenEventInfo ()
 
GenRunInfoProductgetGenRunInfo ()
 
std::unique_ptr< lhef::LHEEventgetLHEEvent ()
 
const std::shared_ptr
< lhef::LHERunInfo > & 
getLHERunInfo () const
 
const std::string & gridpackPath () const
 
int randomIndex () const
 
const std::string & randomInitConfigDescription () const
 
void randomizeIndex (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
 
void resetEvent (std::unique_ptr< HepMC::GenEvent > event)
 
void resetEventInfo (std::unique_ptr< GenEventInfoProduct > eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (std::unique_ptr< lhef::LHEEvent > event)
 
void setLHERunInfo (std::unique_ptr< lhef::LHERunInfo > runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
virtual ~BaseHadronizer () noexcept(false)
 

Private Types

enum  { PP, PPbar, ElectronPositron }
 

Private Member Functions

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

Private Attributes

double comEnergy
 Center-of-Mass energy. More...
 
vector< float > DJR
 
int EV1_emittedMode
 
int EV1_maxVetoCount
 
bool EV1_MPIvetoOn
 
int EV1_nFinal
 
int EV1_nFinalMode
 
int EV1_pTdefMode
 
int EV1_pTempMode
 
int EV1_pThardMode
 
int EV1_QEDvetoMode
 
bool EV1_vetoOn
 
double fBeam1PZ
 
double fBeam2PZ
 
std::shared_ptr< BiasedTauDecayerfBiasedTauDecayer
 
std::shared_ptr< UserHooksVector > fCustomHooksVector
 
std::shared_ptr< PowhegHooks > fEmissionVetoHook
 
std::shared_ptr
< EmissionVetoHook1
fEmissionVetoHook1
 
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
< ResonanceDecayFilterHook
fResonanceDecayFilterHook
 
std::shared_ptr< UserHooks > fReweightEmpUserHook
 
std::shared_ptr< UserHooks > fReweightPtHatRapUserHook
 
std::shared_ptr< UserHooks > fReweightRapUserHook
 
std::shared_ptr< UserHooks > fReweightUserHook
 
std::shared_ptr< UserHooksVector > fUserHooksVector
 
std::shared_ptr< LHAupLesHoucheslhaUP
 
std::string LHEInputFileName
 
int nFSRveto
 
int nISRveto
 
int nME
 
int nMEFiltered
 
bool UserHooksSet
 

Static Private Attributes

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

Additional Inherited Members

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

Detailed Description

Definition at line 78 of file Pythia8Hadronizer.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 176 of file Pythia8Hadronizer.cc.

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

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

Definition at line 337 of file Pythia8Hadronizer.cc.

337 {}

Member Function Documentation

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 95 of file Pythia8Hadronizer.cc.

95 { return "Pythia8Hadronizer"; }
void Pythia8Hadronizer::doSetRandomEngine ( CLHEP::HepRandomEngine *  v)
inlineoverrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 100 of file Pythia8Hadronizer.cc.

100 { p8SetRandomEngine(v); }
void p8SetRandomEngine(CLHEP::HepRandomEngine *v)
std::vector<std::string> const& Pythia8Hadronizer::doSharedResources ( ) const
inlineoverrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 101 of file Pythia8Hadronizer.cc.

101 { return p8SharedResources; }
static const std::vector< std::string > p8SharedResources
void Pythia8Hadronizer::finalizeEvent ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 930 of file Pythia8Hadronizer.cc.

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

930  {
931  bool lhe = lheEvent() != nullptr;
932 
933  // protection against empty weight container
934  if ((event()->weights()).empty())
935  (event()->weights()).push_back(1.);
936 
937  // now create the GenEventInfo product from the GenEvent and fill
938  // the missing pieces
939  eventInfo() = std::make_unique<GenEventInfoProduct>(event().get());
940 
941  // in pythia pthat is used to subdivide samples into different bins
942  // in LHE mode the binning is done by the external ME generator
943  // which is likely not pthat, so only filling it for Py6 internal mode
944  if (!lhe) {
945  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
946  }
947 
948  eventInfo()->setDJR(DJR);
949  eventInfo()->setNMEPartons(nME);
950  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
951 
952  //******** Verbosity ********
953 
956  if (pythiaPylistVerbosity) {
957  fMasterGen->info.list();
958  fMasterGen->event.list();
959  }
960 
961  if (pythiaHepMCVerbosity) {
962  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
963  << "----------------------" << std::endl;
964  event()->print();
965  }
967  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
968  << "----------------------" << std::endl;
969  ascii_io->write_event(event().get());
970  }
971  }
972 }
HepMC::IO_AsciiParticles * ascii_io
lhef::LHEEvent * lheEvent()
unsigned int pythiaPylistVerbosity
std::unique_ptr< HepMC::GenEvent > & event()
static std::vector< std::string > checklist lhe
std::unique_ptr< GenEventInfoProduct > & eventInfo()
unsigned int maxEventsToPrint
deadvectors[0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
vector< float > DJR
tuple cout
Definition: gather_cfg.py:144
std::unique_ptr< Pythia8::Pythia > fMasterGen
bool Pythia8Hadronizer::generatePartonsAndHadronize ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 698 of file Pythia8Hadronizer.cc.

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

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

Reimplemented from gen::BaseHadronizer.

Definition at line 974 of file Pythia8Hadronizer.cc.

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

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

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

807  {
808  DJR.resize(0);
809  nME = -1;
810  nMEFiltered = -1;
811  if (LHEInputFileName.empty())
812  lhaUP->loadEvent(lheEvent());
813 
814  if (fJetMatchingHook.get()) {
815  fJetMatchingHook->resetMatchingStatus();
816  fJetMatchingHook->beforeHadronization(lheEvent());
817  }
818 
819  bool py8next = fMasterGen->next();
820 
821  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
822  if (fMergingHook.get()) {
823  mergeweight *= fMergingHook->getNormFactor();
824  }
825 
826  //protect against 0-weight from ckkw or similar
827  if (!py8next || std::abs(mergeweight) == 0.) {
828  lheEvent()->count(lhef::LHERunInfo::kSelected, 1.0, mergeweight);
829  event().reset();
830  return false;
831  }
832 
833  if (fJetMatchingPy8InternalHook.get()) {
834  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
835  //cap size of djr vector to save storage space (keep only up to first 6 elements)
836  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
837  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
838  DJR.push_back(djrmatch[idjr]);
839  }
840 
841  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
842  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
843  }
844 
845  // update LHE matching statistics
846  //
847  lheEvent()->count(lhef::LHERunInfo::kAccepted, 1.0, mergeweight);
848 
849  if (evtgenDecays.get())
850  evtgenDecays->decay();
851 
852  event() = std::make_unique<HepMC::GenEvent>();
853  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
854  if (!py8hepmc) {
855  return false;
856  }
857 
858  //add ckkw/umeps/unlops merging weight
859  if (mergeweight != 1.) {
860  event()->weights()[0] *= mergeweight;
861  }
862 
863  if (fEmissionVetoHook.get()) {
864  nISRveto += fEmissionVetoHook->getNISRveto();
865  nFSRveto += fEmissionVetoHook->getNFSRveto();
866  }
867 
868  // fill shower weights
869  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
870  if (fMasterGen->info.nWeights() > 1) {
871  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
872  double wgt = fMasterGen->info.weight(i);
873  event()->weights().push_back(wgt);
874  }
875  }
876 
877  return true;
878 }
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
bool Pythia8Hadronizer::initializeForExternalPartons ( )

Definition at line 511 of file Pythia8Hadronizer.cc.

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

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

Implements gen::Py8InterfaceBase.

Definition at line 339 of file Pythia8Hadronizer.cc.

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

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

Definition at line 880 of file Pythia8Hadronizer.cc.

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

880  {
881  Event *pythiaEvent = &(fMasterGen->event);
882 
883  int NPartsBeforeDecays = pythiaEvent->size();
884  int NPartsAfterDecays = event().get()->particles_size();
885 
886  if (NPartsAfterDecays == NPartsBeforeDecays)
887  return true;
888 
889  bool result = true;
890 
891  for (int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
892  HepMC::GenParticle *part = event().get()->barcode_to_particle(ipart);
893 
894  if (part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id())) {
895  fDecayer->event.reset();
896  Particle py8part(part->pdg_id(),
897  93,
898  0,
899  0,
900  0,
901  0,
902  0,
903  0,
904  part->momentum().x(),
905  part->momentum().y(),
906  part->momentum().z(),
907  part->momentum().t(),
908  part->generated_mass());
909  HepMC::GenVertex *ProdVtx = part->production_vertex();
910  py8part.vProd(ProdVtx->position().x(), ProdVtx->position().y(), ProdVtx->position().z(), ProdVtx->position().t());
911  py8part.tau((fDecayer->particleData).tau0(part->pdg_id()));
912  fDecayer->event.append(py8part);
913  int nentries = fDecayer->event.size();
914  if (!fDecayer->event[nentries - 1].mayDecay())
915  continue;
916  fDecayer->next();
917  int nentries1 = fDecayer->event.size();
918  if (nentries1 <= nentries)
919  continue; //same number of particles, no decays...
920 
921  part->set_status(2);
922 
923  result = toHepMC.fill_next_event(*(fDecayer.get()), event().get(), -1, true, part);
924  }
925  }
926 
927  return result;
928 }
std::unique_ptr< Pythia8::Pythia > fDecayer
tuple result
Definition: mps_fire.py:311
std::unique_ptr< HepMC::GenEvent > & event()
part
Definition: HCALResponse.h:20
HepMC::Pythia8ToHepMC toHepMC
std::unique_ptr< Pythia8::Pythia > fMasterGen
void Pythia8Hadronizer::statistics ( )
overridevirtual

Reimplemented from gen::Py8InterfaceBase.

Definition at line 682 of file Pythia8Hadronizer.cc.

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

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

double Pythia8Hadronizer::comEnergy
private

Center-of-Mass energy.

Definition at line 104 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 166 of file Pythia8Hadronizer.cc.

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

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 158 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 155 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 160 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 153 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_nFinalMode
private

Definition at line 162 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 159 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 157 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 156 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_QEDvetoMode
private

Definition at line 161 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 154 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 112 of file Pythia8Hadronizer.cc.

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 113 of file Pythia8Hadronizer.cc.

std::shared_ptr<BiasedTauDecayer> Pythia8Hadronizer::fBiasedTauDecayer
private
std::shared_ptr<UserHooksVector> Pythia8Hadronizer::fCustomHooksVector
private
std::shared_ptr<PowhegHooks> Pythia8Hadronizer::fEmissionVetoHook
private
std::shared_ptr<EmissionVetoHook1> Pythia8Hadronizer::fEmissionVetoHook1
private
int Pythia8Hadronizer::fInitialState
private

Definition at line 110 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons(), and Pythia8Hadronizer().

std::shared_ptr<JetMatchingHook> Pythia8Hadronizer::fJetMatchingHook
private
std::shared_ptr<Pythia8::JetMatchingMadgraph> Pythia8Hadronizer::fJetMatchingPy8InternalHook
private
std::shared_ptr<Pythia8::amcnlo_unitarised_interface> Pythia8Hadronizer::fMergingHook
private
std::shared_ptr<PowhegHooksBB4L> Pythia8Hadronizer::fPowhegHooksBB4L
private
std::shared_ptr<PowhegResHook> Pythia8Hadronizer::fPowhegResHook
private
std::shared_ptr<PTFilterHook> Pythia8Hadronizer::fPTFilterHook
private
std::shared_ptr<ResonanceDecayFilterHook> Pythia8Hadronizer::fResonanceDecayFilterHook
private
std::shared_ptr<UserHooks> Pythia8Hadronizer::fReweightEmpUserHook
private
std::shared_ptr<UserHooks> Pythia8Hadronizer::fReweightPtHatRapUserHook
private
std::shared_ptr<UserHooks> Pythia8Hadronizer::fReweightRapUserHook
private
std::shared_ptr<UserHooks> Pythia8Hadronizer::fReweightUserHook
private
std::shared_ptr<UserHooksVector> Pythia8Hadronizer::fUserHooksVector
private
std::shared_ptr<LHAupLesHouches> Pythia8Hadronizer::lhaUP
private

Definition at line 107 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

std::string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 106 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

int Pythia8Hadronizer::nFSRveto
private

Definition at line 171 of file Pythia8Hadronizer.cc.

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

int Pythia8Hadronizer::nISRveto
private

Definition at line 170 of file Pythia8Hadronizer.cc.

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

int Pythia8Hadronizer::nME
private

Definition at line 167 of file Pythia8Hadronizer.cc.

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

int Pythia8Hadronizer::nMEFiltered
private

Definition at line 168 of file Pythia8Hadronizer.cc.

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

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

Definition at line 164 of file Pythia8Hadronizer.cc.

bool Pythia8Hadronizer::UserHooksSet
private