diff --git a/MCwrapper/MakeMC.csh b/MCwrapper/MakeMC.csh index f3b562b9..03710dbd 100755 --- a/MCwrapper/MakeMC.csh +++ b/MCwrapper/MakeMC.csh @@ -1,5 +1,5 @@ #!/bin/csh -f - + # SET INPUTS setenv ENVIRONMENT $1 shift @@ -82,18 +82,18 @@ echo "detected c-shell" #necessary to run swif, uses local directory if swif=0 is used if ( "$MCSWIF" == "1" ) then # ENVIRONMENT -echo $ENVIRONMENT -source $ENVIRONMENT -echo pwd=$PWD -mkdir -p $OUTDIR -mkdir -p $OUTDIR/log + echo $ENVIRONMENT + source $ENVIRONMENT + echo pwd=$PWD + mkdir -p $OUTDIR + mkdir -p $OUTDIR/log endif if ( "$CUSTOM_GCONTROL" == "0" ) then -cp $MCWRAPPER_CENTRAL/Gcontrol.in ./temp_Gcontrol.in -chmod 777 ./temp_Gcontrol.in + cp $MCWRAPPER_CENTRAL/Gcontrol.in ./temp_Gcontrol.in + chmod 777 ./temp_Gcontrol.in else -cp $CUSTOM_GCONTROL/Gcontrol.in ./temp_Gcontrol.in + cp $CUSTOM_GCONTROL/Gcontrol.in ./temp_Gcontrol.in endif @ length_count=`echo $RUN_NUMBER | wc -c` - 1 @@ -153,6 +153,29 @@ if ( ! -d "$OUTDIR/root/" ) then mkdir $OUTDIR/root/ endif +set bkglocstring="" +if ( "$BKGFOLDSTR" == "DEFAULT" ) then + #find file and run:1 + echo "Finding the right file to fold in during MCsmear step" + set runperiod="RunPeriod-2017-01" + + if ( $RUN_NUMBER > 40000 ) then + echo + #set runperiod="RunPeriod-2017-10" + endif + + if ( $RUN_NUMBER < 30000 ) then + echo "Warning: random triggers did not exist by this point" + endif + set bkglocstring="/cache/halld/""$runperiod""/sim/random_triggers/""run$formatted_runNumber""_random.hddm" + #set bkglocstring="/w/halld-scifs1a/home/tbritton/converted.hddm" + + if ( ! -f $bkglocstring ) then + echo "Could not find mix-in file "$bkglocstring + exit + endif +endif + set gen_pre="" if ( "$GENR" != "0" ) then @@ -323,37 +346,15 @@ if ( "$GENR" != "0" ) then if ( "$BKGFOLDSTR" == "BeamPhotons" || "$BKGFOLDSTR" == "None" ) then echo "running MCsmear without folding in random background" mcsmear -o$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' $STANDARD_NAME'_geant'$GEANTVER'.hddm' - else - if ( "$BKGFOLDSTR" == "DEFAULT" ) then - #find file and run:1 - echo "Finding the right file to fold in" - set runperiod="RunPeriod-2017-01" - - if ( $RUN_NUMBER > 40000 ) then - echo - #set runperiod="RunPeriod-2017-10" - endif - - if ( $RUN_NUMBER < 30000 ) then - echo "Warning: random triggers did not exist by this point" - endif - set bkglocstring="/cache/halld/""$runperiod""/sim/random_triggers/""run$formatted_runNumber""_random.hddm" - #set bkglocstring="/w/halld-scifs1a/home/tbritton/converted.hddm" - - if ( ! -f $bkglocstring ) then - echo "Could not find mix-in file "$bkglocstring - exit - else + else if ( "$BKGFOLDSTR" == "DEFAULT" ) echo "mcsmear -o$STANDARD_NAME"\_"geant$GEANTVER"\_"smeared.hddm $STANDARD_NAME"\_"geant$GEANTVER.hddm $bkglocstring"\:"1" mcsmear -o$STANDARD_NAME\_geant$GEANTVER\_smeared.hddm $STANDARD_NAME\_geant$GEANTVER.hddm $bkglocstring\:1 - endif - else #trust the user and use their string echo 'mcsmear -o'$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm'' '$STANDARD_NAME'_geant'$GEANTVER'.hddm'' '$BKGFOLDSTR mcsmear -o$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' $STANDARD_NAME'_geant'$GEANTVER'.hddm' $BKGFOLDSTR endif - endif + #run reconstruction if ( "$CLEANGENR" == "1" ) then if ( "$GENERATOR" == "genr8" ) then @@ -369,25 +370,34 @@ if ( "$GENR" != "0" ) then endif if ( "$RECON" != "0" ) then - echo "RUNNING RECONSTRUCTION" - set pluginlist=("danarest" "monitoring_hists") + echo "RUNNING RECONSTRUCTION" + + set recon_pre=`echo $CUSTOM_PLUGINS | cut -c1-4` + + if ( "$recon_pre" == "file" ) then + set jana_config_file=`echo $CUSTOM_PLUGINS | sed -r 's/^.{5}//'` + echo "using config file: "$jana_config_file + hd_root ./$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' --config=$jana_config_file -PNTHREADS=$NUMTHREADS + else + set pluginlist=("danarest" "monitoring_hists") - if ( "$CUSTOM_PLUGINS" != "None" ) then - set pluginlist=( "$pluginlist" "$CUSTOM_PLUGINS" ) - endif + if ( "$CUSTOM_PLUGINS" != "None" ) then + set pluginlist=( "$pluginlist" "$CUSTOM_PLUGINS" ) + endif - set PluginStr="" + set PluginStr="" - foreach plugin ($pluginlist) - set PluginStr="$PluginStr""$plugin""," - end - - set PluginStr=`echo $PluginStr | sed -r 's/.{1}$//'` - 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 - mv dana_rest.hddm dana_rest_$STANDARD_NAME.hddm + foreach plugin ($pluginlist) + set PluginStr="$PluginStr""$plugin""," + end + set PluginStr=`echo $PluginStr | sed -r 's/.{1}$//'` + 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 + mv dana_rest.hddm dana_rest_$STANDARD_NAME.hddm + endif + if ( "$CLEANGEANT" == "1" ) then rm *_geant$GEANTVER.hddm rm control.in @@ -412,9 +422,10 @@ if ( "$GENR" != "0" ) then foreach rootfile ($rootfiles) set filename_root=`echo $rootfile | sed -r 's/.{5}$//'` set filetomv="$rootfile" - mv $filetomv $filename_root\_$STANDARD_NAME.root - end - mv $PWD/$filename_root\_$STANDARD_NAME.root $OUTDIR/root/ + mv $filetomv $filename_root\_$STANDARD_NAME.root + mv $PWD/$filename_root\_$STANDARD_NAME.root $OUTDIR/root/ + end + endif endif @@ -424,6 +435,11 @@ endif if ( "$gen_pre" != "file" ) then mv $PWD/*.conf $OUTDIR/configurations/ endif -mv $PWD/*.hddm $OUTDIR/hddm/ + +set hddmfiles=`ls | grep .hddm` +if ( $hddmfiles != "" ) then + mv $PWD/*.hddm $OUTDIR/hddm/ +endif + # mv $PWD/*.root $OUTDIR/root/ #just in case echo `date` diff --git a/MCwrapper/MakeMC.sh b/MCwrapper/MakeMC.sh index e01c311e..e4ffc6b0 100755 --- a/MCwrapper/MakeMC.sh +++ b/MCwrapper/MakeMC.sh @@ -153,6 +153,30 @@ if [[ ! -d "$OUTDIR/root/" ]]; then mkdir $OUTDIR/root/ fi +bkglocstring="" +if [[ "$BKGFOLDSTR" == "DEFAULT" ]]; then + #find file and run:1 + echo "Finding the right file to fold in during MCsmear step" + runperiod="RunPeriod-2017-01" + + if [[ $RUN_NUMBER > 40000 ]]; then + echo + #set runperiod="RunPeriod-2017-10" + fi + + if [[ $RUN_NUMBER < 30000 ]]; then + echo "Warning: random triggers did not exist by this point" + fi + + bkglocstring="/cache/halld/""$runperiod""/sim/random_triggers/""run$formatted_runNumber""_random.hddm" + #set bkglocstring="/w/halld-scifs1a/home/tbritton/converted.hddm" + + if [[ ! -f $bkglocstring ]]; then + echo "Could not find mix-in file "$bkglocstring + exit + fi +fi + gen_pre="" if [[ "$GENR" != "0" ]]; then @@ -322,36 +346,14 @@ if [[ "$GENR" != "0" ]]; then if [[ "$BKGFOLDSTR" == "BeamPhotons" || "$BKGFOLDSTR" == "None" ]]; then echo "running MCsmear without folding in random background" mcsmear -o$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' $STANDARD_NAME'_geant'$GEANTVER'.hddm' - else - if [[ "$BKGFOLDSTR" == "DEFAULT" ]]; then - #find file and run:1 - echo "Finding the right file to fold in" - runperiod="RunPeriod-2017-01" - - if [[ $RUN_NUMBER > 40000 ]]; then - echo - #runperiod="RunPeriod-2017-10" - fi - - if [[ $RUN_NUMBER < 30000 ]]; then - echo "Warning: random triggers did not exist by this point" - fi - bkglocstring="/cache/halld/""$runperiod""/sim/random_triggers/""run$formatted_runNumber""_random.hddm" - #bkglocstring="/w/halld-scifs1a/home/tbritton/converted.hddm" - - if [[ ! -f $bkglocstring ]]; then - echo "Could not find mix-in file "$bkglocstring - exit - else + elif [[ "$BKGFOLDSTR" == "DEFAULT" ]]; then echo "mcsmear -o$STANDARD_NAME"\_"geant$GEANTVER"\_"smeared.hddm $STANDARD_NAME"\_"geant$GEANTVER.hddm $bkglocstring"\:"1" mcsmear -o$STANDARD_NAME\_geant$GEANTVER\_smeared.hddm $STANDARD_NAME\_geant$GEANTVER.hddm $bkglocstring\:1 - fi - else #trust the user and use their string echo 'mcsmear -o'$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm'' '$STANDARD_NAME'_geant'$GEANTVER'.hddm'' '$BKGFOLDSTR mcsmear -o$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' $STANDARD_NAME'_geant'$GEANTVER'.hddm' $BKGFOLDSTR - fi + fi #run reconstruction if [[ "$CLEANGENR" == "1" ]]; then @@ -369,26 +371,36 @@ if [[ "$GENR" != "0" ]]; then if [[ "$RECON" != "0" ]]; then echo "RUNNING RECONSTRUCTION" - declare -a pluginlist=("danarest" "monitoring_hists") - echo ${pluginlist[@]} - echo $CUSTOM_PLUGINS - if [[ "$CUSTOM_PLUGINS" != "None" ]]; then - pluginlist=("${pluginlist[@]}" $CUSTOM_PLUGINS) - fi - echo ${pluginlist[@]} + + recon_pre=`echo $CUSTOM_PLUGINS | cut -c1-4` - PluginStr="" + if [[ "$recon_pre" == "file" ]]; then + jana_config_file=`echo $CUSTOM_PLUGINS | sed -r 's/^.{5}//'` + echo "using config file: "$jana_config_file + hd_root ./$STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' --config=$jana_config_file -PNTHREADS=$NUMTHREADS + else - for plugin in "${pluginlist[@]}"; do - PluginStr="$PluginStr""$plugin""," - done + declare -a pluginlist=("danarest" "monitoring_hists") + echo ${pluginlist[@]} + echo $CUSTOM_PLUGINS + if [[ "$CUSTOM_PLUGINS" != "None" ]]; then + pluginlist=("${pluginlist[@]}" $CUSTOM_PLUGINS) + fi + echo ${pluginlist[@]} + + PluginStr="" - PluginStr=`echo $PluginStr | sed -r 's/.{1}$//'` - 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 - mv dana_rest.hddm dana_rest_$STANDARD_NAME.hddm + for plugin in "${pluginlist[@]}"; do + PluginStr="$PluginStr""$plugin""," + done + PluginStr=`echo $PluginStr | sed -r 's/.{1}$//'` + 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 + mv dana_rest.hddm dana_rest_$STANDARD_NAME.hddm + fi + if [[ "$CLEANGEANT" == "1" ]]; then rm *_geant$GEANTVER.hddm rm control.in @@ -415,14 +427,17 @@ if [[ "$GENR" != "0" ]]; then filename_root=`echo $rootfile | sed -r 's/.{5}$//'` filetomv="$rootfile" mv $filetomv $filename_root\_$STANDARD_NAME.root - done mv $PWD/$filename_root\_$STANDARD_NAME.root $OUTDIR/root/ + done fi fi fi fi if [[ "$gen_pre" != "file" ]]; then -mv $PWD/*.conf $OUTDIR/configurations/ + mv $PWD/*.conf $OUTDIR/configurations/ +fi +hddmfiles=$(ls | grep .hddm) +if [[ $hddmfiles != "" ]]; then + mv $PWD/*.hddm $OUTDIR/hddm/ fi -mv $PWD/*.hddm $OUTDIR/hddm/ #mv $PWD/*.root $OUTDIR/root/ #just in case diff --git a/MCwrapper/examples/MC.config b/MCwrapper/examples/MC.config index 34b9b99f..22ea962a 100644 --- a/MCwrapper/examples/MC.config +++ b/MCwrapper/examples/MC.config @@ -2,25 +2,27 @@ #CUSTOM_MAKEMC=use-this-script-instead #CUSTOM_GCONTROL=use-this-Gcontrol-instead #======================================================================== -#TAG=my-custom-prefix-tab -# OUTPUT DATA LOCATION + +#TAG=my-custom-prefix-tag + DATA_OUTPUT_BASE_DIR=OUTPUT-LOCATION#your desired output location NCORES=4 # Number of CPU threads to use -GENERATOR=generator-to-use +GENERATOR=generator-to-use #or you may specifile file:/.../file-to-use GENERATOR_CONFIG=config file for generator #common parameters for generators -eBEAM_ENERGY=12 -COHERENT_PEAK=9 -GEN_MIN_ENERGY=4 -GEN_MAX_ENERGY=12 +#eBEAM_ENERGY=12 +#COHERENT_PEAK=9 +#GEN_MIN_ENERGY=4 +#GEN_MAX_ENERGY=12 GEANT_VERSION=4 BKG=BeamPhotons #[None, BeamPhotons, DEFAULT, custom bg.hddm:1.8] -#CUSTOM_PLUGINS #optional additional plugins that will be run along side danarest and hd_root. This should be a comma separated list (e.g. plugin1,plugin2) +#optional additional plugins that will be run along side danarest and hd_root. This should be a comma separated list (e.g. plugin1,plugin2) +#CUSTOM_PLUGINS= #or file:/.../file-to-use which is a configuration file for jana/hd_root #==================================================================================== #EVERYTHING BELOW FOR SWIF ONLY diff --git a/MCwrapper/gluex_MC.py b/MCwrapper/gluex_MC.py index 1dad29c5..de700025 100755 --- a/MCwrapper/gluex_MC.py +++ b/MCwrapper/gluex_MC.py @@ -103,7 +103,7 @@ def main(argv): print "*********************************" print "Welcome to v1.3.1 of the MCwrapper" - print "Thomas Britton 04/14/17" + print "Thomas Britton 04/18/17" print "*********************************"