17 from functools
import reduce
18 from D3PDMakerTest.split_list
import split_list, split_list1
20 ignore_event_differences =
False
29 'caloMeta/EventInfoD3PDObject_000005' :
'caloMeta/EventInfoD3PDObject_000004',
30 'physicsMeta/EventInfoD3PDObject_000003' :
'physicsMeta/EventInfoD3PDObject_000002',
31 'physicsTrigDecMeta/EventInfoD3PDObject_000004' :
'physicsTrigDecMeta/EventInfoD3PDObject_000003',
36 (ver.find(
'17.2')>=0
or
37 ver.find(
'17.3')>=0)
and
39 ver.find(
'AtlasPhysics')==-1
and
40 ver.find(
'usatlas+u/snyder')==-1)
58 'trig_roidescriptor_*',
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_*',
85 'trig_EF_trigmuonefisolation_*',
87 'trig_EF_trigmugirl_*',
96 '*_BCH_CORR_JET_FORCELL',
100 '*_BAD_CELLS_CORR_E',
110 'trig_EF_el*_isEMLoose',
112 'trig_EF_el*_isEMMedium',
114 'trig_EF_el*_isEMTight',
116 'trig_EF_el*_looseIso',
118 'trig_EF_el*_mediumIso',
120 'trig_EF_el*_tightIso',
122 'trig_EF_el*_loosePP',
124 'trig_EF_el*_loosePPIso',
126 'trig_EF_el*_mediumPP',
128 'trig_EF_el*_mediumPPIso',
130 'trig_EF_el*_tightPP',
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',
144 'trig_EF_el*_medium',
150 'el*_convanglematch',
151 'el*_convtrackmatch',
153 'trig_EF_el*_etacorrmag',
154 'el*_deltaPhiFromLast',
156 'el*_trackd0_physics',
157 'trig_EF_el*_trackd0_physics',
167 'el*_convtrk1nBLHits',
168 'el*_convtrk1nPixHits',
169 'el*_convtrk1nSCTHits',
170 'el*_convtrk1nTRTHits',
172 'el*_convtrk2nBLHits',
173 'el*_convtrk2nPixHits',
174 'el*_convtrk2nSCTHits',
175 'el*_convtrk2nTRTHits',
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',
192 'el*_isolationlikelihoodjets',
193 'el*_isolationlikelihoodhqelectrons',
194 'el*_electronweight',
195 'el*_electronbgweight',
202 'el*_softeneuralnet',
204 'el*_refittedTrack_*',
205 'el*_nPixSharedHits',
207 'trig_EF_el*_nPixSplitHits',
209 'trig_EF_el*_nPixHoles',
210 'el*_nSCTSharedHits',
211 'el*_nSCTDoubleHoles',
213 'trig_EF_el*_nTRTHoles',
215 'trig_EF_el*_nSCTHoles',
216 'el*_nSCTDeadSensors',
217 'trig_EF_el*_nSCTDeadSensors',
218 'el*_nBLayerSplitHits',
219 'trig_EF_el*_nBLayerSplitHits',
221 'el*_nPixelDeadSensors',
222 'trig_EF_el*_nPixelDeadSensors',
224 'trig_EF_el*_nTRTXenonHits',
240 'el*_Etcone40_ED_corrected',
241 'el*_Etcone40_corrected',
242 'el*_topoEtcone20_corrected',
243 'el*_topoEtcone30_corrected',
244 'el*_topoEtcone40_corrected',
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',
261 'trig_EF_el*_massPixeldEdx',
262 'el*_nGoodHitsPixeldEdx',
263 'trig_EF_el*_nGoodHitsPixeldEdx',
265 'trig_EF_el*_pixeldEdx',
267 'trig_EF_el*_nSiHits',
268 'el*_nSingleTrackConv',
269 'el*_nDoubleTrackConv',
271 'el*_CaloPointing_*',
276 'el*_truth_mothercharge',
277 'el*_truth_motherstatus',
278 'mcevt_event_number',
279 'mcevt_signal_process_id',
301 'trig_EF_ph*_isEMLoose',
303 'trig_EF_ph*_isEMMedium',
305 'trig_EF_ph*_isEMTight',
321 'ph*_truth_motherbarcode',
322 'ph*_truth_mothertype',
323 'ph*_truth_mothercharge',
324 'ph*_truth_motherstatus',
327 'ph*_deltaRRecPhoton',
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',
344 'ph*_photonbgweight',
355 'ph*_convMatchDeltaPhi1',
356 'ph*_convMatchDeltaPhi2',
357 'ph*_convMatchDeltaEta1',
358 'ph*_convMatchDeltaEta2',
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',
409 'ph*_CaloPointing_eta',
410 'ph*_CaloPointing_sigma_eta',
411 'ph*_CaloPointing_zvertex',
412 'ph*_CaloPointing_sigma_zvertex',
416 'ph*_HPV_sigma_zvertex',
418 'ph*_NN_discriminant',
428 'ph*_Etcone40_ED_corrected',
429 'ph*_Etcone40_corrected',
433 'ph*_convanglematch',
438 'trig_EF_ph*_convanglematch',
439 'ph*_convtrackmatch',
440 'trig_EF_ph*_convtrackmatch',
442 'trig_EF_ph*_isRecovered',
444 'trig_EF_ph*_looseAR',
446 'trig_EF_ph*_looseARIso',
448 'trig_EF_ph*_tightAR',
450 'trig_EF_ph*_tightARIso',
452 'trig_EF_ph*_tightIso',
454 'trig_EF_ph*_looseIso',
455 'ph*_topoEtcone20_corrected',
456 'ph*_topoEtcone30_corrected',
457 'ph*_topoEtcone40_corrected',
459 'el*_Unrefittedtrack_*',
479 'mu*_caloLRLikelihood',
482 'mu*_isStandAloneMuon',
483 'mu*_isCombinedMuon',
484 'mu*_isLowPtReconstructedMuon',
485 'mu*_isSegmentTaggedMuon',
487 'mu*_alsoFoundByLowPt',
488 'mu*_alsoFoundByCaloMuonId',
489 'mu*_isSiliconAssociatedForwardMuon',
494 'mu*_cov_qoverp_exPV',
495 'mu*_cov_theta_exPV',
499 'mu*_err_qoverp_exPV',
500 'mu*_err_theta_exPV',
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',
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',
553 'mu*_phiLayer1Holes',
554 'mu*_phiLayer2Holes',
555 'mu*_phiLayer3Holes',
556 'mu*_phiLayer4Holes',
557 'mu*_etaLayer1Holes',
558 'mu*_etaLayer2Holes',
559 'mu*_etaLayer3Holes',
560 'mu*_etaLayer4Holes',
565 'mu*_nCSCUnspoiledEtaHits',
578 'mu*_nTRTDeadStraws',
579 'mu*_ntrigEtaLayers',
582 'mu*_nprecisionLayers',
594 'mu*_truth_mothertype',
595 'mu*_truth_motherbarcode',
599 'mu*_isMuonLikelihood',
600 'mu*_trackIPEstimate_*unbiased',
601 'mu*_track*unbiased',
605 'mu*_truth_mothercharge',
606 'mu*_truth_motherstatus',
610 'mu*_numberOfSegments',
616 'vxp_trk_unbiased_z0',
617 'vxp_trk_unbiased_d0',
618 'vxp_trk_err_unbiased_z0',
619 'vxp_trk_err_unbiased_d0',
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',
654 'trig_L1_mu_thrValue',
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',
681 'trig_EF_el_ptcone20',
695 'ph_Etcone20_pt_corrected',
696 'ph_Etcone30_pt_corrected',
697 'ph_Etcone40_pt_corrected',
698 'trig_L1_emtau_thrPattern',
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',
745 'el*_deltaphiRescaled',
752 'trig_EF_el_Etcone45',
768 [
'trk_blayerPrediction_*',
774 [
'trk_blayerPrediction_*',
778 (
'-', atlasProduction,
784 (
'-', atlasProduction,
'/dev',
'/18',
'17.7',
'17.X',
'/mig0',
'localbuild',
785 [
'MET_RefFinal_STVF_*',
802 'ph_NN_discriminant',
814 (
'-', atlasProduction,
816 'UnpairedBunchIntensities',
818 'FilledBunchIntBeam1',
819 'FilledBunchIntBeam2',
833 (
'-', atlasProduction,
841 'jet_*_nTrk_pv0_500MeV',
843 'jet_*_sumPtTrk_pv0_500MeV',
844 'jet_*_flavor_component_ip3d_pc',
845 'jet_*_flavor_component_sv1_pc',
849 'jet_*CENTER_LAMBDA',
850 'jet_*SECOND_LAMBDA',
853 'jet_antikt4truth_isBad*',
854 'jet_antikt4h1tower_isBad*',
855 'jet_antikt4h1topo_isBad*',
856 'jet_antikt6h1tower_isBad*',
861 [
'*_materialTraversed',
866 [
'jet_*_ActiveArea*',
867 'jet_*_TruthMFindex',
877 'jet_*CENTER_LAMBDA',
878 'jet_*SECOND_LAMBDA',
895 'mu_id_curvatureSig']),
899 [
'mu_*neighbourSig']),
903 [
'trig_L2_passedThrough',
904 'trig_L2_resurrected',
905 'trig_L2_passedPhysics',
907 'trig_EF_passedThrough',
908 'trig_EF_resurrected',
909 'trig_EF_passedPhysics',
911 'HLTRerunPrescaleMap',
916 [
'trig_roidescriptor_forID_etaMinus',
917 'trig_roidescriptor_forID_etaPlus',
923 'el_trackd0pvunbiased',
924 'el_tracksigd0pvunbiased',
925 'el_trackz0pvunbiased',
926 'el_tracksigz0pvunbiased',
927 'el_trackIPEstimate*',
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',
993 'egammaTrigDecMeta/*',
1000 (
'-', atlasProduction,
1001 [
'*Meta/TauD3PDObject_*']),
1005 (
'-', atlasProduction,
1006 [
'*Meta/JetD3PDObject_*']),
1011 [
'trackMeta/PixelClusterD3PDObject_*']),
1015 def compile_list (ignore_list):
1016 for vlist
in ignore_list:
1018 for i
in range(len(l)):
1019 l[i] = re.compile (fnmatch.translate (l[i]))
1023 compile_list(_ignore_branches)
1024 compile_list(_ignore_keys)
1028 ver = os.environ.get (
'CMTPATH')
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,
':')
1042 for vlist
in ignore_list:
1045 if vv
and vv[0] ==
'-':
1049 if (callable(v)
and v(ver)
or
1050 not callable(v)
and ver
and ver.find (v) >= 0):
1053 if not ignore:
continue
1061 def ignore_br_p (br):
1062 return ignore_p (br, _ignore_branches)
1065 def ignore_key_p (key):
1066 return ignore_p (key, _ignore_keys)
1070 if not val:
return val
1072 if val.find (
'+') >= 0:
1073 psplit = split_list1 (val,
'+')
1078 for i
in range(len(psplit)):
1079 psplit[i] = read_val (psplit[i])
1080 if not isinstance(psplit[i], list):
1084 return reduce (operator.__add__, psplit)
1092 if val[0]
in '0123456789-':
1093 if val.find (
'.') < 0:
1109 (count, elt) = val.split (
'*', 1)
1111 if elt.startswith(
'[')
and elt.endswith(
']'):
1112 return count * [read_val(elt[1:-1])]
1117 return [read_val(s)
for s
in split_list(val)]
1129 if self.saved
is not None:
1133 l = self.f.readline()
1136 if len(l) > 0
and l[-1] ==
'\n':
1141 def ungetline (self, l):
1142 assert self.saved
is None
1150 self.reader = reader
1158 l = self.reader.getline()
1161 if l ==
'[Dummy tree skipped]':
1164 if l.startswith (
'Branches'):
1165 l = self.reader.getline()
1166 if not l.startswith (
'-------'):
1167 self.reader.ungetline (l)
1169 self.read_by_branches()
1172 if not l.startswith (
'Event '):
1173 self.reader.ungetline (l)
1175 iev =
int(l.split()[1])
1176 l = self.reader.getline()
1177 if not l.startswith (
'-------'):
1178 self.reader.ungetline (l)
1180 self.read_branches (iev)
1184 def read_by_branches (self):
1187 l = self.reader.getline()
1189 if l.startswith (
':'):
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):
1202 def read_branches (self, iev):
1204 l = self.reader.getline()
1206 (name, val) = l.split (
None, 1)
1207 br = self.branches.setdefault (name, {})
1208 br[iev] = read_val (val)
1217 l = reader.getline()
1219 ipos = l.find (
'__END_OF_STRING__')
1221 self.val = self.val + l[:ipos]
1224 self.val = self.val + l +
'\n'
1230 l = reader.getline()
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:]))
1241 class Dumpreader (
object):
1243 self.reader = Reader (f)
1251 l = self.reader.getline()
1254 if l.find (
'wrong interface id') >= 0:
continue
1257 print (
'Unknown line', l)
1261 self.keys[key] = Tree (self.reader)
1262 elif typ ==
'String':
1263 self.keys[key] = String (self.reader)
1265 self.keys[key] = Hist (self.reader)
1267 print (
'Unknown type', typ)
1271 def read_tree (self):
1275 def 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)]
1286 def 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)):
1295 def 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')
1302 inttypes = [types.IntType, types.LongType]
1303 def compare (o1, o2, thresh = 1e-6, ithresh = None, eltcmp = None):
1304 if eltcmp
and not isinstance(o1, list):
1305 return eltcmp (o1, o2)
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)
1312 if type(o1)
in inttypes
and isinstance(o2, float):
1314 elif type(o2)
in inttypes
and isinstance(o1, float):
1319 if isinstance(o1, list):
1320 if len(o1) != len(o2):
1324 if len(o1) > 0
and isinstance(o1[0], float)
and not ithresh
and not callable(thresh)
and not eltcmp:
1326 for i
in range(len(o1)):
1333 if den == 0:
continue
1336 print (
'fnmismatch', x1, x2, x, thresh)
1340 for i
in range(len(o1)):
1341 if not compare (o1[i], o2[i],
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:
1358 den = abs(o1)+abs(o2)
1359 if den == 0:
return True
1361 if callable(thresh): thresh =
thresh(den)
1363 print (
'fmismatch', o1, o2, x, thresh)
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
1378 def eg_pid_compare (o1, o2):
1379 if o1 == 0xffffffff
and o2 == 0:
return True
1383 def compare_detElementId (o1, o2):
1384 if o1 == o2:
return True
1385 if o1 == (o2 << 32):
return True
1389 def compare_pixid (o1, o2):
1390 if o1 == o2:
return True
1391 o2a = ((o2&0x7fffffff)-1)<<28
1392 if o1 == o2a :
return True
1396 def compare_abs (o1, o2):
1397 return compare (abs(o1), abs(o2))
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],
1419 [
'trk_z0_wrtPV' , 2e-4],
1420 [
'trk_d0_wrtPV' , 2e-4],
1421 [
'trk_phi_wrtPV' , 1e-4],
1423 [
'trk_err_theta_wrtPV' , 1e-5],
1424 [
'trk_err_phi_wrtPV' , 2e-5],
1426 [
'trk_phi_wrtBL' , 2e-2],
1427 [
'trk_z0_wrtBL' , 1],
1428 [
'trk_d0_wrtBL' , 3e-1],
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],
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],
1447 [
'trk_d0_wrtBS' , 2e-4],
1448 [
'trk_z0_wrtBS' , 5e-5],
1449 [
'trk_phi_wrtBS' , 5e-5],
1451 [
'trk_err_theta_wrtBS' , 1e-5],
1452 [
'trk_err_phi_wrtBS' , 2e-5],
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],
1464 [
'trk_mc_z0' , 4e-2],
1465 [
'trk_mc_d0' , 2e-2],
1466 [
'trk_mc_phi' , 2e-2],
1467 [
'trk_mc_theta' , 1e-3],
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],
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],
1482 [
'el*_jetcone_dr' , 1e-5],
1483 [
'el*_jetcone_ptrel' , 2e-5],
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)],
1518 [
'*_cl_eta0Calo', 1e-3],
1519 [
'*_cl_etaCalo', 1e-3],
1521 [
'ph_vx_Dist' , (6e-4, 2e-2)],
1523 [
'egtruth_phiCalo' , 3e-5],
1524 [
'egtruth_etaCalo' , 6e-5],
1528 for l
in branch_thresh:
1529 l[0] = re.compile (fnmatch.translate (l[0]))
1532 def diff_branch (k, kb, v1, v2):
1533 head =
'%s branch %s:' % (k, kb)
1539 if ignore_event_differences:
1543 print (head,
'Different set of events; new file: ',
1544 ev1,
'reference file', ev2)
1551 for (pat, th)
in branch_thresh:
1553 if isinstance(th, tuple):
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':
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
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')):
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
1633 if kb ==
'mc_perigee_theta': thresh = 1
1634 if kb ==
'mc_perigee_d0': thresh = 1
1635 if kb ==
'mc_perigee_phi': thresh = 1
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
1642 if kb.endswith (
'_mvaptcone20'): ithresh = 1e-10
1643 if kb.endswith (
'_mvaptcone30'): ithresh = 1e-10
1644 if kb.endswith (
'_mvaptcone40'): ithresh = 1e-10
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
1658 if kb.endswith (
'_neighbourSig'): thresh = 1e-4
1659 if kb.endswith (
'_curvatureSig'): thresh = 1e-4
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
1666 head =
'%s branch %s event %d:' % (k, kb, e)
1671 if type(b1)
in inttypes
and isinstance(b2, float):
1673 elif type(b2)
in inttypes
and isinstance(b1, float):
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,
1681 print (head,
'Branch mismatch')
1682 print (
' new file:', b1)
1683 print (
' ref file:', b2)
1687 def 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,
1692 dictkey_diff (t2.branches, t1.branches,
'%s: Branches only in reference file:'%k,
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])
1701 def 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')
1713 def 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:',
1717 dictkey_diff (d2.keys, d1.keys,
'Keys only in reference file:',
1719 for k
in d1.keys.keys():
1720 if k
in d2.keys
and not ignore_key_p (k):
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)
1734 print (
'Unknown type for diff:',
type(v1).__name__)
1738 if __name__ ==
'__main__':
1742 if sys.argv[1] ==
'--ignore-event-differences':
1743 ignore_event_differences =
True
1747 p = subprocess.Popen (
'python -m D3PDMakerTest.dumptuple_any %s' %
1750 stdout = subprocess.PIPE)
1751 d1 = Dumpreader (p.stdout)
1753 d2 = Dumpreader (open (sys.argv[2]))