Skip to content

Commit edac356

Browse files
authored
Installing AOD creator scripts in AOD folder + fixes (#87)
- Fix name of directory - Improve logging of errors - Removing disallineament for the primary vertexing
1 parent f3e6ad3 commit edac356

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

examples/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ file(GLOB AOD
3030
aod/*.C
3131
aod/*.h
3232
aod/*.root
33+
scripts/common.py
34+
scripts/createO2tables.py
3335
)
3436

3537
install(FILES ${PYTHIA8} DESTINATION examples/pythia8)

examples/aod/createO2tables.C

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int createO2tables(const char* inputFile = "delphes.root",
7575
TDatabasePDG::Instance()->AddAntiParticle("anti-helium3", -1000020030);
7676

7777
if (do_vertexing) {
78-
o2::base::GeometryManager::loadGeometry();
78+
o2::base::GeometryManager::loadGeometry("./", false);
7979
o2::base::Propagator::initFieldFromGRP("o2sim_grp.root");
8080
}
8181

@@ -502,8 +502,8 @@ int createO2tables(const char* inputFile = "delphes.root",
502502

503503
Printf("Writing tables for %i events", eventextra.fStart[kEvents] + 1);
504504
TString out_dir = outputFile;
505-
out_dir.ReplaceAll(".root", "");
506-
out_dir.ReplaceAll("AODRun5.", "");
505+
const TObjArray* out_tag = out_dir.Tokenize(".");
506+
out_dir = out_tag->GetEntries() > 1 ? out_tag->At(1)->GetName() : "";
507507
if (!out_dir.IsDec()) {
508508
out_dir = "DF_0";
509509
} else {

examples/scripts/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def run_in_parallel(processes, job_runner, job_arguments, job_message):
8282
bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}'))
8383

8484

85-
def run_cmd(cmd, comment="", check_status=True):
85+
def run_cmd(cmd, comment="", check_status=True, log_file=None):
8686
"""
8787
Function to run a command in bash, allows to check the status of the command and to log the command output
8888
"""
@@ -96,6 +96,10 @@ def run_cmd(cmd, comment="", check_status=True):
9696
content = content.strip()
9797
for i in content.strip().split("\n"):
9898
verbose_msg("++", i)
99+
if log_file is not None:
100+
with open(log_file) as f_log:
101+
for i in content.strip().split("\n"):
102+
f_log.write(i + "\n")
99103
if "Encountered error" in content:
100104
warning_msg("Error encountered runtime error in", cmd)
101105
if check_status:

examples/scripts/createO2tables.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ def process_run(run_number):
1818
processing_time = time.time()
1919
verbose_msg("> starting run", run_number)
2020
run_cmd(f"bash runner{run_number}.sh")
21-
if not os.path.isfile(f"AODRun5.{run_number}.root"):
22-
msg(f"++ something went wrong for run {run_number}, no output table found. Please check: 'AODRun5.{run_number}.log'",
21+
aod_name = f"AODRun5.{run_number}.root"
22+
if not os.path.isfile(aod_name):
23+
msg(f"++ something went wrong for run {run_number}, no output AOD file {aod_name} found.",
24+
f"Please check: 'AODRun5.{run_number}.log'",
2325
color=bcolors.FAIL)
2426
verbose_msg("< complete run", run_number)
2527
processing_time = time.time() - processing_time
@@ -345,9 +347,9 @@ def copy_and_link(file_name):
345347
check_status=True)
346348
# Check that there were no O2 errors
347349
write_to_runner(
348-
f"if grep -q \"\[ERROR\]\" {aod_log_file}; then echo \": got some errors in '{aod_log_file}'\" && exit 1; fi")
350+
f"if grep -q \"\[ERROR\]\" {aod_log_file}; then echo \": got some errors in '{aod_log_file}'\" && echo \"Found some ERROR in this log\" >> {aod_log_file}; fi")
349351
write_to_runner(
350-
f"if grep -q \"\[FATAL\]\" {aod_log_file}; then echo \": got some fatals in '{aod_log_file}'\" && exit 1; fi")
352+
f"if grep -q \"\[FATAL\]\" {aod_log_file}; then echo \": got some fatals in '{aod_log_file}'\" && echo \"Found some FATAL in this log\" >> {aod_log_file} && exit 1; fi")
351353
# Rename the temporary AODs to standard AODs
352354
write_to_runner(f"mv tmp_{aod_file} {aod_file}", check_status=True)
353355
if not clean_delphes_files:

0 commit comments

Comments
 (0)