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
 
MultiUserHookfMultiUserHook
 
ResonanceDecayFilterHookfResonanceDecayFilterHook
 
UserHooks * fReweightPtHatRapUserHook
 
UserHooks * fReweightRapUserHook
 
UserHooks * fReweightUserHook
 
std::auto_ptr< LHAupLesHoucheslhaUP
 
std::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
 
EvtGenDecays * evtgenDecays
 
std::string evtgenDecFile
 
std::string evtgenPdlFile
 
std::vector< std::string > evtgenUserFiles
 
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
 
bool useEvtGen
 

Detailed Description

Definition at line 66 of file Pythia8Hadronizer.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 153 of file Pythia8Hadronizer.cc.

References MultiUserHook::addHook(), 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, Exception, edm::ParameterSet::exists(), validate-o2o-wbm::f1, ztee::fd, fEmissionVetoHook1, fInitialState, fJetMatchingHook, gen::Py8InterfaceBase::fMasterGen, fMultiUserHook, gen::Py8InterfaceBase::fParameters, fReweightPtHatRapUserHook, fReweightRapUserHook, fReweightUserHook, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), geometryCSVtoXML::line, NHooks, PP, PPbar, slhafile_, AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

153  :
154  BaseHadronizer(params), Py8InterfaceBase(params),
155  comEnergy(params.getParameter<double>("comEnergy")),
156  LHEInputFileName(params.getUntrackedParameter<std::string>("LHEInputFileName","")),
157  fInitialState(PP),
161  NHooks(0)
162 {
163 
164  // J.Y.: the following 3 parameters are hacked "for a reason"
165  //
166  if ( params.exists( "PPbarInitialState" ) )
167  {
168  if ( fInitialState == PP )
169  {
171  edm::LogImportant("GeneratorInterface|Pythia8Interface")
172  << "Pythia8 will be initialized for PROTON-ANTIPROTON INITIAL STATE. "
173  << "This is a user-request change from the DEFAULT PROTON-PROTON initial state.";
174  }
175  else
176  {
177  // probably need to throw on attempt to override ?
178  }
179  }
180  else if ( params.exists( "ElectronPositronInitialState" ) )
181  {
182  if ( fInitialState == PP )
183  {
185  edm::LogInfo("GeneratorInterface|Pythia8Interface")
186  << "Pythia8 will be initialized for ELECTRON-POSITRON INITIAL STATE. "
187  << "This is a user-request change from the DEFAULT PROTON-PROTON initial state.";
188  }
189  else
190  {
191  // probably need to throw on attempt to override ?
192  }
193  }
194  else if ( params.exists( "ElectronProtonInitialState" ) || params.exists( "PositronProtonInitialState" ) )
195  {
196  // throw on unknown initial state !
197  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
198  <<" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
199  }
200 
201  if( params.exists( "SLHAFileForPythia8" ) ) {
202  std::string slhafilenameshort = params.getParameter<std::string>("SLHAFileForPythia8");
203  edm::FileInPath f1( slhafilenameshort );
204 
205  fMasterGen->settings.mode("SLHA:readFrom", 2);
206  fMasterGen->settings.word("SLHA:file", f1.fullPath());
207 
209  line != fParameters.end(); ++line ) {
210  if (line->find("SLHA:file") != std::string::npos)
211  throw cms::Exception("PythiaError") << "Attempted to set SLHA file name twice, "
212  << "using Pythia8 card SLHA:file and Pythia8Interface card SLHAFileForPythia8"
213  << std::endl;
214  }
215  }
216  else if( params.exists( "SLHATableForPythia8" ) ) {
217  std::string slhatable = params.getParameter<std::string>("SLHATableForPythia8");
218 
219  char tempslhaname[] = "pythia8SLHAtableXXXXXX";
220  int fd = mkstemp(tempslhaname);
221  write(fd,slhatable.c_str(),slhatable.size());
222  close(fd);
223 
224  slhafile_ = tempslhaname;
225 
226  fMasterGen->settings.mode("SLHA:readFrom", 2);
227  fMasterGen->settings.word("SLHA:file", slhafile_);
228 
230  line != fParameters.end(); ++line ) {
231  if (line->find("SLHA:file") != std::string::npos)
232  throw cms::Exception("PythiaError") << "Attempted to set SLHA file name twice, "
233  << "using Pythia8 card SLHA:file and Pythia8Interface card SLHATableForPythia8"
234  << std::endl;
235  }
236  }
237 
238  //add settings for resonance decay filter
239  fMasterGen->settings.addFlag("ResonanceDecayFilter:filter",false);
240  fMasterGen->settings.addFlag("ResonanceDecayFilter:exclusive",false);
241  fMasterGen->settings.addFlag("ResonanceDecayFilter:eMuAsEquivalent",false);
242  fMasterGen->settings.addFlag("ResonanceDecayFilter:eMuTauAsEquivalent",false);
243  fMasterGen->settings.addFlag("ResonanceDecayFilter:allNuAsEquivalent",false);
244  fMasterGen->settings.addMVec("ResonanceDecayFilter:mothers",std::vector<int>(),false,false,0,0);
245  fMasterGen->settings.addMVec("ResonanceDecayFilter:daughters",std::vector<int>(),false,false,0,0);
246 
247  // Reweight user hook
248  //
249  if( params.exists( "reweightGen" ) )
251  if( params.exists( "reweightGenRap" ) )
252  {
253  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGenRap";
254  edm::ParameterSet rgrParams =
255  params.getParameter<edm::ParameterSet>("reweightGenRap");
257  new RapReweightUserHook(rgrParams.getParameter<std::string>("yLabSigmaFunc"),
258  rgrParams.getParameter<double>("yLabPower"),
259  rgrParams.getParameter<std::string>("yCMSigmaFunc"),
260  rgrParams.getParameter<double>("yCMPower"),
261  rgrParams.getParameter<double>("pTHatMin"),
262  rgrParams.getParameter<double>("pTHatMax"));
263  edm::LogInfo("Pythia8Interface") << "End setup for reweightGenRap";
264  }
265  if( params.exists( "reweightGenPtHatRap" ) )
266  {
267  edm::LogInfo("Pythia8Interface") << "Start setup for reweightGenPtHatRap";
268  edm::ParameterSet rgrParams =
269  params.getParameter<edm::ParameterSet>("reweightGenPtHatRap");
271  new PtHatRapReweightUserHook(rgrParams.getParameter<std::string>("yLabSigmaFunc"),
272  rgrParams.getParameter<double>("yLabPower"),
273  rgrParams.getParameter<std::string>("yCMSigmaFunc"),
274  rgrParams.getParameter<double>("yCMPower"),
275  rgrParams.getParameter<double>("pTHatMin"),
276  rgrParams.getParameter<double>("pTHatMax"));
277  edm::LogInfo("Pythia8Interface") << "End setup for reweightGenPtHatRap";
278  }
279 
280  if( params.exists( "useUserHook" ) )
281  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
282  <<" Obsolete parameter: useUserHook \n Please use the actual one instead \n";
283 
284  // PS matching prototype
285  //
286  if ( params.exists("jetMatching") )
287  {
288  edm::ParameterSet jmParams =
289  params.getUntrackedParameter<edm::ParameterSet>("jetMatching");
290  std::string scheme = jmParams.getParameter<std::string>("scheme");
291  if ( scheme == "Madgraph" || scheme == "MadgraphFastJet" )
292  {
293  fJetMatchingHook = new JetMatchingHook( jmParams, &fMasterGen->info );
294  }
295  }
296 
297  // Pythia8Interface emission veto
298  //
299  if ( params.exists("emissionVeto1") )
300  {
301  EV1_nFinal = -1;
302  if(params.exists("EV1_nFinal")) EV1_nFinal = params.getParameter<int>("EV1_nFinal");
303  EV1_vetoOn = true;
304  if(params.exists("EV1_vetoOn")) EV1_vetoOn = params.getParameter<bool>("EV1_vetoOn");
305  EV1_maxVetoCount = 10;
306  if(params.exists("EV1_maxVetoCount")) EV1_maxVetoCount = params.getParameter<int>("EV1_maxVetoCount");
307  EV1_pThardMode = 1;
308  if(params.exists("EV1_pThardMode")) EV1_pThardMode = params.getParameter<int>("EV1_pThardMode");
309  EV1_pTempMode = 0;
310  if(params.exists("EV1_pTempMode")) EV1_pTempMode = params.getParameter<int>("EV1_pTempMode");
311  if(EV1_pTempMode > 2 || EV1_pTempMode < 0)
312  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
313  <<" Wrong value for EV1_pTempMode code\n";
314  EV1_emittedMode = 0;
315  if(params.exists("EV1_emittedMode")) EV1_emittedMode = params.getParameter<int>("EV1_emittedMode");
316  EV1_pTdefMode = 1;
317  if(params.exists("EV1_pTdefMode")) EV1_pTdefMode = params.getParameter<int>("EV1_pTdefMode");
318  EV1_MPIvetoOn = false;
319  if(params.exists("EV1_MPIvetoOn")) EV1_MPIvetoOn = params.getParameter<bool>("EV1_MPIvetoOn");
323  }
324 
328  if(fJetMatchingHook) NHooks++;
330  if(NHooks > 1)
331  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
332  <<" Too many User Hooks. \n Please choose one from: reweightGen, reweightGenRap, reweightGenPtHatRap, jetMatching, emissionVeto1 \n";
337  if(fEmissionVetoHook1) {
338  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook 1 from CMSSW Pythia8Interface";
340  }
341 
342 }
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
void addHook(Pythia8::UserHooks *hook)
Definition: MultiUserHook.h:11
BaseHadronizer(edm::ParameterSet const &ps)
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string LHEInputFileName
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
MultiUserHook * fMultiUserHook
const_iterator end() const
const_iterator begin() const
ResonanceDecayFilterHook * fResonanceDecayFilterHook
Pythia8Hadronizer::~Pythia8Hadronizer ( )

