File indexing completed on 2023-03-17 10:44:55
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 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 $templatefile > $Tag.py
0145
0146 echo "genLUT.sh::generate: Running..."
0147
0148 if ! cmsRun $Tag.py
0149 then
0150 echo "ERROR: LUT Generation has failed. Exiting..."
0151 exit 1
0152 fi
0153
0154 echo "genLUT.sh::generate: Wrapping up..."
0155
0156 for file in $Tag*.xml; do mv $file $file.dat; done
0157
0158 echo "-------------------"
0159 echo "-------------------"
0160 echo "Creating LUT Loader..."
0161 echo
0162 timestamp=$(date +%s)
0163 flist=$(ls $Tag*_[0-9]*.xml.dat | xargs)
0164 if ! hcalLUT create-lut-loader outputFile="$flist" tag="$Tag" storePrepend="$description"
0165 then
0166 echo "ERROR: LUT loader generation has failed. Exiting..."
0167 exit 1
0168 fi
0169 echo
0170 echo "LUT Loader created."
0171 echo "-------------------"
0172 echo "-------------------"
0173 echo
0174
0175 zip -j $Tag.zip *$Tag*.{xml,dat}
0176
0177 mkdir -p $CondDir/$Tag
0178 mkdir -p $CondDir/$Tag/Deploy
0179 mv $Tag.zip $Tag.py Gen_L1TriggerObjects_$Tag.txt $CondDir/$Tag/Deploy
0180
0181 mkdir -p $CondDir/$Tag/Debug
0182 hcalLUT merge storePrepend="$flist" outputFile=$CondDir/$Tag/${Tag}.xml
0183 sed -i 's:UTF-8:ISO-8859-1:g' $CondDir/$Tag/${Tag}.xml
0184 sed -i 's:"no" :'\''no'\'':g' $CondDir/$Tag/${Tag}.xml
0185 sed -i '/^$/d' $CondDir/$Tag/${Tag}.xml
0186 mv *$Tag*.{xml,dat} $CondDir/$Tag/Debug
0187
0188 echo "-------------------"
0189 echo "-------------------"
0190 echo "Creating Trigger Key..."
0191 echo
0192
0193 HcalInput=( "${inputConditions[@]/#/Hcal}" )
0194 declare -A tagMap
0195 eval $(conddb list $GlobalTag | grep -E "$(export IFS="|"; echo "${HcalInput[*]}")" | \
0196 awk '{if($1~/^HcalPed/ && $2=="effective") print "tagMap["$1"+"$2"]="$3; else print "tagMap["$1"]="$3}')
0197
0198 EffSTR='Effective'
0199 individualInputTags=""
0200 for i in ${inputConditions[@]}; do
0201 t=$i
0202 v=${!t}
0203 if [[ -z $v ]]; then
0204 if [[ ${i} == *"$EffSTR"* ]]; then
0205 v=${tagMap[Hcal${i:9}Rcd+effective]}
0206 l="effective"
0207 else
0208 v=${tagMap[Hcal${i}Rcd]}
0209 l=""
0210 fi
0211 else
0212 if [[ ${i} == *"$EffSTR"* ]]; then
0213 l="effective"
0214 else
0215 l=""
0216 fi
0217 fi
0218
0219 if ! [[ -z $v ]]; then
0220 individualInputTags="""$individualInputTags
0221 <Parameter type=\"string\" name=\"$t\" label=\"$l\">$v</Parameter>"""
0222 fi
0223 done
0224
0225 dd=$(date +"%Y-%m-%d %H:%M:%S")
0226 echo """<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>
0227 <CFGBrickSet>
0228 <CFGBrick>
0229 <Parameter type=\"string\" name=\"INFOTYPE\">TRIGGERKEY</Parameter>
0230 <Parameter type=\"string\" name=\"CREATIONSTAMP\">$dd</Parameter>
0231 <Parameter type=\"string\" name=\"CREATIONTAG\">$Tag</Parameter>
0232 <Parameter type=\"string\" name=\"HCAL_LUT_TAG\">$Tag</Parameter>
0233 <Parameter type=\"boolean\" name=\"applyO2O\">$applyO2O</Parameter>
0234 <Parameter type=\"string\" name=\"CMSSW\">$CMSSW_VERSION</Parameter>
0235 <Parameter type=\"string\" name=\"InputRun\">$Run</Parameter>
0236 <Parameter type=\"string\" name=\"GlobalTag\">$GlobalTag</Parameter>$individualInputTags
0237 <Data elements=\"1\">1</Data>
0238 </CFGBrick>
0239 </CFGBrickSet>""" > $CondDir/$Tag/tk_$Tag.xml
0240
0241 elif [[ "$cmd" == "validate" ]]
0242 then
0243 CheckParameter card
0244 CheckFile $card
0245 source $card
0246
0247 echo "Comparing input and re-generated L1TriggerObjects files"
0248 diff $CondDir/L1TriggerObjects/L1TriggerObjects_Run$Run.txt $CondDir/$Tag/Deploy/Gen_L1TriggerObjects_$Tag.txt
0249
0250
0251 runs=$OldRun,$Run
0252 mkdir -p $CondDir/$Tag/Figures
0253 cmsRun PlotLUT.py globaltag=$GlobalTag run=$Run \
0254 inputDir=$BaseDir/$CondDir plotsDir=$CondDir/$Tag/Figures/ \
0255 tags=$OldTag,$Tag gains=$runs respcorrs=$runs pedestals=$runs effpedestals=$runs quality=$runs
0256
0257 elif [ "$cmd" == "upload" ]
0258 then
0259 CheckParameter tag
0260 CheckParameter dropbox
0261 lutfile=$CMSSW_BASE/src/$BaseDir/$CondDir/$tag/Deploy/$tag.zip
0262 CheckFile $lutfile
0263
0264 scp $lutfile cmsusr:~/.
0265
0266 cmd="scp $tag.zip $dropbox"
0267 ssh -XY cmsusr $cmd
0268
0269 elif [ "$cmd" == "diff" ]
0270 then
0271 if [[ $
0272 then
0273 echo "Bad input."
0274 exit 1
0275 fi
0276
0277 CheckFile $2
0278 CheckFile $3
0279 echo $BaseDir/$2,$BaseDir/$3
0280
0281 if [[ -z $verbosity ]]
0282 then
0283 verbosity=0
0284 fi
0285
0286 hcalLUT diff inputFiles=$BaseDir/$2,$BaseDir/$3 section=$verbosity
0287
0288 else
0289 dumpHelpAndExit
0290 fi
0291
0292