Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:21

0001 #!/bin/bash
0002 
0003 referencerelease="CMSSW_2_2_3"
0004 basedir="/afs/cern.ch/cms/Physics/muon/CMSSW/Performance/RecoMuon/MuonIdentification"
0005 
0006 if [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ $# -gt 6 ]; then
0007    echo "Usage: muonIdVal.sh [dqmFilename1 = dqm file in \$PWD] [dqmFilename2 = dqm file from ${referencerelease}] [make2DPlots = 1] [printPng = 1] [printHtml = 0] [printEps = 0]"
0008    echo
0009    echo "       dqmFilename1 could be the file you want to validate, it's plots are drawn first anyway"
0010    echo "       dqmFilename2 could be the file you want to use as a reference, it's plots are drawn second anyway"
0011    echo
0012    exit 1
0013 fi
0014 
0015 args=("$@")
0016 
0017 # Initialize arguments to pass to muonIdVal.C
0018 if [ "${args[0]}" == "" ]; then
0019    args[0]=""
0020 fi
0021 if [ "${args[1]}" == "" ]; then
0022    args[1]=""
0023 fi
0024 if [ "${args[2]}" == "" ]; then
0025    args[2]="1"
0026 fi
0027 if [ "${args[3]}" == "" ]; then
0028    args[3]="1"
0029 fi
0030 if [ "${args[4]}" == "" ]; then
0031    args[4]="0"
0032 fi
0033 if [ "${args[5]}" == "" ]; then
0034    args[5]="0"
0035 fi
0036 
0037 # Make sure we are in a CMSSW release because we need ROOT
0038 cmsswrelease=$(echo ${CMSSW_BASE} | awk '{print substr($0,match($0,/\/[^\/]*$/)+1,length($0))}')
0039 if [ "${cmsswrelease}" == "" ]; then
0040    echo "Error: unable to determine CMSSW release; please eval \`scramv1 ru -sh\`"
0041    exit 2
0042 fi
0043 
0044 # Make sure we can find $dqmFilename1 if specified, and the dqm file in $PWD otherwise
0045 if [ "${args[0]}" != "" ]; then
0046    if [ ! -f "${args[0]}" ]; then
0047       echo "Error: unable to find ${args[0]}"
0048       exit 3
0049    fi
0050 else
0051    filename1=$(find ${PWD} -name "DQM*.root")
0052    if [ "$filename1" == "" ]; then
0053       echo "Error: unable to find dqm file in the present working directory, i.e. ${PWD}/DQM*.root"
0054       exit 4
0055    fi
0056    args[0]="${filename1}"
0057 fi
0058 sample=$(echo ${args[0]} | sed 's/^.*Muons__MuonIdVal__\(.*\)\.root$/\1/')
0059 
0060 # Make sure we can find $dqmFilename1 if specified, and the reference release dqm file otherwise
0061 if [ "${args[1]}" != "" ]; then
0062    if [ ! -f "${args[1]}" ]; then
0063       echo "Error: unable to find ${args[1]}"
0064       exit 5
0065    fi
0066 else
0067    filename2=$(find ${basedir}/${referencerelease}/${sample} -name "DQM*.root")
0068    if [ "$filename2" == "" ]; then
0069        echo "Error: unable to find reference release dqm file, i.e. ${basedir}/${referencerelease}/${sample}/DQM*.root"
0070        exit 6
0071    fi
0072    args[1]="${filename2}"
0073 fi
0074 
0075 # Make target directory for this CMSSW release
0076 target="${basedir}/${cmsswrelease}/${sample}"
0077 mkdir -p ${target}
0078 if [ $? -ne 0 ]; then
0079    echo "Error: unable to create $target, or maybe it already exists"
0080    exit 7
0081 fi
0082 mkdir -p ${target}/TrackerMuons
0083 if [ $? -ne 0 ]; then
0084    echo "Error: unable to create $target/TrackerMuons, or maybe it already exists"
0085    exit 8
0086 fi
0087 mkdir -p ${target}/GlobalMuons
0088 if [ $? -ne 0 ]; then
0089    echo "Error: unable to create $target/GlobalMuons, or maybe it already exists"
0090    exit 9
0091 fi
0092 
0093 echo "Processing ${cmsswrelease} MuonIdVal..."
0094 echo "   File to validate: ${args[0]}"
0095 echo "   Reference file  : ${args[1]}"
0096 echo "   Target directory: $target"
0097 
0098 # Run the muonIdVal.C ROOT macro
0099 echo ".L muonIdVal.C++
0100 muonIdVal(\"${args[0]}\", \"${args[1]}\", ${args[2]}, ${args[3]}, ${args[4]}, ${args[5]})" | root -b -l
0101 if [ $? -ne 0 ]; then
0102    echo "Error: unable to run root?"
0103    exit 10
0104 fi
0105 
0106 # Move pngs and whatnots to target directory
0107 echo "Moving pngs and whatnots to ${target}..."
0108 mv tm_*.png ${target}/TrackerMuons/
0109 if [ $? -ne 0 ]; then
0110    echo "Error: failed to move tm_*.png to ${target}/TrackerMuons/"
0111    exit 11
0112 fi
0113 mv gm_*.png ${target}/GlobalMuons/
0114 if [ $? -ne 0 ]; then
0115    echo "Error: failed to move gm_*.png to ${target}/GlobalMuons/"
0116    exit 12
0117 fi
0118 # Is there anything left to move?
0119 if [ "`ls *.png`" != "" ]; then
0120    mv *.png ${target}/
0121    if [ $? -ne 0 ]; then
0122       echo "Error: failed to move *.png to ${target}/"
0123       exit 13
0124    fi
0125 fi
0126 
0127 cp ${args[0]} ${target}/
0128 if [ $? -ne 0 ]; then
0129    echo "Error: failed to copy ${args[0]} to ${target}/"
0130    exit 14
0131 fi