Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:30

0001 #!/bin/sh
0002 
0003 function write_dbconfigurationOrconXML() {
0004         [ -e ${2} ] && rm -f ${2}
0005                 echo "<?xml version=\"1.0\" ?>" > ${2}
0006                 echo "<dbconfiguration>" >> ${2}
0007                 echo "<detector name='STRIP' offline_connect='$1'>">> ${2}
0008         echo "<poolsetup mappingdir='src/CondFormats/SiStripObjects/xml' mappingfile='*.xml' library='CondFormatsSiStripObjects' />">> ${2}
0009                 echo "</detector>">> ${2}
0010                 echo "</dbconfiguration>">> ${2}
0011 
0012 }
0013 
0014 
0015 function test_db() {
0016 
0017     [ $# = 0 ] && echo -e "usage: test_db -mode<write/read> -what<gain,ped,noise,pednoise,modulehv,badstrip,threshold> -stream<blob,noblob>  <-debug>\n"
0018 
0019     mode=""
0020     [ `echo $@ | grep -c "\-write[ ]*"` = 1 ] && mode=write 
0021     [ `echo $@ | grep -c "\-read[ ]*"`  = 1 ] && mode=read 
0022 
0023     [ "$mode" != "write" ] && [ "$mode" != "read" ] && return
0024     
0025     blobflag=noblob
0026     [ `echo $@ | grep -c "\-blob[ ]*"` = 1 ] && blobflag=blob 
0027     [ `echo $@ | grep -c "\-badstrip[ ]*"`      = 1 ] && module=badstrip     
0028     [ `echo $@ | grep -c "\-threshold[ ]*"`      = 1 ] && module=threshold     
0029     [ `echo $@ | grep -c "\-modulehv[ ]*"`      = 1 ] && module=modulehv     
0030     [ `echo $@ | grep -c "\-gain[ ]*"`      = 1 ] && module=gain     
0031     [ `echo $@ | grep -c "\-ped[ ]*"`      = 1 ] && module=ped     
0032     [ `echo $@ | grep -c "\-noise[ ]*"`    = 1 ] && module=noise   
0033 
0034     debugflag="false"
0035     [ `echo $@ | grep -c "\-debug[ ]*"` = 1 ] && debugflag=debug 
0036 
0037 
0038     logfile=${mode}_${module}_${blobflag}.log
0039     dbfile=${workdir}/${module}_${blobflag}.db
0040     dbcatalog=${workdir}/${module}_${blobflag}.xml
0041 
0042     cfgfile=${workdir}/${mode}_${module}_${blobflag}.cfg
0043 
0044 
0045     eval `scramv1 runtime -sh`
0046     SealPluginRefresh
0047 
0048     
0049     if [ ${blobflag} == "blob" ] && [ "${mode}" == "write" ]; then
0050                 #cp dbfile.db ${dbfile}
0051         [ -e ${dbfile} ] && rm -f ${dbfile}
0052 
0053         #echo "cmscond_bootstrap_detector.pl --offline_connect sqlite_file:$dbfile --auth ${CORAL_AUTH_PATH}/authentication.xml STRIP "
0054         dbconfigurationOrconXML="./dbconfiguration-orcon.xml"
0055         #cmscond_bootstrap_detector.pl --offline_connect sqlite_file:$dbfile --auth ${CORAL_AUTH_PATH}/authentication.xml STRIP 
0056         write_dbconfigurationOrconXML sqlite_file:$dbfile $dbconfigurationOrconXML
0057         cmscond_bootstrap_detector -P ~/conddb -D STRIP -f ./dbconfiguration-orcon.xml -b $CMSSW_BASE
0058         [ -e ${dbconfigurationOrconXML} ] && rm -f ${dbconfigurationOrconXML}
0059         echo " " 
0060 
0061     fi
0062 
0063     cat template_Timing_${mode}.cfg | sed \
0064         -e "s@insert_workdir@${workdir}@"  \
0065         -e "s@insert_logfile@${logfile}@"  \
0066         -e "s@insert_dbfile@${dbfile}@"  \
0067         -e "s@insert_dbcatalog@${dbcatalog}@"  \
0068         -e "s@\#${blobflag}@@"  \
0069         -e "s@\#${debugflag}[ ]* @@g" \
0070         -e "s@\#${module}[ ]* @@g" \
0071         > ${cfgfile}
0072 
0073     echo -e "\ncmsRun ${cfgfile} | tee ${workdir}/out \n"
0074     cmsRun ${cfgfile} | tee ${workdir}/out
0075 
0076     export timereport=`grep "Time report complete in" ${workdir}/out | awk '{print $6}'`
0077 }
0078 
0079 function setEnvironment(){
0080     [ -n "$setEnvironment" ] && return
0081     setEnvironment=1
0082     
0083     echo -e "Creating sqlite db schema from custom mapping"
0084     
0085     export workdir=/tmp/$USER/$$
0086     export CORAL_AUTH_USER="me"
0087     export CORAL_AUTH_PASSWORD="me"
0088     
0089     if [ ! -n "$CORAL_AUTH_PATH" ];
0090         then
0091         export CORAL_AUTH_PATH=/afs/cern.ch/cms/DB/conddb
0092         echo -e "\nWARNING: CORAL_AUTH_PATH environment variable is not defined in your shell\n default value will be used CORAL_AUTH_PATH=$CORAL_AUTH_PATH"
0093     fi
0094     
0095 
0096     echo -e "workdir $workdir\n"
0097 
0098     [ -e ${workdir} ] && rm -rf ${workdir} 
0099     mkdir ${workdir}
0100 }
0101 #%%%%%%%%%%%%%%%%%%%%
0102 #   Main
0103 #%%%%%%%%%%%%%%%%%%%%
0104 
0105 setEnvironment
0106 
0107 if [ "$1" == "doLoop" ];
0108     then
0109     i=0
0110     for stream in blob noblob; 
0111       do
0112       for mode in write read;
0113         do
0114         for what in badstrip gain ped noise threshold;
0115           do
0116           echo -e "\n\n$mode $what with $stream on geometry ideal\n\n"      
0117           test_db -$mode -$what -$stream 
0118           timeis[$i]=$timereport
0119           let i++
0120         done
0121       done
0122     done
0123 
0124     echo -e "\n\nTime Report\n\n"
0125 
0126 
0127     i=0
0128     for stream in blob noblob; 
0129       do
0130       for mode in write read;
0131         do
0132         for what in modulehv badstrip gain ped noise threshold;
0133           do
0134           echo -e "$mode \t$what \twith $stream on geometry ideal      \t\t" ${timeis[$i]}     
0135           let i++
0136         done
0137       done
0138     done
0139 else 
0140     echo -e "\n[usage]:  "
0141     echo -e "\n\ttest_Timing.sh doLoop"
0142     echo -e "OR\n\tgo to bash\n\t. ./test_Timing.sh  \n\t test_db -mode<write/read> -what<modulehv, badstrip,gain,ped,noise,threshold> -stream<blob,noblob> <-debug>\n"
0143 fi