CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
Herwig::HerwigUIProvider Class Reference

#include <HerwigUIProvider.h>

Inheritance diagram for Herwig::HerwigUIProvider:

Public Member Functions

const std::vector< std::string > & appendReadDirectories () const override
 
std::ostream & errStream () const override
 Return the standard err stream to be used. More...
 
 HerwigUIProvider (const edm::ParameterSet &pset, std::string inputFileName, RunMode::Mode)
 Constructor from the arguments provided by CMSSW. More...
 
std::string inputfile () const override
 Name of the file to be read. More...
 
std::istream & inStream () const override
 Return the standard in stream to be used. More...
 
std::string integrationList () const override
 
int jobs () const override
 
unsigned int jobSize () const override
 
unsigned int maxJobs () const override
 
long N () const override
 
std::ostream & outStream () const override
 Return the standard out stream to be used. More...
 
const std::vector< std::string > & prependReadDirectories () const override
 
void quit () const override
 
void quitWithHelp () const override
 
std::string repository () const override
 Repository name to operate on. More...
 
bool resume () const override
 Try to resume execution from an earlier interrupted run. More...
 
RunMode::Mode runMode () const override
 Requested Herwig run mode. More...
 
int seed () const override
 
void setRunMode (RunMode::Mode runMode, const edm::ParameterSet &pset, std::string inputFile="")
 
void setSeed (long seed)
 
std::string setupfile () const override
 Name of the setup file to be read, to modify the repository. More...
 
std::string tag () const override
 A user-defined tag to append to the run name. More...
 
bool tics () const override
 Require verbose progress markers. More...
 
 ~HerwigUIProvider () override
 Destructor to leave a clean ThePEG::Repository behind. More...
 

Private Attributes

std::vector< std::string > appendReadDirectories_
 
std::string inputfile_
 
std::string integrationList_
 
int jobs_
 
unsigned int jobsize_
 
unsigned int maxjobs_
 
long nEvents_
 
std::vector< std::string > prependReadDirectories_
 
std::string repository_
 
bool resume_
 
RunMode::Mode runMode_
 
int seed_
 
std::string setupfile_
 
std::string tag_
 
bool tics_
 

Detailed Description

HerwigUIProvider is an implementation of the HerwigUI interface getting its input from CMSSW configs.

Definition at line 18 of file HerwigUIProvider.h.

Constructor & Destructor Documentation

Herwig::HerwigUIProvider::HerwigUIProvider ( const edm::ParameterSet pset,
std::string  inputFileName,
RunMode::Mode  runMode 
)

Constructor from the arguments provided by CMSSW.

Definition at line 34 of file HerwigUIProvider.cc.

References appendReadDirectories_, dqm::qstatus::ERROR, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, integrationList_, jobs_, jobsize_, maxjobs_, nEvents_, prependReadDirectories_, repository_, gen::ParameterCollector::resolve(), resume_, runMode_, seed_, setupfile_, AlCaHLTBitMon_QueryRunRegistry::string, tag_, and tics_.

