-
Notifications
You must be signed in to change notification settings - Fork 5
/
hgcalNtupleExample.py
64 lines (55 loc) · 2.28 KB
/
hgcalNtupleExample.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
# import ROOT
from NtupleDataFormat import HGCalNtuple
# The purpose of this file is to demonstrate mainly the objects
# that are in the HGCalNtuple
def main():
ntuple = HGCalNtuple("/Users/clange/CERNBox/partGun_PDGid211_x120_E80.0To80.0_NTUP_9.root")
tot_nevents = 0
tot_genpart = 0
tot_rechit = 0
tot_rechit_raw = 0
tot_cluster2d = 0
tot_multiclus = 0
tot_simcluster = 0
tot_pfcluster = 0
tot_calopart = 0
tot_track = 0
for event in ntuple:
# print "Event", event.entry()
tot_nevents += 1
genParts = event.genParticles()
tot_genpart += len(genParts)
recHits = event.recHits()
tot_rechit += len(recHits)
if (ntuple.hasRawRecHits()):
recHitsRaw = event.recHits("rechit_raw")
tot_rechit_raw += len(recHitsRaw)
layerClusters = event.layerClusters()
tot_cluster2d += len(layerClusters)
multiClusters = event.multiClusters()
tot_multiclus += len(multiClusters)
simClusters = event.simClusters()
tot_simcluster += len(simClusters)
pfClusters = event.pfClusters()
tot_pfcluster += len(pfClusters)
pfClusters = event.pfClusters()
tot_pfcluster += len(pfClusters)
caloParts = event.caloParticles()
tot_calopart += len(caloParts)
tracks = event.tracks()
tot_track += len(tracks)
# for genPart in genParts:
# print tot_nevents, "genPart pt:", genPart.pt()
print "Processed %d events" % tot_nevents
print "On average %f generator particles" % (float(tot_genpart) / tot_nevents)
print "On average %f reconstructed hits" % (float(tot_rechit) / tot_nevents)
print "On average %f raw reconstructed hits" % (float(tot_rechit_raw) / tot_nevents)
print "On average %f layer clusters" % (float(tot_cluster2d) / tot_nevents)
print "On average %f multi-clusters" % (float(tot_multiclus) / tot_nevents)
print "On average %f sim-clusters" % (float(tot_simcluster) / tot_nevents)
print "On average %f PF clusters" % (float(tot_pfcluster) / tot_nevents)
print "On average %f calo particles" % (float(tot_calopart) / tot_nevents)
print "On average %f tracks" % (float(tot_track) / tot_nevents)
if __name__ == "__main__":
main()