#include <GeneratorFileOrCmd.h>
Inherited by o2::eventgen::GeneratorHepMC, and o2::eventgen::GeneratorTParticle.
Service class for either reading from a file or executing a program writing to a specific file
Definition at line 31 of file GeneratorFileOrCmd.h.
◆ ensureFiles()
| bool o2::eventgen::GeneratorFileOrCmd::ensureFiles |
( |
| ) |
|
|
protectedvirtual |
Ensure that all files in the list of file names exists. If any of te file names point to a net resource (e.g., alien://or https://) then this member function should not be called
The file names registered are replaced with their canonical path equivalents.
- Returns
- true if all currently registered file names can be found.
Definition at line 270 of file GeneratorFileOrCmd.cxx.
◆ executeCmdLine()
| bool o2::eventgen::GeneratorFileOrCmd::executeCmdLine |
( |
const std::string & |
cmd | ) |
|
|
protectedvirtual |
Execute a command line (presumably formatted by makeCmdLine). If the command failed to execute, then make it a fatal error.
- Parameters
-
| cmd | Command line to execute, presumabley formatted by makeCmdLine. |
- Returns
- true if the background command line was executed, false otherwise.
Definition at line 120 of file GeneratorFileOrCmd.cxx.
◆ makeCmdLine()
| std::string o2::eventgen::GeneratorFileOrCmd::makeCmdLine |
( |
| ) |
const |
|
protectedvirtual |
Format a command line using the set command line, option flags, and option values.
- Returns
- formatted command line.
Definition at line 100 of file GeneratorFileOrCmd.cxx.
◆ makeFifo()
| bool o2::eventgen::GeneratorFileOrCmd::makeFifo |
( |
| ) |
const |
|
protectedvirtual |
Make a fifo at the location of the first element of the list of file names (presumably a temporary file as created by makeTemp).
- Returns
- true if the FIFo was made correctly
Definition at line 252 of file GeneratorFileOrCmd.cxx.
◆ makeTemp()
| bool o2::eventgen::GeneratorFileOrCmd::makeTemp |
( |
const bool & |
fromName | ) |
|
|
protectedvirtual |
Create a temporary file (and close it immediately). On success, the list of file names is cleared and the name of the temporary file set as the sole element in that list.
- Returns
- true if the temporary file name was generated successfully.
Definition at line 188 of file GeneratorFileOrCmd.cxx.
◆ removeTemp()
| bool o2::eventgen::GeneratorFileOrCmd::removeTemp |
( |
| ) |
const |
|
protectedvirtual |
Remove the temporary file if it was set and it exists.
- Returns
- true if the temporary file was removed.
Definition at line 225 of file GeneratorFileOrCmd.cxx.
◆ setBackgroundSwitch()
| void o2::eventgen::GeneratorFileOrCmd::setBackgroundSwitch |
( |
const std::string & |
opt | ) |
|
|
inline |
Set the background switch.
- Parameters
-
| opt | Command line switch (e.g., &) to detach and send the event generator program into the background. |
Definition at line 119 of file GeneratorFileOrCmd.h.
◆ setBmax()
| void o2::eventgen::GeneratorFileOrCmd::setBmax |
( |
float |
bmax | ) |
|
|
inline |
Set the maximum impact parameter to sample by a background command. This should come from SimConfig::getBMax()
- Parameters
-
| bmax | Maximum impact parameter, in fm, to sample. This is passed to the command line via the mBmaxSwitch. |
Definition at line 78 of file GeneratorFileOrCmd.h.
◆ setBmaxSwitch()
| void o2::eventgen::GeneratorFileOrCmd::setBmaxSwitch |
( |
const std::string & |
opt | ) |
|
|
inline |
Set the maximum impact parameter switch.
- Parameters
-
| opt | Command line switch (e.g., -b) to specify the maximum impact parameter (in fm) to sample when generating events. |
Definition at line 112 of file GeneratorFileOrCmd.h.
◆ setCmd()
| void o2::eventgen::GeneratorFileOrCmd::setCmd |
( |
const std::string & |
cmd | ) |
|
|
inline |
Set command to execute in bacground rather than reading from existing file(s)
- Parameters
-
| cmd | Command line. Can include options for the program to execute, but should not include pipes. |
Definition at line 48 of file GeneratorFileOrCmd.h.
◆ setCmdPid()
| void o2::eventgen::GeneratorFileOrCmd::setCmdPid |
( |
const pid_t |
cmdPid | ) |
|
|
inline |
◆ setFileNames()
| void o2::eventgen::GeneratorFileOrCmd::setFileNames |
( |
const std::string & |
filenames | ) |
|
Set the file names to read from.
- Parameters
-
| filenames | A comma seperated list of files to read from. |
Definition at line 91 of file GeneratorFileOrCmd.cxx.
◆ setNEvents()
| void o2::eventgen::GeneratorFileOrCmd::setNEvents |
( |
unsigned int |
nev | ) |
|
|
inline |
Set the number of events that a background command should generate. This should come from SimConfig::getNEents.
- Parameters
-
| nev | Number of events to generate. This is passed via mNEventsSwitch to the command line. |
Definition at line 62 of file GeneratorFileOrCmd.h.
◆ setNEventsSwitch()
| void o2::eventgen::GeneratorFileOrCmd::setNEventsSwitch |
( |
const std::string & |
opt | ) |
|
|
inline |
Set the nevents switch.
- Parameters
-
| opt | Command line switch (e.g., -n) to specify the number of events to generate. |
Definition at line 104 of file GeneratorFileOrCmd.h.
◆ setOutputSwitch()
| void o2::eventgen::GeneratorFileOrCmd::setOutputSwitch |
( |
const std::string & |
opt | ) |
|
|
inline |
Set the output switch.
- Parameters
-
| opt | Command line switch (e.g., -o) to specify output file name. |
Definition at line 90 of file GeneratorFileOrCmd.h.
◆ setSeed()
| void o2::eventgen::GeneratorFileOrCmd::setSeed |
( |
unsigned long |
seed | ) |
|
|
inline |
Set the random number seed that a background command should use. This should come from SimConfig::getStartSeed
- Parameters
-
| seed | Random number seed. Will be passed to the commandline using the mSeedSwitch. |
Definition at line 70 of file GeneratorFileOrCmd.h.
◆ setSeedSwitch()
| void o2::eventgen::GeneratorFileOrCmd::setSeedSwitch |
( |
const std::string & |
opt | ) |
|
|
inline |
Set the seed switch.
- Parameters
-
| opt | Command line switch (e.g., -s) to specify the random number seed to use when generating events. |
Definition at line 97 of file GeneratorFileOrCmd.h.
◆ setup() [1/2]
◆ setup() [2/2]
Configure the generator from parameters and the general simulation configuration. This is implemented as a member function so as to better facilitate changes.
Definition at line 60 of file GeneratorFileOrCmd.cxx.
◆ setWait()
| void o2::eventgen::GeneratorFileOrCmd::setWait |
( |
int |
miliseconds = 500 | ) |
|
|
inline |
◆ terminateCmd()
| bool o2::eventgen::GeneratorFileOrCmd::terminateCmd |
( |
unsigned int |
graceMillis = 0 | ) |
|
|
protectedvirtual |
Terminates the background command using PID of the child process generated by fork.
- Parameters
-
| graceMillis | How long to wait for the command to exit on its own before killing its process group. A command started through an intermediate shell (a wrapper script, say) only contributes the CPU time of the actual generator to this process' RUSAGE_CHILDREN once that shell has reaped it, which it can no longer do once we have killed it. Zero preserves the previous kill-immediately behaviour. |
- Returns
- true if the process was terminated successfully
Definition at line 145 of file GeneratorFileOrCmd.cxx.
◆ waitForData()
| void o2::eventgen::GeneratorFileOrCmd::waitForData |
( |
const std::string & |
filename | ) |
const |
|
protectedvirtual |
Wait for data to be available in case we're executing a background command
Definition at line 284 of file GeneratorFileOrCmd.cxx.
◆ mBackgroundSwitch
| std::string o2::eventgen::GeneratorFileOrCmd::mBackgroundSwitch = "&" |
|
protected |
The "switch" to put the program being executed in the background.
Definition at line 261 of file GeneratorFileOrCmd.h.
◆ mBmax
| float o2::eventgen::GeneratorFileOrCmd::mBmax = -1.f |
|
protected |
Maximum impact parameter to sample in case we're executing a command. IF negative, then it is not passed to the command. This is passed to the command via the switch mBmaxSwitch
Definition at line 235 of file GeneratorFileOrCmd.h.
◆ mBmaxSwitch
| std::string o2::eventgen::GeneratorFileOrCmd::mBmaxSwitch = "-b" |
|
protected |
The switch to specify maximum impact parameter to sample by the program being executed.
Definition at line 256 of file GeneratorFileOrCmd.h.
◆ mCmd
| std::string o2::eventgen::GeneratorFileOrCmd::mCmd = "" |
|
protected |
Possible command line to execute. The command executed must accept the switches defined below. Note if mOutputSwitch is set to ">", then the program must write data to standard output
Definition at line 208 of file GeneratorFileOrCmd.h.
◆ mCmdPid
| int o2::eventgen::GeneratorFileOrCmd::mCmdPid = -1 |
|
protected |
◆ mFileNames
| std::list<std::string> o2::eventgen::GeneratorFileOrCmd::mFileNames |
|
protected |
List of file names to read. In case we're executing a command, then there will only be one file name in the list
Definition at line 213 of file GeneratorFileOrCmd.h.
◆ mNEvents
| unsigned int o2::eventgen::GeneratorFileOrCmd::mNEvents = 0 |
|
protected |
Number of events to generate in case we're executing a command. This is passed to the program via the switch mNEventsSwitch
Definition at line 223 of file GeneratorFileOrCmd.h.
◆ mNEventsSwitch
| std::string o2::eventgen::GeneratorFileOrCmd::mNEventsSwitch = "-n" |
|
protected |
The switch to specify the number of events to generate to the program being executed
Definition at line 251 of file GeneratorFileOrCmd.h.
◆ mOutputSwitch
| std::string o2::eventgen::GeneratorFileOrCmd::mOutputSwitch = ">" |
|
protected |
Switch to direct output to specified file. In case of a fifo, this should often be ">" - i.e., the standard output of the program is redirected to the fifo.
Definition at line 241 of file GeneratorFileOrCmd.h.
◆ mSeed
| unsigned long o2::eventgen::GeneratorFileOrCmd::mSeed = 0 |
|
protected |
Random number seed to use in case we're executing a command. This is passed to the program via the switch mSeedSwitch
Definition at line 229 of file GeneratorFileOrCmd.h.
◆ mSeedSwitch
| std::string o2::eventgen::GeneratorFileOrCmd::mSeedSwitch = "-s" |
|
protected |
The switch specify the random number seed to the program executed
Definition at line 246 of file GeneratorFileOrCmd.h.
◆ mTemporary
| std::string o2::eventgen::GeneratorFileOrCmd::mTemporary |
|
protected |
◆ mWait
| int o2::eventgen::GeneratorFileOrCmd::mWait = 500 |
|
protected |
◆ sStopGraceMillis
| constexpr unsigned int o2::eventgen::GeneratorFileOrCmd::sStopGraceMillis = 5000 |
|
staticconstexprprotected |
Time granted to the command to exit by itself when the generator is stopped normally. It has produced everything that was asked of it by then, so this only covers its teardown.
Definition at line 162 of file GeneratorFileOrCmd.h.
The documentation for this struct was generated from the following files: