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

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

Definition at line 327 of file Pythia8Hadronizer.cc.

327 {}

Member Function Documentation

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 96 of file Pythia8Hadronizer.cc.

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

Reimplemented from gen::BaseHadronizer.

Definition at line 104 of file Pythia8Hadronizer.cc.

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

Reimplemented from gen::BaseHadronizer.

Definition at line 105 of file Pythia8Hadronizer.cc.

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

Implements gen::Py8InterfaceBase.

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

893  {
894  bool lhe = lheEvent() != nullptr;
895 
896  // now create the GenEventInfo product from the GenEvent and fill
897  // the missing pieces
898  eventInfo().reset(new GenEventInfoProduct(event().get()));
899 
900  // in pythia pthat is used to subdivide samples into different bins
901  // in LHE mode the binning is done by the external ME generator
902  // which is likely not pthat, so only filling it for Py6 internal mode
903  if (!lhe) {
904  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
905  }
906 
907  eventInfo()->setDJR(DJR);
908  eventInfo()->setNMEPartons(nME);
909  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
910 
911  //******** Verbosity ********
912 
915  if (pythiaPylistVerbosity) {
916  fMasterGen->info.list();
917  fMasterGen->event.list();
918  }
919 
920  if (pythiaHepMCVerbosity) {
921  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
922  << "----------------------" << std::endl;
923  event()->print();
924  }
926  std::cout << "Event process = " << fMasterGen->info.code() << "\n"
927  << "----------------------" << std::endl;
928  ascii_io->write_event(event().get());
929  }
930  }
931 }
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 663 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.

663  {
664  DJR.resize(0);
665  nME = -1;
666  nMEFiltered = -1;
667 
668  if (fJetMatchingHook.get()) {
669  fJetMatchingHook->resetMatchingStatus();
670  fJetMatchingHook->beforeHadronization(lheEvent());
671  }
672 
673  if (!fMasterGen->next())
674  return false;
675 
676  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
677  if (fMergingHook.get()) {
678  mergeweight *= fMergingHook->getNormFactor();
679  }
680 
681  //protect against 0-weight from ckkw or similar
682  if (std::abs(mergeweight) == 0.) {
683  event().reset();
684  return false;
685  }
686 
687  if (fJetMatchingPy8InternalHook.get()) {
688  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
689  //cap size of djr vector to save storage space (keep only up to first 6 elements)
690  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
691  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
692  DJR.push_back(djrmatch[idjr]);
693  }
694 
695  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
696  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
697  }
698 
699  if (evtgenDecays.get())
700  evtgenDecays->decay();
701 
702  event().reset(new HepMC::GenEvent);
703  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
704 
705  if (!py8hepmc) {
706  return false;
707  }
708 
709  //add ckkw/umeps/unlops merging weight
710  if (mergeweight != 1.) {
711  event()->weights()[0] *= mergeweight;
712  }
713 
714  if (fEmissionVetoHook.get()) {
715  nISRveto += fEmissionVetoHook->getNISRveto();
716  nFSRveto += fEmissionVetoHook->getNFSRveto();
717  }
718 
719  //fill additional weights for systematic uncertainties
720  if (fMasterGen->info.getWeightsDetailedSize() > 0) {
721  for (const string &key : fMasterGen->info.initrwgt->weightsKeys) {
722  double wgt = (*fMasterGen->info.weights_detailed)[key];
723  event()->weights().push_back(wgt);
724  }
725  } else if (fMasterGen->info.getWeightsCompressedSize() > 0) {
726  for (unsigned int i = 0; i < fMasterGen->info.getWeightsCompressedSize(); i++) {
727  double wgt = fMasterGen->info.getWeightsCompressedValue(i);
728  event()->weights().push_back(wgt);
729  }
730  }
731 
732  // fill shower weights
733  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
734  if (fMasterGen->info.nWeights() > 1) {
735  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
736  double wgt = fMasterGen->info.weight(i);
737  event()->weights().push_back(wgt);
738  }
739  }
740 
741  // VINCIA shower weights
742  // http://vincia.hepforge.org/current/share/Vincia/htmldoc/VinciaUncertainties.html
743  if (fvincia.get()) {
744  event()->weights()[0] *= fvincia->weight(0);
745  for (int iVar = 1; iVar < fvincia->nWeights(); iVar++) {
746  event()->weights().push_back(fvincia->weight(iVar));
747  }
748  }
749 
750  // Retrieve Dire shower weights
751  if (fDire.get()) {
752  fDire->weightsPtr->calcWeight(0.);
753  fDire->weightsPtr->reset();
754 
755  //Make sure the base weight comes first
756  event()->weights()[0] *= fDire->weightsPtr->getShowerWeight("base");
757 
758  map<string, double>::iterator it;
759  for (it = fDire->weightsPtr->getShowerWeights()->begin(); it != fDire->weightsPtr->getShowerWeights()->end();
760  it++) {
761  if (it->first == "base")
762  continue;
763  event()->weights().push_back(it->second);
764  }
765  }
766 
767  return true;
768 }
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 933 of file Pythia8Hadronizer.cc.

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

