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
std::auto_ptr< Pythia8::Pythia > fDecayer
 
std::auto_ptr< Pythia8::Pythia > fMasterGen
 
ParameterCollector fParameters
 
unsigned int maxEventsToPrint
 
bool pythiaHepMCVerbosity
 
unsigned int pythiaPylistVerbosity
 
HepMC::Pythia8ToHepMC toHepMC
 

Detailed Description

Definition at line 55 of file Pythia8Hadronizer.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 135 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, fEmissionVetoHook1, fInitialState, fJetMatchingHook, gen::Py8InterfaceBase::fMasterGen, gen::Py8InterfaceBase::fParameters, fReweightPtHatRapUserHook, fReweightRapUserHook, fReweightUserHook, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), geometryCSVtoXML::line, NHooks, PP, PPbar, slhafile_, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 298 of file Pythia8Hadronizer.cc.

References fEmissionVetoHook, and fEmissionVetoHook1.

299 {
300 // do we need to delete UserHooks/JetMatchingHook here ???
303 }
EmissionVetoHook1 * fEmissionVetoHook1
PowhegHooks * fEmissionVetoHook

Member Function Documentation

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 74 of file Pythia8Hadronizer.cc.

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

Reimplemented from gen::BaseHadronizer.

Definition at line 78 of file Pythia8Hadronizer.cc.

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

Reimplemented from gen::BaseHadronizer.

Definition at line 79 of file Pythia8Hadronizer.cc.

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

Implements gen::Py8InterfaceBase.

Definition at line 623 of file Pythia8Hadronizer.cc.

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

624 {
625  bool lhe = lheEvent() != 0;
626 
627  // now create the GenEventInfo product from the GenEvent and fill
628  // the missing pieces
629  eventInfo().reset( new GenEventInfoProduct( event().get() ) );
630 
631  // in pythia pthat is used to subdivide samples into different bins
632  // in LHE mode the binning is done by the external ME generator
633  // which is likely not pthat, so only filling it for Py6 internal mode
634  if (!lhe) {
635  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
636  }
637 
638  eventInfo()->setDJR(DJR);
639  eventInfo()->setNMEPartons(nME);
640  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
641 
642  //******** Verbosity ********
643 
644  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  }
658  }
659 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
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 475 of file Pythia8Hadronizer.cc.

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

476 {
477 
478  if (!fMasterGen->next()) return false;
479 
480  event().reset(new HepMC::GenEvent);
481  return toHepMC.fill_next_event( *(fMasterGen.get()), event().get());
482 
483 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
std::auto_ptr< HepMC::GenEvent > & event()
HepMC::Pythia8ToHepMC toHepMC
bool Pythia8Hadronizer::hadronize ( )

Definition at line 486 of file Pythia8Hadronizer.cc.

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

487 {
488  DJR.resize(0);
489  nME = -1;
490  nMEFiltered = -1;
491  if(LHEInputFileName == string()) lhaUP->loadEvent(lheEvent());
492 
493  if ( fJetMatchingHook )
494  {
497  }
498 
499  bool py8next = fMasterGen->next();
500 
501  double mergeweight = fMasterGen.get()->info.mergingWeight();
502 
503  //protect against 0-weight from ckkw or similar
504  if (!py8next || std::abs(mergeweight)==0.)
505  {
506  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
507  event().reset();
508  return false;
509  }
510 
512  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->GetDJR();
513  //cap size of djr vector to save storage space (keep only up to first 6 elements)
514  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
515  for (unsigned int idjr=0; idjr<ndjr; ++idjr) {
516  DJR.push_back(djrmatch[idjr]);
517  }
518 
519  nME=fJetMatchingPy8InternalHook->nMEpartons().first;
520  nMEFiltered=fJetMatchingPy8InternalHook->nMEpartons().second;
521  }
522 
523  // update LHE matching statistics
524  //
525  lheEvent()->count( lhef::LHERunInfo::kAccepted, 1.0, mergeweight );
526 
527  event().reset(new HepMC::GenEvent);
528  bool py8hepmc = toHepMC.fill_next_event( *(fMasterGen.get()), event().get());
529  if (!py8hepmc) {
530  return false;
531  }
532 
533  //add ckkw merging weight
534  if (mergeweight!=1.) {
535  event()->weights().push_back(mergeweight);
536  }
537 
538  if (fEmissionVetoHook) {
539  nISRveto += fEmissionVetoHook->getNISRveto();
540  nFSRveto += fEmissionVetoHook->getNFSRveto();
541  }
542 
543  return true;
544 
545 
546 }
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
JetMatchingHook * fJetMatchingHook
vector< float > DJR
void resetMatchingStatus()
HepMC::Pythia8ToHepMC toHepMC
bool Pythia8Hadronizer::initializeForExternalPartons ( )

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

