CMS 3D CMS Logo

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

Public Member Functions

const char * classname () const override
 
void finalizeEvent () override
 
bool generatePartonsAndHadronize () override
 
std::unique_ptr< GenLumiInfoHeadergetGenLumiInfoHeader () const override
 
bool hadronize ()
 
bool initializeForExternalPartons ()
 
bool initializeForInternalPartons () override
 
 Pythia8Hadronizer (const edm::ParameterSet &params)
 
virtual bool residualDecay ()
 
void statistics () override
 
 ~Pythia8Hadronizer () override
 
- Public Member Functions inherited from gen::Py8InterfaceBase
bool decay ()
 
bool declareSpecialSettings (const std::vector< std::string > &)
 
bool declareStableParticles (const std::vector< int > &)
 
void makeTmpSLHA (const std::string &)
 
void p8SetRandomEngine (CLHEP::HepRandomEngine *v)
 
 Py8InterfaceBase (edm::ParameterSet const &ps)
 
P8RndmEnginerandomEngine ()
 
bool readSettings (int)
 
 ~Py8InterfaceBase () override
 
- Public Member Functions inherited from gen::BaseHadronizer
 BaseHadronizer (edm::ParameterSet const &ps)
 
void cleanLHE ()
 
void generateLHE (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine, unsigned int ncpu)
 
edm::EventgetEDMEvent () const
 
std::unique_ptr< HepMC::GenEventgetGenEvent ()
 
std::unique_ptr< GenEventInfoProductgetGenEventInfo ()
 
GenRunInfoProductgetGenRunInfo ()
 
std::unique_ptr< lhef::LHEEventgetLHEEvent ()
 
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo () const
 
const std::string & gridpackPath () const
 
int randomIndex () const
 
const std::string & randomInitConfigDescription () const
 
