justIN           Dashboard       Workflows       Jobs       AWT       Sites       Storages       Docs       Login

Workflow 7077, Stage 1

Priority50
Processors1
Wall seconds80000
Image/cvmfs/singularity.opensciencegrid.org/fermilab/fnal-wn-sl7:latest
RSS bytes6815744000 (6500 MiB)
Max distance for inputs100.0
Enabled input RSEs CERN_PDUNE_EOS, DUNE_CA_SFU, DUNE_CERN_EOS, DUNE_ES_PIC, DUNE_FR_CCIN2P3_DISK, DUNE_IN_TIFR, DUNE_IT_INFN_CNAF, DUNE_UK_GLASGOW, DUNE_UK_LANCASTER_CEPH, DUNE_UK_MANCHESTER_CEPH, DUNE_US_BNL_SDCC, DUNE_US_FNAL_DISK_STAGE, FNAL_DCACHE, FNAL_DCACHE_STAGING, FNAL_DCACHE_TEST, MONTECARLO, NIKHEF, PRAGUE, QMUL, RAL-PP, RAL_ECHO, SURFSARA, T3_US_NERSC
Enabled output RSEs CERN_PDUNE_EOS, DUNE_CA_SFU, DUNE_CERN_EOS, DUNE_ES_PIC, DUNE_FR_CCIN2P3_DISK, DUNE_IN_TIFR, DUNE_IT_INFN_CNAF, DUNE_UK_GLASGOW, DUNE_UK_LANCASTER_CEPH, DUNE_UK_MANCHESTER_CEPH, DUNE_US_BNL_SDCC, DUNE_US_FNAL_DISK_STAGE, FNAL_DCACHE, FNAL_DCACHE_STAGING, FNAL_DCACHE_TEST, NIKHEF, PRAGUE, QMUL, RAL-PP, RAL_ECHO, SURFSARA, T3_US_NERSC
Enabled sites BR_CBPF, CA_SFU, CA_Victoria, CERN, CH_UNIBE-LHEP, ES_CIEMAT, ES_PIC, FR_CCIN2P3, IN_TIFR, IT_CNAF, NL_SURFsara, UK_Bristol, UK_Brunel, UK_Durham, UK_Edinburgh, UK_Lancaster, UK_Manchester, UK_Oxford, UK_QMUL, UK_RAL-PPD, UK_RAL-Tier1, UK_Sheffield, US_Caltech, US_Colorado, US_FNAL-FermiGrid, US_FNAL-T1, US_Michigan, US_MIT, US_Nebraska, US_NotreDame, US_PuertoRico, US_SU-ITS, US_Swan, US_UChicago, US_UConn-HPC, US_UCSD, US_Wisconsin
Scopeusertests
Events for this stage

Output patterns

 DestinationPatternLifetimeFor next stageRSE expression
1Rucio usertests:pdhd-LE-test-w7077s1p1prod_*_reco_*.root2592000False
2Rucio usertests:pdhd-LE-test-w7077s1p2prod_*_ana_*.root2592000False

Environment variables

NameValue
DUNESW_TAR/cvmfs/fifeuser3.opensciencegrid.org/sw/dune/ae94a800af351021f8223109dc879dd93f7b205f
JSONFILEpdhd_LE_prod.json
MCJob1
NEVENTS50
pipyaml1
UTIL_TAR/cvmfs/fifeuser2.opensciencegrid.org/sw/dune/2ef5788781cadbdb6a4b0424812439d2453f3477
YAMLFILEpdhd_radiologicals_gen.yaml

File states

Total filesFindingUnallocatedAllocatedOutputtingProcessedNot foundFailed
100010000000

Job states

TotalSubmittedStartedProcessingOutputtingFinishedNotusedAbortedStalledJobscript errorOutputting failedNone processed
15000005000100000

RSEs used

NameInputsOutputs
MONTECARLO1000

Stats of processed input files as CSV or JSON, and of uploaded output files as CSV or JSON (up to 10000 files included)

File reset events, by site

