4 from genericValidation
import GenericValidation
5 from helperFunctions
import replaceByMap
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
84 "comparedGeometry": (
".oO[alignmentName]Oo."
86 "referenceGeometry":
"IDEAL",
88 "reference": referenceName,
89 "referenceTitle": referenceTitle,
90 "alignmentTitle": self.alignmentToValidate.title
92 if not referenceName ==
"IDEAL":
93 repMap[
"referenceGeometry"] = (
".oO[reference]Oo."
95 repMap[
"name"] +=
"_vs_.oO[reference]Oo."
101 cfgFileName =
"TkAlCompareToNTuple.%s_cfg.py"%(
102 self.alignmentToValidate.name)
103 cfgs = {cfgFileName: configTemplates.intoNTuplesTemplate}
104 repMaps = {cfgFileName: repMap}
107 cfgFileName =
"TkAlCompareToNTuple.%s_cfg.py"%(
108 self.referenceAlignment.name )
109 cfgs[cfgFileName] = configTemplates.intoNTuplesTemplate
110 repMaps[cfgFileName] = referenceRepMap
112 cfgSchedule = cfgs.keys()
113 for common
in self.__compares:
114 repMap.update({
"common": common,
115 "levels": self.__compares[common][0],
116 "dbOutput": self.__compares[common][1]
118 if self.__compares[common][1].
split()[0] ==
"true":
119 repMap[
"dbOutputService"] = configTemplates.dbOutputTemplate
121 repMap[
"dbOutputService"] =
""
122 cfgName =
replaceByMap((
"TkAlCompareCommon.oO[common]Oo.."
123 ".oO[name]Oo._cfg.py"),repMap)
124 cfgs[cfgName] = configTemplates.compareTemplate
125 repMaps[cfgName] = repMap
127 cfgSchedule.append( cfgName )
128 GenericValidation.createConfiguration(self, cfgs, path, cfgSchedule, repMaps = repMaps)
132 repMap[
"runComparisonScripts"] =
""
133 scriptName =
replaceByMap((
"TkAlGeomCompare.%s..oO[name]Oo..sh"
137 plottedDifferences = [
"dx",
"dy",
"dz",
"dr",
"rdphi",
"dalpha",
"dbeta",
"dgamma"]
138 for diff
in plottedDifferences:
139 y_ranges +=
","+repMap[
"%s_min"%diff]
140 y_ranges +=
","+repMap[
"%s_max"%diff]
142 for name
in self.__compares:
143 if '"DetUnit"' in self.__compares[name][0].
split(
","):
144 repMap[
"outputFile"] = (
".oO[name]Oo..Comparison_common"+name+
".root")
145 repMap[
"nIndex"] = (
"")
146 repMap[
"runComparisonScripts"] += \
147 (
"rfcp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation"
148 "/scripts/comparisonScript.C .\n"
149 "rfcp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation"
150 "/scripts/GeometryComparisonPlotter.h .\n"
151 "rfcp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation"
152 "/scripts/GeometryComparisonPlotter.cc .\n"
153 "root -b -q 'comparisonScript.C+(\""
154 ".oO[name]Oo..Comparison_common"+name+
".root\",\""
155 "./\",\".oO[modulesToPlot]Oo.\",\".oO[alignmentName]Oo.\",\".oO[reference]Oo.\",\".oO[useDefaultRange]Oo.\",\".oO[plotOnlyGlobal]Oo.\",\".oO[plotPng]Oo.\""+y_ranges+
")'\n"
156 "rfcp "+path+
"/TkAl3DVisualization_.oO[name]Oo..C .\n"
157 "root -l -b -q TkAl3DVisualization_.oO[name]Oo..C+\n")
159 repMap[
"runComparisonScripts"] += \
160 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
161 ".Comparison_common"+name+
"_Images\n")
162 repMap[
"runComparisonScripts"] += \
163 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
164 ".Comparison_common"+name+
"_Images/Translations\n")
165 repMap[
"runComparisonScripts"] += \
166 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
167 ".Comparison_common"+name+
"_Images/Rotations\n")
174 if repMap[
"plotPng"] ==
"true":
175 repMap[
"runComparisonScripts"] += \
176 (
"find . -maxdepth 1 -name \"*_1*\" "
177 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
178 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
179 repMap[
"runComparisonScripts"] += \
180 (
"find . -maxdepth 1 -name \"*_2*\" "
181 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
182 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
184 repMap[
"runComparisonScripts"] += \
185 (
"find . -maxdepth 1 -name \"*_3*\" "
186 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
187 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
188 repMap[
"runComparisonScripts"] += \
189 (
"find . -maxdepth 1 -name \"*_4*\" "
190 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
191 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
194 repMap[
"runComparisonScripts"] += \
195 (
"find . -maxdepth 1 -name \"*_1*\" "
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 \"*_2*\" "
201 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
202 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
204 repMap[
"runComparisonScripts"] += \
205 (
"find . -maxdepth 1 -name "
206 "\"TkMap_SurfDeform*.pdf\" -print | xargs -I {} bash -c"
207 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
208 ".Comparison_common"+name+
"_Images/\" \n")
209 repMap[
"runComparisonScripts"] += \
210 (
"find . -maxdepth 1 -name "
211 "\"TkMap_SurfDeform*.png\" -print | xargs -I {} bash -c"
212 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
213 ".Comparison_common"+name+
"_Images/\" \n")
214 repMap[
"runComparisonScripts"] += \
215 (
"if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]]\n"
217 " rfmkdir -p .oO[workdir]Oo./.oO[name]Oo.."+name
220 " mkdir -p $CWD/TkAllInOneTool/.oO[name]Oo.."+name
223 repMap[
"runComparisonScripts"] += \
224 (
"rfcp .oO[CMSSW_BASE]Oo./src/Alignment"
225 "/OfflineValidation/scripts/makeArrowPlots.C "
227 "root -b -q 'makeArrowPlots.C(\""
228 ".oO[name]Oo..Comparison_common"+name
229 +
".root\",\".oO[name]Oo.."
230 +name+
"_ArrowPlots\")'\n")
231 repMap[
"runComparisonScripts"] += \
232 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
233 ".Comparison_common"+name+
"_Images/ArrowPlots\n")
234 repMap[
"runComparisonScripts"] += \
235 (
"find .oO[name]Oo.."+name+
"_ArrowPlots "
236 "-maxdepth 1 -name \"*.png\" -print | xargs -I {} bash "
237 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
238 ".Comparison_common"+name+
"_Images/ArrowPlots\"\n")
239 repMap[
"runComparisonScripts"] += \
241 "-maxdepth 1 -name \".oO[name]Oo..Visualization_rotated.gif\" -print | xargs -I {} bash "
242 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
243 ".Comparison_common"+name+
"_Images/.oO[name]Oo..Visualization.gif\"\n")
245 resultingFile =
replaceByMap((
"/store/caf/user/$USER/.oO[eosdir]Oo./compared%s_"
246 ".oO[name]Oo..root"%name), repMap)
247 resultingFile = os.path.expandvars( resultingFile )
248 resultingFile = os.path.abspath( resultingFile )
249 resultingFile =
"root://eoscms//eos/cms" + resultingFile
250 repMap[
"runComparisonScripts"] += \
251 (
"xrdcp -f OUTPUT_comparison.root %s\n"
255 repMap[
"CommandLine"]=
""
256 repMap[
"CommandLine"]+= \
257 (
"# copy module list required for comparison script \n"
258 "rfcp .oO[moduleList]Oo. .\n")
265 repMap[
"CommandLine"]+= \
266 repMap[
"CommandLineTemplate"]%{
"cfgFile":cfg,
267 "postProcess":postProcess}
268 repMap[
"CommandLine"]+= (
"# overall postprocessing\n"
269 ".oO[runComparisonScripts]Oo.\n"
273 scripts = {scriptName:
replaceByMap( configTemplates.scriptTemplate, repMap )}
274 files = {
replaceByMap(
"TkAl3DVisualization_.oO[name]Oo..C", repMap ):
replaceByMap(configTemplates.visualizationTrackerTemplate, repMap )}
276 return GenericValidation.createScript(self, scripts, path)
279 msg = (
"Parallelization not supported for geometry comparison. Please "
280 "choose another 'jobmode'.")
def replaceByMap
— Helpers —############################