4 from genericValidation
import GenericValidation
5 from helperFunctions
import replaceByMap, getCommandOutput2, cppboolstring, pythonboolstring
6 from TkAlExceptions
import AllInOneError
11 Object representing a geometry comparison job. 16 "3DTranslationalScaleFactor":
"50",
17 "modulesToPlot":
"all",
18 "moduleList":
"/store/caf/user/cschomak/emptyModuleList.txt",
19 "useDefaultRange":
"false",
20 "plotOnlyGlobal":
"false",
22 "makeProfilePlots":
"true",
33 "dalpha_min":
"-99999",
34 "dalpha_max":
"-99999",
37 "dgamma_min":
"-99999",
38 "dgamma_max":
"-99999",
40 mandatories = {
"levels",
"dbOutput"}
42 def __init__( self, valName, alignment, referenceAlignment,
43 config, copyImages =
True):
45 Constructor of the GeometryComparison class. 48 - `valName`: String which identifies individual validation instances 49 - `alignment`: `Alignment` instance to validate 50 - `referenceAlignment`: `Alignment` instance which is compared 52 - `config`: `BetterConfigParser` instance which includes the 53 configuration of the validations 54 - `copyImages`: Boolean which indicates whether png- and pdf-files 55 should be copied back from the batch farm 57 super(GeometryComparison, self).
__init__(valName, alignment, config)
59 referenceName =
"IDEAL" 61 referenceName = self.referenceAlignment.name
63 allCompares = config.getCompares()
66 if valName
in allCompares:
67 self.
__compares[valName] = allCompares[valName]
69 msg = (
"Could not find compare section '%s' in '%s'" 70 %(valName, allCompares))
74 for name
in "useDefaultRange",
"plotOnlyGlobal",
"plotPng":
81 repMap = super(GeometryComparison, self).
getRepMap( alignment )
82 referenceName =
"IDEAL" 83 referenceTitle =
"IDEAL" 85 referenceName = self.referenceAlignment.name
86 referenceTitle = self.referenceAlignment.title
89 common = self.__compares.keys()[0]
93 "comparedGeometry": (
".oO[alignmentName]Oo." 95 "referenceGeometry":
"IDEAL",
97 "reference": referenceName,
98 "referenceTitle": referenceTitle,
99 "alignmentTitle": self.alignmentToValidate.title,
100 "moduleListBase": os.path.basename(repMap[
"moduleList"]),
102 if not referenceName ==
"IDEAL":
103 repMap[
"referenceGeometry"] = (
".oO[reference]Oo." 105 repMap[
"name"] +=
"_vs_.oO[reference]Oo." 115 cfgFileName =
"TkAlCompareToNTuple.%s_cfg.py"%(
116 self.alignmentToValidate.name)
117 cfgs = {cfgFileName: configTemplates.intoNTuplesTemplate}
118 repMaps = {cfgFileName: repMap}
121 cfgFileName =
"TkAlCompareToNTuple.%s_cfg.py"%(
122 self.referenceAlignment.name )
123 cfgs[cfgFileName] = configTemplates.intoNTuplesTemplate
124 repMaps[cfgFileName] = referenceRepMap
126 cfgSchedule = cfgs.keys()
133 repMap[
"dbOutputService"] = configTemplates.dbOutputTemplate
135 repMap[
"dbOutputService"] =
"" 136 cfgName =
replaceByMap((
"TkAlCompareCommon.oO[common]Oo.." 137 ".oO[name]Oo._cfg.py"),repMap)
138 cfgs[cfgName] = configTemplates.compareTemplate
139 repMaps[cfgName] = repMap
141 cfgSchedule.append( cfgName )
142 super(GeometryComparison, self).
createConfiguration(cfgs, path, cfgSchedule, repMaps = repMaps)
146 repMap[
"runComparisonScripts"] =
"" 147 scriptName =
replaceByMap((
"TkAlGeomCompare.%s..oO[name]Oo..sh" 151 plottedDifferences = [
"dx",
"dy",
"dz",
"dr",
"rdphi",
"dalpha",
"dbeta",
"dgamma"]
152 for diff
in plottedDifferences:
153 y_ranges +=
","+repMap[
"%s_min"%diff]
154 y_ranges +=
","+repMap[
"%s_max"%diff]
158 repMap[
"outputFile"] = (
".oO[name]Oo..Comparison_common"+name+
".root")
159 repMap[
"nIndex"] = (
"")
160 repMap[
"runComparisonScripts"] += \
161 (
"rfcp .oO[Alignment/OfflineValidation]Oo." 162 "/scripts/comparisonScript.C .\n" 163 "rfcp .oO[Alignment/OfflineValidation]Oo." 164 "/scripts/GeometryComparisonPlotter.h .\n" 165 "rfcp .oO[Alignment/OfflineValidation]Oo." 166 "/scripts/GeometryComparisonPlotter.cc .\n" 167 "root -b -q 'comparisonScript.C+(\"" 168 ".oO[name]Oo..Comparison_common"+name+
".root\",\"" 169 "./\",\".oO[modulesToPlot]Oo.\",\".oO[alignmentName]Oo.\",\".oO[reference]Oo.\",.oO[useDefaultRange]Oo.,.oO[plotOnlyGlobal]Oo.,.oO[plotPng]Oo.,.oO[makeProfilePlots]Oo."+y_ranges+
")'\n" 170 "rfcp "+path+
"/TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C .\n" 171 "root -l -b -q TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C+\n")
173 repMap[
"runComparisonScripts"] += \
174 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo." 175 ".Comparison_common"+name+
"_Images\n")
176 repMap[
"runComparisonScripts"] += \
177 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo." 178 ".Comparison_common"+name+
"_Images/Translations\n")
179 repMap[
"runComparisonScripts"] += \
180 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo." 181 ".Comparison_common"+name+
"_Images/Rotations\n")
188 if repMap[
"plotPng"] ==
"true":
189 repMap[
"runComparisonScripts"] += \
190 (
"find . -maxdepth 1 -name \"*_1*\" " 191 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 192 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
193 repMap[
"runComparisonScripts"] += \
194 (
"find . -maxdepth 1 -name \"*_2*\" " 195 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 196 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
198 repMap[
"runComparisonScripts"] += \
199 (
"find . -maxdepth 1 -name \"*_3*\" " 200 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 201 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
202 repMap[
"runComparisonScripts"] += \
203 (
"find . -maxdepth 1 -name \"*_4*\" " 204 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 205 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
208 repMap[
"runComparisonScripts"] += \
209 (
"find . -maxdepth 1 -name \"*_1*\" " 210 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 211 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
213 repMap[
"runComparisonScripts"] += \
214 (
"find . -maxdepth 1 -name \"*_2*\" " 215 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 216 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
218 repMap[
"runComparisonScripts"] += \
219 (
"find . -maxdepth 1 -name " 220 "\"*.tex\" -print | xargs -I {} bash -c" 221 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 222 ".Comparison_common"+name+
"_Images/\" \n")
223 repMap[
"runComparisonScripts"] += \
224 (
"find . -maxdepth 1 -name " 225 "\"TkMap_SurfDeform*.pdf\" -print | xargs -I {} bash -c" 226 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 227 ".Comparison_common"+name+
"_Images/\" \n")
228 repMap[
"runComparisonScripts"] += \
229 (
"find . -maxdepth 1 -name " 230 "\"TkMap_SurfDeform*.png\" -print | xargs -I {} bash -c" 231 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 232 ".Comparison_common"+name+
"_Images/\" \n")
233 repMap[
"runComparisonScripts"] += \
234 (
"if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]]\n" 236 " rfmkdir -p .oO[workdir]Oo./.oO[name]Oo.."+name
239 " mkdir -p $CWD/TkAllInOneTool/.oO[name]Oo.."+name
242 repMap[
"runComparisonScripts"] += \
243 (
"rfcp .oO[Alignment/OfflineValidation]Oo." 244 "/scripts/makeArrowPlots.C " 246 "root -b -q 'makeArrowPlots.C(\"" 247 ".oO[name]Oo..Comparison_common"+name
248 +
".root\",\".oO[name]Oo.." 249 +name+
"_ArrowPlots\")'\n")
250 repMap[
"runComparisonScripts"] += \
251 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo." 252 ".Comparison_common"+name+
"_Images/ArrowPlots\n")
253 repMap[
"runComparisonScripts"] += \
254 (
"find .oO[name]Oo.."+name+
"_ArrowPlots " 255 "-maxdepth 1 -name \"*.png\" -print | xargs -I {} bash " 256 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 257 ".Comparison_common"+name+
"_Images/ArrowPlots\"\n")
258 repMap[
"runComparisonScripts"] += \
260 "-maxdepth 1 -name \".oO[common]Oo._.oO[name]Oo..Visualization_rotated.gif\" -print | xargs -I {} bash " 261 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 262 ".Comparison_common"+name+
"_Images/.oO[common]Oo._.oO[name]Oo..Visualization.gif\"\n")
264 resultingFile =
replaceByMap((
"/store/caf/user/$USER/.oO[eosdir]Oo./compared%s_" 265 ".oO[name]Oo..root"%name), repMap)
266 resultingFile = os.path.expandvars( resultingFile )
267 resultingFile = os.path.abspath( resultingFile )
268 resultingFile =
"root://eoscms//eos/cms" + resultingFile
274 repMap[
"CommandLine"]=
"" 275 repMap[
"CommandLine"]+= \
276 "# copy module list required for comparison script \n" 277 if repMap[
"moduleList"].startswith(
"/store"):
278 repMap[
"CommandLine"]+= \
279 "xrdcp root://eoscms//eos/cms.oO[moduleList]Oo. .\n" 280 elif repMap[
"moduleList"].startswith(
"root://"):
281 repMap[
"CommandLine"]+= \
282 "xrdcp .oO[moduleList]Oo. .\n" 284 repMap[
"CommandLine"]+= \
285 "rfcp .oO[moduleList]Oo. .\n" 297 repMap[
"CommandLine"]+= \
298 repMap[
"CommandLineTemplate"]%{
"cfgFile":cfg,
299 "postProcess":postProcess}
300 repMap[
"CommandLine"]+= (
"# overall postprocessing\n" 301 ".oO[runComparisonScripts]Oo.\n" 305 scripts = {scriptName:
replaceByMap( configTemplates.scriptTemplate, repMap )}
306 files = {
replaceByMap(
"TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C", repMap ):
replaceByMap(configTemplates.visualizationTrackerTemplate, repMap )}
308 return super(GeometryComparison, self).
createScript(scripts, path)
311 msg = (
"Parallelization not supported for geometry comparison. Please " 312 "choose another 'jobmode'.")
def createConfiguration(self, path)
def pythonboolstring(string, name)
def createScript(self, path)
def createCrabCfg(self, path)
def getCommandOutput2(command)
def getRepMap(self, alignment=None)
def cppboolstring(string, name)
def replaceByMap(target, the_map)
— Helpers —############################
def createFiles(self, fileContents, path, repMap=None, repMaps=None)
def __init__(self, valName, alignment, referenceAlignment, config, copyImages=True)
def getRepMap(self, alignment=None)