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 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 5cadac3e..7c46f223 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 @@ -93,27 +93,27 @@ 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 cd $RUNNING_DIR/${RUN_NUMBER}_${FILE_NUMBER} if ( "$ccdbSQLITEPATH" != "no_sqlite" ) then - #cp $ccdbSQLITEPATH ./ccdb.sqlite - setenv CCDB_CONNECTION sqlite:///$ccdbSQLITEPATH + cp $ccdbSQLITEPATH ./ccdb.sqlite + 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 + cp $rcdbSQLITEPATH ./rcdb.sqlite + setenv RCDB_CONNECTION sqlite:///$PWD/rcdb.sqlite #$rcdbSQLITEPATH endif echo "" @@ -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,21 +413,23 @@ 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 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 else echo "cannot find file: "$gen_in_file - exit + 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" @@ -433,7 +437,7 @@ if ( "$GENR" != "0" ) then echo "Config file not applicable" else echo $CONFIG_FILE" does not exist" - exit + exit 1 endif endif @@ -507,6 +511,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 +529,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 +540,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 +556,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 +572,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 +610,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 +632,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 +660,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 +709,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 +739,37 @@ 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 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 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 +788,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 +803,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 +828,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 +872,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 +884,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 f4b7d650..ef43a807 100755 --- a/MCwrapper/MakeMC.sh +++ b/MCwrapper/MakeMC.sh @@ -111,14 +111,14 @@ fi cd $RUNNING_DIR/${RUN_NUMBER}_${FILE_NUMBER} if [[ "$ccdbSQLITEPATH" != "no_sqlite" ]]; then - #cp $ccdbSQLITEPATH ./ccdb.sqlite - export CCDB_CONNECTION=sqlite:///$ccdbSQLITEPATH + cp $ccdbSQLITEPATH ./ccdb.sqlite + 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 + cp $rcdbSQLITEPATH ./rcdb.sqlite + export RCDB_CONNECTION=sqlite:///$PWD/rcdb.sqlite fi echo "" @@ -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 @@ -419,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 @@ -426,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" @@ -508,6 +512,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 +530,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 +542,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 +557,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 +573,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 +611,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 +630,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 +663,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 +709,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 +740,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 +784,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 +803,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 +821,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 +879,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..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 ./ @@ -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 e3a70e74..efa147bc 100755 --- a/MCwrapper/gluex_MC.py +++ b/MCwrapper/gluex_MC.py @@ -153,6 +153,102 @@ 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, 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 = "+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 = YES'+"\n") + f.write('when_to_transfer_output = ON_EXIT'+"\n") + + f.write('concurrency_limits = GluexProduction'+"\n") + 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("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") + 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 :#THIS CHECK HELPS PROTEXT AGAINST A POTENTIAL HACK VIA CONFIG FILES + print "Nice try.....you cannot use ; or &" + exit(1) + + status = subprocess.call(mkdircom, shell=True) + 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" @@ -195,8 +291,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 1/3/18" print "*********************************" #load all argument passed in and set default options @@ -337,6 +433,8 @@ def main(argv): return if subparts[0].upper() == "TAGONLY": BGTAGONLY=1 + if BGFOLD == "DEFAULT": + BGFOLD="TagOnly" if len(subparts)==2: BGRATE=subparts[1] @@ -482,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" @@ -592,6 +692,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": + 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: @@ -620,6 +722,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": + 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": diff --git a/MCwrapper/osg-container.sh b/MCwrapper/osg-container.sh new file mode 100755 index 00000000..44ecf9fd --- /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 + 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 $* + +else + echo "Job container not found on" `hostname` +fi