105 def getTopoCellPosition(cls, etacode, phicode, rois):
106 rois = list(rois)
107
108
109
110
111
112
113
114
115 cellsEta = [(
min(e.etamin,e.etamax),
max(e.etamin,e.etamax))
for e
in rois]
116 etamins, etamaxs = zip(*cellsEta)
117 etamin =
min( [
min(e.etamin,e.etamax)
for e
in rois] )
118 etamax =
max( [
max(e.etamin,e.etamax)
for e
in rois] )
119 eta = (etamin+etamax)/2
120
121
122
123 cellsPhi = [(e.phimin, e.phimax) for e in rois]
124
125
126 upperedge = any([e.phi>6.2 for e in rois])
127 loweredge = any([e.phi<0.2 for e in rois])
128 splitTopoCell = upperedge and loweredge
129
130
131 if splitTopoCell:
132 maxAtLowerEdge =
max([e.phimax
for e
in rois
if e.phi<1])
133 minAtUpperEdge =
min([e.phimin
for e
in rois
if e.phi>5])
134 centerTopoCell = minAtUpperEdge + maxAtLowerEdge
135 if centerTopoCell>=2*PI:
136 phimin = minAtUpperEdge - 2 * PI
137 phimax = maxAtLowerEdge
138 else:
139 phimin = minAtUpperEdge
140 phimax = maxAtLowerEdge + 2 * PI
141 phi = (phimin+phimax)/2
142 else:
143
144 phimins, phimaxs = zip(*cellsPhi)
145 phimin =
min(phimins)
146 phimax =
max(phimaxs)
147 phi = (phimin+phimax)/2
148
149
150
151 ieta = round(eta*10)
152 if ieta== 12: ieta= 11
153 if ieta==-12: ieta=-11
154 if ieta== 9: ieta= 8
155 if ieta==-9: ieta=-8
156
157
158 iphi = int(phi*10)
159 if abs(ieta) in [2,5]:
160 if phi>2.05 and phi<2.35: iphi += 1
161 if phi>2.75 and phi<3.25: iphi += 1
162 if phi>3.45: iphi += 1
163
164 if abs(ieta) == 8:
165 if phi>2.05 and phi<2.35: iphi += 1
166 if phi>2.75 and phi<3.25: iphi += 1
167 if phi>3.45 and phi<4.95: iphi += 1
168 if phi>5.05: iphi += 1
169
170 if abs(ieta) in [15,18]:
171 if phi>2.65: iphi += 1
172
173 if abs(ieta) == 11:
174 if phi>2.15 and phi<2.35: iphi += 1
175 if phi>2.65 and phi<3.25: iphi += 1
176 if phi>3.35: iphi += 1
177
178 if abs(ieta) == 22:
179 if phi>0.05 and phi<5.35: iphi += 1
180 if phi>5.35: iphi += 2
181
182 return (eta, phi, ieta, iphi, etamin, etamax, phimin, phimax)
183