SiteAllocatedOutputting
CERN300
UK_Manchester200
UK_RAL-PPD160
US_FNAL-FermiGrid100
US_UChicago60
US_Colorado60
UK_Brunel60
UK_RAL-Tier140
US_Wisconsin20

Jobscript

#!/bin/bash
#

#These must be defined
#if [ -z $FCL_FILE ]; then
#  echo "Fatal Must provide FCL_FILE env var"
#  exit 1
#fi

if [ -z $UTIL_TAR ]; then
  echo "Fatal must provide UTIL_TAR env var"
  exit 1
fi
export PYTHONPATH=$UTIL_TAR:$PYTHONPATH

source /cvmfs/dune.opensciencegrid.org/products/dune/setup_dune.sh
setup metacat
export METACAT_SERVER_URL=https://metacat.fnal.gov:9443/dune_meta_prod/app
export METACAT_AUTH_SERVER_URL=https://metacat.fnal.gov:8143/auth/dune

if [ -z ${JUSTIN_PROCESSORS} ]; then
  JUSTIN_PROCESSORS=1
fi

echo "Justin processors: ${JUSTIN_PROCESSORS}"

export TF_NUM_THREADS=${JUSTIN_PROCESSORS}   
export OPENBLAS_NUM_THREADS=${JUSTIN_PROCESSORS} 
export JULIA_NUM_THREADS=${JUSTIN_PROCESSORS} 
export MKL_NUM_THREADS=${JUSTIN_PROCESSORS} 
export NUMEXPR_NUM_THREADS=${JUSTIN_PROCESSORS} 
export OMP_NUM_THREADS=${JUSTIN_PROCESSORS}  

echo "Justin specific env vars"
env | grep JUSTIN
now=$(date -u +"%Y%m%dT%H%M%SZ")
jobid=`echo "${JUSTIN_JOBSUB_ID:-1}" | cut -f1 -d'@' | sed -e "s/\./_/"`
stageid=${JUSTIN_STAGE_ID:-1}
a=1
 if [ -n "$DUNESW_TAR" ]; then
   stat ${DUNESW_TAR}
   if [ $? -ne 0 ]; then
     echo "Failed to stat $DUNESW_TAR. Exiting safely"
     exit 0
   fi
 
   export PRODUCTS=$DUNESW_TAR:$PRODUCTS 
   echo "Set dunesw to $DUNESW_TAR"
 fi

 if [ -n "$WIRECELL_TAR" ]; then
   stat ${WIRECELL_TAR}
   if [ $? -ne 0 ]; then
     echo "Failed to stat $WIRECELL_TAR. Exiting safely"
     exit 0
   fi
 
   export PRODUCTS=$WIRECELL_TAR:$PRODUCTS 
   echo "Set wirecell to $WIRECELL_TAR"
 fi

 #Setup recent lar software suite
 DUNESW_VERSION=${DUNESW_VERSION:-v10_06_00d01}
 setup dunesw \
    "${DUNESW_VERSION}" \
    -q "${DUNE_QUALIFIER:-e26:prof}"
 
 setup_exit=$?
 if [ $? -ne 0 ]; then
   echo "Failed to setup dunesw $DUNESW_VERSION $DUNE_QUALIFIER"
   exit $setup_exit
 fi

 echo "DUNESW loc:"
 ups active | grep dunesw

 echo "WIRECELL loc:"
 ups active | grep wirecell
 
export FHICL_FILE_PATH=${DUNESW_TAR}:${FHICL_FILE_PATH}
 
 
 echo "printing env"
 env
 echo "DUNE specific env vars"
 env | grep DUNE

# User can specify to pip install pyyaml
if [ -n "$pipyaml" ]; then
  echo "Installing yaml"
  pip install --user pyyaml
  echo "Done"
