Skip to content

Commit bd03ecd

Browse files
committed
Formatting fixes and bring docs into Sync
1 parent 634f5f9 commit bd03ecd

File tree

7 files changed

+177
-132
lines changed

7 files changed

+177
-132
lines changed

Generators/src/GeneratorHepMC.cxx

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -178,31 +178,55 @@ void putAttributeInfo(o2::dataformats::MCEventHeader* eventHeader,
178178
const std::string& name,
179179
const std::shared_ptr<HepMC3::Attribute>& a)
180180
{
181-
using IntAttribute=HepMC3::IntAttribute;
182-
using LongAttribute=HepMC3::LongAttribute;
183-
using FloatAttribute=HepMC3::FloatAttribute;
184-
using DoubleAttribute=HepMC3::DoubleAttribute;
185-
using StringAttribute=HepMC3::StringAttribute;
186-
using CharAttribute=HepMC3::CharAttribute;
187-
using LongLongAttribute=HepMC3::LongLongAttribute;
188-
using LongDoubleAttribute=HepMC3::LongDoubleAttribute;
189-
using UIntAttribute=HepMC3::UIntAttribute;
190-
using ULongAttribute=HepMC3::ULongAttribute;
191-
using ULongLongAttribute=HepMC3::ULongLongAttribute;
192-
using BoolAttribute=HepMC3::BoolAttribute;
193-
194-
if (putAttributeInfoImpl<IntAttribute, int>(eventHeader, name, a)) return;
195-
if (putAttributeInfoImpl<LongAttribute, int>(eventHeader, name, a)) return;
196-
if (putAttributeInfoImpl<FloatAttribute, float>(eventHeader, name, a)) return;
197-
if (putAttributeInfoImpl<DoubleAttribute, float>(eventHeader, name, a)) return;
198-
if (putAttributeInfoImpl<StringAttribute, std::string>(eventHeader, name, a)) return;
199-
if (putAttributeInfoImpl<CharAttribute, char>(eventHeader, name, a)) return;
200-
if (putAttributeInfoImpl<LongLongAttribute, int>(eventHeader, name, a)) return;
201-
if (putAttributeInfoImpl<LongDoubleAttribute, float>(eventHeader, name, a)) return;
202-
if (putAttributeInfoImpl<UIntAttribute, int>(eventHeader, name, a)) return;
203-
if (putAttributeInfoImpl<ULongAttribute, int>(eventHeader, name, a)) return;
204-
if (putAttributeInfoImpl<ULongLongAttribute, int>(eventHeader, name, a)) return;
205-
if (putAttributeInfoImpl<BoolAttribute, bool>(eventHeader, name, a)) return;
181+
using IntAttribute = HepMC3::IntAttribute;
182+
using LongAttribute = HepMC3::LongAttribute;
183+
using FloatAttribute = HepMC3::FloatAttribute;
184+
using DoubleAttribute = HepMC3::DoubleAttribute;
185+
using StringAttribute = HepMC3::StringAttribute;
186+
using CharAttribute = HepMC3::CharAttribute;
187+
using LongLongAttribute = HepMC3::LongLongAttribute;
188+
using LongDoubleAttribute = HepMC3::LongDoubleAttribute;
189+
using UIntAttribute = HepMC3::UIntAttribute;
190+
using ULongAttribute = HepMC3::ULongAttribute;
191+
using ULongLongAttribute = HepMC3::ULongLongAttribute;
192+
using BoolAttribute = HepMC3::BoolAttribute;
193+
194+
if (putAttributeInfoImpl<IntAttribute, int>(eventHeader, name, a)) {
195+
return;
196+
}
197+
if (putAttributeInfoImpl<LongAttribute, int>(eventHeader, name, a)) {
198+
return;
199+
}
200+
if (putAttributeInfoImpl<FloatAttribute, float>(eventHeader, name, a)) {
201+
return;
202+
}
203+
if (putAttributeInfoImpl<DoubleAttribute, float>(eventHeader, name, a)) {
204+
return;
205+
}
206+
if (putAttributeInfoImpl<StringAttribute, std::string>(eventHeader, name, a)) {
207+
return;
208+
}
209+
if (putAttributeInfoImpl<CharAttribute, char>(eventHeader, name, a)) {
210+
return;
211+
}
212+
if (putAttributeInfoImpl<LongLongAttribute, int>(eventHeader, name, a)) {
213+
return;
214+
}
215+
if (putAttributeInfoImpl<LongDoubleAttribute, float>(eventHeader, name, a)) {
216+
return;
217+
}
218+
if (putAttributeInfoImpl<UIntAttribute, int>(eventHeader, name, a)) {
219+
return;
220+
}
221+
if (putAttributeInfoImpl<ULongAttribute, int>(eventHeader, name, a)) {
222+
return;
223+
}
224+
if (putAttributeInfoImpl<ULongLongAttribute, int>(eventHeader, name, a)) {
225+
return;
226+
}
227+
if (putAttributeInfoImpl<BoolAttribute, bool>(eventHeader, name, a)) {
228+
return;
229+
}
206230
}
207231
} // namespace
208232

