CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
gen::CepGenEventGenerator Class Reference

#include <CepGenEventGenerator.h>

Inheritance diagram for gen::CepGenEventGenerator:
gen::BaseHadronizer

Public Member Functions

 CepGenEventGenerator (const edm::ParameterSet &, edm::ConsumesCollector &&)
 
const char * classname () const
 
bool decay ()
 
bool declareSpecialSettings (const std::vector< std::string > &)
 
bool declareStableParticles (const std::vector< int > &)
 
const std::vector< std::string > & doSharedResources () const override
 
void finalizeEvent ()
 
bool generatePartonsAndHadronize ()
 
bool initializeForInternalPartons ()
 
bool readSettings (int)
 
bool residualDecay ()
 
void statistics ()
 
virtual ~CepGenEventGenerator ()
 
- Public Member Functions inherited from gen::BaseHadronizer
 BaseHadronizer (edm::ParameterSet const &ps)
 
void cleanLHE ()
 
void generateLHE (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine, unsigned int ncpu)
 
edm::EventgetEDMEvent () const
 
std::unique_ptr< HepMC::GenEventgetGenEvent ()
 
std::unique_ptr< HepMC3::GenEvent > getGenEvent3 ()
 
std::unique_ptr< GenEventInfoProductgetGenEventInfo ()
 
std::unique_ptr< GenEventInfoProduct3getGenEventInfo3 ()
 
virtual std::unique_ptr< GenLumiInfoHeadergetGenLumiInfoHeader () const
 
GenRunInfoProductgetGenRunInfo ()
 
std::unique_ptr< lhef::LHEEventgetLHEEvent ()
 
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo () const
 
unsigned int getVHepMC ()
 
const std::string & gridpackPath () const
 
int randomIndex () const
 
const std::string & randomInitConfigDescription () const
 
