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",
42 mandatories = {
"levels",
"dbOutput"}
44 def __init__( self, valName, alignment, referenceAlignment,
45 config, copyImages =
True):
47 Constructor of the GeometryComparison class. 50 - `valName`: String which identifies individual validation instances 51 - `alignment`: `Alignment` instance to validate 52 - `referenceAlignment`: `Alignment` instance which is compared 54 - `config`: `BetterConfigParser` instance which includes the 55 configuration of the validations 56 - `copyImages`: Boolean which indicates whether png- and pdf-files 57 should be copied back from the batch farm 59 super(GeometryComparison, self).
__init__(valName, alignment, config)
61 referenceName =
"IDEAL" 63 referenceName = self.referenceAlignment.name
65 allCompares = config.getCompares()
68 if valName
in allCompares:
69 self.
__compares[valName] = allCompares[valName]
71 msg = (
"Could not find compare section '%s' in '%s'" 72 %(valName, allCompares))
76 for name
in "useDefaultRange",
"plotOnlyGlobal",
"plotPng":
83 repMap = super(GeometryComparison, self).
getRepMap( alignment )
84 referenceName =
"IDEAL" 85 referenceTitle =
"IDEAL" 87 referenceName = self.referenceAlignment.name
88 referenceTitle = self.referenceAlignment.title
91 common = self.__compares.keys()[0]
95 "comparedGeometry": (
".oO[alignmentName]Oo." 97 "referenceGeometry":
"IDEAL",
100 "referenceTitle": referenceTitle,
101 "alignmentTitle": self.alignmentToValidate.title,
102 "moduleListBase": os.path.basename(repMap[
"moduleList"]),
104 if not referenceName ==
"IDEAL":
105 repMap[
"referenceGeometry"] = (
".oO[reference]Oo." 107 repMap[
"name"] +=
"_vs_.oO[reference]Oo." 117 cfgFileName =
"TkAlCompareToNTuple.%s_cfg.py"%(
118 self.alignmentToValidate.name)
119 cfgs = {cfgFileName: configTemplates.intoNTuplesTemplate}
120 repMaps = {cfgFileName: repMap}
123 cfgFileName =
"TkAlCompareToNTuple.%s_cfg.py"%(
124 self.referenceAlignment.name )
125 cfgs[cfgFileName] = configTemplates.intoNTuplesTemplate
126 repMaps[cfgFileName] = referenceRepMap
128 cfgSchedule = cfgs.keys()
135 repMap[
"dbOutputService"] = configTemplates.dbOutputTemplate
137 repMap[
"dbOutputService"] =
"" 138 cfgName =
replaceByMap((
"TkAlCompareCommon.oO[common]Oo.." 139 ".oO[name]Oo._cfg.py"),repMap)
140 cfgs[cfgName] = configTemplates.compareTemplate
141 repMaps[cfgName] = repMap
143 cfgSchedule.append( cfgName )
144 super(GeometryComparison, self).
createConfiguration(cfgs, path, cfgSchedule, repMaps = repMaps)
148 repMap[
"runComparisonScripts"] =
"" 149 scriptName =
replaceByMap((
"TkAlGeomCompare.%s..oO[name]Oo..sh" 153 plottedDifferences = [
"dx",
"dy",
"dz",
"dr",
"rdphi",
"dalpha",
"dbeta",
"dgamma"]
154 for diff
in plottedDifferences:
155 y_ranges +=
","+repMap[
"%s_min"%diff]
156 y_ranges +=
","+repMap[
"%s_max"%diff]
160 repMap[
"outputFile"] = (
".oO[name]Oo..Comparison_common"+name+
".root")
161 repMap[
"nIndex"] = (
"")
162 repMap[
"runComparisonScripts"] += \
163 (
"cp .oO[Alignment/OfflineValidation]Oo." 164 "/scripts/comparisonScript.C .\n" 165 "cp .oO[Alignment/OfflineValidation]Oo." 166 "/scripts/GeometryComparisonPlotter.h .\n" 167 "cp .oO[Alignment/OfflineValidation]Oo." 168 "/scripts/GeometryComparisonPlotter.cc .\n" 169 "root -b -q 'comparisonScript.C+(\"" 170 ".oO[name]Oo..Comparison_common"+name+
".root\",\"" 171 "./\",\".oO[modulesToPlot]Oo.\",\".oO[alignmentName]Oo.\",\".oO[reference]Oo.\",.oO[useDefaultRange]Oo.,.oO[plotOnlyGlobal]Oo.,.oO[plotPng]Oo.,.oO[makeProfilePlots]Oo."+y_ranges+
")'\n" 172 "cp "+path+
"/TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C .\n" 173 "root -l -b -q TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C+\n")
175 repMap[
"runComparisonScripts"] += \
176 (
"mkdir -p .oO[datadir]Oo./.oO[name]Oo." 177 ".Comparison_common"+name+
"_Images/Translations\n")
178 repMap[
"runComparisonScripts"] += \
179 (
"mkdir -p .oO[datadir]Oo./.oO[name]Oo." 180 ".Comparison_common"+name+
"_Images/Rotations\n")
187 if repMap[
"plotPng"] ==
"true":
188 repMap[
"runComparisonScripts"] += \
189 (
"find . -maxdepth 1 -name \"*_1*\" " 190 "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo." 191 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
192 repMap[
"runComparisonScripts"] += \
193 (
"find . -maxdepth 1 -name \"*_2*\" " 194 "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo." 195 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
197 repMap[
"runComparisonScripts"] += \
198 (
"find . -maxdepth 1 -name \"*_3*\" " 199 "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo." 200 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
201 repMap[
"runComparisonScripts"] += \
202 (
"find . -maxdepth 1 -name \"*_4*\" " 203 "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo." 204 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
207 repMap[
"runComparisonScripts"] += \
208 (
"find . -maxdepth 1 -name \"*_1*\" " 209 "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo." 210 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
212 repMap[
"runComparisonScripts"] += \
213 (
"find . -maxdepth 1 -name \"*_2*\" " 214 "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo." 215 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
217 repMap[
"runComparisonScripts"] += \
218 (
"find . -maxdepth 1 -name " 219 "\"*.tex\" -print | xargs -I {} bash -c" 220 " \"cp {} .oO[datadir]Oo./.oO[name]Oo." 221 ".Comparison_common"+name+
"_Images/\" \n")
222 repMap[
"runComparisonScripts"] += \
223 (
"find . -maxdepth 1 -name " 224 "\"TkMap_SurfDeform*.pdf\" -print | xargs -I {} bash -c" 225 " \"cp {} .oO[datadir]Oo./.oO[name]Oo." 226 ".Comparison_common"+name+
"_Images/\" \n")
227 repMap[
"runComparisonScripts"] += \
228 (
"find . -maxdepth 1 -name " 229 "\"TkMap_SurfDeform*.png\" -print | xargs -I {} bash -c" 230 " \"cp {} .oO[datadir]Oo./.oO[name]Oo." 231 ".Comparison_common"+name+
"_Images/\" \n")
232 repMap[
"runComparisonScripts"] += \
233 (
"cp .oO[Alignment/OfflineValidation]Oo." 234 "/macros/makeArrowPlots.C " 236 "root -b -q 'makeArrowPlots.C(\"" 237 ".oO[name]Oo..Comparison_common"+name
238 +
".root\",\".oO[name]Oo.." 239 +name+
"_ArrowPlots\")'\n")
240 repMap[
"runComparisonScripts"] += \
241 (
"mkdir -p .oO[datadir]Oo./.oO[name]Oo." 242 ".Comparison_common"+name+
"_Images/ArrowPlots\n")
243 repMap[
"runComparisonScripts"] += \
244 (
"find .oO[name]Oo.."+name+
"_ArrowPlots " 245 "-maxdepth 1 -name \"*.png\" -print | xargs -I {} bash " 246 "-c \"cp {} .oO[datadir]Oo./.oO[name]Oo." 247 ".Comparison_common"+name+
"_Images/ArrowPlots\"\n")
248 repMap[
"runComparisonScripts"] += \
249 (
"find .oO[name]Oo.."+name+
"_ArrowPlots " 250 "-maxdepth 1 -name \"*.pdf\" -print | xargs -I {} bash " 251 "-c \"cp {} .oO[datadir]Oo./.oO[name]Oo." 252 ".Comparison_common"+name+
"_Images/ArrowPlots\"\n")
253 repMap[
"runComparisonScripts"] += \
255 "-maxdepth 1 -name \".oO[common]Oo._.oO[name]Oo..Visualization_rotated.gif\" -print | xargs -I {} bash " 256 "-c \"cp {} .oO[datadir]Oo./.oO[name]Oo." 257 ".Comparison_common"+name+
"_Images/.oO[common]Oo._.oO[name]Oo..Visualization.gif\"\n")
261 plottedDifferences = [
"dx",
"dy",
"dz",
"dr",
"rdphi",
"dalpha",
"dbeta",
"dgamma"]
262 for diff
in plottedDifferences:
263 range_str += diff+
'_range=['+
str(repMap[diff+
'_min'])+
','+
str(repMap[diff+
'_max'])+
'];' 264 repMap[
"runComparisonScripts"] += \
265 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo." 266 ".Comparison_common"+name+
"_Images/TkAlMapPlots\n")
267 repMap[
"runComparisonScripts"] += \
268 (
"python .oO[Alignment/OfflineValidation]Oo./python/runGCPTkAlMap.py -b " 269 "inFile=.oO[name]Oo..Comparison_common"+name+
".root " 270 "refAl=\".oO[reference]Oo.\" " 271 "compAl=\".oO[alignmentName]Oo.\" " 273 "TkVersion=\"phase0\" " 275 "defRanges=\""+range_str+
"\" " 276 "outDir=.oO[datadir]Oo./.oO[name]Oo..Comparison_common"+name+
"_Images/TkAlMapPlots\n")
281 repMap[
"runComparisonScripts"] += \
282 (
"rfcp .oO[name]Oo..Comparison_common"+name+
".root " 283 ".oO[datadir]Oo./.oO[name]Oo..Comparison_common"+name+
"_Images/TkAlMapPlots/GCP.root\n")
288 resultingFile =
replaceByMap((
"/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./compared%s_" 289 ".oO[name]Oo..root"%name), repMap)
290 resultingFile = os.path.expandvars( resultingFile )
291 resultingFile = os.path.abspath( resultingFile )
292 resultingFile =
"root://eoscms//eos/cms" + resultingFile
298 repMap[
"CommandLine"]=
"" 299 repMap[
"CommandLine"]+= \
300 "# copy module list required for comparison script \n" 301 if repMap[
"moduleList"].startswith(
"/store"):
302 repMap[
"CommandLine"]+= \
303 "xrdcp root://eoscms//eos/cms.oO[moduleList]Oo. .\n" 304 elif repMap[
"moduleList"].startswith(
"root://"):
305 repMap[
"CommandLine"]+= \
306 "xrdcp .oO[moduleList]Oo. .\n" 308 repMap[
"CommandLine"]+= \
309 "cp .oO[moduleList]Oo. .\n" 321 repMap[
"CommandLine"]+= \
322 repMap[
"CommandLineTemplate"]%{
"cfgFile":cfg,
323 "postProcess":postProcess}
324 repMap[
"CommandLine"]+= (
"# overall postprocessing\n" 325 ".oO[runComparisonScripts]Oo.\n" 329 scripts = {scriptName:
replaceByMap( configTemplates.scriptTemplate, repMap )}
330 files = {
replaceByMap(
"TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C", repMap ):
replaceByMap(configTemplates.visualizationTrackerTemplate, repMap )}
332 return super(GeometryComparison, self).
createScript(scripts, path)
335 msg = (
"Parallelization not supported for geometry comparison. Please " 336 "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)