1 from __future__
import absolute_import
4 from .
import configTemplates
5 from .genericValidation
import GenericValidation
6 from .helperFunctions
import replaceByMap, getCommandOutput2, cppboolstring, pythonboolstring, clean_name
7 from .TkAlExceptions
import AllInOneError
12 Object representing a geometry comparison job. 17 "3DTranslationalScaleFactor":
"50",
18 "modulesToPlot":
"all",
19 "moduleList":
"/store/caf/user/cschomak/emptyModuleList.txt",
20 "useDefaultRange":
"false",
21 "plotOnlyGlobal":
"true",
23 "makeProfilePlots":
"true",
34 "dalpha_min":
"-99999",
35 "dalpha_max":
"-99999",
38 "dgamma_min":
"-99999",
39 "dgamma_max":
"-99999",
41 mandatories = {
"levels",
"dbOutput"}
43 def __init__( self, valName, alignment, referenceAlignment,
44 config, copyImages =
True):
46 Constructor of the GeometryComparison class. 49 - `valName`: String which identifies individual validation instances 50 - `alignment`: `Alignment` instance to validate 51 - `referenceAlignment`: `Alignment` instance which is compared 53 - `config`: `BetterConfigParser` instance which includes the 54 configuration of the validations 55 - `copyImages`: Boolean which indicates whether png- and pdf-files 56 should be copied back from the batch farm 58 super(GeometryComparison, self).
__init__(valName, alignment, config)
60 referenceName =
"IDEAL" 62 referenceName = self.referenceAlignment.name
64 allCompares = config.getCompares()
67 if valName
in allCompares:
68 self.
__compares[valName] = allCompares[valName]
70 msg = (
"Could not find compare section '%s' in '%s'" 71 %(valName, allCompares))
75 for name
in "useDefaultRange",
"plotOnlyGlobal",
"plotPng":
82 repMap = super(GeometryComparison, self).
getRepMap( alignment )
83 referenceName =
"IDEAL" 84 referenceTitle =
"IDEAL" 86 referenceName = self.referenceAlignment.name
87 referenceTitle = self.referenceAlignment.title
90 common = self.__compares.keys()[0]
94 "comparedGeometry": (
".oO[alignmentName]Oo." 96 "referenceGeometry":
"IDEAL",
99 "referenceTitle": referenceTitle,
100 "alignmentTitle": self.alignmentToValidate.title,
101 "moduleListBase": os.path.basename(repMap[
"moduleList"]),
103 if not referenceName ==
"IDEAL":
104 repMap[
"referenceGeometry"] = (
".oO[reference]Oo." 106 repMap[
"name"] +=
"_vs_.oO[reference]Oo." 116 cfgFileName =
"TkAlCompareToNTuple.%s_cfg.py"%(
117 self.alignmentToValidate.name)
118 cfgs = {cfgFileName: configTemplates.intoNTuplesTemplate}
119 repMaps = {cfgFileName: repMap}
122 cfgFileName =
"TkAlCompareToNTuple.%s_cfg.py"%(
123 self.referenceAlignment.name )
124 cfgs[cfgFileName] = configTemplates.intoNTuplesTemplate
125 repMaps[cfgFileName] = referenceRepMap
127 cfgSchedule = cfgs.keys()
134 repMap[
"dbOutputService"] = configTemplates.dbOutputTemplate
136 repMap[
"dbOutputService"] =
"" 137 cfgName =
replaceByMap((
"TkAlCompareCommon.oO[common]Oo.." 138 ".oO[name]Oo._cfg.py"),repMap)
139 cfgs[cfgName] = configTemplates.compareTemplate
140 repMaps[cfgName] = repMap
142 cfgSchedule.append( cfgName )
143 super(GeometryComparison, self).
createConfiguration(cfgs, path, cfgSchedule, repMaps = repMaps)
147 repMap[
"runComparisonScripts"] =
"" 148 scriptName =
replaceByMap((
"TkAlGeomCompare.%s..oO[name]Oo..sh" 152 plottedDifferences = [
"dx",
"dy",
"dz",
"dr",
"rdphi",
"dalpha",
"dbeta",
"dgamma"]
153 for diff
in plottedDifferences:
154 y_ranges +=
","+repMap[
"%s_min"%diff]
155 y_ranges +=
","+repMap[
"%s_max"%diff]
159 repMap[
"outputFile"] = (
".oO[name]Oo..Comparison_common"+name+
".root")
160 repMap[
"nIndex"] = (
"")
161 repMap[
"runComparisonScripts"] += \
162 (
"rfcp .oO[Alignment/OfflineValidation]Oo." 163 "/scripts/comparisonScript.C .\n" 164 "rfcp .oO[Alignment/OfflineValidation]Oo." 165 "/scripts/GeometryComparisonPlotter.h .\n" 166 "rfcp .oO[Alignment/OfflineValidation]Oo." 167 "/scripts/GeometryComparisonPlotter.cc .\n" 168 "root -b -q 'comparisonScript.C+(\"" 169 ".oO[name]Oo..Comparison_common"+name+
".root\",\"" 170 "./\",\".oO[modulesToPlot]Oo.\",\".oO[alignmentName]Oo.\",\".oO[reference]Oo.\",.oO[useDefaultRange]Oo.,.oO[plotOnlyGlobal]Oo.,.oO[plotPng]Oo.,.oO[makeProfilePlots]Oo."+y_ranges+
")'\n" 171 "rfcp "+path+
"/TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C .\n" 172 "root -l -b -q TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C+\n")
174 repMap[
"runComparisonScripts"] += \
175 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo." 176 ".Comparison_common"+name+
"_Images\n")
177 repMap[
"runComparisonScripts"] += \
178 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo." 179 ".Comparison_common"+name+
"_Images/Translations\n")
180 repMap[
"runComparisonScripts"] += \
181 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo." 182 ".Comparison_common"+name+
"_Images/Rotations\n")
189 if repMap[
"plotPng"] ==
"true":
190 repMap[
"runComparisonScripts"] += \
191 (
"find . -maxdepth 1 -name \"*_1*\" " 192 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 193 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
194 repMap[
"runComparisonScripts"] += \
195 (
"find . -maxdepth 1 -name \"*_2*\" " 196 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 197 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
199 repMap[
"runComparisonScripts"] += \
200 (
"find . -maxdepth 1 -name \"*_3*\" " 201 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 202 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
203 repMap[
"runComparisonScripts"] += \
204 (
"find . -maxdepth 1 -name \"*_4*\" " 205 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 206 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
209 repMap[
"runComparisonScripts"] += \
210 (
"find . -maxdepth 1 -name \"*_1*\" " 211 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 212 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
214 repMap[
"runComparisonScripts"] += \
215 (
"find . -maxdepth 1 -name \"*_2*\" " 216 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo." 217 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
219 repMap[
"runComparisonScripts"] += \
220 (
"find . -maxdepth 1 -name " 221 "\"*.tex\" -print | xargs -I {} bash -c" 222 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 223 ".Comparison_common"+name+
"_Images/\" \n")
224 repMap[
"runComparisonScripts"] += \
225 (
"find . -maxdepth 1 -name " 226 "\"TkMap_SurfDeform*.pdf\" -print | xargs -I {} bash -c" 227 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 228 ".Comparison_common"+name+
"_Images/\" \n")
229 repMap[
"runComparisonScripts"] += \
230 (
"find . -maxdepth 1 -name " 231 "\"TkMap_SurfDeform*.png\" -print | xargs -I {} bash -c" 232 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 233 ".Comparison_common"+name+
"_Images/\" \n")
234 repMap[
"runComparisonScripts"] += \
235 (
"rfcp .oO[Alignment/OfflineValidation]Oo." 236 "/macros/makeArrowPlots.C " 238 "root -b -q 'makeArrowPlots.C(\"" 239 ".oO[name]Oo..Comparison_common"+name
240 +
".root\",\".oO[name]Oo.." 241 +name+
"_ArrowPlots\")'\n")
242 repMap[
"runComparisonScripts"] += \
243 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo." 244 ".Comparison_common"+name+
"_Images/ArrowPlots\n")
245 repMap[
"runComparisonScripts"] += \
246 (
"find .oO[name]Oo.."+name+
"_ArrowPlots " 247 "-maxdepth 1 -name \"*.png\" -print | xargs -I {} bash " 248 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 249 ".Comparison_common"+name+
"_Images/ArrowPlots\"\n")
250 repMap[
"runComparisonScripts"] += \
251 (
"find .oO[name]Oo.."+name+
"_ArrowPlots " 252 "-maxdepth 1 -name \"*.pdf\" -print | xargs -I {} bash " 253 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 254 ".Comparison_common"+name+
"_Images/ArrowPlots\"\n")
255 repMap[
"runComparisonScripts"] += \
257 "-maxdepth 1 -name \".oO[common]Oo._.oO[name]Oo..Visualization_rotated.gif\" -print | xargs -I {} bash " 258 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo." 259 ".Comparison_common"+name+
"_Images/.oO[common]Oo._.oO[name]Oo..Visualization.gif\"\n")
261 resultingFile =
replaceByMap((
"/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./compared%s_" 262 ".oO[name]Oo..root"%name), repMap)
263 resultingFile = os.path.expandvars( resultingFile )
264 resultingFile = os.path.abspath( resultingFile )
265 resultingFile =
"root://eoscms//eos/cms" + resultingFile
271 repMap[
"CommandLine"]=
"" 272 repMap[
"CommandLine"]+= \
273 "# copy module list required for comparison script \n" 274 if repMap[
"moduleList"].startswith(
"/store"):
275 repMap[
"CommandLine"]+= \
276 "xrdcp root://eoscms//eos/cms.oO[moduleList]Oo. .\n" 277 elif repMap[
"moduleList"].startswith(
"root://"):
278 repMap[
"CommandLine"]+= \
279 "xrdcp .oO[moduleList]Oo. .\n" 281 repMap[
"CommandLine"]+= \
282 "rfcp .oO[moduleList]Oo. .\n" 294 repMap[
"CommandLine"]+= \
295 repMap[
"CommandLineTemplate"]%{
"cfgFile":cfg,
296 "postProcess":postProcess}
297 repMap[
"CommandLine"]+= (
"# overall postprocessing\n" 298 ".oO[runComparisonScripts]Oo.\n" 302 scripts = {scriptName:
replaceByMap( configTemplates.scriptTemplate, repMap )}
303 files = {
replaceByMap(
"TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C", repMap ):
replaceByMap(configTemplates.visualizationTrackerTemplate, repMap )}
305 return super(GeometryComparison, self).
createScript(scripts, path)
308 msg = (
"Parallelization not supported for geometry comparison. Please " 309 "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)