Definition at line 345 of file Pythia8Hadronizer.cc.

References fEmissionVetoHook, fEmissionVetoHook1, fMultiUserHook, MatrixUtil::remove(), and slhafile_.

346 {
347 // do we need to delete UserHooks/JetMatchingHook here ???
350  if (fMultiUserHook) {
351  delete fMultiUserHook;
352  fMultiUserHook = 0;
353  }
354 
355  //clean up temp file
356  if (!slhafile_.empty()) {
357  std::remove(slhafile_.c_str());
358  }
359 
360 }
EmissionVetoHook1 * fEmissionVetoHook1
PowhegHooks * fEmissionVetoHook
MultiUserHook * fMultiUserHook

Member Function Documentation

const char* Pythia8Hadronizer::classname ( ) const
inlineoverridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 85 of file Pythia8Hadronizer.cc.

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

Reimplemented from gen::BaseHadronizer.

Definition at line 89 of file Pythia8Hadronizer.cc.

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

Reimplemented from gen::BaseHadronizer.

Definition at line 90 of file Pythia8Hadronizer.cc.

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

Implements gen::Py8InterfaceBase.

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

698 {
699  bool lhe = lheEvent() != 0;
700 
701  // now create the GenEventInfo product from the GenEvent and fill
702  // the missing pieces
703  eventInfo().reset( new GenEventInfoProduct( event().get() ) );
704 
705  // in pythia pthat is used to subdivide samples into different bins
706  // in LHE mode the binning is done by the external ME generator
707  // which is likely not pthat, so only filling it for Py6 internal mode
708  if (!lhe) {
709  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
710  }
711 
712  eventInfo()->setDJR(DJR);
713  eventInfo()->setNMEPartons(nME);
714  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
715 
716  //******** Verbosity ********
717 
718  if (maxEventsToPrint > 0 &&
722  if (pythiaPylistVerbosity) {
723  fMasterGen->info.list(std::cout);
724  fMasterGen->event.list(std::cout);
725  }
726 
727  if (pythiaHepMCVerbosity) {
728  std::cout << "Event process = "
729  << fMasterGen->info.code() << "\n"
730  << "----------------------" << std::endl;
731  event()->print();
732  }
734  std::cout << "Event process = "
735  << fMasterGen->info.code() << "\n"
736  << "----------------------" << std::endl;
737  ascii_io->write_event(event().get());
738  }
739  }
740 }
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:145
bool Pythia8Hadronizer::generatePartonsAndHadronize ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 567 of file Pythia8Hadronizer.cc.

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

