CMS 3D CMS Logo

Functions | Variables
diffTrackingNtuple Namespace Reference

Functions

def body (opts, ev1, ev2, printTrack)
 
def inOrder (opts, ntpl1, ntpl2, *args, **kwargs)
 
def main (opts)
 
def outOfOrder (opts, ntpl1, ntpl2, *args, **kwargs)
 

Variables

 action
 
 default
 
 description
 
 help
 
 int
 
 opts
 
 parser
 
 type
 

Function Documentation

◆ body()

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

Definition at line 10 of file diffTrackingNtuple.py.

10 def body(opts, ev1, ev2, printTrack):
11  print(ev1.eventIdStr())
12 
13  tracks1 = ev1.tracks()
14  tracks2 = ev2.tracks()
15 
16  singleTrack = (opts.track is not None)
17  if singleTrack:
18  tracks1 = [tracks1[opts.track]]
19 
20  diff = ntuple.diffTrackListsGeneric(printTrack, tracks1, tracks2, ignoreAdditionalLst2=singleTrack)
21  if diff.hasDifference():
22  print(str(diff))
23  print()
24 

References print(), and str.

Referenced by inOrder(), and outOfOrder().

◆ inOrder()

def diffTrackingNtuple.inOrder (   opts,
  ntpl1,
  ntpl2,
args,
**  kwargs 
)

Definition at line 25 of file diffTrackingNtuple.py.

25 def inOrder(opts, ntpl1, ntpl2, *args, **kwargs):
26  if opts.entry is not None:
27  ev1 = ntpl1.getEvent(opts.entry)
28  ev2 = ntpl2.getEvent(opts.entry)
29 
30  if ev1.eventId() != ev2.eventId():
31  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()))
32 
33  body(opts, ev1, ev2, *args, **kwargs)
34  return
35 
36  for i, (ev1, ev2) in enumerate(itertools.izip(ntpl1, ntpl2)):
37  if opts.maxEvents >= 0 and i >= opts.maxEvents:
38  break
39 
40  if ev1.eventId() != ev2.eventId():
41  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()))
42 
43  body(opts, ev1, ev2, *args, **kwargs)
44 
45 

References body().

Referenced by main().

◆ main()

def diffTrackingNtuple.main (   opts)

Definition at line 71 of file diffTrackingNtuple.py.

71 def main(opts):
72  ntpl1 = ntuple.TrackingNtuple(opts.file1)
73  ntpl2 = ntuple.TrackingNtuple(opts.file2)
74 
75  print("--- %s" % opts.file1)
76  print("+++ %s" % opts.file2)
77 
78  printTrack = ntuple.TrackPrinter(trackingParticlePrinter=ntuple.TrackingParticlePrinter(parentage=False), diffForTwiki=opts.twiki)
79 
80  if opts.outOfOrder:
81  outOfOrder(opts, ntpl1, ntpl2, printTrack)
82  else:
83  inOrder(opts, ntpl1, ntpl2, printTrack)
84 

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

◆ outOfOrder()

def diffTrackingNtuple.outOfOrder (   opts,
  ntpl1,
  ntpl2,
args,
**  kwargs 
)

Definition at line 46 of file diffTrackingNtuple.py.

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

References body(), and print().

Referenced by main().

Variable Documentation

◆ action

diffTrackingNtuple.action

Definition at line 91 of file diffTrackingNtuple.py.

◆ default

diffTrackingNtuple.default

Definition at line 95 of file diffTrackingNtuple.py.

◆ description

diffTrackingNtuple.description

Definition at line 86 of file diffTrackingNtuple.py.

◆ help

diffTrackingNtuple.help

Definition at line 88 of file diffTrackingNtuple.py.

◆ int

diffTrackingNtuple.int

Definition at line 95 of file diffTrackingNtuple.py.

◆ opts

diffTrackingNtuple.opts

Definition at line 102 of file diffTrackingNtuple.py.

◆ parser

diffTrackingNtuple.parser

Definition at line 86 of file diffTrackingNtuple.py.

◆ type

diffTrackingNtuple.type

Definition at line 87 of file diffTrackingNtuple.py.

diffTrackingNtuple.inOrder
def inOrder(opts, ntpl1, ntpl2, *args, **kwargs)
Definition: diffTrackingNtuple.py:25
str
#define str(s)
Definition: TestProcessor.cc:51
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
Exception
diffTrackingNtuple.outOfOrder
def outOfOrder(opts, ntpl1, ntpl2, *args, **kwargs)
Definition: diffTrackingNtuple.py:46
diffTrackingNtuple.main
def main(opts)
Definition: diffTrackingNtuple.py:71
diffTrackingNtuple.body
def body(opts, ev1, ev2, printTrack)
Definition: diffTrackingNtuple.py:10