363 {
364 
365  edm::LogInfo("Pythia8Interface") << "Initializing for external partons";
366 
367  bool status = true;
368 
369  if((fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) && !fEmissionVetoHook) {
370 
372  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
373  <<" Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible are : jetMatching, emissionVeto1 \n";
374 
375  fEmissionVetoHook = new PowhegHooks();
376 
377  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook from pythia8 code";
378  fMasterGen->setUserHooksPtr(fEmissionVetoHook);
379 
380  }
381 
382  //adapted from main89.cc in pythia8 examples
383  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
384  bool internalMerging = !(fMasterGen->settings.word("Merging:Process").compare("void")==0);
385 
386  if (internalMatching && internalMerging) {
387  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
388  <<" Only one jet matching/merging scheme can be used at a time. \n";
389  }
390 
391  if (internalMatching && !fJetMatchingPy8InternalHook) {
392  fJetMatchingPy8InternalHook = new Pythia8::JetMatchingMadgraph;
393  fMasterGen->setUserHooksPtr(fJetMatchingPy8InternalHook);
394  }
395 
396  if (internalMerging && !fMergingHook) {
397  int scheme = ( fMasterGen->settings.flag("Merging:doUMEPSTree")
398  || fMasterGen->settings.flag("Merging:doUMEPSSubt")) ?
399  1 :
400  ( ( fMasterGen->settings.flag("Merging:doUNLOPSTree")
401  || fMasterGen->settings.flag("Merging:doUNLOPSSubt")
402  || fMasterGen->settings.flag("Merging:doUNLOPSLoop")
403  || fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO")) ?
404  2 :
405  0 );
406  fMergingHook = new Pythia8::amcnlo_unitarised_interface(scheme);
407  fMasterGen->setUserHooksPtr(fMergingHook);
408  }
409 
410 
411  if(LHEInputFileName != string()) {
412 
413  edm::LogInfo("Pythia8Interface") << "Initialize direct pythia8 reading from LHE file "
414  << LHEInputFileName;
415  edm::LogInfo("Pythia8Interface") << "Some LHE information can be not stored";
416  //fMasterGen->init(LHEInputFileName);
417  fMasterGen->settings.mode("Beams:frameType", 4);
418  fMasterGen->settings.word("Beams:LHEF", LHEInputFileName);
419  status &= fMasterGen->init();
420 
421  } else {
422 
423  lhaUP.reset(new LHAupLesHouches());
424  lhaUP->loadRunInfo(lheRunInfo());
425 
426  if ( fJetMatchingHook )
427  {
429  }
430 
431  //fMasterGen->init(lhaUP.get());
432  fMasterGen->settings.mode("Beams:frameType", 5);
433  fMasterGen->setLHAupPtr(lhaUP.get());
434  status &= fMasterGen->init();
435  }
436 
437  if ( pythiaPylistVerbosity > 10 )
438  {
439  if ( pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13 )
440  fMasterGen->settings.listAll();
441  if ( pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13 )
442  fMasterGen->particleData.listAll();
443  }
444 
445  // init decayer
446  //fDecayer->readString("ProcessLevel:all = off"); // trick
447  //fDecayer->readString("ProcessLevel::resonanceDecays=on");
448  fDecayer->settings.flag("ProcessLevel:all", false ); // trick
449  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true );
450  status &= fDecayer->init();
451 
452  return status;
453 }
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 305 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.

306 {
307 
308  bool status = true;
309 
310  if ( fInitialState == PP ) // default
311  {
312  //fMasterGen->init(2212, 2212, comEnergy);
313  fMasterGen->settings.mode("Beams:idA", 2212);
314  fMasterGen->settings.mode("Beams:idB", 2212);
315  fMasterGen->settings.parm("Beams:eCM", comEnergy);
316  status &= fMasterGen->init();
317  }
318  else if ( fInitialState == PPbar )
319  {
320  //fMasterGen->init(2212, -2212, comEnergy);
321  fMasterGen->settings.mode("Beams:idA", 2212);
322  fMasterGen->settings.mode("Beams:idB", -2212);
323  fMasterGen->settings.parm("Beams:eCM", comEnergy);
324  status &= fMasterGen->init();
325  }
326  else if ( fInitialState == ElectronPositron )
327  {
328  //fMasterGen->init(11, -11, comEnergy);
329  fMasterGen->settings.mode("Beams:idA", 11);
330  fMasterGen->settings.mode("Beams:idB", -11);
331  fMasterGen->settings.parm("Beams:eCM", comEnergy);
332  status &= fMasterGen->init();
333  }
334  else
335  {
336  // throw on unknown initial state !
337  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
338  <<" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
339  }
340 
341  fMasterGen->settings.listChanged();
342 
343  if ( pythiaPylistVerbosity > 10 )
344  {
345  if ( pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13 )
346  fMasterGen->settings.listAll();
347  if ( pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13 )
348  fMasterGen->particleData.listAll();
349  }
350 
351  // init decayer
352  //fDecayer->readString("ProcessLevel:all = off"); // trick
353  //fDecayer->readString("ProcessLevel::resonanceDecays=on");
354  fDecayer->settings.flag("ProcessLevel:all", false ); // trick
355  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true );
356  status &= fDecayer->init();
357 
358  return status;
359 }
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 549 of file Pythia8Hadronizer.cc.

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