568 {
569 
570  if (!fMasterGen->next()) return false;
571 
572  if (evtgenDecays) evtgenDecays->decay();
573 
574  event().reset(new HepMC::GenEvent);
575  return toHepMC.fill_next_event( *(fMasterGen.get()), event().get());
576 
577 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
std::auto_ptr< HepMC::GenEvent > & event()
EvtGenDecays * evtgenDecays
HepMC::Pythia8ToHepMC toHepMC
bool Pythia8Hadronizer::hadronize ( )

Definition at line 580 of file Pythia8Hadronizer.cc.

References funct::abs(), JetMatchingHook::beforeHadronization(), lhef::LHEEvent::count(), DJR, gen::BaseHadronizer::event(), gen::Py8InterfaceBase::evtgenDecays, 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(), AlCaHLTBitMon_QueryRunRegistry::string, and gen::Py8InterfaceBase::toHepMC.

581 {
582  DJR.resize(0);
583  nME = -1;
584  nMEFiltered = -1;
585  if(LHEInputFileName == std::string()) lhaUP->loadEvent(lheEvent());
586 
587  if ( fJetMatchingHook )
588  {
591  }
592 
593  bool py8next = fMasterGen->next();
594 
595  double mergeweight = fMasterGen.get()->info.mergingWeightNLO();
596  if (fMergingHook) {
597  mergeweight *= fMergingHook->getNormFactor();
598  }
599 
600 
601  //protect against 0-weight from ckkw or similar
602  if (!py8next || std::abs(mergeweight)==0.)
603  {
604  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
605  event().reset();
606  return false;
607  }
608 
610  const std::vector<double> djrmatch = fJetMatchingPy8InternalHook->GetDJR();
611  //cap size of djr vector to save storage space (keep only up to first 6 elements)
612  unsigned int ndjr = std::min(djrmatch.size(), std::vector<double>::size_type(6));
613  for (unsigned int idjr=0; idjr<ndjr; ++idjr) {
614  DJR.push_back(djrmatch[idjr]);
615  }
616 
617  nME=fJetMatchingPy8InternalHook->nMEpartons().first;
618  nMEFiltered=fJetMatchingPy8InternalHook->nMEpartons().second;
619  }
620 
621  // update LHE matching statistics
622  //
623  lheEvent()->count( lhef::LHERunInfo::kAccepted, 1.0, mergeweight );
624 
625  if (evtgenDecays) evtgenDecays->decay();
626 
627  event().reset(new HepMC::GenEvent);
628  bool py8hepmc = toHepMC.fill_next_event( *(fMasterGen.get()), event().get());
629  if (!py8hepmc) {
630  return false;
631  }
632 
633  //add ckkw/umeps/unlops merging weight
634  if (mergeweight!=1.) {
635  event()->weights()[0] *= mergeweight;
636  }
637 
638  if (fEmissionVetoHook) {
639  nISRveto += fEmissionVetoHook->getNISRveto();
640  nFSRveto += fEmissionVetoHook->getNFSRveto();
641  }
642 
643  return true;
644 
645 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
std::string LHEInputFileName
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()
EvtGenDecays * evtgenDecays
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 433 of file Pythia8Hadronizer.cc.

References MultiUserHook::addHook(), edm::errors::Configuration, gen::Py8InterfaceBase::evtgenDecays, gen::Py8InterfaceBase::evtgenDecFile, gen::Py8InterfaceBase::evtgenPdlFile, gen::Py8InterfaceBase::evtgenUserFiles, Exception, gen::Py8InterfaceBase::fDecayer, fEmissionVetoHook, fEmissionVetoHook1, fJetMatchingHook, fJetMatchingPy8InternalHook, gen::Py8InterfaceBase::fMasterGen, fMergingHook, fMultiUserHook, fResonanceDecayFilterHook, i, JetMatchingHook::init(), lhaUP, LHEInputFileName, gen::BaseHadronizer::lheRunInfo(), MultiUserHook::nHooks(), gen::Py8InterfaceBase::pythiaPylistVerbosity, ntuplemaker::status, AlCaHLTBitMon_QueryRunRegistry::string, and gen::Py8InterfaceBase::useEvtGen.

434 {
435 
436  edm::LogInfo("Pythia8Interface") << "Initializing for external partons";
437 
438  bool status = false, status1 = false;
439 
440  if((fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) && !fEmissionVetoHook) {
441 
443  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
444  <<" Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible are : jetMatching, emissionVeto1 \n";
445 
446  fEmissionVetoHook = new PowhegHooks();
447 
448  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook from pythia8 code";
450 
451  }
452 
453  //adapted from main89.cc in pythia8 examples
454  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
455  bool internalMerging = !(fMasterGen->settings.word("Merging:Process").compare("void")==0);
456 
457  if (internalMatching && internalMerging) {
458  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
459  <<" Only one jet matching/merging scheme can be used at a time. \n";
460  }
461 
462  if (internalMatching && !fJetMatchingPy8InternalHook) {
463  fJetMatchingPy8InternalHook = new Pythia8::JetMatchingMadgraph;
465  }
466 
467  if (internalMerging && !fMergingHook) {
468  int scheme = ( fMasterGen->settings.flag("Merging:doUMEPSTree")
469  || fMasterGen->settings.flag("Merging:doUMEPSSubt")) ?
470  1 :
471  ( ( fMasterGen->settings.flag("Merging:doUNLOPSTree")
472  || fMasterGen->settings.flag("Merging:doUNLOPSSubt")
473  || fMasterGen->settings.flag("Merging:doUNLOPSLoop")
474  || fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO")) ?
475  2 :
476  0 );
477  fMergingHook = new Pythia8::amcnlo_unitarised_interface(scheme);
479  }
480 
481  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
482  if (resonanceDecayFilter && !fResonanceDecayFilterHook) {
485  }
486 
487  if (fMultiUserHook->nHooks()>0) {
488  fMasterGen->setUserHooksPtr(fMultiUserHook);
489  }
490 
491  if(LHEInputFileName != std::string()) {
492 
493  edm::LogInfo("Pythia8Interface") << "Initialize direct pythia8 reading from LHE file "
494  << LHEInputFileName;
495  edm::LogInfo("Pythia8Interface") << "Some LHE information can be not stored";
496  fMasterGen->settings.mode("Beams:frameType", 4);
497  fMasterGen->settings.word("Beams:LHEF", LHEInputFileName);
498  status = fMasterGen->init();
499 
500  } else {
501 
502  lhaUP.reset(new LHAupLesHouches());
503  lhaUP->setScalesFromLHEF(fMasterGen->settings.flag("Beams:setProductionScalesFromLHEF"));
504  lhaUP->loadRunInfo(lheRunInfo());
505 
506  if ( fJetMatchingHook )
507  {
509  }
510 
511  fMasterGen->settings.mode("Beams:frameType", 5);
512  fMasterGen->setLHAupPtr(lhaUP.get());
513  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
514  status = fMasterGen->init();
515  }
516 
517  if ( pythiaPylistVerbosity > 10 )
518  {
519  if ( pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13 )
520  fMasterGen->settings.listAll();
521  if ( pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13 )
522  fMasterGen->particleData.listAll();
523  }
524 
525  // init decayer
526  fDecayer->settings.flag("ProcessLevel:all", false ); // trick
527  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true );
528  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
529  status1 = fDecayer->init();
530 
531  if (useEvtGen) {
532  edm::LogInfo("Pythia8Interface") << "Creating and initializing pythia8 EvtGen plugin";
533 
534  std::string evtgenpath(getenv("EVTGENDATA"));
535  evtgenDecays = new EvtGenDecays(fMasterGen.get(), evtgenDecFile.c_str(), evtgenPdlFile.c_str());
536 
537  for (unsigned int i=0; i<evtgenUserFiles.size(); i++) {
538  edm::FileInPath evtgenUserFile(evtgenUserFiles.at(i));
539  evtgenDecays->readDecayFile(evtgenUserFile.fullPath().c_str());
540  }
541 
542  }
543 
544  return (status&&status1);
545 }
int i
Definition: DBlmapReader.cc:9
std::auto_ptr< Pythia8::Pythia > fMasterGen
EmissionVetoHook1 * fEmissionVetoHook1
void addHook(Pythia8::UserHooks *hook)
Definition: MultiUserHook.h:11
std::string LHEInputFileName
Pythia8::JetMatchingMadgraph * fJetMatchingPy8InternalHook
PowhegHooks * fEmissionVetoHook
std::vector< std::string > evtgenUserFiles
std::auto_ptr< LHAupLesHouches > lhaUP
EvtGenDecays * evtgenDecays
unsigned int pythiaPylistVerbosity
lhef::LHERunInfo * lheRunInfo()
virtual void init(lhef::LHERunInfo *runInfo)
Pythia8::amcnlo_unitarised_interface * fMergingHook
JetMatchingHook * fJetMatchingHook
MultiUserHook * fMultiUserHook
std::auto_ptr< Pythia8::Pythia > fDecayer
ResonanceDecayFilterHook * fResonanceDecayFilterHook
unsigned int nHooks() const
Definition: MultiUserHook.h:10
tuple status
Definition: ntuplemaker.py:245
bool Pythia8Hadronizer::initializeForInternalPartons ( )
overridevirtual

Implements gen::Py8InterfaceBase.

Definition at line 362 of file Pythia8Hadronizer.cc.

References MultiUserHook::addHook(), comEnergy, edm::errors::Configuration, ElectronPositron, gen::Py8InterfaceBase::evtgenDecays, gen::Py8InterfaceBase::evtgenDecFile, gen::Py8InterfaceBase::evtgenPdlFile, gen::Py8InterfaceBase::evtgenUserFiles, Exception, gen::Py8InterfaceBase::fDecayer, fInitialState, gen::Py8InterfaceBase::fMasterGen, fMultiUserHook, fResonanceDecayFilterHook, i, MultiUserHook::nHooks(), PP, PPbar, gen::Py8InterfaceBase::pythiaPylistVerbosity, ntuplemaker::status, and gen::Py8InterfaceBase::useEvtGen.

363 {
364 
365  bool status = false, status1 = false;
366 
367  if ( fInitialState == PP ) // default
368  {
369  fMasterGen->settings.mode("Beams:idA", 2212);
370  fMasterGen->settings.mode("Beams:idB", 2212);
371  }
372  else if ( fInitialState == PPbar )
373  {
374  fMasterGen->settings.mode("Beams:idA", 2212);
375  fMasterGen->settings.mode("Beams:idB", -2212);
376  }
377  else if ( fInitialState == ElectronPositron )
378  {
379  fMasterGen->settings.mode("Beams:idA", 11);
380  fMasterGen->settings.mode("Beams:idB", -11);
381  }
382  else
383  {
384  // throw on unknown initial state !
385  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
386  <<" UNKNOWN INITIAL STATE. \n The allowed initial states are: PP, PPbar, ElectronPositron \n";
387  }
388 
389  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
390  if (resonanceDecayFilter && !fResonanceDecayFilterHook) {
393  }
394 
395  if (fMultiUserHook->nHooks()>0) {
396  fMasterGen->setUserHooksPtr(fMultiUserHook);
397  }
398 
399  fMasterGen->settings.parm("Beams:eCM", comEnergy);
400  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
401  status = fMasterGen->init();
402 
403  if ( pythiaPylistVerbosity > 10 )
404  {
405  if ( pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13 )
406  fMasterGen->settings.listAll();
407  if ( pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13 )
408  fMasterGen->particleData.listAll();
409  }
410 
411  // init decayer
412  fDecayer->settings.flag("ProcessLevel:all", false ); // trick
413  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true );
414  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
415  status1 = fDecayer->init();
416 
417  if (useEvtGen) {
418  edm::LogInfo("Pythia8Interface") << "Creating and initializing pythia8 EvtGen plugin";
419 
420  evtgenDecays = new EvtGenDecays(fMasterGen.get(), evtgenDecFile.c_str(), evtgenPdlFile.c_str());
421 
422  for (unsigned int i=0; i<evtgenUserFiles.size(); i++) {
423  edm::FileInPath evtgenUserFile(evtgenUserFiles.at(i));
424  evtgenDecays->readDecayFile(evtgenUserFile.fullPath().c_str());
425  }
426 
427  }
428 
429  return (status&&status1);
430 }
int i
Definition: DBlmapReader.cc:9
double comEnergy
Center-of-Mass energy.
std::auto_ptr< Pythia8::Pythia > fMasterGen
void addHook(Pythia8::UserHooks *hook)
Definition: MultiUserHook.h:11
std::vector< std::string > evtgenUserFiles
EvtGenDecays * evtgenDecays
unsigned int pythiaPylistVerbosity
MultiUserHook * fMultiUserHook
std::auto_ptr< Pythia8::Pythia > fDecayer
ResonanceDecayFilterHook * fResonanceDecayFilterHook
unsigned int nHooks() const
Definition: MultiUserHook.h:10
tuple status
Definition: ntuplemaker.py:245
bool Pythia8Hadronizer::residualDecay ( )
virtual

