CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
Pythia8Hadronizer Class Reference
Inheritance diagram for Pythia8Hadronizer:
gen::BaseHadronizer gen::Py8InterfaceBase

Public Member Functions

const char * classname () const override
 
void finalizeEvent () override
 
bool generatePartonsAndHadronize () override
 
bool hadronize ()
 
bool initializeForExternalPartons ()
 
bool initializeForInternalPartons () override
 
 Pythia8Hadronizer (const edm::ParameterSet &params)
 
virtual bool residualDecay ()
 
void statistics () override
 
 ~Pythia8Hadronizer ()
 
- Public Member Functions inherited from gen::BaseHadronizer
 BaseHadronizer (edm::ParameterSet const &ps)
 
edm::EventgetEDMEvent () const
 
HepMC::GenEvent * getGenEvent ()
 
GenEventInfoProductgetGenEventInfo ()
 
GenRunInfoProductgetGenRunInfo ()
 
const boost::shared_ptr
< lhef::LHERunInfo > & 
getLHERunInfo () const
 
void resetEvent (HepMC::GenEvent *event)
 
void resetEventInfo (GenEventInfoProduct *eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (lhef::LHEEvent *event)
 
void setLHERunInfo (lhef::LHERunInfo *runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
 ~BaseHadronizer ()
 
- 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 ()
 

Private Types

enum  { PP, PPbar, ElectronPositron }
 

Private Member Functions

virtual void doSetRandomEngine (CLHEP::HepRandomEngine *v) override
 
virtual 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_pTdefMode
 
int EV1_pTempMode
 
int EV1_pThardMode
 
bool EV1_vetoOn
 
double fBeam1PZ
 
double fBeam2PZ
 
PowhegHooks * fEmissionVetoHook
 
EmissionVetoHook1fEmissionVetoHook1
 
int fInitialState
 
JetMatchingHookfJetMatchingHook
 
Pythia8::JetMatchingMadgraph * fJetMatchingPy8InternalHook
 
Pythia8::amcnlo_unitarised_interface * fMergingHook
 
UserHooks * fReweightPtHatRapUserHook
 
UserHooks * fReweightRapUserHook
 
UserHooks * fReweightUserHook
 
std::auto_ptr< LHAupLesHoucheslhaUP
 
string LHEInputFileName
 
int nFSRveto
 
int NHooks
 
int nISRveto
 
int nME
 
int nMEFiltered
 
std::string slhafile_
 

Static Private Attributes

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

Additional Inherited Members

- Protected Member Functions inherited from gen::BaseHadronizer
std::auto_ptr< HepMC::GenEvent > & event ()
 
std::auto_ptr
< GenEventInfoProduct > & 
eventInfo ()
 
lhef::LHEEventlheEvent ()
 
lhef::LHERunInfolheRunInfo ()
 
GenRunInfoProductrunInfo ()
 
- Protected Attributes inherited from gen::Py8InterfaceBase
HepMC::IO_AsciiParticles * ascii_io
 
std::auto_ptr< Pythia8::Pythia > fDecayer
 
std::auto_ptr< Pythia8::Pythia > fMasterGen
 
ParameterCollector fParameters
 
unsigned int maxEventsToPrint
 
bool pythiaHepMCVerbosity
 
bool pythiaHepMCVerbosityParticles
 
unsigned int pythiaPylistVerbosity
 
HepMC::Pythia8ToHepMC toHepMC
 

Detailed Description

Definition at line 56 of file Pythia8Hadronizer.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 137 of file Pythia8Hadronizer.cc.

References gen::ParameterCollector::begin(), edm::errors::Configuration, ElectronPositron, gen::ParameterCollector::end(), EV1_emittedMode, EV1_maxVetoCount, EV1_MPIvetoOn, EV1_nFinal, EV1_pTdefMode, EV1_pTempMode, EV1_pThardMode, EV1_vetoOn, edm::hlt::Exception, edm::ParameterSet::exists(), python.connectstrParser::f1, ztee::fd, fEmissionVetoHook1, fInitialState, fJetMatchingHook, gen::Py8InterfaceBase::fMasterGen, gen::Py8InterfaceBase::fParameters, fReweightPtHatRapUserHook, fReweightRapUserHook, fReweightUserHook, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), geometryCSVtoXML::line, NHooks, PP, PPbar, slhafile_, AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

137  :
138  BaseHadronizer(params), Py8InterfaceBase(params),
139  comEnergy(params.getParameter<double>("comEnergy")),
140  LHEInputFileName(params.getUntrackedParameter<string>("LHEInputFileName","")),
141  fInitialState(PP),
145  NHooks(0)
146 {
147 
148  // J.Y.: the following 3 parameters are hacked "for a reason"
149  //
150  if ( params.exists( "PPbarInitialState" ) )
151  {
152  if ( fInitialState == PP )
153  {
155  edm::LogImportant("GeneratorInterface|Pythia8Interface")
156  << "Pythia8 will be initialized for PROTON-ANTIPROTON INITIAL STATE. "
157  << "This is a user-request change from the DEFAULT PROTON-PROTON initial state.";
158  }
159  else
160  {
161  // probably need to throw on attempt to override ?
162  }
163  }
164  else if ( params.exists( "ElectronPositronInitialState" ) )
165  {
166  if ( fInitialState == PP )
167  {
169  edm::LogInfo("GeneratorInterface|Pythia8Interface")
170  << "Pythia8 will be initialized for ELECTRON-POSITRON INITIAL STATE. "
171  << "This is a user-request change from the DEFAULT PROTON-PROTON initial state.";
172  }
173  else
174  {
175  // probably need to throw on attempt to override ?
176  }
177  }
178  else if ( params.exists( "ElectronProtonInitialState" ) || params.exists( "PositronProtonInitialState" ) )
179  {
180  // throw on unknown initial state !
181  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
182  <<" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
183  }
184 
185  if( params.exists( "SLHAFileForPythia8" ) ) {
186  std::string slhafilenameshort = params.getParameter<string>("SLHAFileForPythia8");
187  edm::FileInPath f1( slhafilenameshort );
188 
189  fMasterGen->settings.mode("SLHA:readFrom", 2);
190  fMasterGen->settings.word("SLHA:file", f1.fullPath());
191 
193  line != fParameters.end(); ++line ) {
194  if (line->find("SLHA:file") != std::string::npos)
195  throw cms::Exception("PythiaError") << "Attempted to set SLHA file name twice, "
196  << "using Pythia8 card SLHA:file and Pythia8Interface card SLHAFileForPythia8"
197  << std::endl;
198  }
199  }
200  else if( params.exists( "SLHATableForPythia8" ) ) {
201  std::string slhatable = params.getParameter<string>("SLHATableForPythia8");
202 
203  char tempslhaname[] = "pythia8SLHAtableXXXXXX";
204  int fd = mkstemp(tempslhaname);
205  write(fd,slhatable.c_str(),slhatable.size());
206  close(fd);
207 
208  slhafile_ = tempslhaname;
209 
210  fMasterGen->settings.mode("SLHA:readFrom", 2);
211  fMasterGen->settings.word("SLHA:file", slhafile_);
212 
214  line != fParameters.end(); ++line ) {
215  if (line->find("SLHA:file") != std::string::npos)
216  throw cms::Exception("PythiaError") << "Attempted to set SLHA file name twice, "
217  << "using Pythia8 card SLHA:file and Pythia8Interface card SLHATableForPythia8"
218  << std::endl;
219  }
220  }
221 
222  // Reweight user hook
223  //
224  if( params.exists( "reweightGen" ) )
226  if( params.exists( "reweightGenRap" ) )
227  {
228  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGenRap";
229  edm::ParameterSet rgrParams =
230  params.getParameter<edm::ParameterSet>("reweightGenRap");
232  new RapReweightUserHook(rgrParams.getParameter<std::string>("yLabSigmaFunc"),
233  rgrParams.getParameter<double>("yLabPower"),
234  rgrParams.getParameter<std::string>("yCMSigmaFunc"),
235  rgrParams.getParameter<double>("yCMPower"),
236  rgrParams.getParameter<double>("pTHatMin"),
237  rgrParams.getParameter<double>("pTHatMax"));
238  edm::LogInfo("Pythia8Interface") << "End setup for reweightGenRap";
239  }
240  if( params.exists( "reweightGenPtHatRap" ) )
241  {
242  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGenPtHatRap";
243  edm::ParameterSet rgrParams =
244  params.getParameter<edm::ParameterSet>("reweightGenPtHatRap");
246  new PtHatRapReweightUserHook(rgrParams.getParameter<std::string>("yLabSigmaFunc"),
247  rgrParams.getParameter<double>("yLabPower"),
248  rgrParams.getParameter<std::string>("yCMSigmaFunc"),
249  rgrParams.getParameter<double>("yCMPower"),
250  rgrParams.getParameter<double>("pTHatMin"),
251  rgrParams.getParameter<double>("pTHatMax"));
252  edm::LogInfo("Pythia8Interface") << "End setup for reweightGenPtHatRap";
253  }
254 
255  if( params.exists( "useUserHook" ) )
256  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
257  <<" Obsolete parameter: useUserHook \n Please use the actual one instead \n";
258 
259  // PS matching prototype
260  //
261  if ( params.exists("jetMatching") )
262  {
263  edm::ParameterSet jmParams =
264  params.getUntrackedParameter<edm::ParameterSet>("jetMatching");
265  std::string scheme = jmParams.getParameter<std::string>("scheme");
266  if ( scheme == "Madgraph" || scheme == "MadgraphFastJet" )
267  {
268  fJetMatchingHook = new JetMatchingHook( jmParams, &fMasterGen->info );
269  }
270  }
271 
272  // Pythia8Interface emission veto
273  //
274  if ( params.exists("emissionVeto1") )
275  {
276  EV1_nFinal = -1;
277  if(params.exists("EV1_nFinal")) EV1_nFinal = params.getParameter<int>("EV1_nFinal");
278  EV1_vetoOn = true;
279  if(params.exists("EV1_vetoOn")) EV1_vetoOn = params.getParameter<bool>("EV1_vetoOn");
280  EV1_maxVetoCount = 10;
281  if(params.exists("EV1_maxVetoCount")) EV1_maxVetoCount = params.getParameter<int>("EV1_maxVetoCount");
282  EV1_pThardMode = 1;
283  if(params.exists("EV1_pThardMode")) EV1_pThardMode = params.getParameter<int>("EV1_pThardMode");
284  EV1_pTempMode = 0;
285  if(params.exists("EV1_pTempMode")) EV1_pTempMode = params.getParameter<int>("EV1_pTempMode");
286  if(EV1_pTempMode > 2 || EV1_pTempMode < 0)
287  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
288  <<" Wrong value for EV1_pTempMode code\n";
289  EV1_emittedMode = 0;
290  if(params.exists("EV1_emittedMode")) EV1_emittedMode = params.getParameter<int>("EV1_emittedMode");
291  EV1_pTdefMode = 1;
292  if(params.exists("EV1_pTdefMode")) EV1_pTdefMode = params.getParameter<int>("EV1_pTdefMode");
293  EV1_MPIvetoOn = false;
294  if(params.exists("EV1_MPIvetoOn")) EV1_MPIvetoOn = params.getParameter<bool>("EV1_MPIvetoOn");
298  }
299 
303  if(fJetMatchingHook) NHooks++;
305  if(NHooks > 1)
306  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
307  <<" Too many User Hooks. \n Please choose one from: reweightGen, reweightGenRap, reweightGenPtHatRap, jetMatching, emissionVeto1 \n";
308  if(fReweightUserHook) fMasterGen->setUserHooksPtr(fReweightUserHook);
311  if(fJetMatchingHook) fMasterGen->setUserHooksPtr(fJetMatchingHook);
312  if(fEmissionVetoHook1) {
313  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook 1 from CMSSW Pythia8Interface";
314  fMasterGen->setUserHooksPtr(fEmissionVetoHook1);
315  }
316 
317 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ParameterCollector fParameters
double comEnergy
Center-of-Mass energy.
std::auto_ptr< Pythia8::Pythia > fMasterGen
EmissionVetoHook1 * fEmissionVetoHook1
UserHooks * fReweightUserHook
BaseHadronizer(edm::ParameterSet const &ps)
bool exists(std::string const &parameterName) const
checks if a parameter exists
Pythia8::JetMatchingMadgraph * fJetMatchingPy8InternalHook
Py8InterfaceBase(edm::ParameterSet const &ps)
PowhegHooks * fEmissionVetoHook
UserHooks * fReweightPtHatRapUserHook
tuple fd
Definition: ztee.py:136
UserHooks * fReweightRapUserHook
Pythia8::amcnlo_unitarised_interface * fMergingHook
JetMatchingHook * fJetMatchingHook
const_iterator end() const
const_iterator begin() const
Pythia8Hadronizer::~Pythia8Hadronizer ( )