550 {
551 
552  Event* pythiaEvent = &(fMasterGen->event);
553 
554  int NPartsBeforeDecays = pythiaEvent->size();
555  int NPartsAfterDecays = event().get()->particles_size();
556  int NewBarcode = NPartsAfterDecays;
557 
558  for ( int ipart=NPartsAfterDecays; ipart>NPartsBeforeDecays; ipart-- )
559  {
560 
561  HepMC::GenParticle* part = event().get()->barcode_to_particle( ipart );
562 
563  if ( part->status() == 1 )
564  {
565  fDecayer->event.reset();
566  Particle py8part( part->pdg_id(), 93, 0, 0, 0, 0, 0, 0,
567  part->momentum().x(),
568  part->momentum().y(),
569  part->momentum().z(),
570  part->momentum().t(),
571  part->generated_mass() );
572  HepMC::GenVertex* ProdVtx = part->production_vertex();
573  py8part.vProd( ProdVtx->position().x(), ProdVtx->position().y(),
574  ProdVtx->position().z(), ProdVtx->position().t() );
575  py8part.tau( (fDecayer->particleData).tau0( part->pdg_id() ) );
576  fDecayer->event.append( py8part );
577  int nentries = fDecayer->event.size();
578  if ( !fDecayer->event[nentries-1].mayDecay() ) continue;
579  fDecayer->next();
580  int nentries1 = fDecayer->event.size();
581  if ( nentries1 <= nentries ) continue; //same number of particles, no decays...
582 
583  part->set_status(2);
584 
585  Particle& py8daughter = fDecayer->event[nentries]; // the 1st daughter
586  HepMC::GenVertex* DecVtx = new HepMC::GenVertex( HepMC::FourVector(py8daughter.xProd(),
587  py8daughter.yProd(),
588  py8daughter.zProd(),
589  py8daughter.tProd()) );
590 
591  DecVtx->add_particle_in( part ); // this will cleanup end_vertex if exists, replace with the new one
592  // I presume (vtx) barcode will be given automatically
593 
594  HepMC::FourVector pmom( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() );
595 
596  HepMC::GenParticle* daughter =
597  new HepMC::GenParticle( pmom, py8daughter.id(), 1 );
598 
599  NewBarcode++;
600  daughter->suggest_barcode( NewBarcode );
601  DecVtx->add_particle_out( daughter );
602 
603  for ( int ipart1=nentries+1; ipart1<nentries1; ipart1++ )
604  {
605  py8daughter = fDecayer->event[ipart1];
606  HepMC::FourVector pmomN( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() );
607  HepMC::GenParticle* daughterN =
608  new HepMC::GenParticle( pmomN, py8daughter.id(), 1 );
609  NewBarcode++;
610  daughterN->suggest_barcode( NewBarcode );
611  DecVtx->add_particle_out( daughterN );
612  }
613 
614  event().get()->add_vertex( DecVtx );
615 
616  }
617  }
618  return true;
619 
620 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
std::auto_ptr< HepMC::GenEvent > & event()
part
Definition: HCALResponse.h:20
std::auto_ptr< Pythia8::Pythia > fDecayer
void Pythia8Hadronizer::statistics ( )
overridevirtual

Reimplemented from gen::Py8InterfaceBase.

Definition at line 456 of file Pythia8Hadronizer.cc.

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

457 {
458  fMasterGen->stat();
459 
460  if(fEmissionVetoHook) {
461  edm::LogPrint("Pythia8Interface") << "\n"
462  << "Number of ISR vetoed = " << nISRveto;
463  edm::LogPrint("Pythia8Interface")
464  << "Number of FSR vetoed = " << nFSRveto;
465  }
466 
467  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
468  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
469  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
470  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
472 }
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 82 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 123 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), and hadronize().

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 115 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 112 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 117 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 110 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 116 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 114 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 113 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 111 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 90 of file Pythia8Hadronizer.cc.

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 91 of file Pythia8Hadronizer.cc.

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

Definition at line 88 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons(), and Pythia8Hadronizer().

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

Definition at line 102 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

Pythia8::amcnlo_unitarised_interface* Pythia8Hadronizer::fMergingHook
private

Definition at line 103 of file Pythia8Hadronizer.cc.

Referenced by initializeForExternalPartons().

UserHooks* Pythia8Hadronizer::fReweightPtHatRapUserHook
private

Definition at line 97 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

UserHooks* Pythia8Hadronizer::fReweightRapUserHook
private

Definition at line 96 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

UserHooks* Pythia8Hadronizer::fReweightUserHook
private

Definition at line 95 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

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

Definition at line 85 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 84 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

int Pythia8Hadronizer::nFSRveto
private

Definition at line 128 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and statistics().

int Pythia8Hadronizer::NHooks
private

Definition at line 130 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::nISRveto
private

Definition at line 127 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and statistics().

int Pythia8Hadronizer::nME
private

Definition at line 124 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), and hadronize().

int Pythia8Hadronizer::nMEFiltered
private

Definition at line 125 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), and hadronize().

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

Definition at line 119 of file Pythia8Hadronizer.cc.

std::string Pythia8Hadronizer::slhafile_
private

Definition at line 121 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().