18 def hist(tree_file_name, hist_name,subdet_ids,module_directions,overlap_directions,profile_directions):
19 f = ROOT.TFile(tree_file_name)
20 t = f.Get(
"analysis/Overlaps")
22 for subdet
in range(6):
24 for module
in range(3):
26 for overlap
in range(3):
27 h[subdet][module].
append([])
28 for profile
in range(4):
29 if subdetConditon(subdet,module,overlap):
30 h[subdet][module][overlap].
append(0)
32 name = hist_name +
"{0}_{1}_{2}".
format(dirNameList[module],dirNameList[overlap],detNameList[subdet])
33 if not ((subdet_ids[subdet])
and (module_directions[module])
and (profile_directions[profile])
and overlap_directions[overlap]):
34 h[subdet][module][overlap].
append(0)
37 if profile == 3: bins, xmin, xmax = 10, -math.pi, math.pi
38 if subdet+1 == 1
and profile == 1: bins, xmin, xmax = 10, -30, -30
39 if subdet+1 == 2
and profile == 1: bins, xmin, xmax = 40, -60, 60
40 if subdet+1 == 3
and profile == 1: bins, xmin, xmax = 10, -70, 70
41 if subdet+1 == 4
and profile == 1: bins, xmin, xmax = 40, -110, 110
42 if subdet+1 == 5
and profile == 1: bins, xmin, xmax = 10, -110, 110
43 if subdet+1 == 6
and profile == 1: bins, xmin, xmax = 20, -280, 280
44 if subdet+1 == 1
and profile == 2: bins, xmin, xmax = 10, 0, 20
45 if subdet+1 == 2
and profile == 2: bins, xmin, xmax = 10, 0, 20
46 if subdet+1 == 3
and profile == 2: bins, xmin, xmax = 10, 20, 55
47 if subdet+1 == 4
and profile == 2: bins, xmin, xmax = 10, 20, 55
48 if subdet+1 == 5
and profile == 2: bins, xmin, xmax = 10, 55, 110
49 if subdet+1 == 6
and profile == 2: bins, xmin, xmax = 10, 20, 110
50 h[subdet][module][overlap].
append(ROOT.TProfile(hist_name, hist_name, bins, xmin, xmax))
51 elif subdet+1==4
or subdet+1==6:
52 h[subdet][module][overlap].
append(ROOT.TH1F(name, name, 100, -5000, 5000))
54 h[subdet][module][overlap].
append(ROOT.TH1F(name, name, 100, -300, 300))
55 h[subdet][module][overlap][profile].SetDirectory(0)
57 nentries = t.GetEntries()
59 for i, entry
in enumerate(t, start=1):
60 if i % 10000 == 0
or i == nentries:
61 print(i,
"/", nentries)
63 subdet_id = t.subdetID
64 if subdet_ids[subdet_id-1]==
False:
67 modulePhi0 = math.atan2(t.moduleY[0], t.moduleX[0])
68 modulePhi1 = math.atan2(t.moduleY[1], t.moduleX[1])
69 phidiff =
min(
abs(modulePhi0-modulePhi1),
abs(math.pi -
abs(modulePhi0-modulePhi1)))
70 moduleR0 = math.sqrt(t.moduleY[0]**2+t.moduleX[0]**2)
71 moduleR1 = math.sqrt(t.moduleY[1]**2+t.moduleX[1]**2)
74 if subdet_id%2 == 1
and ((
abs(t.moduleZ[0] - t.moduleZ[1]) > 1)):
76 elif subdet_id%2 == 0
and (
abs(moduleR0 - moduleR1)>1):
78 elif ((moduleR0*phidiff)>1):
83 if module_directions[module_direction]==
False:
85 avgList=[(t.moduleZ[0]+t.moduleZ[1])/2,(moduleR0+moduleR1)/2,(modulePhi0+modulePhi1)/2]
86 if overlap_directions[2]:
88 if modulePhi0 > modulePhi1:
93 overlapSignA = t.localxdotglobalphi[1]
94 overlapSignB = t.localxdotglobalphi[0]
100 overlapSignA = t.localxdotglobalphi[0]
101 overlapSignB = t.localxdotglobalphi[1]
102 residualA = hitXA - predXA
103 residualB = hitXB - predXB
108 A = 10000*(residualA - residualB)
109 h[subdet_id-1][module_direction][overlap_direction][0].
Fill(A)
110 for profile
in range(3):
111 if profile_directions[profile+1]:
112 h[subdet_id-1][module_direction][overlap_direction][profile+1].
Fill(avgList[profile],A)
115 if subdet_id==1
and module_direction != 1
and overlap_directions[0]:
116 overlap_direction = 0
117 if t.moduleZ[0] > t.moduleZ[1]:
122 overlapSignA = t.localydotglobalz[1]
123 overlapSignB = t.localydotglobalz[0]
129 overlapSignA = t.localydotglobalz[0]
130 overlapSignB = t.localydotglobalz[1]
131 residualA = hitXA - predXA
132 residualB = hitXB - predXB
137 A = 10000*(residualA - residualB)
138 h[subdet_id-1][module_direction][overlap_direction][0].
Fill(A)
139 for profile
in range(3):
140 if profile_directions[profile+1]:
141 h[subdet_id-1][module_direction][overlap_direction][profile+1].
Fill(avgList[profile],A)
143 if subdet_id==2
and module_direction !=0
and overlap_directions[1]:
144 overlap_direction = 1
145 if moduleR0 > moduleR1:
150 overlapSignA = t.localydotglobalr[1]
151 overlapSignB = t.localydotglobalr[0]
157 overlapSignA = t.localydotglobalr[0]
158 overlapSignB = t.localydotglobalr[1]
160 residualA = hitXA - predXA
161 residualB = hitXB - predXB
166 A = 10000*(residualA - residualB)
167 h[subdet_id-1][module_direction][overlap_direction][0].
Fill(A)
168 for profile
in range(3):
169 if profile_directions[profile+1]:
170 h[subdet_id-1][module_direction][overlap_direction][profile+1].
Fill(avgList[profile],A)
def hist(tree_file_name, hist_name, subdet_ids, module_directions, overlap_directions, profile_directions)
S & print(S &os, JobReport::InputFile const &f)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Abs< T >::type abs(const T &t)