35  : runMode_(runMode),
36  resume_(false), tics_(true), tag_(),
39  nEvents_(-1), seed_(0), jobs_(1),
40  jobsize_(0), maxjobs_(0)
41 {
42 
43  // check runMode of program and terminate if error state
44  if (runMode_ == RunMode::ERROR)
45  edm::LogError("Herwig7Interface") << "Invalid run mode: RunMode::ERROR was passed to Herwig.\n";
46 
47 /*
48  std::string tmpRunMode = pset.getUntrackedParameter<std::string>("runMode", "read");
49  if ( tmpRunMode == "init" ) { runMode_ = RunMode::INIT; }
50  else if ( tmpRunMode == "read" ) { runMode_ = RunMode::READ; }
51  else if ( tmpRunMode == "build" ) { runMode_ = RunMode::BUILD; }
52  else if ( tmpRunMode == "integrate" ) { runMode_ = RunMode::INTEGRATE; }
53  else if ( tmpRunMode == "mergegrids" ) { runMode_ = RunMode::MERGEGRIDS; }
54  else if ( tmpRunMode == "run" ) { runMode_ = RunMode::RUN; }
55  else {
56  runMode_ = RunMode::ERROR;
57  quitWithHelp();
58  }
59 */
60 
61  // File path to repository file
63  if (repository_.empty()) {
64  repository_ = std::string("HerwigDefaults.rpo");
65  }
66 
67  // Number of events
68  if ( pset.getUntrackedParameter<int>("numberEvents", -1) != -1 )
69  nEvents_ = pset.getUntrackedParameter<int>("numberEvents", 1);
70 
71 
72  // run name tag (default given in ggo file)
73  if ( !pset.getUntrackedParameter<std::string>("runTag", "").empty())
74  tag_ = pset.getUntrackedParameter<std::string>("runTag", "Tag1");
75 
76  // Debugging level
77  if ( pset.getUntrackedParameter<unsigned int>("debugOutput", 0) )
78  ThePEG::Debug::setDebug( pset.getUntrackedParameter<unsigned int>("debugOutput", 0) );
79 
80  // Floating point exceptions
81  if ( pset.getUntrackedParameter<bool>("debugFPE", false) )
82  ThePEG::Debug::unmaskFpuErrors();
83 
84  // Exit-on-error flag
85  if ( pset.getUntrackedParameter<bool>("exitOnError", false) )
86  ThePEG::Repository::exitOnError() = 1;
87 
88  // Tics
89  if ( pset.getUntrackedParameter<bool>("hideTics", false) )
90  tics_ = false;
91 
92 
93 
94 
95  // RNG seed
96  if ( pset.getUntrackedParameter<int>("seed", 0) != 0 )
97  seed_ = pset.getUntrackedParameter<int>("seed", 0);
98 
99  // run modification file
100  if ( !pset.getUntrackedParameter<std::string>("setupFile", "").empty() )
101  setupfile_ = pset.getUntrackedParameter<std::string>("setupFile", "");
102 
103  // parallel jobs
104  if ( pset.getUntrackedParameter<int>("jobs", 1) != 1 )
105  jobs_ = pset.getUntrackedParameter<int>("jobs", 1);
106 
107 
108  // Directories from which Herwig reads filesystem
109  std::vector<std::string> aReadDirectories = pset.getUntrackedParameter<std::vector<std::string> >("appendReadDirectories", std::vector<std::string>() );
110  std::vector<std::string> pReadDirectories = pset.getUntrackedParameter<std::vector<std::string> >("prependReadDirectories", std::vector<std::string>() );
111  appendReadDirectories_.insert(appendReadDirectories_.end(), aReadDirectories.begin(), aReadDirectories.end());
112  prependReadDirectories_.insert(prependReadDirectories_.end(), pReadDirectories.begin(), pReadDirectories.end());
113 
114  // Library search path for dlopen()
115  std::vector<std::string> aPath = pset.getUntrackedParameter<std::vector<std::string> >("appendPath", std::vector<std::string>() );
116  std::vector<std::string> pPath = pset.getUntrackedParameter<std::vector<std::string> >("prependPath", std::vector<std::string>() );
117  for ( size_t i = 0; i < aPath.size(); ++i )
118  ThePEG::DynamicLoader::appendPath( aPath[i] );
119  for ( size_t i = 0; i < pPath.size(); ++i )
120  ThePEG::DynamicLoader::prependPath( pPath[i] );
121 
122 
123  // integration list
124  if ( !pset.getUntrackedParameter<std::string>("integrationList", "").empty() ) {
125  integrationList_ = "integrationJob" + pset.getUntrackedParameter<std::string>("integrationList", "1");
126  }
127 
128 
129 
130  // job size
131  if ( pset.getUntrackedParameter<unsigned int>("jobSize", 0) != 0 ) {
132  if ( runMode_ == RunMode::BUILD ) {
133  jobsize_ = pset.getUntrackedParameter<unsigned int>("jobSize", 1);
134  ThePEG::SamplerBase::setIntegratePerJob(jobsize_);
135  }
136  }
137 
138  // max integration jobs
139  if ( pset.getUntrackedParameter<unsigned int>("maxJobs", 0) != 0 ) {
140  if ( runMode_ == RunMode::BUILD ) {
141  maxjobs_ = pset.getUntrackedParameter<unsigned int>("maxJobs", 1);
142  ThePEG::SamplerBase::setIntegrationJobs(maxjobs_);
143  }
144  }
145 
146 
147  // Resume
148  if ( pset.getUntrackedParameter<bool>("resume", false) )
149  resume_ = true;
150 
151 
152 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > appendReadDirectories_
static std::string resolve(const std::string &line)
std::vector< std::string > prependReadDirectories_
static const int ERROR
RunMode::Mode runMode() const override
Requested Herwig run mode.
Herwig::HerwigUIProvider::~HerwigUIProvider ( )
override

Destructor to leave a clean ThePEG::Repository behind.

Definition at line 30 of file HerwigUIProvider.cc.

References edm::cleanup().

30  {
32 }
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12

Member Function Documentation

const std::vector<std::string>& Herwig::HerwigUIProvider::appendReadDirectories ( ) const
inlineoverride

Definition at line 57 of file HerwigUIProvider.h.

References appendReadDirectories_.

57 { return appendReadDirectories_; }
std::vector< std::string > appendReadDirectories_
std::ostream& Herwig::HerwigUIProvider::errStream ( ) const
inlineoverride

Return the standard err stream to be used.

Definition at line 73 of file HerwigUIProvider.h.

References MessageLogger_cfi::cerr.

std::string Herwig::HerwigUIProvider::inputfile ( ) const
inlineoverride

Name of the file to be read.

Definition at line 42 of file HerwigUIProvider.h.

References inputfile_.

42 { return inputfile_; }
std::istream& Herwig::HerwigUIProvider::inStream ( ) const
inlineoverride

Return the standard in stream to be used.

Definition at line 76 of file HerwigUIProvider.h.

References analyzePatCleaning_cfg::inputFile, runMode(), setRunMode(), and AlCaHLTBitMon_QueryRunRegistry::string.

76 { return std::cin; }
std::string Herwig::HerwigUIProvider::integrationList ( ) const
inlineoverride

Definition at line 50 of file HerwigUIProvider.h.

References integrationList_.

50 { return integrationList_; }
int Herwig::HerwigUIProvider::jobs ( ) const
inlineoverride

Definition at line 61 of file HerwigUIProvider.h.

References jobs_.

61 { return jobs_; }
unsigned int Herwig::HerwigUIProvider::jobSize ( ) const
inlineoverride

Definition at line 62 of file HerwigUIProvider.h.

References jobsize_.

62 { return jobsize_; }
unsigned int Herwig::HerwigUIProvider::maxJobs ( ) const
inlineoverride

Definition at line 63 of file HerwigUIProvider.h.

References maxjobs_, quit(), and quitWithHelp().

63 { return maxjobs_; }
long Herwig::HerwigUIProvider::N ( ) const
inlineoverride

Definition at line 59 of file HerwigUIProvider.h.

References nEvents_.

59 { return nEvents_; }
std::ostream& Herwig::HerwigUIProvider::outStream ( ) const
inlineoverride

Return the standard out stream to be used.

Definition at line 70 of file HerwigUIProvider.h.

References gather_cfg::cout.

70 { return std::cout; }
const std::vector<std::string>& Herwig::HerwigUIProvider::prependReadDirectories ( ) const
inlineoverride

Definition at line 54 of file HerwigUIProvider.h.

References prependReadDirectories_.

54 { return prependReadDirectories_; }
std::vector< std::string > prependReadDirectories_
void Herwig::HerwigUIProvider::quit ( ) const
override

Definition at line 25 of file HerwigUIProvider.cc.

References edm::cleanup().

Referenced by maxJobs(), and quitWithHelp().

25  {
27  edm::LogInfo("Herwig7Interface") << "Quitting HerwigUIProvider after ThePEG repository cleanup.";
28 }
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12
void Herwig::HerwigUIProvider::quitWithHelp ( ) const
override

Definition at line 20 of file HerwigUIProvider.cc.

References quit().

Referenced by maxJobs().

20  {
21 edm::LogError("Herwig7Interface") << "An error occured, interface quits now.";
22  quit();
23 }
void quit() const override
std::string Herwig::HerwigUIProvider::repository ( ) const
inlineoverride

Repository name to operate on.

Definition at line 45 of file HerwigUIProvider.h.

References repository_.

45 { return repository_; }
bool Herwig::HerwigUIProvider::resume ( ) const
inlineoverride

Try to resume execution from an earlier interrupted run.

Definition at line 33 of file HerwigUIProvider.h.

References resume_.

33 { return resume_; }
RunMode::Mode Herwig::HerwigUIProvider::runMode ( ) const
inlineoverride

Requested Herwig run mode.

Definition at line 28 of file HerwigUIProvider.h.

References runMode_.

Referenced by inStream(), and setRunMode().

28 { return runMode_; }
int Herwig::HerwigUIProvider::seed ( ) const
inlineoverride

Definition at line 60 of file HerwigUIProvider.h.

References seed_.

Referenced by setSeed().

60 { return seed_; }
void Herwig::HerwigUIProvider::setRunMode ( RunMode::Mode  runMode,
const edm::ParameterSet pset,
std::string  inputFile = "" 
)

Change run mode of Herwig Additionally pass the name of the new input file

Function sets jobsize_ and maxjobs_ accordingly to the run modes.

Definition at line 158 of file HerwigUIProvider.cc.

References edm::ParameterSet::getUntrackedParameter(), inputfile_, jobsize_, maxjobs_, runMode(), and runMode_.

Referenced by inStream().

159 {
160  runMode_ = runMode;
161  if( !inputFile.empty())
163 
164  /* If build mode is chosen set these parameters accordingly, else unset them.*/
165  if (runMode_ == RunMode::BUILD)
166  {
167  // job size
168  if ( pset.getUntrackedParameter<unsigned int>("jobSize", 0) != 0 )
169  {
170  jobsize_ = pset.getUntrackedParameter<unsigned int>("jobSize", 1);
171  ThePEG::SamplerBase::setIntegratePerJob(jobsize_);
172  }
173  // max integration jobs
174  if ( pset.getUntrackedParameter<unsigned int>("maxJobs", 0) != 0 )
175  {
176  maxjobs_ = pset.getUntrackedParameter<unsigned int>("maxJobs", 1);
177  ThePEG::SamplerBase::setIntegrationJobs(maxjobs_);
178  }
179  } else {
180  jobsize_ = 0;
181  ThePEG::SamplerBase::setIntegratePerJob(jobsize_);
182  maxjobs_ = 0;
183  ThePEG::SamplerBase::setIntegrationJobs(maxjobs_);
184  }
185 }
T getUntrackedParameter(std::string const &, T const &) const
RunMode::Mode runMode() const override
Requested Herwig run mode.
void Herwig::HerwigUIProvider::setSeed ( long  seed)
inline

Definition at line 29 of file HerwigUIProvider.h.

References seed(), and seed_.

std::string Herwig::HerwigUIProvider::setupfile ( ) const
inlineoverride

Name of the setup file to be read, to modify the repository.

Definition at line 48 of file HerwigUIProvider.h.

References setupfile_.

48 { return setupfile_; }
std::string Herwig::HerwigUIProvider::tag ( ) const
inlineoverride

A user-defined tag to append to the run name.

Definition at line 39 of file HerwigUIProvider.h.

References tag_.

39 { return tag_; }
bool Herwig::HerwigUIProvider::tics ( ) const
inlineoverride

Require verbose progress markers.

Definition at line 36 of file HerwigUIProvider.h.

References tics_.

36 { return tics_; }

Member Data Documentation

std::vector<std::string> Herwig::HerwigUIProvider::appendReadDirectories_
private

Definition at line 102 of file HerwigUIProvider.h.

Referenced by appendReadDirectories(), and HerwigUIProvider().

std::string Herwig::HerwigUIProvider::inputfile_
private

Definition at line 95 of file HerwigUIProvider.h.

Referenced by inputfile(), and setRunMode().

std::string Herwig::HerwigUIProvider::integrationList_
private

Definition at line 99 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and integrationList().

int Herwig::HerwigUIProvider::jobs_
private

Definition at line 106 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and jobs().

unsigned int Herwig::HerwigUIProvider::jobsize_
private

Definition at line 107 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), jobSize(), and setRunMode().

unsigned int Herwig::HerwigUIProvider::maxjobs_
private

Definition at line 108 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), maxJobs(), and setRunMode().

long Herwig::HerwigUIProvider::nEvents_
private

Definition at line 104 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and N().

std::vector<std::string> Herwig::HerwigUIProvider::prependReadDirectories_
private

Definition at line 101 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and prependReadDirectories().

std::string Herwig::HerwigUIProvider::repository_
private

Definition at line 96 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and repository().

bool Herwig::HerwigUIProvider::resume_
private

Definition at line 91 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and resume().

RunMode::Mode Herwig::HerwigUIProvider::runMode_
private

Definition at line 89 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), runMode(), and setRunMode().

int Herwig::HerwigUIProvider::seed_
private

Definition at line 105 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), seed(), and setSeed().

std::string Herwig::HerwigUIProvider::setupfile_
private

Definition at line 97 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and setupfile().

std::string Herwig::HerwigUIProvider::tag_
private

Definition at line 93 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and tag().

bool Herwig::HerwigUIProvider::tics_
private

Definition at line 92 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and tics().