Skip to content

Commit 7164798

Browse files
committed
Improvements for MC-DATA anchoring
* ability to pass forward the parent-AOD file and to link it in the MC-produced AO2D * keep `DF_` folder structure intact: MC timeframes are now stored under the same `DF_` folder as in the original data file
1 parent 5e972df commit 7164798

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

MC/bin/o2dpg_sim_workflow.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@
126126
# help='Treat smaller sensors in a single digitization')
127127
parser.add_argument('--pregenCollContext', action='store_true', help=argparse.SUPPRESS) # Now the default, giving this option or not makes not difference. We keep it for backward compatibility
128128
parser.add_argument('--data-anchoring', type=str, default='', help="Take collision contexts (from data) stored in this path")
129+
parser.add_argument('--aod-output-folder', type=str, default='', help="Force this AOD folder in the AOD producer")
130+
parser.add_argument('--aod-parent-file', type=str, default='', help="Link this as parent file in the AOD")
129131
parser.add_argument('--no-combine-smaller-digi', action='store_true', help=argparse.SUPPRESS)
130132
parser.add_argument('--no-combine-dpl-devices', action='store_true', help=argparse.SUPPRESS)
131133
parser.add_argument('--no-mc-labels', action='store_true', default=False, help=argparse.SUPPRESS)
@@ -1794,6 +1796,10 @@ def getDigiTaskName(det):
17941796
if created_by_option != '':
17951797
created_by_option += ' ' + aod_creator
17961798

1799+
aod_timeframe_id = f"${{ALIEN_PROC_ID}}{aod_df_id}" if not args.run_anchored else ""
1800+
if len(args.aod_output_folder) > 0:
1801+
aod_timeframe_id = args.aod_output_folder
1802+
17971803
AODtask = createTask(name='aod_'+str(tf), needs=aodneeds, tf=tf, cwd=timeframeworkdir, lab=["AOD"], mem='4000', cpu='1')
17981804
AODtask['cmd'] = ('','ln -nfs ../bkg_Kine.root . ;')[doembedding]
17991805
AODtask['cmd'] += '[ -f AO2D.root ] && rm AO2D.root; '
@@ -1809,12 +1815,14 @@ def getDigiTaskName(det):
18091815
f"--lpmp-prod-tag {args.productionTag}",
18101816
"--anchor-pass ${ALIEN_JDL_LPMANCHORPASSNAME:-unknown}",
18111817
"--anchor-prod ${ALIEN_JDL_LPMANCHORPRODUCTION:-unknown}",
1818+
"--reco-pass ${ALIEN_JDL_LPMPASSNAME:-unknown}",
1819+
f"--aod-parent {args.aod_parent_file}" if len(args.aod_parent_file) > 0 else ""
18121820
created_by_option,
18131821
"--combine-source-devices" if not args.no_combine_dpl_devices else "",
18141822
"--disable-mc" if args.no_mc_labels else "",
18151823
"--enable-truncation 0" if environ.get("O2DPG_AOD_NOTRUNCATE") or environ.get("ALIEN_JDL_O2DPG_AOD_NOTRUNCATE") else "",
18161824
"--disable-strangeness-tracker" if args.no_strangeness_tracking else "",
1817-
f"--aod-timeframe-id ${{ALIEN_PROC_ID}}{aod_df_id}" if not args.run_anchored else "",
1825+
f"--aod-timeframe-id {aod_timeframe_id}" if len(aod_timeframe_id) > 0 else ""
18181826
])
18191827
# Consider in future: AODtask['disable_alternative_reco_software'] = True # do not apply reco software here (we prefer latest aod converter)
18201828
workflow['stages'].append(AODtask)

MC/run/ANCHOR/anchorMC_DataEmbedding.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,10 @@ for external_context in collission_context_*.root; do
329329
# extract timeframe from name
330330
anchoring_tf="${external_context#collission_context_}" # remove prefix 'collision_context_'
331331
anchoring_tf="${anchoring_tf%.root}" # remove suffix '.root'
332-
echo "Treating timeframe ${anchoring_tf}"
332+
# now we have a string with DF_FOLDERNAME:TIMEFRAMEID
333+
df_folder="${anchoring_tf%%:*}"
334+
anchoring_tf="${anchoring_tf##*:}"
335+
echo "Treating timeframe ${anchoring_tf} coming from folder ${df_folder}"
333336

