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

◆ HerwigUIProvider()

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

Constructor from the arguments provided by CMSSW.

Definition at line 31 of file HerwigUIProvider.cc.

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

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

◆ ~HerwigUIProvider()

Herwig::HerwigUIProvider::~HerwigUIProvider ( )
override

Destructor to leave a clean ThePEG::Repository behind.

Definition at line 29 of file HerwigUIProvider.cc.

References edm::cleanup().

Member Function Documentation

◆ appendReadDirectories()

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

Definition at line 52 of file HerwigUIProvider.h.

52 { return appendReadDirectories_; }

References appendReadDirectories_.

◆ errStream()

std::ostream& Herwig::HerwigUIProvider::errStream ( ) const
inlineoverride

Return the standard err stream to be used.

Definition at line 68 of file HerwigUIProvider.h.

68 { return std::cerr; }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr.

◆ inputfile()

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

Name of the file to be read.

Definition at line 40 of file HerwigUIProvider.h.

40 { return inputfile_; }

References inputfile_.

◆ inStream()

std::istream& Herwig::HerwigUIProvider::inStream ( ) const
inlineoverride

Return the standard in stream to be used.

Definition at line 71 of file HerwigUIProvider.h.

71 { return std::cin; }

◆ integrationList()

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

Definition at line 48 of file HerwigUIProvider.h.

48 { return integrationList_; }

References integrationList_.

◆ jobs()

int Herwig::HerwigUIProvider::jobs ( ) const
inlineoverride

Definition at line 56 of file HerwigUIProvider.h.

56 { return jobs_; }

References jobs_.

◆ jobSize()

unsigned int Herwig::HerwigUIProvider::jobSize ( ) const
inlineoverride

Definition at line 57 of file HerwigUIProvider.h.

57 { return jobsize_; }

References jobsize_.

◆ maxJobs()

unsigned int Herwig::HerwigUIProvider::maxJobs ( ) const
inlineoverride

Definition at line 58 of file HerwigUIProvider.h.

58 { return maxjobs_; }

References maxjobs_.

◆ N()

long Herwig::HerwigUIProvider::N ( ) const
inlineoverride

Definition at line 54 of file HerwigUIProvider.h.

54 { return nEvents_; }

References nEvents_.

◆ outStream()

std::ostream& Herwig::HerwigUIProvider::outStream ( ) const
inlineoverride

Return the standard out stream to be used.

Definition at line 65 of file HerwigUIProvider.h.

65 { return std::cout; }

References gather_cfg::cout.

◆ prependReadDirectories()

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

Definition at line 50 of file HerwigUIProvider.h.

50 { return prependReadDirectories_; }

References prependReadDirectories_.

◆ quit()

void Herwig::HerwigUIProvider::quit ( ) const
override

Definition at line 24 of file HerwigUIProvider.cc.

24  {
26  edm::LogInfo("Herwig7Interface") << "Quitting HerwigUIProvider after ThePEG repository cleanup.";
27  }

References edm::cleanup().

Referenced by quitWithHelp().

◆ quitWithHelp()

void Herwig::HerwigUIProvider::quitWithHelp ( ) const
override

Definition at line 19 of file HerwigUIProvider.cc.

19  {
20  edm::LogError("Herwig7Interface") << "An error occured, interface quits now.";
21  quit();
22  }

References quit().

◆ repository()

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

Repository name to operate on.

Definition at line 43 of file HerwigUIProvider.h.

43 { return repository_; }

References repository_.

◆ resume()

bool Herwig::HerwigUIProvider::resume ( ) const
inlineoverride

Try to resume execution from an earlier interrupted run.

Definition at line 31 of file HerwigUIProvider.h.

31 { return resume_; }

References resume_.

◆ runMode()

RunMode::Mode Herwig::HerwigUIProvider::runMode ( ) const
inlineoverride

Requested Herwig run mode.

Definition at line 27 of file HerwigUIProvider.h.

27 { return runMode_; }

References runMode_.

Referenced by setRunMode().

◆ seed()

int Herwig::HerwigUIProvider::seed ( ) const
inlineoverride

Definition at line 55 of file HerwigUIProvider.h.

55 { return seed_; }

References seed_.

Referenced by setSeed().

◆ setRunMode()

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 149 of file HerwigUIProvider.cc.

149  {
150  runMode_ = runMode;
151  if (!inputFile.empty())
153 
154  /* If build mode is chosen set these parameters accordingly, else unset them.*/
155  if (runMode_ == RunMode::BUILD) {
156  // job size
157  if (pset.getUntrackedParameter<unsigned int>("jobSize", 0) != 0) {
158  jobsize_ = pset.getUntrackedParameter<unsigned int>("jobSize", 1);
159  ThePEG::SamplerBase::setIntegratePerJob(jobsize_);
160  }
161  // max integration jobs
162  if (pset.getUntrackedParameter<unsigned int>("maxJobs", 0) != 0) {
163  maxjobs_ = pset.getUntrackedParameter<unsigned int>("maxJobs", 1);
164  ThePEG::SamplerBase::setIntegrationJobs(maxjobs_);
165  }
166  } else {
167  jobsize_ = 0;
168  ThePEG::SamplerBase::setIntegratePerJob(jobsize_);
169  maxjobs_ = 0;
170  ThePEG::SamplerBase::setIntegrationJobs(maxjobs_);
171  }
172  }

