diff --git a/MCwrapper/MakeMC.csh b/MCwrapper/MakeMC.csh index 67775eec..8d3a94c2 100755 --- a/MCwrapper/MakeMC.csh +++ b/MCwrapper/MakeMC.csh @@ -1,8 +1,13 @@ #!/bin/csh -f # SET INPUTS +setenv BATCHRUN $1 +shift setenv ENVIRONMENT $1 shift +if ( "$BATCHRUN" != "0" ) then +source $ENVIRONMENT +endif setenv CONFIG_FILE $1 shift setenv OUTDIR $1 @@ -17,7 +22,7 @@ setenv VERSION $1 shift setenv CALIBTIME $1 set wholecontext = $VERSION -if($CALIBTIME != "notime") then +if ( $CALIBTIME != "notime" ) then set wholecontext = "variation=$VERSION calibtime=$CALIBTIME" else set wholecontext = "variation=$VERSION" @@ -42,8 +47,6 @@ setenv CLEANRECON $1 shift setenv BATCHSYS $1 shift -setenv BATCHRUN $1 -shift setenv NUMTHREADS $1 shift setenv GENERATOR $1 @@ -81,23 +84,27 @@ set radthick="50.e-6" set words = `rcnd $RUN_NUMBER radiator_type | sed 's/ / /g' ` foreach word ($words:q) - set removedum = `echo $word:q | sed 's/um/ /g'` + if ( $word != "number" ) then + + set removedum = `echo $word:q | sed 's/um/ /g'` - if( $removedum != $word:q ) then - #set radthick=$removedum.e-6 - set radthick = `echo $removedum.e-6 | tr -d '[:space:]'` + if ( $removedum != $word:q ) then + #set radthick=$removedum.e-6 + set radthick = `echo $removedum.e-6 | tr -d '[:space:]'` + endif endif end -echo polarization angle: `rcnd $RUN_NUMBER polarization_angle` # will need some doing +set polarization_angle = `rcnd $RUN_NUMBER polarization_angle | awk '{print $1}'` +echo polarization angle: $polarization_angle set elecE = 0 set elecE_text = `rcnd $RUN_NUMBER beam_energy | awk '{print $1}'` #echo "text: " $elecE_text -if ( "$eBEAM_ENERGY" != "rcdb" || "$JANA_CALIB_CONTEXT" != "variation=mc" ) then +if ( "$eBEAM_ENERGY" != "rcdb" || "$VERSION" != "mc" ) then set elecE=$eBEAM_ENERGY else if ( $elecE_text == "Run" ) then set elecE=12 @@ -110,7 +117,7 @@ endif set copeak = 0 set copeak_text = `rcnd $RUN_NUMBER coherent_peak | awk '{print $1}'` -if ( "$COHERENT_PEAK" != "rcdb" || "$JANA_CALIB_CONTEXT" != "variation=mc" ) then +if ( "$COHERENT_PEAK" != "rcdb" || "$VERSION" != "mc" ) then set copeak=$COHERENT_PEAK else if ( $copeak_text == "Run" ) then set copeak=9 @@ -124,13 +131,29 @@ endif #set copeak=`rcnd $RUN_NUMBER coherent_peak | awk '{print $1}' | sed 's/\.//g' #| awk -vFS="" -vOFS="" '{$1=$1"."}1' ` setenv COHERENT_PEAK $copeak + +if ( "$VERSION" != "mc" && "$COHERENT_PEAK" == "rcdb" ) then + echo "error in requesting rcdb for the coherent peak and not using variation=mc" + exit 1 +endif + setenv eBEAM_ENERGY $elecE +if ( "$VERSION" != "mc" && "$eBEAM_ENERGY" == "rcdb" ) then + echo "error in requesting rcdb for the electron beam energy and not using variation=mc" + exit 1 +endif + +if ( "$polarization_angle" == "-1.0" ) then + set copeak=`echo "$eBEAM_ENERGY + .5" | bc` + setenv COHERENT_PEAK $copeak +endif + # PRINT INPUTS echo "Job started: " `date` echo "sqlite path: " $SQLITEPATH echo "Producing file number: "$FILE_NUMBER -echo "Containing at most "$PER_FILE" events" +echo "Containing: " $EVT_TO_GEN"/""$PER_FILE"" events" echo "Running location:" $RUNNING_DIR echo "Output location: "$OUTDIR echo "Environment file: " $ENVIRONMENT @@ -173,8 +196,7 @@ cd $RUNNING_DIR/${RUN_NUMBER}_${FILE_NUMBER} if ( "$BATCHRUN" != "0" ) then # ENVIRONMENT echo $ENVIRONMENT - source $ENVIRONMENT - + if ( "$SQLITEPATH" != "no_sqlite" ) then cp $SQLITEPATH . setenv CCDB_CONNECTION sqlite:///$RUNNING_DIR/ccdb.sqlite @@ -409,32 +431,32 @@ if ( "$GENR" != "0" ) then set optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` #set RANDOMnum=`bash -c 'echo $RANDOM'` echo $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 + 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 -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 -m $eBEAM_ENERGY $optionals_line else if ( "$GENERATOR" == "gen_omega_3pi" ) then echo "RUNNING GEN_OMEGA_3PI" set optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` 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 $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 $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 $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 $optionals_line 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 $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 $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 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 $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 -m $eBEAM_ENERGY $optionals_line 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 $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 $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 -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 -m $eBEAM_ENERGY $optionals_line endif set RETURN_CODE=$? @@ -471,13 +493,15 @@ if ( "$GENR" != "0" ) then sed -i 's/TEMPSKIP/'0'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in endif - if ( "$BKGFOLDSTR" != "BeamPhotons" ) then + if ( "$BKGFOLDSTR" == "None" ) then echo "removing Beam Photon background from geant simulation" sed -i 's/BGRATE/cBGRATE/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in sed -i 's/BGGATE/cBGGATE/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in sed -i 's/TEMPMINE/'$GEN_MIN_ENERGY'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in - else + else if ( "$BKGFOLDSTR" == "BeamPhotons" ) then sed -i 's/TEMPMINE/0.0012/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in + else + sed -i 's/TEMPMINE/'$GEN_MIN_ENERGY'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in endif cp $PWD/control'_'$formatted_runNumber'_'$formatted_fileNumber.in $OUTDIR/configurations/geant/ diff --git a/MCwrapper/MakeMC.sh b/MCwrapper/MakeMC.sh index 85407964..12da4883 100755 --- a/MCwrapper/MakeMC.sh +++ b/MCwrapper/MakeMC.sh @@ -1,8 +1,13 @@ #!/bin/bash # SET INPUTS +export BATCHRUN=$1 +shift export ENVIRONMENT=$1 shift +if [[ "$BATCHRUN" != "0" ]]; then +source $ENVIRONMENT +fi export CONFIG_FILE=$1 shift export OUTDIR=$1 @@ -42,8 +47,6 @@ export CLEANRECON=$1 shift export BATCHSYS=$1 shift -export BATCHRUN=$1 -shift export NUMTHREADS=$1 shift export GENERATOR=$1 @@ -81,19 +84,22 @@ exponentialu=".e-6" words=`rcnd $RUN_NUMBER radiator_type | sed 's/ / /g' ` for word in $words; do - removedum=`echo $word | sed 's/um/ /g'` - if [[ $removedum != $word ]]; then - radthick=`echo "$removedum.e-6" | tr -d '[:space:]'` + if [[ "$word" != "number" ]]; then + + removedum=`echo $word | sed 's/um/ /g'` + if [[ $removedum != $word ]]; then + radthick=`echo "$removedum.e-6" | tr -d '[:space:]'` + fi fi - done -echo polarization angle: `rcnd $RUN_NUMBER polarization_angle` +polarization_angle=`rcnd $RUN_NUMBER polarization_angle | awk '{print $1}'` +echo polarization angle: $polarization_angle elecE=0 elecE_text=`rcnd $RUN_NUMBER beam_energy | awk '{print $1}'` -if [[ "$eBEAM_ENERGY" != "rcdb" || "$JANA_CALIB_CONTEXT" != "variation=mc" ]]; then +if [[ "$eBEAM_ENERGY" != "rcdb" || "$VERSION" != "mc" ]]; then elecE=$eBEAM_ENERGY elif [[ $elecE_text == "Run" ]]; then elecE=12 @@ -106,7 +112,7 @@ fi copeak=0 copeak_text=`rcnd $RUN_NUMBER coherent_peak | awk '{print $1}'` -if [[ "$COHERENT_PEAK" != "rcdb" || "$JANA_CALIB_CONTEXT" != "variation=mc" ]]; then +if [[ "$COHERENT_PEAK" != "rcdb" || "$VERSION" != "mc" ]]; then copeak=$COHERENT_PEAK elif [[ $copeak_text == "Run" ]]; then copeak=9 @@ -122,13 +128,27 @@ fi export COHERENT_PEAK=$copeak +if [[ "$VERSION" != "mc" && "$COHERENT_PEAK" == "rcdb" ]]; then + echo "error in requesting rcdb for the coherent peak while not using variation=mc" + exit 1 +fi + export eBEAM_ENERGY=$elecE +if [[ "$VERSION" != "mc" && "$eBEAM_ENERGY" == "rcdb" ]]; then + echo "error in requesting rcdb for the electron beam energy and not using variation=mc" + exit 1 +fi + +if [[ "$polarization_angle" == "-1.0" ]]; then + copeak=`echo "$eBEAM_ENERGY + .5" | bc` + export COHERENT_PEAK=$copeak +fi # PRINT INPUTS echo "Job started: " `date` echo "Producing file number: "$FILE_NUMBER -echo "Containing at most "$PER_FILE" events" +echo "Containing: " $EVT_TO_GEN"/""$PER_FILE"" events" echo "Running location:" $RUNNING_DIR echo "Output location: "$OUTDIR echo "Environment file: " $ENVIRONMENT @@ -172,7 +192,7 @@ if [[ "$BATCHRUN" != "0" ]]; then if [[ "$BATCHSYS" == "QSUB" ]]; then cd $RUNNING_DIR fi - source $ENVIRONMENT + if [[ "$SQLITEPATH" != "no_sqlite" ]]; then cp $SQLITEPATH . export CCDB_CONNECTION sqlite:///$RUNNING_DIR/ccdb.sqlite @@ -407,32 +427,32 @@ if [[ "$GENR" != "0" ]]; then optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` echo $optionals_line #RANDOMnum=`bash -c 'echo $RANDOM'` - 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 $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 $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 elif [[ "$GENERATOR" == "gen_omega_3pi" ]]; then echo "RUNNING GEN_OMEGA_3PI" optionals_line=`head -n 1 $STANDARD_NAME.conf | sed -r 's/.//'` 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 $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 $optionals_li + 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 $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 $optionals_line elif [[ "$GENERATOR" == "gen_2pi_primakoff" ]]; then echo "RUNNING GEN_2PI_PRIMAKOFF" 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 $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 $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 echo "RUNNING GEN_PI0" 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 $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 -m $eBEAM_ENERGY $optionals_line 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 $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 $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 fi #GEANT/smearing @@ -465,11 +485,13 @@ if [[ "$GENR" != "0" ]]; then sed -i 's/TEMPSKIP/'0'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in fi - if [[ "$BKGFOLDSTR" != "BeamPhotons" ]]; then + if [[ "$BKGFOLDSTR" == "None" ]]; then echo "removing Beam Photon background from geant simulation" sed -i 's/BGRATE/cBGRATE/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in sed -i 's/BGGATE/cBGGATE/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in sed -i 's/TEMPMINE/'$GEN_MIN_ENERGY'/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in + elif [[ "$BKGFOLDSTR" == "BeamPhotons" ]]; then + sed -i 's/TEMPMINE/0.0012/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in else sed -i 's/TEMPMINE/0.0012/' control'_'$formatted_runNumber'_'$formatted_fileNumber.in fi diff --git a/MCwrapper/examples/MC.config b/MCwrapper/examples/MC.config index 82a10f3c..aff2a2b8 100755 --- a/MCwrapper/examples/MC.config +++ b/MCwrapper/examples/MC.config @@ -3,6 +3,8 @@ #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 + #RUNNING_DIRECTORY=/run/in/this/directory #where the code should run. This is defaulted to ./ #SQLITEPATH=/your/sqlite/path #if you use SQLITE and it is not part of the environment file that gets sourced diff --git a/MCwrapper/gluex_MC.py b/MCwrapper/gluex_MC.py index cc094fdf..db3b98c6 100755 --- a/MCwrapper/gluex_MC.py +++ b/MCwrapper/gluex_MC.py @@ -23,6 +23,11 @@ from os import environ from optparse import OptionParser import os.path +import rcdb +import ccdb +from ccdb.cmd.console_context import ConsoleContext +import ccdb.path_utils +import mysql.connector import time import os import sys @@ -185,13 +190,13 @@ def main(argv): #!!!!!!!!!!!!!!!!!!REQUIRED COMMAND LINE ARGUMENTS!!!!!!!!!!!!!!!!!!!!!!!! CONFIG_FILE = args[0] - RUNNUM = int(args[1]) + RUNNUM = args[1] EVTS = int(args[2]) #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! print "*********************************" - print "Welcome to v1.8.0 of the MCwrapper" - print "Thomas Britton 09/4/17" + print "Welcome to v1.9 of the MCwrapper" + print "Thomas Britton 10/24/17" print "*********************************" #load all argument passed in and set default options @@ -238,6 +243,7 @@ def main(argv): #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VERSION = "mc" CALIBTIME="notime" + BASEFILENUM=0 PERFILE=10000 GENR=1 GEANT=1 @@ -264,7 +270,7 @@ def main(argv): #print "Warning! No Sets given" continue - if len(parts)>2: + if len(parts)>2 and str(parts[0]).upper() != "VARIATION": print "warning! I am going to have a really difficult time with:" print line print "I'm going to just ignore it and hope it isn't a problem...." @@ -338,6 +344,12 @@ def main(argv): QUEUENAME=batch_sys_parts[1] elif str(parts[0]).upper()=="RUNNING_DIRECTORY" : RUNNING_DIR=rm_comments[0].strip() + elif str(parts[0]).upper()=="VARIATION" : + if ( len(parts)>2 ) : + VERSION=str(parts[1]).split("calibtime")[0].split("#")[0].strip() + CALIBTIME=str(parts[2]).split("#")[0].strip() + else: + VERSION=rm_comments[0].strip() elif str(parts[0]).upper()=="SQLITEPATH" : SQLITEPATH=rm_comments[0].strip() else: @@ -357,6 +369,7 @@ def main(argv): argfound=1 VERSION=flag[1] + CALIBTIME="notime" # for part in range(2,len(flag)): # VERSION+="="+flag[part] if flag[0]=="calibtime": @@ -365,6 +378,9 @@ def main(argv): if flag[0]=="per_file": argfound=1 PERFILE=int(flag[1]) + if flag[0]=="base_file_number": + argfound=1 + BASEFILENUM=int(flag[1]) if flag[0]=="genr8": argfound=1 GENR=int(flag[1]) @@ -450,30 +466,124 @@ def main(argv): outdir+= "/" #for every needed file call the script with the right options - for FILENUM in range(1, FILES_TO_GEN + 2): - num=PERFILE - #last file gets the remainder - if FILENUM == FILES_TO_GEN +1: - num=REMAINING_GEN - #if ever asked to generate 0 events....just don't - if num == 0: - continue - - COMMAND=ENVFILE+" "+GENCONFIG+" "+str(outdir)+" "+str(RUNNUM)+" "+str(FILENUM-1)+" "+str(num)+" "+str(VERSION)+" "+str(CALIBTIME)+" "+str(GENR)+" "+str(GEANT)+" "+str(SMEAR)+" "+str(RECON)+" "+str(CLEANGENR)+" "+str(CLEANGEANT)+" "+str(CLEANSMEAR)+" "+str(CLEANRECON)+" "+str(BATCHRUN)+" "+str(BATCHRUN)+" "+str(NCORES).split(':')[-1]+" "+str(GENERATOR)+" "+str(GEANTVER)+" "+str(BGFOLD)+" "+str(CUSTOM_GCONTROL)+" "+str(eBEAM_ENERGY)+" "+str(COHERENT_PEAK)+" "+str(MIN_GEN_ENERGY)+" "+str(MAX_GEN_ENERGY)+" "+str(TAGSTR)+" "+str(CUSTOM_PLUGINS)+" "+str(PERFILE)+" "+str(RUNNING_DIR)+" "+str(SQLITEPATH) - - #print COMMAND - #either call MakeMC.csh or add a job depending on swif flag - if BATCHRUN == 0 or BATCHSYS=="NULL": - os.system(str(indir)+" "+COMMAND) - else: - if BATCHSYS.upper()=="SWIF": - swif_add_job(WORKFLOW, RUNNUM, FILENUM,str(indir),COMMAND,VERBOSE,PROJECT,TRACK,NCORES,DISK,RAM,TIMELIMIT,OS,DATA_OUTPUT_BASE_DIR) - elif BATCHSYS.upper()=="QSUB": - qsub_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR, RAM, QUEUENAME, LOG_DIR ) - elif BATCHSYS.upper()=="CONDOR": - condor_add_job(VERBOSE, WORKFLOW, RUNNUM, FILENUM, indir, COMMAND, NCORES, DATA_OUTPUT_BASE_DIR, TIMELIMIT, RUNNING_DIR ) + #need two loops 1) for when RUNNUM is a number and 2) when it contains a "-" as in 11366-11555 or RunPeriod2017-02 + # for 2) use rcdb to get a list of the runs of a runperiod and amount of data. Normalize number of events. Loop through list calling with the runnumbers from rcdb and their normalized num_events*requested events + RunType=str(RUNNUM).split("-") + + if len(RunType) != 1 : + event_sum=0. + #Make python rcdb calls to form the vector + db = rcdb.RCDBProvider("mysql://rcdb@hallddb/rcdb") + + dbhost = "hallddb.jlab.org" + dbuser = 'datmon' + dbpass = '' + dbname = 'data_monitoring' + + runlow=0 + runhigh=0 + + if RunType[0] != "RunPeriod": + runlow=RunType[0] + runhigh=RunType[1] + else: + cnx = mysql.connector.connect(user='ccdb_user', database='ccdb', host='hallddb.jlab.org') + cursor = cnx.cursor() + #ccddb = ccdb.CCDBProvider("mysql://ccdb_user@hallddb/ccdb") + + #runhigh=ccdbcon.session.query("select runMax from runRanges where name = test2") + #runlow=runRange[0] + #runhigh=runRange[1] + runrange_name="" + for npart in RunType: + if npart=="RunPeriod": + continue + else: + runrange_name=runrange_name+npart + + cursor.execute("select runMin,runMax from runRanges where name = '"+runrange_name+"'") + runRange = cursor.fetchall() + runlow=runRange[0][0] + runhigh=runRange[0][1] + print runRange + #cursor.close() + #cnx.close() + print str(runlow)+"-->"+str(runhigh) + + table = db.select_runs("@is_production and @status_approved",runlow,runhigh).get_values(['event_count'],True) + #print table + #print len(table) + for runs in table: + if len(table)<=1: + break + event_sum = event_sum + runs[1] + + #print event_sum + sum2=0. + for runs in table: #do for each job + #print runs[0] + if len(table) <= 1: + break + num_events_this_run=int(((float(runs[1])/float(event_sum))*EVTS)+.5) + sum2=sum2+int(((float(runs[1])/float(event_sum))*EVTS)+.5) + #print num_events_this_run + + if num_events_this_run == 0: + continue + + #do for each file needed + FILES_TO_GEN_this_run=num_events_this_run/PERFILE + REMAINING_GEN_this_run=num_events_this_run%PERFILE + + for FILENUM_this_run in range(1, FILES_TO_GEN_this_run + 2): + num_this_file=PERFILE + + if FILENUM_this_run == FILES_TO_GEN_this_run +1: + num_this_file=REMAINING_GEN_this_run + + if num_this_file == 0: + continue + + COMMAND=str(BATCHRUN)+" "+ENVFILE+" "+GENCONFIG+" "+str(outdir)+" "+str(runs[0])+" "+str(BASEFILENUM+FILENUM_this_run+-1)+" "+str(num_this_file)+" "+str(VERSION)+" "+str(CALIBTIME)+" "+str(GENR)+" "+str(GEANT)+" "+str(SMEAR)+" "+str(RECON)+" "+str(CLEANGENR)+" "+str(CLEANGEANT)+" "+str(CLEANSMEAR)+" "+str(CLEANRECON)+" "+str(BATCHSYS)+" "+str(NCORES).split(':')[-1]+" "+str(GENERATOR)+" "+str(GEANTVER)+" "+str(BGFOLD)+" "+str(CUSTOM_GCONTROL)+" "+str(eBEAM_ENERGY)+" "+str(COHERENT_PEAK)+" "+str(MIN_GEN_ENERGY)+" "+str(MAX_GEN_ENERGY)+" "+str(TAGSTR)+" "+str(CUSTOM_PLUGINS)+" "+str(PERFILE)+" "+str(RUNNING_DIR)+" "+str(SQLITEPATH) + if BATCHRUN == 0 or BATCHSYS=="NULL": + #print str(runs[0])+" "+str(BASEFILENUM+FILENUM_this_run+-1)+" "+str(num_this_file) + os.system(str(indir)+" "+COMMAND) + else: + if BATCHSYS.upper()=="SWIF": + swif_add_job(WORKFLOW, runs[0], BASEFILENUM+FILENUM_this_run+-1,str(indir),COMMAND,VERBOSE,PROJECT,TRACK,NCORES,DISK,RAM,TIMELIMIT,OS,DATA_OUTPUT_BASE_DIR) + elif BATCHSYS.upper()=="QSUB": + 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 ) + #print "----------------" + + else: + for FILENUM in range(1, FILES_TO_GEN + 2): + num=PERFILE + #last file gets the remainder + if FILENUM == FILES_TO_GEN +1: + num=REMAINING_GEN + #if ever asked to generate 0 events....just don't + if num == 0: + continue + + COMMAND=str(BATCHRUN)+" "+ENVFILE+" "+GENCONFIG+" "+str(outdir)+" "+str(RUNNUM)+" "+str(BASEFILENUM+FILENUM+-1)+" "+str(num)+" "+str(VERSION)+" "+str(CALIBTIME)+" "+str(GENR)+" "+str(GEANT)+" "+str(SMEAR)+" "+str(RECON)+" "+str(CLEANGENR)+" "+str(CLEANGEANT)+" "+str(CLEANSMEAR)+" "+str(CLEANRECON)+" "+str(BATCHSYS)+" "+str(NCORES).split(':')[-1]+" "+str(GENERATOR)+" "+str(GEANTVER)+" "+str(BGFOLD)+" "+str(CUSTOM_GCONTROL)+" "+str(eBEAM_ENERGY)+" "+str(COHERENT_PEAK)+" "+str(MIN_GEN_ENERGY)+" "+str(MAX_GEN_ENERGY)+" "+str(TAGSTR)+" "+str(CUSTOM_PLUGINS)+" "+str(PERFILE)+" "+str(RUNNING_DIR)+" "+str(SQLITEPATH) + + #print COMMAND + #either call MakeMC.csh or add a job depending on swif flag + if BATCHRUN == 0 or BATCHSYS=="NULL": + os.system(str(indir)+" "+COMMAND) + else: + if BATCHSYS.upper()=="SWIF": + swif_add_job(WORKFLOW, RUNNUM, BASEFILENUM+FILENUM+-1,str(indir),COMMAND,VERBOSE,PROJECT,TRACK,NCORES,DISK,RAM,TIMELIMIT,OS,DATA_OUTPUT_BASE_DIR) + elif BATCHSYS.upper()=="QSUB": + 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 ) + + if BATCHRUN == 1 and BATCHSYS.upper() == "SWIF": print "All Jobs created. Please call \"swif run "+WORKFLOW+"\" to run" elif BATCHRUN == 2 and BATCHSYS.upper()=="SWIF":