933  {
934  auto genLumiInfoHeader = BaseHadronizer::getGenLumiInfoHeader();
935 
936  //fill lhe headers
937  //*FIXME* initrwgt header is corrupt due to pythia bug
938  for (const std::string &key : fMasterGen->info.headerKeys()) {
939  genLumiInfoHeader->lheHeaders().emplace_back(key, fMasterGen->info.header(key));
940  }
941 
942  //check, if it is not only nominal weight
943  int weights_number = fMasterGen->info.nWeights();
944  if (fMasterGen->info.initrwgt)
945  weights_number += fMasterGen->info.initrwgt->weightsKeys.size();
946  if (weights_number > 1) {
947  genLumiInfoHeader->weightNames().reserve(weights_number + 1);
948  genLumiInfoHeader->weightNames().push_back("nominal");
949  }
950 
951  //fill weight names
952  if (fMasterGen->info.initrwgt) {
953  for (const std::string &key : fMasterGen->info.initrwgt->weightsKeys) {
954  std::string weightgroupname;
955  for (const auto &wgtgrp : fMasterGen->info.initrwgt->weightgroups) {
956  const auto &wgtgrpwgt = wgtgrp.second.weights.find(key);
957  if (wgtgrpwgt != wgtgrp.second.weights.end()) {
958  weightgroupname = wgtgrp.first;
959  }
960  }
961 
962  std::ostringstream weightname;
963  weightname << "LHE, id = " << key << ", ";
964  if (!weightgroupname.empty()) {
965  weightname << "group = " << weightgroupname << ", ";
966  }
967  weightname << fMasterGen->info.initrwgt->weights[key].contents;
968  genLumiInfoHeader->weightNames().push_back(weightname.str());
969  }
970  }
971 
972  //fill shower labels
973  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
974  // http://home.thep.lu.se/~torbjorn/doxygen/classPythia8_1_1Info.html
975  if (fMasterGen->info.nWeights() > 1) {
976  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
977  genLumiInfoHeader->weightNames().push_back(fMasterGen->info.weightLabel(i));
978  }
979  }
980 
981  // VINCIA shower weights
982  // http://vincia.hepforge.org/current/share/Vincia/htmldoc/VinciaUncertainties.html
983  if (fvincia.get()) {
984  for (int iVar = 0; iVar < fvincia->nWeights(); iVar++) {
985  genLumiInfoHeader->weightNames().push_back(fvincia->weightLabel(iVar));
986  }
987  }
988 
989  if (fDire.get()) {
990  //Make sure the base weight comes first
991  genLumiInfoHeader->weightNames().push_back("base");
992 
993  map<string, double>::iterator it;
994  for (it = fDire->weightsPtr->getShowerWeights()->begin(); it != fDire->weightsPtr->getShowerWeights()->end();
995  it++) {
996  if (it->first == "base")
997  continue;
998  genLumiInfoHeader->weightNames().push_back(it->first);
999  }
1000  }
1001 
1002  return genLumiInfoHeader;
1003 }
genLumiInfoHeader
Definition: nano_cff.py:101
std::unique_ptr< Pythia8::Pythia > fMasterGen
std::unique_ptr< Pythia8::Dire > fDire
std::unique_ptr< Vincia::VinciaPlugin > fvincia
bool Pythia8Hadronizer::hadronize ( )

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

