CMS 3D CMS Logo

HerwigUIProvider.cc
Go to the documentation of this file.
1 
7 
11 
12 #include <ThePEG/Utilities/DynamicLoader.h>
13 #include <ThePEG/Utilities/Debug.h>
14 #include <ThePEG/Repository/Repository.h>
15 #include <ThePEG/Handlers/SamplerBase.h>
16 
17 namespace Herwig {
18 
20  edm::LogError("Herwig7Interface") << "An error occured, interface quits now.";
21  quit();
22  }
23 
24  void HerwigUIProvider::quit() const {
26  edm::LogInfo("Herwig7Interface") << "Quitting HerwigUIProvider after ThePEG repository cleanup.";
27  }
28 
30 
32  : runMode_(runMode),
33  resume_(false),
34  tics_(true),
35  tag_(),
36  inputfile_(inputFileName),
37  repository_(),
38  setupfile_(),
39  integrationList_(),
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  }
148 
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  }
173  // End Herwig namespace
174 } // namespace Herwig
Herwig::HerwigUIProvider::seed_
int seed_
Definition: HerwigUIProvider.h:98
Herwig::HerwigUIProvider::HerwigUIProvider
HerwigUIProvider(const edm::ParameterSet &pset, std::string inputFileName, RunMode::Mode)
Constructor from the arguments provided by CMSSW.
Definition: HerwigUIProvider.cc:31
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
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
HcalTopologyMode::Mode
Mode
Definition: HcalTopologyMode.h:26
Herwig::HerwigUIProvider::appendReadDirectories_
std::vector< std::string > appendReadDirectories_
Definition: HerwigUIProvider.h:95
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::quitWithHelp
void quitWithHelp() const override
Definition: HerwigUIProvider.cc:19
Herwig::HerwigUIProvider::inputfile_
std::string inputfile_
Definition: HerwigUIProvider.h:88
ParameterCollector.h
HerwigUIProvider.h
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
Herwig
Definition: HerwigUIProvider.h:12
Herwig::HerwigUIProvider::~HerwigUIProvider
~HerwigUIProvider() override
Destructor to leave a clean ThePEG::Repository behind.
Definition: HerwigUIProvider.cc:29
edm::ParameterSet
Definition: ParameterSet.h:47
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
TopDecaySubset_cfi.runMode
runMode
define run mode.
Definition: TopDecaySubset_cfi.py:19
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
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:54
Herwig::HerwigUIProvider::setRunMode
void setRunMode(RunMode::Mode runMode, const edm::ParameterSet &pset, std::string inputFile="")
Definition: HerwigUIProvider.cc:149
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
RandomEngineGlue.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::cleanup
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12