@@ -109,15 +109,16 @@ def opt(entry, require=True):
109109 barrel_half_length = opt ("barrel_half_length" )
110110
111111 # copy relevant files in the working directory
112- def do_copy (in_file , out_file ):
112+ def do_copy (in_file , out_file = "." , in_path = None ):
113+ """Function to copy files"""
114+ if in_path is not None :
115+ in_file = os .path .join (in_path , in_file )
113116 in_file = os .path .expanduser (os .path .expandvars (in_file ))
114117 verbose_msg ("Copying" , in_file , "to" , out_file )
115118 shutil .copy2 (in_file , out_file )
116119
117120 # Fetching the propagation card
118- do_copy (os .path .join (opt ("card_path" ),
119- opt ("propagate_card" )),
120- "propagate.tcl" )
121+ do_copy (opt ("propagate_card" ), "propagate.tcl" , in_path = opt ("card_path" ))
121122
122123 lut_path = opt ("lut_path" )
123124 lut_tag = opt ("lut_tag" )
@@ -133,8 +134,7 @@ def do_copy(in_file, out_file):
133134 verbose_msg (f"Fetching LUTs with tag { lut_tag } from path { lut_path } " )
134135 for i in ["el" , "mu" , "pi" , "ka" , "pr" ]:
135136 lut_bg = "{}kG" .format (bField ).replace ("." , "" )
136- do_copy (os .path .join (lut_path , f"lutCovm.{ i } .{ lut_bg } .{ lut_tag } .dat" ),
137- f"lutCovm.{ i } .dat" )
137+ do_copy (f"lutCovm.{ i } .{ lut_bg } .{ lut_tag } .dat" , f"lutCovm.{ i } .dat" , in_path = lut_path )
138138
139139 # Checking that we actually have LUTs
140140 for i in ["el" , "mu" , "pi" , "ka" , "pr" ]:
@@ -150,7 +150,7 @@ def do_copy(in_file, out_file):
150150 config_entry , "in your configuration file" , configuration_file )
151151 generators = opt ("generators" ).split (" " )
152152 for i in generators :
153- do_copy (i , "." )
153+ do_copy (i )
154154 msg ("Using pythia with configuration" , generators )
155155 else :
156156 def check_duplicate (option_name ):
@@ -201,11 +201,11 @@ def check_duplicate(option_name):
201201 msg (" etaMax =" , etaMax )
202202
203203 aod_path = opt ("aod_path" )
204- do_copy (os . path . join ( aod_path , "createO2tables.h" ), "." )
205- do_copy (os . path . join ( aod_path , "createO2tables.C" ), "." )
206- do_copy ("../aod/ muonAccEffPID.root" , "." )
204+ do_copy ("createO2tables.h" , in_path = aod_path )
205+ do_copy ("createO2tables.C" , in_path = aod_path )
206+ do_copy ("muonAccEffPID.root" , in_path = aod_path )
207207 if qa :
208- do_copy ("diagnostic_tools/dpl-config_std.json" , "." )
208+ do_copy ("diagnostic_tools/dpl-config_std.json" )
209209
210210 def set_config (config_file , config , value ):
211211 config = config .strip ()
@@ -355,8 +355,10 @@ def copy_and_link(file_name):
355355 write_to_runner (f"root -l -b -q 'createO2tables.C+(\" { delphes_file } \" , \" tmp_{ aod_file } \" , 0)'" ,
356356 log_file = aod_log_file ,
357357 check_status = True )
358- write_to_runner (f"mv tmp_{ aod_file } { aod_file } " ,
359- check_status = True )
358+ # Check that there were no O2 errors
359+ write_to_runner (f"if grep -q \" \[ERROR\]\" { aod_log_file } ; then echo \" : got some errors in '{ aod_log_file } '\" && exit 1; fi" )
360+ # Rename the temporary AODs to standard AODs
361+ write_to_runner (f"mv tmp_{ aod_file } { aod_file } " , check_status = True )
360362 if not clean_delphes_files :
361363 copy_and_link (delphes_file )
362364 if hepmc_file is not None :
0 commit comments