10 piecesRE = re.compile (
r'(.+?)\s+"(\S+)"\s+"(\S*)"\s+"(\S+)"')
12 nonAlphaRE = re.compile (
r'\W')
13 commaRE = re.compile (
r',')
14 queueCommand =
'/uscms/home/cplager/bin/clpQueue.pl addjob %s'
16 compRootDir =
'compRoot'
19 doubleRE = re.compile (
r'^(double|int)')
20 vectorRE = re.compile (
r'^vector<([^<>]+)>')
21 detSetVecRE = re.compile (
r'^edm::DetSetVector<([^<>]+)>')
22 edColRE = re.compile (
r'^edm::EDCollection<([^<>]+)>')
23 sortedColRE = re.compile (
r'^edm::SortedCollection<([^<>]+),\S+?> >')
24 singletonRE = re.compile (
r'^([\w:]+)$')
25 containerList = [vectorRE, detSetVecRE, edColRE, sortedColRE, doubleRE]
30 self.container, self.one, self.two, self.
three = tup
32 for regex
in containerList:
33 match = regex.search( self.container)
40 return pprint.pformat (self.__dict__)
46 return "%s,%s,%s" % (self.one, self.two, self.
three)
49 if __name__ ==
"__main__":
54 parser = optparse.OptionParser (
"%prog [options] file1.root [file2.root]"\
55 "\nFor more details, see\nhttps://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePhysicsToolsEdmOneToOneComparison")
56 describeGroup = optparse.OptionGroup (parser,
"Description Options")
57 precisionGroup = optparse.OptionGroup (parser,
"Precision Options")
58 summaryGroup = optparse.OptionGroup (parser,
"Summary Options")
59 queueGroup = optparse.OptionGroup (parser,
"Queue Options")
60 verboseGroup = optparse.OptionGroup (parser,
"Verbose Options")
62 parser.add_option (
"--compRoot", dest=
"compRoot",
63 action=
"store_true", default=
False,
64 help=
"Make compRoot files.")
65 parser.add_option (
'--strictPairing', dest=
'strictPairing',
67 help=
"Objects are paired uniquely by order in collection")
68 parser.add_option (
"--prefix", dest=
"prefix", type=
"string",
69 help=
"Prefix to prepend to logfile name")
70 parser.add_option (
"--regex", dest=
'regex', action=
"append",
71 type=
"string", default=[],
72 help=
"Only run on branches containing regex")
74 describeGroup.add_option (
"--describeOnly", dest=
"describeOnly",
75 action=
"store_true", default=
False,
76 help=
"Run description step only and stop.")
77 describeGroup.add_option (
"--forceDescribe", dest=
"forceDescribe",
78 action=
"store_true", default=
False,
79 help=
"Run description step even if "\
80 "file already exists.")
81 describeGroup.add_option (
"--singletons", dest=
"singletons",
82 action=
"store_true", default=
False,
83 help=
"Describe singleton objects (" \
84 "used only with --describeOnly option).")
85 describeGroup.add_option (
"--privateMemberData", dest=
"privateMemberData",
86 action=
"store_true", default=
False,
87 help=
"include private member data "\
88 "(NOT for comparisons)")
90 precisionGroup.add_option (
"--precision", dest=
"precision", type=
"string",
91 help=
"Change precision use for floating "\
93 precisionGroup.add_option (
'--absolute', dest=
'absolute',
94 action=
'store_true', default=
False,
95 help=
'Precision is checked against '\
96 'absolute difference')
97 precisionGroup.add_option (
'--relative', dest=
'relative',
98 action=
'store_true', default=
False,
99 help=
'Precision is checked against '\
100 'relative difference')
102 summaryGroup.add_option (
"--summary", dest=
"summary",
103 action=
"store_true", default=
False,
104 help=
"Print out summary counts at end")
105 summaryGroup.add_option (
"--summaryFull", dest=
"summaryFull",
106 action=
"store_true", default=
False,
107 help=
"Print out full summary at end (VERY LONG)")
109 queueGroup.add_option (
"--noQueue", dest=
"noQueue",
110 action=
"store_true", default=
True,
111 help=
"Do not use queue, but run "\
112 "jobs serially (default).")
113 queueGroup.add_option (
"--queue", dest=
"noQueue",
114 action=
"store_false",
115 help=
"Use defaultqueueing system.")
116 queueGroup.add_option (
"--queueCommand", dest=
"queueCommand", type=
"string",
117 help=
"Use QUEUECOMMAND TO queue jobs")
119 verboseGroup.add_option (
"--verbose", dest=
"verbose",
120 action=
"store_true", default=
False,
121 help=
"Verbose output")
122 verboseGroup.add_option (
"--verboseDebug", dest=
"verboseDebug",
123 action=
"store_true", default=
False,
124 help=
"Verbose output for debugging")
125 parser.add_option_group (describeGroup)
126 parser.add_option_group (precisionGroup)
127 parser.add_option_group (summaryGroup)
128 parser.add_option_group (queueGroup)
129 parser.add_option_group (verboseGroup)
130 options, args = parser.parse_args()
134 if len (args) < 1
or len (args) > 2:
135 raise RuntimeError,
"You must provide 1 or 2 root files"
140 if options.queueCommand:
141 queueCommand = options.queueCommand
142 options.noQueue =
False
143 if not re.match (
r'%%s', queueCommand):
144 queueCommand +=
' %s'
146 command =
'src/Validation/Tools/scripts/runCommand.bash'
148 command =
'src/Validation/Tools/scripts/runCMScommand.bash'
151 if options.compRoot
or options.summary
or options.summaryFull:
152 raise RuntimeError,
"You can not use --compRoot or --summary "\
158 base = os.environ.get (
'CMSSW_BASE')
159 release_base = os.environ.get (
'CMSSW_RELEASE_BASE')
160 if not base
or not release_base:
161 raise RuntimeError,
"You must have already setup a CMSSW environment."
164 for directory
in [base, release_base]:
165 fullCommand = directory +
'/' + command
166 if os.path.exists (fullCommand):
170 raise RuntimeError,
"Can not find %s" % command
171 if not options.noQueue:
172 fullCommand = queueCommand % fullCommand
173 if not os.path.isdir (logDir):
175 if not os.path.isdir (logDir):
176 raise RuntimeError,
"Can't create %s directory" % logDir
177 if options.compRoot
and not os.path.isdir (compRootDir):
178 os.mkdir (compRootDir)
179 if not os.path.isdir (compRootDir):
180 raise RuntimeError,
"Can't create %s directory" % compRootDir
181 logPrefix = logDir +
'/'
182 compRootPrefix = compRootDir +
'/'
184 logPrefix += options.prefix +
'_'
185 currentDir = os.getcwd()
190 filename2 = filename1
191 if not os.path.exists (filename1)
or not os.path.exists (filename2):
192 raise RuntimeError,
"Can not find '%s' or '%s'" % (filename1, filename2)
194 if options.verboseDebug:
195 options.verbose =
True
197 print "files", filename1, filename2
198 if options.singletons
and not options.describeOnly:
199 raise RuntimeError,
"--singletons can only be used with "\
200 "--describeOnly option"
201 if options.privateMemberData
and not options.describeOnly:
202 raise RuntimeError,
"--privateMemberData can only be used with "\
203 "--describeOnly option"
204 if options.singletons:
205 containerList.append (singletonRE)
210 print "Getting edmDumpEventContent output"
212 for regex
in options.regex:
213 regexLine +=
' "--regex=%s"' % regex
214 dumpCommand =
'edmDumpEventContent %s %s' % (regexLine, filename1)
215 if options.verboseDebug:
216 print dumpCommand,
'\n'
217 output = commands.getoutput (dumpCommand).
split(
"\n")
219 raise RuntimeError,
"No output from edmDumpEventContent."
220 if options.verboseDebug:
221 print "output:\n",
"\n".
join(output)
223 total = failed = skipped = useless = 0
226 match = piecesRE.search(line)
230 collection.setdefault( obj.container, [] ).
append(obj)
239 for key, value
in sorted (collection.iteritems()):
241 prettyName = nonAlphaRE.sub(
'', name)
242 descriptionName = prettyName +
'.txt'
243 if os.path.exists (descriptionName) \
244 and os.path.getsize (descriptionName) \
245 and not options.forceDescribe:
247 print '%s exists. Skipping' % descriptionName
250 describeCmd =
"%s %s %s useReflexToDescribeForGenObject.py %s '--type=%s'" \
251 % (fullCommand, currentDir, logPrefix + prettyName,
252 GenObject.encodeNonAlphanumerics (name),
254 GenObject.encodeNonAlphanumerics (key))
255 if options.precision:
256 describeCmd +=
" --precision=" + options.precision
258 print "describing %s" % name
259 if options.verboseDebug:
260 print describeCmd,
'\n'
261 returnCode = os.system (describeCmd)
264 if returnCode == GenObject.uselessReturnCode << 8:
267 print "Error trying to describe '%s'. Continuing.\n" % \
270 if options.describeOnly:
271 print "Total: %3d Skipped: %3d Failed: %3d Useless: %3d" % \
272 (total, skipped, failed, useless)
273 if not options.noQueue:
274 print "Note: Failed not recorded when using queuing system."
280 for key, value
in sorted (collection.iteritems()):
285 prettyName = nonAlphaRE.sub(
'', name)
286 scriptName =
'edmOneToOneComparison.py'
287 if prettyName
in [
'int',
'double']:
288 scriptName =
'simpleEdmComparison.py'
289 prettyLabel = commaRE.sub (
'_', obj.label())
290 compareCmd =
'%s %s %s %s --compare --label=reco^%s^%s' \
297 fullCompareCmd =
'%s %s %s %s' \
298 % (fullCommand, currentDir,
299 logPrefix + prettyName +
'_' + prettyLabel,
302 fullCompareCmd +=
' --relative'
303 elif options.absolute:
304 fullCompareCmd +=
' --absolute'
306 compRootName = compRootPrefix + prettyName \
307 +
'_' + prettyLabel +
'.root'
308 fullCompareCmd +=
' --compRoot=%s' % compRootName
309 if options.strictPairing:
310 fullCompareCmd +=
' --strictPairing'
312 print "comparing branch %s %s" % (name, obj.label())
313 if options.verboseDebug:
314 print fullCompareCmd,
'\n'
315 os.system (fullCompareCmd)
320 if options.summary
or options.summaryFull:
322 summaryMask = options.prefix +
'_%_'
325 if options.summaryFull:
326 summaryOptions =
'--diffTree'
328 summaryOptions =
'--counts'
329 summaryCmd =
'summarizeEdmComparisonLogfiles.py %s %s logfiles' \
330 % (summaryOptions, summaryMask)
332 print commands.getoutput (summaryCmd)
static std::string join(char **cmd)