void randomizeIndex (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
 
void resetEvent (std::unique_ptr< HepMC::GenEvent > event)
 
void resetEventInfo (std::unique_ptr< GenEventInfoProduct > eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (std::unique_ptr< lhef::LHEEvent > event)
 
void setLHERunInfo (std::unique_ptr< lhef::LHERunInfo > runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
virtual ~BaseHadronizer ()(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::unique_ptr< BiasedTauDecayerfBiasedTauDecayer
 
std::unique_ptr< MultiUserHookfCustomHooksVector
 
std::unique_ptr< Pythia8::Dire > fDire
 
std::unique_ptr< PowhegHooks > fEmissionVetoHook
 
std::unique_ptr< EmissionVetoHook1fEmissionVetoHook1
 
int fInitialState
 
std::unique_ptr< JetMatchingHookfJetMatchingHook
 
std::unique_ptr< Pythia8::JetMatchingMadgraph > fJetMatchingPy8InternalHook
 
std::unique_ptr< Pythia8::amcnlo_unitarised_interface > fMergingHook
 
std::unique_ptr< MultiUserHookfMultiUserHook
 
std::unique_ptr< PowhegHooksBB4LfPowhegHooksBB4L
 
std::unique_ptr< PowhegResHookfPowhegResHook
 
std::unique_ptr< PTFilterHookfPTFilterHook
 
std::unique_ptr< ResonanceDecayFilterHookfResonanceDecayFilterHook
 
std::unique_ptr< UserHooks > fReweightEmpUserHook
 
std::unique_ptr< UserHooks > fReweightPtHatRapUserHook
 
std::unique_ptr< UserHooks > fReweightRapUserHook
 
std::unique_ptr< UserHooks > fReweightUserHook
 
std::shared_ptr< TopRecoilHookfTopRecoilHook
 
std::unique_ptr< Vincia::VinciaPlugin > fvincia
 
std::unique_ptr< LHAupLesHoucheslhaUP
 
std::string LHEInputFileName
 
int nFSRveto
 
int nISRveto
 
int nME
 
int nMEFiltered
 

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< 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 82 of file Pythia8Hadronizer.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 185 of file Pythia8Hadronizer.cc.

References edm::errors::Configuration, beamerCreator::create(), 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, fDire, fEmissionVetoHook1, fInitialState, fJetMatchingHook, gen::Py8InterfaceBase::fMasterGen, fReweightEmpUserHook, fReweightPtHatRapUserHook, fReweightRapUserHook, fReweightUserHook, fvincia, reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), PP, PPbar, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 346 of file Pythia8Hadronizer.cc.

346 {}

Member Function Documentation

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 99 of file Pythia8Hadronizer.cc.

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

Reimplemented from gen::BaseHadronizer.

Definition at line 107 of file Pythia8Hadronizer.cc.

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

Reimplemented from gen::BaseHadronizer.

Definition at line 108 of file Pythia8Hadronizer.cc.

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

Implements gen::Py8InterfaceBase.

Definition at line 942 of file Pythia8Hadronizer.cc.

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

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

Implements gen::Py8InterfaceBase.

Definition at line 712 of file Pythia8Hadronizer.cc.

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

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

Reimplemented from gen::BaseHadronizer.

Definition at line 982 of file Pythia8Hadronizer.cc.

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

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

Definition at line 819 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, min(), nFSRveto, nISRveto, nME, nMEFiltered, and gen::Py8InterfaceBase::toHepMC.

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

Definition at line 528 of file Pythia8Hadronizer.cc.

References 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, fMultiUserHook, fPowhegHooksBB4L, fPowhegResHook, fPTFilterHook, fResonanceDecayFilterHook, fReweightEmpUserHook, fReweightPtHatRapUserHook, fReweightRapUserHook, fReweightUserHook, fTopRecoilHook, mps_fire::i, lhaUP, LHEInputFileName, gen::BaseHadronizer::lheRunInfo(), gen::Py8InterfaceBase::pythiaPylistVerbosity, MatrixUtil::remove(), gen::Py8InterfaceBase::slhafile_, mps_update::status, and gen::Py8InterfaceBase::useEvtGen.

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

Implements gen::Py8InterfaceBase.

Definition at line 348 of file Pythia8Hadronizer.cc.

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

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

Definition at line 892 of file Pythia8Hadronizer.cc.

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

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

Reimplemented from gen::Py8InterfaceBase.

Definition at line 696 of file Pythia8Hadronizer.cc.

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

696  {
697  fMasterGen->stat();
698 
699  if (fEmissionVetoHook.get()) {
700  edm::LogPrint("Pythia8Interface") << "\n"
701  << "Number of ISR vetoed = " << nISRveto;
702  edm::LogPrint("Pythia8Interface") << "Number of FSR vetoed = " << nFSRveto;
703  }
704 
705  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
706  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
707  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
708  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
710 }
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
std::unique_ptr< PowhegHooks > fEmissionVetoHook
std::unique_ptr< Pythia8::Pythia > fMasterGen

Member Data Documentation

double Pythia8Hadronizer::comEnergy
private

Center-of-Mass energy.

Definition at line 111 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 175 of file Pythia8Hadronizer.cc.

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

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 167 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 164 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 169 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 162 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_nFinalMode
private

Definition at line 171 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 168 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 166 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 165 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_QEDvetoMode
private

Definition at line 170 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 163 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 119 of file Pythia8Hadronizer.cc.

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 120 of file Pythia8Hadronizer.cc.

std::unique_ptr<BiasedTauDecayer> Pythia8Hadronizer::fBiasedTauDecayer
private
std::unique_ptr<MultiUserHook> Pythia8Hadronizer::fCustomHooksVector
private
std::unique_ptr<Pythia8::Dire> Pythia8Hadronizer::fDire
private
std::unique_ptr<PowhegHooks> Pythia8Hadronizer::fEmissionVetoHook
private
std::unique_ptr<EmissionVetoHook1> Pythia8Hadronizer::fEmissionVetoHook1
private
int Pythia8Hadronizer::fInitialState
private

Definition at line 117 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons(), and Pythia8Hadronizer().

std::unique_ptr<JetMatchingHook> Pythia8Hadronizer::fJetMatchingHook
private
std::unique_ptr<Pythia8::JetMatchingMadgraph> Pythia8Hadronizer::fJetMatchingPy8InternalHook
private
std::unique_ptr<Pythia8::amcnlo_unitarised_interface> Pythia8Hadronizer::fMergingHook
private
std::unique_ptr<MultiUserHook> Pythia8Hadronizer::fMultiUserHook
private
std::unique_ptr<PowhegHooksBB4L> Pythia8Hadronizer::fPowhegHooksBB4L
private
std::unique_ptr<PowhegResHook> Pythia8Hadronizer::fPowhegResHook
private
std::unique_ptr<PTFilterHook> Pythia8Hadronizer::fPTFilterHook
private
std::unique_ptr<ResonanceDecayFilterHook> Pythia8Hadronizer::fResonanceDecayFilterHook
private
std::unique_ptr<UserHooks> Pythia8Hadronizer::fReweightEmpUserHook
private
std::unique_ptr<UserHooks> Pythia8Hadronizer::fReweightPtHatRapUserHook
private
std::unique_ptr<UserHooks> Pythia8Hadronizer::fReweightRapUserHook
private
std::unique_ptr<UserHooks> Pythia8Hadronizer::fReweightUserHook
private
std::shared_ptr<TopRecoilHook> Pythia8Hadronizer::fTopRecoilHook
private
std::unique_ptr<Vincia::VinciaPlugin> Pythia8Hadronizer::fvincia
private
std::unique_ptr<LHAupLesHouches> Pythia8Hadronizer::lhaUP
private

Definition at line 114 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

std::string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 113 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

int Pythia8Hadronizer::nFSRveto
private

Definition at line 180 of file Pythia8Hadronizer.cc.

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

int Pythia8Hadronizer::nISRveto
private

Definition at line 179 of file Pythia8Hadronizer.cc.

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

int Pythia8Hadronizer::nME
private

Definition at line 176 of file Pythia8Hadronizer.cc.

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

int Pythia8Hadronizer::nMEFiltered
private

Definition at line 177 of file Pythia8Hadronizer.cc.

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

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

Definition at line 173 of file Pythia8Hadronizer.cc.