770  {
771  DJR.resize(0);
772  nME = -1;
773  nMEFiltered = -1;
774  if (LHEInputFileName.empty())
775  lhaUP->loadEvent(lheEvent());
776 
777  if (fJetMatchingHook.get()) {
778  fJetMatchingHook->resetMatchingStatus();
779  fJetMatchingHook->beforeHadronization(lheEvent());
780  }
781 
782  bool py8next = fMasterGen->next();
783 
784  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
785  if (fMergingHook.get()) {
786  mergeweight *= fMergingHook->getNormFactor();
787  }
788 
789  //protect against 0-weight from ckkw or similar
790  if (!py8next || std::abs(mergeweight) == 0.) {
791  lheEvent()->count(lhef::LHERunInfo::kSelected, 1.0, mergeweight);
792  event().reset();
793  return false;
794  }
795 
796  if (fJetMatchingPy8InternalHook.get()) {
797  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->getDJR();
798  //cap size of djr vector to save storage space (keep only up to first 6 elements)
799  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
800  for (unsigned int idjr = 0; idjr < ndjr; ++idjr) {
801  DJR.push_back(djrmatch[idjr]);
802  }
803 
804  nME = fJetMatchingPy8InternalHook->nMEpartons().first;
805  nMEFiltered = fJetMatchingPy8InternalHook->nMEpartons().second;
806  }
807 
808  // update LHE matching statistics
809  //
810  lheEvent()->count(lhef::LHERunInfo::kAccepted, 1.0, mergeweight);
811 
812  if (evtgenDecays.get())
813  evtgenDecays->decay();
814 
815  event().reset(new HepMC::GenEvent);
816  bool py8hepmc = toHepMC.fill_next_event(*(fMasterGen.get()), event().get());
817  if (!py8hepmc) {
818  return false;
819  }
820 
821  //add ckkw/umeps/unlops merging weight
822  if (mergeweight != 1.) {
823  event()->weights()[0] *= mergeweight;
824  }
825 
826  if (fEmissionVetoHook.get()) {
827  nISRveto += fEmissionVetoHook->getNISRveto();
828  nFSRveto += fEmissionVetoHook->getNFSRveto();
829  }
830 
831  // fill shower weights
832  // http://home.thep.lu.se/~torbjorn/pythia82html/Variations.html
833  if (fMasterGen->info.nWeights() > 1) {
834  for (int i = 0; i < fMasterGen->info.nWeights(); ++i) {
835  double wgt = fMasterGen->info.weight(i);
836  event()->weights().push_back(wgt);
837  }
838  }
839 
840  return true;
841 }
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 494 of file Pythia8Hadronizer.cc.

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