void randomizeIndex (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
 
void resetEvent (std::unique_ptr< HepMC::GenEvent > event)
 
void resetEvent3 (std::unique_ptr< HepMC3::GenEvent > event3)
 
void resetEventInfo (std::unique_ptr< GenEventInfoProduct > eventInfo)
 
void resetEventInfo3 (std::unique_ptr< GenEventInfoProduct3 > eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (std::unique_ptr< lhef::LHEEvent > event)
 
void setLHERunInfo (std::unique_ptr< lhef::LHERunInfo > runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
virtual ~BaseHadronizer () noexcept(false)
 

Private Attributes

cepgen::Generator * gen_ {nullptr}
 
std::vector< std::pair< std::string, cepgen::ParametersList > > modif_modules_
 
std::vector< std::pair< std::string, cepgen::ParametersList > > output_modules_
 
const cepgen::ParametersList proc_params_
 
const std::vector< std::string > shared_resources_
 
HepMC::GenCrossSection xsec_
 

Additional Inherited Members

- Protected Member Functions inherited from gen::BaseHadronizer
std::unique_ptr< HepMC::GenEvent > & event ()
 
std::unique_ptr< HepMC3::GenEvent > & event3 ()
 
std::unique_ptr< GenEventInfoProduct > & eventInfo ()
 
std::unique_ptr< GenEventInfoProduct3 > & eventInfo3 ()
 
lhef::LHEEventlheEvent ()
 
lhef::LHERunInfolheRunInfo ()
 
GenRunInfoProductrunInfo ()
 
- Protected Attributes inherited from gen::BaseHadronizer
unsigned int ivhepmc = 2
 
std::string lheFile_
 
int randomIndex_
 

Detailed Description

Definition at line 15 of file CepGenEventGenerator.h.

Constructor & Destructor Documentation

◆ CepGenEventGenerator()

CepGenEventGenerator::CepGenEventGenerator ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)
explicit

Definition at line 25 of file CepGenEventGenerator.cc.

References cepgen::fromParameterSet(), get, edm::ParameterSet::getUntrackedParameter(), mod(), modif_modules_, output_modules_, and proc_params_.

26  : BaseHadronizer(iConfig),
28  // specify the overall module verbosity
29  cepgen::utils::Logger::get().setLevel(
30  static_cast<cepgen::utils::Logger::Level>(iConfig.getUntrackedParameter<int>("verbosity", 0)));
31 
32  // build the process
33  edm::LogInfo("CepGenEventGenerator") << "Process to be generated: " << proc_params_ << ".";
34 
35  const auto modif_mods = cepgen::fromParameterSet(
36  iConfig.getUntrackedParameter<edm::ParameterSet>("modifierModules", edm::ParameterSet{}));
37  edm::LogInfo("CepGenEventGenerator") << "Event modifier modules: " << modif_mods << ".";
38  for (const auto& mod : modif_mods.keys())
39  modif_modules_.emplace_back(std::make_pair(mod, modif_mods.get<cepgen::ParametersList>(mod)));
40 
41  const auto output_mods =
43  edm::LogInfo("CepGenEventGenerator") << "Output modules: " << output_mods << ".";
44  for (const auto& mod : output_mods.keys())
45  output_modules_.emplace_back(std::make_pair(mod, output_mods.get<cepgen::ParametersList>(mod)));
46 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
BaseHadronizer(edm::ParameterSet const &ps)
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::pair< std::string, cepgen::ParametersList > > modif_modules_
std::vector< std::pair< std::string, cepgen::ParametersList > > output_modules_
Log< level::Info, false > LogInfo
const cepgen::ParametersList proc_params_
#define get
ParametersList fromParameterSet(const edm::ParameterSet &iConfig)
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4

◆ ~CepGenEventGenerator()

CepGenEventGenerator::~CepGenEventGenerator ( )
virtual

Definition at line 48 of file CepGenEventGenerator.cc.

48 { edm::LogInfo("CepGenEventGenerator") << "Destructor called."; }
Log< level::Info, false > LogInfo

Member Function Documentation

◆ classname()

const char* gen::CepGenEventGenerator::classname ( ) const
inline

Definition at line 32 of file CepGenEventGenerator.h.

32 { return "CepGenEventGenerator"; }

◆ decay()

bool gen::CepGenEventGenerator::decay ( )
inline

Definition at line 26 of file CepGenEventGenerator.h.

26 { return true; } // NOT used - let's call it "design imperfection"

◆ declareSpecialSettings()

bool gen::CepGenEventGenerator::declareSpecialSettings ( const std::vector< std::string > &  )
inline

Definition at line 22 of file CepGenEventGenerator.h.

22 { return true; }

◆ declareStableParticles()

bool gen::CepGenEventGenerator::declareStableParticles ( const std::vector< int > &  )
inline

Definition at line 21 of file CepGenEventGenerator.h.

21 { return true; }

◆ doSharedResources()

const std::vector<std::string>& gen::CepGenEventGenerator::doSharedResources ( ) const
inlineoverridevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 33 of file CepGenEventGenerator.h.

References shared_resources_.

33 { return shared_resources_; }
const std::vector< std::string > shared_resources_

◆ finalizeEvent()

void gen::CepGenEventGenerator::finalizeEvent ( )
inline

Definition at line 29 of file CepGenEventGenerator.h.

29 {}

◆ generatePartonsAndHadronize()

bool CepGenEventGenerator::generatePartonsAndHadronize ( )

Definition at line 87 of file CepGenEventGenerator.cc.

References gen::BaseHadronizer::event(), gen_, and xsec_.

87  {
88  event().reset(new HepMC::CepGenEvent(gen_->next()));
89  event()->set_cross_section(xsec_);
90  event()->weights().push_back(1.);
91  return true;
92 }
HepMC::GenCrossSection xsec_
std::unique_ptr< HepMC::GenEvent > & event()

◆ initializeForInternalPartons()

bool CepGenEventGenerator::initializeForInternalPartons ( )

Definition at line 50 of file CepGenEventGenerator.cc.

References newFWLiteAna::build, looper::cfg, gen_, g4SimHits_cfi::Generator, get, mod(), modif_modules_, eostools::move(), output_modules_, proc_params_, gen::BaseHadronizer::runInfo(), GenRunInfoProduct::setInternalXSec(), and xsec_.

50  {
51  gen_ = new cepgen::Generator(true /* "safe" mode: start without plugins */);
52 
53  auto pproc = proc_params_;
54  { // little treatment to allow for standard CepGen configurations to be copy-pasted in place
55  pproc += proc_params_.get<cepgen::ParametersList>("processParameters");
56  pproc.erase("processParameters");
57  auto& pkin = pproc.operator[]<cepgen::ParametersList>("kinematics");
58  pkin += pproc.get<cepgen::ParametersList>("inKinematics");
59  pproc.erase("inKinematics");
60  pkin += pproc.get<cepgen::ParametersList>("outKinematics");
61  pproc.erase("outKinematics");
62  if (pproc.has<unsigned long long>("mode"))
63  pkin.set<int>("mode", pproc.get<unsigned long long>("mode"));
64  }
65 
66  gen_->runParameters().setProcess(cepgen::ProcessFactory::get().build(pproc));
67  if (!gen_->runParameters().hasProcess())
68  throw cms::Exception("CepGenEventGenerator") << "Failed to retrieve a process from the configuration";
69  for (const auto& mod : modif_modules_) {
70  auto modifier = cepgen::EventModifierFactory::get().build(mod.first, mod.second);
71  for (const auto& cfg : mod.second.get<std::vector<std::string> >("preConfiguration"))
72  modifier->readString(cfg);
73  for (const auto& cfg : mod.second.get<std::vector<std::string> >("processConfiguration"))
74  modifier->readString(cfg);
75  gen_->runParameters().addModifier(std::move(modifier));
76  }
77  for (const auto& mod : output_modules_)
78  gen_->runParameters().addEventExporter(cepgen::EventExporterFactory::get().build(mod.first, mod.second));
79 
80  edm::LogInfo("CepGenEventGenerator") << "Run parameters:\n" << gen_->runParameters();
81  const auto xsec = gen_->computeXsection();
82  xsec_.set_cross_section(xsec, xsec.uncertainty());
83  runInfo().setInternalXSec(GenRunInfoProduct::XSec(xsec, xsec.uncertainty()));
84  return true;
85 }
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
HepMC::GenCrossSection xsec_
std::vector< std::pair< std::string, cepgen::ParametersList > > modif_modules_
std::vector< std::pair< std::string, cepgen::ParametersList > > output_modules_
Log< level::Info, false > LogInfo
const cepgen::ParametersList proc_params_
#define get
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
def move(src, dest)
Definition: eostools.py:511

◆ readSettings()

bool gen::CepGenEventGenerator::readSettings ( int  )
inline

Definition at line 20 of file CepGenEventGenerator.h.

20 { return true; }

◆ residualDecay()

bool gen::CepGenEventGenerator::residualDecay ( )
inline

Definition at line 27 of file CepGenEventGenerator.h.

27 { return true; }

◆ statistics()

void gen::CepGenEventGenerator::statistics ( )
inline

Definition at line 30 of file CepGenEventGenerator.h.

30 {}

Member Data Documentation

◆ gen_

cepgen::Generator* gen::CepGenEventGenerator::gen_ {nullptr}
private

◆ modif_modules_

std::vector<std::pair<std::string, cepgen::ParametersList> > gen::CepGenEventGenerator::modif_modules_
private

Definition at line 38 of file CepGenEventGenerator.h.

Referenced by CepGenEventGenerator(), and initializeForInternalPartons().

◆ output_modules_

std::vector<std::pair<std::string, cepgen::ParametersList> > gen::CepGenEventGenerator::output_modules_
private

Definition at line 38 of file CepGenEventGenerator.h.

Referenced by CepGenEventGenerator(), and initializeForInternalPartons().

◆ proc_params_

const cepgen::ParametersList gen::CepGenEventGenerator::proc_params_
private

Definition at line 37 of file CepGenEventGenerator.h.

Referenced by CepGenEventGenerator(), and initializeForInternalPartons().

◆ shared_resources_

const std::vector<std::string> gen::CepGenEventGenerator::shared_resources_
private

Definition at line 39 of file CepGenEventGenerator.h.

Referenced by doSharedResources().

◆ xsec_

HepMC::GenCrossSection gen::CepGenEventGenerator::xsec_
private