References dtResolutionTest_cfi::inputFile, inputfile_, jobsize_, maxjobs_, muonDTDigis_cfi::pset, runMode(), and runMode_.

◆ setSeed()

void Herwig::HerwigUIProvider::setSeed ( long  seed)
inline

Definition at line 28 of file HerwigUIProvider.h.

28 { seed_ = seed; }

References seed(), and seed_.

◆ setupfile()

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

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

Definition at line 46 of file HerwigUIProvider.h.

46 { return setupfile_; }

References setupfile_.

◆ tag()

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

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

Definition at line 37 of file HerwigUIProvider.h.

37 { return tag_; }

References tag_.

◆ tics()

bool Herwig::HerwigUIProvider::tics ( ) const
inlineoverride

Require verbose progress markers.

Definition at line 34 of file HerwigUIProvider.h.

34 { return tics_; }

References tics_.

Member Data Documentation

◆ appendReadDirectories_

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

Definition at line 95 of file HerwigUIProvider.h.

Referenced by appendReadDirectories(), and HerwigUIProvider().

◆ inputfile_

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

Definition at line 88 of file HerwigUIProvider.h.

Referenced by inputfile(), and setRunMode().

◆ integrationList_

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

Definition at line 92 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and integrationList().

◆ jobs_

int Herwig::HerwigUIProvider::jobs_
private

Definition at line 99 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and jobs().

◆ jobsize_

unsigned int Herwig::HerwigUIProvider::jobsize_
private

Definition at line 100 of file HerwigUIProvider.h.

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

◆ maxjobs_

unsigned int Herwig::HerwigUIProvider::maxjobs_
private

Definition at line 101 of file HerwigUIProvider.h.

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

◆ nEvents_

long Herwig::HerwigUIProvider::nEvents_
private

Definition at line 97 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and N().

◆ prependReadDirectories_

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

Definition at line 94 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and prependReadDirectories().

◆ repository_

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

Definition at line 89 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and repository().

◆ resume_

bool Herwig::HerwigUIProvider::resume_
private

Definition at line 84 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and resume().

◆ runMode_

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

Definition at line 82 of file HerwigUIProvider.h.

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

◆ seed_

int Herwig::HerwigUIProvider::seed_
private

Definition at line 98 of file HerwigUIProvider.h.

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

◆ setupfile_

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

Definition at line 90 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and setupfile().

◆ tag_

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

Definition at line 86 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and tag().

◆ tics_

bool Herwig::HerwigUIProvider::tics_
private

Definition at line 85 of file HerwigUIProvider.h.

Referenced by HerwigUIProvider(), and tics().

Herwig::HerwigUIProvider::seed_
int seed_
Definition: HerwigUIProvider.h:98
Herwig::HerwigUIProvider::runMode
RunMode::Mode runMode() const override
Requested Herwig run mode.
Definition: HerwigUIProvider.h:27
mps_fire.i
i
Definition: mps_fire.py:428
Herwig::HerwigUIProvider::appendReadDirectories_
std::vector< std::string > appendReadDirectories_
Definition: HerwigUIProvider.h:95
gather_cfg.cout
cout
Definition: gather_cfg.py:144
Herwig::HerwigUIProvider::jobs_
int jobs_
Definition: HerwigUIProvider.h:99
Herwig::HerwigUIProvider::nEvents_
long nEvents_
Definition: HerwigUIProvider.h:97
Herwig::HerwigUIProvider::setupfile_
std::string setupfile_
Definition: HerwigUIProvider.h:90
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
Herwig::HerwigUIProvider::tics_
bool tics_
Definition: HerwigUIProvider.h:85
Herwig::HerwigUIProvider::jobsize_
unsigned int jobsize_
Definition: HerwigUIProvider.h:100
Herwig::HerwigUIProvider::resume_
bool resume_
Definition: HerwigUIProvider.h:84
InefficientDoubleROC.inputFileName
inputFileName
Definition: InefficientDoubleROC.py:437
Herwig::HerwigUIProvider::inputfile_
std::string inputfile_
Definition: HerwigUIProvider.h:88
Herwig::HerwigUIProvider::integrationList_
std::string integrationList_
Definition: HerwigUIProvider.h:92
Herwig::HerwigUIProvider::prependReadDirectories_
std::vector< std::string > prependReadDirectories_
Definition: HerwigUIProvider.h:94
Herwig::HerwigUIProvider::maxjobs_
unsigned int maxjobs_
Definition: HerwigUIProvider.h:101
Herwig::HerwigUIProvider::seed
int seed() const override
Definition: HerwigUIProvider.h:55
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Herwig::HerwigUIProvider::tag_
std::string tag_
Definition: HerwigUIProvider.h:86
Herwig::HerwigUIProvider::runMode_
RunMode::Mode runMode_
Definition: HerwigUIProvider.h:82
Herwig::HerwigUIProvider::repository_
std::string repository_
Definition: HerwigUIProvider.h:89
dqm::qstatus::ERROR
static const int ERROR
Definition: MonitorElement.h:55
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
Herwig::HerwigUIProvider::quit
void quit() const override
Definition: HerwigUIProvider.cc:24
gen::ParameterCollector::resolve
static std::string resolve(const std::string &line)
Definition: ParameterCollector.cc:117
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::cleanup
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12