-
Notifications
You must be signed in to change notification settings - Fork 1
/
loopTracks.py
34 lines (27 loc) · 1.38 KB
/
loopTracks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from DataFormats.FWLite import Handle, Events
from ROOT import gROOT, gStyle, TCanvas, TF1, TFile, TTree, gRandom, TH1F, TH2F
import os
eventsRef = Events("ReReco_1.root")
tracksRef = Handle("std::vector<reco::Track>")
label = "generalTracks"
quality = "highPurity"
#quality = "tight"
#quality = "loose"
for i in range(0, eventsRef.size()):
#for i in range(0, 200):
a= eventsRef.to(i)
print "Event", i
a=eventsRef.getByLabel(label, tracksRef)
trVal = []
for track in tracksRef.product():
# if (track.phi()<0) : continue
# if (track.eta()<0) : continue
# if (track.pt()<5) : continue
# if (track.quality(track.qualityByName(quality))) :
pattern = track.hitPattern()
if (pattern.numberOfValidHits() != (pattern.numberOfValidPixelHits()+pattern.numberOfValidStripHits())) :
print pattern.numberOfValidHits(),pattern.numberOfValidPixelHits(),pattern.numberOfValidStripHits(), pattern.numberOfValidPixelHits()+pattern.numberOfValidStripHits()
# trVal.append([10*int(100*track.eta())+track.phi(), "ori", track.eta(), track.phi(), track.pt(), track.numberOfValidHits() , track.hitPattern().numberOfValidPixelHits(), track.ndof(),track.chi2(),
# track.algo()-4,track.originalAlgo()-4,track.algoMask().to_string(), track.algoMask(), track.quality(track.qualityByName("highPurity"))])
print tracksRef.product().size(), len(trVal)
print eventsRef.size()