334337
# we do it in a separate workspace
335338
workspace="TF_${anchoring_tf}"
@@ -366,7 +369,7 @@ for external_context in collission_context_*.root; do
366369
remainingargs="${remainingargs} ${ALIEN_JDL_CCDB_CONDITION_NOT_AFTER:+--condition-not-after ${ALIEN_JDL_CCDB_CONDITION_NOT_AFTER}}"
367370
# add external collision context injection
368371
if [ "${ALIEN_JDL_MC_DATA_EMBEDDING_AO2D}" ]; then
369-
remainingargs="${remainingargs} --data-anchoring ${PWD}/../${external_context}"
372+
remainingargs="${remainingargs} --data-anchoring ${PWD}/../${external_context} --aod-output-folder ${df_folder##*_} --aod-parent-file ${ALIEN_JDL_MC_DATA_EMBEDDING_AO2D}"
370373
fi
371374

372375
echo_info "baseargs passed to o2dpg_sim_workflow_anchored.py: ${baseargs}"

MC/utils/o2dpg_data_embedding_utils.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Set of python modules/util functions for the MC-to-DATA embedding
22
# Mostly concerning extraction of MC collision context from existing data AO2D.root
33

4+
import warnings
5+
warnings.filterwarnings(
6+
"ignore",
7+
message="pandas.Int64Index is deprecated",
8+
category=FutureWarning,
9+
)
10+
411
import ROOT
512
import uproot
613
import pandas as pd
@@ -240,7 +247,7 @@ def fetch_bccoll_to_localFile(alien_file, local_filename):
240247
return True
241248

242249

243-
def convert_to_digicontext(aod_timeframe=None, timeframeID=-1):
250+
def convert_to_digicontext(aod_timeframe, df_folder, timeframeID=-1):
244251
"""
245252
converts AOD collision information from AO2D to collision context
246253
which can be used for MC
@@ -282,13 +289,16 @@ def convert_to_digicontext(aod_timeframe=None, timeframeID=-1):
282289

283290
# set the bunch filling ---> NEED to fetch it from CCDB
284291
# digicontext.setBunchFilling(bunchFillings[0]);
292+
293+
# TODO: set the interaction rate (for TPC loopers)
294+
# digicontext.mDigitizerInteractionRate = ...
285295

286296
prefixes = ROOT.std.vector("std::string")();
287297
prefixes.push_back("sgn")
288298

289299
digicontext.setSimPrefixes(prefixes);
290300
digicontext.printCollisionSummary();
291-
digicontext.saveToFile(f"collission_context_{timeframeID}.root")
301+
digicontext.saveToFile(f"collission_context_{df_folder}:{timeframeID}.root")
292302

293303

294304
def process_data_AO2D(file_name, run_number, upper_limit = -1):
@@ -315,7 +325,8 @@ def process_data_AO2D(file_name, run_number, upper_limit = -1):
315325
break
316326
tf = row['timeframeID']
317327
cols = row['position_vectors']
318-
convert_to_digicontext(cols, tf)
328+
df = key.split('@')[0] # this is the DF folder name
329+
convert_to_digicontext(cols, df, tf)
319330
counter = counter + 1
320331

321332

@@ -324,7 +335,7 @@ def main():
324335

325336
parser.add_argument("--run-number", type=int, help="Run number to anchor to", required=True)
326337
parser.add_argument("--aod-file", type=str, help="Data AO2D file (can be on AliEn)", required=True)
327-
parser.add_argument("--limit", type=int, default=-1, help="Upper limit of timeframes to be extracted")
338+
parser.add_argument("--limit", type=int, default=-1, help="Upper limit of timeframes to be extracted (-1 is no limit)")
328339
args = parser.parse_args()
329340

330341
process_data_AO2D(args.aod_file, args.run_number, args.limit)

0 commit comments

Comments
 (0)