CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
diffTrackingNtuple Namespace Reference

Functions

def body
 
def inOrder
 
def main
 
def outOfOrder
 

Variables

string help = "File1"
 
tuple opts = parser.parse_args()
 
tuple parser = argparse.ArgumentParser(description="Unified diff of two TrackingNtuple files (clusters i.e. hits and TrackingParticles are assumed to be the same")
 

Function Documentation

def diffTrackingNtuple.body (   opts,
  ev1,
  ev2,
  printTrack 
)

Definition at line 10 of file diffTrackingNtuple.py.

References print(), and str.

Referenced by inOrder(), and outOfOrder().

10 
11 def body(opts, ev1, ev2, printTrack):
12  print(ev1.eventIdStr())
13 
14  tracks1 = ev1.tracks()
15  tracks2 = ev2.tracks()
16 
17  singleTrack = (opts.track is not None)
18  if singleTrack:
19  tracks1 = [tracks1[opts.track]]
20 
21  diff = ntuple.diffTrackListsGeneric(printTrack, tracks1, tracks2, ignoreAdditionalLst2=singleTrack)
22  if diff.hasDifference():
23  print(str(diff))
24  print()
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)
def diffTrackingNtuple.inOrder (   opts,
  ntpl1,
  ntpl2,
  args,
  kwargs 
)

Definition at line 25 of file diffTrackingNtuple.py.

References body().

Referenced by main().

25 
26 def inOrder(opts, ntpl1, ntpl2, *args, **kwargs):
27  if opts.entry is not None:
28  ev1 = ntpl1.getEvent(opts.entry)
29  ev2 = ntpl2.getEvent(opts.entry)
30 
31  if ev1.eventId() != ev2.eventId():
32  raise Exception("Events are out of order, entry %d file1 has %s and file %s. Use --outOfOrder option instead." % (ev1.entry(), ev1.eventIdStr(), ev2.eventIdStr()))
33 
34  body(opts, ev1, ev2, *args, **kwargs)
35  return
36 
37  for i, (ev1, ev2) in enumerate(itertools.izip(ntpl1, ntpl2)):
38  if opts.maxEvents >= 0 and i >= opts.maxEvents:
39  break
40 
41  if ev1.eventId() != ev2.eventId():
42  raise Exception("Events are out of order, entry %d file1 has %s and file %s. Use --outOfOrder option instead." % (ev1.entry(), ev1.eventIdStr(), ev2.eventIdStr()))
43 
44  body(opts, ev1, ev2, *args, **kwargs)
45 
def diffTrackingNtuple.main (   opts)

Definition at line 71 of file diffTrackingNtuple.py.

References inOrder(), outOfOrder(), and print().

71 
72 def main(opts):
73  ntpl1 = ntuple.TrackingNtuple(opts.file1)
74  ntpl2 = ntuple.TrackingNtuple(opts.file2)
75 
76  print("--- %s" % opts.file1)
77  print("+++ %s" % opts.file2)
78 
79  printTrack = ntuple.TrackPrinter(trackingParticlePrinter=ntuple.TrackingParticlePrinter(parentage=False), diffForTwiki=opts.twiki)
80 
81  if opts.outOfOrder:
82  outOfOrder(opts, ntpl1, ntpl2, printTrack)
83  else:
84  inOrder(opts, ntpl1, ntpl2, printTrack)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def diffTrackingNtuple.outOfOrder (   opts,
  ntpl1,
  ntpl2,
  args,
  kwargs 
)

Definition at line 46 of file diffTrackingNtuple.py.

References body(), and print().

Referenced by main().

46 
47 def outOfOrder(opts, ntpl1, ntpl2, *args, **kwargs):
48  if opts.entry is not None:
49  raise Exception("--entry does not make sense with --outOfOrder")
50 
51  events2 = collections.OrderedDict()
52  for ev2 in ntpl2:
53  events2[ev2.eventIdStr()] = ev2.entry()
54 
55  for i, ev1 in enumerate(ntpl1):
56  if opts.maxEvents >= 0 and i >= opts.maxEvents:
57  break
58 
59  if not ev1.eventId() in events2:
60  print("-", ev1.eventIdStr())
61  continue
62 
63  ev2 = ntpl2.getEvent(events2[ev1.eventIdStr()])
64  events2.remove(ev1.eventId())
65 
66  body(opts, ev1, ev2, *args, **kwargs)
67 
68 
69  for eventIdStr in events2.iterkeys():
70  print("+", eventIdStr)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Variable Documentation

string diffTrackingNtuple.help = "File1"

Definition at line 88 of file diffTrackingNtuple.py.

tuple diffTrackingNtuple.opts = parser.parse_args()

Definition at line 102 of file diffTrackingNtuple.py.

tuple diffTrackingNtuple.parser = argparse.ArgumentParser(description="Unified diff of two TrackingNtuple files (clusters i.e. hits and TrackingParticles are assumed to be the same")

Definition at line 86 of file diffTrackingNtuple.py.