test
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::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, edm::hlt::Exception, edm::ParameterSet::exists(), python.connectstrParser::f1, 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
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, python.multivaluedict::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 687 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.

688 {
689  bool lhe = lheEvent() != 0;
690 
691  // now create the GenEventInfo product from the GenEvent and fill
692  // the missing pieces
693  eventInfo().reset( new GenEventInfoProduct( event().get() ) );
694 
695  // in pythia pthat is used to subdivide samples into different bins
696  // in LHE mode the binning is done by the external ME generator
697  // which is likely not pthat, so only filling it for Py6 internal mode
698  if (!lhe) {
699  eventInfo()->setBinningValues(std::vector<double>(1, fMasterGen->info.pTHat()));
700  }
701 
702  eventInfo()->setDJR(DJR);
703  eventInfo()->setNMEPartons(nME);
704  eventInfo()->setNMEPartonsFiltered(nMEFiltered);
705 
706  //******** Verbosity ********
707 
708  if (maxEventsToPrint > 0 &&
712  if (pythiaPylistVerbosity) {
713  fMasterGen->info.list(std::cout);
714  fMasterGen->event.list(std::cout);
715  }
716 
717  if (pythiaHepMCVerbosity) {
718  std::cout << "Event process = "
719  << fMasterGen->info.code() << "\n"
720  << "----------------------" << std::endl;
721  event()->print();
722  }
724  std::cout << "Event process = "
725  << fMasterGen->info.code() << "\n"
726  << "----------------------" << std::endl;
727  ascii_io->write_event(event().get());
728  }
729  }
730 }
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 557 of file Pythia8Hadronizer.cc.

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

558 {
559 
560  if (!fMasterGen->next()) return false;
561 
562  if (evtgenDecays) evtgenDecays->decay();
563 
564  event().reset(new HepMC::GenEvent);
565  return toHepMC.fill_next_event( *(fMasterGen.get()), event().get());
566 
567 }
std::auto_ptr< Pythia8::Pythia > fMasterGen
std::auto_ptr< HepMC::GenEvent > & event()
EvtGenDecays * evtgenDecays
HepMC::Pythia8ToHepMC toHepMC
bool Pythia8Hadronizer::hadronize ( )

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

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

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