494  {
495  edm::LogInfo("Pythia8Interface") << "Initializing for external partons";
496 
497  bool status = false, status1 = false;
498 
499  fMultiUserHook.reset(new MultiUserHook);
500 
501  if (fReweightUserHook.get())
502  fMultiUserHook->addHook(fReweightUserHook.get());
503  if (fReweightEmpUserHook.get())
504  fMultiUserHook->addHook(fReweightEmpUserHook.get());
505  if (fReweightRapUserHook.get())
506  fMultiUserHook->addHook(fReweightRapUserHook.get());
507  if (fReweightPtHatRapUserHook.get())
509  if (fJetMatchingHook.get())
510  fMultiUserHook->addHook(fJetMatchingHook.get());
511  if (fEmissionVetoHook1.get()) {
512  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook 1 from CMSSW Pythia8Interface";
513  fMultiUserHook->addHook(fEmissionVetoHook1.get());
514  }
515 
516  if (fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) {
517  if (fJetMatchingHook.get() || fEmissionVetoHook1.get())
518  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
519  << " Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible "
520  "are : jetMatching, emissionVeto1 \n";
521 
522  fEmissionVetoHook.reset(new PowhegHooks());
523 
524  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook from pythia8 code";
525  fMultiUserHook->addHook(fEmissionVetoHook.get());
526  }
527 
528  bool PowhegRes = fMasterGen->settings.flag("POWHEGres:calcScales");
529  if (PowhegRes) {
530  edm::LogInfo("Pythia8Interface") << "Turning on resonance scale setting from CMSSW Pythia8Interface";
531  fPowhegResHook.reset(new PowhegResHook());
532  fMultiUserHook->addHook(fPowhegResHook.get());
533  }
534 
535  bool PowhegBB4L = fMasterGen->settings.flag("POWHEG:bb4l");
536  if (PowhegBB4L) {
537  edm::LogInfo("Pythia8Interface") << "Turning on BB4l hook from CMSSW Pythia8Interface";
538  fPowhegHooksBB4L.reset(new PowhegHooksBB4L());
539  fMultiUserHook->addHook(fPowhegHooksBB4L.get());
540  }
541 
542  //adapted from main89.cc in pythia8 examples
543  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
544  bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void");
545 
546  if (internalMatching && internalMerging) {
547  throw edm::Exception(edm::errors::Configuration, "Pythia8Interface")
548  << " Only one jet matching/merging scheme can be used at a time. \n";
549  }
550 
551  if (internalMatching) {
552  fJetMatchingPy8InternalHook.reset(new Pythia8::JetMatchingMadgraph);
554  }
555 
556  if (internalMerging) {
557  int scheme = (fMasterGen->settings.flag("Merging:doUMEPSTree") || fMasterGen->settings.flag("Merging:doUMEPSSubt"))
558  ? 1
559  : ((fMasterGen->settings.flag("Merging:doUNLOPSTree") ||
560  fMasterGen->settings.flag("Merging:doUNLOPSSubt") ||
561  fMasterGen->settings.flag("Merging:doUNLOPSLoop") ||
562  fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO"))
563  ? 2
564  : 0);
565  fMergingHook.reset(new Pythia8::amcnlo_unitarised_interface(scheme));
566  fMultiUserHook->addHook(fMergingHook.get());
567  }
568 
569  bool biasedTauDecayer = fMasterGen->settings.flag("BiasedTauDecayer:filter");
570  if (biasedTauDecayer) {
571  fBiasedTauDecayer.reset(new BiasedTauDecayer(&(fMasterGen->info),
572  &(fMasterGen->settings),
573  &(fMasterGen->particleData),
574  &(fMasterGen->rndm),
575  &(fMasterGen->couplings)));
576  std::vector<int> handledParticles;
577  handledParticles.push_back(15);
578  fMasterGen->setDecayPtr(fBiasedTauDecayer.get(), handledParticles);
579  }
580 
581  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
582  if (resonanceDecayFilter) {
585  }
586 
587  bool PTFilter = fMasterGen->settings.flag("PTFilter:filter");
588  if (PTFilter) {
589  fPTFilterHook.reset(new PTFilterHook);
590  fMultiUserHook->addHook(fPTFilterHook.get());
591  }
592 
593  if (fMultiUserHook->nHooks() > 0) {
594  fMasterGen->setUserHooksPtr(fMultiUserHook.get());
595  }
596 
597  if (!LHEInputFileName.empty()) {
598  edm::LogInfo("Pythia8Interface") << "Initialize direct pythia8 reading from LHE file " << LHEInputFileName;
599  edm::LogInfo("Pythia8Interface") << "Some LHE information can be not stored";
600  fMasterGen->settings.mode("Beams:frameType", 4);
601  fMasterGen->settings.word("Beams:LHEF", LHEInputFileName);
602  status = fMasterGen->init();
603 
604  } else {
605  lhaUP.reset(new LHAupLesHouches());
606  lhaUP->setScalesFromLHEF(fMasterGen->settings.flag("Beams:setProductionScalesFromLHEF"));
607  lhaUP->loadRunInfo(lheRunInfo());
608 
609  if (fJetMatchingHook.get()) {
610  fJetMatchingHook->init(lheRunInfo());
611  }
612 
613  fMasterGen->settings.mode("Beams:frameType", 5);
614  fMasterGen->setLHAupPtr(lhaUP.get());
615  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
616  status = fMasterGen->init();
617  }
618 
619  //clean up temp file
620  if (!slhafile_.empty()) {
621  std::remove(slhafile_.c_str());
622  }
623 
624  if (pythiaPylistVerbosity > 10) {
625  if (pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13)
626  fMasterGen->settings.listAll();
627  if (pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13)
628  fMasterGen->particleData.listAll();
629  }
630 
631  // init decayer
632  fDecayer->settings.flag("ProcessLevel:all", false); // trick
633  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true);
634  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
635  status1 = fDecayer->init();
636 
637  if (useEvtGen) {
638  edm::LogInfo("Pythia8Hadronizer") << "Creating and initializing pythia8 EvtGen plugin";
639  evtgenDecays.reset(new EvtGenDecays(fMasterGen.get(), evtgenDecFile, evtgenPdlFile));
640  for (unsigned int i = 0; i < evtgenUserFiles.size(); i++)
641  evtgenDecays->readDecayFile(evtgenUserFiles.at(i));
642  }
643 
644  return (status && status1);
645 }
std::unique_ptr< UserHooks > fReweightPtHatRapUserHook
std::unique_ptr< Pythia8::Pythia > fDecayer
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::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 329 of file Pythia8Hadronizer.cc.

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

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

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