Definition at line 648 of file Pythia8Hadronizer.cc.

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

649 {
650 
651  Event* pythiaEvent = &(fMasterGen->event);
652 
653  int NPartsBeforeDecays = pythiaEvent->size();
654  int NPartsAfterDecays = event().get()->particles_size();
655 
656  if(NPartsAfterDecays == NPartsBeforeDecays) return true;
657 
658  bool result = true;
659 
660  for ( int ipart=NPartsAfterDecays; ipart>NPartsBeforeDecays; ipart-- )
661  {
662 
663  HepMC::GenParticle* part = event().get()->barcode_to_particle( ipart );
664 
665  if ( part->status() == 1 && (fDecayer->particleData).canDecay(part->pdg_id()) )
666  {
667  fDecayer->event.reset();
668  Particle py8part( part->pdg_id(), 93, 0, 0, 0, 0, 0, 0,
669  part->momentum().x(),
670  part->momentum().y(),
671  part->momentum().z(),
672  part->momentum().t(),
673  part->generated_mass() );
674  HepMC::GenVertex* ProdVtx = part->production_vertex();
675  py8part.vProd( ProdVtx->position().x(), ProdVtx->position().y(),
676  ProdVtx->position().z(), ProdVtx->position().t() );
677  py8part.tau( (fDecayer->particleData).tau0( part->pdg_id() ) );
678  fDecayer->event.append( py8part );
679  int nentries = fDecayer->event.size();
680  if ( !fDecayer->event[nentries-1].mayDecay() ) continue;
681  fDecayer->next();
682  int nentries1 = fDecayer->event.size();
683  if ( nentries1 <= nentries ) continue; //same number of particles, no decays...
684 
685  part->set_status(2);
686 
687  result = toHepMC.fill_next_event( *(fDecayer.get()), event().get(), -1, true, part);
688 
689  }
690  }
691 
692  return result;
693 
694 }
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
HepMC::Pythia8ToHepMC toHepMC
void Pythia8Hadronizer::statistics ( )
overridevirtual

