Skip to content

Commit

Permalink
rewrite of standard names, enhanced naming, more minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Britton committed Apr 7, 2017
1 parent 2d757aa commit e4e8af4
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 187 deletions.
106 changes: 60 additions & 46 deletions MCwrapper/MakeMC.csh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ setenv ENVIRONMENT $1
shift
setenv CONFIG_FILE $1
shift
setenv GEN_NAME $1
shift
setenv OUTDIR $1
shift
setenv RUN_NUMBER $1
Expand Down Expand Up @@ -52,6 +50,8 @@ shift
setenv GEN_MIN_ENERGY $1
shift
setenv GEN_MAX_ENERGY $1
shift
setenv TAGSTR $1

if ("$GEANTVER" == "3") then
setenv NUMTHREADS 1
Expand Down Expand Up @@ -86,7 +86,7 @@ mkdir -p $OUTDIR
mkdir -p $OUTDIR/log
endif

if ("$CUSTOM_GCONTROL" == "0" ) then
if ( "$CUSTOM_GCONTROL" == "0" ) then
cp $MCWRAPPER_CENTRAL/Gcontrol.in ./temp_Gcontrol.in
chmod 777 ./temp_Gcontrol.in
else
Expand All @@ -111,6 +111,14 @@ set formatted_fileNumber="0""$formatted_fileNumber"
end
set formatted_fileNumber=$formatted_fileNumber$FILE_NUMBER

set custom_tag=""

if ( "$TAGSTR" != "I_dont_have_one" ) then
set custom_tag=$TAGSTR\_
endif

set STANDARD_NAME=$custom_tag$formatted_runNumber\_$formatted_fileNumber

set colsize=`rcnd $RUN_NUMBER collimator_diameter | awk '{print $1}' | sed -r 's/.{2}$//' | sed -e 's/\.//g'`
if ( "$colsize" == "B" || "$colsize" == "R" || "$JANA_CALIB_CONTEXT" != "variation=mc" ) then
set colsize="50"
Expand Down Expand Up @@ -145,78 +153,84 @@ if ( "$GENR" != "0" ) then

if ( "$GENERATOR" == "genr8" ) then
echo "configuring genr8"
cp $CONFIG_FILE ./genr8\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
set STANDARD_NAME="genr8_"$STANDARD_NAME
cp $CONFIG_FILE ./$STANDARD_NAME.conf
else if ( "$GENERATOR" == "bggen" ) then
echo "configuring bggen"
set STANDARD_NAME="bggen_"$STANDARD_NAME
cp $MCWRAPPER_CENTRAL/Generators/bggen/particle.dat ./
cp $MCWRAPPER_CENTRAL/Generators/bggen/pythia.dat ./
cp $MCWRAPPER_CENTRAL/Generators/bggen/pythia-geant.map ./
cp $CONFIG_FILE ./bggen\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
cp $CONFIG_FILE ./$STANDARD_NAME.conf

else if ( "$GENERATOR" == "genEtaRegge" ) then
echo "configuring genEtaRegge"
cp $CONFIG_FILE ./genEtaRegge\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
set STANDARD_NAME="genEtaRegge_"$STANDARD_NAME
cp $CONFIG_FILE ./$STANDARD_NAME.conf
else if ( "$GENERATOR" == "gen_2pi_amp" ) then
echo "configuring gen_2pi_amp"
cp $CONFIG_FILE ./gen_2pi_amp\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
set STANDARD_NAME="gen_2pi_amp_"$STANDARD_NAME
cp $CONFIG_FILE ./$STANDARD_NAME.conf
else if ( "$GENERATOR" == "gen_2pi_primakoff" ) then
echo "configuring gen_2pi_primakoff"
cp $CONFIG_FILE ./gen_2pi_primakoff\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
set STANDARD_NAME="gen_2pi_primakoff_"$STANDARD_NAME
cp $CONFIG_FILE ./$STANDARD_NAME.conf
else if ( "$GENERATOR" == "gen_pi0" ) then
echo "configuring gen_pi0"
cp $CONFIG_FILE ./gen_pi0\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
set STANDARD_NAME="genr_pi0_"$STANDARD_NAME
cp $CONFIG_FILE ./$STANDARD_NAME.conf
endif
set config_file_name=`basename "$CONFIG_FILE"`
echo $config_file_name

