Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-25 08:29:08

0001 #!/usr/bin/env bash
0002 
0003 ## Logging details
0004 echo Hostname: `hostname`
0005 echo Working directory: $_CONDOR_SCRATCH_DIR
0006 echo Timestamp at start of script
0007 echo $(date)
0008 echo "Calling script is $0"
0009 echo "This script is ${BASH_SOURCE[0]}"
0010 echo "Full argument list:"
0011 echo $@
0012 
0013 
0014 # Fun4All_SingleStream_Combiner.C        \(${nevents},${runnumber},\"${outdir}\",\"${histdir}\",\"${outbase}\",${neventsper},\"${dbtag}\",\"${gl1file}\",\"${ebdcfile}\",\"${inttfile}\",\"${mvtxfile}\",\"${tpotfile}\"\);
0015 # Fun4All_Prdf_Combiner.C                \(${nevents},\"${daqhost}\",\"${outbase}\",\"${outdir}\"\)
0016 # Fun4All_SingleJob0.C                   \(${nevents},${run},\"${logbase}.root\",\"${dbtag}\",\"infile.list\"\);  status_f4a=$?
0017 # Fun4All_JobA.C                         \(${nevents},\"${logbase}.root\",\"${dbtag}\",\"infile.list\"\);  status_f4a=$?
0018 # Fun4All_Year2_Fitting.C                \(${nevents},\"${infile}\",\"${outfile}\",\"${outhist}\",\"${dbtag}\"\)
0019 
0020 ### Argument order is informed by what the order variables are needed, and the signatures of the Fun4All macros
0021 ARG_COUNT=17
0022 if [ "$#" -lt $ARG_COUNT ]  ; then
0023     echo "Error: Incorrect number of arguments."
0024     echo "Expected $ARG_COUNT [+1], but received $#."
0025     echo "Usage: $0 <buildarg> <dataset> <intriplet> <dsttype> <run> <seg> <daqhost> <inputs>"
0026     echo "       <nevents> <outdir> <histdir> <outbase> <neventsper> <dbtag>"
0027     echo "       <logbase> <logdir> <condor_rsync> [dbid]"
0028     exit 1
0029 fi
0030 
0031 # Parse arguments using shift
0032 buildarg="$1"; shift
0033 dataset="$1"; shift
0034 intriplet="$1"; shift
0035 dsttype="$1"; shift
0036 run="$1"; shift
0037 seg="$1"; shift
0038 daqhost="$1"; shift
0039 inputs="$1"; shift
0040 nevents="$1"; shift
0041 outdir="$1"; shift
0042 histdir="$1"; shift
0043 outbase="$1"; shift
0044 neventsper="$1"; shift
0045 dbtag="$1"; shift
0046 logbase="$1"; shift
0047 logdir="$1"; shift
0048 condor_rsync="$1"; shift       # Corresponds to {payload}
0049 dbid=${1:--1};shift            # for prod db, -1 means no dbid (should produce an error soon)
0050 export PRODDB_DBID=$dbid
0051 
0052 # Variables for all run scripts
0053 echo "---------------------------------------------"
0054 echo "Processing job with the following parameters:"
0055 echo "---------------------------------------------"
0056 echo "Environment:"
0057 echo "Build argument (buildarg):             $buildarg"
0058 echo "---------------------------------------------"
0059 echo "Input sources:"
0060 echo "Dataset:                               $dataset"
0061 echo "intriplet (db lingo: 'tag'):           $intriplet"
0062 echo "Input type (dsttype):                  $dsttype"
0063 echo "Run number (run):                      $run"
0064 echo "Segment number (seg):                  $seg"
0065 echo "DAQ host, leaf (daqhost)               $daqhost"
0066 echo "Input mode (inputs):                   $inputs (all segments or seg0 only, or list in some cases)"
0067 echo "---------------------------------------------"
0068 echo "Macro arguments:"
0069 echo "Number of events to process (nevents): $nevents"
0070 echo "Output directory (outdir):             $outdir"
0071 echo "Histogram directory (histdir):         $histdir"
0072 echo "Output base name (outbase):            $outbase"
0073 echo "Events per output file (neventsper):   $neventsper"
0074 echo "DB Tag (dbtag):                        $dbtag"
0075 echo "---------------------------------------------"
0076 # <condor_rsync> [dbid]"nevents="$1"; shift
0077 echo "Logs:"
0078 echo "Log base name (logbase):               $logbase"
0079 echo "Log directory (logdir):                $logdir"
0080 echo "---------------------------------------------"
0081 echo "Files/directories to stage in (condor_rsync):"
0082 echo "$condor_rsync"
0083 echo "---------------------------------------------"
0084 echo "Job database id (dbid):                $dbid"
0085 echo "---------------------------------------------"
0086 
0087 ## Make sure logfiles are kept even when receiving a signal
0088 ## KK: FIXME: Untested and not used enough
0089 sighandler()
0090 {
0091 mv ${logbase}.out ${logdir#file:/}
0092 mv ${logbase}.err ${logdir#file:/}
0093 }
0094 trap sighandler SIGTERM
0095 trap sighandler SIGSTOP
0096 trap sighandler SIGINT
0097 # SIGKILL can't be trapped
0098 
0099 # stage in the payload files
0100 condor_rsync=`echo $condor_rsync|sed 's/,/ /g'` # Change from comma separation
0101 cd $_CONDOR_SCRATCH_DIR
0102 echo Copying payload data to `pwd`
0103 for f in ${condor_rsync}; do
0104     cp --verbose -r  $f .
0105 done
0106 echo "---------------------------------------------"
0107 
0108 export USER="$(id -u -n)"
0109 export LOGNAME=${USER}
0110 export HOME=/sphenix/u/${USER}
0111 
0112 OS=$( grep ^PRETTY_NAME /etc/os-release | sed 's/"//g'| cut -f2- -d'=' ) # Works better, though still mostly for RHEL
0113 if [[ $OS == "" ]]; then
0114     echo "Unable to determine OS version."
0115 else
0116     # Set up environment
0117     if [[ "$_CONDOR_JOB_IWD" =~ "/Users/eickolja" ]]; then
0118         source /Users/eickolja/sphenix/sphenixprod/mac_this_sphenixprod.sh
0119     elif [[ $OS =~ "AlmaLinux" ]]; then
0120         echo "Setting up Production software for ${OS}"
0121         source /opt/sphenix/core/bin/sphenix_setup.sh -n $buildarg
0122     else
0123         echo "Unsupported OS $OS"
0124         exit 1
0125     fi
0126 fi
0127 
0128 if [ -e odbc.ini ]; then
0129 echo export ODBCINI=./odbc.ini
0130      export ODBCINI=./odbc.ini
0131 else
0132      echo No odbc.ini file detected.  Using system odbc.ini
0133 fi
0134 
0135 shopt -s nullglob
0136 jsonfound="$(echo *.json)"
0137 shopt -u nullglob
0138 if [[ -n $jsonfound ]]; then
0139     echo "Found json file(s):"
0140     ls -la *.json
0141 else
0142     echo "No .json files found."
0143 fi
0144 if [ -e sPHENIX_newcdb_test.json ]; then
0145     echo "... setting user provided conditions database config"
0146     export NOPAYLOADCLIENT_CONF=./sPHENIX_newcdb_test.json
0147 fi
0148 echo NOPAYLOADCLIENT_CONF=${NOPAYLOADCLIENT_CONF}
0149 
0150 echo "---------------------------------------------"
0151 echo "Offline main "${OFFLINE_MAIN}
0152 echo pwd is `pwd`
0153 echo ls -lha
0154 ls -lha
0155 # printenv
0156 echo "---------------------------------------------"
0157 return 0  2>/dev/null
0158 
0159 echo "Execution of $0 complete "
0160 echo "---------------------------------------------"
0161 exit
0162 
0163 
0164 # (return 0 2>/dev/null) && ( echo "Leaving sourced script." ) || (echo Exiting) && exit 0