Skip to content

Commit 2ba44a3

Browse files
authored
Improve handling of external hepmc input (#78)
* Fix deuteron charge, add Helium3 * Improve handling of external hepmc data
1 parent 356ad0e commit 2ba44a3

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

examples/aod/createO2tables.C

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ int createO2tables(const char* inputFile = "delphes.root",
6767
return 0;
6868
}
6969

70-
TDatabasePDG::Instance()->AddParticle("deuteron", "deuteron", 1.8756134, kTRUE, 0.0, 1, "Nucleus", 1000010020);
70+
TDatabasePDG::Instance()->AddParticle("deuteron", "deuteron", 1.8756134, kTRUE, 0.0, 3, "Nucleus", 1000010020);
7171
TDatabasePDG::Instance()->AddAntiParticle("anti-deuteron", -1000010020);
7272

73+
TDatabasePDG::Instance()->AddParticle("helium3", "helium3", 2.80839160743, kTRUE, 0.0, 6, "Nucleus", 1000020030);
74+
TDatabasePDG::Instance()->AddAntiParticle("anti-helium3", -1000020030);
75+
7376
if (do_vertexing) {
7477
o2::base::GeometryManager::loadGeometry();
7578
o2::base::Propagator::initFieldFromGRP("o2sim_grp.root");

examples/scripts/createO2tables.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99
import shutil
1010
import time
11+
import glob
1112
import random
1213
from datetime import datetime
1314
from common import bcolors, msg, fatal_msg, verbose_msg, run_in_parallel, set_verbose_mode, get_default_parser, warning_msg
@@ -158,7 +159,28 @@ def check_duplicate(option_name):
158159
"as it will be automatically set")
159160
for i in ["--output", "-o", "--nevents", "-n"]:
160161
check_duplicate(i)
161-
msg("Using custom generator", custom_gen)
162+
if "INPUT_FILES" in custom_gen:
163+
input_hepmc_files = custom_gen.replace("INPUT_FILES",
164+
"").strip().split(" ")
165+
input_hepmc_file_list = []
166+
for i in input_hepmc_files:
167+
input_hepmc_file_list += glob.glob(os.path.normpath(i))
168+
169+
if len(input_hepmc_file_list) >= nruns:
170+
input_hepmc_file_list = input_hepmc_file_list[0:nruns]
171+
else:
172+
nruns = len(input_hepmc_file_list)
173+
174+
if len(input_hepmc_file_list) <= 0:
175+
fatal_msg("Did not find any input file matching to the request:",
176+
custom_gen)
177+
custom_gen = f"INPUT_FILES "+" ".join(input_hepmc_file_list)
178+
msg("Using", len(input_hepmc_file_list),
179+
"input HepMC file" +
180+
("" if len(input_hepmc_file_list) == 1 else "s"),
181+
input_hepmc_file_list)
182+
else:
183+
msg("Using custom generator", custom_gen)
162184

163185
# Printing configuration
164186
msg(" --- running createO2tables.py", color=bcolors.HEADER)
@@ -297,10 +319,7 @@ def copy_and_link(file_name):
297319
if "INPUT_FILES" in custom_gen:
298320
input_hepmc_file = custom_gen.replace("INPUT_FILES",
299321
"").strip().split(" ")
300-
if run_number < len(input_hepmc_file):
301-
input_hepmc_file = input_hepmc_file[run_number]
302-
else:
303-
return
322+
input_hepmc_file = input_hepmc_file[run_number]
304323
write_to_runner(f"ln -s {input_hepmc_file}"
305324
f" {hepmc_file} \n")
306325
else:

examples/scripts/default_configfile.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ generators = $O2DPG_ROOT/MC/config/common/pythia8/generator/pythia8_KrKr.cfg
7171
generators = $DELPHESO2_ROOT/examples/pythia8/pythia8_XeXe.cfg
7272

7373
[INPUT_HEPMC] # AOD creation from input HEPMC files
74-
custom_gen = INPUT_FILES /tmp/AnalysisResults_1.hepmc /tmp/AnalysisResults_2.hepmc
74+
custom_gen = INPUT_FILES /tmp/AnalysisResults_*.hepmc
7575

7676
[GUN]
7777
custom_gen = rpythia8-gun --pdg 421 --px 1. --py 0. --pz 0. --xProd 0. --yProd 0. --zProd 0. --config $DELPHESO2_ROOT/examples/pythia8/decays/force_hadronic_D.cfg --decay

0 commit comments

Comments
 (0)