Definition at line 320 of file Pythia8Hadronizer.cc.

References fEmissionVetoHook, fEmissionVetoHook1, python.multivaluedict::remove(), and slhafile_.

321 {
322 // do we need to delete UserHooks/JetMatchingHook here ???
325 
326  //clean up temp file
327  if (!slhafile_.empty()) {
328  std::remove(slhafile_.c_str());
329  }
330 
331 }
EmissionVetoHook1 * fEmissionVetoHook1
PowhegHooks * fEmissionVetoHook

Member Function Documentation

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 75 of file Pythia8Hadronizer.cc.

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

Reimplemented from gen::BaseHadronizer.

Definition at line 79 of file Pythia8Hadronizer.cc.

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

Reimplemented from gen::BaseHadronizer.

Definition at line 80 of file Pythia8Hadronizer.cc.

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

Implements gen::Py8InterfaceBase.

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

623 {
624  bool lhe = lheEvent() != 0;
625 
626  // now create the GenEventInfo product from the GenEvent and fill
627  // the missing pieces
628  eventInfo().reset( new GenEventInfoProduct( event().get() ) );
629 
630  // in pythia pthat is used to subdivide samples into different bins
631  // in LHE mode the binning is done by the external ME generator
632  // which is likely not pthat, so only filling it for Py6 internal mode
633  if (!lhe) {
634  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
635  }
636 
637  eventInfo()->setDJR(DJR);
638  eventInfo()->setNMEPartons(nME);
639  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
640 
641  //******** Verbosity ********
642 
643  if (maxEventsToPrint > 0 &&
647  if (pythiaPylistVerbosity) {
648  fMasterGen->info.list(std::cout);
649  fMasterGen->event.list(std::cout);
650  }
651 
652  if (pythiaHepMCVerbosity) {
653  std::cout << "Event process = "
654  << fMasterGen->info.code() << "\n"
655  << "----------------------" << std::endl;
656  event()->print();
657  }
659  std::cout << "Event process = "
660  << fMasterGen->info.code() << "\n"
661  << "----------------------" << std::endl;
662  ascii_io->write_event(event().get());
663  }
664  }
665 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
HepMC::IO_AsciiParticles * ascii_io
std::auto_ptr< HepMC::GenEvent > & event()
lhef::LHEEvent * lheEvent()
unsigned int pythiaPylistVerbosity
std::auto_ptr< GenEventInfoProduct > & eventInfo()
unsigned int maxEventsToPrint
vector< float > DJR
tuple cout
Definition: gather_cfg.py:121
bool Pythia8Hadronizer::generatePartonsAndHadronize ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 494 of file Pythia8Hadronizer.cc.

