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 root file from the command line argument and runs 
0004 # first the BadAPVIndentifier and then the HotStripIdentification.
0005 # Results will be found in a result subdir from where the script is run
0006 # All results will be identified by "_runnumber" added to the filename.
0007 # The runnumber is derived from the inputfilename.
0008 
0009 RunDIR=$(pwd)
0010 
0011 # Check if the CMSSW environment has been set, otherwise try do do it
0012 if [ $(echo $SCRAMRT_SET | grep -c CMSSW) -eq 0 ]; then
0013     if [ $(echo $RunDIR | grep -c CMSSW) -gt 0 ]; then
0014         CMSSWDIR=$(echo $RunDIR | awk '{end=match($0,"src"); print substr($0,0,end+2)}')
0015         cd $CMSSWDIR
0016         eval `scramv1 runtime -sh`
0017         cd $RunDIR
0018     else
0019         echo "CMSSW could not be initialized, exiting"
0020         exit 1
0021     fi
0022 fi
0023 
0024 CMSSWDIR=$CMSSW_BASE
0025 template_dir=$CMSSWDIR/src/DQMOffline/CalibTracker/test
0026 
0027 # Getting run number from filename (ARG #1)
0028 if [ ${#1} -eq 0 ]; then
0029     echo "Please provide a filename as ARG1 for this script!"
0030     echo "Example: ./startBadComponents.sh somefile.root"
0031     exit 1
0032 fi
0033 
0034 file=$1
0035 run=`echo $file| awk -F"R00" '{print $2}' | awk -F"_" '{print int($1)}'`
0036 echo Filename:$file, Run: $run
0037 
0038 # Create dir for log and config if not existing yet
0039 if [ ! -d log ]; then 
0040     echo "Creating log dir"
0041     mkdir log; 
0042 fi
0043 
0044 # Create dir for results if not existing yet
0045 if [ ! -d results ]; then 
0046     echo "Creating results dir"
0047     mkdir results; 
0048 fi
0049 
0050 DBFileName=dbfile_${run}.db
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 HotStripIdentification config from template"
0060 cat $template_dir/template_SiStripQualityHotStripIdentifierRoot_cfg.py |sed -e "s@insertRun@$run@"  -e "s@insertInputDQMfile@$file@"  -e "s@dbfile.db@$DBFileName@" > log/SiStripQualityHotStripIdentifierRoot_${run}_cfg.py
0061 
0062 echo "Starting cmsRun HotStripIdentification"
0063 cmsRun log/SiStripQualityHotStripIdentifierRoot_${run}_cfg.py > log/SiStripQualityHotStripIdentifierRoot_$run.log
0064 
0065 echo "Creating SiStripQualityStatistics_offline config from template"
0066 cat $template_dir/template_SiStripQualityStatistics_offline_cfg.py |sed -e "s@insertRun@$run@" -e "s@dbfile.db@$DBFileName@" -e "s@inputTag@SiStripBadChannel_v1@" > log/SiStripQualityStatistics_offline_${run}_BadAPVs_cfg.py
0067 cat $template_dir/template_SiStripQualityStatistics_offline_cfg.py |sed -e "s@insertRun@$run@" -e "s@dbfile.db@$DBFileName@" -e "s@inputTag@HotStrips@" > log/SiStripQualityStatistics_offline_${run}_HotStrips_cfg.py
0068 
0069 echo "Starting cmsRun SiStripQualityStatistics_offline"
0070 cmsRun log/SiStripQualityStatistics_offline_${run}_BadAPVs_cfg.py > out_${run}_BadAPVs.tmp
0071 cmsRun log/SiStripQualityStatistics_offline_${run}_HotStrips_cfg.py > out_${run}_HotStrips.tmp
0072 
0073 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
0074 cat out_${run}_HotStrips.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/HotStrips_${run}.txt
0075 
0076 # Cleaning up and moving results to propper dir
0077 mv out_${run}_* results/
0078 mv $DBFileName results/
0079 if [ -f BadAPVOccupancy_${run}.root ]; then
0080     mv BadAPVOccupancy_${run}.root results/
0081 fi
0082 if [ -f HotStripsOccupancy_${run}.root ]; then
0083     mv HotStripsOccupancy_${run}.root results/
0084 fi
0085 
0086 echo "Run $run finished"