ATLAS Offline Software
Loading...
Searching...
No Matches
difftuple_text.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3#
4# File: D3PDMakerTest/python/difftuple_text.py
5# Author: snyder@bnl.gov
6# Date: Oct, 2010
7# Purpose: Diff a root tuple file against a text dump.
8#
9
10import operator
11import os
12import types
13import re
14import string
15import fnmatch
16import ROOT
17from functools import reduce
18from D3PDMakerTest.split_list import split_list, split_list1
19
20ignore_event_differences = False
21
22
23# NEW:OLD
24renames = {
25 }
26
27rename_keys = {
28 # Hack for ordering difference when scell tuple is on.
29 'caloMeta/EventInfoD3PDObject_000005' : 'caloMeta/EventInfoD3PDObject_000004',
30 'physicsMeta/EventInfoD3PDObject_000003' : 'physicsMeta/EventInfoD3PDObject_000002',
31 'physicsTrigDecMeta/EventInfoD3PDObject_000004' : 'physicsTrigDecMeta/EventInfoD3PDObject_000003',
32 }
33
35 return (ver and
36 (ver.find('17.2')>=0 or
37 ver.find('17.3')>=0) and
38 #ver.find('AtlasProduction')>=0 and
39 ver.find('AtlasPhysics')==-1 and
40 ver.find('usatlas+u/snyder')==-1)
41
42
43# List of branches to ignore for various versions.
44# Format is a list of tuples: (V, V, V, [BRANCHES...])
45# We consider the strings V in turn and see if they're contained
46# in CMTPATH. If the first V is `-', then we ignore the branches
47# if there are any matches. Otherwise, we ignore the branches
48# unless there are any matches.
49# If V is callable, then instead of looking for at match in CMTPATH,
50# we call it with CMTPATH as an argument.
51# The list of branches can include glob patterns.
52_ignore_branches = [
53 # temp
54 ('17.2',
55 ['EF_*',
56 'L1_*',
57 'L2_*',
58 'trig_roidescriptor_*',
59 'trig_bgCode',
60 'trig_L1_esum_*',
61 'trig_L2_sitrack_*',
62 'trig_L2_idscan_*',
63 'trig_L2_tilemufeature_*',
64 'trig_L2_muonfeature_*',
65 'trig_L2_muonfeaturedetails_*',
66 'trig_L2_isomuonfeature_*',
67 'trig_L2_combmuonfeature_*',
68 'trig_L2_tiletrackmufeature_*',
69 'trig_L2_sitrackfinder_*',
70 'trig_L2_el_*',
71 'trig_L2_ph_*',
72 'trig_L2_met_*',
73 'trig_L2_feb_met_*',
74 'trig_DB_*',
75 'trackjet_*',
76 'el*_EF_*',
77 'ph*_EF_*',
78 'mu*_EF*',
79 'el*_L1_*',
80 'ph*_L1_*',
81 'mu*_L1_*',
82 'el*_L2_*',
83 'ph*_L2_*',
84 'mu*_L2*',
85 'trig_EF_trigmuonefisolation_*',
86 #'trig_EF_trigmuonef_*',
87 'trig_EF_trigmugirl_*',
88 'trig_EF_met_*',
89 ]),
90
91 # changed in devval
92 ('17.2',
93 ['*_BCH_CORR_CELL',
94 '*_BCH_CORR_DOTX',
95 '*_BCH_CORR_JET',
96 '*_BCH_CORR_JET_FORCELL',
97 '*_ENG_BAD_CELLS',
98 '*_N_BAD_CELLS',
99 '*_N_BAD_CELLS_CORR',
100 '*_BAD_CELLS_CORR_E',
101 '*_n90',
102 '*_isBadMedium',
103 '*_isBadTight',
104 '*_isBadLooseMinus',
105 '*_tgap3f',
106 '*_hecf',
107 'backgroundFlags',
108 'lumiFlags',
109 'el*_isEMLoose',
110 'trig_EF_el*_isEMLoose',
111 'el*_isEMMedium',
112 'trig_EF_el*_isEMMedium',
113 'el*_isEMTight',
114 'trig_EF_el*_isEMTight',
115 'el*_looseIso',
116 'trig_EF_el*_looseIso',
117 'el*_mediumIso',
118 'trig_EF_el*_mediumIso',
119 'el*_tightIso',
120 'trig_EF_el*_tightIso',
121 'el*_loosePP',
122 'trig_EF_el*_loosePP',
123 'el*_loosePPIso',
124 'trig_EF_el*_loosePPIso',
125 'el*_mediumPP',
126 'trig_EF_el*_mediumPP',
127 'el*_mediumPPIso',
128 'trig_EF_el*_mediumPPIso',
129 'el*_tightPP',
130 'trig_EF_el*_tightPP',
131 'el*_tightPPIso',
132 'trig_EF_el*_tightPPIso',
133 'el*_mediumWithoutTrack',
134 'trig_EF_el*_mediumWithoutTrack',
135 'el*_mediumIsoWithoutTrack',
136 'trig_EF_el*_mediumIsoWithoutTrack',
137 'el*_tightWithoutTrack',
138 'trig_EF_el*_tightWithoutTrack',
139 'el*_tightIsoWithoutTrack',
140 'trig_EF_el*_tightIsoWithoutTrack',
141 'el*_loose',
142 'trig_EF_el*_loose',
143 'el*_medium',
144 'trig_EF_el*_medium',
145 'el*_tight',
146 'trig_EF_el*_tight',
147 'el*_reta',
148 'el*_rphi',
149 'el*_hastrack',
150 'el*_convanglematch',
151 'el*_convtrackmatch',
152 'el*_etacorrmag',
153 'trig_EF_el*_etacorrmag',
154 'el*_deltaPhiFromLast',
155 'el*_deltaPhiRot',
156 'el*_trackd0_physics',
157 'trig_EF_el*_trackd0_physics',
158 'el*_etaSampling1',
159 'el*_hasconv',
160 'el*_convvtxx',
161 'el*_convvtxy',
162 'el*_convvtxz',
163 'el*_Rconv',
164 'el*_zconv',
165 'el*_convvtxchi2',
166 'el*_pt1conv',
167 'el*_convtrk1nBLHits',
168 'el*_convtrk1nPixHits',
169 'el*_convtrk1nSCTHits',
170 'el*_convtrk1nTRTHits',
171 'el*_pt2conv',
172 'el*_convtrk2nBLHits',
173 'el*_convtrk2nPixHits',
174 'el*_convtrk2nSCTHits',
175 'el*_convtrk2nTRTHits',
176 'el*_ptconv',
177 'el*_pzconv',
178 'el*_EtringnoisedR03sig2',
179 'el*_EtringnoisedR03sig3',
180 'el*_EtringnoisedR03sig4',
181 'trig_EF_el*_EtringnoisedR03sig2',
182 'trig_EF_el*_EtringnoisedR03sig3',
183 'trig_EF_el*_EtringnoisedR03sig4',
184 'el*_ptcone20_zpv05',
185 'el*_ptcone30_zpv05',
186 'el*_ptcone40_zpv05',
187 'el*_nucone20_zpv05',
188 'el*_nucone30_zpv05',
189 'el*_nucone40_zpv05',
190 'el*_originbkg',
191 'el*_typebkg',
192 'el*_isolationlikelihoodjets',
193 'el*_isolationlikelihoodhqelectrons',
194 'el*_electronweight',
195 'el*_electronbgweight',
196 'el*_softeweight',
197 'el*_softebgweight',
198 'el*_neuralnet',
199 'el*_Hmatrix',
200 'el*_Hmatrix5',
201 'el*_adaboost',
202 'el*_softeneuralnet',
203 'el*_ringernn',
204 'el*_refittedTrack_*',
205 'el*_nPixSharedHits',
206 'el*_nPixSplitHits',
207 'trig_EF_el*_nPixSplitHits',
208 'el*_nPixHoles',
209 'trig_EF_el*_nPixHoles',
210 'el*_nSCTSharedHits',
211 'el*_nSCTDoubleHoles',
212 'el*_nTRTHoles',
213 'trig_EF_el*_nTRTHoles',
214 'el*_nSCTHoles',
215 'trig_EF_el*_nSCTHoles',
216 'el*_nSCTDeadSensors',
217 'trig_EF_el*_nSCTDeadSensors',
218 'el*_nBLayerSplitHits',
219 'trig_EF_el*_nBLayerSplitHits',
220 'el*_nBLSharedHits',
221 'el*_nPixelDeadSensors',
222 'trig_EF_el*_nPixelDeadSensors',
223 'el*_nTRTXenonHits',
224 'trig_EF_el*_nTRTXenonHits',
225 'el*_vertx',
226 'el*_verty',
227 'el*_vertz',
228 'el*_vertweight',
229 'el*_LM',
230 'el*_ES0_real',
231 'el*_ES1_real',
232 'el*_ES2_real',
233 'el*_ES3_real',
234 'el*_EcellS0',
235 'el*_etacellS0',
236 'el*_topoEtcone60',
237 'el*_ED_Njets',
238 'el*_ED_median',
239 'el*_ED_sigma',
240 'el*_Etcone40_ED_corrected',
241 'el*_Etcone40_corrected',
242 'el*_topoEtcone20_corrected',
243 'el*_topoEtcone30_corrected',
244 'el*_topoEtcone40_corrected',
245 'el*_rawcl_*',
246 'el*_goodOQ',
247 'el*_isConv',
248 'el*_nConv',
249 'el*_convFlag',
250 'el*_isEM',
251 'trig_EF_el*_isEM',
252 'el*_TRTHighTHitsRatio',
253 'trig_EF_el*_TRTHighTHitsRatio',
254 'el*_TRTHighTOutliersRatio',
255 'trig_EF_el*_TRTHighTOutliersRatio',
256 'el*_expectHitInBLayer',
257 'trig_EF_el*_expectHitInBLayer',
258 'el*_likelihoodsPixeldEdx',
259 'trig_EF_el*_likelihoodsPixeldEdx',
260 'el*_massPixeldEdx',
261 'trig_EF_el*_massPixeldEdx',
262 'el*_nGoodHitsPixeldEdx',
263 'trig_EF_el*_nGoodHitsPixeldEdx',
264 'el*_pixeldEdx',
265 'trig_EF_el*_pixeldEdx',
266 'el*_nSiHits',
267 'trig_EF_el*_nSiHits',
268 'el*_nSingleTrackConv',
269 'el*_nDoubleTrackConv',
270 'el*_HPV_*',
271 'el*_CaloPointing_*',
272 'el*_truth_bremLoc',
273 'el*_truth_bremSi',
274 'el*_truth_sumbrem',
275 'el*_truth_charge',
276 'el*_truth_mothercharge',
277 'el*_truth_motherstatus',
278 'mcevt_event_number',
279 'mcevt_signal_process_id',
280 'mcevt_nparticle',
281 'mcevt_pileUpType',
282 'mc_n',
283 'mc_phi',
284 'mc_eta',
285 'mc_m',
286 'mc_pt',
287 'mc_barcode',
288 'mc_pdgId',
289 'mc_status',
290 'mc_charge',
291 'mc_child_index',
292 'mc_parent_index',
293 'mc_children',
294 'mc_parents',
295 'mc_vx_x',
296 'mc_vx_y',
297 'mc_vx_z',
298 'mc_vx_barcode',
299 'el*_truth_index',
300 'ph*_isEMLoose',
301 'trig_EF_ph*_isEMLoose',
302 'ph*_isEMMedium',
303 'trig_EF_ph*_isEMMedium',
304 'ph*_isEMTight',
305 'trig_EF_ph*_isEMTight',
306 'ph*_isEM',
307 'trig_EF_ph*_isEM',
308 'ph*_loose',
309 'trig_EF_ph*_loose',
310 'ph*_tight',
311 'trig_EF_ph*_tight',
312 'ph*_type',
313 'ph*_origin',
314 'ph*_truth_E',
315 'ph*_truth_matched',
316 'ph*_truth_pt',
317 'ph*_truth_eta',
318 'ph*_truth_phi',
319 'ph*_truth_barcode',
320 'ph*_truth_status',
321 'ph*_truth_motherbarcode',
322 'ph*_truth_mothertype',
323 'ph*_truth_mothercharge',
324 'ph*_truth_motherstatus',
325 'ph*_truth_index',
326 'ph*_truth_charge',
327 'ph*_deltaRRecPhoton',
328 'ph*_goodOQ',
329 'ph*_Etcone45',
330 'trig_EF_ph*_Etcone45',
331 'ph*_EtringnoisedR03sig2',
332 'ph*_EtringnoisedR03sig3',
333 'ph*_EtringnoisedR03sig4',
334 'ph*_ptcone20_zpv05',
335 'ph*_ptcone30_zpv05',
336 'ph*_ptcone40_zpv05',
337 'ph*_nucone20_zpv05',
338 'ph*_nucone30_zpv05',
339 'ph*_nucone40_zpv05',
340 'ph*_isolationlikelihoodjets',
341 'ph*_isolationlikelihoodhqelectrons',
342 'ph*_loglikelihood',
343 'ph*_photonweight',
344 'ph*_photonbgweight',
345 'ph*_neuralnet',
346 'ph*_Hmatrix',
347 'ph*_Hmatrix5',
348 'ph*_adaboost',
349 'ph*_ringernn',
350 'ph*_etas3',
351 'ph*_phis3',
352 'ph*_Es3',
353 'ph*_rawcl_*',
354 'ph*_rings_E',
355 'ph*_convMatchDeltaPhi1',
356 'ph*_convMatchDeltaPhi2',
357 'ph*_convMatchDeltaEta1',
358 'ph*_convMatchDeltaEta2',
359 'ph*_vx_px',
360 'ph*_vx_py',
361 'ph*_vx_pz',
362 'ph*_vx_m',
363 'ph*_vx_E',
364 'ph*_vx_sumPt',
365 'ph*_vx_convTrk_patternReco*',
366 'ph*_vx_convTrk_nSCTSharedHits',
367 'ph*_vx_convTrk_nBLSharedHits',
368 'ph*_vx_convTrk_nTRTDeadStraws',
369 'ph*_vx_convTrk_nPixelDeadSensors',
370 'ph*_vx_convTrk_nSCTDeadSensors',
371 'ph*_vx_convTrk_nPixHoles',
372 'ph*_vx_convTrk_nPixSplitHits',
373 'ph*_vx_convTrk_nPixSharedHits',
374 'ph*_vx_convTrk_nSCTDoubleHoles',
375 'ph*_vx_convTrk_nTRTXenonHits',
376 'ph*_vx_convTrk_nTRTHoles',
377 'ph*_vx_convTrk_nSCTHoles',
378 'ph*_vx_convTrk_nBLayerSplitHits',
379 'ph*_vx_convTrk_nCSCEtaHits',
380 'ph*_vx_convTrk_nCSCPhiHits',
381 'ph*_vx_convTrk_nCscEtaHoles',
382 'ph*_vx_convTrk_nCscPhiHoles',
383 'ph*_vx_convTrk_nTGCEtaHits',
384 'ph*_vx_convTrk_nTGCPhiHits',
385 'ph*_vx_convTrk_nTgcEtaHoles',
386 'ph*_vx_convTrk_nTgcPhiHoles',
387 'ph*_vx_convTrk_nRPCEtaHits',
388 'ph*_vx_convTrk_nRPCPhiHits',
389 'ph*_vx_convTrk_nRpcEtaHoles',
390 'ph*_vx_convTrk_nRpcPhiHoles',
391 'ph*_vx_convTrk_nMDTHits',
392 'ph*_vx_convTrk_nMdtHoles',
393 'ph*_vx_convTrk_nHits',
394 'ph*_vx_convTrk_nHoles',
395 'ph*_vx_convTrk_nSiHits',
396 'ph*_vx_convTrk_hitPattern',
397 'ph*_vx_convTrk_TRTHighTHitsRatio',
398 'ph*_vx_convTrk_TRTHighTOutliersRatio',
399 'ph*_vx_convTrk_weight',
400 'ph*_truth_isConv',
401 'ph*_truth_Rconv',
402 'ph*_truth_zconv',
403 'ph*_topoEtcone60',
404 'ph*_vx_Chi2',
405 'ph*_vx_Dcottheta',
406 'ph*_vx_Dphi',
407 'ph*_vx_Dist',
408 'ph*_vx_DR1R2',
409 'ph*_CaloPointing_eta',
410 'ph*_CaloPointing_sigma_eta',
411 'ph*_CaloPointing_zvertex',
412 'ph*_CaloPointing_sigma_zvertex',
413 'ph*_HPV_eta',
414 'ph*_HPV_sigma_eta',
415 'ph*_HPV_zvertex',
416 'ph*_HPV_sigma_zvertex',
417 'ph*_NN_passes',
418 'ph*_NN_discriminant',
419 'ph*_ES0_real',
420 'ph*_ES1_real',
421 'ph*_ES2_real',
422 'ph*_ES3_real',
423 'ph*_EcellS0',
424 'ph*_etacellS0',
425 'ph*_ED_median',
426 'ph*_ED_sigma',
427 'ph*_ED_Njets',
428 'ph*_Etcone40_ED_corrected',
429 'ph*_Etcone40_corrected',
430 'ph*_convIP',
431 'ph*_convIPRev',
432 'ph*_el_index',
433 'ph*_convanglematch',
434 'ph*_zvertex',
435 'ph*_errz',
436 'ph*_etap',
437 'ph*_depth',
438 'trig_EF_ph*_convanglematch',
439 'ph*_convtrackmatch',
440 'trig_EF_ph*_convtrackmatch',
441 'ph*_isRecovered',
442 'trig_EF_ph*_isRecovered',
443 'ph*_looseAR',
444 'trig_EF_ph*_looseAR',
445 'ph*_looseARIso',
446 'trig_EF_ph*_looseARIso',
447 'ph*_tightAR',
448 'trig_EF_ph*_tightAR',
449 'ph*_tightARIso',
450 'trig_EF_ph*_tightARIso',
451 'ph*_tightIso',
452 'trig_EF_ph*_tightIso',
453 'ph*_looseIso',
454 'trig_EF_ph*_looseIso',
455 'ph*_topoEtcone20_corrected',
456 'ph*_topoEtcone30_corrected',
457 'ph*_topoEtcone40_corrected',
458 'ph*_convFlag',
459 'el*_Unrefittedtrack_*',
460 'el_gxx_*',
461 'ef_el_*',
462 'elfilt_*',
463 'elfilt2_*',
464 'elfilt4_*',
465 'elfilt3_*',
466 'emu_*',
467 'cocl_m',
468 'cocl_raw_eta_*',
469 'cocl_raw_phi_*',
470 'cocl_eta_*',
471 'cocl_phi_*',
472 'cocl_E_em',
473 'cocl_E_had',
474 'cocl_etamax_*',
475 'mu*_energyLossErr',
476 'mu*_energyLossPar',
477 'mu*_etCore',
478 'mu*_caloMuonIdTag',
479 'mu*_caloLRLikelihood',
480 'mu*_muonType',
481 'mu*_bestMatch',
482 'mu*_isStandAloneMuon',
483 'mu*_isCombinedMuon',
484 'mu*_isLowPtReconstructedMuon',
485 'mu*_isSegmentTaggedMuon',
486 'mu*_isCaloMuonId',
487 'mu*_alsoFoundByLowPt',
488 'mu*_alsoFoundByCaloMuonId',
489 'mu*_isSiliconAssociatedForwardMuon',
490 'mu*_ie_*',
491 'mu*_ms_*',
492 'mu*_cov_d0_exPV',
493 'mu*_cov_phi_exPV',
494 'mu*_cov_qoverp_exPV',
495 'mu*_cov_theta_exPV',
496 'mu*_cov_z0_exPV',
497 'mu*_err_d0_exPV',
498 'mu*_err_phi_exPV',
499 'mu*_err_qoverp_exPV',
500 'mu*_err_theta_exPV',
501 'mu*_err_z0_exPV',
502 'mu*_nMDTBIHits',
503 'mu*_nMDTBMHits',
504 'mu*_nMDTBOHits',
505 'mu*_nMDTBEEHits',
506 'mu*_nMDTBIS78Hits',
507 'mu*_nMDTEIHits',
508 'mu*_nMDTEMHits',
509 'mu*_nMDTEOHits',
510 'mu*_nMDTEEHits',
511 'mu*_nRPCLayer1EtaHits',
512 'mu*_nRPCLayer2EtaHits',
513 'mu*_nRPCLayer3EtaHits',
514 'mu*_nRPCLayer1PhiHits',
515 'mu*_nRPCLayer2PhiHits',
516 'mu*_nRPCLayer3PhiHits',
517 'mu*_nTGCLayer1EtaHits',
518 'mu*_nTGCLayer2EtaHits',
519 'mu*_nTGCLayer3EtaHits',
520 'mu*_nTGCLayer4EtaHits',
521 'mu*_nTGCLayer1PhiHits',
522 'mu*_nTGCLayer2PhiHits',
523 'mu*_nTGCLayer3PhiHits',
524 'mu*_nTGCLayer4PhiHits',
525 'mu*_barrelSectors',
526 'mu*_endcapSectors',
527 'mu*_primarySector',
528 'mu*_secondarySector',
529 'mu*_innerSmallHits',
530 'mu*_innerLargeHits',
531 'mu*_middleSmallHits',
532 'mu*_middleLargeHits',
533 'mu*_outerSmallHits',
534 'mu*_outerLargeHits',
535 'mu*_extendedSmallHits',
536 'mu*_extendedLargeHits',
537 'mu*_innerSmallHoles',
538 'mu*_innerLargeHoles',
539 'mu*_middleSmallHoles',
540 'mu*_middleLargeHoles',
541 'mu*_outerSmallHoles',
542 'mu*_outerLargeHoles',
543 'mu*_extendedSmallHoles',
544 'mu*_extendedLargeHoles',
545 'mu*_phiLayer1Hits',
546 'mu*_phiLayer2Hits',
547 'mu*_phiLayer3Hits',
548 'mu*_phiLayer4Hits',
549 'mu*_etaLayer1Hits',
550 'mu*_etaLayer2Hits',
551 'mu*_etaLayer3Hits',
552 'mu*_etaLayer4Hits',
553 'mu*_phiLayer1Holes',
554 'mu*_phiLayer2Holes',
555 'mu*_phiLayer3Holes',
556 'mu*_phiLayer4Holes',
557 'mu*_etaLayer1Holes',
558 'mu*_etaLayer2Holes',
559 'mu*_etaLayer3Holes',
560 'mu*_etaLayer4Holes',
561 'mu*_nCSCEtaHits',
562 'mu*_nCSCEtaHoles',
563 'mu*_nCSCPhiHits',
564 'mu*_nCSCPhiHoles',
565 'mu*_nCSCUnspoiledEtaHits',
566 'mu*_nMDTHits',
567 'mu*_nMDTHoles',
568 'mu*_nRPCEtaHits',
569 'mu*_nRPCEtaHoles',
570 'mu*_nRPCPhiHits',
571 'mu*_nRPCPhiHoles',
572 'mu*_nTGCEtaHits',
573 'mu*_nTGCEtaHoles',
574 'mu*_nTGCPhiHits',
575 'mu*_nTGCPhiHoles',
576 'mu*_nTRTOutliers',
577 'mu*_nPixHits',
578 'mu*_nTRTDeadStraws',
579 'mu*_ntrigEtaLayers',
580 'mu*_nBLHits',
581 'mu*_nphiLayers',
582 'mu*_nprecisionLayers',
583 'mu*_nTRTHits',
584 'mu*_type',
585 'mu*_origin',
586 'mu*_truth_eta',
587 'mu*_truth_phi',
588 'mu*_truth_dr',
589 'mu*_truth_pt',
590 'mu*_truth_matched',
591 'mu*_truth_status',
592 'mu*_truth_barcode',
593 'mu*_truth_E',
594 'mu*_truth_mothertype',
595 'mu*_truth_motherbarcode',
596 'mu*_beta',
597 'mu*_matchchi2',
598 'mu*_matchndof',
599 'mu*_isMuonLikelihood',
600 'mu*_trackIPEstimate_*unbiased',
601 'mu*_track*unbiased',
602 'mu*_loose',
603 'mu*_medium',
604 'mu*_tight',
605 'mu*_truth_mothercharge',
606 'mu*_truth_motherstatus',
607 'mu*_truth_charge',
608 'mu*_mc_index',
609 'mu*_dr',
610 'mu*_numberOfSegments',
611 'vxp_ndof',
612 'vxp_py',
613 'vxp_trk_weight',
614 'vxp_trk_z0',
615 'vxp_trk_d0',
616 'vxp_trk_unbiased_z0',
617 'vxp_trk_unbiased_d0',
618 'vxp_trk_err_unbiased_z0',
619 'vxp_trk_err_unbiased_d0',
620 'vxp_trk_qoverp',
621 'vxp_trk_chi2',
622 'muonTruth_m',
623 'muonTruth_status',
624 'MET_*',
625 'METJetsInfo_*',
626 'met_*',
627 'cl_MET_*',
628 'tau_MET_*',
629 'trk_MET_*',
630 'jet_*_MET_*',
631 'el*_MET_*',
632 'ph*_MET_*',
633 'mu*_MET_*',
634 'trig_HLT_*',
635 #'el_truth_*',
636 'mcevt_alphaQCD',
637 'mcevt_alphaQED',
638 'mcevt_event_scale',
639 #'el_type',
640 'trig_L2_emcl_energyInSample',
641 'trig_L2_trk_idscan_*',
642 'trig_L2_trk_sitrack_*',
643 'trig_EF_emcl*_avg_lar_q',
644 'trig_EF_emcl*_avg_tile_q',
645 'trig_EF_emcl*_badlarq_frac',
646 'trig_EF_emcl*_deltaPhi',
647 'trig_EF_emcl*_deltaTheta',
648 'trig_EF_emcl*_eng_pos',
649 'trig_EF_emcl*_nvertexfraction',
650 'trig_EF_emcl*_vertexfraction',
651 'trig_EF_emcl*_significance',
652 'trig_EF_el_EF_*',
653 'trig_EF_ph_EF_*',
654 'trig_L1_mu_thrValue',
655 'trig_L1_mu_pt',
656 'ph_Etcone15',
657 'ph_Etcone25',
658 'ph_Etcone35',
659 'ph_Etcone15_pt_corrected',
660 'ph_Etcone25_pt_corrected',
661 'ph_Etcone35_pt_corrected',
662 'trig_EF_trigmuonef_*',
663 'trig_EF_el_Etcone15',
664 'trig_EF_el_Etcone25',
665 'trig_EF_el_Etcone35',
666 'trig_EF_ph_Etcone15',
667 'trig_EF_ph_Etcone25',
668 'trig_EF_ph_Etcone35',
669 'trig_L1_mu_*',
670 'egtruth_etaCalo',
671 'egtruth_phiCalo',
672 'ph_topoEM*',
673 'trig_EF_el_m',
674 'trig_EF_el_pt',
675 'trig_EF_el_Et',
676 'trig_EF_el_px',
677 'trig_EF_el_py',
678 'trig_EF_el_pz',
679 'trig_EF_el_eta',
680 'trig_EF_el_phi',
681 'trig_EF_el_ptcone20',
682 'el_m',
683 'el_E',
684 'el_Et',
685 'el_px',
686 'el_py',
687 'el_pz',
688 'el_pt',
689 'el_eta',
690 'el_phi',
691 'el_jet_dr',
692 'ph_nucone*',
693 'mu_nucone*',
694 'mu_etconeNoEm*',
695 'ph_Etcone20_pt_corrected',
696 'ph_Etcone30_pt_corrected',
697 'ph_Etcone40_pt_corrected',
698 'trig_L1_emtau_thrPattern',
699 'mcevt_pdf_scale',
700
701 # fwd eles?
702 'el*_f3',
703 'el*_f3core',
704 'el*_E233',
705 'el*_E277',
706 'el*_E237',
707 'el*_weta2',
708 'el*_Ethad',
709 'el*_Ethad1',
710 'el*_depth',
711 'el*_zvertex',
712 'el*_errz',
713 'el*_etap',
714 'el*_f1core',
715 'el*_f1',
716 'el*_Emins1',
717 'el*_fside',
718 'el*_Emax2',
719 'el*_ws3',
720 'el*_wstot',
721 'el*_emaxs1',
722 'el*_Etcone40_pt_corrected',
723 'el*_Etcone35_pt_corrected',
724 'el*_Etcone30_pt_corrected',
725 'el*_Etcone25_pt_corrected',
726 'el*_Etcone20_pt_corrected',
727 'el*_Etcone15_pt_corrected',
728 'el*_nucone20',
729 'el*_nucone30',
730 'el*_nucone40',
731 'el*_ptcone20',
732 'el*_ptcone30',
733 'el*_ptcone40',
734 'el*_Etcone15',
735 'el*_Etcone20',
736 'el*_Etcone25',
737 'el*_Etcone30',
738 'el*_Etcone35',
739 'el*_Etcone40',
740 'el*_Etcone45',
741 'el*_pos7',
742 'el*_deltaeta1',
743 'el*_deltaeta2',
744 'el*_deltaphi2',
745 'el*_deltaphiRescaled',
746 'el*_rphiallcalo',
747 'el*_topoEtcone20',
748 'el*_topoEtcone30',
749 'el*_topoEtcone40',
750 'el*_deltaEs',
751 'el*_deltaEmax2',
752 'trig_EF_el_Etcone45',
753 ]),
754
755 # Changed in devval.
756 ('17.2',
757 ['StreamRDO_ref',
758 'StreamESD_ref',
759 ]),
760
761 # Changed by TriggerMenuPython in devval.
762 ('17.2',
763 ['trig_RoI_*',
764 'trig_Nav_*']),
765
766 # Changed in devval.
767 ('17.2',
768 ['trk_blayerPrediction_*',
769 ]),
770 # This also differs between 32/64 bits.
771 # For now, we're generating reference files on 32-bits, so ignore
772 # on 64-bits.
773 ('-', 'x86_64',
774 ['trk_blayerPrediction_*',
775 ]),
776
777 # TauDiscriminant changes not in AtlasProduction.
778 ('-', atlasProduction,
779 ['tau_*',
780 ]),
781
782 # MissingET-03-03-41 not in AtlasProduction.
783 # Newer version in devval.
784 ('-', atlasProduction, '/dev', '/18', '17.7', '17.X', '/mig0', 'localbuild',
785 ['MET_RefFinal_STVF_*',
786 ]),
787
788
789 # Changed in TauDiscriminant-01-07-28 in devval.
790 ('17.2',
791 ['tau_EleBDTTight',
792 ]),
793
794 # Changed in devval and in 17.2.9.
795 ('17.2.9',
796 ['mu*_SpaceTime_*',
797 ]),
798
799 # Changed in devval --- TMVA change in root 34?
800 ('17.2',
801 ['ph_NN_passes',
802 'ph_NN_discriminant',
803 ]),
804
805 # Changed by CaloClusterCorrection-00-07-74 in devval.
806 ('17.2',
807 ['*_rawcl_pt',
808 '*_rawcl_eta',
809 ]),
810
811 # TriggerD3PDMaker-00-01-99, TrigAnalysisInterfaces-00-02-00,
812 # TrigBunchCrossingTool-00-03-10, TriggerMenuNtuple-00-01-47
813 # in AtlasPhysics but not AtlasProduction...
814 ('-', atlasProduction,
815 ['UnpairedBunches',
816 'UnpairedBunchIntensities',
817 'BunchIntensities',
818 'FilledBunchIntBeam1',
819 'FilledBunchIntBeam2',
820 'UnpairedBeam1',
821 'UnpairedBeam2',
822 'UnpairedIntBeam1',
823 'UnpairedIntBeam2',
824 'trig_RoI_*',
825 'trig_Nav_*',
826 ]),
827
828 # Changed in devval.
829 ('17.2',
830 ['StreamRAW_ref']),
831
832 # Jet changes, not in AtlasProduction.
833 ('-', atlasProduction,
834 ['jet_*ActiveArea*',
835 'jet_*_jvtx_x',
836 'jet_*_jvtx_y',
837 'jet_*_jvtx_z',
838 'jet_*_jvtxfFull',
839 'jet_*_jvtxf',
840 'jet_*_nTrk',
841 'jet_*_nTrk_pv0_500MeV',
842 'jet_*_sumPtTrk',
843 'jet_*_sumPtTrk_pv0_500MeV',
844 'jet_*_flavor_component_ip3d_pc',
845 'jet_*_flavor_component_sv1_pc',
846 'jet_OriginIndex',
847 'jet_*TruthMF',
848 'jet_*TruthMFindex',
849 'jet_*CENTER_LAMBDA',
850 'jet_*SECOND_LAMBDA',
851 'jet_*SECOND_R',
852 'jet_*CLUSTER_PT',
853 'jet_antikt4truth_isBad*',
854 'jet_antikt4h1tower_isBad*',
855 'jet_antikt4h1topo_isBad*',
856 'jet_antikt6h1tower_isBad*',
857 ]),
858
859 # Changed by TrkGeometry-00-23-05 in devval.
860 ('17.2',
861 ['*_materialTraversed',
862 ]),
863
864 # Jet changes in devval.
865 ('17.2',
866 ['jet_*_ActiveArea*',
867 'jet_*_TruthMFindex',
868 'jet_*_TruthMF',
869 'jet_*_jvtxf',
870 'jet_*_jvtxfFull',
871 'jet_*_isBad*',
872 'jet_*_nTrk',
873 'jet_*_sumPtTrk',
874 'jet_*_jvtx_x',
875 'jet_*_jvtx_y',
876 'jet_*_jvtx_z',
877 'jet_*CENTER_LAMBDA',
878 'jet_*SECOND_LAMBDA',
879 'jet_*SECOND_R',
880 'jet_*CLUSTER_PT',
881 ]),
882
883 # Pool changes in devval.
884 ('17.2',
885 ['Token',
886 ]),
887
888 # Change by det descr bugfix in devval.
889 ('17.2',
890 ['ph_rawcl_etas1']),
891
892 # Changed by TrkExTools-02-37-82 in devval.
893 ('17.2',
894 ['mu_curvatureSig',
895 'mu_id_curvatureSig']),
896
897 # Changed in devval.
898 ('17.2',
899 ['mu_*neighbourSig']),
900
901 # Changed in devval.
902 ('17.2',
903 ['trig_L2_passedThrough',
904 'trig_L2_resurrected',
905 'trig_L2_passedPhysics',
906 'trig_L2_passedRaw',
907 'trig_EF_passedThrough',
908 'trig_EF_resurrected',
909 'trig_EF_passedPhysics',
910 'trig_EF_passedRaw',
911 'HLTRerunPrescaleMap',
912 ]),
913
914 # Changed in devval.
915 ('17.2',
916 ['trig_roidescriptor_forID_etaMinus',
917 'trig_roidescriptor_forID_etaPlus',
918 ]),
919
920 # Changed in devval.
921 ('17.2',
922 ['el_jettrack_*',
923 'el_trackd0pvunbiased',
924 'el_tracksigd0pvunbiased',
925 'el_trackz0pvunbiased',
926 'el_tracksigz0pvunbiased',
927 'el_trackIPEstimate*',
928 'trk_*_wrtBL',
929 'mu*_spec_surf_*',
930 ]),
931 ]
932
933
934_ignore_keys = [
935 # temp
936 ('17.2',
937 ['*Meta/ElectronD3PDObject*',
938 '*Meta/MissingETCompositionD3PDObject*',
939 '*Meta/JetD3PDObject*',
940 '*Meta/EMTauROID3PDObject*',
941 '*Meta/GenEventD3PDObject*',
942 '*Meta/RefFinalMETD3PDObject*',
943 '*Meta/TopoMETD3PDObject*',
944 '*Meta/DBKeysD3PDObject*',
945 '*Meta/TrigDecisionD3PDObject*',
946 '*Meta/TrigInDetTrackD3PDObject*',
947 '*Meta/TrigMuonEFInfoD3PDObject*',
948 '*Meta/TrigPhotonD3PDObject*',
949 '*Meta/TruthMuonD3PDObject*',
950 '*Meta/egammaTruthD3PDObject*',
951 '*Meta/MissingETTruthD3PDObject*',
952 '*Meta/MuonD3PDObject*',
953 '*Meta/MuonROID3PDObject*',
954 '*Meta/TrigDBKeysD3PDObject*',
955 '*Meta/TrigEMClusterD3PDObject*',
956 '*Meta/TrigElectronD3PDObject*',
957 '*Meta/TrigMETD3PDObject*',
958 '*Meta/TruthParticleD3PDObject*',
959 '*Meta/CombLinksD3PDObject*',
960 '*Meta/CollisionDecisionD3PDObject*',
961 '*Meta/PhotonD3PDObject*',
962 '*Meta/PrimaryVertexD3PDObject*',
963 '*Meta/TileMuFeatureD3PDObject*',
964 '*Meta/TileTrackMuFeatureD3PDObject*',
965 '*Meta/TrigMuonEFIsolationD3PDObject*',
966 '*Meta/triggerBitsD3PDObject*',
967 '*Meta/ChainEntryD3PDObject*',
968 '*Meta/ClusterD3PDObject*',
969 '*Meta/BGCodeD3PDObject*',
970 '*Meta/CorrectionClusterD3PDObject*',
971 '*Meta/EFElectronD3PDObject*',
972 '*Meta/EFPhotonD3PDObject*',
973 '*Meta/JetsInfoMETD3PDObject*',
974 '*Meta/MBTSD3PDObject*',
975 '*Meta/MBTSTimeD3PDObject*',
976 '*Meta/MBTSTriggerBitsD3PDObject*',
977 '*Meta/MuonFeatureD3PDObject*',
978 '*Meta/MuonFeatureDetailsD3PDObject*',
979 '*Meta/CombinedMuonFeatureD3PDObject*',
980 '*Meta/EmTauROID3PDObject*',
981 '*Meta/EnergySumD3PDObject*',
982 '*Meta/METD3PDObject*',
983 '*Meta/TrigRoiDescD3PDObject*',
984 '*Meta/BunchConfigIDD3PDObject*',
985 '*Meta/IsoMuonFeatureD3PDObject*',
986 '*Meta/MissingETGoodnessD3PDObject*',
987 '*Meta/EnergySumROID3PDObject*',
988 '*Meta/EventInfoD3PDObject*',
989 '*Meta/CompositeParticle*',
990 '*Meta/BunchConfTree',
991 '*Meta/TrigConfTree',
992 'egammaTrigDec',
993 'egammaTrigDecMeta/*',
994 'trigtest',
995 'trigtestMeta/*',
996 'Lumi/egamma'
997 ]),
998
999 # TauDiscriminant-01-07-19 / TauD3PDMaker-01-08-19 not in 17.2.X.Y.
1000 ('-', atlasProduction,
1001 ['*Meta/TauD3PDObject_*']),
1002
1003
1004 # JetTagD3PDMaker-00-01-89 not in AtlasProduction.
1005 ('-', atlasProduction,
1006 ['*Meta/JetD3PDObject_*']),
1007
1008
1009 # Types change when moving to 64-bit ids.
1010 ('17.2',
1011 ['trackMeta/PixelClusterD3PDObject_*']),
1012 ]
1013
1014
1015def compile_list (ignore_list):
1016 for vlist in ignore_list:
1017 l = vlist[-1]
1018 for i in range(len(l)):
1019 l[i] = re.compile (fnmatch.translate (l[i]))
1020 return
1021
1022
1023compile_list(_ignore_branches)
1024compile_list(_ignore_keys)
1025
1026
1027def get_ver():
1028 ver = os.environ.get ('CMTPATH')
1029 if ver:
1030 ver = string.split (ver, ':')
1031 ver = [s for s in ver if s.find('AtlasSetup') < 0]
1032 ver.append (os.environ.get ('CMTCONFIG'))
1033 ver = string.join (ver, ':')
1034 else:
1035 ver = 'localbuild'
1036 return ver
1037
1038
1039def ignore_p (match, ignore_list):
1040 ver = get_ver()
1041
1042 for vlist in ignore_list:
1043 vv = vlist[:-1]
1044 ignore = True
1045 if vv and vv[0] == '-':
1046 ignore = False
1047 vv = vv[1:]
1048 for v in vv:
1049 if (callable(v) and v(ver) or
1050 not callable(v) and ver and ver.find (v) >= 0):
1051 ignore = not ignore
1052 break
1053 if not ignore: continue
1054 for b in vlist[-1]:
1055 if b.match (match):
1056 return True
1057 return False
1058
1059
1060# Should a branch be ignored?
1061def ignore_br_p (br):
1062 return ignore_p (br, _ignore_branches)
1063
1064
1065def ignore_key_p (key):
1066 return ignore_p (key, _ignore_keys)
1067
1068
1069def read_val (val):
1070 if not val: return val
1071
1072 if val.find ('+') >= 0:
1073 psplit = split_list1 (val, '+')
1074 if len(psplit) > 1:
1075 #psplit = split_list1 (val, '+')
1076 #if len(psplit) > 1:
1077 good = True
1078 for i in range(len(psplit)):
1079 psplit[i] = read_val (psplit[i])
1080 if not isinstance(psplit[i], list):
1081 good = False
1082 break
1083 if good:
1084 return reduce (operator.__add__, psplit)
1085
1086 if val[-1] == 'L':
1087 try:
1088 return int(val)
1089 except TypeError:
1090 pass
1091
1092 if val[0] in '0123456789-':
1093 if val.find ('.') < 0:
1094 try:
1095 return int(val)
1096 except TypeError:
1097 pass
1098 except ValueError:
1099 pass
1100
1101 try:
1102 return float (val)
1103 except TypeError:
1104 pass
1105 except ValueError:
1106 pass
1107
1108 try:
1109 (count, elt) = val.split ('*', 1)
1110 count = int (count)
1111 if elt.startswith('[') and elt.endswith(']'):
1112 return count * [read_val(elt[1:-1])]
1113 except ValueError:
1114 pass
1115
1116 if val[0] == '[':
1117 return [read_val(s) for s in split_list(val)]
1118 return val
1119
1120
1121class Reader (object):
1122 def __init__ (self, f):
1123 self.saved = None
1124 self.f = f
1125 return
1126
1127
1128 def getline (self):
1129 if self.saved is not None:
1130 out = self.saved
1131 self.saved = None
1132 return out
1133 l = self.f.readline()
1134 if not l:
1135 return None
1136 if len(l) > 0 and l[-1] == '\n':
1137 l = l[:-1]
1138 return l
1139
1140
1141 def ungetline (self, l):
1142 assert self.saved is None
1143 self.saved = l
1144 return
1145
1146
1147class Tree (object):
1148 def __init__ (self, reader):
1149 self.dummy = False
1150 self.reader = reader
1151 self.branches = {}
1152 self.read()
1153 return
1154
1155
1156 def read (self):
1157 while True:
1158 l = self.reader.getline()
1159 if l is None: break
1160 if not l: continue
1161 if l == '[Dummy tree skipped]':
1162 self.dummy = True
1163 break
1164 if l.startswith ('Branches'):
1165 l = self.reader.getline()
1166 if not l.startswith ('-------'):
1167 self.reader.ungetline (l)
1168 break
1169 self.read_by_branches()
1170 return
1171
1172 if not l.startswith ('Event '):
1173 self.reader.ungetline (l)
1174 break
1175 iev = int(l.split()[1])
1176 l = self.reader.getline()
1177 if not l.startswith ('-------'):
1178 self.reader.ungetline (l)
1179 break
1180 self.read_branches (iev)
1181 return
1182
1183
1184 def read_by_branches (self):
1185 lasttag = ''
1186 while True:
1187 l = self.reader.getline()
1188 if not l: break
1189 if l.startswith (':'):
1190 lasttag = l[1:]
1191 continue
1192 (name, val) = l.split (None, 1)
1193 if name == '$': name = ''
1194 name = lasttag + name
1195 br = self.branches.setdefault (name, {})
1196 val = read_val (val)
1197 for (iev, v) in enumerate(val):
1198 br[iev] = v
1199 return
1200
1201
1202 def read_branches (self, iev):
1203 while True:
1204 l = self.reader.getline()
1205 if not l: break
1206 (name, val) = l.split (None, 1)
1207 br = self.branches.setdefault (name, {})
1208 br[iev] = read_val (val)
1209 return
1210
1211
1212
1213class String (object):
1214 def __init__ (self, reader):
1215 self.val = ''
1216 while True:
1217 l = reader.getline()
1218 if l is None: break
1219 ipos = l.find ('__END_OF_STRING__')
1220 if ipos >= 0:
1221 self.val = self.val + l[:ipos]
1222 break
1223 else:
1224 self.val = self.val + l + '\n'
1225 return
1226
1227
1228class Hist (object):
1229 def __init__ (self, reader):
1230 l = reader.getline()
1231 self.bins = []
1232 self.errs = []
1233 if l.startswith ('bins:'):
1234 self.bins = read_val (string.strip (l[5:]))
1235 l = reader.getline()
1236 if l.startswith ('errs:'):
1237 self.errs = read_val (string.strip (l[5:]))
1238 return
1239
1240
1241class Dumpreader (object):
1242 def __init__ (self, f):
1243 self.reader = Reader (f)
1244 self.keys = {}
1245 self.read()
1246 return
1247
1248
1249 def read (self):
1250 while True:
1251 l = self.reader.getline()
1252 if l is None: break
1253 if not l: continue
1254 if l.find ('wrong interface id') >= 0: continue
1255 ll = l.split()
1256 if len(ll) != 2:
1257 print ('Unknown line', l)
1258 break
1259 (typ, key) = ll
1260 if typ == 'Tree':
1261 self.keys[key] = Tree (self.reader)
1262 elif typ == 'String':
1263 self.keys[key] = String (self.reader)
1264 elif typ == 'TH1':
1265 self.keys[key] = Hist (self.reader)
1266 else:
1267 print ('Unknown type', typ)
1268 break
1269
1270
1271 def read_tree (self):
1272 return None
1273
1274
1275def dictkey_diff (d1, d2, msg, filter = None):
1276 keys = [k for k in d1.keys() if k not in d2]
1277 if filter: keys = [k for k in keys if not filter(k)]
1278 if keys:
1279 keys.sort()
1280 print (msg)
1281 for k in keys:
1282 print (' ', k)
1283 return
1284
1285
1286def apply_renames (d1, d2, renames):
1287 for (knew, kold) in renames.items():
1288 if (d2.has_key (kold) and not d2.has_key (knew) and
1289 not d1.has_key (kold) and d1.has_key (knew)):
1290 d2[knew] = d2[kold]
1291 del d2[kold]
1292 return
1293
1294
1295def diff_string (k, s1, s2):
1296 if s1.val != s2.val:
1297 print ('String', k, 'has value', s1.val,
1298 'in new file but value', s2.val, 'in reference file')
1299 return
1300
1301
1302inttypes = [types.IntType, types.LongType]
1303def compare (o1, o2, thresh = 1e-6, ithresh = None, eltcmp = None):
1304 if eltcmp and not isinstance(o1, list):
1305 return eltcmp (o1, o2)
1306 # Allow comparing int/long int.
1307 if type(o1) in inttypes and type(o2) in inttypes:
1308 if o1 < 0: o1 = o1 + (1<<32)
1309 if o2 < 0: o2 = o2 + (1<<32)
1310 return o1 == o2
1311 # Promote int to float if needed.
1312 if type(o1) in inttypes and isinstance(o2, float):
1313 o1 = float(o1)
1314 elif type(o2) in inttypes and isinstance(o1, float):
1315 o2 = float(o2)
1316
1317 if type(o1) is not type(o2):
1318 return False
1319 if isinstance(o1, list):
1320 if len(o1) != len(o2):
1321 return False
1322
1323 # Inline this to speed up this common case.
1324 if len(o1) > 0 and isinstance(o1[0], float) and not ithresh and not callable(thresh) and not eltcmp:
1325 xabs = abs
1326 for i in range(len(o1)):
1327 x1 = o1[i]
1328 x2 = o2[i]
1329 ax1 = xabs(x1)
1330 ax2 = xabs(x2)
1331 num = x1-x2
1332 den = ax1 + ax2
1333 if den == 0: continue
1334 x = xabs(num / den)
1335 if x > thresh:
1336 print ('fnmismatch', x1, x2, x, thresh)
1337 return False
1338 return True
1339
1340 for i in range(len(o1)):
1341 if not compare (o1[i], o2[i],
1342 thresh=thresh,
1343 ithresh=ithresh,
1344 eltcmp=eltcmp):
1345 return False
1346 return True
1347 if type(o1).__name__ in ['map<string,int>',
1348 'map<string,float>',
1349 'map<string,string>']:
1350 return ROOT.D3PDTest.MapDumper.equal (o1, o2)
1351 if isinstance(o1, float):
1352 if callable(ithresh):
1353 ret = ithresh(o1, o2)
1354 if ret is True or ret is False: return ret
1355 elif ithresh and abs(o1) < ithresh and abs(o2) < ithresh:
1356 return True
1357 num = o1-o2
1358 den = abs(o1)+abs(o2)
1359 if den == 0: return True
1360 x = abs(num / den)
1361 if callable(thresh): thresh = thresh(den)
1362 if x > thresh:
1363 print ('fmismatch', o1, o2, x, thresh)
1364 return False
1365 return True
1366 return o1 == o2
1367
1368
1369def mc_eta_thresh (x):
1370 if x > 36: return 1e-2
1371 if x > 34: return 2e-3
1372 if x > 32: return 2e-4
1373 if x > 30: return 1e-4
1374 if x > 28: return 1e-5
1375 return 1e-6
1376
1377
1378def eg_pid_compare (o1, o2):
1379 if o1 == 0xffffffff and o2 == 0: return True
1380 return None
1381
1382
1383def compare_detElementId (o1, o2):
1384 if o1 == o2: return True
1385 if o1 == (o2 << 32): return True
1386 return False
1387
1388
1389def compare_pixid (o1, o2):
1390 if o1 == o2: return True
1391 o2a = ((o2&0x7fffffff)-1)<<28
1392 if o1 == o2a : return True
1393 return False
1394
1395
1396def compare_abs (o1, o2):
1397 return compare (abs(o1), abs(o2))
1398
1399
1400branch_thresh = [
1401
1402 ['mu*_cov_theta_qoverp_exPV' , (2e-2, 2e-14)],
1403 ['mu_cov_phi_exPV' , 4e-4],
1404 ['mu*_cov_*_exPV' , 1e-2],
1405 ['mu*_d0_exPV' , 5e-3],
1406 ['mu*_z0_exPV' , 2e-5],
1407 ['mu*_theta_exPV' , 1e-5],
1408 ['mu*_spec_surf_*' , 6e-2],
1409 ['mu*_trackz0pv' , 2e-6],
1410 ['mu*_trackd0pv' , 1e-5],
1411 ['mu*_trackz0pvunbiased' , 2e-6],
1412 ['mu*_trackd0pvunbiased' , 1e-5],
1413 ['mu*_trackd0beam' , 2e-5],
1414 ['mu*_trackIPEstimate_d0_unbiasedpvunbiased', 1e-5],
1415 ['mu*_trackIPEstimate_z0_unbiasedpvunbiased', 1e-5],
1416 ['mu*_trackIPEstimate_d0_biasedpvunbiased', 1e-5],
1417 ['mu*_trackIPEstimate_z0_biasedpvunbiased', 1e-5],
1418
1419 ['trk_z0_wrtPV' , 2e-4],
1420 ['trk_d0_wrtPV' , 2e-4],
1421 ['trk_phi_wrtPV' , 1e-4],
1422
1423 ['trk_err_theta_wrtPV' , 1e-5],
1424 ['trk_err_phi_wrtPV' , 2e-5],
1425
1426 ['trk_phi_wrtBL' , 2e-2],
1427 ['trk_z0_wrtBL' , 1],
1428 ['trk_d0_wrtBL' , 3e-1],
1429
1430 ['trk_theta_err_wrtBL' , 3e-2],
1431 ['trk_qoverp_err_wrtBL' , 1e-4],
1432 ['trk_phi_err_wrtBL' , 3e-2],
1433 ['trk_z0_err_wrtBL' , 6e-2],
1434 ['trk_d0_err_wrtBL' , 7e-2],
1435
1436 ['trk_d0_phi_err_wrtBL' , 1e-1],
1437 ['trk_d0_qoverp_err_wrtBL' , 4e-3],
1438 ['trk_d0_theta_err_wrtBL' , 1],
1439 ['trk_d0_z0_err_wrtBL' , 1],
1440 ['trk_phi_theta_err_wrtBL' , 1],
1441 ['trk_phi_qoverp_err_wrtBL' , 4e-3],
1442 ['trk_theta_qoverp_err_wrtBL' , 1],
1443 ['trk_z0_phi_err_wrtBL' , 1],
1444 ['trk_z0_qoverp_err_wrtBL' , 1],
1445 ['trk_z0_theta_err_wrtBL' , 8e-2],
1446
1447 ['trk_d0_wrtBS' , 2e-4],
1448 ['trk_z0_wrtBS' , 5e-5],
1449 ['trk_phi_wrtBS' , 5e-5],
1450
1451 ['trk_err_theta_wrtBS' , 1e-5],
1452 ['trk_err_phi_wrtBS' , 2e-5],
1453
1454 ['trk_cov_theta_qoverp_wrtBS' , (4e-1, 1e-14)],
1455 ['trk_cov_phi_theta_wrtBS' , 5e-2],
1456 ['trk_cov_phi_qoverp_wrtBS' , 4e-5],
1457 ['trk_cov_z0_qoverp_wrtBS' , 5e-3],
1458 ['trk_cov_z0_phi_wrtBS' , 2e-3],
1459 ['trk_cov_z0_theta_wrtBS' , 1e-5],
1460 ['trk_cov_d0_phi_wrtBS' , 1e-5],
1461 ['trk_cov_d0_z0_wrtBS' , 3e-1],
1462 ['trk_cov_d0_theta_wrtBS' , 6e-3],
1463
1464 ['trk_mc_z0' , 4e-2],
1465 ['trk_mc_d0' , 2e-2],
1466 ['trk_mc_phi' , 2e-2],
1467 ['trk_mc_theta' , 1e-3],
1468
1469 ['vxp_trk_d0' , (9e-4, 2e-4)],
1470 ['vxp_trk_z0' , 9e-4],
1471 ['vxp_trk_phi' , 5e-5],
1472 ['vxp_trk_theta' , 2e-5],
1473 ['vxp_trk_unbiased_d0' , (1e-3, 2e-4)],
1474 ['vxp_trk_unbiased_z0' , 1e-3],
1475
1476 ['el*_jettrack_m' , 6e-6],
1477 ['el*_jettrack_reducedPt' , 2e-6],
1478 ['el*_jettrack_ptrel' , 1e-5],
1479 ['el*_jettrack_dr' , 1e-5],
1480 ['el*_jettrack_phi' , 1e-5],
1481
1482 ['el*_jetcone_dr' , 1e-5],
1483 ['el*_jetcone_ptrel' , 2e-5],
1484
1485 ['el*_refittedTrack_d0_err_wrtBL' , 1e-4],
1486 ['el*_refittedTrack_phi_err_wrtBL' , 3e-3],
1487 ['el*_refittedTrack_theta_err_wrtBL' , 4e-5],
1488 ['el*_refittedTrack_phi_theta_err_wrtBL', (2e-2, 1e-10)],
1489 ['el*_refittedTrack_phi_qoverp_err_wrtBL', 5e-3],
1490 ['el*_refittedTrack_theta_qoverp_err_wrtBL', 1],
1491 ['el*_refittedTrack_z0_theta_err_wrtBL', 3e-4],
1492 ['el*_refittedTrack_z0_qoverp_err_wrtBL', 6e-3],
1493 ['el*_refittedTrack_z0_phi_err_wrtBL', 9e-3],
1494 ['el*_refittedTrack_d0_wrtBL' , 6e-4],
1495 ['el*_refittedTrack_d0_phi_err_wrtBL', 3e-3],
1496 ['el*_refittedTrack_d0_z0_err_wrtBL', 5e-4],
1497 ['el*_refittedTrack_d0_theta_err_wrtBL', 6e-2],
1498 ['el*_refittedTrack_d0_qoverp_err_wrtBL', 6e-4],
1499 ['el*_tracksigz0pvunbiased' , 1e-5],
1500 ['el*_trackz0pvunbiased' , 7e-4],
1501 ['el*_trackd0pvunbiased' , 2e-4],
1502 ['el*_trackz0pv' , 6e-4],
1503 ['el*_trackd0pv' , 1e-4],
1504 ['el*_trackz0beam' , 4e-5],
1505 ['el*_trackd0beam' , 1e-3],
1506 ['el*_trackIPEstimate_z0_unbiasedpvunbiased', 1e-3],
1507 ['el*_trackIPEstimate_d0_unbiasedpvunbiased', 2e-4],
1508 ['el*_trackIPEstimate_sigz0_unbiasedpvunbiased', 1e-5],
1509 ['el*_trackIPEstimate_z0_biasedpvunbiased', 6e-4],
1510 ['el*_trackIPEstimate_d0_biasedpvunbiased', 1e-4],
1511 ['el*_trackIPEstimate_sigz0_biasedpvunbiased', 1e-5],
1512 ['el*_m', (1e-4, 2e-3)],
1513 ['ph*_m', (1e-4, 2e-3)],
1514 ['mu*_m', (1e-4, 2e-3)],
1515 ['trig_EF_el*_m', (1e-4, 2e-3)],
1516 ['trig_EF_ph*_m', (1e-4, 2e-3)],
1517
1518 ['*_cl_eta0Calo', 1e-3],
1519 ['*_cl_etaCalo', 1e-3],
1520
1521 ['ph_vx_Dist' , (6e-4, 2e-2)],
1522
1523 ['egtruth_phiCalo' , 3e-5],
1524 ['egtruth_etaCalo' , 6e-5],
1525
1526 ]
1527
1528for l in branch_thresh:
1529 l[0] = re.compile (fnmatch.translate (l[0]))
1530
1531
1532def diff_branch (k, kb, v1, v2):
1533 head = '%s branch %s:' % (k, kb)
1534 ev1 = v1.keys()
1535 ev2 = v2.keys()
1536 ev1.sort()
1537 ev2.sort()
1538 if ev1 != ev2:
1539 if ignore_event_differences:
1540 ev1 = list(set(ev1).intersection(set(ev2)))
1541 ev1.sort()
1542 else:
1543 print (head, 'Different set of events; new file: ',
1544 ev1, 'reference file', ev2)
1545 return
1546
1547 ithresh = None
1548 eltcmp = None
1549
1550 thresh = 1e-6
1551 for (pat, th) in branch_thresh:
1552 if pat.match (kb):
1553 if isinstance(th, tuple):
1554 thresh = th[0]
1555 ithresh = th[1]
1556 else:
1557 thresh = th
1558 break
1559
1560 # GSF reco run in d3pd job, so we have dbg/opt diffs.
1561 if kb.startswith ('el_gsf_'): thresh = 1e-4
1562 if kb == 'el_gsf_deltaeta2': thresh = 3e-3
1563 if kb == 'el_gsf_deltaphi2': thresh = 2e-1
1564 if kb == 'el_gsf_deltaphiRescaled': thresh = 2e-2
1565 if kb == 'el_gsf_deltaeta1': thresh = 3e-3
1566 if kb == 'el_gsf_trackz0pv': thresh = 1e-1
1567 if kb == 'el_gsf_covqoverp': thresh = 5e-2
1568 if kb == 'el_gsf_L2_dr': thresh = 3e-2
1569 if kb == 'el_gsf_EF_dr': thresh = 7e-2
1570 if kb == 'el_gsf_covd0theta': thresh = 3e-4
1571 if kb == 'el_gsf_electronweight': thresh = 2e-2
1572 if kb == 'el_gsf_electronbgweight': thresh = 3e-1
1573 if kb == 'el_gsf_adaboost': thresh = 7e-2
1574 if kb == 'el_gsf_neuralnet': thresh = 2e-1
1575 if kb == 'el_gsf_isolationlikelihoodhqelectrons': thresh = 4e-2
1576 if kb == 'el_gsf_jet_dr': thresh = 2e-2
1577 if kb == 'el_gsf_Et': thresh = 3e-3
1578 if kb == 'el_gsf_E': thresh = 4e-3
1579 if kb == 'sc_yCells': thresh = 2e-6
1580 if kb.startswith ('el_gsf_p'): thresh = 3e-3
1581 if kb.startswith ('el_gsf_refittedTrack_cov'): thresh = 3e-1
1582 if kb.startswith ('el_gsf_trackcov'): thresh = 5e-1
1583 if kb.startswith ('el_gsf_tracksig'): thresh = 4e-2
1584 if kb.startswith ('el_gsf_trackd0'): thresh = 6e-2
1585 if kb.startswith ('el_gsf_trackz0'): thresh = 3e-2
1586 if kb.startswith ('el_gsf_trackfitchi2'): thresh = 7e-3
1587 if kb.startswith ('el_gsf_trackqoverp'): thresh = 2e-2
1588 if kb.startswith ('el_gsf_trackpt'): thresh = 2e-2
1589 if kb.startswith ('el_gsf_refittedTrack_d0'): thresh = 3e-3
1590 if kb.startswith ('el_gsf_refittedTrack_LMqoverp'): thresh = 3e-3
1591 if kb.startswith ('el_gsf_refittedTrack_qoverp'): thresh = 2e-2
1592 if kb.startswith ('el_gsf_refittedTrack_covphitheta'): thresh = 5e-1
1593 if kb.startswith ('el_gsf_mvaptcone'): ithresh = 1e-10
1594 if kb == 'el_gsf_m':
1595 thresh = 2e-2
1596 ithresh = 0.01
1597
1598 if kb.find('jet_')>=0 and kb.endswith ('_m'): ithresh = 0.1
1599 if kb.find('jetcone_')>=0 and kb.endswith ('_m'): ithresh = 1e-3
1600 if kb.find('muonTruth_')>=0 and kb.endswith ('_m'): ithresh = 0.5
1601 if kb == 'mc_m':
1602 ithresh = 0.1
1603 thresh = 2e-5
1604 if kb.endswith ('_effTopoInvMass'): thresh = 1e-2
1605 if kb.endswith ('_topoInvMass'): thresh = 1e-2
1606 if (kb.endswith ('_topoMeanDeltaR') or
1607 kb.endswith ('_effTopoMeanDeltaR')):
1608 ithresh = 1e-6
1609 if kb.find ('_rawcl_etas') >= 0: thresh = 2e-4
1610 if kb.endswith ('_convIP'): thresh = 4e-4
1611 if kb.endswith ('_convIPRev'): thresh = 6e-5
1612 if kb.endswith ('_emscale_E'): thresh = 9e-5
1613 if kb.endswith ('_emscale_eta'): thresh = 9e-5
1614 if kb.endswith ('_emscale_m'): ithresh = 0.1
1615 if kb.endswith ('_constscale_E'): thresh = 9e-5
1616 if kb.endswith ('_constscale_eta'): thresh = 9e-5
1617 if kb == 'mc_eta': thresh = mc_eta_thresh
1618 if kb.endswith ('_seg_locX'): ithresh = 2e-12
1619 if kb.endswith ('_seg_locY'): ithresh = 2e-12
1620 if kb == 'MET_Goodness_DeltaEt_JetAlgs_Jet': ithresh = 3e-11
1621 if kb == 'MET_Goodness_EEM_Jet': thresh = 2e-5
1622 if kb == 'MET_Goodness_HECf_Jet': thresh = 3e-6
1623 if kb.find ('_blayerPrediction') >= 0: thresh = 1e-2
1624 if kb.endswith ('_hecf'): thresh = 4e-6
1625 if kb.endswith ('_SpaceTime_t'): thresh = 4e-6
1626 if kb.endswith ('_SpaceTime_weight'): thresh = 2e-5
1627 if kb.endswith ('_SpaceTime_tError'): thresh = 8e-6
1628 if kb.endswith ('_calcVars_ChPiEMEOverCaloEME'): thresh = 1e-5
1629 if kb.endswith ('_vx_m'): ithresh = 1e-2
1630 if kb.endswith ('MET_Goodness_DeltaEt_JetAlgs_Jet'): ithresh = 1e-10
1631
1632 # Diffs btn 32/64-bit
1633 if kb == 'mc_perigee_theta': thresh = 1
1634 if kb == 'mc_perigee_d0': thresh = 1
1635 if kb == 'mc_perigee_phi': thresh = 1 #(ev 2,9)
1636 if kb == 'mc_perigee_z0': thresh = 1
1637 if kb == 'tau_likelihood': thresh = 1e-5
1638 if kb == 'tau_SafeLikelihood': thresh = 1e-5
1639 if kb == 'el_gsf_softeweight': thresh = 1e-1
1640 if kb == 'el_gsf_softebgweight': thresh = 2e-2
1641
1642 if kb.endswith ('_mvaptcone20'): ithresh = 1e-10
1643 if kb.endswith ('_mvaptcone30'): ithresh = 1e-10
1644 if kb.endswith ('_mvaptcone40'): ithresh = 1e-10
1645
1646 # more 32/64 dbg/opt diffs
1647 if kb == 'tau_SafeLikelihood': thresh = 0.4
1648 if kb == 'tau_likelihood': thresh = 0.4
1649 if kb == 'tau_BDTJetScore': thresh = 1.0
1650 if kb == 'tau_calcVars_corrFTrk': thresh = 0.02
1651 if kb == 'tau_calcVars_corrCentFrac': thresh = 0.4
1652 if kb == 'tau_JetBDTSigLoose': thresh = 1.0
1653 if kb == 'tau_JetBDTSigMedium': thresh = 1.0
1654 if kb == 'tau_JetBDTSigTight': thresh = 1.0
1655 if kb == 'tau_tauLlhMedium': thresh = 1.0
1656 if kb == 'tau_pi0_cl1_pt': thresh = 1e-5
1657
1658 if kb.endswith ('_neighbourSig'): thresh = 1e-4
1659 if kb.endswith ('_curvatureSig'): thresh = 1e-4
1660
1661 if kb == 'pixClus_detElementId': eltcmp = compare_detElementId
1662 if kb == 'pixClus_id': eltcmp = compare_pixid
1663 if kb == 'trig_EF_emcl_pt': eltcmp = compare_abs
1664
1665 for e in ev1:
1666 head = '%s branch %s event %d:' % (k, kb, e)
1667 b1 = v1[e]
1668 b2 = v2[e]
1669
1670 # Promote int to float if needed.
1671 if type(b1) in inttypes and isinstance(b2, float):
1672 b1 = float(b1)
1673 elif type(b2) in inttypes and isinstance(b1, float):
1674 b2 = float(b2)
1675
1676 if type(b1) is not type(b2):
1677 print (head, 'Type differs; new file: ', type(b1).__name__,
1678 'reference file:', type(b2).__name__)
1679 elif not compare (b1, b2, thresh = thresh, ithresh = ithresh,
1680 eltcmp = eltcmp):
1681 print (head, 'Branch mismatch')
1682 print (' new file:', b1)
1683 print (' ref file:', b2)
1684
1685 return
1686
1687def diff_tree (k, t1, t2):
1688 if t1.dummy and t2.dummy: return
1689 apply_renames (t1.branches, t2.branches, renames)
1690 dictkey_diff (t1.branches, t2.branches, '%s: Branches only in new file:'%k,
1691 ignore_br_p)
1692 dictkey_diff (t2.branches, t1.branches, '%s: Branches only in reference file:'%k,
1693 ignore_br_p)
1694 for kb in t1.branches:
1695 if t2.branches.has_key (kb):
1696 if not ignore_br_p(kb):
1697 diff_branch (k, kb, t1.branches[kb], t2.branches[kb])
1698 return
1699
1700
1701def diff_hist (k, h1, h2):
1702 if not compare (h1.bins, h2.bins):
1703 print ('Hist', k, 'has bins', h1.bins)
1704 print ('in new file but bins', h2.bins)
1705 print ('in reference file')
1706 if not compare (h1.errs, h2.errs):
1707 print ('Hist', k, 'has errs', h1.errs)
1708 print ('in new file but errs', h2.errs)
1709 print ('in reference file')
1710 return
1711
1712
1713def diff_files (d1, d2):
1714 apply_renames (d1.keys, d2.keys, rename_keys)
1715 dictkey_diff (d1.keys, d2.keys, 'Keys only in new file:',
1716 ignore_key_p)
1717 dictkey_diff (d2.keys, d1.keys, 'Keys only in reference file:',
1718 ignore_key_p)
1719 for k in d1.keys.keys():
1720 if k in d2.keys and not ignore_key_p (k):
1721 v1 = d1.keys[k]
1722 v2 = d2.keys[k]
1723 if type(v1) is not type(v2):
1724 print ('Key', k, 'has type', type(v1).__name__,
1725 'in new file, but type', type(v2).__name__,
1726 'in reference file')
1727 elif type(v1) is String:
1728 diff_string (k, v1, v2)
1729 elif type(v1) is Tree:
1730 diff_tree (k, v1, v2)
1731 elif type(v1) is Hist:
1732 diff_hist (k, v1, v2)
1733 else:
1734 print ('Unknown type for diff:', type(v1).__name__)
1735 return
1736
1737
1738if __name__ == '__main__':
1739 import sys
1740 import subprocess
1741
1742 if sys.argv[1] == '--ignore-event-differences':
1743 ignore_event_differences = True
1744 del sys.argv[1]
1745
1746 # New tuple
1747 p = subprocess.Popen ('python -m D3PDMakerTest.dumptuple_any %s' %
1748 sys.argv[1],
1749 shell = True,
1750 stdout = subprocess.PIPE)
1751 d1 = Dumpreader (p.stdout)
1752 # Reference file
1753 d2 = Dumpreader (open (sys.argv[2]))
1754
1755 diff_files (d1, d2)
1756
1757
Definition Tree.h:18
STL class.
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)