19 def hist(tree_file_name, hist_name,subdet_ids,module_directions,overlap_directions,profile_directions):
20 f = ROOT.TFile(tree_file_name)
21 t = f.Get(
"analysis/Overlaps")
23 for subdet
in range(6):
25 for module
in range(3):
27 for overlap
in range(3):
28 h[subdet][module].
append([])
29 for profile
in range(4):
30 if subdetConditon(subdet,module,overlap):
31 h[subdet][module][overlap].
append(0)
33 name = hist_name +
"{0}_{1}_{2}".
format(dirNameList[module],dirNameList[overlap],detNameList[subdet])
34 if not ((subdet_ids[subdet])
and (module_directions[module])
and (profile_directions[profile])
and overlap_directions[overlap]):
35 h[subdet][module][overlap].
append(0)
38 if profile == 3: bins, xmin, xmax = 10, -math.pi, math.pi
39 if subdet+1 == 1
and profile == 1: bins, xmin, xmax = 10, -30, -30
40 if subdet+1 == 2
and profile == 1: bins, xmin, xmax = 40, -60, 60
41 if subdet+1 == 3
and profile == 1: bins, xmin, xmax = 10, -70, 70
42 if subdet+1 == 4
and profile == 1: bins, xmin, xmax = 40, -110, 110
43 if subdet+1 == 5
and profile == 1: bins, xmin, xmax = 10, -110, 110
44 if subdet+1 == 6
and profile == 1: bins, xmin, xmax = 20, -280, 280
45 if subdet+1 == 1
and profile == 2: bins, xmin, xmax = 10, 0, 20
46 if subdet+1 == 2
and profile == 2: bins, xmin, xmax = 10, 0, 20
47 if subdet+1 == 3
and profile == 2: bins, xmin, xmax = 10, 20, 55
48 if subdet+1 == 4
and profile == 2: bins, xmin, xmax = 10, 20, 55
49 if subdet+1 == 5
and profile == 2: bins, xmin, xmax = 10, 55, 110
50 if subdet+1 == 6
and profile == 2: bins, xmin, xmax = 10, 20, 110
51 h[subdet][module][overlap].
append(ROOT.TProfile(hist_name, hist_name, bins, xmin, xmax))
52 elif subdet+1==4
or subdet+1==6:
53 h[subdet][module][overlap].
append(ROOT.TH1F(name, name, 100, -5000, 5000))
55 h[subdet][module][overlap].
append(ROOT.TH1F(name, name, 100, -300, 300))
58 nentries = t.GetEntries()
60 for i, entry
in enumerate(t, start=1):
61 if i % 10000 == 0
or i == nentries:
62 print(i,
"/", nentries)
64 subdet_id = t.subdetID
65 if subdet_ids[subdet_id-1]==
False:
68 modulePhi0 = math.atan2(t.moduleY[0], t.moduleX[0])
69 modulePhi1 = math.atan2(t.moduleY[1], t.moduleX[1])
70 phidiff =
min(
abs(modulePhi0-modulePhi1),
abs(math.pi -
abs(modulePhi0-modulePhi1)))
71 moduleR0 = math.sqrt(t.moduleY[0]**2+t.moduleX[0]**2)
72 moduleR1 = math.sqrt(t.moduleY[1]**2+t.moduleX[1]**2)
75 if subdet_id%2 == 1
and ((
abs(t.moduleZ[0] - t.moduleZ[1]) > 1)):
77 elif subdet_id%2 == 0
and (
abs(moduleR0 - moduleR1)>1):
79 elif ((moduleR0*phidiff)>1):
84 if module_directions[module_direction]==
False:
86 avgList=[(t.moduleZ[0]+t.moduleZ[1])/2,(moduleR0+moduleR1)/2,(modulePhi0+modulePhi1)/2]
87 if overlap_directions[2]:
89 if modulePhi0 > modulePhi1:
94 overlapSignA = t.localxdotglobalphi[1]
95 overlapSignB = t.localxdotglobalphi[0]
101 overlapSignA = t.localxdotglobalphi[0]
102 overlapSignB = t.localxdotglobalphi[1]
103 residualA = hitXA - predXA
104 residualB = hitXB - predXB
109 A = 10000*(residualA - residualB)
110 h[subdet_id-1][module_direction][overlap_direction][0].
Fill(A)
111 for profile
in range(3):
112 if profile_directions[profile+1]:
113 h[subdet_id-1][module_direction][overlap_direction][profile+1].
Fill(avgList[profile],A)
116 if subdet_id==1
and module_direction != 1
and overlap_directions[0]:
117 overlap_direction = 0
118 if t.moduleZ[0] > t.moduleZ[1]:
123 overlapSignA = t.localydotglobalz[1]
124 overlapSignB = t.localydotglobalz[0]
130 overlapSignA = t.localydotglobalz[0]
131 overlapSignB = t.localydotglobalz[1]
132 residualA = hitXA - predXA
133 residualB = hitXB - predXB
138 A = 10000*(residualA - residualB)
139 h[subdet_id-1][module_direction][overlap_direction][0].
Fill(A)
140 for profile
in range(3):
141 if profile_directions[profile+1]:
142 h[subdet_id-1][module_direction][overlap_direction][profile+1].
Fill(avgList[profile],A)
144 if subdet_id==2
and module_direction !=0
and overlap_directions[1]:
145 overlap_direction = 1
146 if moduleR0 > moduleR1:
151 overlapSignA = t.localydotglobalr[1]
152 overlapSignB = t.localydotglobalr[0]
158 overlapSignA = t.localydotglobalr[0]
159 overlapSignB = t.localydotglobalr[1]
161 residualA = hitXA - predXA
162 residualB = hitXB - predXB
167 A = 10000*(residualA - residualB)
168 h[subdet_id-1][module_direction][overlap_direction][0].
Fill(A)
169 for profile
in range(3):
170 if profile_directions[profile+1]:
171 h[subdet_id-1][module_direction][overlap_direction][profile+1].
Fill(avgList[profile],A)