# elif [ -n "${YAML_TAR}" ]; then
#   echo "Using venv at ${YAML_TAR}"
#   source ${YAML_TAR}/yaml_venv/bin/activate
fi


 echo "Will use justin-get-file"
 DID_PFN_RSE=`$JUSTIN_PATH/justin-get-file`
 if [ "${DID_PFN_RSE}" == "" ] ; then
   echo "Could not get file"
   exit 0
 fi
 pfn=`echo ${DID_PFN_RSE} | cut -f2 -d' '`
 did=`echo ${DID_PFN_RSE} | cut -f1 -d' '`
 
 input_filename=`echo $did | cut -f2 -d':'`
 echo "input file: $input_filename"

 echo "jobsub_id: ${JUSTIN_JOBSUB_ID:-1}"
 
 #Get run/subrun from parent if using input -- else from justin job ID/process"
 echo "MCJob: $MCJob"
 if [ -z "$MCJob" ]; then
   echo "Getting run subrun from $did"
   run_subrun=`python -m beam_job_utils get_run_subrun -i $did`
   get_run_ret=$?
   if [ $get_run_ret -ne 0 ]; then
     echo "error in get_run_subrun"
   fi
 
   echo $run_subrun
   run=`echo $run_subrun | cut -f1 -d' '`
   subrun=`echo $run_subrun | cut -f2 -d' '`
 else
   run=`echo $jobid | cut -f1 -d'_'`  ##TODO -- check order here
   subrun=`echo $jobid | cut -f2 -d'_'`
 fi
 nevents=${NEVENTS:--1} #Set from env override or -1 
 NSKIP=${NSKIP:-0} 
 echo "nevents: $nevents"
 
 overrides="core.data_tier=full-reconstructed \
  core.application.version=${DUNESW_VERSION} \
  core.application.name=reco \
  core.application.family=dunesw \
  core.application=dunesw.reco \
 "

#User specifies if they'd like to use an input file or not 
if [ -n "$MCJob" ]; then
  inputflag=""
else
  inputflag="-i $pfn --parent $did"
fi

echo "input flag: $inputflag"

echo "Will execute:"
echo "python -m beam_job_utils run_job \
      --json ${UTIL_TAR}/${JSONFILE} \
      --overrides ${overrides} \
      --run $run \
      --subrun $subrun \
      --yaml ${UTIL_TAR}/${YAMLFILE} \
      --nevents $nevents \
      --event 0 \
      $inputflag"

starttime=`date +"%s"`.0

# TODO -- metadata file configurable
python -m beam_job_utils run_job \
      --json ${UTIL_TAR}/${JSONFILE} \
      --overrides ${overrides} \
      --run $run \
      --subrun $subrun \
      --yaml ${UTIL_TAR}/${YAMLFILE} \
      --nevents $nevents \
      --event 0 \
      $inputflag

endtime=`date +"%s"`.0

output_g4_files=`ls *_g4_stage2_*.root`
output_reco_files=`ls *_reco_*.root`
output_ana_files=`ls *_ana_*.root`

echo "Output files:"
echo "\tG4: ${output_g4_files}"
echo "\tReco: ${output_reco_files}"
echo "\tAna: ${output_ana_files}"

