Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:12:34

0001 #!/bin/bash
0002 
0003 # This script takes a file from the argument and runs the BadAPVIndentifier
0004 # Results will be found in a result subdir from where the script is run
0005 # All results will be identified by "_runnumber" added to the filename.
0006 # The runnumber is derived from the inputfilename.
0007 
0008 RunDIR=$(pwd)
0009 
0010 # Check if the CMSSW environment has been set, otherwise try do do it
0011 if [ $(echo $SCRAMRT_SET | grep -c CMSSW) -eq 0 ]; then
0012     if [ $(echo $RunDIR | grep -c CMSSW) -gt 0 ]; then
0013         CMSSWDIR=$(echo $RunDIR | awk '{end=match($0,"src"); print substr($0,0,end+2)}')
0014         cd $CMSSWDIR
0015         eval `scramv1 runtime -sh`
0016         cd $RunDIR
0017     else
0018         echo "CMSSW could not be initialized, exiting"
0019         exit 1
0020     fi
0021 fi
0022 
0023 CMSSWDIR=$CMSSW_BASE
0024 template_dir=$CMSSWDIR/src/DQMOffline/CalibTracker/test
0025 
0026 # Getting run number from filename (ARG #1)
0027 if [ ${#1} -eq 0 ]; then
0028     echo "Please provide a filename as ARG1 for this script!"
0029     echo "Example: ./startBadAPVIdentifier.sh somefile.root"
0030     exit 1
0031 fi
0032 
0033 file=$1
0034 run=`echo $file| awk -F"R00" '{print $2}' | awk -F"_" '{print int($1)}'`
0035 echo Filename:$file, Run: $run
0036 
0037 # Create dir for log and config if not existing yet
0038 if [ ! -d log ]; then 
0039     echo "Creating log dir"
0040     mkdir log; 
0041 fi
0042 
0043 # Create dir for results if not existing yet
0044 if [ ! -d results ]; then 
0045     echo "Creating results dir"
0046     mkdir results; 
0047 fi
0048 
0049 DBFileName=dbfile_${run}.db
0050 echo $DBFileName
0051 cp $template_dir/dbfile_empty.db ./$DBFileName
0052 
0053 echo "Creating BadAPVIdentifier config from template"
0054 cat $template_dir/template_SiStripQualityBadAPVIdentifierRoot_cfg.py |sed -e "s@insertRun@$run@g" -e "s@dbfile.db@$DBFileName@" -e "s@insertInputDQMfile@$file@" > log/SiStripQualityBadAPVIdentifierRoot_${run}_cfg.py
0055 
0056 echo "Starting cmsRun BadAPVIdentifier"
0057 cmsRun log/SiStripQualityBadAPVIdentifierRoot_${run}_cfg.py > log/SiStripQualityBadAPVIdentifierRoot_${run}.log
0058 
0059 echo "Creating SiStripQualityStatistics_offline config from template"
0060 cat $template_dir/template_SiStripQualityStatistics_offline_cfg.py |sed -e "s@insertRun@$run@g" -e "s@dbfile.db@$DBFileName@" -e "s@inputTag@HotStrips@" > log/SiStripQualityStatistics_offline_${run}_BadAPVs_cfg.py
0061 
0062 echo "Starting cmsRun SiStripQualityStatistics_offline"
0063 cmsRun log/SiStripQualityStatistics_offline_${run}_BadAPVs_cfg.py > out_${run}_BadAPVs.tmp
0064 
0065 cat out_${run}_BadAPVs.tmp  | awk 'BEGIN{doprint=0}{if(match($0,"New IOV")!=0) doprint=1;if(match($0,"%MSG")!=0) {doprint=0;print "";} if(doprint==1) print $0}' > results/BadAPVs_${run}.txt
0066 
0067 # Cleaning up and moving results to propper dir
0068 mv out_${run}_* results/
0069 mv $DBFileName results/
0070 mv BadAPVOccupancy_${run}.root results/
0071 
0072 echo "Run $run finished"