Reimplemented from gen::Py8InterfaceBase.

Definition at line 548 of file Pythia8Hadronizer.cc.

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

549 {
550  fMasterGen->stat();
551 
552  if(fEmissionVetoHook) {
553  edm::LogPrint("Pythia8Interface") << "\n"
554  << "Number of ISR vetoed = " << nISRveto;
555  edm::LogPrint("Pythia8Interface")
556  << "Number of FSR vetoed = " << nFSRveto;
557  }
558 
559  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
560  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
561  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
562  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
564 }
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 93 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons().

vector<float> Pythia8Hadronizer::DJR
private

Definition at line 140 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), and hadronize().

int Pythia8Hadronizer::EV1_emittedMode
private

Definition at line 132 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_maxVetoCount
private

Definition at line 129 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

bool Pythia8Hadronizer::EV1_MPIvetoOn
private

Definition at line 134 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_nFinal
private

Definition at line 127 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pTdefMode
private

Definition at line 133 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pTempMode
private

Definition at line 131 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::EV1_pThardMode
private

Definition at line 130 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

bool Pythia8Hadronizer::EV1_vetoOn
private

Definition at line 128 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

double Pythia8Hadronizer::fBeam1PZ
private

Definition at line 101 of file Pythia8Hadronizer.cc.

