File indexing completed on 2024-11-27 03:17:29
0001
0002
0003 dumpHelpAndExit(){
0004 cat << EOF
0005
0006 examples:
0007 ./genLUT.sh dumpAll card=cardPhysics.sh
0008 ./genLUT.sh generate card=cardPhysics.sh
0009 ./genLUT.sh diff card=cardPhysics.sh conditions/newtag/newtag.xml conditions/oldtag/oldtag.xml
0010 ./genLUT.sh validate card=cardPhysics.sh
0011
0012 EOF
0013 exit 0
0014 }
0015
0016 FullPath=`pwd -P`
0017 BaseDir=${FullPath
0018 CondDir=conditions
0019 templatefile=template.py
0020
0021 inputConditions=(ElectronicsMap LutMetadata LUTCorrs QIETypes QIEData SiPMParameters TPParameters TPChannelParameters ChannelQuality Gains Pedestals EffectivePedestals PedestalWidths EffectivePedestalWidths RespCorrs L1TriggerObjects)
0022
0023
0024
0025 CheckParameter(){
0026 if [[ -z ${!1} ]]
0027 then
0028 echo "ERROR: Parameter '$1' is not provided."
0029 exit 1
0030 fi
0031 }
0032
0033 CheckFile(){
0034 if [[ ! -f $1 ]]
0035 then
0036 echo "ERROR: file $1 not found."
0037 exit 1
0038 fi
0039 }
0040
0041
0042
0043
0044
0045 cmd=$1
0046
0047 echo ">>>>>>>>>>>>>>>>> genLUT::$cmd <<<<<<<<<<<<<<<<<<<<<"
0048 for var in "$@"
0049 do
0050 if [[ $var == *=* ]]
0051 then
0052 map=(${var//=/ })
0053 echo "${map[0]}:\"${map[@]:1}\""
0054 eval "${map[0]}=\"${map[@]:1}\""
0055 fi
0056 done
0057
0058
0059
0060
0061
0062
0063
0064
0065 dump(){
0066 CheckParameter record
0067 CheckParameter Run
0068 CheckParameter GlobalTag
0069
0070 dumpCmd="cmsRun $CMSSW_RELEASE_BASE/src/CondTools/Hcal/test/runDumpHcalCond_cfg.py geometry=DB prefix="""
0071 PedSTR='Pedestal'
0072 PedWidthSTR='PedestalWidths'
0073 EffSTR='Effective'
0074
0075 if [ -z $frontier ]
0076 then
0077 frontier="frontier://FrontierProd/CMS_CONDITIONS"
0078 fi
0079
0080 if [ ! -z $tag ]
0081 then
0082 if [[ ${record} == *"$EffSTR"* ]]; then
0083 if [[ ${record} == *"$PedWidthSTR"* ]]; then
0084 if ! $dumpCmd dumplist=$record run=$Run globaltag=$GlobalTag frontierloc=$frontier frontierlist=HcalPedestalWidthsRcd:effective:$tag
0085 then
0086 exit 1
0087 fi
0088 elif [[ ${record} == *"$PedSTR"* ]]; then
0089 if ! $dumpCmd dumplist=$record run=$Run globaltag=$GlobalTag frontierloc=$frontier frontierlist=HcalPedestalsRcd:effective:$tag
0090 then
0091 exit 1
0092 fi
0093 fi
0094 else
0095 if ! $dumpCmd dumplist=$record run=$Run globaltag=$GlobalTag frontierloc=$frontier frontierlist=Hcal${record}Rcd:$tag
0096 then
0097 exit 1
0098 fi
0099 fi
0100 else
0101 if ! $dumpCmd dumplist=$record run=$Run globaltag=$GlobalTag
0102 then
0103 exit 1
0104 fi
0105 fi
0106
0107 mkdir -p $CondDir/$record
0108 mv ${record}_Run$Run.txt $CondDir/$record/.
0109 }
0110
0111 if [[ "$cmd" == "dump" ]]
0112 then
0113 dump
0114
0115 elif [[ "$cmd" == "dumpAll" ]]
0116 then
0117 CheckParameter card
0118 CheckFile $card
0119 source $card
0120 for i in ${inputConditions[@]}; do
0121 record=$i
0122 tag=${!i}
0123 dump
0124 done
0125
0126
0127 elif [[ "$cmd" == "generate" ]]
0128 then
0129 CheckParameter card
0130 CheckFile $card
0131 source $card
0132
0133 CheckFile $HOAsciiInput
0134
0135 rm -rf $CondDir/$Tag
0136
0137 echo "genLUT.sh::generate: Preparing the configuration file..."
0138
0139 sed -e "s#__LUTtag__#$Tag#g" \
0140 -e "s#__RUN__#$Run#g" \
0141 -e "s#__CONDDIR__#$BaseDir/$CondDir#g" \
0142 -e "s#__GlobalTag__#$GlobalTag#g" \
0143 -e "s#__HO_master_file__#$HOAsciiInput#g" \
0144 -e "s#__ERA__#$Era#g" \
0145 $templatefile > $Tag.py
0146
0147 echo "genLUT.sh::generate: Running..."
0148
0149 if ! cmsRun $Tag.py
0150 then
0151 echo "ERROR: LUT Generation has failed. Exiting..."
0152 exit 1
0153 fi
0154
0155 echo "genLUT.sh::generate: Wrapping up..."
0156
0157 for file in $Tag*.xml; do mv $file $file.dat; done
0158
0159 echo "-------------------"
0160 echo "-------------------"
0161 echo "Creating LUT Loader..."
0162 echo
0163 timestamp=$(date +%s)
0164 flist=$(ls $Tag*_[0-9]*.xml.dat | xargs)
0165 if ! hcalLUT create-lut-loader outputFile="$flist" tag="$Tag" storePrepend="$description"
0166 then
0167 echo "ERROR: LUT loader generation has failed. Exiting..."
0168 exit 1
0169 fi
0170 echo
0171 echo "LUT Loader created."
0172 echo "-------------------"
0173 echo "-------------------"
0174 echo
0175
0176 zip -j $Tag.zip *$Tag*.{xml,dat}
0177
0178 mkdir -p $CondDir/$Tag
0179 mkdir -p $CondDir/$Tag/Deploy
0180 mv $Tag.zip $Tag.py Gen_L1TriggerObjects_$Tag.txt $CondDir/$Tag/Deploy
0181
0182 mkdir -p $CondDir/$Tag/Debug
0183 hcalLUT merge storePrepend="$flist" outputFile=$CondDir/$Tag/${Tag}.xml
0184 sed -i 's:UTF-8:ISO-8859-1:g' $CondDir/$Tag/${Tag}.xml
0185 sed -i 's:"no" :'\''no'\'':g' $CondDir/$Tag/${Tag}.xml
0186 sed -i '/^$/d' $CondDir/$Tag/${Tag}.xml
0187 mv *$Tag*.{xml,dat} $CondDir/$Tag/Debug
0188
0189 echo "-------------------"
0190 echo "-------------------"
0191 echo "Creating Trigger Key..."
0192 echo
0193
0194 HcalInput=( "${inputConditions[@]/#/Hcal}" )
0195 declare -A tagMap
0196 eval $(conddb list $GlobalTag | grep -E "$(export IFS="|"; echo "${HcalInput[*]}")" | \
0197 awk '{if($1~/^HcalPed/ && $2=="effective") print "tagMap["$1"+"$2"]="$3; else print "tagMap["$1"]="$3}')
0198
0199 EffSTR='Effective'
0200 individualInputTags=""
0201 for i in ${inputConditions[@]}; do
0202 t=$i
0203 v=${!t}
0204 if [[ -z $v ]]; then
0205 if [[ ${i} == *"$EffSTR"* ]]; then
0206 v=${tagMap[Hcal${i:9}Rcd+effective]}
0207 l="effective"
0208 else
0209 v=${tagMap[Hcal${i}Rcd]}
0210 l=""
0211 fi
0212 else
0213 if [[ ${i} == *"$EffSTR"* ]]; then
0214 l="effective"
0215 else
0216 l=""
0217 fi
0218 fi
0219
0220 if ! [[ -z $v ]]; then
0221 individualInputTags="""$individualInputTags
0222 <Parameter type=\"string\" name=\"$t\" label=\"$l\">$v</Parameter>"""
0223 fi
0224 done
0225
0226 dd=$(date +"%Y-%m-%d %H:%M:%S")
0227 echo """<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>
0228 <CFGBrickSet>
0229 <CFGBrick>
0230 <Parameter type=\"string\" name=\"INFOTYPE\">TRIGGERKEY</Parameter>
0231 <Parameter type=\"string\" name=\"CREATIONSTAMP\">$dd</Parameter>
0232 <Parameter type=\"string\" name=\"CREATIONTAG\">$Tag</Parameter>
0233 <Parameter type=\"string\" name=\"HCAL_LUT_TAG\">$Tag</Parameter>
0234 <Parameter type=\"boolean\" name=\"applyO2O\">$applyO2O</Parameter>
0235 <Parameter type=\"string\" name=\"CMSSW\">$CMSSW_VERSION</Parameter>
0236 <Parameter type=\"string\" name=\"InputRun\">$Run</Parameter>
0237 <Parameter type=\"string\" name=\"GlobalTag\">$GlobalTag</Parameter>$individualInputTags
0238 <Data elements=\"1\">1</Data>
0239 </CFGBrick>
0240 </CFGBrickSet>""" > $CondDir/$Tag/tk_$Tag.xml
0241
0242 elif [[ "$cmd" == "validate" ]]
0243 then
0244 CheckParameter card
0245 CheckFile $card
0246 source $card
0247
0248 echo "Comparing input and re-generated L1TriggerObjects files"
0249 diff $CondDir/L1TriggerObjects/L1TriggerObjects_Run$Run.txt $CondDir/$Tag/Deploy/Gen_L1TriggerObjects_$Tag.txt
0250
0251
0252 runs=$OldRun,$Run
0253 mkdir -p $CondDir/$Tag/Figures
0254 cmsRun PlotLUT.py globaltag=$GlobalTag run=$Run \
0255 inputDir=$BaseDir/$CondDir plotsDir=$CondDir/$Tag/Figures/ \
0256 tags=$OldTag,$Tag gains=$runs respcorrs=$runs pedestals=$runs effpedestals=$runs quality=$runs
0257
0258 elif [ "$cmd" == "upload" ]
0259 then
0260 CheckParameter tag
0261 CheckParameter dropbox
0262 lutfile=$CMSSW_BASE/src/$BaseDir/$CondDir/$tag/Deploy/$tag.zip
0263 CheckFile $lutfile
0264
0265 scp $lutfile cmsusr:~/.
0266
0267 cmd="scp $tag.zip $dropbox"
0268 ssh -XY cmsusr $cmd
0269
0270 elif [ "$cmd" == "diff" ]
0271 then
0272 if [[ $
0273 then
0274 echo "Bad input."
0275 exit 1
0276 fi
0277
0278 source $card
0279
0280 lutFile1="$BaseDir/$3"
0281 lutFile2="$BaseDir/$4"
0282 CheckFile $3
0283 CheckFile $4
0284 echo $lutFile1,$lutFile2
0285
0286 if [[ -z $verbosity ]]
0287 then
0288 verbosity=0
0289 fi
0290
0291 cmsRun DiffLUT.py globaltag=$GlobalTag run=$Run lutXML1=$lutFile1 lutXML2=$lutFile2 verbosity=$verbosity
0292
0293 else
0294 dumpHelpAndExit
0295 fi