References gen::BaseHadronizer::event(), gen::Py8InterfaceBase::fMasterGen, and gen::Py8InterfaceBase::toHepMC.

495 {
496 
497  if (!fMasterGen->next()) return false;
498 
499  event().reset(new HepMC::GenEvent);
500  return toHepMC.fill_next_event( *(fMasterGen.get()), event().get());
501 
502 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
std::auto_ptr< HepMC::GenEvent > & event()
HepMC::Pythia8ToHepMC toHepMC
bool Pythia8Hadronizer::hadronize ( )

Definition at line 505 of file Pythia8Hadronizer.cc.

References funct::abs(), JetMatchingHook::beforeHadronization(), lhef::LHEEvent::count(), DJR, gen::BaseHadronizer::event(), fEmissionVetoHook, fJetMatchingHook, fJetMatchingPy8InternalHook, gen::Py8InterfaceBase::fMasterGen, fMergingHook, lhef::LHERunInfo::kAccepted, lhef::LHERunInfo::kSelected, lhaUP, gen::BaseHadronizer::lheEvent(), LHEInputFileName, min(), nFSRveto, nISRveto, nME, nMEFiltered, JetMatchingHook::resetMatchingStatus(), and gen::Py8InterfaceBase::toHepMC.

506 {
507  DJR.resize(0);
508  nME = -1;
509  nMEFiltered = -1;
510  if(LHEInputFileName == string()) lhaUP->loadEvent(lheEvent());
511 
512  if ( fJetMatchingHook )
513  {
516  }
517 
518  bool py8next = fMasterGen->next();
519 
520  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
521  if (fMergingHook) {
522  mergeweight *= fMergingHook->getNormFactor();
523  }
524 
525 
526  //protect against 0-weight from ckkw or similar
527  if (!py8next || std::abs(mergeweight)==0.)
528  {
529  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
530  event().reset();
531  return false;
532  }
533 
535  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->GetDJR();
536  //cap size of djr vector to save storage space (keep only up to first 6 elements)
537  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
538  for (unsigned int idjr=0; idjr<ndjr; ++idjr) {
539  DJR.push_back(djrmatch[idjr]);
540  }
541 
542  nME=fJetMatchingPy8InternalHook->nMEpartons().first;
543  nMEFiltered=fJetMatchingPy8InternalHook->nMEpartons().second;
544  }
545 
546  // update LHE matching statistics
547  //
548  lheEvent()->count( lhef::LHERunInfo::kAccepted, 1.0, mergeweight );
549 
550  event().reset(new HepMC::GenEvent);
551  bool py8hepmc = toHepMC.fill_next_event( *(fMasterGen.get()), event().get());
552  if (!py8hepmc) {
553  return false;
554  }
555 
556  //add ckkw/umeps/unlops merging weight
557  if (mergeweight!=1.) {
558  event()->weights()[0] *= mergeweight;
559  }
560 
561  if (fEmissionVetoHook) {
562  nISRveto += fEmissionVetoHook->getNISRveto();
563  nFSRveto += fEmissionVetoHook->getNFSRveto();
564  }
565 
566  return true;
567 
568 
569 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
Pythia8::JetMatchingMadgraph * fJetMatchingPy8InternalHook
void count(LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0)
Definition: LHEEvent.cc:207
uint16_t size_type
PowhegHooks * fEmissionVetoHook
virtual void beforeHadronization(lhef::LHEEvent *lhee)
std::auto_ptr< HepMC::GenEvent > & event()
std::auto_ptr< LHAupLesHouches > lhaUP
lhef::LHEEvent * lheEvent()
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
Pythia8::amcnlo_unitarised_interface * fMergingHook
JetMatchingHook * fJetMatchingHook
vector< float > DJR
void resetMatchingStatus()
HepMC::Pythia8ToHepMC toHepMC
bool Pythia8Hadronizer::initializeForExternalPartons ( )

Definition at line 382 of file Pythia8Hadronizer.cc.

References edm::errors::Configuration, edm::hlt::Exception, gen::Py8InterfaceBase::fDecayer, fEmissionVetoHook, fEmissionVetoHook1, fJetMatchingHook, fJetMatchingPy8InternalHook, gen::Py8InterfaceBase::fMasterGen, fMergingHook, JetMatchingHook::init(), lhaUP, LHEInputFileName, gen::BaseHadronizer::lheRunInfo(), gen::Py8InterfaceBase::pythiaPylistVerbosity, and ntuplemaker::status.

383 {
384 
385  edm::LogInfo("Pythia8Interface") << "Initializing for external partons";
386 
387  bool status = false, status1 = false;
388 
389  if((fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) && !fEmissionVetoHook) {
390 
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 are : jetMatching, emissionVeto1 \n";
394 
395  fEmissionVetoHook = new PowhegHooks();
396 
397  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook from pythia8 code";
398  fMasterGen->setUserHooksPtr(fEmissionVetoHook);
399 
400  }
401 
402  //adapted from main89.cc in pythia8 examples
403  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
404  bool internalMerging = !(fMasterGen->settings.word("Merging:Process").compare("void")==0);
405 
406  if (internalMatching && internalMerging) {
407  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
408  <<" Only one jet matching/merging scheme can be used at a time. \n";
409  }
410 
411  if (internalMatching && !fJetMatchingPy8InternalHook) {
412  fJetMatchingPy8InternalHook = new Pythia8::JetMatchingMadgraph;
413  fMasterGen->setUserHooksPtr(fJetMatchingPy8InternalHook);
414  }
415 
416  if (internalMerging && !fMergingHook) {
417  int scheme = ( fMasterGen->settings.flag("Merging:doUMEPSTree")
418  || fMasterGen->settings.flag("Merging:doUMEPSSubt")) ?
419  1 :
420  ( ( fMasterGen->settings.flag("Merging:doUNLOPSTree")
421  || fMasterGen->settings.flag("Merging:doUNLOPSSubt")
422  || fMasterGen->settings.flag("Merging:doUNLOPSLoop")
423  || fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO")) ?
424  2 :
425  0 );
426  fMergingHook = new Pythia8::amcnlo_unitarised_interface(scheme);
427  fMasterGen->setUserHooksPtr(fMergingHook);
428  }
429 
430 
431  if(LHEInputFileName != string()) {
432 
433  edm::LogInfo("Pythia8Interface") << "Initialize direct pythia8 reading from LHE file "
434  << LHEInputFileName;
435  edm::LogInfo("Pythia8Interface") << "Some LHE information can be not stored";
436  fMasterGen->settings.mode("Beams:frameType", 4);
437  fMasterGen->settings.word("Beams:LHEF", LHEInputFileName);
438  status = fMasterGen->init();
439 
440  } else {
441 
442  lhaUP.reset(new LHAupLesHouches());
443  lhaUP->setScalesFromLHEF(fMasterGen->settings.flag("Beams:setProductionScalesFromLHEF"));
444  lhaUP->loadRunInfo(lheRunInfo());
445 
446  if ( fJetMatchingHook )
447  {
449  }
450 
451  fMasterGen->settings.mode("Beams:frameType", 5);
452  fMasterGen->setLHAupPtr(lhaUP.get());
453  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
454  status = fMasterGen->init();
455  }
456 
457  if ( pythiaPylistVerbosity > 10 )
458  {
459  if ( pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13 )
460  fMasterGen->settings.listAll();
461  if ( pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13 )
462  fMasterGen->particleData.listAll();
463  }
464 
465  // init decayer
466  fDecayer->settings.flag("ProcessLevel:all", false ); // trick
467  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true );
468  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
469  status1 = fDecayer->init();
470 
471  return (status&&status1);
472 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
EmissionVetoHook1 * fEmissionVetoHook1
Pythia8::JetMatchingMadgraph * fJetMatchingPy8InternalHook
PowhegHooks * fEmissionVetoHook
std::auto_ptr< LHAupLesHouches > lhaUP
unsigned int pythiaPylistVerbosity
lhef::LHERunInfo * lheRunInfo()
virtual void init(lhef::LHERunInfo *runInfo)
Pythia8::amcnlo_unitarised_interface * fMergingHook
JetMatchingHook * fJetMatchingHook
std::auto_ptr< Pythia8::Pythia > fDecayer
tuple status
Definition: ntuplemaker.py:245
bool Pythia8Hadronizer::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 333 of file Pythia8Hadronizer.cc.

References comEnergy, edm::errors::Configuration, ElectronPositron, edm::hlt::Exception, gen::Py8InterfaceBase::fDecayer, fInitialState, gen::Py8InterfaceBase::fMasterGen, PP, PPbar, gen::Py8InterfaceBase::pythiaPylistVerbosity, and ntuplemaker::status.

334 {
335 
336  bool status = false, status1 = false;
337 
338  if ( fInitialState == PP ) // default
339  {
340  fMasterGen->settings.mode("Beams:idA", 2212);
341  fMasterGen->settings.mode("Beams:idB", 2212);
342  }
343  else if ( fInitialState == PPbar )
344  {
345  fMasterGen->settings.mode("Beams:idA", 2212);
346  fMasterGen->settings.mode("Beams:idB", -2212);
347  }
348  else if ( fInitialState == ElectronPositron )
349  {
350  fMasterGen->settings.mode("Beams:idA", 11);
351  fMasterGen->settings.mode("Beams:idB", -11);
352  }
353  else
354  {
355  // throw on unknown initial state !
356  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
357  <<" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
358  }
359 
360  fMasterGen->settings.parm("Beams:eCM", comEnergy);
361  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
362  status = fMasterGen->init();
363 
364  if ( pythiaPylistVerbosity > 10 )
365  {
366  if ( pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13 )
367  fMasterGen->settings.listAll();
368  if ( pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13 )
369  fMasterGen->particleData.listAll();
370  }
371 
372  // init decayer
373  fDecayer->settings.flag("ProcessLevel:all", false ); // trick
374  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true );
375  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
376  status1 = fDecayer->init();
377 
378  return (status&&status1);
379 }
double comEnergy
Center-of-Mass energy.
std::auto_ptr< Pythia8::Pythia > fMasterGen
unsigned int pythiaPylistVerbosity
std::auto_ptr< Pythia8::Pythia > fDecayer
tuple status
Definition: ntuplemaker.py:245
bool Pythia8Hadronizer::residualDecay ( )
virtual

Definition at line 572 of file Pythia8Hadronizer.cc.

References HepMC::Pythia8ToHepMCA::append_event(), gen::BaseHadronizer::event(), gen::Py8InterfaceBase::fDecayer, gen::Py8InterfaceBase::fMasterGen, GenParticle::GenParticle, and query::result.

573 {
574 
575  Event* pythiaEvent = &(fMasterGen->event);
576 
577  int NPartsBeforeDecays = pythiaEvent->size();
578  int NPartsAfterDecays = event().get()->particles_size();
579 
580  if(NPartsAfterDecays == NPartsBeforeDecays) return true;
581 
582  HepMC::Pythia8ToHepMCA toHepMCA;
583  bool result = true;
584 
585  for ( int ipart=NPartsAfterDecays; ipart>NPartsBeforeDecays; ipart-- )
586  {
587 
588  HepMC::GenParticle* part = event().get()->barcode_to_particle( ipart );
589 
590  if ( part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id()) )
591  {
592  fDecayer->event.reset();
593  Particle py8part( part->pdg_id(), 93, 0, 0, 0, 0, 0, 0,
594  part->momentum().x(),
595  part->momentum().y(),
596  part->momentum().z(),
597  part->momentum().t(),
598  part->generated_mass() );
599  HepMC::GenVertex* ProdVtx = part->production_vertex();
600  py8part.vProd( ProdVtx->position().x(), ProdVtx->position().y(),
601  ProdVtx->position().z(), ProdVtx->position().t() );
602  py8part.tau( (fDecayer->particleData).tau0( part->pdg_id() ) );
603  fDecayer->event.append( py8part );
604  int nentries = fDecayer->event.size();
605  if ( !fDecayer->event[nentries-1].mayDecay() ) continue;
606  fDecayer->next();
607  int nentries1 = fDecayer->event.size();
608  if ( nentries1 <= nentries ) continue; //same number of particles, no decays...
609 
610  part->set_status(2);
611 
612  result = toHepMCA.append_event( fDecayer->event, event().get(), part);
613 
614  }
615  }
616 
617  return result;
618 
619 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
std::auto_ptr< HepMC::GenEvent > & event()
tuple result
Definition: query.py:137
part
Definition: HCALResponse.h:20
std::auto_ptr< Pythia8::Pythia > fDecayer
bool append_event(Pythia8::Event &pyev, GenEvent *evt, GenParticle *rootpart, int ibarcode=-1, Pythia8::Info *pyinfo=0, Pythia8::Settings *pyset=0)
Definition: HepMCA2.h:74
void Pythia8Hadronizer::statistics ( )
overridevirtual

Reimplemented from gen::Py8InterfaceBase.

Definition at line 475 of file Pythia8Hadronizer.cc.

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

476 {
477  fMasterGen->stat();
478 
479  if(fEmissionVetoHook) {
480  edm::LogPrint("Pythia8Interface") << "\n"
481  << "Number of ISR vetoed = " << nISRveto;
482  edm::LogPrint("Pythia8Interface")
483  << "Number of FSR vetoed = " << nFSRveto;
484  }
485 
486  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
487  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
488  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
489  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
491 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
void setInternalXSec(const XSec &xsec)
PowhegHooks * fEmissionVetoHook
GenRunInfoProduct & runInfo()

Member Data Documentation

double Pythia8Hadronizer::comEnergy
private

Center-of-Mass energy.

Definition at line 83 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 124 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), and hadronize().

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 116 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 113 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 118 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 111 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 117 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 115 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 114 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 112 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 91 of file Pythia8Hadronizer.cc.

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 92 of file Pythia8Hadronizer.cc.

PowhegHooks* Pythia8Hadronizer::fEmissionVetoHook
private
EmissionVetoHook1* Pythia8Hadronizer::fEmissionVetoHook1
private
int Pythia8Hadronizer::fInitialState
private

Definition at line 89 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons(), and Pythia8Hadronizer().

JetMatchingHook* Pythia8Hadronizer::fJetMatchingHook
private
Pythia8::JetMatchingMadgraph* Pythia8Hadronizer::fJetMatchingPy8InternalHook
private

Definition at line 103 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

Pythia8::amcnlo_unitarised_interface* Pythia8Hadronizer::fMergingHook
private

Definition at line 104 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

UserHooks* Pythia8Hadronizer::fReweightPtHatRapUserHook
private

Definition at line 98 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

UserHooks* Pythia8Hadronizer::fReweightRapUserHook
private

Definition at line 97 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

UserHooks* Pythia8Hadronizer::fReweightUserHook
private

Definition at line 96 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

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

Definition at line 86 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 85 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

int Pythia8Hadronizer::nFSRveto
private

Definition at line 129 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and statistics().

int Pythia8Hadronizer::NHooks
private

Definition at line 131 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::nISRveto
private

Definition at line 128 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and statistics().

int Pythia8Hadronizer::nME
private

Definition at line 125 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), and hadronize().

int Pythia8Hadronizer::nMEFiltered
private

Definition at line 126 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), and hadronize().

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

Definition at line 120 of file Pythia8Hadronizer.cc.

std::string Pythia8Hadronizer::slhafile_
private

Definition at line 122 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer(), and ~Pythia8Hadronizer().