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

◆ findEvent()

def printTrackingNtuple.findEvent (   ntpl,
  event 
)

Definition at line 9 of file printTrackingNtuple.py.

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

References createfilelist.int.

Referenced by main().

◆ main()

def printTrackingNtuple.main (   opts)

Definition at line 21 of file printTrackingNtuple.py.

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

References findEvent(), and print().

Variable Documentation

◆ description

printTrackingNtuple.description

Definition at line 120 of file printTrackingNtuple.py.

◆ help

printTrackingNtuple.help

Definition at line 122 of file printTrackingNtuple.py.

◆ opts

printTrackingNtuple.opts

Definition at line 142 of file printTrackingNtuple.py.

◆ parser

printTrackingNtuple.parser

Definition at line 120 of file printTrackingNtuple.py.

◆ type

printTrackingNtuple.type

Definition at line 121 of file printTrackingNtuple.py.

printTrackingNtuple.findEvent
def findEvent(ntpl, event)
Definition: printTrackingNtuple.py:9
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
Exception
createfilelist.int
int
Definition: createfilelist.py:10
printTrackingNtuple.main
def main(opts)
Definition: printTrackingNtuple.py:21