Skip to content

Commit

Permalink
Merge pull request #20733 from mkirsano/usevincia2
Browse files Browse the repository at this point in the history
Code to turn on VINCIA plugin version 2
  • Loading branch information
cmsbuild committed Oct 16, 2017
2 parents 1da1abf + 2922d43 commit 70855be
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 6 deletions.
1 change: 1 addition & 0 deletions GeneratorInterface/Pythia8Interface/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<use name="boost"/>
<use name="pythia8"/>
<use name="evtgen"/>
<use name="vincia"/>
<use name="hepmc"/>
<use name="clhep"/>
<export>
Expand Down
21 changes: 17 additions & 4 deletions GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sstream>
#include <string>
#include <memory>
#include <stdint.h>
#include <cstdint>
#include <vector>

#include "HepMC/GenEvent.h"
Expand All @@ -11,6 +11,8 @@
#include "Pythia8/Pythia.h"
#include "Pythia8Plugins/HepMC2.h"

#include "Vincia/Vincia.h"

using namespace Pythia8;

#include "GeneratorInterface/Pythia8Interface/interface/Py8InterfaceBase.h"
Expand Down Expand Up @@ -74,7 +76,7 @@ class Pythia8Hadronizer : public Py8InterfaceBase {
public:

Pythia8Hadronizer(const edm::ParameterSet &params);
~Pythia8Hadronizer();
~Pythia8Hadronizer() override;

bool initializeForInternalPartons() override;
bool initializeForExternalPartons();
Expand All @@ -94,7 +96,9 @@ class Pythia8Hadronizer : public Py8InterfaceBase {

private:

virtual void doSetRandomEngine(CLHEP::HepRandomEngine* v) override { p8SetRandomEngine(v); }
std::auto_ptr<Vincia::VinciaPlugin> fvincia;

void doSetRandomEngine(CLHEP::HepRandomEngine* v) override { p8SetRandomEngine(v); }
virtual std::vector<std::string> const& doSharedResources() const override { return p8SharedResources; }

/// Center-of-Mass energy
Expand Down Expand Up @@ -305,6 +309,11 @@ Pythia8Hadronizer::Pythia8Hadronizer(const edm::ParameterSet &params) :
EV1_emittedMode, EV1_pTdefMode, EV1_MPIvetoOn, 0));
}

if( params.exists( "VinciaPlugin" ) ) {
fMasterGen.reset(new Pythia);
fvincia.reset(new Vincia::VinciaPlugin(fMasterGen.get()));
}

}


Expand Down Expand Up @@ -430,7 +439,11 @@ bool Pythia8Hadronizer::initializeForInternalPartons()
}

edm::LogInfo("Pythia8Interface") << "Initializing MasterGen";
status = fMasterGen->init();
if( fvincia.get() ) {
fvincia->init(); status = true;
} else {
status = fMasterGen->init();
}

//clean up temp file
if (!slhafile_.empty()) {
Expand Down
4 changes: 2 additions & 2 deletions GeneratorInterface/Pythia8Interface/src/Py8InterfaceBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace gen {

Py8InterfaceBase::Py8InterfaceBase( edm::ParameterSet const& ps ) :
BaseHadronizer(ps),
useEvtGen(false), evtgenDecays(0)
useEvtGen(false), evtgenDecays(nullptr)
{
fParameters = ps;

Expand Down Expand Up @@ -49,7 +49,7 @@ useEvtGen(false), evtgenDecays(0)
bool Py8InterfaceBase::readSettings( int )
{

fMasterGen.reset(new Pythia);
if(!fMasterGen.get()) fMasterGen.reset(new Pythia);
fDecayer.reset(new Pythia);

//add settings for resonance decay filter
Expand Down
57 changes: 57 additions & 0 deletions GeneratorInterface/Pythia8Interface/test/pythia8ex13_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Using VINCIA plugin

import FWCore.ParameterSet.Config as cms

process = cms.Process("PROD")

process.load("Configuration.StandardSequences.SimulationRandomNumberGeneratorSeeds_cff")

process.source = cms.Source("EmptySource")

process.generator = cms.EDFilter("Pythia8GeneratorFilter",
maxEventsToPrint = cms.untracked.int32(1),
pythiaPylistVerbosity = cms.untracked.int32(1),
filterEfficiency = cms.untracked.double(1.0),
pythiaHepMCVerbosity = cms.untracked.bool(False),
comEnergy = cms.double(91.188),
ElectronPositronInitialState = cms.PSet(),
VinciaPlugin = cms.PSet(),
PythiaParameters = cms.PSet(
pythia8_example13 = cms.vstring('WeakSingleBoson:ffbar2gmZ = on',
'23:onMode = off',
'23:onIfAny = 1 2 3 4 5',
'PDF:lepton = off',
'SpaceShower:QEDshowerByL = off',
'HadronLevel:all = on'),
parameterSets = cms.vstring('pythia8_example13')
)
)

process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.MessageLogger = cms.Service("MessageLogger",
cout = cms.untracked.PSet(
default = cms.untracked.PSet(
limit = cms.untracked.int32(2)
)
),
destinations = cms.untracked.vstring('cout')
)

process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService",
generator = cms.PSet(
initialSeed = cms.untracked.uint32(123456789),
)
)

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(100)
)

process.GEN = cms.OutputModule("PoolOutputModule",
fileName = cms.untracked.string('pythia8ex13.root')
)

process.p = cms.Path(process.generator)
process.outpath = cms.EndPath(process.GEN)

process.schedule = cms.Schedule(process.p, process.outpath)

0 comments on commit 70855be

Please sign in to comment.