843  {
844  Event *pythiaEvent = &(fMasterGen->event);
845 
846  int NPartsBeforeDecays = pythiaEvent->size();
847  int NPartsAfterDecays = event().get()->particles_size();
848 
849  if (NPartsAfterDecays == NPartsBeforeDecays)
850  return true;
851 
852  bool result = true;
853 
854  for (int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
855  HepMC::GenParticle *part = event().get()->barcode_to_particle(ipart);
856 
857  if (part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id())) {
858  fDecayer->event.reset();
859  Particle py8part(part->pdg_id(),
860  93,
861  0,
862  0,
863  0,
864  0,
865  0,
866  0,
867  part->momentum().x(),
868  part->momentum().y(),
869  part->momentum().z(),
870  part->momentum().t(),
871  part->generated_mass());
872  HepMC::GenVertex *ProdVtx = part->production_vertex();
873  py8part.vProd(ProdVtx->position().x(), ProdVtx->position().y(), ProdVtx->position().z(), ProdVtx->position().t());
874  py8part.tau((fDecayer->particleData).tau0(part->pdg_id()));
875  fDecayer->event.append(py8part);
876  int nentries = fDecayer->event.size();
877  if (!fDecayer->event[nentries - 1].mayDecay())
878  continue;
879  fDecayer->next();
880  int nentries1 = fDecayer->event.size();
881  if (nentries1 <= nentries)
882  continue; //same number of particles, no decays...
883 
884  part->set_status(2);
885 
886  result = toHepMC.fill_next_event(*(fDecayer.get()), event().get(), -1, true, part);
887  }
888  }
889 
890  return result;
891 }
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 647 of file Pythia8Hadronizer.cc.

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

647  {
648  fMasterGen->stat();
649 
650  if (fEmissionVetoHook.get()) {
651  edm::LogPrint("Pythia8Interface") << "\n"
652  << "Number of ISR vetoed = " << nISRveto;
653  edm::LogPrint("Pythia8Interface") << "Number of FSR vetoed = " << nFSRveto;
654  }
655 
656  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
657  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
658  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
659  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
661 }
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 108 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 116 of file Pythia8Hadronizer.cc.

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 117 of file Pythia8Hadronizer.cc.

std::unique_ptr<BiasedTauDecayer> Pythia8Hadronizer::fBiasedTauDecayer
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 114 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::unique_ptr<Vincia::VinciaPlugin> Pythia8Hadronizer::fvincia
private
std::unique_ptr<LHAupLesHouches> Pythia8Hadronizer::lhaUP
private

Definition at line 111 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

std::string Pythia8Hadronizer::LHEInputFileName
private

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