ATLAS Offline Software
MdtMonUtils.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 #
5 from ROOT import TBox, kGray, TLine, TMath , TF1, kBlue, kRed, kBlack
6 from MdtRawDataMonitoring.MdtRawMonLabels import * # noqa
7 
8 def getMDTLabel(x,y):
9  labelx = getattr(labels, x)
10  labely = getattr(labels, y)
11  return labelx,labely
12 
13 
14 def getMDTLabelx(x):
15  labelx = getattr(labels, x)
16  return labelx
17 
18 
19 def putBoxMdtRegional(h, xAxis, geo):
20  offset=0
21  #Make gray boxes
22  if(xAxis=="BOA"):
23  putBox(h, 0, 0, 1, 44, offset); putBox(h, 7, 0, 9, 44 ,offset)
24  putBox(h, 0, 48, 1, 52 ,offset); putBox(h, 8, 48, 9, 52 ,offset)
25  putBox(h, 0, 56, 1, 64 ,offset); putBox(h, 7, 56, 9, 64 ,offset)
26 
27  putLine(h, 1, 0, 1, 44 ); putLine(h, 7, 0, 7, 44 ); putLine(h, 0, 44, 1, 44); putLine(h, 7, 44, 9, 44)
28  putLine(h, 1, 48, 1, 52); putLine(h, 8, 48, 8, 52); putLine(h, 0, 48, 1, 48); putLine(h, 8, 48, 9, 48); putLine(h, 0, 52, 1, 52); putLine(h, 8, 52, 9, 52)
29  putLine(h, 1, 56, 1, 64); putLine(h, 7, 56, 7, 64); putLine(h, 0, 56, 1, 56); putLine(h, 7, 56, 9, 56 )
30 
31  if(xAxis=="BOC"):
32  putBox(h, 0, 0, 2, 44 ,offset)
33  putBox(h, 0, 48, 1, 52 ,offset)
34  putBox(h, 0, 56, 2, 64 ,offset)
35 
36  putLine(h, 2, 0, 2, 44); putLine(h, 0, 44, 2, 44)
37  putLine(h, 1, 48, 1, 52); putLine(h, 0, 48, 1, 48); putLine(h, 0, 52, 1, 52)
38  putLine(h, 2, 56, 2, 64); putLine(h, 0, 56, 2, 56)
39 
40  if(xAxis=="BIA") :
41  putBox(h, 6, 0, 8, 4 ,offset); putLine(h, 6, 0, 8, 0); putLine(h, 6, 0, 6, 4); putLine(h, 6, 4, 8, 4) #phi 1
42  putBox(h, 7, 6, 8, 8 ,offset); putLine(h, 7, 6, 8, 6); putLine(h, 7, 6, 7, 8) #phi 2
43  putBox(h, 6, 8, 8, 12 ,offset); putLine(h, 6, 8, 7, 8); putLine(h, 6, 8, 6, 12); putLine(h, 6, 12, 8, 12) #phi 3
44  putBox(h, 7, 14, 8, 16 ,offset); putLine(h, 7, 14, 8, 14); putLine(h, 7, 14, 7, 16) #phi 4
45  putBox(h, 6, 16, 8, 20 ,offset); putLine(h, 6, 16, 7, 16); putLine(h, 6, 16, 6, 20); putLine(h, 6, 20, 8, 20) #phi 5
46  putBox(h, 7, 22, 8, 24 ,offset); putLine(h, 7, 22, 8, 22); putLine(h, 7, 22, 7, 24) #phi 6
47  putBox(h, 6, 24, 8, 28 ,offset); putLine(h, 6, 24, 7, 24); putLine(h, 6, 24, 6, 28); putLine(h, 6, 28, 8, 28) #phi 7
48  putBox(h, 7, 30, 8, 32 ,offset); putLine(h, 7, 30, 8, 30); putLine(h, 7, 30, 7, 32) #phi 8
49  putBox(h, 6, 32, 8, 36 ,offset); putLine(h, 6, 32, 7, 32); putLine(h, 6, 32, 6, 36); putLine(h, 6, 36, 8, 36) #phi 9
50  putBox(h, 7, 38, 8, 40 ,offset); putLine(h, 7, 38, 8, 38); putLine(h, 7, 38, 7, 40) #phi 10
51  putBox(h, 6, 40, 8, 44 ,offset); putLine(h, 6, 40, 7, 40); putLine(h, 6, 40, 6, 44) #putLine(h, 6, 40, 5, 44) #phi 11
52  putBox(h, 5, 44, 8, 48 ,offset); putLine(h, 5, 44, 6, 44); putLine(h, 5, 44, 5, 48); putLine(h, 5, 48, 8, 48) #phi 11 M
53  putBox(h, 7, 50, 8, 52 ,offset); putLine(h, 7, 50, 8, 50); putLine(h, 7, 50, 7, 52) #phi 12
54  putBox(h, 6, 52, 8, 56 ,offset); putLine(h, 6, 52, 7, 52); putLine(h, 6, 52, 6, 56); putLine(h, 6, 56, 8, 56) #phi 13
55  putBox(h, 7, 58, 8, 60 ,offset); putLine(h, 7, 58, 8, 58); putLine(h, 7, 58, 7, 60) #phi 14
56  putBox(h, 6, 60, 8, 64 ,offset); putLine(h, 6, 60, 7, 60); putLine(h, 6, 60, 6, 64) #putLine(h, 6, 60, 5, 64) #phi 15
57  putBox(h, 5, 64, 8, 68 ,offset); putLine(h, 5, 64, 6, 64); putLine(h, 5, 64, 5, 68); putLine(h, 5, 68, 8, 68) #phi 15 M
58  putBox(h, 7, 70, 8, 72 ,offset); putLine(h, 7, 70, 8, 70); putLine(h, 7, 70, 7, 72); putLine(h, 7, 72, 8, 72) # phi 16
59 
60  if geo==1:
61  putBox(h, 7, 0, 8, 72, 0)
62 
63 
64  if(xAxis=="BIC"):
65  putBox(h, 2, 0, 0, 4 ,offset); putLine(h, 2, 0, 0, 0); putLine(h, 2, 0, 2, 4); putLine(h, 2, 4, 0, 4) #phi 1
66  putBox(h, 1, 6, 0, 8 ,offset); putLine(h, 1, 6, 0, 6); putLine(h, 1, 6, 1, 8) #phi 2
67  putBox(h, 2, 8, 0, 12 ,offset); putLine(h, 2, 8, 1, 8); putLine(h, 2, 8, 2, 12); putLine(h, 2, 12, 0, 12) #phi 3
68  putBox(h, 1, 14, 0, 16 ,offset); putLine(h, 1, 14, 0, 14); putLine(h, 1, 14, 1, 16)#phi 4
69  putBox(h, 2, 16, 0, 20 ,offset); putLine(h, 2, 16, 1, 16); putLine(h, 2, 16, 2, 20); putLine(h, 2, 20, 0, 20) #phi 5
70  putBox(h, 1, 22, 0, 24 ,offset); putLine(h, 1, 22, 0, 22); putLine(h, 1, 22, 1, 24) #phi 6
71  putBox(h, 2, 24, 0, 28 ,offset); putLine(h, 2, 24, 1, 24); putLine(h, 2, 24, 2, 28); putLine(h, 2, 28, 0, 28) #phi 7
72  putBox(h, 1, 30, 0, 32 ,offset); putLine(h, 1, 30, 0, 30); putLine(h, 1, 30, 1, 32) #phi 8
73  putBox(h, 2, 32, 0, 36 ,offset); putLine(h, 2, 32, 1, 32); putLine(h, 2, 32, 2, 36); putLine(h, 2, 36, 0, 36) #phi 9
74  putBox(h, 1, 38, 0, 40 ,offset); putLine(h, 1, 38, 0, 38); putLine(h, 1, 38, 1, 40) #phi 10
75  putBox(h, 2, 40, 0, 44 ,offset); putLine(h, 2, 40, 1, 40); putLine(h, 2, 40, 2, 44) #putLine(h, 2, 40, 3, 44) #phi 11
76  putBox(h, 3, 44, 0, 48 ,offset); putLine(h, 3, 44, 2, 44); putLine(h, 3, 44, 3, 48); putLine(h, 3, 48, 0, 48)#phi 11 M
77  putBox(h, 1, 50, 0, 52 ,offset); putLine(h, 1, 50, 0, 50); putLine(h, 1, 50, 1, 52) #phi 12
78  putBox(h, 2, 52, 0, 56 ,offset); putLine(h, 2, 52, 1, 52); putLine(h, 2, 52, 2, 56); putLine(h, 2, 56, 0, 56)# phi 13
79  putBox(h, 1, 58, 0, 60 ,offset); putLine(h, 1, 58, 0, 58); putLine(h, 1, 58, 1, 60) #phi 14
80  putBox(h, 2, 60, 0, 64 ,offset); putLine(h, 2, 60, 1, 60); putLine(h, 2, 60, 2, 64) #putLine(h, 2, 60, 3, 64); //phi 15
81  putBox(h, 3, 64, 0, 68 ,offset); putLine(h, 3, 64, 2, 64); putLine(h, 3, 64, 3, 68); putLine(h, 3, 68, 0, 68) #phi 15 M
82  putBox(h, 1, 70, 0, 72 ,offset); putLine(h, 1, 70, 0, 70); putLine(h, 1, 70, 1, 72); putLine(h, 1, 72, 0, 72) #phi 16
83 
84  if(xAxis=="EIA"):
85  putBox(h, 2, 4, 5, 8 ,offset); putLine(h, 2, 4, 5, 4); putLine(h, 2, 4, 2, 8); putLine(h, 2, 8, 4, 8) #phi 2
86  putBox(h, 4, 8, 5, 12 ,offset); putLine(h, 4, 8, 4, 12) #phi 3
87  putBox(h, 2, 12, 5, 16 ,offset); putLine(h, 2, 12, 4, 12); putLine(h, 2, 12, 2, 16); putLine(h, 2, 16, 4, 16) #phi 4
88  putBox(h, 4, 16, 5, 20 ,offset); putLine(h, 4, 16, 4, 20) #phi 5
89  putBox(h, 2, 20, 5, 24 ,offset); putLine(h, 2, 20, 4, 20); putLine(h, 2, 20, 2, 24); putLine(h, 2, 24, 4, 24) #phi 6
90  putBox(h, 4, 24, 5, 28 ,offset); putLine(h, 4, 24, 4, 28) #phi 7
91  putBox(h, 2, 28, 5, 32 ,offset); putLine(h, 2, 28, 4, 28); putLine(h, 2, 28, 2, 32); putLine(h, 2, 32, 5, 32) # phi 8
92  putBox(h, 2, 36, 5, 40 ,offset); putLine(h, 2, 36, 5, 36); putLine(h, 2, 36, 2, 40); putLine(h, 2, 40, 4, 40) #phi 10
93  putBox(h, 4, 40, 5, 44 ,offset); putLine(h, 4, 40, 4, 44) #phi 11
94  putBox(h, 2, 44, 5, 48 ,offset); putLine(h, 2, 44, 4, 44); putLine(h, 2, 44, 2, 48); putLine(h, 2, 48, 4, 48) #phi 12
95  putBox(h, 4, 48, 5, 52 ,offset); putLine(h, 4, 48, 4, 52) #phi 13
96  putBox(h, 2, 52, 5, 56 ,offset); putLine(h, 2, 52, 4, 52); putLine(h, 2, 52, 2, 56); putLine(h, 2, 56, 4, 56) # phi 14
97  putBox(h, 4, 56, 5, 60 ,offset); putLine(h, 4, 56, 4, 60) #phi 15
98  putBox(h, 2, 60, 5, 64 ,offset); putLine(h, 2, 60, 4, 60); putLine(h, 2, 60, 2, 64); putLine(h, 2, 64, 5, 64) # phi 16
99 
100  if geo ==1:
101  putBox(h, 0, 0, 3, 64 ,0)
102 
103  if(xAxis=="EIC"):
104  putBox(h, 3, 4, 0, 8 ,offset); putLine(h, 3, 4, 0, 4); putLine(h, 3, 4, 3, 8); putLine(h, 3, 8, 1, 8) # phi 2
105  putBox(h, 1, 8, 0, 12 ,offset); putLine(h, 1, 8, 1, 12) #phi 3
106  putBox(h, 3, 12, 0, 16 ,offset); putLine(h, 3, 12, 1, 12); putLine(h, 3, 12, 3, 16); putLine(h, 3, 16, 1, 16) # phi 4
107  putBox(h, 1, 16, 0, 20 ,offset); putLine(h, 1, 16, 1, 20) #phi 5
108  putBox(h, 3, 20, 0, 24 ,offset); putLine(h, 3, 20, 1, 20); putLine(h, 3, 20, 3, 24); putLine(h, 3, 24, 1, 24) # phi 6
109  putBox(h, 1, 24, 0, 28 ,offset); putLine(h, 1, 24, 1, 28) #phi 7
110  putBox(h, 3, 28, 0, 32 ,offset); putLine(h, 3, 28, 1, 28); putLine(h, 3, 28, 3, 32); putLine(h, 3, 32, 0, 32) # phi
111  putBox(h, 3, 36, 0, 40 ,offset); putLine(h, 3, 36, 0, 36); putLine(h, 3, 36, 3, 40); putLine(h, 3, 40, 1, 40) # phi 10
112  putBox(h, 1, 40, 0, 44 ,offset); putLine(h, 1, 40, 1, 44) #phi 11
113  putBox(h, 3, 44, 0, 48 ,offset); putLine(h, 3, 44, 1, 44); putLine(h, 3, 44, 3, 48); putLine(h, 3, 48, 1, 48) # phi 12
114  putBox(h, 1, 48, 0, 52 ,offset); putLine(h, 1, 48, 1, 52) #phi 13
115  putBox(h, 3, 52, 0, 56 ,offset); putLine(h, 3, 52, 1, 52); putLine(h, 3, 52, 3, 56); putLine(h, 3, 56, 1, 56) # phi 14
116  putBox(h, 1, 56, 0, 60 ,offset); putLine(h, 1, 56, 1, 60) #phi 15
117  putBox(h, 3, 60, 0, 64 ,offset); putLine(h, 3, 60, 1, 60); putLine(h, 3, 60, 3, 64); putLine(h, 3, 64, 0, 64) # phi 16
118 
119  if geo ==1:
120  putBox(h, 2, 0, 5, 64 ,0)
121 
122 
123 
124  if(xAxis=="EEA"):
125  putBox(h, 1, 16, 2, 20 ,offset)
126  putLine(h, 1, 16, 2, 16)
127  putLine(h, 1, 16, 1, 20)
128  putLine(h, 1, 20, 2, 20)
129 
130 
131  if(xAxis=="EEC"):
132  putBox(h, 0, 16, 1, 20 ,offset)
133  putLine(h, 0, 16, 1, 16)
134  putLine(h, 1, 16, 1, 20)
135  putLine(h, 0, 20, 1, 20)
136 
137 
138  if(xAxis=="BEA" or xAxis == "BEC"):
139  putBox(h, 2, 0, 3, 16 ,offset)
140  putLine(h, 2, 0, 2, 16)
141 
142 
143  if(xAxis == "EMA" or xAxis == "EMC"):
144  putBox(h, 5, 0, 6, 64 ,offset)
145  putLine(h, 5, 0, 5, 64)
146 
147 
148  if(xAxis == "EOA" or xAxis == "EOC"):
149  putBox(h, 6, 0, 7, 64 ,offset)
150  putLine(h, 6, 0, 6, 64)
151 
152  if(xAxis[0:2] == "EE" or xAxis[0:2] == "BI" or xAxis[0:2] == "EI" or xAxis[0:2] == "BM" or xAxis[0:2] == "BO"):
153  #Draw TickMarks
154  for i in range(h.GetNbinsY()+1):
155  l = TLine(0,i,0.55*h.GetNbinsX()/17,i)
156  h.GetListOfFunctions().Add(l)
157  for i in range(h.GetNbinsX()+1):
158  l = TLine(i,0,i,0.55/17*h.GetNbinsY())
159  h.GetListOfFunctions().Add(l)
160 
161  lx = TLine(0,0,h.GetNbinsX(),0)
162  ly = TLine(0,0,0,h.GetNbinsY())
163  lx.SetLineColor(kBlack)
164  ly.SetLineColor(kBlack)
165  h.GetListOfFunctions().Add(lx)
166  h.GetListOfFunctions().Add(ly)
167 
168 
169 def putBoxMdtGlobal(h, ecap, geo):
170  if(ecap == "B"):
171  offset = 8
172  # Left Side
173  putBox(h, 0, 0, 6, 16, offset); putLine(h, 6, 0, 6, 16, offset); putLine(h, 2, 16, 6, 16, offset)
174  putBox(h, 0, 16, 2, 18, offset); putLine(h, 2, 16, 2, 18, offset)
175  putLine(h, 0, 18, 2, 18, offset)
176  putBox(h, 0, 20, 2, 22, offset); putLine(h, 2, 20, 2, 22, offset); putLine(h, 0, 20, 2, 20, offset); putLine(h, 0, 22, 2, 22, offset) # 3
177  putBox(h, 0, 24, 2, 26, offset); putLine(h,2,24,2,26,offset); putLine(h, 0, 24, 2, 24, offset); putLine(h, 0, 26, 2, 26, offset) # 5
178  putBox(h, 0, 28, 2, 30, offset); putLine(h,2,28,2,30,offset); putLine(h,0,28,2,28,offset); putLine(h,0,30,2,30,offset) # 7
179  putBox(h, 0, 32, 2, 34, offset); putLine(h,2,32,2,34,offset); putLine(h,0,32,2,32,offset); putLine(h,0,34,2,34,offset) # 9
180  putBox(h, 0, 36, 3, 38, offset); putLine(h,3,36,3,38,offset); putLine(h,0,36,3,36,offset); putLine(h,2,38,3,38,offset) # 11M
181  putBox(h, 0, 38, 2, 40, offset); putLine(h,2,38,2,40,offset); putLine(h,0,40,2,40,offset) # 11R
182  putBox(h, 0, 42, 2, 44, offset); putLine(h,0,42,2,42,offset); putLine(h,2,42,2,44,offset); putLine(h,0,44,2,44,offset) # 13
183  putBox(h, 0, 46, 3, 48, offset); putLine(h,3,46,3,48,offset); putLine(h,0,46,3,46,offset); putLine(h,2,48,3,48,offset) # 15M
184  putBox(h, 0, 48, 2, 50, offset); putLine(h,2,48,2,50,offset); putLine(h,0,50,2,50,offset) # 15R
185  putBox(h, 0, 52, 2, 106, offset)
186  putLine(h,0,52,2,52,offset)
187 
188  putLine(h,0,106,2,106,offset)
189  putBox(h, 0, 108, 1, 110, offset); putLine(h,1,108,1,110,offset); putLine(h,0,108,1,108,offset); putLine(h,0,110,1,110,offset)
190  putBox(h, 0, 112, 2, 116, offset); putLine(h,2,112,2,116,offset); putLine(h,0,112,2,112,offset)
191  putLine(h,2,52,2,106,offset)
192 
193  # Mid Section
194  putBox(h, 8, 0, 9, 106, offset); putLine(h,8,0,8,106, offset); putLine(h,8,106,9,106, offset); putLine(h,9,0,9,106, offset)
195  putBox(h, 8, 108, 9, 110, offset); putLine(h,8,108,9,108, offset); putLine(h,8,110,9,110, offset); putLine(h,8,108,8,110, offset); putLine(h,9,108,9,110, offset)
196  putBox(h, 8, 112, 9, 116, offset); putLine(h,8,112,9,112, offset); putLine(h,8,112,8,116, offset); putLine(h,9,112,9,116, offset)
197 
198  # Right Side
199  putBox(h, 11, 0, 17, 16, offset); putLine(h,11,0,11,16, offset); putLine(h,11,16,15,16, offset)
200  putBox(h, 15, 16, 17, 18, offset); putLine(h,15,16,15,18, offset)
201  if geo==0:
202  putLine(h,15,18,17,18, offset) # 1
203  elif geo==1:
204  putLine(h,15,18,16,18, offset) # 1
205  putBox(h, 15, 20, 17, 22, offset); putLine(h,15,20,15,22, offset); putLine(h,15,20,17,20, offset); putLine(h,15,22,17,22, offset) # 3
206  putBox(h, 15, 24, 17, 26, offset); putLine(h,15,24,15,26, offset); putLine(h,15,24,17,24, offset); putLine(h,15,26,17,26, offset) # 5
207  putBox(h, 15, 28, 17, 30, offset); putLine(h,15,28,15,30, offset); putLine(h,15,28,17,28, offset); putLine(h,15,30,17,30, offset) # 7
208  putBox(h, 15, 32, 17, 34, offset); putLine(h,15,32,15,34, offset); putLine(h,15,32,17,32, offset); putLine(h,15,34,17,34, offset) # 9
209  putBox(h, 14, 36, 17, 38, offset); putLine(h,14,36,14,38, offset); putLine(h,14,36,17,36, offset); putLine(h,14,38,15,38, offset) # 11M
210  putBox(h, 15, 38, 17, 40, offset); putLine(h,15,38,15,40, offset); putLine(h,15,40,17,40, offset) # 11R
211  putBox(h, 15, 42, 17, 44, offset); putLine(h,15,42,15,44, offset); putLine(h,15,42,17,42, offset); putLine(h,15,44,17,44, offset) # 13
212  putBox(h, 14, 46, 17, 48, offset); putLine(h,14,46,14,48, offset); putLine(h,14,46,17,46, offset); putLine(h,14,48,15,48, offset) # 15M
213  putBox(h, 15, 48, 17, 50, offset); putLine(h,15,48,15,50, offset); putLine(h,15,50,17,50, offset) # 15R
214  putBox(h, 15, 52, 17, 106, offset)
215  if geo==0:
216  putLine(h,15,52,17,52, offset)
217  elif geo==1:
218  putLine(h,15,52,16,52, offset)
219  putLine(h,15,106,17,106, offset)
220  putBox(h, 16, 108, 17, 110, offset); putLine(h,16,108,16,110, offset); putLine(h,16,108,17,108, offset); putLine(h,16,110,17,110, offset)
221  putBox(h, 15, 112, 17, 116, offset); putLine(h,15,112,15,116, offset); putLine(h,15,112,17,112, offset)
222 
223  if geo==1:
224  putBox(h, 8, 18, 9, 52, 0)
225 
226  putLine(h,15,52,15,106, offset)
227 
228  elif(ecap == "E"):
229  offset = 6
230  # Bottom:
231  putBox(h, 0, 0, 4, 32, offset); putBox(h, 4, 8, 5, 10, offset)
232  putLine(h, 4, 0, 4, 8, offset); putLine(h, 4, 8, 5, 8, offset); putLine(h, 5, 8, 5, 10, offset); putLine(h, 4, 10, 5, 10, offset); putLine(h, 4, 10, 4, 32, offset) # Left side
233  putBox(h, 8, 0, 12, 32, offset); putBox(h, 7, 8, 8, 10, offset)
234  putLine(h, 8, 0, 8, 8, offset); putLine(h, 7, 8, 8, 8, offset); putLine(h, 7, 8, 7, 10, offset); putLine(h, 7, 10, 8, 10, offset); putLine(h, 8, 10, 8, 32, offset)
235  # Left
236  putBox(h, 0, 32, 1, 34, offset)
237  putBox(h, 0, 34, 4, 36, offset)
238  putBox(h, 0, 36, 2, 38, offset); putLine(h, 2, 36, 2, 38, offset) # phi 3
239  putBox(h, 0, 38, 4, 40, offset)
240  putBox(h, 0, 40, 2, 42, offset)
241  putBox(h, 0, 42, 4, 44, offset)
242  putBox(h, 0, 44, 2, 46, offset); putLine(h, 2, 44, 2, 46, offset) # phi 7
243  putBox(h, 0, 46, 4, 48, offset); putLine(h, 2, 46, 4, 46, offset)
244  putBox(h, 0, 48, 1, 50, offset); putLine(h, 1, 48, 1, 50, offset) # phi 9
245  putBox(h, 0, 50, 4, 52, offset)
246  putBox(h, 0, 52, 2, 54, offset)
247  putBox(h, 0, 54, 4, 56, offset)
248  putBox(h, 0, 56, 2, 58, offset)
249  putBox(h, 0, 58, 4, 60, offset)
250  putBox(h, 0, 60, 2, 62, offset)
251  putBox(h, 0, 62, 4, 64, offset)
252  putBox(h, 0, 64, 1, 96, offset); putLine(h, 1, 64, 1, 96, offset); putLine(h, 0, 96, 1, 96, offset)
253  if geo==1:
254  putBox(h, -3, 32, 3, 64, 0)
255 
256  if geo==0:
257  putLine(h, 1, 32, 4, 32, offset)
258  putLine(h, 1, 34, 4, 34, offset)
259  putLine(h, 1, 48, 4, 48, offset) # phi 8
260  putLine(h, 1, 50, 4, 50, offset)
261  putLine(h, 1, 64, 4, 64, offset) # phi 16
262  putLine(h, 2, 36, 4, 36, offset) # phi 2
263  putLine(h, 2, 38, 4, 38, offset)
264  putLine(h, 2, 40, 4, 40, offset) # phi 4
265  putLine(h, 2, 42, 4, 42, offset)
266  putLine(h, 2, 44, 4, 44, offset) # phi 6
267  putLine(h, 2, 52, 4, 52, offset) # phi 10
268  putLine(h, 2, 54, 4, 54, offset)
269  putLine(h, 2, 56, 4, 56, offset) # phi 12
270  putLine(h, 2, 58, 4, 58, offset)
271  putLine(h, 2, 60, 4, 60, offset) # phi 14
272  putLine(h, 2, 62, 4, 62, offset)
273  elif geo==1:
274  putLine(h, 1, 32, 3, 32, offset)
275  putLine(h, 1, 34, 3, 34, offset)
276  putLine(h, 1, 48, 3, 48, offset) # phi 8
277  putLine(h, 1, 50, 3, 50, offset)
278  putLine(h, 1, 64, 3, 64, offset) # phi 16
279  putLine(h, 2, 36, 3, 36, offset) # phi 2
280  putLine(h, 2, 38, 3, 38, offset)
281  putLine(h, 2, 40, 3, 40, offset) # phi 4
282  putLine(h, 2, 42, 3, 42, offset)
283  putLine(h, 2, 44, 3, 44, offset) # phi 6
284  putLine(h, 2, 52, 3, 52, offset) # phi 10
285  putLine(h, 2, 54, 3, 54, offset)
286  putLine(h, 2, 56, 3, 56, offset) # phi 12
287  putLine(h, 2, 58, 3, 58, offset)
288  putLine(h, 2, 60, 3, 60, offset) # phi 14
289  putLine(h, 2, 62, 3, 62, offset)
290 
291  if geo==0:
292  putLine(h, 4, 34, 4, 36, offset)
293  putLine(h, 4, 38, 4, 40, offset)
294  putLine(h, 4, 42, 4, 44, offset)
295  putLine(h, 4, 46, 4, 48, offset)
296  putLine(h, 4, 50, 4, 52, offset)
297  putLine(h, 4, 54, 4, 56, offset)
298  putLine(h, 4, 58, 4, 60, offset)
299  putLine(h, 4, 62, 4, 64, offset)
300 
301  putLine(h, 1, 32, 1, 34, offset) # phi 1
302  putLine(h, 2, 40, 2, 42, offset) # phi 5
303  putLine(h, 2, 52, 2, 54, offset) # phi 11
304  putLine(h, 2, 56, 2, 58, offset) # phi 13
305  putLine(h, 2, 60, 2, 62, offset) # phi 15
306 
307 
308  # Right
309  putBox(h, 11, 32, 12, 34, offset)
310  putBox(h, 8, 34, 12, 36, offset)
311  putBox(h, 10, 36, 12, 38, offset); putLine(h, 10, 36, 10, 38, offset) # phi 3
312  putBox(h, 8, 38, 12, 40, offset)
313  putBox(h, 10, 40, 12, 42, offset); putLine(h, 10, 40, 10, 42, offset) # phi 5
314  putBox(h, 8, 42, 12, 44, offset)
315  putBox(h, 10, 44, 12, 46, offset); putLine(h, 10, 44, 10, 46, offset) # phi 7
316  putBox(h, 8, 46, 12, 48, offset)# phi 8
317  putBox(h, 11, 48, 12, 50, offset); putLine(h, 11, 48, 11, 50, offset) # phi 9
318  putBox(h, 8, 50, 12, 52, offset)
319  putBox(h, 10, 52, 12, 54, offset); putLine(h, 10, 52, 10, 54, offset) # phi 11
320  putBox(h, 8, 54, 12, 56, offset)
321  putBox(h, 10, 56, 12, 58, offset); putLine(h, 10, 56, 10, 58, offset) # phi 13
322  putBox(h, 8, 58, 12, 60, offset)
323  putBox(h, 10, 60, 12, 62, offset); putLine(h, 10, 60, 10, 62, offset) # phi 15
324  putBox(h, 8, 62, 12, 64, offset)
325  putBox(h, 11, 64, 12, 96, offset); putLine(h, 11, 64, 11, 96, offset); putLine(h, 12, 96, 11, 96, offset)
326 
327  if geo==0:
328  putLine(h, 8, 32, 11, 32, offset)
329  putLine(h, 8, 34, 11, 34, offset)
330  putLine(h, 10, 36, 8, 36, offset) # phi 2
331  putLine(h, 10, 38, 8, 38, offset)
332  putLine(h, 10, 40, 8, 40, offset) # phi 4
333  putLine(h, 10, 42, 8, 42, offset)
334  putLine(h, 10, 44, 8, 44, offset) # phi 6
335  putLine(h, 10, 46, 8, 46, offset)
336  putLine(h, 11, 48, 8, 48, offset) # phi 8
337  putLine(h, 11, 50, 8, 50, offset)
338  putLine(h, 10, 52, 8, 52, offset) # phi 10
339  putLine(h, 10, 54, 8, 54, offset)
340  putLine(h, 10, 56, 8, 56, offset) # phi 12
341  putLine(h, 10, 58, 8, 58, offset)
342  putLine(h, 10, 60, 8, 60, offset) # phi 14
343  putLine(h, 10, 62, 8, 62, offset)
344  putLine(h, 11, 64, 8, 64, offset) # phi 16
345  elif geo==1:
346  putLine(h, 9, 32, 11, 32, offset)
347  putLine(h, 9, 34, 11, 34, offset)
348  putLine(h, 10, 36, 9, 36, offset) # phi 2
349  putLine(h, 10, 38, 9, 38, offset)
350  putLine(h, 10, 40, 9, 40, offset) # phi 4
351  putLine(h, 10, 42, 9, 42, offset)
352  putLine(h, 10, 44, 9, 44, offset) # phi 6
353  putLine(h, 10, 46, 9, 46, offset)
354  putLine(h, 11, 48, 9, 48, offset) # phi 8
355  putLine(h, 11, 50, 9, 50, offset)
356  putLine(h, 10, 52, 9, 52, offset) # phi 10
357  putLine(h, 10, 54, 9, 54, offset)
358  putLine(h, 10, 56, 9, 56, offset) # phi 12
359  putLine(h, 10, 58, 9, 58, offset)
360  putLine(h, 10, 60, 9, 60, offset) # phi 14
361  putLine(h, 10, 62, 9, 62, offset)
362  putLine(h, 11, 64, 9, 64, offset) # phi 16
363 
364  if geo==0:
365  putLine(h, 8, 34, 8, 36, offset)
366  putLine(h, 8, 38, 8, 40, offset)
367  putLine(h, 8, 42, 8, 44, offset)
368  putLine(h, 8, 46, 8, 48, offset)
369  putLine(h, 8, 50, 8, 52, offset)
370  putLine(h, 8, 54, 8, 56, offset)
371  putLine(h, 8, 58, 8, 60, offset)
372  putLine(h, 8, 62, 8, 64, offset)
373 
374  putLine(h, 11, 32, 11, 34, offset) # phi 1
375 
376 
377 def putBox(h, x1, y1, x2, y2, offset):
378  box = TBox(x1-offset, y1*0.5, x2-offset, y2*0.5)
379  box.SetFillColor(kGray)
380  box.SetLineColor(kGray)
381  h.GetListOfFunctions().Add(box)
382 
383 def putLine(h, x1, y1, x2, y2, offset=0, c=1):
384  line = TLine(x1-offset, y1*0.5, x2-offset, y2*0.5)
385  line.SetLineColor(c)
386  h.GetListOfFunctions().Add(line)
387 
388 tubeLenght_dict = {
389  "BEE": 0.9115,
390  "BIS": 1.6715,
391  "BIS8": 0.8515,
392  "BIL": 2.6715,
393  "BIM" : 1.5365,
394  "BIR" : 1.1055,
395  "BIR1" : 2.6715,
396  "BIR2" : 1.5365,
397  "BIR4": 1.5365,
398  "BIR5" : 1.5365,
399  "BIR3" : 1.1055,
400  "BIR6" : 1.1055,
401  "BME" : 2.15, #approximate!
402  "BMG" : 1.12, #approximate!
403  "BML" : 3.5515,
404  "BMS" : 3.0715,
405  "BMF" : 3.0715,
406  "BOL" : 4.9615,
407  "BOG" : 3.7715,
408  "BOS": 3.7733,
409  "BOF" : 3.7733,
410  "EES1" : 2.1945,
411  "EES2" : 2.5905,
412  "EEL105": 2.6265,
413  "EEL1" : 4.2015,
414  "EEL2" : 3.6015,
415  "EIS1" : 1.0605,
416  "EIS2" : 1.4115,
417  "EIL1" : 1.5465,
418  "EIL2" : 2.0865,
419  "EIL311" : 1.7415,
420  "EIL315" : 1.7415,
421  "EIL3" : 2.0715,
422  "EIL411" : 1.5515,
423  "EIL415" : 1.5515,
424  "EIL401" : 1.5365,
425  "EIL409" : 1.5365,
426  "EIL403" : 2.8015,
427  "EIL405" : 2.8015,
428  "EIL413" : 2.8015,
429  "EIL407" : 2.0115,
430  "EIL501" : 2.8015,
431  "EIL509" : 2.8015,
432  "EML1" : 1.5465,
433  "EML2" : 2.4465,
434  "EML3" : 3.4065,
435  "EML4" : 4.3665,
436  "EML5" : 5.3265,
437  "EMS1" : 1.0875,
438  "EMS2" : 1.6635,
439  "EMS3" : 2.2395,
440  "EMS4" : 2.8155,
441  "EMS5" : 3.3915,
442  "EOL1" : 2.0415,
443  "EOL2" : 3.0015,
444  "EOL3" : 3.7815,
445  "EOL4" : 4.5015,
446  "EOL5" : 5.2215,
447  "EOL6" : 5.9415,
448  "EOS1" : 1.4655,
449  "EOS2" : 1.9695,
450  "EOS3" : 2.4735,
451  "EOS4" : 2.9415,
452  "EOS5" : 3.3735,
453  "EOS6" : 3.8055,
454 }
455 
456 def getTubeLength( name ):
457 
458  name03=name[0:3]
459  name04=name[0:4]
460  name56= name[5:7]
461 
462  tubeLength = 4.9615
463 
464  tubeLength = tubeLenght_dict.get(name03, tubeLength)
465  tubeLength = tubeLenght_dict.get(name04, tubeLength)
466  tubeLength = tubeLenght_dict.get(name03+name56, tubeLength)
467  tubeLength = tubeLenght_dict.get(name04+name56, tubeLength)
468 
469  return tubeLength
470 
471 
472 def MDT2DHWName(name):
473  statphi_s = name[5:7]
474  eta_s = name[3:4]
475  #ME1[AC]14 (mistake - is actually 13 - so account for both cases!) -->BME4[AC]13 in histogram position
476  if(name[0:3]=="BME"):
477  eta_s = "4"
478  statphi_s = "13"
479 
480  statphi_c = statphi_s+" 1"
481  statphi_c2 = statphi_s+" 2"
482  if(name[0:3]=="BIR" or name[0:3]=="BIM") :
483  statphi_c = statphi_c +" "+name[2:3]
484  statphi_c2 = statphi_c2 +" "+name[2:3]
485 
486  #BML[45][AC]13-->BML[56][AC]13
487  if(name[0:3] == "BML" and int(name[3:4])>=4 and name[5:7] == "13"):
488  eta_s = str(int(name[3:4])+1)
489 
490  #BMF1,2,3 corresponds to eta stations 1,3,5
491  if( name[0:3] == "BMF"):
492  eta_s=str(int(name[3:4])*2-1)
493 
494  stateta_c = name[0:2]
495  stateta_c += name[4:5]
496  stateta_c += eta_s
497 
498  stateta_IMO_c = name[0:1]
499  stateta_IMO_c += name[4:5]
500  stateta_IMO_c += eta_s
501 
502  statphi_IMO_c = name[1:2]+" "+statphi_s
503  if((name[0:3]=="BIR" or name[0:3]=="BIM") and (name[5:7] == "11" or name[5:7] == "15" )):
504  statphi_IMO_c = statphi_IMO_c+" "+name[2:3]
505 
506  return (stateta_IMO_c, statphi_IMO_c, stateta_c, statphi_c, statphi_c2)
507 
508 
509 def MDTTubeEff(name,hi_num,hi_den):
510  nBinsNum = hi_num.GetNbinsX()
511  BinsML1 = nBinsNum/2
512  if(name[0:4]=="BIS8" or name[0:2]=="BE"):
513  BinsML1=nBinsNum
514  if(nBinsNum!=hi_den.GetNbinsX()):
515  return
516  countsML1=0
517  countsML2=0
518  entriesML1=0
519  entriesML2=0
520  for ibin in range(nBinsNum):
521  entries = hi_den.GetBinContent(ibin)
522  counts = hi_num.GetBinContent(ibin)
523  if(ibin<BinsML1 or BinsML1==nBinsNum) :
524  countsML1+=counts
525  entriesML1+=entries
526  else:
527  countsML2+=counts
528  entriesML2+=entries
529 
530  return (countsML1, countsML2, entriesML1, entriesML2)
531 
532 
533 def fittzero(x, par):
534  fitvaltzero = par[0] + ( par[3] / ( 1 + ( TMath.Exp((-x[0]+par[1])/par[2]) ) ) )
535  return fitvaltzero
536 
537 tf1_fittzero = TF1("func1", fittzero, 0., 200., 4)
538 
539 
540 def fittmax(x, par):
541  fitvaltmax = par[0] + ( par[3] / ( 1 + ( TMath.Exp((x[0]-par[1])/par[2]) ) ) )
542  return fitvaltmax
543 
544 tf1_fittmax = TF1("func2", fittmax, 0., 200., 4)
545 
546 def MDTFitTDC(h):
547  t0 = 0
548  tmax = 0
549  t0err = 0
550  tmaxerr = 0
551  up = h.GetBinCenter(h.GetMaximumBin()+1)
552  if( up > 200 ):
553  up = 200
554  down = up + 650
555  if( up < 50 ):
556  up = 50
557  parESD0 = h.GetBinContent(h.GetMinimumBin())
558  parESD1 = up
559  parESD2 = 20
560  parESD3 = h.GetBinContent(h.GetMaximumBin()) - h.GetBinContent(h.GetMinimumBin())
561  func1 = tf1_fittzero
562  func1.SetRange(0., up)
563  func1.SetParameters(parESD0, parESD1, parESD2, parESD3)
564  func1.SetLineColor(kBlue+2)
565  if(h.GetEntries()>100):
566  h.Fit("func1","RQN")
567  t0 = func1.GetParameter(1)
568  t0err = func1.GetParError(1)
569  binAtT0 = h.GetBinContent(h.FindBin(t0))
570  if(binAtT0<1):
571  binAtT0 = 1
572  # // to additionally account for bad fits
573  if(func1.GetNumberFitPoints()!=0):
574  t0err += 10.0 * func1.GetChisquare() / (0.01*binAtT0*binAtT0*func1.GetNumberFitPoints())
575 
576  parESD0 = h.GetBinContent(h.GetMinimumBin())
577  parESD1 = down
578  parESD2 = 50
579  parESD3 = (h.GetBinContent(h.GetMaximumBin())-h.GetBinContent(h.GetMinimumBin()))/10.
580  func2 = tf1_fittmax
581  func2.SetRange((down-135), (down+135))
582  func2.SetParameters(parESD0,parESD1,parESD2,parESD3)
583  func2.SetLineColor(kRed+1)
584  if(h.GetEntries()>100):
585  func2.SetParLimits(0, parESD0, 2.0*parESD0+1)
586  func2.SetParLimits(2, 5, 90)
587  func2.SetParLimits(3, 0.2*parESD3, 7*parESD3)
588  h.Fit("func2","WWRQN+")
589  tmax = func2.GetParameter(1)
590  tmaxerr = func2.GetParError(1)
591  binAtTmax = h.GetBinContent(h.FindBin(tmax))
592  if(binAtTmax<1):
593  binAtTmax = 1
594  # to additionally account for bad fits
595  if func2.GetNumberFitPoints() > 0:
596  tmaxerr += 10.0 * func2.GetChisquare() / (0.01*binAtTmax*binAtTmax*func2.GetNumberFitPoints())
597 
598  return [t0, t0err, tmax, tmaxerr]
599 
600 
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MdtMonUtils.MDTTubeEff
def MDTTubeEff(name, hi_num, hi_den)
Definition: MdtMonUtils.py:509
MdtMonUtils.fittmax
def fittmax(x, par)
Definition: MdtMonUtils.py:540
MdtMonUtils.getMDTLabelx
def getMDTLabelx(x)
Definition: MdtMonUtils.py:14
MdtMonUtils.getMDTLabel
def getMDTLabel(x, y)
Definition: MdtMonUtils.py:8
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.grid.Add
def Add(name)
Definition: grid.py:41
MdtRawMonLabels
MdtMonUtils.putBoxMdtRegional
def putBoxMdtRegional(h, xAxis, geo)
Definition: MdtMonUtils.py:19
MdtMonUtils.putLine
def putLine(h, x1, y1, x2, y2, offset=0, c=1)
Definition: MdtMonUtils.py:383
MdtMonUtils.getTubeLength
def getTubeLength(name)
Definition: MdtMonUtils.py:456
MdtMonUtils.MDTFitTDC
def MDTFitTDC(h)
Definition: MdtMonUtils.py:546
MdtMonUtils.putBox
def putBox(h, x1, y1, x2, y2, offset)
Definition: MdtMonUtils.py:377
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
MdtMonUtils.MDT2DHWName
def MDT2DHWName(name)
Definition: MdtMonUtils.py:472
str
Definition: BTagTrackIpAccessor.cxx:11
MdtMonUtils.putBoxMdtGlobal
def putBoxMdtGlobal(h, ecap, geo)
Definition: MdtMonUtils.py:169
MdtMonUtils.fittzero
def fittzero(x, par)
Definition: MdtMonUtils.py:533