Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-23 12:03:59

0001 #!/bin/bash
0002 #
0003 
0004 # Script to prepare the tables in TkAlignmentPixelPosition.
0005 #
0006 # In the beginning you have to state
0007 # - the paths to the template config for the geometry comparison and
0008 #   the plotting macros
0009 # - which run numbers to test
0010 # - which global tags and possibly which tracker alignment tags in which DB paths
0011 
0012 #CONFIG_TEMPLATE="src/Alignment/MillePedeAlignmentAlgorithm/test/alignment_forGeomComp_cfg_TEMPLATE.py"
0013 #PLOTMILLEPEDEDIR=
0014 CONFIG_TEMPLATE="$CMSSW_BASE/src/Alignment/TrackerAlignment/test/alignment_forGeomComp_cfg_TEMPLATE.py"
0015 PLOTMILLEPEDEDIR="$CMSSW_BASE/src/Alignment/MillePedeAlignmentAlgorithm/macros/"
0016 if [ ! -f "${CONFIG_TEMPLATE}" ]
0017 then
0018     CONFIG_TEMPLATE="${CMSSW_RELEASE_BASE}/src/Alignment/TrackerAlignment/test/alignment_forGeomComp_cfg_TEMPLATE.py"
0019 fi
0020 if [ ! -d "${PLOTMILLEPEDEDIR}" ]
0021 then
0022     PLOTMILLEPEDEDIR="${CMSSW_RELEASE_BASE}/src/Alignment/MillePedeAlignmentAlgorithm/macros/"
0023 fi
0024 
0025 if [ $# -gt 0 ]
0026 then
0027     EXECUTION_DIR="${1}/"
0028 else
0029     EXECUTION_DIR="$(pwd)/"
0030 fi
0031 
0032 echo Using template $CONFIG_TEMPLATE 
0033 echo and plotting macros from $PLOTMILLEPEDEDIR
0034 echo "Running in ${EXECUTION_DIR}"
0035 echo 
0036 
0037 RUN_NUMBERS="272011 273000"
0038 
0039 # First conditions to check
0040 # (if ALIGNMENT_TAG1 and DB_PATH_TAG1 are empty takes content from GLOBALTAG1)
0041 # also symbolic Global Tags are allowed
0042 GLOBALTAG1="auto:run2_data"
0043 # GLOBALTAG1="90X_dataRun2_Express_v4"
0044 ALIGNMENT_TAG1="TrackerAlignment_2009_v1_express"
0045 DB_PATH_TAG1="frontier://FrontierProd/CMS_CONDITIONS"
0046 
0047 # Second conditions to check
0048 # also symbolic Global Tags are allowed
0049 GLOBALTAG2="auto:run2_data"
0050 # GLOBALTAG2="90X_dataRun2_Express_v4"
0051 ALIGNMENT_TAG2="SiPixelAli_PCL_v0_prompt"
0052 # ALIGNMENT_TAG2="SiPixelAli_PCL_v0_p"
0053 DB_PATH_TAG2="frontier://FrontierPrep/CMS_CONDITIONS"
0054 
0055 if [ ! -d "${EXECUTION_DIR}" ]
0056 then
0057     mkdir ${EXECUTION_DIR}
0058 fi
0059 cd ${EXECUTION_DIR}
0060 
0061 for RUN in $RUN_NUMBERS ; do
0062     echo "============================================================"
0063     echo " Run $RUN: $GLOBALTAG1 / $ALIGNMENT_TAG1 (=1) vs $GLOBALTAG2 / $ALIGNMENT_TAG2 (=2)" 
0064     echo "============================================================"
0065     CONFIG1=alignment_forGeomComp_${GLOBALTAG1}_${ALIGNMENT_TAG1}_r${RUN}_1.py
0066     TREEFILE1=treeFile_${GLOBALTAG1}_${ALIGNMENT_TAG1}_r${RUN}_1.root
0067     TREEFILE1=`echo ${TREEFILE1//"auto:"/"auto_"}`
0068     LOGFILE1=alignment_${GLOBALTAG1}_${ALIGNMENT_TAG1}r${RUN}_1
0069     LOGFILE1=`echo ${LOGFILE1//"auto:"/"auto_"}`
0070     #echo $TREEFILE1 $LOGFILE1
0071 
0072     CONFIG2=alignment_forGeomComp_${GLOBALTAG2}_${ALIGNMENT_TAG2}_r${RUN}_2.py
0073     TREEFILE2=treeFile_${GLOBALTAG2}_${ALIGNMENT_TAG2}_r${RUN}_2.root
0074     TREEFILE2=`echo ${TREEFILE2//"auto:"/"auto_"}`
0075     LOGFILE2=alignment_${GLOBALTAG2}_${ALIGNMENT_TAG2}r${RUN}_2
0076     LOGFILE2=`echo ${LOGFILE2//"auto:"/"auto_"}`
0077     #echo $TREEFILE2 $LOGFILE2
0078 
0079     if [ -e $TREEFILE1 ] ; then
0080         echo "Removing old file" $TREEFILE1
0081         rm $TREEFILE1
0082     fi
0083     sed -e "s/RUNNUMBER/${RUN}/g" $CONFIG_TEMPLATE > ${CONFIG1}_tmp 
0084     sed -e "s/TREEFILE/${TREEFILE1}/g" ${CONFIG1}_tmp > ${CONFIG1}_tmp2
0085     sed -e "s/GLOBALTAG/${GLOBALTAG1}/g" ${CONFIG1}_tmp2 > ${CONFIG1}_tmp3
0086     sed -e "s/LOGFILE/${LOGFILE1}/g" ${CONFIG1}_tmp3 > ${CONFIG1}
0087   
0088     # maybe we need to overwrite GlobalTag alignment?
0089     if [ "$ALIGNMENT_TAG1" != "" ]; then
0090         cat >> ${CONFIG1} <<EOF
0091 
0092 from CondCore.CondDB.CondDB_cfi import *
0093 CondDBReference = CondDB.clone(connect = cms.string("$DB_PATH_TAG1"))
0094 process.trackerAlignment = cms.ESSource("PoolDBESSource",
0095                                         CondDBReference,
0096                                         toGet = cms.VPSet(cms.PSet(record = cms.string("TrackerAlignmentRcd"),
0097                                                                    tag = cms.string("$ALIGNMENT_TAG1")
0098                                                                   )
0099                                                          )       
0100                                        )
0101 process.es_prefer_trackerAlignment = cms.ESPrefer("PoolDBESSource", "trackerAlignment")
0102 EOF
0103     fi
0104 
0105     rm ${CONFIG1}_tmp* 
0106     cmsRun $CONFIG1
0107     return_code=${?}
0108     if [ ${return_code} -ne 0 ]
0109     then
0110         echo "The command 'cmsRun ${CONFIG1}' failed. Please check the log file."
0111         exit ${return_code}
0112     fi
0113     rm remove_me.db
0114 
0115     if [ -e $TREEFILE2 ] ; then
0116         echo "Removing old file" $TREEFILE2
0117         rm $TREEFILE2
0118     fi
0119     sed -e "s/RUNNUMBER/${RUN}/g" $CONFIG_TEMPLATE > ${CONFIG2}_tmp 
0120     sed -e "s/TREEFILE/${TREEFILE2}/g" ${CONFIG2}_tmp > ${CONFIG2}_tmp2
0121     sed -e "s/GLOBALTAG/${GLOBALTAG2}/g" ${CONFIG2}_tmp2 > ${CONFIG2}_tmp3
0122     sed -e "s/LOGFILE/${LOGFILE2}/g" ${CONFIG2}_tmp3 > ${CONFIG2}
0123    
0124     # maybe we need to overwrite GlobalTag alignment?
0125     if [ "$ALIGNMENT_TAG2" != "" ]; then
0126         cat >> ${CONFIG2} <<EOF
0127 
0128 from CondCore.CondDB.CondDB_cfi import *
0129 CondDBReference = CondDB.clone(connect = cms.string("$DB_PATH_TAG2"))
0130 process.trackerAlignment = cms.ESSource("PoolDBESSource",
0131                                         CondDBReference,
0132                                         toGet = cms.VPSet(cms.PSet(record = cms.string("TrackerAlignmentRcd"),
0133                                                                    tag = cms.string("$ALIGNMENT_TAG2")
0134                                                                   )
0135                                                          )       
0136                                        )
0137 process.es_prefer_trackerAlignment = cms.ESPrefer("PoolDBESSource", "trackerAlignment")
0138 EOF
0139     fi
0140 
0141     rm ${CONFIG2}_tmp*
0142     cmsRun $CONFIG2
0143     return_code=${?}
0144     if [ ${return_code} -ne 0 ]
0145     then
0146         echo "The command 'cmsRun ${CONFIG2}' failed. Please check the log file."
0147         exit ${return_code}
0148     fi
0149     rm remove_me.db
0150 
0151     HEREIAM=$(pwd)
0152     PLOTDIR=${HEREIAM}/PixelBaryCentrePlottingTools
0153     if [ ! -d ${PLOTDIR} ]
0154     then
0155        mkdir ${PLOTDIR}
0156        cp -r $PLOTMILLEPEDEDIR/* ${PLOTDIR}
0157     fi
0158     cd ${PLOTDIR}
0159     root -b -q -l allMillePede.C "pixelPositionChange.C+(\"${HEREIAM}/$TREEFILE1\", \"${HEREIAM}/$TREEFILE2\")"
0160     return_code=${?}
0161     if [ ${return_code} -ne 0 ]
0162     then
0163         echo "Running 'allMillePede.C' failed."
0164         exit ${return_code}
0165     fi
0166     cd $HEREIAM
0167 done