CMS 3D CMS Logo

Functions | Variables
printTrackingNtuple Namespace Reference

Functions

def findEvent (ntpl, event)
 
def main (opts)
 

Variables

 description
 
 help
 
 opts
 
 parser
 
 type
 

Function Documentation

def printTrackingNtuple.findEvent (   ntpl,
  event 
)

Definition at line 8 of file printTrackingNtuple.py.

References createfilelist.int.

Referenced by main().

8 def findEvent(ntpl, event):
9  eventId = event.split(":")
10  if len(eventId) != 3:
11  raise Exception("Malformed eventId %s, is not run:lumi:event" % eventId)
12  eventId = (int(eventId[0]), int(eventId[1]), int(eventId[2]))
13 
14  for ev in ntpl:
15  if ev.eventId() == eventId:
16  return ev
17 
18  raise Exception("Did not find event %s from file %s" % (eventId, ntpl.file().GetPath()))
19 
def findEvent(ntpl, event)
def printTrackingNtuple.main (   opts)

Definition at line 20 of file printTrackingNtuple.py.

References cmsPerfStripChart.dict, and findEvent().

20 def main(opts):
21  if opts.track is None and opts.trackingParticle is None and opts.seed is None and opts.pixelHit is None and opts.stripHit is None:
22  return
23 
24  ntpl = ntuple.TrackingNtuple(opts.file)
25 
26  if opts.entry is not None:
27  event = ntpl.getEvent(opts.entry)
28  print event.eventIdStr()
29  elif opts.event is not None:
30  event = findEvent(ntpl, opts.event)
31  print "Entry %d" % event.entry()
32 
33  hasHits = ntpl.hasHits()
34  hasSeeds = ntpl.hasSeeds()
35 
36  if not hasSeeds and opts.seed is not None:
37  print "Ntuple %s does not have seeds saved!" % opts.file
38  return
39  if not hasHits and (opts.pixelHit is not None or opts.stripHit is not None):
40  print "Ntuple %s does not have hits saved!" % opts.file
41  return
42 
43  seedArgs = dict(hits=hasHits, bestMatchingTrackingParticle=hasHits)
44  trackArgs = dict(hits=hasHits, bestMatchingTrackingParticle=hasHits)
45  tpArgs = dict(hits=hasHits, bestMatchingTrack=hasHits)
46  if not hasSeeds:
47  trackArgs["seedPrinter"] = None
48  tpArgs["seedPrinter"] = None
49  elif not hasHits:
50  trackArgs["seedPrinter"] = ntuple.SeedPrinter(**seedArgs)
51  tpArgs["seedPrinter"] = ntuple.SeedPrinter(**seedArgs)
52 
53  printSeed = ntuple.SeedPrinter(trackingParticles=True, trackingParticlePrinter=ntuple.TrackingParticlePrinter(**tpArgs), **seedArgs)
54  printTrack = ntuple.TrackPrinter(trackingParticlePrinter=ntuple.TrackingParticlePrinter(**tpArgs), **trackArgs)
55  printTrackingParticle = ntuple.TrackingParticlePrinter(trackPrinter=ntuple.TrackPrinter(**trackArgs), **tpArgs)
56 
57  if opts.track is not None:
58  trks = event.tracks()
59  if opts.track >= len(trks):
60  print "You requested track %d, but this event has only %d tracks" % (opts.track, len(trks))
61  return
62  trk = trks[opts.track]
63  printTrack(trk)
64 
65  if opts.trackingParticle is not None:
66  tps = event.trackingParticles()
67  if opts.trackingParticle >= len(tps):
68  print "You requested TrackingParticle %d, but this event has ony %d TrackingParticles" % (opts.trackingParticle, len(tps))
69  return
70  tp = tps[opts.trackingParticle]
71  printTrackingParticle(tp)
72 
73  if opts.seed is not None:
74  seeds = event.seeds()
75  if opts.seedIteration is not None:
76  algo = getattr(ntuple.Algo, opts.seedIteration)
77  if opts.seed >= seeds.nSeedsForAlgo(algo):
78  print "You requested seed %d for algo %s, but this event has only %d seeds for that algo" % (opts.seed, opts.seedIteration, seeds.nSeedsForAlgo(algo))
79  return
80  seed = seeds.seedForAlgo(algo, opts.seed)
81  else:
82  if opts.seed >= len(seeds):
83  print "You requested seed %d, but this event has only %d seeds" % (opts.seed, len(seeds))
84  return
85  seed = seeds[opts.seed]
86  printSeed(seed)
87 
88  if opts.pixelHit is not None:
89  hits = event.pixelHits()
90  if opts.pixelHit >= len(hits):
91  print "You requested pixel hit %d, but this event has only %d pixel hits" % (opts.pixelHit, len(hits))
92  return
93 
94  hit = hits[opts.pixelHit]
95  print "Pixel hit %d tracks" % opts.pixelHit
96  for t in hit.tracks():
97  printTrack(t)
98  if hasSeeds:
99  print "Pixel hit %d seeds" % opts.pixelHit
100  for s in hit.seeds():
101  printSeed(s)
102 
103  if opts.stripHit is not None:
104  hits = event.stripHits()
105  if opts.stripHit >= len(hits):
106  print "You requested strip hit %d, but this event has only %d strip hits" % (opts.stripHit, len(hits))
107  return
108  hit = hits[opts.stripHit]
109  print "Strip hit %d tracks" % opts.stripHit
110  for t in hit.tracks():
111  printTrack(t)
112  if hasSeeds:
113  print "Strip hit %d seeds" % opts.stripHit
114  for s in hit.seeds():
115  printSeed(s)
116 
117 
def findEvent(ntpl, event)

Variable Documentation

printTrackingNtuple.description

Definition at line 119 of file printTrackingNtuple.py.

printTrackingNtuple.help

Definition at line 121 of file printTrackingNtuple.py.

printTrackingNtuple.opts

Definition at line 141 of file printTrackingNtuple.py.

printTrackingNtuple.parser

Definition at line 119 of file printTrackingNtuple.py.

printTrackingNtuple.type

Definition at line 120 of file printTrackingNtuple.py.