Skip to content

Commit

Permalink
Merge pull request #34 from JeffersonLab/OSG
Browse files Browse the repository at this point in the history
Osg
  • Loading branch information
T-Britton authored Jan 3, 2018
2 parents ff938ff + bf76792 commit ded92e2
Show file tree
Hide file tree
Showing 7 changed files with 343 additions and 84 deletions.
1 change: 1 addition & 0 deletions MCwrapper/Generators/bggen_jpsi/particle.dat
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions MCwrapper/Generators/genEtaRegge/examples/eta548.in
Original file line number Diff line number Diff line change
Expand Up @@ -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



137 changes: 99 additions & 38 deletions MCwrapper/MakeMC.csh
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,35 @@ 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
mkdir -p $OUTDIR
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 ""
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -389,19 +389,21 @@ 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


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=""
Expand All @@ -411,29 +413,31 @@ 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"
else if( "$GENERATOR" == "gen_ee" || "$GENERATOR" == "gen_ee_hb" ) then
echo "Config file not applicable"
else
echo $CONFIG_FILE" does not exist"
exit
exit 1
endif
endif

Expand Down Expand Up @@ -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'`
Expand All @@ -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"
Expand All @@ -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/.//'`

Expand All @@ -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/.//'`
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
Loading

0 comments on commit ded92e2

Please sign in to comment.