429 {
430 
431  edm::LogInfo("Pythia8Interface") << "Initializing for external partons";
432 
433  bool status = false, status1 = false;
434 
435  if((fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) && !fEmissionVetoHook) {
436 
438  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
439  <<" Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible are : jetMatching, emissionVeto1 \n";
440 
441  fEmissionVetoHook = new PowhegHooks();
442 
443  edm::LogInfo("Pythia8Interface") << "Turning on Emission Veto Hook from pythia8 code";
445 
446  }
447 
448  //adapted from main89.cc in pythia8 examples
449  bool internalMatching = fMasterGen->settings.flag("JetMatching:merge");
450  bool internalMerging = !(fMasterGen->settings.word("Merging:Process").compare("void")==0);
451 
452  if (internalMatching && internalMerging) {
453  throw edm::Exception(edm::errors::Configuration,"Pythia8Interface")
454  <<" Only one jet matching/merging scheme can be used at a time. \n";
455  }
456 
457  if (internalMatching && !fJetMatchingPy8InternalHook) {
458  fJetMatchingPy8InternalHook = new Pythia8::JetMatchingMadgraph;
460  }
461 
462  if (internalMerging && !fMergingHook) {
463  int scheme = ( fMasterGen->settings.flag("Merging:doUMEPSTree")
464  || fMasterGen->settings.flag("Merging:doUMEPSSubt")) ?
465  1 :
466  ( ( fMasterGen->settings.flag("Merging:doUNLOPSTree")
467  || fMasterGen->settings.flag("Merging:doUNLOPSSubt")
468  || fMasterGen->settings.flag("Merging:doUNLOPSLoop")
469  || fMasterGen->settings.flag("Merging:doUNLOPSSubtNLO")) ?
470  2 :
471  0 );
472  fMergingHook = new Pythia8::amcnlo_unitarised_interface(scheme);
474  }
475 
476  bool resonanceDecayFilter = fMasterGen->settings.flag("ResonanceDecayFilter:filter");
477  if (resonanceDecayFilter && !fResonanceDecayFilterHook) {
480  }
481 
482  if (fMultiUserHook->nHooks()>0) {
483  fMasterGen->setUserHooksPtr(fMultiUserHook);
484  }
485 
486  if(LHEInputFileName != std::string()) {
487 
488  edm::LogInfo("Pythia8Interface") << "Initialize direct pythia8 reading from LHE file "
489  << LHEInputFileName;
490  edm::LogInfo("Pythia8Interface") << "Some LHE information can be not stored";
491  fMasterGen->settings.mode("Beams:frameType", 4);
492  fMasterGen->settings.word("Beams:LHEF", LHEInputFileName);
493  status = fMasterGen->init();
494 
495  } else {
496 
497  lhaUP.reset(new LHAupLesHouches());
498  lhaUP->setScalesFromLHEF(fMasterGen->settings.flag("Beams:setProductionScalesFromLHEF"));
499  lhaUP->loadRunInfo(lheRunInfo());
500 
501  if ( fJetMatchingHook )
502  {
504  }
505 
506  fMasterGen->settings.mode("Beams:frameType", 5);
507  fMasterGen->setLHAupPtr(lhaUP.get());
508  edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
509  status = fMasterGen->init();
510  }
511 
512  if ( pythiaPylistVerbosity > 10 )
513  {
514  if ( pythiaPylistVerbosity == 11 || pythiaPylistVerbosity == 13 )
515  fMasterGen->settings.listAll();
516  if ( pythiaPylistVerbosity == 12 || pythiaPylistVerbosity == 13 )
517  fMasterGen->particleData.listAll();
518  }
519 
520  // init decayer
521  fDecayer->settings.flag("ProcessLevel:all", false ); // trick
522  fDecayer->settings.flag("ProcessLevel:resonanceDecays", true );
523  edm::LogInfo("Pythia8Interface") << "Initializing Decayer";
524  status1 = fDecayer->init();
525 
526  if (useEvtGen) {
527  edm::LogInfo("Pythia8Interface") << "Creating and initializing pythia8 EvtGen plugin";
528 
529  std::string evtgenpath(getenv("EVTGENDATA"));
530  evtgenDecays = new EvtGenDecays(fMasterGen.get(), evtgenDecFile.c_str(), evtgenPdlFile.c_str());
531  evtgenDecays->readDecayFile("evtgen_userfile.dec");
532  }
533 
534  return (status&&status1);
535 }
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::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, edm::hlt::Exception, gen::Py8InterfaceBase::fDecayer, fInitialState, gen::Py8InterfaceBase::fMasterGen, fMultiUserHook, fResonanceDecayFilterHook, 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  evtgenDecays->readDecayFile("evtgen_userfile.dec");
422  }
423 
424  return (status&&status1);
425 }
double comEnergy
Center-of-Mass energy.
std::auto_ptr< Pythia8::Pythia > fMasterGen
void addHook(Pythia8::UserHooks *hook)
Definition: MultiUserHook.h:11
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 638 of file Pythia8Hadronizer.cc.

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

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

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

539 {
540  fMasterGen->stat();
541 
542  if(fEmissionVetoHook) {
543  edm::LogPrint("Pythia8Interface") << "\n"
544  << "Number of ISR vetoed = " << nISRveto;
545  edm::LogPrint("Pythia8Interface")
546  << "Number of FSR vetoed = " << nFSRveto;
547  }
548 
549  double xsec = fMasterGen->info.sigmaGen(); // cross section in mb
550  xsec *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
551  double err = fMasterGen->info.sigmaErr(); // cross section err in mb
552  err *= 1.0e9; // translate to pb (CMS/Gen "convention" as of May 2009)
554 }
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().