Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions MC/bin/o2_hybrid_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def main():
parser.add_argument('--mode', type=str, help='Run generator in sequential or parallel mode for quicker event generation (multi-threading)')
parser.add_argument('--output', type=str, required=True, help='Output JSON file path')
parser.add_argument('--clone', type=int, help='Number of clones to make of the generator list')
parser.add_argument('--trigger', action='store_true', help='Add triggers to the template JSON file')

args = parser.parse_args()

Expand All @@ -69,6 +70,11 @@ def main():
else:
print(f"Running in {mode} mode")

# Available options for trigger are "off", "or", "and"
# in all the other cases the trigger is forced "off"

add_trigger = lambda d: d.update({"triggers": {"mode": "off", "specs": [{"macro": "", "function": ""}]}}) if args.trigger else None

# put in a list all the elementes in the gen flag
noConfGen = ["pythia8pp", "pythia8hf", "pythia8hi", "pythia8powheg"]
gens = []
Expand All @@ -88,17 +94,20 @@ def main():
"confighepmc": configs[1]
}
})
add_trigger(gens[-1])
else:
configs = get_params(gens_instances[gen],gens_params[gen])
gens.append({
'name': gen,
'config': configs
})
add_trigger(gens[-1])
elif gen in noConfGen:
gens.append({
"name": gen,
"config": ""
})
add_trigger(gens[-1])
else:
print(f"Generator {gen} not found in the list of available generators")
exit(1)
Expand All @@ -115,6 +124,7 @@ def main():
'name': 'external',
'config': configs
})
add_trigger(gens[-1])

if args.clone:
if args.clone < 2:
Expand Down
45 changes: 45 additions & 0 deletions MC/config/examples/trigger/trigger_impactb.macro
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "Generators/Trigger.h"
#include "TParticle.h"
#include <iostream>

// a very simple trigger example, examining generated particles
o2::eventgen::Trigger trigger()
{
//
return [](const std::vector<TParticle>& particles) -> bool {
std::cout << "Running trigger on event with size " << particles.size() << "\n";
if (particles.size() > 10000) {
return true;
}
return false;
};
}

#include "Pythia8/Pythia.h"
#include "Pythia8/HIInfo.h"
#include <fairlogger/Logger.h>
// a deep trigger example, looking into the internal generator state
o2::eventgen::DeepTrigger
trigger_impactb_pythia8(double bmin = 5., double bmax = 10.)
{
return [bmin, bmax](void* interface, std::string name) -> bool {
if (!name.compare("pythia8")) {
auto py8 = reinterpret_cast<Pythia8::Pythia*>(interface);
#if PYTHIA_VERSION_INTEGER < 8300
auto hiinfo = py8->info.hiinfo;
#else
auto hiinfo = py8->info.hiInfo;
#endif
if (!hiinfo) {
LOG(fatal) << "Cannot define impact parameter: is \'pythia8\' running in heavy-ion mode?";
}
auto b = hiinfo->b();
auto selected = (b > bmin && b < bmax);
LOG(info) << "Impact parameter = " << b << " fm: " << (selected ? "selected" : "rejected");
return selected;
} else {
LOG(fatal) << "Cannot define impact parameter for generator interface \'" << name << "\'";
}
return false;
};
}
Loading