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
 
virtual std::ostream & errStream () const
 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
 Name of the file to be read. More...
 
virtual std::istream & inStream () const
 Return the standard in stream to be used. More...
 
std::string integrationList () const
 
int jobs () const
 
unsigned int jobSize () const
 
unsigned int maxJobs () const
 
long N () const
 
virtual std::ostream & outStream () const
 Return the standard out stream to be used. More...
 
const std::vector< std::string > & prependReadDirectories () const
 
void quit () const
 
void quitWithHelp () const
 
std::string repository () const
 Repository name to operate on. More...
 
bool resume () const
 Try to resume execution from an earlier interrupted run. More...
 
RunMode::Mode runMode () const
 Requested Herwig run mode. More...
 
int seed () const
 
void setRunMode (RunMode::Mode runMode, const edm::ParameterSet &pset, std::string inputFile="")
 
std::string setupfile () const
 Name of the setup file to be read, to modify the repository. More...
 
std::string tag () const
 A user-defined tag to append to the run name. More...
 
bool tics () const
 Require verbose progress markers. More...
 
 ~HerwigUIProvider ()
 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", "") != "")
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", "") != "" )
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", "") != "" ) {
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_
RunMode::Mode runMode() const
Requested Herwig run mode.
static const int ERROR
Herwig::HerwigUIProvider::~HerwigUIProvider ( )

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
inline

Definition at line 55 of file HerwigUIProvider.h.

References appendReadDirectories_.

55 { return appendReadDirectories_; }
std::vector< std::string > appendReadDirectories_
virtual std::ostream& Herwig::HerwigUIProvider::errStream ( ) const
inlinevirtual

Return the standard err stream to be used.

Definition at line 71 of file HerwigUIProvider.h.

References MessageLogger_cfi::cerr.

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

Name of the file to be read.

Definition at line 40 of file HerwigUIProvider.h.

References inputfile_.

40 { return inputfile_; }
virtual std::istream& Herwig::HerwigUIProvider::inStream ( ) const
inlinevirtual

Return the standard in stream to be used.

Definition at line 74 of file HerwigUIProvider.h.

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

74 { return std::cin; }
std::string Herwig::HerwigUIProvider::integrationList ( ) const
inline

Definition at line 48 of file HerwigUIProvider.h.

References integrationList_.

48 { return integrationList_; }
int Herwig::HerwigUIProvider::jobs ( ) const
inline

Definition at line 59 of file HerwigUIProvider.h.

References jobs_.

59 { return jobs_; }
unsigned int Herwig::HerwigUIProvider::jobSize ( ) const
inline

Definition at line 60 of file HerwigUIProvider.h.

References jobsize_.

60 { return jobsize_; }
unsigned int Herwig::HerwigUIProvider::maxJobs ( ) const
inline

Definition at line 61 of file HerwigUIProvider.h.

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

61 { return maxjobs_; }
long Herwig::HerwigUIProvider::N ( ) const
inline

Definition at line 57 of file HerwigUIProvider.h.

References nEvents_.

57 { return nEvents_; }
virtual std::ostream& Herwig::HerwigUIProvider::outStream ( ) const
inlinevirtual

Return the standard out stream to be used.

Definition at line 68 of file HerwigUIProvider.h.

References gather_cfg::cout.

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

Definition at line 52 of file HerwigUIProvider.h.

References prependReadDirectories_.

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

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

Definition at line 20 of file HerwigUIProvider.cc.

References quit().

Referenced by Herwig7Interface::callHerwigGenerator(), and maxJobs().

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

Repository name to operate on.

Definition at line 43 of file HerwigUIProvider.h.

References repository_.

43 { return repository_; }
bool Herwig::HerwigUIProvider::resume ( ) const
inline

Try to resume execution from an earlier interrupted run.

Definition at line 31 of file HerwigUIProvider.h.

References resume_.

31 { return resume_; }
RunMode::Mode Herwig::HerwigUIProvider::runMode ( ) const
inline
int Herwig::HerwigUIProvider::seed ( ) const
inline

Definition at line 58 of file HerwigUIProvider.h.

References seed_.

58 { 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 Herwig7Interface::initRepository(), and 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
Requested Herwig run mode.
std::string Herwig::HerwigUIProvider::setupfile ( ) const
inline

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

Definition at line 46 of file HerwigUIProvider.h.

References setupfile_.

46 { return setupfile_; }
std::string Herwig::HerwigUIProvider::tag ( ) const
inline

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

Definition at line 37 of file HerwigUIProvider.h.

References tag_.

37 { return tag_; }
bool Herwig::HerwigUIProvider::tics ( ) const
inline

Require verbose progress markers.

Definition at line 34 of file HerwigUIProvider.h.

References tics_.

34 { return tics_; }

Member Data Documentation

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

Definition at line 100 of file HerwigUIProvider.h.

Referenced by appendReadDirectories(), and HerwigUIProvider().

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

Definition at line 93 of file HerwigUIProvider.h.

Referenced by inputfile(), and setRunMode().

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

Definition at line 97 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and integrationList().

int Herwig::HerwigUIProvider::jobs_
private

Definition at line 104 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and jobs().

unsigned int Herwig::HerwigUIProvider::jobsize_
private

Definition at line 105 of file HerwigUIProvider.h.

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

unsigned int Herwig::HerwigUIProvider::maxjobs_
private

Definition at line 106 of file HerwigUIProvider.h.

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

long Herwig::HerwigUIProvider::nEvents_
private

Definition at line 102 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and N().

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

Definition at line 99 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and prependReadDirectories().

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

Definition at line 94 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and repository().

bool Herwig::HerwigUIProvider::resume_
private

Definition at line 89 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and resume().

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

Definition at line 87 of file HerwigUIProvider.h.

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

int Herwig::HerwigUIProvider::seed_
private

Definition at line 103 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and seed().

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

Definition at line 95 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and setupfile().

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

Definition at line 91 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and tag().

bool Herwig::HerwigUIProvider::tics_
private

Definition at line 90 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and tics().