Skip to content

Commit 74da39b

Browse files
authored
Merge c6f4961 into sapling-pr-archive-ehellbar
2 parents dd55d75 + c6f4961 commit 74da39b

7 files changed

Lines changed: 128 additions & 20 deletions

DATA/tools/epn/gen_topo.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ fi
4141

4242
# Extra arguments for topology merger
4343
if [[ -z "$GEN_TOPO_ODC_EPN_TOPO_POST_CACHING_ARGS" ]]; then
44-
if [[ "${GEN_TOPO_DEPLOYMENT_TYPE:-}" == "ALICE_STAGING" ]]; then
45-
export GEN_TOPO_ODC_EPN_TOPO_POST_CACHING_ARGS="--recozone staging-mi50 --reco100zone staging-mi100 --calibzone calib"
46-
else
47-
export GEN_TOPO_ODC_EPN_TOPO_POST_CACHING_ARGS="--recozone online-mi50 --reco100zone online-mi100 --calibzone calib"
48-
fi
44+
export GEN_TOPO_ODC_EPN_TOPO_POST_CACHING_ARGS="--recozone online-mi50 --reco100zone online-mi100 --calibzone calib"
4945
fi
5046
if [[ -z "$GEN_TOPO_MI100_NODES" ]]; then export GEN_TOPO_MI100_NODES=-1; fi
5147

DATA/tools/parse

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ for line in f:
223223
odccommand += ' ' + os.environ['GEN_TOPO_ODC_EPN_TOPO_ARGS']
224224
if True:
225225
replacestring = ''
226-
dd_env_variables = ['DD_DISK_FRACTION', 'EPN_DD_TEST', 'EPN_DD_TEST_2', 'EPN_DD_TEST_3', 'SHM_MANAGER_SHMID']
226+
dd_env_variables = ['DD_DISK_FRACTION', 'TF_SINK_NUM_TFS', 'DD_STF_MIN_ID', 'DD_STF_MAX_ID', 'EPN_DD_TEST', 'EPN_DD_TEST_2', 'EPN_DD_TEST_3', 'SHM_MANAGER_SHMID']
227227
for i in dd_env_variables:
228228
if i in os.environ:
229229
replacestring += ' ' + i + '=' + os.environ[i]

MC/bin/o2dpg_dpl_config_tools.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,23 @@ def log_line(logger, message):
161161
else:
162162
logger.write(message + "\n")
163163