if ( "$GENERATOR" == "genr8" ) then
echo "RUNNING GENR8"
set RUNNUM=$formatted_runNumber+$formatted_fileNumber
sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' genr8\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' $STANDARD_NAME.conf
# RUN genr8 and convert
genr8 -r$formatted_runNumber -M$EVT_TO_GEN -A$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.ascii < genr8\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf #$config_file_name
genr8_2_hddm $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.ascii
genr8 -r$formatted_runNumber -M$EVT_TO_GEN -A$STANDARD_NAME.ascii < $STANDARD_NAME.conf #$config_file_name
genr8_2_hddm $STANDARD_NAME.ascii
else if ( "$GENERATOR" == "bggen" ) then
set RANDOM=$$
echo $RANDOM
sed -i 's/TEMPTRIG/'$EVT_TO_GEN'/' bggen\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPRUNNO/'$RUN_NUMBER'/' bggen\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPCOLD/'0.00$colsize'/' bggen\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPRAND/'$RANDOM'/' bggen\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPELECE/'$eBEAM_ENERGY'/' bggen\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' bggen\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPMINGENE/'$GEN_MIN_ENERGY'/' bggen\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPMAXGENE/'$GEN_MAX_ENERGY'/' bggen\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPTRIG/'$EVT_TO_GEN'/' $STANDARD_NAME.conf
sed -i 's/TEMPRUNNO/'$RUN_NUMBER'/' $STANDARD_NAME.conf
sed -i 's/TEMPCOLD/'0.00$colsize'/' $STANDARD_NAME.conf
sed -i 's/TEMPRAND/'$RANDOM'/' $STANDARD_NAME.conf
sed -i 's/TEMPELECE/'$eBEAM_ENERGY'/' $STANDARD_NAME.conf
sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' $STANDARD_NAME.conf
sed -i 's/TEMPMINGENE/'$GEN_MIN_ENERGY'/' $STANDARD_NAME.conf
sed -i 's/TEMPMAXGENE/'$GEN_MAX_ENERGY'/' $STANDARD_NAME.conf

ln -s bggen\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf fort.15
ln -s $STANDARD_NAME.conf fort.15
bggen
mv bggen.hddm $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.hddm
mv bggen.hddm $STANDARD_NAME.hddm
else if ( "$GENERATOR" == "genEtaRegge" ) then
echo "RUNNING GENETAREGGE"

sed -i 's/TEMPCOLD/'0.00$colsize'/' genEtaRegge\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPELECE/'$eBEAM_ENERGY'/' genEtaRegge\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' genEtaRegge\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPMINGENE/'$GEN_MIN_ENERGY'/' genEtaRegge\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPMAXGENE/'$GEN_MAX_ENERGY'/' genEtaRegge\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
genEtaRegge -N$EVT_TO_GEN -O$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.hddm -I'genEtaRegge'\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf
sed -i 's/TEMPCOLD/'0.00$colsize'/' $STANDARD_NAME.conf
sed -i 's/TEMPELECE/'$eBEAM_ENERGY'/' $STANDARD_NAME.conf
sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' $STANDARD_NAME.conf
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
echo "RUNNING GEN_2PI_AMP"
set optionals_line=`head -n 1 $config_file_name | sed -r 's/.//'`
echo $optionals_line
echo gen_2pi_amp -c gen_2pi_amp\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf -o $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.hddm -hd $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY $optionals_line
gen_2pi_amp -c gen_2pi_amp\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf -hd $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.hddm -o $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY $optionals_line
echo gen_2pi_amp -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 $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 $optionals_line
else if ( "$GENERATOR" == "gen_2pi_primakoff" ) then
echo "RUNNING GEN_2PI_PRIMAKOFF"
set optionals_line=`head -n 1 $config_file_name | sed -r 's/.//'`
echo $optionals_line
echo gen_2pi_primakoff -c gen_2pi_primakoff\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf -o $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.hddm -hd $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY $optionals_line
gen_2pi_primakoff -c gen_2pi_primakoff\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf -hd $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.hddm -o $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY $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 $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 $optionals_line
else if ( "$GENERATOR" == "gen_pi0" ) then
echo "RUNNING GEN_PI0"
set optionals_line=`head -n 1 $config_file_name | sed -r 's/.//'`
echo $optionals_line
gen_pi0 -c gen_pi0\_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.conf -hd $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.hddm -o $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.root -n $EVT_TO_GEN -r $RUN_NUMBER -a $GEN_MIN_ENERGY -b $GEN_MAX_ENERGY -p $COHERENT_PEAK -s $formatted_fileNumber $optionals_line -m $eBEAM_ENERGY
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 $optionals_line -m $eBEAM_ENERGY
endif

