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, randomWorkdirPart =
None):
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
27 - `randomWorkDirPart`: If this option is ommitted a random number is
28 generated to create unique path names for the
29 individual validation instances.
34 "3DTranslationalScaleFactor":
"50"
36 mandatories = [
"levels",
"dbOutput"]
37 GenericValidation.__init__(self, valName, alignment, config,
38 "compare", addDefaults=defaults,
39 addMandatories = mandatories)
40 if not randomWorkdirPart ==
None:
43 referenceName =
"IDEAL"
45 referenceName = self.referenceAlignment.name
47 allCompares = config.getCompares()
49 if valName
in allCompares:
50 self.__compares[valName] = allCompares[valName]
52 msg = (
"Could not find compare section '%s' in '%s'"
53 %(valName, allCompares))
55 self.copyImages = copyImages
60 repMap = GenericValidation.getRepMap( self, alignment )
61 referenceName =
"IDEAL"
62 referenceTitle =
"IDEAL"
64 referenceName = self.referenceAlignment.name
65 referenceTitle = self.referenceAlignment.title
68 "comparedGeometry": (
".oO[alignmentName]Oo."
70 "referenceGeometry":
"IDEAL",
72 "reference": referenceName,
73 "referenceTitle": referenceTitle,
74 "alignmentTitle": self.alignmentToValidate.title
76 if not referenceName ==
"IDEAL":
77 repMap[
"referenceGeometry"] = (
".oO[reference]Oo."
79 repMap[
"name"] +=
"_vs_.oO[reference]Oo."
85 cfgFileName =
"TkAlCompareToNTuple.%s.%s_cfg.py"%(
87 cfgs = {cfgFileName: configTemplates.intoNTuplesTemplate}
88 repMaps = {cfgFileName: repMap}
91 cfgFileName =
"TkAlCompareToNTuple.%s.%s_cfg.py"%(
93 cfgs[cfgFileName] = configTemplates.intoNTuplesTemplate
94 repMaps[cfgFileName] = referenceRepMap
96 cfgSchedule = cfgs.keys()
97 for common
in self.__compares:
98 repMap.update({
"common": common,
99 "levels": self.__compares[common][0],
100 "dbOutput": self.__compares[common][1]
102 if self.__compares[common][1].
split()[0] ==
"true":
103 repMap[
"dbOutputService"] = configTemplates.dbOutputTemplate
105 repMap[
"dbOutputService"] =
""
106 cfgName =
replaceByMap((
"TkAlCompareCommon.oO[common]Oo.."
107 ".oO[name]Oo._cfg.py"),repMap)
108 cfgs[cfgName] = configTemplates.compareTemplate
109 repMaps[cfgName] = repMap
111 cfgSchedule.append( cfgName )
112 GenericValidation.createConfiguration(self, cfgs, path, cfgSchedule, repMaps = repMaps)
116 repMap[
"runComparisonScripts"] =
""
117 scriptName =
replaceByMap((
"TkAlGeomCompare.%s..oO[name]Oo..sh"
119 for name
in self.__compares:
120 if '"DetUnit"' in self.__compares[name][0].
split(
","):
121 repMap[
"outputFile"] = (
".oO[name]Oo..Comparison_common"+name+
".root")
122 repMap[
"nIndex"] = (
"")
123 repMap[
"runComparisonScripts"] += \
124 (
"rfcp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation"
125 "/scripts/comparisonScript.C .\n"
126 "rfcp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation"
127 "/scripts/GeometryComparisonPlotter.h .\n"
128 "rfcp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation"
129 "/scripts/GeometryComparisonPlotter.cc .\n"
130 "root -b -q 'comparisonScript.C+(\""
131 ".oO[name]Oo..Comparison_common"+name+
".root\",\""
133 "rfcp "+path+
"/TkAl3DVisualization_.oO[name]Oo..C .\n"
134 "root -l -b -q TkAl3DVisualization_.oO[name]Oo..C+\n")
136 repMap[
"runComparisonScripts"] += \
137 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
138 ".Comparison_common"+name+
"_Images\n")
139 repMap[
"runComparisonScripts"] += \
140 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
141 ".Comparison_common"+name+
"_Images/Translations\n")
142 repMap[
"runComparisonScripts"] += \
143 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
144 ".Comparison_common"+name+
"_Images/Rotations\n")
145 repMap[
"runComparisonScripts"] += \
146 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
147 ".Comparison_common"+name+
"_Images/CrossTalk\n")
153 repMap[
"runComparisonScripts"] += \
154 (
"find . -maxdepth 1 -name \"*_1*\" "
155 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
156 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
157 repMap[
"runComparisonScripts"] += \
158 (
"find . -maxdepth 1 -name \"*_2*\" "
159 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
160 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Translations/\" \n")
162 repMap[
"runComparisonScripts"] += \
163 (
"find . -maxdepth 1 -name \"*_3*\" "
164 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
165 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
166 repMap[
"runComparisonScripts"] += \
167 (
"find . -maxdepth 1 -name \"*_4*\" "
168 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
169 "/.oO[name]Oo..Comparison_common"+name+
"_Images/Rotations/\" \n")
171 repMap[
"runComparisonScripts"] += \
172 (
"find . -maxdepth 1 -name \"*_5*\" "
173 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
174 "/.oO[name]Oo..Comparison_common"+name+
"_Images/CrossTalk/\" \n")
175 repMap[
"runComparisonScripts"] += \
176 (
"find . -maxdepth 1 -name \"*_6*\" "
177 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
178 "/.oO[name]Oo..Comparison_common"+name+
"_Images/CrossTalk/\" \n")
179 repMap[
"runComparisonScripts"] += \
180 (
"find . -maxdepth 1 -name \"*_7*\" "
181 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
182 "/.oO[name]Oo..Comparison_common"+name+
"_Images/CrossTalk/\" \n")
183 repMap[
"runComparisonScripts"] += \
184 (
"find . -maxdepth 1 -name \"*_8*\" "
185 "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
186 "/.oO[name]Oo..Comparison_common"+name+
"_Images/CrossTalk/\" \n")
188 repMap[
"runComparisonScripts"] += \
189 (
"find . -maxdepth 1 -name "
190 "\"TkMap_SurfDeform*.pdf\" -print | xargs -I {} bash -c"
191 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
192 ".Comparison_common"+name+
"_Images/\" \n")
193 repMap[
"runComparisonScripts"] += \
194 (
"find . -maxdepth 1 -name "
195 "\"TkMap_SurfDeform*.png\" -print | xargs -I {} bash -c"
196 " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
197 ".Comparison_common"+name+
"_Images/\" \n")
198 repMap[
"runComparisonScripts"] += \
199 (
"if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]]\n"
201 " rfmkdir -p .oO[workdir]Oo./.oO[name]Oo.."+name
204 " mkdir -p $CWD/TkAllInOneTool/.oO[name]Oo.."+name
207 repMap[
"runComparisonScripts"] += \
208 (
"rfcp .oO[CMSSW_BASE]Oo./src/Alignment"
209 "/OfflineValidation/scripts/makeArrowPlots.C "
211 "root -b -q 'makeArrowPlots.C(\""
212 ".oO[name]Oo..Comparison_common"+name
213 +
".root\",\".oO[name]Oo.."
214 +name+
"_ArrowPlots\")'\n")
215 repMap[
"runComparisonScripts"] += \
216 (
"rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
217 ".Comparison_common"+name+
"_Images/ArrowPlots\n")
218 repMap[
"runComparisonScripts"] += \
219 (
"find .oO[name]Oo.."+name+
"_ArrowPlots "
220 "-maxdepth 1 -name \"*.png\" -print | xargs -I {} bash "
221 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
222 ".Comparison_common"+name+
"_Images/ArrowPlots\"\n")
223 repMap[
"runComparisonScripts"] += \
225 "-maxdepth 1 -name \".oO[name]Oo..Visualization_rotated.gif\" -print | xargs -I {} bash "
226 "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
227 ".Comparison_common"+name+
"_Images/.oO[name]Oo..Visualization.gif\"\n")
229 resultingFile =
replaceByMap((
"/store/caf/user/$USER/.oO[eosdir]Oo./compared%s_"
230 ".oO[name]Oo..root"%name), repMap)
231 resultingFile = os.path.expandvars( resultingFile )
232 resultingFile = os.path.abspath( resultingFile )
233 repMap[
"runComparisonScripts"] += \
234 (
"cmsStage -f OUTPUT_comparison.root %s\n"
238 repMap[
"CommandLine"]=
""
245 repMap[
"CommandLine"]+= \
246 repMap[
"CommandLineTemplate"]%{
"cfgFile":cfg,
247 "postProcess":postProcess}
248 repMap[
"CommandLine"]+= (
"# overall postprocessing\n"
249 ".oO[runComparisonScripts]Oo.\n"
253 scripts = {scriptName:
replaceByMap( configTemplates.scriptTemplate, repMap )}
254 files = {
replaceByMap(
"TkAl3DVisualization_.oO[name]Oo..C", repMap ):
replaceByMap(configTemplates.visualizationTrackerTemplate, repMap )}
256 return GenericValidation.createScript(self, scripts, path)
259 msg = (
"Parallelization not supported for geometry comparison. Please "
260 "choose another 'jobmode'.")
def replaceByMap
— Helpers —############################