4 from genericValidation
import GenericValidation
5 from helperFunctions
import replaceByMap, getCommandOutput2
6 from TkAlExceptions
import AllInOneError
11 Object representing a geometry comparison job.
13 def __init__( self, valName, alignment, referenceAlignment,
14 config, copyImages =
True):
16 Constructor of the GeometryComparison class.
19 - `valName`: String which identifies individual validation instances
20 - `alignment`: `Alignment` instance to validate
21 - `referenceAlignment`: `Alignment` instance which is compared
23 - `config`: `BetterConfigParser` instance which includes the
24 configuration of the validations
25 - `copyImages`: Boolean which indicates whether png- and pdf-files
26 should be copied back from the batch farm
31 "3DTranslationalScaleFactor":
"50",
32 "modulesToPlot":
"all",
33 "moduleList":
"/store/caf/user/cschomak/emptyModuleList.txt",
34 "useDefaultRange":
"false",
35 "plotOnlyGlobal":
"false",
47 "dalpha_min":
"-99999",
48 "dalpha_max":
"-99999",
51 "dgamma_min":
"-99999",
52 "dgamma_max":
"-99999",
54 mandatories = [
"levels",
"dbOutput"]
55 GenericValidation.__init__(self, valName, alignment, config,
56 "compare", addDefaults=defaults,
57 addMandatories = mandatories)
59 referenceName =
"IDEAL"
61 referenceName = self.referenceAlignment.name
63 allCompares = config.getCompares()
65 if valName
in allCompares:
66 self.__compares[valName] = allCompares[valName]
68 msg = (
"Could not find compare section '%s' in '%s'"
69 %(valName, allCompares))
71 self.copyImages = copyImages
76 repMap = GenericValidation.getRepMap( self, alignment )
77 referenceName =
"IDEAL"
78 referenceTitle =
"IDEAL"
80 referenceName = self.referenceAlignment.name
81 referenceTitle = self.referenceAlignment.title
83 assert len(self.__compares) == 1
84 common = self.__compares.keys()[0]
88 "comparedGeometry": (
".oO[alignmentName]Oo."
90 "referenceGeometry":
"IDEAL",
92 "reference": referenceName,
93 "referenceTitle": referenceTitle,
94 "alignmentTitle": self.alignmentToValidate.title,
95 "moduleListBase": os.path.basename(repMap[
"moduleList"]),
97 if not referenceName ==
"IDEAL":
98 repMap[
"referenceGeometry"] = (
".oO[reference]Oo."
100 repMap[
"name"] +=
"_vs_.oO[reference]Oo."
106 cfgFileName =
"TkAlCompareToNTuple.%s_cfg.py"%(
107 self.alignmentToValidate.name)
108 cfgs = {cfgFileName: configTemplates.intoNTuplesTemplate}
109 repMaps = {cfgFileName: repMap}
112 cfgFileName =
"TkAlCompareToNTuple.%s_cfg.py"%(
113 self.referenceAlignment.name )
114 cfgs[cfgFileName] = configTemplates.intoNTuplesTemplate
115 repMaps[cfgFileName] = referenceRepMap
117 cfgSchedule = cfgs.keys()
118 for common
in self.__compares:
120 "levels": self.__compares[common][0],
121 "dbOutput": self.__compares[common][1]
123 if self.__compares[common][1].
split()[0] ==
"true":
124 repMap[
"dbOutputService"] = configTemplates.dbOutputTemplate
126 repMap[
"dbOutputService"] =
""
127 cfgName =
replaceByMap((
"TkAlCompareCommon.oO[common]Oo.."
128 ".oO[name]Oo._cfg.py"),repMap)
129 cfgs[cfgName] = configTemplates.compareTemplate
130 repMaps[cfgName] = repMap
132 cfgSchedule.append( cfgName )
133 GenericValidation.createConfiguration(self, cfgs, path, cfgSchedule, repMaps = repMaps)
137 repMap[
"runComparisonScripts"] =
""
138 scriptName =
replaceByMap((
"TkAlGeomCompare.%s..oO[name]Oo..sh"
142 plottedDifferences = [
"dx",
"dy",
"dz",
"dr",
"rdphi",
"dalpha",
"dbeta",
"dgamma"]
143 for diff
in plottedDifferences:
144 y_ranges +=
","+repMap[
"%s_min"%diff]
145 y_ranges +=
","+repMap[
"%s_max"%diff]
147 for name
in self.__compares:
148 if '"DetUnit"' in self.__compares[name][0].
split(
","):
149 repMap[
"outputFile"] = (
".oO[name]Oo..Comparison_common"+name+
".root")
150 repMap[
"nIndex"] = (
"")
151 repMap[
"runComparisonScripts"] += \
152 (
"rfcp .oO[Alignment/OfflineValidation]Oo."
153 "/scripts/comparisonScript.C .\n"
154 "rfcp .oO[Alignment/OfflineValidation]Oo."
155 "/scripts/GeometryComparisonPlotter.h .\n"
156 "rfcp .oO[Alignment/OfflineValidation]Oo."
157 "/scripts/GeometryComparisonPlotter.cc .\n"
158 "root -b -q 'comparisonScript.C+(\""
159 ".oO[name]Oo..Comparison_common"+name+
".root\",\""
160 "./\",\".oO[modulesToPlot]Oo.\",\".oO[alignmentName]Oo.\",\".oO[reference]Oo.\",\".oO[useDefaultRange]Oo.\",\".oO[plotOnlyGlobal]Oo.\",\".oO[plotPng]Oo.\""+y_ranges+
")'\n"
161 "rfcp "+path+
"/TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C .\n"
162 "root -l -b -q TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C+\n")
164 repMap[
"runComparisonScripts"] += \
165 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
166 ".Comparison_common"+name+
"_Images\n")
167 repMap[
"runComparisonScripts"] += \
168 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
169 ".Comparison_common"+name+
"_Images/Translations\n")
170 repMap[
"runComparisonScripts"] += \
171 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
172 ".Comparison_common"+name+
"_Images/Rotations\n")
179 if repMap[
"plotPng"] ==
"true":
180 repMap[
"runComparisonScripts"] += \
181 (
"find . -maxdepth 1 -name \"*_1*\" "
182 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
183 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
184 repMap[
"runComparisonScripts"] += \
185 (
"find . -maxdepth 1 -name \"*_2*\" "
186 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
187 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
189 repMap[
"runComparisonScripts"] += \
190 (
"find . -maxdepth 1 -name \"*_3*\" "
191 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
192 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
193 repMap[
"runComparisonScripts"] += \
194 (
"find . -maxdepth 1 -name \"*_4*\" "
195 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
196 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
199 repMap[
"runComparisonScripts"] += \
200 (
"find . -maxdepth 1 -name \"*_1*\" "
201 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
202 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
204 repMap[
"runComparisonScripts"] += \
205 (
"find . -maxdepth 1 -name \"*_2*\" "
206 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
207 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
209 repMap[
"runComparisonScripts"] += \
210 (
"find . -maxdepth 1 -name "
211 "\"TkMap_SurfDeform*.pdf\" -print | xargs -I {} bash -c"
212 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
213 ".Comparison_common"+name+
"_Images/\" \n")
214 repMap[
"runComparisonScripts"] += \
215 (
"find . -maxdepth 1 -name "
216 "\"TkMap_SurfDeform*.png\" -print | xargs -I {} bash -c"
217 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
218 ".Comparison_common"+name+
"_Images/\" \n")
219 repMap[
"runComparisonScripts"] += \
220 (
"if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]]\n"
222 " rfmkdir -p .oO[workdir]Oo./.oO[name]Oo.."+name
225 " mkdir -p $CWD/TkAllInOneTool/.oO[name]Oo.."+name
228 repMap[
"runComparisonScripts"] += \
229 (
"rfcp .oO[Alignment/OfflineValidation]Oo."
230 "/scripts/makeArrowPlots.C "
232 "root -b -q 'makeArrowPlots.C(\""
233 ".oO[name]Oo..Comparison_common"+name
234 +
".root\",\".oO[name]Oo.."
235 +name+
"_ArrowPlots\")'\n")
236 repMap[
"runComparisonScripts"] += \
237 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
238 ".Comparison_common"+name+
"_Images/ArrowPlots\n")
239 repMap[
"runComparisonScripts"] += \
240 (
"find .oO[name]Oo.."+name+
"_ArrowPlots "
241 "-maxdepth 1 -name \"*.png\" -print | xargs -I {} bash "
242 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
243 ".Comparison_common"+name+
"_Images/ArrowPlots\"\n")
244 repMap[
"runComparisonScripts"] += \
246 "-maxdepth 1 -name \".oO[common]Oo._.oO[name]Oo..Visualization_rotated.gif\" -print | xargs -I {} bash "
247 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
248 ".Comparison_common"+name+
"_Images/.oO[common]Oo._.oO[name]Oo..Visualization.gif\"\n")
250 resultingFile =
replaceByMap((
"/store/caf/user/$USER/.oO[eosdir]Oo./compared%s_"
251 ".oO[name]Oo..root"%name), repMap)
252 resultingFile = os.path.expandvars( resultingFile )
253 resultingFile = os.path.abspath( resultingFile )
254 resultingFile =
"root://eoscms//eos/cms" + resultingFile
260 repMap[
"CommandLine"]=
""
261 repMap[
"CommandLine"]+= \
262 "# copy module list required for comparison script \n"
263 if repMap[
"moduleList"].startswith(
"/store"):
264 repMap[
"CommandLine"]+= \
265 "xrdcp root://eoscms//eos/cms.oO[moduleList]Oo. .\n"
266 elif repMap[
"moduleList"].startswith(
"root://"):
267 repMap[
"CommandLine"]+= \
268 "xrdcp .oO[moduleList]Oo. .\n"
270 repMap[
"CommandLine"]+= \
271 "rfcp .oO[moduleList]Oo. .\n"
283 repMap[
"CommandLine"]+= \
284 repMap[
"CommandLineTemplate"]%{
"cfgFile":cfg,
285 "postProcess":postProcess}
286 repMap[
"CommandLine"]+= (
"# overall postprocessing\n"
287 ".oO[runComparisonScripts]Oo.\n"
291 scripts = {scriptName:
replaceByMap( configTemplates.scriptTemplate, repMap )}
292 files = {
replaceByMap(
"TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C", repMap ):
replaceByMap(configTemplates.visualizationTrackerTemplate, repMap )}
294 return GenericValidation.createScript(self, scripts, path)
297 msg = (
"Parallelization not supported for geometry comparison. Please "
298 "choose another 'jobmode'.")
def replaceByMap
— Helpers —############################