Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-22 22:37:08

0001 #!/bin/bash
0002 function die { echo $1: status $2 ; exit $2; }
0003 
0004 # Define the base directory where the geometry files are located
0005 GEOMETRY_DIR="${CMSSW_BASE}/src/Configuration/Geometry/python"
0006 if [ ! -e ${GEOMETRY_DIR} ] ; then
0007   GEOMETRY_DIR="${CMSSW_RELEASE_BASE}/src/Configuration/Geometry/python"
0008 fi
0009 
0010 # Check if the TAG is provided as an argument
0011 if [ -z "$1" ]; then
0012   echo "Error: No TAG provided. Usage: ./script.sh <TAG>"
0013   exit 1
0014 fi
0015 
0016 # Get the TAG from the command-line argument
0017 TAG=$1
0018 
0019 # Function to extract the available versions for 2026
0020 get_2026_versions() {
0021   local files=($(ls ${GEOMETRY_DIR}/GeometryExtended2026D*Reco*))
0022   if [ ${#files[@]} -eq 0 ]; then
0023     echo "No files found for 2026 versions."
0024     exit 1
0025   fi
0026 
0027   local versions=()
0028   for file in "${files[@]}"; do
0029     local version=$(basename "$file" | sed -n 's/.*GeometryExtended2026D\([0-9]\{1,3\}\).*/\1/p')
0030     if [[ "$version" =~ ^[0-9]{1,3}$ ]]; then
0031       versions+=("D${version}")
0032     fi
0033   done
0034 
0035   # Return the unique sorted list of versions
0036   echo "${versions[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '
0037 }
0038 
0039 # Set the number of parallel jobs (adjust based on system resources)
0040 MAX_JOBS=4
0041 
0042 # Function to run cmsRun and limit parallel jobs
0043 run_cmsrun() {
0044   local tag=$1
0045   local version=$2
0046 
0047   cmsRun $CMSSW_BASE/src/Fireworks/Geometry/python/dumpRecoGeometry_cfg.py tag=$tag version=$version &
0048 
0049   # Wait for jobs to finish if the number of background jobs reaches MAX_JOBS
0050   while [ $(jobs -r | wc -l) -ge $MAX_JOBS ]; do
0051     sleep 1
0052   done
0053 }
0054 
0055 # Check if the tag is 2026
0056 if [ "$TAG" == "2026" ]; then
0057   # Get all the versions for 2026
0058   VERSIONS=($(get_2026_versions))
0059   for VERSION in "${VERSIONS[@]}"; do
0060     echo "Running for 2026 with version $VERSION"
0061     run_cmsrun "2026" "$VERSION"  || die "Failure running dumpRecoGeometry_cfg.py tag=$TAG" $?
0062   done
0063 
0064   # Wait for all background jobs to finish
0065   wait
0066 else
0067   echo "Running for tag $TAG"
0068   cmsRun $CMSSW_BASE/src/Fireworks/Geometry/python/dumpRecoGeometry_cfg.py tag=$TAG || die "Failure running dumpRecoGeometry_cfg.py tag=$TAG" $?
0069   if [ $? -ne 0 ]; then
0070     echo "Error running cmsRun for tag=$TAG"
0071     exit 1
0072   fi
0073 fi