echo "Forming g4 metadata"
for FILE in ${output_g4_files[@]}
do
	echo "  G4 file: $FILE"

	#Retrieve the key in output filename that corresponds to YAML config. stage
        IFS=_ read -ra substrs <<< $(echo ${FILE} | cut -d '.' -f 1)
	key_found='false'
	KEY='g4_stage2_'
	iter=0
	declare -i nsub=${#substrs[@]}-1
	for substr in ${substrs[@]}; do
        	if [ $key_found == 'true' ]; then
                	KEY+=$substr
                	if [ $iter -lt ${nsub} ]; then
                        	KEY+='_'
                	fi      
        	fi
        	if [ $substr == 'stage2' ]; then
                	key_found='true'
        	fi      
        	let iter=$iter+1
	done    
	echo "    KEY: ${KEY}"

	#Retrieve the FHICL file that corresponds to the output file key
	FCL=$(grep ${UTIL_TAR}/${YAMLFILE} -e "${KEY}:" -A 1 | grep -e "fcl" | cut -d ':' -f 2)
        echo "    FCL: ${FCL}"

	python -m meta_maker --start_time $starttime --end_time $endtime --file_format "artroot" \
                     --app_family "dunesw" --app_name "reco" --app_version ${DUNESW_VERSION} \
                     --data_tier "detector-simulated" --get_events \
                     --campaign "pdhd-LE-test" \
                     --fcl $FCL \
                     -f "${JUSTIN_SCOPE}:${FILE}" -j "${FILE}.json"
	if [ $? -ne 0 ]; then
	  echo "  Error in g4 metadata"
	  exit 1
	fi
        echo "  Ran successfully"
        cat ${FILE}.json
done

echo "Forming reco metadata"
for FILE in ${output_reco_files[@]}
do
	echo "  reco file: $FILE"

	#Retrieve the key in output filename that corresponds to YAML config. stage
        IFS=_ read -ra substrs <<< $(echo ${FILE} | cut -d '.' -f 1)
        key_found='false'
        KEY='reco_'
        iter=0
        declare -i nsub=${#substrs[@]}-1
        for substr in ${substrs[@]}; do
                if [ $key_found == 'true' ]; then
                        KEY+=$substr
                        if [ $iter -lt ${nsub} ]; then
                                KEY+='_'
                        fi
                fi
                if [ $substr == 'reco' ]; then
                        key_found='true'
                fi
                let iter=$iter+1
        done
        echo "    KEY: ${KEY}"

        #Retrieve the FHICL file that corresponds to the output file key
        FCL=$(grep ${UTIL_TAR}/${YAMLFILE} -e "${KEY}:" -A 1 | grep -e "fcl" | cut -d ':' -f 2)
        echo "    FCL: ${FCL}"

	python -m meta_maker --start_time $starttime --end_time $endtime --file_format "artroot" \
                     --app_family "dunesw" --app_name "reco" --app_version ${DUNESW_VERSION} \
                     --data_tier "full-reconstructed" --get_events \
                     --campaign "pdhd-LE-test" \
                     --fcl $FCL \
                     -f "${JUSTIN_SCOPE}:${FILE}" -j "${FILE}.json"
	if [ $? -ne 0 ]; then
	  echo "  Error in reco metadata"
	  exit 1
	fi
        echo "  Ran successfully"
        cat ${FILE}.json
done

echo "Forming ana metadata"
for FILE in ${output_ana_files[@]}
do
	echo "  ana file: $FILE"
        #Retrieve the key in output filename that corresponds to YAML config. stage
        IFS=_ read -ra substrs <<< $(echo ${FILE} | cut -d '.' -f 1)
        key_found='false'
        KEY='ana_'
        iter=0
        declare -i nsub=${#substrs[@]}-2
        for substr in ${substrs[@]}; do
                if [ $key_found == 'true' ] && [ $substr != 'tfile' ]; then
                        KEY+=$substr
                        if [ $iter -lt ${nsub} ]; then
                                KEY+='_'
                        fi
                fi
                if [ $substr == 'ana' ]; then
                        key_found='true'
                fi
                let iter=$iter+1
        done

	echo "    KEY: ${KEY}"
        FCL=$(grep ${UTIL_TAR}/${YAMLFILE} -e "${KEY}:" -A 1 | grep -e "fcl" | cut -d ':' -f 2)
        echo "    FCL: ${FCL}"

	python -m meta_maker --start_time $starttime --end_time $endtime --file_format "tfile" \
                     --app_family "dunesw" --app_name "reco" --app_version ${DUNESW_VERSION} \
                     --data_tier "root-tuple" \
                     --campaign "pdhd-LE-test" \
                     --fcl $FCL \
                     -f "${JUSTIN_SCOPE}:${FILE}" -j "${FILE}.json"
	if [ $? -ne 0 ]; then
	  echo "  Error in ana metadata"
	  exit 1
	fi
	echo "  Ran successfully"
	cat ${FILE}.json
done



exitcode=$?
if [ $exitcode -ne 0 ]; then
  echo "Error running. Exiting with ${exitcode}"
  exit $exitcode
fi

echo "$pfn" > justin-processed-pfns.txt
justIN time: 2025-05-22 14:14:24 UTC       justIN version: 01.03.01