double Pythia8Hadronizer::fBeam2PZ
private

Definition at line 102 of file Pythia8Hadronizer.cc.

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

Definition at line 99 of file Pythia8Hadronizer.cc.

Referenced by initializeForInternalPartons(), and Pythia8Hadronizer().

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

Definition at line 116 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

Pythia8::amcnlo_unitarised_interface* Pythia8Hadronizer::fMergingHook
private

Definition at line 117 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

MultiUserHook* Pythia8Hadronizer::fMultiUserHook
private
ResonanceDecayFilterHook* Pythia8Hadronizer::fResonanceDecayFilterHook
private
UserHooks* Pythia8Hadronizer::fReweightPtHatRapUserHook
private

Definition at line 111 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

UserHooks* Pythia8Hadronizer::fReweightRapUserHook
private

Definition at line 110 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

UserHooks* Pythia8Hadronizer::fReweightUserHook
private

Definition at line 109 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

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

Definition at line 96 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

std::string Pythia8Hadronizer::LHEInputFileName
private

Definition at line 95 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

int Pythia8Hadronizer::nFSRveto
private

Definition at line 145 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and statistics().

int Pythia8Hadronizer::NHooks
private

Definition at line 147 of file Pythia8Hadronizer.cc.

Referenced by Pythia8Hadronizer().

int Pythia8Hadronizer::nISRveto
private

Definition at line 144 of file Pythia8Hadronizer.cc.

Referenced by hadronize(), and statistics().

int Pythia8Hadronizer::nME
private

Definition at line 141 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), and hadronize().

int Pythia8Hadronizer::nMEFiltered
private

Definition at line 142 of file Pythia8Hadronizer.cc.

Referenced by finalizeEvent(), and hadronize().

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

Definition at line 136 of file Pythia8Hadronizer.cc.

std::string Pythia8Hadronizer::slhafile_
private

Definition at line 138 of file Pythia8Hadronizer.cc.

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