#GEANT/smearing
Expand All @@ -231,14 +245,13 @@ if ( "$GENR" != "0" ) then
set COHERENT_PEAK=$COHERENT_PEAK\.
endif

set inputfile=$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber
cp temp_Gcontrol.in $PWD/control'_'$formatted_runNumber'_'$formatted_fileNumber.in
chmod 777 $PWD/control'_'$formatted_runNumber'_'$formatted_fileNumber.in
sed -i 's/TEMPELECE/'$eBEAM_ENERGY'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in
sed -i 's/TEMPCOHERENT/'$COHERENT_PEAK'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in
sed -i 's/TEMPIN/'$inputfile.hddm'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in
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
sed -i 's/TEMPOUT/'$inputfile'_geant.hddm/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in
sed -i 's/TEMPOUT/'$STANDARD_NAME'_geant'$GEANTVER'.hddm/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in
sed -i 's/TEMPTRIG/'$EVT_TO_GEN'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in
sed -i 's/TEMPCOLD/'0.00$colsize'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in

Expand Down Expand Up @@ -272,14 +285,15 @@ if ( "$GENR" != "0" ) then

if ( "$BKGFOLDSTR" == "BeamPhotons" || "$BKGFOLDSTR" == "None" ) then
echo "running MCsmear without folding in random background"
mcsmear -o$inputfile'_geant_smeared.hddm' $inputfile'_geant.hddm'
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

Expand All @@ -293,14 +307,14 @@ if ( "$GENR" != "0" ) then
echo "Could not find mix-in file "$bkglocstring
exit
else
echo "mcsmear -o$inputfile"\_"geant"\_"smeared.hddm $inputfile"\_"geant.hddm $bkglocstring"\:"1"
mcsmear -o$inputfile\_geant\_smeared.hddm $inputfile\_geant.hddm $bkglocstring\:1
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'$inputfile'_geant_smeared.hddm'' '$inputfile'_geant.hddm'' '$BKGFOLDSTR
mcsmear -o$inputfile'_geant_smeared.hddm' $inputfile'_geant.hddm' $BKGFOLDSTR
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
Expand All @@ -314,17 +328,17 @@ if ( "$GENR" != "0" ) then
unlink fort.15
endif

rm $GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.hddm
rm $STANDARD_NAME.hddm
endif

if ( "$RECON" != "0" ) then
echo "RUNNING RECONSTRUCTION"
hd_root $inputfile'_geant_smeared.hddm' -PPLUGINS=danarest,monitoring_hists -PNTHREADS=$NUMTHREADS
mv hd_root.root hd_root_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.root
mv dana_rest.hddm dana_rest_$GEN_NAME\_$formatted_runNumber\_$formatted_fileNumber.hddm
hd_root $STANDARD_NAME'_geant'$GEANTVER'_smeared.hddm' -PPLUGINS=danarest,monitoring_hists -PNTHREADS=$NUMTHREADS
mv hd_root.root hd_root_$STANDARD_NAME.root
mv dana_rest.hddm dana_rest_$STANDARD_NAME.hddm

if ( "$CLEANGEANT" == "1" ) then
rm *_geant.hddm
rm *_geant$GEANTVER.hddm
if ( "$PWD" != "$MCWRAPPER_CENTRAL" ) then
rm temp_Gcontrol.in
endif
Expand Down
Loading

0 comments on commit e4e8af4

Please sign in to comment.