164+
def quote_for_nested_string(val):
165+
s = str(val)
166+
# Already double-quoted?
167+
if s.startswith('"') and s.endswith('"'):
168+
return s
169+
# Escape inner quotes
170+
s_escaped = s.replace('"', r'\"')
171+
return f'"{s_escaped}"'
172+
173+
def quote_if_needed(val):
174+
# Only quote values that are likely to break shell parsing
175+
# or contain nested shell-sensitive characters
176+
s = str(val)
177+
if re.search(r'[ \t;:&|<>]', s):
178+
return quote_for_nested_string(s)
179+
return s
180+
164181
def modify_dpl_command(cmd_str, config_anchor, allow_overwrite=False, logger=None, configname=None):
165182
# check if cmd_str is given as list, in which case we transfrom to string
166183
if isinstance(cmd_str, list) == True:
@@ -196,12 +213,6 @@ def modify_dpl_command(cmd_str, config_anchor, allow_overwrite=False, logger=Non
196213
added = []
197214
overwritten = []
198215

199-
def quote_if_needed(val):
200-
s = str(val)
201-
if " " in s and not (s.startswith('"') and s.endswith('"')):
202-
return f'"{s}"'
203-
return s
204-
205216
# Step 1: Existing options (preserved or overwritten)
206217
for key, val in existing_opts.items():
207218
if allow_overwrite and key in anchor_opts:

MC/bin/o2dpg_sim_workflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from o2dpg_workflow_utils import createTask, createGlobalInitTask, dump_workflow, adjust_RECO_environment, isActive, activate_detector, deactivate_detector, compute_n_workers, merge_dicts
4444
from o2dpg_qc_finalization_workflow import include_all_QC_finalization
4545
from o2dpg_sim_config import create_sim_config, create_geant_config, constructConfigKeyArg, option_if_available, overwrite_config
46-
from o2dpg_dpl_config_tools import parse_command_string, modify_dpl_command, dpl_option_from_config, TaskFinalizer
46+
from o2dpg_dpl_config_tools import dpl_option_from_config, TaskFinalizer, quote_if_needed
4747

4848
# for some JAliEn interaction
4949
from alienpy.alien import JAlien
@@ -504,7 +504,7 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
504504
if ccdbbackend:
505505
common=common + " --condition-not-after " + str(args.condition_not_after)
506506
if ccdbRemap != None:
507-
common=common + " --condition-remap " + ccdbRemap
507+
common=common + f" --condition-remap {quote_if_needed(ccdbRemap)} "
508508
if args.noIPC!=None:
509509
return common + " --no-IPC "
510510
if bigshm:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### The external generator derives from GeneratorPythia8.
2+
[GeneratorExternal]
3+
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/external/generator/generator_pythia8_withInjectedPromptSignals_gaptriggered_dq.C
4+
funcName=GeneratorPythia8InjectedPromptCharmoniaGapTriggered(2,7)
5+
6+
[GeneratorPythia8]
7+
### config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/generator/pythia8_inel_triggerGap_5TeV.cfg
8+
### config=${O2DPG_MC_CONFIG_ROOT}/MC/config/common/pythia8/generator/pythia8_hi.cfg
9+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/ALICE3/pythia8/generator/pythia8_PbPb_536tev.cfg
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
int External()
2+
{
3+
int checkPdgSignal[] = {443,100443};
4+
int checkPdgDecay = 13;
5+
double rapiditymin = -4.3; double rapiditymax = -2.3;
6+
std::string path{"o2sim_Kine.root"};
7+
std::cout << "Check for\nsignal PDG " << checkPdgSignal << "\ndecay PDG " << checkPdgDecay << "\n";
8+
TFile file(path.c_str(), "READ");
9+
if (file.IsZombie()) {
10+
std::cerr << "Cannot open ROOT file " << path << "\n";
11+
return 1;
12+
}
13+
14+
auto tree = (TTree*)file.Get("o2sim");
15+
std::vector<o2::MCTrack>* tracks{};
16+
tree->SetBranchAddress("MCTrack", &tracks);
17+
18+
int nLeptons{};
19+
int nAntileptons{};
20+
int nLeptonPairs{};
21+
int nLeptonPairsToBeDone{};
22+
int nSignalJpsi{};
23+
int nSignalPsi2S{};
24+
int nSignalJpsiWithinAcc{};
25+
int nSignalPsi2SWithinAcc{};
26+
auto nEvents = tree->GetEntries();
27+
o2::steer::MCKinematicsReader mcreader("o2sim", o2::steer::MCKinematicsReader::Mode::kMCKine);
28+
Bool_t isInjected = kFALSE;
29+
30+
for (int i = 0; i < nEvents; i++) {
31+
tree->GetEntry(i);
32+
for (auto& track : *tracks) {
33+
auto pdg = track.GetPdgCode();
34+
auto rapidity = track.GetRapidity();
35+
auto idMoth = track.getMotherTrackId();
36+
if (pdg == checkPdgDecay) {
37+
// count leptons
38+
nLeptons++;
39+
} else if(pdg == -checkPdgDecay) {
40+
// count anti-leptons
41+
nAntileptons++;
42+
} else if (pdg == checkPdgSignal[0] || pdg == checkPdgSignal[1]) {
43+
if(idMoth < 0){
44+
// count signal PDG
45+
pdg == checkPdgSignal[0] ? nSignalJpsi++ : nSignalPsi2S++;
46+
// count signal PDG within acceptance
47+
if(rapidity > rapiditymin && rapidity < rapiditymax) { pdg == checkPdgSignal[0] ? nSignalJpsiWithinAcc++ : nSignalPsi2SWithinAcc++;}
48+
}
49+
auto child0 = o2::mcutils::MCTrackNavigator::getDaughter0(track, *tracks);
50+
auto child1 = o2::mcutils::MCTrackNavigator::getDaughter1(track, *tracks);
51+
if (child0 != nullptr && child1 != nullptr) {
52+
// check for parent-child relations
53+
auto pdg0 = child0->GetPdgCode();
54+
auto pdg1 = child1->GetPdgCode();
55+
std::cout << "First and last children of parent " << checkPdgSignal << " are PDG0: " << pdg0 << " PDG1: " << pdg1 << "\n";
56+
if (std::abs(pdg0) == checkPdgDecay && std::abs(pdg1) == checkPdgDecay && pdg0 == -pdg1) {
57+
nLeptonPairs++;
58+
if (child0->getToBeDone() && child1->getToBeDone()) {
59+
nLeptonPairsToBeDone++;
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
std::cout << "#events: " << nEvents << "\n"
67+
<< "#leptons: " << nLeptons << "\n"
68+
<< "#antileptons: " << nAntileptons << "\n"
69+
<< "#signal (prompt Jpsi): " << nSignalJpsi << "; within acceptance " << rapiditymin << " < y < " << rapiditymax << " : " << nSignalJpsiWithinAcc << "\n"
70+
<< "#signal (prompt Psi(2S)): " << nSignalPsi2S << "; within acceptance " << rapiditymin << " < y < " << rapiditymax << " : " << nSignalPsi2SWithinAcc << "\n"
71+
<< "#lepton pairs: " << nLeptonPairs << "\n"
72+
<< "#lepton pairs to be done: " << nLeptonPairs << "\n";
73+
74+
75+
if (nLeptonPairs == 0 || nLeptons == 0 || nAntileptons == 0) {
76+
std::cerr << "Number of leptons, number of anti-leptons as well as number of lepton pairs should all be greater than 1.\n";
77+
return 1;
78+
}
79+
if (nLeptonPairs != nLeptonPairsToBeDone) {
80+
std::cerr << "The number of lepton pairs should be the same as the number of lepton pairs which should be transported.\n";
81+
return 1;
82+
}
83+
84+
return 0;
85+
}

MC/run/ANCHOR/anchorMC.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ fi
198198
#<----- START OF part that should run under a clean alternative software environment if this was given ------
199199
if [ "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" ]; then
200200
if [ "${LOADEDMODULES}" ]; then
201-
export > env_before_stashing.env
201+
printenv > env_before_stashing.printenv
202202
echo "Stashing initial modules"
203203
module save initial_modules.list # we stash the current modules environment
204204
module list --no-pager
205205
module purge --no-pager
206-
export > env_after_stashing.env
206+
printenv > env_after_stashing.printenv
207207
echo "Modules after purge"
208208
module list --no-pager
209209
fi
@@ -272,10 +272,17 @@ if [ "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" ]; then
272272
echo "Restoring initial environment"
273273
module --no-pager restore initial_modules.list
274274
module saverm initial_modules.list
275-
if [ "${ALIEN_JDL_O2DPG_OVERWRITE}" ]; then
276-
echo "Setting back O2DPG_ROOT to overwritten path ${ALIEN_JDL_O2DPG_OVERWRITE}"
277-
export O2DPG_ROOT=${ALIEN_JDL_O2DPG_OVERWRITE}
278-
fi
275+
276+
# Restore overwritten O2DPG variables set by modules but changed by user
277+
# (in particular custom O2DPG_ROOT and O2DPG_MC_CONFIG_ROOT)
278+
printenv > env_after_restore.printenv
279+
comm -12 <(grep '^O2DPG' env_before_stashing.printenv | cut -d= -f1 | sort) \
280+
<(grep '^O2DPG' env_after_restore.printenv | cut -d= -f1 | sort) |
281+
while read -r var; do
282+
b=$(grep "^$var=" env_before_stashing.printenv | cut -d= -f2-)
283+
a=$(grep "^$var=" env_after_restore.printenv | cut -d= -f2-)
284+
[[ "$b" != "$a" ]] && export "$var=$b" && echo "Reapplied: $var to ${b}"
285+
done
279286
fi
280287
#<----- END OF part that should run under a clean alternative software environment if this was given ------
281288

0 commit comments

Comments
 (0)