3 from __future__
import print_function
12 piecesRE = re.compile (
r'(.+?)\s+"(\S+)"\s+"(\S*)"\s+"(\S+)"')
14 nonAlphaRE = re.compile (
r'\W')
15 commaRE = re.compile (
r',')
16 queueCommand =
'/uscms/home/cplager/bin/clpQueue.pl addjob %s' 18 compRootDir =
'compRoot' 21 doubleRE = re.compile (
r'^(double|int)')
22 vectorRE = re.compile (
r'^vector<([^<>]+)>')
23 detSetVecRE = re.compile (
r'^edm::DetSetVector<([^<>]+)>')
24 edColRE = re.compile (
r'^edm::EDCollection<([^<>]+)>')
25 sortedColRE = re.compile (
r'^edm::SortedCollection<([^<>]+),\S+?> >')
26 singletonRE = re.compile (
r'^([\w:]+)$')
27 containerList = [vectorRE, detSetVecRE, edColRE, sortedColRE, doubleRE]
32 self.container, self.one, self.two, self.
three = tup
34 for regex
in containerList:
35 match = regex.search( self.container)
42 return pprint.pformat (self.__dict__)
48 return "%s,%s,%s" % (self.one, self.two, self.
three)
51 if __name__ ==
"__main__":
56 parser = optparse.OptionParser (
"%prog [options] file1.root [file2.root]"\
57 "\nFor more details, see\nhttps://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePhysicsToolsEdmOneToOneComparison")
58 describeGroup = optparse.OptionGroup (parser,
"Description Options")
59 precisionGroup = optparse.OptionGroup (parser,
"Precision Options")
60 summaryGroup = optparse.OptionGroup (parser,
"Summary Options")
61 queueGroup = optparse.OptionGroup (parser,
"Queue Options")
62 verboseGroup = optparse.OptionGroup (parser,
"Verbose Options")
64 parser.add_option (
"--compRoot", dest=
"compRoot",
65 action=
"store_true", default=
False,
66 help=
"Make compRoot files.")
67 parser.add_option (
'--strictPairing', dest=
'strictPairing',
69 help=
"Objects are paired uniquely by order in collection")
70 parser.add_option (
"--prefix", dest=
"prefix", type=
"string",
71 help=
"Prefix to prepend to logfile name")
72 parser.add_option (
"--regex", dest=
'regex', action=
"append",
73 type=
"string", default=[],
74 help=
"Only run on branches containing regex")
76 describeGroup.add_option (
"--describeOnly", dest=
"describeOnly",
77 action=
"store_true", default=
False,
78 help=
"Run description step only and stop.")
79 describeGroup.add_option (
"--forceDescribe", dest=
"forceDescribe",
80 action=
"store_true", default=
False,
81 help=
"Run description step even if "\
82 "file already exists.")
83 describeGroup.add_option (
"--singletons", dest=
"singletons",
84 action=
"store_true", default=
False,
85 help=
"Describe singleton objects (" \
86 "used only with --describeOnly option).")
87 describeGroup.add_option (
"--privateMemberData", dest=
"privateMemberData",
88 action=
"store_true", default=
False,
89 help=
"include private member data "\
90 "(NOT for comparisons)")
92 precisionGroup.add_option (
"--precision", dest=
"precision", type=
"string",
93 help=
"Change precision use for floating "\
95 precisionGroup.add_option (
'--absolute', dest=
'absolute',
96 action=
'store_true', default=
False,
97 help=
'Precision is checked against '\
98 'absolute difference')
99 precisionGroup.add_option (
'--relative', dest=
'relative',
100 action=
'store_true', default=
False,
101 help=
'Precision is checked against '\
102 'relative difference')
104 summaryGroup.add_option (
"--summary", dest=
"summary",
105 action=
"store_true", default=
False,
106 help=
"Print out summary counts at end")
107 summaryGroup.add_option (
"--summaryFull", dest=
"summaryFull",
108 action=
"store_true", default=
False,
109 help=
"Print out full summary at end (VERY LONG)")
111 queueGroup.add_option (
"--noQueue", dest=
"noQueue",
112 action=
"store_true", default=
True,
113 help=
"Do not use queue, but run "\
114 "jobs serially (default).")
115 queueGroup.add_option (
"--queue", dest=
"noQueue",
116 action=
"store_false",
117 help=
"Use defaultqueueing system.")
118 queueGroup.add_option (
"--queueCommand", dest=
"queueCommand", type=
"string",
119 help=
"Use QUEUECOMMAND TO queue jobs")
121 verboseGroup.add_option (
"--verbose", dest=
"verbose",
122 action=
"store_true", default=
False,
123 help=
"Verbose output")
124 verboseGroup.add_option (
"--verboseDebug", dest=
"verboseDebug",
125 action=
"store_true", default=
False,
126 help=
"Verbose output for debugging")
127 parser.add_option_group (describeGroup)
128 parser.add_option_group (precisionGroup)
129 parser.add_option_group (summaryGroup)
130 parser.add_option_group (queueGroup)
131 parser.add_option_group (verboseGroup)
132 options, args = parser.parse_args()
136 if len (args) < 1
or len (args) > 2:
137 raise RuntimeError(
"You must provide 1 or 2 root files")
142 if options.queueCommand:
143 queueCommand = options.queueCommand
144 options.noQueue =
False 145 if not re.match (
r'%%s', queueCommand):
146 queueCommand +=
' %s' 148 command =
'src/Validation/Tools/scripts/runCommand.bash' 150 command =
'src/Validation/Tools/scripts/runCMScommand.bash' 153 if options.compRoot
or options.summary
or options.summaryFull:
154 raise RuntimeError(
"You can not use --compRoot or --summary "\
160 base = os.environ.get (
'CMSSW_BASE')
161 release_base = os.environ.get (
'CMSSW_RELEASE_BASE')
162 if not base
or not release_base:
163 raise RuntimeError(
"You must have already setup a CMSSW environment.")
166 for directory
in [base, release_base]:
167 fullCommand = directory +
'/' + command
168 if os.path.exists (fullCommand):
172 raise RuntimeError(
"Can not find %s" % command)
173 if not options.noQueue:
174 fullCommand = queueCommand % fullCommand
175 if not os.path.isdir (logDir):
177 if not os.path.isdir (logDir):
178 raise RuntimeError(
"Can't create %s directory" % logDir)
179 if options.compRoot
and not os.path.isdir (compRootDir):
180 os.mkdir (compRootDir)
181 if not os.path.isdir (compRootDir):
182 raise RuntimeError(
"Can't create %s directory" % compRootDir)
183 logPrefix = logDir +
'/' 184 compRootPrefix = compRootDir +
'/' 186 logPrefix += options.prefix +
'_' 187 currentDir = os.getcwd()
192 filename2 = filename1
193 if not os.path.exists (filename1)
or not os.path.exists (filename2):
194 raise RuntimeError(
"Can not find '%s' or '%s'" % (filename1, filename2))
196 if options.verboseDebug:
197 options.verbose =
True 199 print(
"files", filename1, filename2)
200 if options.singletons
and not options.describeOnly:
201 raise RuntimeError(
"--singletons can only be used with "\
202 "--describeOnly option")
203 if options.privateMemberData
and not options.describeOnly:
204 raise RuntimeError(
"--privateMemberData can only be used with "\
205 "--describeOnly option")
206 if options.singletons:
207 containerList.append (singletonRE)
212 print(
"Getting edmDumpEventContent output")
214 for regex
in options.regex:
215 regexLine +=
' "--regex=%s"' % regex
216 dumpCommand =
'edmDumpEventContent %s %s' % (regexLine, filename1)
217 if options.verboseDebug:
218 print(dumpCommand,
'\n')
219 output = commands.getoutput (dumpCommand).
split(
"\n")
221 raise RuntimeError(
"No output from edmDumpEventContent.")
222 if options.verboseDebug:
225 total = failed = skipped = useless = 0
228 match = piecesRE.search(line)
232 collection.setdefault( obj.container, [] ).
append(obj)
241 for key, value
in sorted (six.iteritems(collection)):
243 prettyName = nonAlphaRE.sub(
'', name)
244 descriptionName = prettyName +
'.txt' 245 if os.path.exists (descriptionName) \
246 and os.path.getsize (descriptionName) \
247 and not options.forceDescribe:
249 print(
'%s exists. Skipping' % descriptionName)
252 describeCmd =
"%s %s %s useReflexToDescribeForGenObject.py %s '--type=%s'" \
253 % (fullCommand, currentDir, logPrefix + prettyName,
254 GenObject.encodeNonAlphanumerics (name),
256 GenObject.encodeNonAlphanumerics (key))
257 if options.precision:
258 describeCmd +=
" --precision=" + options.precision
260 print(
"describing %s" % name)
261 if options.verboseDebug:
262 print(describeCmd,
'\n')
263 returnCode = os.system (describeCmd)
266 if returnCode == GenObject.uselessReturnCode << 8:
269 print(
"Error trying to describe '%s'. Continuing.\n" % \
272 if options.describeOnly:
273 print(
"Total: %3d Skipped: %3d Failed: %3d Useless: %3d" % \
274 (total, skipped, failed, useless))
275 if not options.noQueue:
276 print(
"Note: Failed not recorded when using queuing system.")
282 for key, value
in sorted (six.iteritems(collection)):
287 prettyName = nonAlphaRE.sub(
'', name)
288 scriptName =
'edmOneToOneComparison.py' 289 if prettyName
in [
'int',
'double']:
290 scriptName =
'simpleEdmComparison.py' 291 prettyLabel = commaRE.sub (
'_', obj.label())
292 compareCmd =
'%s %s %s %s --compare --label=reco^%s^%s' \
299 fullCompareCmd =
'%s %s %s %s' \
300 % (fullCommand, currentDir,
301 logPrefix + prettyName +
'_' + prettyLabel,
304 fullCompareCmd +=
' --relative' 305 elif options.absolute:
306 fullCompareCmd +=
' --absolute' 308 compRootName = compRootPrefix + prettyName \
309 +
'_' + prettyLabel +
'.root' 310 fullCompareCmd +=
' --compRoot=%s' % compRootName
311 if options.strictPairing:
312 fullCompareCmd +=
' --strictPairing' 314 print(
"comparing branch %s %s" % (name, obj.label()))
315 if options.verboseDebug:
316 print(fullCompareCmd,
'\n')
317 os.system (fullCompareCmd)
322 if options.summary
or options.summaryFull:
324 summaryMask = options.prefix +
'_%_' 327 if options.summaryFull:
328 summaryOptions =
'--diffTree' 330 summaryOptions =
'--counts' 331 summaryCmd =
'summarizeEdmComparisonLogfiles.py %s %s logfiles' \
332 % (summaryOptions, summaryMask)
334 print(commands.getoutput (summaryCmd))
S & print(S &os, JobReport::InputFile const &f)
static std::string join(char **cmd)