From 6aee9efbccc68b91849dd61ea8d83e4f7df98e75 Mon Sep 17 00:00:00 2001 From: T-Britton Date: Wed, 13 Dec 2017 10:42:31 -0500 Subject: [PATCH 01/13] completed a bulk of the error checking/handling. Fixed a bug with requesting just TagOnly background. Cleaned up some spurious warnings/errors. Brought bash version up to par --- MCwrapper/MakeMC.csh | 111 +++++++++++++++++++++++++--------- MCwrapper/MakeMC.sh | 114 +++++++++++++++++++++++++---------- MCwrapper/examples/MC.config | 6 +- MCwrapper/gluex_MC.py | 6 +- 4 files changed, 172 insertions(+), 65 deletions(-) diff --git a/MCwrapper/MakeMC.csh b/MCwrapper/MakeMC.csh index 9d7f26a9..477ba5c6 100755 --- a/MCwrapper/MakeMC.csh +++ b/MCwrapper/MakeMC.csh @@ -93,13 +93,13 @@ if ( "$BATCHRUN" != "0" ) then mkdir -p $OUTDIR/log endif -if (! -d $RUNNING_DIR) then +if ( ! -d $RUNNING_DIR ) then mkdir $RUNNING_DIR endif cd $RUNNING_DIR -if(! -d $RUNNING_DIR/${RUN_NUMBER}_${FILE_NUMBER}) then +if ( ! -d $RUNNING_DIR/${RUN_NUMBER}_${FILE_NUMBER} ) then mkdir $RUNNING_DIR/${RUN_NUMBER}_${FILE_NUMBER} endif @@ -362,7 +362,7 @@ endif set bkglocstring="" set bkgloc_pre=`echo $BKGFOLDSTR | cut -c 1-4` - +echo $BKGFOLDSTR if ( "$BKGFOLDSTR" == "DEFAULT" || "$bkgloc_pre" == "loc:" || "$BKGFOLDSTR" == "Random" ) then #find file and run:1 echo "Finding the right file to fold in during MCsmear step" @@ -380,7 +380,7 @@ if ( "$BKGFOLDSTR" == "DEFAULT" || "$bkgloc_pre" == "loc:" || "$BKGFOLDSTR" == " if ( $RUN_NUMBER < 10000 ) then echo "Warning: random triggers do not exist for this run" - exit + exit 1 endif if ( "$bkgloc_pre" == "loc:" ) then @@ -389,10 +389,10 @@ if ( "$BKGFOLDSTR" == "DEFAULT" || "$bkgloc_pre" == "loc:" || "$BKGFOLDSTR" == " else set bkglocstring="/cache/halld/""$runperiod""/sim/random_triggers/""run$formatted_runNumber""_random.hddm" endif - + if ( ! -f $bkglocstring ) then echo "Could not find mix-in file "$bkglocstring - exit + exit 1 endif endif @@ -400,8 +400,10 @@ endif set recon_pre=`echo $CUSTOM_PLUGINS | cut -c1-4` set jana_config_file=`echo $CUSTOM_PLUGINS | sed -r 's/^.{5}//'` -if ( -f $jana_config_file ) then - cp $jana_config_file ./jana_config.cfg +if ( $recon_pre == "file" ) then + if ( -f $jana_config_file ) then + cp $jana_config_file ./jana_config.cfg + endif endif set gen_pre="" @@ -411,7 +413,7 @@ if ( "$GENR" != "0" ) then if ( "$gen_pre" != "file" && "$GENERATOR" != "genr8" && "$GENERATOR" != "bggen" && "$GENERATOR" != "genEtaRegge" && "$GENERATOR" != "gen_2pi_amp" && "$GENERATOR" != "gen_pi0" && "$GENERATOR" != "gen_2pi_primakoff" && "$GENERATOR" != "gen_omega_3pi" && "$GENERATOR" != "gen_2k" && "$GENERATOR" != "bggen_jpsi" && "$GENERATOR" != "gen_ee" && "$GENERATOR" != "gen_ee_hb" && "$GENERATOR" != "particle_gun" ) then echo "NO VALID GENERATOR GIVEN" echo "only [genr8, bggen, genEtaRegge, gen_2pi_amp, gen_pi0, gen_omega_3pi, gen_2k, bggen_jpsi, gen_ee , gen_ee_hb, particl_gun] are supported" - exit + exit 1 endif if ( "$gen_pre" == "file" ) then @@ -422,7 +424,7 @@ if ( "$GENR" != "0" ) then cp $gen_in_file ./$STANDARD_NAME.hddm else echo "cannot find file: "$gen_in_file - exit + exit 1 endif else if ( "$GENERATOR" == "particle_gun") then echo "bypassing generation" @@ -433,7 +435,7 @@ if ( "$GENR" != "0" ) then echo "Config file not applicable" else echo $CONFIG_FILE" does not exist" - exit + exit 1 endif endif @@ -507,6 +509,7 @@ if ( "$GENR" != "0" ) then sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' $STANDARD_NAME.conf # RUN genr8 and convert genr8 -r$formatted_runNumber -M$EVT_TO_GEN -A$STANDARD_NAME.ascii < $STANDARD_NAME.conf #$config_file_name + set generator_return_code=$status genr8_2_hddm $STANDARD_NAME.ascii else if ( "$GENERATOR" == "bggen" ) then set RANDOMnum=`bash -c 'echo $RANDOM'` @@ -524,6 +527,7 @@ if ( "$GENR" != "0" ) then ln -s $STANDARD_NAME.conf fort.15 bggen + set generator_return_code=$status mv bggen.hddm $STANDARD_NAME.hddm else if ( "$GENERATOR" == "genEtaRegge" ) then echo "RUNNING GENETAREGGE" @@ -534,7 +538,8 @@ if ( "$GENR" != "0" ) then sed -i 's/TEMPMINGENE/'$GEN_MIN_ENERGY'/' $STANDARD_NAME.conf sed -i 's/TEMPMAXGENE/'$GEN_MAX_ENERGY'/' $STANDARD_NAME.conf genEtaRegge -N$EVT_TO_GEN -O$STANDARD_NAME.hddm -I$STANDARD_NAME.conf - else if ( "$GENERATOR" == "gen_2pi_amp" ) then + set generator_return_code=$status + else if ( "$GENERATOR" == "gen_2pi_amp" ) then echo "RUNNING GEN_2PI_AMP" set optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` @@ -549,6 +554,7 @@ if ( "$GENR" != "0" ) then echo $optionals_line echo gen_2pi_amp -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line gen_2pi_amp -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line + set generator_return_code=$status else if ( "$GENERATOR" == "gen_omega_3pi" ) then echo "RUNNING GEN_OMEGA_3PI" set optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` @@ -564,24 +570,28 @@ if ( "$GENR" != "0" ) then echo $optionals_line echo gen_omega_3pi -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -m $eBEAM_ENERGY -p $COHERENT_PEAK $optionals_line gen_omega_3pi -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -m $eBEAM_ENERGY -p $COHERENT_PEAK $optionals_line - else if ( "$GENERATOR" == "gen_2pi_primakoff" ) then + set generator_return_code=$status + else if ( "$GENERATOR" == "gen_2pi_primakoff" ) then echo "RUNNING GEN_2PI_PRIMAKOFF" set optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` echo $optionals_line echo gen_2pi_primakoff -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line gen_2pi_primakoff -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line - else if ( "$GENERATOR" == "gen_pi0" ) then + set generator_return_code=$status + else if ( "$GENERATOR" == "gen_pi0" ) then echo "RUNNING GEN_PI0" set optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` echo $optionals_line gen_pi0 -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -s $formatted_fileNumber -m $eBEAM_ENERGY $optionals_line - else if ( "$GENERATOR" == "gen_2k" ) then + set generator_return_code=$status + else if ( "$GENERATOR" == "gen_2k" ) then echo "RUNNING GEN_2K" set optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` #set RANDOMnum=`bash -c 'echo $RANDOM'` echo $optionals_line echo gen_2k -c $STANDARD_NAME.conf -o $STANDARD_NAME.hddm -hd $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line gen_2k -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line + set generator_return_code=$status else if ( "$GENERATOR" == "bggen_jpsi" ) then set RANDOMnum=`bash -c 'echo $RANDOM'` echo Random Number used: $RANDOMnum @@ -598,16 +608,19 @@ if ( "$GENR" != "0" ) then ln -s $STANDARD_NAME.conf fort.15 bggen_jpsi + set generator_return_code=$status mv bggen.hddm $STANDARD_NAME.hddm else if ( "$GENERATOR" == "gen_ee" ) then set RANDOMnum=`bash -c 'echo $RANDOM'` echo "Random number used: "$RANDOMnum echo ee_mc -n$EVT_TO_GEN -R2 -b2 -l$GEN_MIN_ENERGY -u$GEN_MAX_ENERGY -t2 -r$RANDOMnum -omc_ee.hddm ee_mc -n$EVT_TO_GEN -R2 -b2 -l$GEN_MIN_ENERGY -u$GEN_MAX_ENERGY -t2 -r$RANDOMnum -omc_ee.hddm + set generator_return_code=$status mv mc_ee.hddm $STANDARD_NAME.hddm else if ( "$GENERATOR" == "gen_ee_hb" ) then echo ee_mc_hb -N$RUN_NUMBER -n$EVT_TO_GEN ee_mc_hb -N$RUN_NUMBER -n$EVT_TO_GEN + set generator_return_code=$status mv genOut.hddm $STANDARD_NAME.hddm endif @@ -617,7 +630,13 @@ if ( "$GENR" != "0" ) then exit 11 endif - + if ( $generator_return_code != 0 ) then + echo + echo + echo "Something went wrong with " "$GENERATOR" + echo "status code: "$generator_return_code + exit $generator_return_code + endif #GEANT/smearing if ( "$GEANT" != "0" ) then @@ -639,7 +658,8 @@ if ( "$GENR" != "0" ) then if ( "$polarization_angle" == "-1" ) then sed -i 's/TEMPCOHERENT/'0'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in else - sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in + set Fortran_COHERENT_PEAK=`echo $COHERENT_PEAK | cut -c -7` + sed -i 's/TEMPCOHERENT/'$Fortran_COHERENT_PEAK'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in endif sed -i 's/TEMPIN/'$STANDARD_NAME.hddm'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in @@ -687,16 +707,26 @@ if ( "$GENR" != "0" ) then if ( "$GEANTVER" == "3" ) then hdgeant + set geant_return_code=$status else if ( "$GEANTVER" == "4" ) then #make run.mac then call it below rm -f run.mac echo "/run/beamOn $EVT_TO_GEN" > run.mac echo "exit" >>! run.mac hdgeant4 -t$NUMTHREADS run.mac + set geant_return_code=$status rm run.mac else echo "INVALID GEANT VERSION" - exit + exit 1 + endif + + if ( $geant_return_code != 0 ) then + echo + echo + echo "Something went wrong with hdgeant(4)" + echo "status code: "$geant_return_code + exit $geant_return_code endif if ( ! -f ./$STANDARD_NAME'_geant'$GEANTVER'.hddm' ) then @@ -707,20 +737,33 @@ if ( "$GENR" != "0" ) then if ( "$SMEAR" != "0" ) then echo "RUNNING MCSMEAR" - if ( "$BKGFOLDSTR" == "BeamPhotons" || "$BKGFOLDSTR" == "None" ) then + if ( "$BKGFOLDSTR" == "BeamPhotons" || "$BKGFOLDSTR" == "None" || "$BKGFOLDSTR" == "TagOnly" ) then echo "running MCsmear without folding in random background" mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' $STANDARD_NAME'_geant'$GEANTVER'.hddm' + set mcsmear_return_code=$status else if ( "$BKGFOLDSTR" == "DEFAULT" || "$BKGFOLDSTR" == "Random" ) then echo "mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME"\_"geant$GEANTVER"\_"smeared.hddm $STANDARD_NAME"\_"geant$GEANTVER.hddm $bkglocstring"\:"1" mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME\_geant$GEANTVER\_smeared.hddm $STANDARD_NAME\_geant$GEANTVER.hddm $bkglocstring\:1 + set mcsmear_return_code=$status else if ( "$bkgloc_pre" == "loc:" ) then echo "mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME"\_"geant$GEANTVER"\_"smeared.hddm $STANDARD_NAME"\_"geant$GEANTVER.hddm $bkglocstring"\:"1" mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME\_geant$GEANTVER\_smeared.hddm $STANDARD_NAME\_geant$GEANTVER.hddm $bkglocstring\:1 + set mcsmear_return_code=$status else #trust the user and use their string echo 'mcsmear -PTHREAD_TIMEOUT=300 -o'$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm'' '$STANDARD_NAME'_geant'$GEANTVER'.hddm'' '$BKGFOLDSTR mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' $STANDARD_NAME'_geant'$GEANTVER'.hddm' $BKGFOLDSTR + set mcsmear_return_code=$status endif + + if ( $mcsmear_return_code != 0 ) then + echo + echo + echo "Something went wrong with mcsmear" + echo "status code: "$mcsmear_return_code + exit $mcsmear_return_code + endif + else cp $STANDARD_NAME'_geant'$GEANTVER'.hddm' $STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' endif @@ -739,6 +782,8 @@ if ( "$GENR" != "0" ) then else if ( "$GENERATOR" == "gen_ee_hb" ) then rm CFFs_DD_Feb2012.dat rm ee.ascii + rm cobrems.root + rm tcs_gen.root endif if ( "$GENERATOR" != "particle_gun" && "$gen_pre" != "file" ) then rm $STANDARD_NAME.hddm @@ -752,14 +797,18 @@ if ( "$GENR" != "0" ) then if ( "$RECON" != "0" ) then echo "RUNNING RECONSTRUCTION" - + if ( "$recon_pre" == "file" ) then echo "using config file: "$jana_config_file + hd_root ./$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' --config=jana_config.cfg -PNTHREADS=$NUMTHREADS + set hd_root_return_code=$status + echo "STATUS: " $hd_root_return_code rm jana_config.cfg else + set pluginlist=("danarest" "monitoring_hists") - + if ( "$CUSTOM_PLUGINS" != "None" ) then set pluginlist=( "$pluginlist" "$CUSTOM_PLUGINS" ) endif @@ -773,13 +822,18 @@ if ( "$GENR" != "0" ) then echo "Running hd_root with:""$PluginStr" echo "hd_root ""$STANDARD_NAME"'_geant'"$GEANTVER"'_smeared.hddm'" -PPLUGINS=""$PluginStr ""-PNTHREADS=""$NUMTHREADS" hd_root ./$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' -PPLUGINS=$PluginStr -PNTHREADS=$NUMTHREADS - + set hd_root_return_code=$status + + endif + + if ( $hd_root_return_code != 0 ) then + echo + echo + echo "Something went wrong with hd_root" + echo "Status code: "$hd_root_return_code + exit $hd_root_return_code endif - #set hd_root_return_code=$? - #if ( hd_root_return_code != 0 ) then - # echo "Something went wrong with hd_root" - # exit hd_root_return_code - #endif + if ( -f dana_rest.hddm ) then mv dana_rest.hddm dana_rest_$STANDARD_NAME.hddm endif @@ -812,6 +866,7 @@ if ( "$GENR" != "0" ) then set filecheck=`echo $current_files | grep -c $filetomv` if ( "$filecheck" == "0" ) then + mv $filetomv $filename_root\_$STANDARD_NAME.root mv $PWD/$filename_root\_$STANDARD_NAME.root $OUTDIR/root/ endif @@ -823,7 +878,7 @@ endif rm -rf ccdb.sqlite rm -rf rcdb.sqlite -if ( "$gen_pre" != "file" ) then +if ( "$gen_pre" != "file" && "$GENERATOR" != "gen_ee_hb" && "$GENERATOR" != "gen_ee" ) then mv $PWD/*.conf $OUTDIR/configurations/generation/ endif diff --git a/MCwrapper/MakeMC.sh b/MCwrapper/MakeMC.sh index f2046744..c6c1443e 100755 --- a/MCwrapper/MakeMC.sh +++ b/MCwrapper/MakeMC.sh @@ -127,8 +127,6 @@ echo "Detected bash shell" current_files=`find . -maxdepth 1 -type f` -BGRATE_toUse=$BGRATE - radthick="50.e-6" if [[ "$RADIATOR_THICKNESS" != "rcdb" || "$VERSION" != "mc" ]]; then @@ -140,7 +138,7 @@ else if [[ "$word" != "number" ]]; then if [[ "$word" == "3x10-4" ]]; then radthick="30e-6" - done + break else removedum=`echo $word | sed 's/um/ /g'` if [[ $removedum != $word ]]; then @@ -247,7 +245,7 @@ else if [[ $BGTAGONLY_OPTION == "1" || $BKGFOLDSTR=="BeamPhotons" ]]; then echo "Calculating BGRate. This process takes a minute..." BGRATE_toUse=`BGRate_calc --runNo $RUN_NUMBER --coherent_peak $COHERENT_PEAK --beam_on_current $beam_on_current --beam_energy $eBEAM_ENERGY --collimator_diameter 0.00$colsize --radiator_thickness $radthick --endpoint_energy_low $GEN_MIN_ENERGY --endpoint_energy_high $GEN_MAX_ENERGY` - echo BGRATE Is: $BGRATE_toUse + if [[ $BGRATE_toUse == "" ]]; then echo "BGrate_calc is not built or inaccessible. Please check your build and/or specify a BGRate to be used." exit 12 @@ -368,13 +366,13 @@ if [[ "$BKGFOLDSTR" == "DEFAULT" || "$bkgloc_pre" == "loc:" || "$BKGFOLDSTR" == runperiod="RunPeriod-2017-01" - if [[ $RUN_NUMBER >= 40000 ]]; then + if [[ $RUN_NUMBER -gt 40000 || $RUN_NUMBER == 40000 ]]; then runperiod="RunPeriod-2018-01" - elif [[ $RUN_NUMBER >= 30000 ]]; then + elif [[ $RUN_NUMBER -gt 30000 || $RUN_NUMBER == 30000 ]]; then runperiod="RunPeriod-2017-01" - elif [[ $RUN_NUMBER >= 20000 ]]; then + elif [[ $RUN_NUMBER -gt 20000 || $RUN_NUMBER == 20000 ]]; then runperiod="RunPeriod-2016-10" - elif [[ $RUN_NUMBER >= 10000 ]]; then + elif [[ $RUN_NUMBER -gt 10000 || $RUN_NUMBER == 10000 ]]; then runperiod="RunPeriod-2016-02" fi @@ -401,11 +399,12 @@ fi recon_pre=`echo $CUSTOM_PLUGINS | cut -c1-4` jana_config_file=`echo $CUSTOM_PLUGINS | sed -r 's/^.{5}//'` -if [[ -f $jana_config_file ]]; then -echo "gathering jana config file" -cp $jana_config_file ./jana_config.cfg +if [[ $recon_pre == "file" ]]; then + if [[ -f $jana_config_file ]]; then + echo "gathering jana config file" + cp $jana_config_file ./jana_config.cfg + fi fi - gen_pre="" if [[ "$GENR" != "0" ]]; then @@ -508,6 +507,7 @@ if [[ "$GENR" != "0" ]]; then sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' $STANDARD_NAME.conf # RUN genr8 and convert genr8 -r$formatted_runNumber -M$EVT_TO_GEN -A$STANDARD_NAME.ascii < $STANDARD_NAME.conf #$config_file_name + generator_return_code=$? genr8_2_hddm $STANDARD_NAME.ascii elif [[ "$GENERATOR" == "bggen" ]]; then RANDOMnum=`bash -c 'echo $RANDOM'` @@ -525,6 +525,7 @@ if [[ "$GENR" != "0" ]]; then ln -s $STANDARD_NAME.conf fort.15 bggen + generator_return_code=$? mv bggen.hddm $STANDARD_NAME.hddm elif [[ "$GENERATOR" == "genEtaRegge" ]]; then echo "RUNNING GENETAREGGE" @@ -536,7 +537,8 @@ if [[ "$GENR" != "0" ]]; then sed -i 's/TEMPMINGENE/'$GEN_MIN_ENERGY'/' $STANDARD_NAME.conf sed -i 's/TEMPMAXGENE/'$GEN_MAX_ENERGY'/' $STANDARD_NAME.conf genEtaRegge -N$EVT_TO_GEN -O$STANDARD_NAME.hddm -I$STANDARD_NAME.conf - elif [[ "$GENERATOR" == "gen_2pi_amp" ]]; then + generator_return_code=$? + elif [[ "$GENERATOR" == "gen_2pi_amp" ]]; then echo "RUNNING GEN_2PI_AMP" optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` echo $optionals_line @@ -550,6 +552,7 @@ if [[ "$GENR" != "0" ]]; then echo gen_2pi_amp -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line gen_2pi_amp -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line + generator_return_code=$? elif [[ "$GENERATOR" == "gen_omega_3pi" ]]; then echo "RUNNING GEN_OMEGA_3PI" optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` @@ -565,24 +568,28 @@ if [[ "$GENR" != "0" ]]; then echo $optionals_line echo gen_omega_3pi -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -m $eBEAM_ENERGY -p $COHERENT_PEAK $optionals_line gen_omega_3pi -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -m $eBEAM_ENERGY -p $COHERENT_PEAK $optionals_line - elif [[ "$GENERATOR" == "gen_2pi_primakoff" ]]; then + generator_return_code=$? + elif [[ "$GENERATOR" == "gen_2pi_primakoff" ]]; then echo "RUNNING GEN_2PI_PRIMAKOFF" - optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` + optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` echo $optionals_line echo gen_2pi_primakoff -c $STANDARD_NAME.conf -o $STANDARD_NAME.hddm -hd $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line gen_2pi_primakoff -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line - elif [[ "$GENERATOR" == "gen_pi0" ]]; then + generator_return_code=$? + elif [[ "$GENERATOR" == "gen_pi0" ]]; then echo "RUNNING GEN_PI0" - optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` + optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` echo $optionals_line gen_pi0 -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -s $formatted_fileNumber -m $eBEAM_ENERGY $optionals_line - elif [[ "$GENERATOR" == "gen_2k" ]]; then + generator_return_code=$? + elif [[ "$GENERATOR" == "gen_2k" ]]; then echo "RUNNING GEN_2K" set optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` #set RANDOMnum=`bash -c 'echo $RANDOM'` echo $optionals_line echo gen_2k -c $STANDARD_NAME.conf -o $STANDARD_NAME.hddm -hd $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line gen_2k -c $STANDARD_NAME.conf -hd $STANDARD_NAME.hddm -o $STANDARD_NAME.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -m $eBEAM_ENERGY $optionals_line + generator_return_code=$? elif [[ "$GENERATOR" == "bggen_jpsi" ]]; then RANDOMnum=`bash -c 'echo $RANDOM'` echo "Random number used: "$RANDOMnum @@ -599,15 +606,18 @@ if [[ "$GENR" != "0" ]]; then ln -s $STANDARD_NAME.conf fort.15 bggen_jpsi + generator_return_code=$? mv bggen.hddm $STANDARD_NAME.hddm elif [[ "$GENERATOR" == "gen_ee" ]]; then set RANDOMnum=`bash -c 'echo $RANDOM'` echo "Random number used: "$RANDOMnum ee_mc -n$EVT_TO_GEN -R2 -b2 -l$GEN_MIN_ENERGY -u$GEN_MAX_ENERGY -t2 -r$RANDOMnum -omc_ee.hddm + generator_return_code=$? mv mc_ee.hddm $STANDARD_NAME.hddm elif [[ "$GENERATOR" == "gen_ee_hb" ]]; then echo ee_mc_hb -N$RUN_NUMBER -n$EVT_TO_GEN ee_mc_hb -N$RUN_NUMBER -n$EVT_TO_GEN + generator_return_code=$? mv genOut.hddm $STANDARD_NAME.hddm elif [[ "$GENERATOR" == "particle_gun" ]]; then echo "configuring the particle gun" @@ -615,6 +625,15 @@ if [[ "$GENR" != "0" ]]; then cp $CONFIG_FILE ./$STANDARD_NAME.conf fi + + if [[ $generator_return_code != 0 ]]; then + echo + echo + echo "Something went wrong with " "$GENERATOR" + echo "status code: "$generator_return_code + exit $generator_return_code + fi + if [[ ! -f ./$STANDARD_NAME.hddm && "$GENERATOR" != "particle_gun" && "$gen_pre" != "file" ]]; then echo "An hddm file was not found after generation step. Terminating MC production. Please consult logs to diagnose" exit 11 @@ -639,7 +658,8 @@ if [[ "$GENR" != "0" ]]; then if [[ "$polarization_angle" == "-1" ]]; then sed -i 's/TEMPCOHERENT/'0'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in else - sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in + Fortran_COHERENT_PEAK=`echo $COHERENT_PEAK | cut -c -7` + sed -i 's/TEMPCOHERENT/'$Fortran_COHERENT_PEAK'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in fi sed -i 's/TEMPIN/'$STANDARD_NAME.hddm'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in sed -i 's/TEMPRUNG/'$RUN_NUMBER'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in @@ -684,19 +704,29 @@ if [[ "$GENR" != "0" ]]; then mv $PWD/control'_'$formatted_runNumber'_'$formatted_fileNumber.in $PWD/control.in if [[ "$GEANTVER" == "3" ]]; then - hdgeant + hdgeant + geant_return_code=$? elif [[ "$GEANTVER" == "4" ]]; then #make run.mac then call it below rm -f run.mac echo "/run/beamOn $EVT_TO_GEN" > run.mac echo "exit" >>! run.mac hdgeant4 -t$NUMTHREADS run.mac + geant_return_code=$? rm run.mac else echo "INVALID GEANT VERSION" - exit + exit 1 fi + if [[ $geant_return_code != 0 ]]; then + echo + echo + echo "Something went wrong with hdgeant(4)" + echo "status code: "$geant_return_code + exit $geant_return_code + fi + if [[ ! -f ./$STANDARD_NAME'_geant'$GEANTVER'.hddm' ]]; then echo "An hddm file was not created by Geant. Terminating MC production. Please consult logs to diagnose" exit 12 @@ -705,21 +735,34 @@ if [[ "$GENR" != "0" ]]; then if [[ "$SMEAR" != "0" ]]; then echo "RUNNING MCSMEAR" - if [[ "$BKGFOLDSTR" == "BeamPhotons" || "$BKGFOLDSTR" == "None" ]]; then + if [[ "$BKGFOLDSTR" == "BeamPhotons" || "$BKGFOLDSTR" == "None" || "$BKGFOLDSTR" == "TagOnly" ]]; then echo "running MCsmear without folding in random background" mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' $STANDARD_NAME'_geant'$GEANTVER'.hddm' + mcsmear_return_code=$? elif [[ "$BKGFOLDSTR" == "DEFAULT" || "$BKGFOLDSTR" == "Random" ]]; then echo "mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME"\_"geant$GEANTVER"\_"smeared.hddm $STANDARD_NAME"\_"geant$GEANTVER.hddm $bkglocstring"\:"1" mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME\_geant$GEANTVER\_smeared.hddm $STANDARD_NAME\_geant$GEANTVER.hddm $bkglocstring\:1 + mcsmear_return_code=$? elif [[ "$bkgloc_pre" == "loc:" ]]; then echo "mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME"\_"geant$GEANTVER"\_"smeared.hddm $STANDARD_NAME"\_"geant$GEANTVER.hddm $bkglocstring"\:"1" mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME\_geant$GEANTVER\_smeared.hddm $STANDARD_NAME\_geant$GEANTVER.hddm $bkglocstring\:1 + mcsmear_return_code=$? else #trust the user and use their string echo 'mcsmear -PTHREAD_TIMEOUT=300 -o'$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm'' '$STANDARD_NAME'_geant'$GEANTVER'.hddm'' '$BKGFOLDSTR mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' $STANDARD_NAME'_geant'$GEANTVER'.hddm' $BKGFOLDSTR + mcsmear_return_code=$? fi + + if [[ $mcsmear_return_code != 0 ]]; then + echo + echo + echo "Something went wrong with mcsmear" + echo "status code: "$mcsmear_return_code + exit $mcsmear_return_code + fi + else cp $STANDARD_NAME'_geant'$GEANTVER'.hddm' $STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' fi @@ -736,6 +779,8 @@ if [[ "$GENR" != "0" ]]; then elif [[ "$GENERATOR" == "gen_ee_hb" ]]; then rm CFFs_DD_Feb2012.dat rm ee.ascii + rm cobrems.root + rm tcs_gen.root fi if [[ "$GENERATOR" != "particle_gun" && "$gen_pre" != "file" ]]; then rm $STANDARD_NAME.hddm @@ -753,16 +798,16 @@ if [[ "$GENR" != "0" ]]; then if [[ "$recon_pre" == "file" ]]; then echo "using config file: "$jana_config_file hd_root ./$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' --config=jana_config.cfg -PNTHREADS=$NUMTHREADS + hd_root_return_code=$? rm jana_config.cfg else declare -a pluginlist=("danarest" "monitoring_hists") - echo ${pluginlist[@]} - echo $CUSTOM_PLUGINS + if [[ "$CUSTOM_PLUGINS" != "None" ]]; then pluginlist=("${pluginlist[@]}" $CUSTOM_PLUGINS) fi - echo ${pluginlist[@]} + PluginStr="" @@ -771,15 +816,20 @@ if [[ "$GENR" != "0" ]]; then done PluginStr=`echo $PluginStr | sed -r 's/.{1}$//'` - echo "Running hd_root with:""$PluginStr" + echo "Running hd_root with: ""$PluginStr" echo "hd_root ""$STANDARD_NAME"'_geant'"$GEANTVER"'_smeared.hddm'" -PPLUGINS=""$PluginStr ""-PNTHREADS=""$NUMTHREADS" hd_root ./$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' -PPLUGINS=$PluginStr -PNTHREADS=$NUMTHREADS + hd_root_return_code=$? fi - #if [[ hd_root_return_code != 0 ]]; then - # echo "Something went wrong with hd_root" - # exit hd_root_return_code - # fi - + + if [[ $hd_root_return_code != 0 ]]; then + echo + echo + echo "Something went wrong with hd_root" + echo "Status code: "$hd_root_return_code + exit $hd_root_return_code + fi + if [[ -f dana_rest.hddm ]]; then mv dana_rest.hddm dana_rest_$STANDARD_NAME.hddm fi @@ -824,7 +874,7 @@ fi rm -rf ccdb.sqlite rm -rf rcdb.sqlite -if [[ "$gen_pre" != "file" ]]; then +if [[ "$gen_pre" != "file" && "$GENERATOR" != "gen_ee_hb" && "$GENERATOR" != "gen_ee" ]]; then mv $PWD/*.conf $OUTDIR/configurations/generation/ fi hddmfiles=$(ls | grep .hddm) diff --git a/MCwrapper/examples/MC.config b/MCwrapper/examples/MC.config index 974dda12..28e06a88 100755 --- a/MCwrapper/examples/MC.config +++ b/MCwrapper/examples/MC.config @@ -21,9 +21,9 @@ GENERATOR=generator-to-use #or you may specifile file:/.../file-to-use.hddm GENERATOR_CONFIG=config file for generator #common parameters for generators -#eBEAM_ENERGY=12 #either use =rcdb or do not set to pull the value for the chosen run number from the rcdb -#RADIATOR_THICKNESS=50.e-06#either use =rcdb or do not set to pull the value for the chosen run number from the rcdb -#COHERENT_PEAK=9 #either use =rcdb or do not set to pull the value for the chosen run number from the rcdb +#eBEAM_ENERGY=12 #either use rcdb or do not set to pull the value for the chosen run number from the rcdb +#RADIATOR_THICKNESS=50.e-06#either use rcdb or do not set to pull the value for the chosen run number from the rcdb +#COHERENT_PEAK=9 #either use rcdb or do not set to pull the value for the chosen run number from the rcdb #GEN_MIN_ENERGY=4 #GEN_MAX_ENERGY=12 diff --git a/MCwrapper/gluex_MC.py b/MCwrapper/gluex_MC.py index e688d7c1..b74285c8 100755 --- a/MCwrapper/gluex_MC.py +++ b/MCwrapper/gluex_MC.py @@ -195,8 +195,8 @@ def main(argv): #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! print "*********************************" - print "Welcome to v1.11 of the MCwrapper" - print "Thomas Britton 12/7/17" + print "Welcome to v1.12 of the MCwrapper" + print "Thomas Britton 12/12/17" print "*********************************" #load all argument passed in and set default options @@ -337,6 +337,8 @@ def main(argv): return if subparts[0].upper() == "TAGONLY": BGTAGONLY=1 + if BGFOLD == "DEFAULT": + BGFOLD="TagOnly" if len(subparts)==2: BGRATE=subparts[1] From d79aef37defb1b105c8cbf9b8d18a193bc669507 Mon Sep 17 00:00:00 2001 From: T-Britton Date: Fri, 15 Dec 2017 08:19:25 -0500 Subject: [PATCH 02/13] now with less stable jpsi --- MCwrapper/Generators/bggen_jpsi/particle.dat | 1 + 1 file changed, 1 insertion(+) diff --git a/MCwrapper/Generators/bggen_jpsi/particle.dat b/MCwrapper/Generators/bggen_jpsi/particle.dat index 309fc4b5..e36d3db9 100644 --- a/MCwrapper/Generators/bggen_jpsi/particle.dat +++ b/MCwrapper/Generators/bggen_jpsi/particle.dat @@ -19,3 +19,4 @@ 44 0.7755 0. 0 0 0 0 80 0.7755 0.151 9 8 0 1 82 1.232 0.118 14 8 0 0 + 83 3.097 0. 2 3 0 2 From be26ef61b5dbe6abe25b24d1e3ebadbb36371f27 Mon Sep 17 00:00:00 2001 From: T-Britton Date: Mon, 18 Dec 2017 11:24:26 -0500 Subject: [PATCH 03/13] touch ups --- MCwrapper/MakeMC.csh | 8 +++++--- MCwrapper/MakeMC.sh | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/MCwrapper/MakeMC.csh b/MCwrapper/MakeMC.csh index 477ba5c6..d2a06990 100755 --- a/MCwrapper/MakeMC.csh +++ b/MCwrapper/MakeMC.csh @@ -106,13 +106,13 @@ endif cd $RUNNING_DIR/${RUN_NUMBER}_${FILE_NUMBER} if ( "$ccdbSQLITEPATH" != "no_sqlite" ) then - #cp $ccdbSQLITEPATH ./ccdb.sqlite + cp $ccdbSQLITEPATH ./ccdb.sqlite setenv CCDB_CONNECTION sqlite:///$ccdbSQLITEPATH setenv JANA_CALIB_URL ${CCDB_CONNECTION} endif if ( "$rcdbSQLITEPATH" != "no_sqlite" ) then - #cp $rcdbSQLITEPATH ./rcdb.sqlite + cp $rcdbSQLITEPATH ./rcdb.sqlite setenv RCDB_CONNECTION sqlite:///$rcdbSQLITEPATH endif @@ -419,6 +419,7 @@ if ( "$GENR" != "0" ) then if ( "$gen_pre" == "file" ) then set gen_in_file=`echo $GENERATOR | sed -r 's/^.{5}//'` echo "bypassing generation" + set generator_return_code=0 if ( -f $gen_in_file ) then echo "using pre-generated file: "$gen_in_file cp $gen_in_file ./$STANDARD_NAME.hddm @@ -426,8 +427,9 @@ if ( "$GENR" != "0" ) then echo "cannot find file: "$gen_in_file exit 1 endif - else if ( "$GENERATOR" == "particle_gun") then + else if ( "$GENERATOR" == "particle_gun" ) then echo "bypassing generation" + set generator_return_code=0 else if ( -f $CONFIG_FILE ) then echo "input file found" diff --git a/MCwrapper/MakeMC.sh b/MCwrapper/MakeMC.sh index c6c1443e..661eb332 100755 --- a/MCwrapper/MakeMC.sh +++ b/MCwrapper/MakeMC.sh @@ -418,6 +418,7 @@ if [[ "$GENR" != "0" ]]; then if [[ "$gen_pre" == "file" ]]; then gen_in_file=`echo $GENERATOR | sed -r 's/^.{5}//'` echo "bypassing generation" + if [[ -f $gen_in_file ]]; then echo "using pre-generated file: "$gen_in_file cp $gen_in_file ./$STANDARD_NAME.hddm @@ -425,7 +426,11 @@ if [[ "$GENR" != "0" ]]; then echo "cannot find file: "$gen_in_file exit fi - + generator_return_code=0 + + else if [[ "$GENERATOR" == "particle_gun" ]]; then + echo "bypassing generation" + generator_return_code=0 else if [[ -f $CONFIG_FILE ]]; then echo "input file found" From b8e065fbc48a8d91d8a6c0fdeed20b919bbea4d2 Mon Sep 17 00:00:00 2001 From: T-Britton Date: Wed, 20 Dec 2017 11:23:16 -0500 Subject: [PATCH 04/13] First commit pre OSG testing --- .../Generators/genEtaRegge/examples/eta548.in | 3 -- MCwrapper/MakeMC.csh | 14 ++++--- MCwrapper/MakeMC.sh | 4 +- MCwrapper/gluex_MC.py | 42 ++++++++++++++++++- MCwrapper/osg-container.csh | 41 ++++++++++++++++++ MCwrapper/osg-container.sh | 41 ++++++++++++++++++ 6 files changed, 134 insertions(+), 11 deletions(-) create mode 100644 MCwrapper/osg-container.csh create mode 100644 MCwrapper/osg-container.sh diff --git a/MCwrapper/Generators/genEtaRegge/examples/eta548.in b/MCwrapper/Generators/genEtaRegge/examples/eta548.in index da33b5f4..ed68aaeb 100644 --- a/MCwrapper/Generators/genEtaRegge/examples/eta548.in +++ b/MCwrapper/Generators/genEtaRegge/examples/eta548.in @@ -10,6 +10,3 @@ TEMPELECE TEMPCOHERENT TEMPCOLD TEMPRADTHICK 3 #GEANT ids of decay particles (1=gamma,7=pi0, 8=pi+, 9=pi-, 17=eta). 1 2 3 - - - diff --git a/MCwrapper/MakeMC.csh b/MCwrapper/MakeMC.csh index d2a06990..37beeb25 100755 --- a/MCwrapper/MakeMC.csh +++ b/MCwrapper/MakeMC.csh @@ -744,12 +744,16 @@ if ( "$GENR" != "0" ) then mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' $STANDARD_NAME'_geant'$GEANTVER'.hddm' set mcsmear_return_code=$status else if ( "$BKGFOLDSTR" == "DEFAULT" || "$BKGFOLDSTR" == "Random" ) then - echo "mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME"\_"geant$GEANTVER"\_"smeared.hddm $STANDARD_NAME"\_"geant$GEANTVER.hddm $bkglocstring"\:"1" - mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME\_geant$GEANTVER\_smeared.hddm $STANDARD_NAME\_geant$GEANTVER.hddm $bkglocstring\:1 + set fold_skip_num=`echo "$FILE_NUMBER * $PER_FILE" | bc` + #set bkglocstring="/w/halld-scifs17exp/halld2/home/tbritton/MCwrapper_Development/converted.hddm" + echo "mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME"\_"geant$GEANTVER"\_"smeared.hddm $STANDARD_NAME"\_"geant$GEANTVER.hddm $bkglocstring"\:"1""+"$fold_skip_num + mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME\_geant$GEANTVER\_smeared.hddm $STANDARD_NAME\_geant$GEANTVER.hddm $bkglocstring\:1\+$fold_skip_num set mcsmear_return_code=$status else if ( "$bkgloc_pre" == "loc:" ) then - echo "mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME"\_"geant$GEANTVER"\_"smeared.hddm $STANDARD_NAME"\_"geant$GEANTVER.hddm $bkglocstring"\:"1" - mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME\_geant$GEANTVER\_smeared.hddm $STANDARD_NAME\_geant$GEANTVER.hddm $bkglocstring\:1 + set fold_skip_num=`echo "$FILE_NUMBER * $PER_FILE" | bc` + + echo "mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME"\_"geant$GEANTVER"\_"smeared.hddm $STANDARD_NAME"\_"geant$GEANTVER.hddm $bkglocstring"\:"1""+"$fold_skip_num + mcsmear -PTHREAD_TIMEOUT=300 -o$STANDARD_NAME\_geant$GEANTVER\_smeared.hddm $STANDARD_NAME\_geant$GEANTVER.hddm $bkglocstring\:1\+$fold_skip_num set mcsmear_return_code=$status else #trust the user and use their string @@ -805,7 +809,7 @@ if ( "$GENR" != "0" ) then hd_root ./$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' --config=jana_config.cfg -PNTHREADS=$NUMTHREADS set hd_root_return_code=$status - echo "STATUS: " $hd_root_return_code + #echo "STATUS: " $hd_root_return_code rm jana_config.cfg else diff --git a/MCwrapper/MakeMC.sh b/MCwrapper/MakeMC.sh index 661eb332..bea6bea5 100755 --- a/MCwrapper/MakeMC.sh +++ b/MCwrapper/MakeMC.sh @@ -111,13 +111,13 @@ fi cd $RUNNING_DIR/${RUN_NUMBER}_${FILE_NUMBER} if [[ "$ccdbSQLITEPATH" != "no_sqlite" ]]; then - #cp $ccdbSQLITEPATH ./ccdb.sqlite + cp $ccdbSQLITEPATH ./ccdb.sqlite export CCDB_CONNECTION=sqlite:///$ccdbSQLITEPATH export JANA_CALIB_URL=$CCDB_CONNECTION fi if [[ "$rcdbSQLITEPATH" != "no_sqlite" ]]; then - #cp $rcdbSQLITEPATH ./rcdb.sqlite + cp $rcdbSQLITEPATH ./rcdb.sqlite export RCDB_CONNECTION=sqlite:///$rcdbSQLITEPATH fi diff --git a/MCwrapper/gluex_MC.py b/MCwrapper/gluex_MC.py index b74285c8..cdb3884d 100755 --- a/MCwrapper/gluex_MC.py +++ b/MCwrapper/gluex_MC.py @@ -153,6 +153,42 @@ def condor_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, status = subprocess.call(add_command, shell=True) status = subprocess.call("rm MCcondor.submit", shell=True) +def OSG_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE ): + STUBNAME = str(RUNNUM) + "_" + str(FILENUM) + JOBNAME = WORKFLOW + "_" + STUBNAME + + f=open('MCOSG.submit','w') + f.write("universe = vanilla"+"\n") + f.write("Executable = osg-container.sh""\n") + f.write("Arguments = "+indir+" "+COMMAND+"\n") + f.write("Requirements = (HAS_SINGULARITY == TRUE) && (HAS_CVMFS_oasis_opensciencegrid_org == True)"+"\n") + f.write('+SingularityImage = "/cvmfs/singularity.opensciencegrid.org/rjones30/gluex:latest"'+"\n") + f.write('+SingularityBindCVMFS = True'+"\n") + f.write('+SingularityAutoLoad = True'+"\n") + f.write('should_transfer_files = IF_NEEDED'+"\n") + f.write('when_to_transfer_output = ON_EXIT'+"\n") + f.write('x509userproxy = /tmp/user_proxy'+"\n") + f.write('concurrency_limits = GluexProduction'+"\n") + f.write('on_exit_remove = true'+"\n") + f.write('on_exit_hold = false'+"\n") + f.write("Error = "+DATA_OUTPUT_BASE_DIR+"/log/"+"error_"+JOBNAME+".log\n") + f.write("Log = "+DATA_OUTPUT_BASE_DIR+"/log/"+"out_"+JOBNAME+".log\n") + f.write("output = /$(CLUSTER).$(PROCESS).out\n") + f.write("initialdir = "+RUNNING_DIR+"\n") + f.write("transfer_input_files = "+ENVFILE+"\n") + f.write("transfer_output_files = "+DATA_OUTPUT_BASE_DIR+"\n") + + f.write("queue\n") + f.close() + + add_command="condor_submit -name "+JOBNAME+" MCOSG.submit" + if add_command.find(';')!=-1 or add_command.find('&')!=-1 or mkdircom.find(';')!=-1 or mkdircom.find('&')!=-1:#THIS CHECK HELPS PROTEXT AGAINST A POTENTIAL HACK VIA CONFIG FILES + print "Nice try.....you cannot use ; or &" + exit(1) + + status = subprocess.call(add_command, shell=True) + status = subprocess.call("rm MCOSG.submit", shell=True) + def showhelp(): helpstring= "variation=%s where %s is a valid jana_calib_context variation string (default is \"mc\")\n" @@ -196,7 +232,7 @@ def main(argv): print "*********************************" print "Welcome to v1.12 of the MCwrapper" - print "Thomas Britton 12/12/17" + print "Thomas Britton 12/19/17" print "*********************************" #load all argument passed in and set default options @@ -594,6 +630,8 @@ def main(argv): qsub_add_job(VERBOSE, WORKFLOW, runs[0], BASEFILENUM+FILENUM_this_run+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, RAM, QUEUENAME, LOG_DIR ) elif BATCHSYS.upper()=="CONDOR": condor_add_job(VERBOSE, WORKFLOW, runs[0], BASEFILENUM+FILENUM_this_run+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR ) + elif BATCHSYS.upper()=="OSG": + condor_add_job(VERBOSE, WORKFLOW, runs[0], BASEFILENUM+FILENUM_this_run+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE ) #print "----------------" else: @@ -622,6 +660,8 @@ def main(argv): qsub_add_job(VERBOSE, WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, RAM, QUEUENAME, LOG_DIR ) elif BATCHSYS.upper()=="CONDOR": condor_add_job(VERBOSE, WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR ) + elif BATCHSYS.upper()=="OSG": + condor_add_job(VERBOSE, WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE ) if BATCHRUN == 1 and BATCHSYS.upper() == "SWIF": diff --git a/MCwrapper/osg-container.csh b/MCwrapper/osg-container.csh new file mode 100644 index 00000000..81b854de --- /dev/null +++ b/MCwrapper/osg-container.csh @@ -0,0 +1,41 @@ +#!/bin/sh +# +# osg-container.sh - gluex job wrapper script for osg jobs +# +# This script contains GENERIC (non-job-specific) steps for getting +# set up inside the gluex container on an osg worker node and launching +# the job script. It should not normally be modified by the user. +# +# Usage: osg-container.sh [job script arguments] +# +# Author: Richard.T.Jones at uconn.edu +# Version: June 8, 2017 + +set container="/cvmfs/singularity.opensciencegrid.org/rjones30/gluex:latest" +#oasismount="/cvmfs/oasis.opensciencegrid.org" +set oasismount="/cvmfs" +set dockerimage="docker://rjones30/gluex:latest" +set userproxy=x509up_u$UID + +# define the container context for running on osg workers + +if ( -f /environment ) then +    echo "Job running on" `hostname` +    ( -r .$userproxy ) && mv .$userproxy /tmp/$userproxy +    source /environment +    unset CCDB_CONNECTION +    unset RCDB_CONNECTION +    $* && retcode=$? +    echo "Job finished with exit code" $retcode +    rm -rf *.sqlite +    exit $retcode + +else if ( -f $container/environment ) then +    echo "Starting up container on" `hostname` +    ( -r /tmp/$userproxy ) && cp /tmp/$userproxy .$userproxy +    exec singularity exec --containall --bind ${oasismount} --home `pwd`:/srv --pwd /srv --scratch /tmp,/var/tmp ${container} \ +    bash $0 $* + +else +    echo "Job container not found on" `hostname` +endif \ No newline at end of file diff --git a/MCwrapper/osg-container.sh b/MCwrapper/osg-container.sh new file mode 100644 index 00000000..d6572188 --- /dev/null +++ b/MCwrapper/osg-container.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# +# osg-container.sh - gluex job wrapper script for osg jobs +# +# This script contains GENERIC (non-job-specific) steps for getting +# set up inside the gluex container on an osg worker node and launching +# the job script. It should not normally be modified by the user. +# +# Usage: osg-container.sh [job script arguments] +# +# Author: Richard.T.Jones at uconn.edu +# Version: June 8, 2017 + +container="/cvmfs/singularity.opensciencegrid.org/rjones30/gluex:latest" +#oasismount="/cvmfs/oasis.opensciencegrid.org" +oasismount="/cvmfs" +dockerimage="docker://rjones30/gluex:latest" +userproxy=x509up_u$UID + +# define the container context for running on osg workers + +if [[ -f /environment ]]; then +    echo "Job running on" `hostname` +    [ -r .$userproxy ] && mv .$userproxy /tmp/$userproxy +    source /environment +    unset CCDB_CONNECTION +    unset RCDB_CONNECTION +    $* && retcode=$? +    echo "Job finished with exit code" $retcode +    rm -rf *.sqlite +    exit $retcode + +elif [[ -f $container/environment ]]; then +    echo "Starting up container on" `hostname` +    [ -r /tmp/$userproxy ] && cp /tmp/$userproxy .$userproxy +    exec singularity exec --containall --bind ${oasismount} --home `pwd`:/srv --pwd /srv --scratch /tmp,/var/tmp ${container} \ +    bash $0 $* + +else +    echo "Job container not found on" `hostname` +fi \ No newline at end of file From 741231c2ac7f8f9f55e4f58e3bebd069dc145ae7 Mon Sep 17 00:00:00 2001 From: T-Britton Date: Thu, 21 Dec 2017 10:19:48 -0500 Subject: [PATCH 05/13] step 1 of OSG --- MCwrapper/gluex_MC.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/MCwrapper/gluex_MC.py b/MCwrapper/gluex_MC.py index cdb3884d..af87ecfa 100755 --- a/MCwrapper/gluex_MC.py +++ b/MCwrapper/gluex_MC.py @@ -173,7 +173,7 @@ def OSG_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, DAT f.write('on_exit_hold = false'+"\n") f.write("Error = "+DATA_OUTPUT_BASE_DIR+"/log/"+"error_"+JOBNAME+".log\n") f.write("Log = "+DATA_OUTPUT_BASE_DIR+"/log/"+"out_"+JOBNAME+".log\n") - f.write("output = /$(CLUSTER).$(PROCESS).out\n") + f.write("output = "+DATA_OUTPUT_BASE_DIR+"/log/"+"OSGout_"+JOBNAME+".log\n") f.write("initialdir = "+RUNNING_DIR+"\n") f.write("transfer_input_files = "+ENVFILE+"\n") f.write("transfer_output_files = "+DATA_OUTPUT_BASE_DIR+"\n") @@ -181,13 +181,13 @@ def OSG_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, DAT f.write("queue\n") f.close() - add_command="condor_submit -name "+JOBNAME+" MCOSG.submit" - if add_command.find(';')!=-1 or add_command.find('&')!=-1 or mkdircom.find(';')!=-1 or mkdircom.find('&')!=-1:#THIS CHECK HELPS PROTEXT AGAINST A POTENTIAL HACK VIA CONFIG FILES - print "Nice try.....you cannot use ; or &" - exit(1) + #add_command="condor_submit -name "+JOBNAME+" MCOSG.submit" + #if add_command.find(';')!=-1 or add_command.find('&')!=-1 or mkdircom.find(';')!=-1 or mkdircom.find('&')!=-1:#THIS CHECK HELPS PROTEXT AGAINST A POTENTIAL HACK VIA CONFIG FILES + # print "Nice try.....you cannot use ; or &" + # exit(1) - status = subprocess.call(add_command, shell=True) - status = subprocess.call("rm MCOSG.submit", shell=True) + #status = subprocess.call(add_command, shell=True) + #status = subprocess.call("rm MCOSG.submit", shell=True) def showhelp(): @@ -631,7 +631,7 @@ def main(argv): elif BATCHSYS.upper()=="CONDOR": condor_add_job(VERBOSE, WORKFLOW, runs[0], BASEFILENUM+FILENUM_this_run+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR ) elif BATCHSYS.upper()=="OSG": - condor_add_job(VERBOSE, WORKFLOW, runs[0], BASEFILENUM+FILENUM_this_run+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE ) + OSG_add_job(VERBOSE, WORKFLOW, runs[0], BASEFILENUM+FILENUM_this_run+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE ) #print "----------------" else: @@ -660,8 +660,8 @@ def main(argv): qsub_add_job(VERBOSE, WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, RAM, QUEUENAME, LOG_DIR ) elif BATCHSYS.upper()=="CONDOR": condor_add_job(VERBOSE, WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR ) - elif BATCHSYS.upper()=="OSG": - condor_add_job(VERBOSE, WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE ) + elif BATCHSYS.upper()=="OSG": + OSG_add_job(VERBOSE, WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE ) if BATCHRUN == 1 and BATCHSYS.upper() == "SWIF": From 06c2308da6333839f12cb4d87d4981250e0d1b64 Mon Sep 17 00:00:00 2001 From: T-Britton Date: Thu, 21 Dec 2017 10:49:39 -0500 Subject: [PATCH 06/13] added a dummy script to test OSG execution --- MCwrapper/MakeHelloWorld.csh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 MCwrapper/MakeHelloWorld.csh diff --git a/MCwrapper/MakeHelloWorld.csh b/MCwrapper/MakeHelloWorld.csh new file mode 100755 index 00000000..fcf19a70 --- /dev/null +++ b/MCwrapper/MakeHelloWorld.csh @@ -0,0 +1,3 @@ +#!/bin/csh -f + +echo "Hello" >& HelloWorld.txt \ No newline at end of file From 7d8f4a4359e93d72219fa02b3c788fc7f5b8d71c Mon Sep 17 00:00:00 2001 From: tbritton Date: Tue, 2 Jan 2018 15:34:06 -0500 Subject: [PATCH 07/13] beta osg implementation --- MCwrapper/MakeMC.csh | 6 +-- MCwrapper/MakeMC.sh | 4 +- MCwrapper/gluex_MC.py | 100 ++++++++++++++++++++++++++++++++++-------- 3 files changed, 86 insertions(+), 24 deletions(-) diff --git a/MCwrapper/MakeMC.csh b/MCwrapper/MakeMC.csh index 37beeb25..2281a16b 100755 --- a/MCwrapper/MakeMC.csh +++ b/MCwrapper/MakeMC.csh @@ -85,7 +85,7 @@ setenv BGRATE $1 #necessary to run swif, uses local directory if swif=0 is used -if ( "$BATCHRUN" != "0" ) then +if ( "$BATCHRUN" != "0" ) then # ENVIRONMENT echo $ENVIRONMENT echo pwd=$PWD @@ -107,13 +107,13 @@ cd $RUNNING_DIR/${RUN_NUMBER}_${FILE_NUMBER} if ( "$ccdbSQLITEPATH" != "no_sqlite" ) then cp $ccdbSQLITEPATH ./ccdb.sqlite - setenv CCDB_CONNECTION sqlite:///$ccdbSQLITEPATH + setenv CCDB_CONNECTION sqlite:///$PWD/ccdb.sqlite #$ccdbSQLITEPATH setenv JANA_CALIB_URL ${CCDB_CONNECTION} endif if ( "$rcdbSQLITEPATH" != "no_sqlite" ) then cp $rcdbSQLITEPATH ./rcdb.sqlite - setenv RCDB_CONNECTION sqlite:///$rcdbSQLITEPATH + setenv RCDB_CONNECTION sqlite:///$PWD/rcdb.sqlite #$rcdbSQLITEPATH endif echo "" diff --git a/MCwrapper/MakeMC.sh b/MCwrapper/MakeMC.sh index bea6bea5..afe555cc 100755 --- a/MCwrapper/MakeMC.sh +++ b/MCwrapper/MakeMC.sh @@ -112,13 +112,13 @@ cd $RUNNING_DIR/${RUN_NUMBER}_${FILE_NUMBER} if [[ "$ccdbSQLITEPATH" != "no_sqlite" ]]; then cp $ccdbSQLITEPATH ./ccdb.sqlite - export CCDB_CONNECTION=sqlite:///$ccdbSQLITEPATH + export CCDB_CONNECTION=sqlite:///$PWD/ccdb.sqlite export JANA_CALIB_URL=$CCDB_CONNECTION fi if [[ "$rcdbSQLITEPATH" != "no_sqlite" ]]; then cp $rcdbSQLITEPATH ./rcdb.sqlite - export RCDB_CONNECTION=sqlite:///$rcdbSQLITEPATH + export RCDB_CONNECTION=sqlite:///$PWD/rcdb.sqlite fi echo "" diff --git a/MCwrapper/gluex_MC.py b/MCwrapper/gluex_MC.py index af87ecfa..8c1dec11 100755 --- a/MCwrapper/gluex_MC.py +++ b/MCwrapper/gluex_MC.py @@ -153,41 +153,101 @@ def condor_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, status = subprocess.call(add_command, shell=True) status = subprocess.call("rm MCcondor.submit", shell=True) -def OSG_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE ): +def OSG_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE, LOG_DIR ): STUBNAME = str(RUNNUM) + "_" + str(FILENUM) JOBNAME = WORKFLOW + "_" + STUBNAME + mkdircom="mkdir -p "+DATA_OUTPUT_BASE_DIR+"/log/" + + indir_parts=indir.split("/") + script_to_use=indir_parts[len(indir_parts)-1] + + ENVFILE_parts=ENVFILE.split("/") + envfile_to_source="/srv/"+ENVFILE_parts[len(ENVFILE_parts)-1] + + + COMMAND_parts=COMMAND.split(" ") + COMMAND_parts[1]=envfile_to_source + + COMMAND_parts[3]="./" + COMMAND_parts[30]="./" + + additional_passins="" + if COMMAND_parts[2][:5] == "file:": + gen_config_parts=COMMAND_parts[2].split("/") + gen_config_to_use=gen_config_parts[len(gen_config_parts)-1] + additional_passins+=COMMAND_parts[2][5:]+", " + COMMAND_parts[2]="file:/srv/"+gen_config_to_use + else: + gen_config_parts=COMMAND_parts[2].split("/") + gen_config_to_use=gen_config_parts[len(gen_config_parts)-1] + additional_passins+=COMMAND_parts[2]+", " + COMMAND_parts[2]="/srv/"+gen_config_to_use + + if COMMAND_parts[28] != "None" and COMMAND_parts[28][:5]=="file:" : + janaconfig_parts=COMMAND_parts[28].split("/") + janaconfig_to_use=janaconfig_parts[len(janaconfig_parts)-1] + additional_passins+=COMMAND_parts[28][5:]+", " + COMMAND_parts[28]="file:/srv/"+janaconfig_to_use + + if COMMAND_parts[31] != "no_sqlite" : + ccdbsqlite_parts=COMMAND_parts[31].split("/") + ccdbsqlite_to_use=ccdbsqlite_parts[len(ccdbsqlite_parts)-1] + additional_passins+=COMMAND_parts[31]+", " + COMMAND_parts[31]="/srv/"+ccdbsqlite_to_use + + if COMMAND_parts[32] != "no_sqlite" : + rcdbsqlite_parts=COMMAND_parts[32].split("/") + rcdbsqlite_to_use=rcdbsqlite_parts[len(rcdbsqlite_parts)-1] + additional_passins+=COMMAND_parts[32]+", " + COMMAND_parts[32]="/srv/"+rcdbsqlite_to_use + + if additional_passins != "": + additional_passins=", "+additional_passins + additional_passins=additional_passins[:-2] + + modified_COMMAND="" + + for com in COMMAND_parts: + modified_COMMAND=modified_COMMAND+com+" " + + modified_COMMAND=modified_COMMAND[:-1] + f=open('MCOSG.submit','w') f.write("universe = vanilla"+"\n") - f.write("Executable = osg-container.sh""\n") - f.write("Arguments = "+indir+" "+COMMAND+"\n") + f.write("Executable = "+os.environ.get('MCWRAPPER_CENTRAL')+"/osg-container.sh"+"\n") + #f.write("Arguments = "+indir+" "+COMMAND+"\n") + f.write("Arguments = "+"./"+script_to_use+" "+modified_COMMAND+"\n") f.write("Requirements = (HAS_SINGULARITY == TRUE) && (HAS_CVMFS_oasis_opensciencegrid_org == True)"+"\n") f.write('+SingularityImage = "/cvmfs/singularity.opensciencegrid.org/rjones30/gluex:latest"'+"\n") f.write('+SingularityBindCVMFS = True'+"\n") f.write('+SingularityAutoLoad = True'+"\n") - f.write('should_transfer_files = IF_NEEDED'+"\n") + f.write('should_transfer_files = YES'+"\n") f.write('when_to_transfer_output = ON_EXIT'+"\n") - f.write('x509userproxy = /tmp/user_proxy'+"\n") + f.write('concurrency_limits = GluexProduction'+"\n") f.write('on_exit_remove = true'+"\n") f.write('on_exit_hold = false'+"\n") - f.write("Error = "+DATA_OUTPUT_BASE_DIR+"/log/"+"error_"+JOBNAME+".log\n") - f.write("Log = "+DATA_OUTPUT_BASE_DIR+"/log/"+"out_"+JOBNAME+".log\n") - f.write("output = "+DATA_OUTPUT_BASE_DIR+"/log/"+"OSGout_"+JOBNAME+".log\n") + f.write("Error = "+LOG_DIR+"/log/"+"error_"+JOBNAME+".log\n") + f.write("Log = "+LOG_DIR+"/log/"+"out_"+JOBNAME+".log\n") + f.write("output = "+LOG_DIR+"OSGout_"+JOBNAME+".log\n") f.write("initialdir = "+RUNNING_DIR+"\n") - f.write("transfer_input_files = "+ENVFILE+"\n") - f.write("transfer_output_files = "+DATA_OUTPUT_BASE_DIR+"\n") + #f.write("transfer_input_files = "+ENVFILE+"\n") + f.write("transfer_input_files = "+indir+", "+ENVFILE+additional_passins+"\n") + f.write("transfer_output_files = "+RUNNUM+"_"+str(FILENUM)+"\n") + f.write("transfer_output_remaps = "+"\""+RUNNUM+"_"+str(FILENUM)+"="+DATA_OUTPUT_BASE_DIR+"\""+"\n") f.write("queue\n") f.close() - #add_command="condor_submit -name "+JOBNAME+" MCOSG.submit" - #if add_command.find(';')!=-1 or add_command.find('&')!=-1 or mkdircom.find(';')!=-1 or mkdircom.find('&')!=-1:#THIS CHECK HELPS PROTEXT AGAINST A POTENTIAL HACK VIA CONFIG FILES - # print "Nice try.....you cannot use ; or &" - # exit(1) + add_command="condor_submit -name "+JOBNAME+" MCOSG.submit" + if add_command.find(';')!=-1 or add_command.find('&')!=-1 :#THIS CHECK HELPS PROTEXT AGAINST A POTENTIAL HACK VIA CONFIG FILES + print "Nice try.....you cannot use ; or &" + exit(1) - #status = subprocess.call(add_command, shell=True) - #status = subprocess.call("rm MCOSG.submit", shell=True) + status = subprocess.call(mkdircom, shell=True) + status = subprocess.call(add_command, shell=True) + status = subprocess.call("rm MCOSG.submit", shell=True) def showhelp(): @@ -232,7 +292,7 @@ def main(argv): print "*********************************" print "Welcome to v1.12 of the MCwrapper" - print "Thomas Britton 12/19/17" + print "Thomas Britton 1/2/18" print "*********************************" #load all argument passed in and set default options @@ -520,6 +580,8 @@ def main(argv): indir=os.environ.get('MCWRAPPER_CENTRAL') script_to_use = "/MakeMC.csh" + #script_to_use = "/MakeHelloWorld.csh" + if environ['SHELL']=="/bin/bash" : script_to_use = "/MakeMC.sh" @@ -631,7 +693,7 @@ def main(argv): elif BATCHSYS.upper()=="CONDOR": condor_add_job(VERBOSE, WORKFLOW, runs[0], BASEFILENUM+FILENUM_this_run+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR ) elif BATCHSYS.upper()=="OSG": - OSG_add_job(VERBOSE, WORKFLOW, runs[0], BASEFILENUM+FILENUM_this_run+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE ) + OSG_add_job(VERBOSE, WORKFLOW, runs[0], BASEFILENUM+FILENUM_this_run+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE, LOG_DIR ) #print "----------------" else: @@ -661,7 +723,7 @@ def main(argv): elif BATCHSYS.upper()=="CONDOR": condor_add_job(VERBOSE, WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR ) elif BATCHSYS.upper()=="OSG": - OSG_add_job(VERBOSE, WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE ) + OSG_add_job(VERBOSE, WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, ENVFILE, LOG_DIR ) if BATCHRUN == 1 and BATCHSYS.upper() == "SWIF": From 0220e05e778d8720d4df85d670c8ebd8a0e8dcf4 Mon Sep 17 00:00:00 2001 From: T-Britton Date: Wed, 3 Jan 2018 08:22:29 -0500 Subject: [PATCH 08/13] Delete MakeHelloWorld.csh --- MCwrapper/MakeHelloWorld.csh | 3 --- 1 file changed, 3 deletions(-) delete mode 100755 MCwrapper/MakeHelloWorld.csh diff --git a/MCwrapper/MakeHelloWorld.csh b/MCwrapper/MakeHelloWorld.csh deleted file mode 100755 index fcf19a70..00000000 --- a/MCwrapper/MakeHelloWorld.csh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/csh -f - -echo "Hello" >& HelloWorld.txt \ No newline at end of file From c3a184a3a4a93f98c3aad9be64d94b6296af1b96 Mon Sep 17 00:00:00 2001 From: T-Britton Date: Wed, 3 Jan 2018 08:22:50 -0500 Subject: [PATCH 09/13] Delete osg-container.csh --- MCwrapper/osg-container.csh | 41 ------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 MCwrapper/osg-container.csh diff --git a/MCwrapper/osg-container.csh b/MCwrapper/osg-container.csh deleted file mode 100644 index 81b854de..00000000 --- a/MCwrapper/osg-container.csh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# -# osg-container.sh - gluex job wrapper script for osg jobs -# -# This script contains GENERIC (non-job-specific) steps for getting -# set up inside the gluex container on an osg worker node and launching -# the job script. It should not normally be modified by the user. -# -# Usage: osg-container.sh [job script arguments] -# -# Author: Richard.T.Jones at uconn.edu -# Version: June 8, 2017 - -set container="/cvmfs/singularity.opensciencegrid.org/rjones30/gluex:latest" -#oasismount="/cvmfs/oasis.opensciencegrid.org" -set oasismount="/cvmfs" -set dockerimage="docker://rjones30/gluex:latest" -set userproxy=x509up_u$UID - -# define the container context for running on osg workers - -if ( -f /environment ) then -    echo "Job running on" `hostname` -    ( -r .$userproxy ) && mv .$userproxy /tmp/$userproxy -    source /environment -    unset CCDB_CONNECTION -    unset RCDB_CONNECTION -    $* && retcode=$? -    echo "Job finished with exit code" $retcode -    rm -rf *.sqlite -    exit $retcode - -else if ( -f $container/environment ) then -    echo "Starting up container on" `hostname` -    ( -r /tmp/$userproxy ) && cp /tmp/$userproxy .$userproxy -    exec singularity exec --containall --bind ${oasismount} --home `pwd`:/srv --pwd /srv --scratch /tmp,/var/tmp ${container} \ -    bash $0 $* - -else -    echo "Job container not found on" `hostname` -endif \ No newline at end of file From 80e053580d6c6ecbc8e5fb864b703f638c442684 Mon Sep 17 00:00:00 2001 From: tbritton Date: Wed, 3 Jan 2018 08:31:05 -0500 Subject: [PATCH 10/13] text touchups --- MCwrapper/osg-container.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) mode change 100644 => 100755 MCwrapper/osg-container.sh diff --git a/MCwrapper/osg-container.sh b/MCwrapper/osg-container.sh old mode 100644 new mode 100755 index d6572188..44ecf9fd --- a/MCwrapper/osg-container.sh +++ b/MCwrapper/osg-container.sh @@ -20,22 +20,22 @@ userproxy=x509up_u$UID # define the container context for running on osg workers if [[ -f /environment ]]; then -    echo "Job running on" `hostname` -    [ -r .$userproxy ] && mv .$userproxy /tmp/$userproxy -    source /environment -    unset CCDB_CONNECTION -    unset RCDB_CONNECTION -    $* && retcode=$? -    echo "Job finished with exit code" $retcode -    rm -rf *.sqlite -    exit $retcode + echo "Job running on" `hostname` + [ -r .$userproxy ] && mv .$userproxy /tmp/$userproxy + source /environment + unset CCDB_CONNECTION + unset RCDB_CONNECTION + eval $*; retcode=$? + echo "Job finished with exit code" $retcode + rm -rf *.sqlite + exit $retcode elif [[ -f $container/environment ]]; then -    echo "Starting up container on" `hostname` -    [ -r /tmp/$userproxy ] && cp /tmp/$userproxy .$userproxy -    exec singularity exec --containall --bind ${oasismount} --home `pwd`:/srv --pwd /srv --scratch /tmp,/var/tmp ${container} \ -    bash $0 $* + echo "Starting up container on" `hostname` + [ -r /tmp/$userproxy ] && cp /tmp/$userproxy .$userproxy + exec singularity exec --containall --bind ${oasismount} --home `pwd`:/srv --pwd /srv --scratch /tmp,/var/tmp ${container} \ + bash $0 $* else -    echo "Job container not found on" `hostname` -fi \ No newline at end of file + echo "Job container not found on" `hostname` +fi From bf3a88da83e3ca1bd8d8a064d63a9d468420ee83 Mon Sep 17 00:00:00 2001 From: tbritton Date: Wed, 3 Jan 2018 08:31:18 -0500 Subject: [PATCH 11/13] text touchups --- MCwrapper/examples/MC.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MCwrapper/examples/MC.config b/MCwrapper/examples/MC.config index 28e06a88..32799b72 100755 --- a/MCwrapper/examples/MC.config +++ b/MCwrapper/examples/MC.config @@ -3,7 +3,7 @@ #CUSTOM_GCONTROL=use-this-Gcontrol-instead #======================================================================== -#VARIATION=mc calibtime=timegoes here #set your jana calib context here with or without calibtime Default is variation=mc +#VARIATION=mc calibtime=timegoeshere #set your jana calib context here with or without calibtime Default is variation=mc #RUNNING_DIRECTORY=/run/in/this/directory #where the code should run. This is defaulted to ./ From 2915fb2d7f252ec559ab0bdd512d6d8aa6fa71c4 Mon Sep 17 00:00:00 2001 From: tbritton Date: Wed, 3 Jan 2018 09:56:03 -0500 Subject: [PATCH 12/13] changed osg log location --- MCwrapper/gluex_MC.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MCwrapper/gluex_MC.py b/MCwrapper/gluex_MC.py index 8c1dec11..2ddc6adf 100755 --- a/MCwrapper/gluex_MC.py +++ b/MCwrapper/gluex_MC.py @@ -230,7 +230,7 @@ def OSG_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, DAT f.write('on_exit_hold = false'+"\n") f.write("Error = "+LOG_DIR+"/log/"+"error_"+JOBNAME+".log\n") f.write("Log = "+LOG_DIR+"/log/"+"out_"+JOBNAME+".log\n") - f.write("output = "+LOG_DIR+"OSGout_"+JOBNAME+".log\n") + f.write("output = "+LOG_DIR+"/log/"+"OSGout_"+JOBNAME+".log\n") f.write("initialdir = "+RUNNING_DIR+"\n") #f.write("transfer_input_files = "+ENVFILE+"\n") f.write("transfer_input_files = "+indir+", "+ENVFILE+additional_passins+"\n") @@ -292,7 +292,7 @@ def main(argv): print "*********************************" print "Welcome to v1.12 of the MCwrapper" - print "Thomas Britton 1/2/18" + print "Thomas Britton 1/3/18" print "*********************************" #load all argument passed in and set default options From bf76792b00a8dfa6dc500c338b02bc69963e2870 Mon Sep 17 00:00:00 2001 From: tbritton Date: Wed, 3 Jan 2018 10:37:16 -0500 Subject: [PATCH 13/13] better osg log naming scheme --- MCwrapper/gluex_MC.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MCwrapper/gluex_MC.py b/MCwrapper/gluex_MC.py index 2ddc6adf..8846dcc4 100755 --- a/MCwrapper/gluex_MC.py +++ b/MCwrapper/gluex_MC.py @@ -229,8 +229,8 @@ def OSG_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, DAT f.write('on_exit_remove = true'+"\n") f.write('on_exit_hold = false'+"\n") f.write("Error = "+LOG_DIR+"/log/"+"error_"+JOBNAME+".log\n") - f.write("Log = "+LOG_DIR+"/log/"+"out_"+JOBNAME+".log\n") - f.write("output = "+LOG_DIR+"/log/"+"OSGout_"+JOBNAME+".log\n") + f.write("output = "+LOG_DIR+"/log/"+"out_"+JOBNAME+".log\n") + f.write("log = "+LOG_DIR+"/log/"+"OSG_"+JOBNAME+".log\n") f.write("initialdir = "+RUNNING_DIR+"\n") #f.write("transfer_input_files = "+ENVFILE+"\n") f.write("transfer_input_files = "+indir+", "+ENVFILE+additional_passins+"\n")