run/SimExamples/HepMC/README.md

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
Here are pointers on how to use `GeneratorHepMC` selected by the
66
option `-g hepmc` for `o2-sim`.
77

8+
HepMC event structures can be read from any file format supported by
9+
HepMC it self (see
10+
[here](http://hepmc.web.cern.ch/hepmc/group__IO.html) and
11+
[here](http://hepmc.web.cern.ch/hepmc/group__factory.html).
12+
813
## Reading HepMC files
914

1015
The generator `GeneratorHepMC` can read events from a
@@ -23,7 +28,7 @@ event files in the HepMC format.
2328

2429
To make a simulation reading from the file `events.hepmc`, do
2530

26-
o2-sim -g hepmc --configKeyValues "HepMC.fileName=events.hepmc" ...
31+
o2-sim -g hepmc --configKeyValues "FileOrCmd.fileNames=events.hepmc" ...
2732

2833
See also [`read.sh`](read.sh).
2934

@@ -34,17 +39,34 @@ named `eg` which is some EG that writes HepMC event records to the
3439
standard output. Then we can execute a simulation using this external
3540
EG by
3641

37-
o2-sim -g hepmc --configKeyValues "HepMC.progCmd=eg"
42+
o2-sim -g hepmc --configKeyValues "FileOrCmd.cmd=eg"
3843

3944
See also [`child.sh`](child.sh).
4045

4146
There are some requirements on the program `eg`:
4247

43-
- It _must_ write the HepMC event structures to standard output
44-
(`/dev/stdout`).
45-
- It may _not_ write other information to standard output.
46-
- It _must_ accept the option `-n n-events` to set the number of
47-
events to produce to `n-events`.
48+
- The EG program _must_ be able to write the HepMC event structures to
49+
a specified file. The option passed to the program is specified via
50+
the key `FileOrCmd.outputSwitch`. This defaults to `>` which means
51+
the EG program is assumed to write the HepMC event structures to
52+
standard output, _and_ that nothing else is printed on standard
53+
output.
54+
- It _must_ accept an option to set the number of events to generate.
55+
This is controlled by the configuration key
56+
`FileOrCmd.nEventsSwitch` and defaults to `-n`. Thus, the EG
57+
application should accept `-n 10` to mean that it should generate
58+
`10` events, for example.
59+
- The EG application should accept a command line switch to set the
60+
random number generator seed. This option is specified via the
61+
configuration key `FileOrCmd.seedSwitch` and defaults to `-s`.
62+
Thus, the EG application must accept `-s 123456` to mean to set the
63+
random number seed to `123456` for example.
64+
- The EG application should accept a command line switch to set the
65+
maximum impact parameter (in Fermi-metre) sampled. This is set via
66+
the configuration key `FileOrCmd.bMaxSwithc` and defaults to `-b`.
67+
Thus, the EG application should take the command line argument `-b
68+
10` to mean that it should only generate events with an impact
69+
parameter between 0fm and 10fm.
4870

4971
If a program does not adhere to these requirements, it will often be
5072
simple enough to make a small wrapper script that enforce this. For
@@ -65,7 +87,7 @@ The script above also passes any additional command line options on to
6587
the CRMC suite. For example, if we want to simulate p-Pb collisions
6688
using DpmJET, we can do
6789

68-
o2-sim -g hepmc --configKeyValues "HepMC.progCmd=crmc.sh -m 12 -i2212 -I 1002080820"
90+
o2-sim -g hepmc --configKeyValues "FileOrCmd.cmd=crmc.sh -m 12 -i2212 -I 1002080820"
6991

7092

7193
### Implementation details
@@ -81,58 +103,52 @@ Internally `GeneratorHepMC`
81103

82104
4. and executes that command line
83105

84-
## The future
85-
86-
The `GeneratorHepMC` (and sister generator `GeneratorTParticle`) will
87-
in the not so distant future be upgraded with new functionality to
88-
more easily customise reading files and executing a child process. In
89-
particular
106+
## The configuration keys
90107

91-
- HepMC event structures can be read from any file format supported by
92-
HepMC it self (see
93-
[here](http://hepmc.web.cern.ch/hepmc/group__IO.html) and
94-
[here](http://hepmc.web.cern.ch/hepmc/group__factory.html).
108+
The `GeneratorHepMC` (and sister generator `GeneratorTParticle`)
109+
allows customisation of the execution via configuration keys passed
110+
via `--configKeyValues`
95111

96-
- New options that can be specified in `--configKeyValues`
112+
- `HepMC.eventsToSkip=number` a number events to skip at the
113+
beginning of each file read.
97114

98-
- `HepMC.eventsToSkip=number` a number events to skip at the
99-
beginning of each file read.
115+
- `FileOrCmd.fileNames=list` a comma separated list of HepMC files
116+
to read.
100117

101-
- `FileOrCmd.fileNames=list` a comma separated list of HepMC files
102-
to read.
118+
- `FileOrCmd.cmd=command line` a command line to execute as a
119+
background child process. If this is set (not the empty string),
120+
then `FileOrCmd.fileNames` is ignored.
103121

104-
- `FileOrCmd.cmd=command line` a command line to execute as a
105-
background child process. If this is set (not the empty string),
106-
then `FileOrCmd.fileNames` is ignored.
122+
- A number of keys that specifies the command line option switch
123+
that the child program accepts for certain things. If any of
124+
these are set to the empty string, then that switch and
125+
corresponding option value is not passed to the child program.
107126

108-
- A number of keys that specifies the command line option switch
109-
that the child program accepts for certain things. If any of
110-
these are set to the empty string, then that switch and
111-
corresponding option value is not passed to the child program.
127+
- `FileOrCmd.outputSwitch=switch` (default `>`) to specify output
128+
file. The default of `>` assumes that the program write HepMC
129+
events, and _only_ those, to standard output.
112130

113-
- `FileOrCmd.outputSwitch=switch` (default `>`) to specify output
114-
file. The default of `>` assumes that the program write HepMC
115-
events, and _only_ those, to standard output.
131+
- `FileOrCmd.seedSwitch=switch` (default `-s`) to specify the
132+
random number generator seed. The value passed is selected by
133+
the `o2-sim` option `--seed`
116134

117-
- `FileOrCmd.seedSwitch=switch` (default `-s`) to specify the
118-
random number generator seed. The value passed is selected by
119-
the `o2-sim` option `--seed`
135+
- `FileOrCmd.bMaxSwitch=switch` (default `-b`) to specify the
136+
upper limit on the impact parameters sampled. The value passed
137+
is selected by the `o2-sim` option `--bMax`
120138

121-
- `FileOrCmd.bMaxSwitch=switch` (default `-b`) to specify the
122-
upper limit on the impact parameters sampled. The value passed
123-
is selected by the `o2-sim` option `--bMax`
139+
- `FileOrCmd.nEventsSwitch=switch` (default `-n`) to specify the
140+
number of events to generate. The value passed is selected by
141+
the `o2-sim` option `--nEvents` or (`-n`)
124142

125-
- `FileOrCmd.nEventsSwitch=switch` (default `-n`) to specify the
126-
number of events to generate. The value passed is selected by
127-
the `o2-sim` option `--nEvents` or (`-n`)
128-
129-
- `FileOrCmd.backgroundSwitch=switch` (default `&`) to specify how
130-
the program is put in the background. Typically this should be
131-
`&`, but a program may itself fork to the background.
143+
- `FileOrCmd.backgroundSwitch=switch` (default `&`) to specify how
144+
the program is put in the background. Typically this should be
145+
`&`, but a program may itself fork to the background.
132146

133147
- Some options are no longer available
148+
134149
- `HepMC.fileName` - use `FileOrCmd.fileNames`
135-
- `HepMC.progCmd` - use `FileOrCmd.cmd`
150+
- `HepMC.version` - now the code itself figures out which format
151+
version the input file is in.
136152

137153
The command line build will now be
138154

run/SimExamples/HepMC/child.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ fi
4747
out=`echo "$out" | tr ' ' '_'`
4848

4949
export VMCWORKDIR=${O2_ROOT}/share
50-
o2-sim -g hepmc --configKeyValues "HepMC.progCmd=$cmd" \
50+
o2-sim -g hepmc --configKeyValues "FileOrCmd.cmd=$cmd" \
5151
--outPrefix "$out" --seed $seed --nEvents $nev $@

run/SimExamples/HepMC/read.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/bash
1+
#!/usr/bin/env bash
22

33
inp=events.hepmc
44
seed=$RANDOM
@@ -44,5 +44,5 @@ fi
4444
out=`echo "$out" | tr ' ' '_'`
4545

4646
export VMCWORKDIR=${O2_ROOT}/share
47-
o2-sim -g hepmc --configKeyValues "HepMC.fileName=$inp" \
47+
o2-sim -g hepmc --configKeyValues "FileOrCmd.fileNames=$inp" \
4848
--outPrefix "$out" --seed $seed --nEvents $nev $@

0 commit comments

Comments
 (0)