forked from awhitbeck/LDMX_TS
-
Notifications
You must be signed in to change notification settings - Fork 2
/
clusterCheck.py
147 lines (115 loc) · 4.74 KB
/
clusterCheck.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
from ts_digi_container import *
import ROOT as r
## initialize container
cont = ts_digi_container('~whitbeck/raid/LDMX/v2.2.1/four_electron_tracks.root','LDMX_Events')
cont.get_digi_collection('trigScintDigisTag_reco')
cont.get_digi_collection('trigScintDigisUp_reco')
cont.get_digi_collection('trigScintDigisDn_reco')
cont.get_cluster_collection('TriggerPadTaggerClusters_digi')
cont.get_cluster_collection('TriggerPadUpClusters_digi')
cont.get_cluster_collection('TriggerPadDownClusters_digi')
cont.get_track_collection('TriggerPadTracks_digi')
## configuration for pretty root plots
r.gROOT.ProcessLine(".L tdrstyle.C")
r.gROOT.ProcessLine("setTDRStyle()")
## initialize root histogram
PeUp = r.TH1F("Nhits","Title;Number of Photo-electrons > 50; Events",10,0,10)
PeTag = r.TH1F("Numhits","Title;Number of Photo-electrons > 50; Events",10,0,10)
PeDn = r.TH1F("Numhit","Title;Number of Photo-electrons > 50; Events",10,0,10)
clusters = r.TH1F("NumClusters","Title;Number of clusters; Events",10,0,10)
clustersUp = r.TH1F("NumClusters1","Title;Number of clusters; Events",10,0,10)
clustersDn = r.TH1F("NumClusters2","Title;Number of clusters; Events",10,0,10)
Tracks = r.TH1F("NumTracks","Title;Number of Tracks; Events",10,0,10)
hist = r.TH2F("Tagger","Tagger;Number of Photo-electrons > 50;Tracks",8,-0.5,7.5,8,-0.5,7.5)
hist2 = r.TH2F("Upstream","Title;Number of Photo-electrons > 50;Tracks",8,-0.5,7.5,8,-0.5,7.5)
hist3 = r.TH2F("Downstream","Tagger;Number of Photo-electrons > 50;Tracks",8,-0.5,7.5,8,-0.5,7.5)
clushist = r.TH2F("TaggerCluster","TaggerCluster;Number of Clusters;Tracks",8,-0.5,7.5,8,-0.5,7.5)
clushist2 = r.TH2F("UpstreamCluster","UpstreamCluster;Number of Clusters;Tracks",8,-0.5,7.5,8,-0.5,7.5)
clushist3 = r.TH2F("DownstreamCluster","TaggerCluster;Number of Clusters;Tracks",8,-0.5,7.5,8,-0.5,7.5)
## loop over events
for i in range(cont.tree.numentries -1):
## get list of pe for tagger array for event i
pesTag=cont.get_data('trigScintDigisTag_reco','pe',i)
NpeTag = sum(map(lambda x: x> 50, pesTag))
clusterTag = cont.get_data("TriggerPadTaggerClusters_digi","centroid",i)
PeTag.Fill(NpeTag)
clusters.Fill(len(clusterTag))
## get list of pe for upstream array for event i
pesUp = cont.get_data('trigScintDigisUp_reco','pe',i)
clusterUp = cont.get_data("TriggerPadUpClusters_digi","centroid",i)
NpeUp = sum(map(lambda x: x> 50, pesUp))
PeUp.Fill(NpeUp)
clustersUp.Fill(len(clusterUp))
## get list of pe for downstream array for event i
pesDn = cont.get_data('trigScintDigisDn_reco','pe',i)
clusterDn = cont.get_data("TriggerPadDownClusters_digi","centroid",i)
NpeDn = sum(map(lambda x: x> 50, pesDn))
PeDn.Fill(NpeDn)
clustersDn.Fill(len(clusterDn))
TrackCentroid = cont.get_data('TriggerPadTracks_digi', 'centroid',i)
Tracks.Fill(len(TrackCentroid))
hist.Fill(NpeTag,len(TrackCentroid))
hist2.Fill(NpeUp,len(TrackCentroid))
hist3.Fill(NpeDn,len(TrackCentroid))
clushist.Fill(len(clusterTag),len(TrackCentroid))
clushist2.Fill(len(clusterUp),len(TrackCentroid))
clushist3.Fill(len(clusterDn),len(TrackCentroid))
# number of hits greater than threshold 50
# number of clusters in various array
# histogram that shows the numner of tracks for each event
c1 = r.TCanvas("c1", "hist canvas", 600, 500)
PeUp.SetLineWidth(3)
PeUp.SetLineColor(2)
PeUp.SetLineStyle(1)
PeUp.Draw()
PeTag.SetLineWidth(3)
PeTag.SetLineColor(1)
PeTag.SetLineStyle(3)
PeTag.Draw("same")
PeDn.SetLineWidth(3)
PeDn.SetLineColor(4)
PeDn.SetLineStyle(2)
PeDn.Draw("same")
leg=r.TLegend(0.2, 0.6, 0.4, 0.9)
leg.AddEntry(PeTag, "tagger", "L")
leg.AddEntry(PeUp, "upstream", "L")
leg.AddEntry(PeDn, "downstream", "L")
leg.Draw()
c1.SaveAs(PeTag.GetName()+".png")
clustersUp.SetLineWidth(3)
clustersUp.SetLineColor(2)
clustersUp.SetLineStyle(1)
clustersUp.Draw()
clusters.SetLineWidth(3)
clusters.SetLineColor(1)
clusters.SetLineStyle(3)
clusters.Draw("same")
clustersDn.SetLineWidth(3)
clustersDn.SetLineColor(4)
clustersDn.SetLineStyle(2)
clustersDn.Draw("same")
leg=r.TLegend(0.6, 0.6, 0.8, 0.9)
leg.AddEntry(clusters, "tagger", "L")
leg.AddEntry(clustersUp, "upstream", "L")
leg.AddEntry(clustersDn, "downstream", "L")
leg.Draw()
c1.SaveAs(clusters.GetName()+".png")
Tracks.SetLineWidth(3)
#Tracks.SetLineColor(2)
Tracks.SetFillColor(4)
Tracks.Draw()
c1.SaveAs(Tracks.GetName()+".png")
c1.SetRightMargin(0.15)
hist.SetTitle("Tagger")
hist.Draw("colz,text")
c1.SaveAs(hist.GetName()+".png")
hist2.Draw("colz,text")
c1.SaveAs(hist2.GetName()+".png")
hist3.Draw("colz,text")
c1.SaveAs(hist3.GetName()+".png")
clushist.Draw("colz,text")
c1.SaveAs(clushist.GetName()+".png")
clushist2.Draw("colz,text")
c1.SaveAs(clushist2.GetName()+".png")
clushist3.Draw("colz,text")
c1.SaveAs(clushist3.GetName()+".png")