4 from genericValidation
import GenericValidation
5 from helperFunctions
import replaceByMap, getCommandOutput2, cppboolstring, pythonboolstring, clean_name
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":
"true",
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",
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 (
"rfcp .oO[Alignment/OfflineValidation]Oo." 235 "/macros/makeArrowPlots.C " 237 "root -b -q 'makeArrowPlots.C(\"" 238 ".oO[name]Oo..Comparison_common"+name
239 +
".root\",\".oO[name]Oo.." 240 +name+
"_ArrowPlots\")'\n")
241 repMap[
"runComparisonScripts"] += \
242 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo." 243 ".Comparison_common"+name+
"_Images/ArrowPlots\n")
244 repMap[
"runComparisonScripts"] += \
245 (
"find .oO[name]Oo.."+name+
"_ArrowPlots " 246 "-maxdepth 1 -name \"*.png\" -print | xargs -I {} bash " 247 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 248 ".Comparison_common"+name+
"_Images/ArrowPlots\"\n")
249 repMap[
"runComparisonScripts"] += \
250 (
"find .oO[name]Oo.."+name+
"_ArrowPlots " 251 "-maxdepth 1 -name \"*.pdf\" -print | xargs -I {} bash " 252 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 253 ".Comparison_common"+name+
"_Images/ArrowPlots\"\n")
254 repMap[
"runComparisonScripts"] += \
256 "-maxdepth 1 -name \".oO[common]Oo._.oO[name]Oo..Visualization_rotated.gif\" -print | xargs -I {} bash " 257 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 258 ".Comparison_common"+name+
"_Images/.oO[common]Oo._.oO[name]Oo..Visualization.gif\"\n")
260 resultingFile =
replaceByMap((
"/store/caf/user/$USER/.oO[eosdir]Oo./compared%s_" 261 ".oO[name]Oo..root"%name), repMap)
262 resultingFile = os.path.expandvars( resultingFile )
263 resultingFile = os.path.abspath( resultingFile )
264 resultingFile =
"root://eoscms//eos/cms" + resultingFile
270 repMap[
"CommandLine"]=
"" 271 repMap[
"CommandLine"]+= \
272 "# copy module list required for comparison script \n" 273 if repMap[
"moduleList"].startswith(
"/store"):
274 repMap[
"CommandLine"]+= \
275 "xrdcp root://eoscms//eos/cms.oO[moduleList]Oo. .\n" 276 elif repMap[
"moduleList"].startswith(
"root://"):
277 repMap[
"CommandLine"]+= \
278 "xrdcp .oO[moduleList]Oo. .\n" 280 repMap[
"CommandLine"]+= \
281 "rfcp .oO[moduleList]Oo. .\n" 293 repMap[
"CommandLine"]+= \
294 repMap[
"CommandLineTemplate"]%{
"cfgFile":cfg,
295 "postProcess":postProcess}
296 repMap[
"CommandLine"]+= (
"# overall postprocessing\n" 297 ".oO[runComparisonScripts]Oo.\n" 301 scripts = {scriptName:
replaceByMap( configTemplates.scriptTemplate, repMap )}
302 files = {
replaceByMap(
"TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C", repMap ):
replaceByMap(configTemplates.visualizationTrackerTemplate, repMap )}
304 return super(GeometryComparison, self).
createScript(scripts, path)
307 msg = (
"Parallelization not supported for geometry comparison. Please " 308 "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)