19 {
20
21 double dmin = 10.;
22 double dphimin = dmin /
cell.caloDDE()->r();
23
24
25
26 double dphi =
cell.caloDDE()->dphi();
27 if (dphi < dphimin) dphi = dphimin;
28 double CellPhimin =
cell.caloDDE()->phi() - dphi * 0.5;
29 double CellPhimax =
cell.caloDDE()->phi() + dphi * 0.5;
30
31
32
33 int isign = 1;
34 if (
cell.caloDDE()->z() < 0) isign = -1;
35 double dr =
cell.caloDDE()->dr();
36
37
38
39
40 if (dr == 0)
dr = drFix;
42 if (dr < dmin)
dr = dmin;
43 double dz =
cell.caloDDE()->dz();
44 if (dz == 0) dz = dzFix;
45 dz = dzFix;
46 if (dz < dmin) dz = dmin;
47
48 double CellZmin =
cell.caloDDE()->z() - isign * dz * 0.5;
49 double CellZmax =
cell.caloDDE()->z() + isign * dz * 0.5;
50 double CellRmin =
cell.caloDDE()->r() -
dr * 0.5;
51 double CellRmax =
cell.caloDDE()->r() +
dr * 0.5;
52
53
54
55
56
58 if (
dir.mag() == 0)
return 0.;
60
61
62
63 double r0 = (entrance.x() -
cell.caloDDE()->x()) *
sin(
dir.phi()) - (entrance.y() -
cell.caloDDE()->y()) *
cos(
dir.phi());
64 bool crossing = true;
65 if (fabs(r0) > sqrt(
cell.caloDDE()->r() *
cell.caloDDE()->r() * dphi * dphi + dr * dr)) crossing =
false;
66
67
68
69 double rz0 = (entrance.perp() -
cell.caloDDE()->r()) *
cos(
dir.theta()) - (entrance.z() -
cell.caloDDE()->z()) *
sin(
dir.theta());
70 if (fabs(rz0) > sqrt(dr * dr + dz * dz)) crossing = false;
71
72
73 if (!crossing) return 0.;
74
75
76
81
86
87
88
91
93
94
95
96
99
101
102
103
105 dirT = -dirT;
106
107
108
109
110 double dotp1 = fabs(dirT.dot(dir01) / dir01.mag() / dirT.mag());
111 double dotp2 = fabs(dirT.dot(dir02) / dir02.mag() / dirT.mag());
112 double dotp4 = fabs(dirT.dot(dir04) / dir04.mag() / dirT.mag());
113
114
115
116
117
118
119
120
121
122
123
126 mEntry.setZero();
127 mExit.setZero();
128 mEntry.col(2) = dirT;
129 mExit.col(2) = dirT;
130
131 int type = 0;
132 if (dotp1 <= dotp2 && dotp2 <= dotp4) {
134 mEntry.col(0) = dir01;
135 mEntry.col(1) = dir02;
136 mExit.col(0) = dir67;
137 mExit.col(1) = dir64;
138 } else if (dotp1 <= dotp4 && dotp4 <= dotp2) {
140 mEntry.col(0) = dir01;
141 mEntry.col(1) = dir04;
142 mExit.col(0) = dir67;
143 mExit.col(1) = dir62;
144 } else if (dotp2 <= dotp1 && dotp1 <= dotp4) {
146 mEntry.col(0) = dir02;
147 mEntry.col(1) = dir01;
148 mExit.col(0) = dir64;
149 mExit.col(1) = dir67;
150 } else if (dotp2 <= dotp4 && dotp4 <= dotp1) {
152 mEntry.col(0) = dir02;
153 mEntry.col(1) = dir04;
154 mExit.col(0) = dir64;
155 mExit.col(1) = dir62;
156 } else if (dotp4 <= dotp2 && dotp2 <= dotp1) {
158 mEntry.col(0) = dir04;
159 mEntry.col(1) = dir02;
160 mExit.col(0) = dir62;
161 mExit.col(1) = dir64;
162 } else if (dotp4 <= dotp1 && dotp1 <= dotp2) {
164 mEntry.col(0) = dir04;
165 mEntry.col(1) = dir01;
166 mExit.col(0) = dir62;
167 mExit.col(1) = dir67;
168 }
169
170
171
172 Amg::Vector3D posEn = entrance - (Corner1 + Corner2 + Corner4) / 2.;
173 Amg::Vector3D posEx = entrance - (Corner2 + Corner4 + Corner7) / 2.;
174
175
176
177
178
179
180
181
182 int type0 =
type - 10 *
int(type / 10);
183 if (type0 == 1) {
184
185 posEn += Corner1 / 2.;
186 posEx += Corner7 / 2.;
187 }
188 if (type0 == 2) {
189
190 posEn += Corner2 / 2.;
191 posEx += Corner4 / 2.;
192 }
193 if (type0 == 4) {
194
195 posEn += Corner4 / 2.;
196 posEx += Corner2 / 2.;
197 }
198
199
200
201 int typeCheck = type0;
202
205
206 if (!crossingEn) {
207 int type1 =
int((type - 100 *
int(type / 100)) / 10);
208 int type2 =
int(type / 100);
209 if (type1 == 1) posEn += Corner1 / 2.;
210 if (type1 == 2) posEn += Corner2 / 2.;
211 if (type1 == 4) posEn += Corner4 / 2.;
212 if (type0 == 1) {
213 mEntry.col(1) = dir01;
214 posEn -= Corner1 / 2.;
215 }
216 if (type0 == 2) {
217 mEntry.col(1) = dir02;
218 posEn -= Corner2 / 2.;
219 }
220 if (type0 == 4) {
221 mEntry.col(1) = dir04;
222 posEn -= Corner4 / 2.;
223 }
225 typeCheck = type1;
226 if (!crossingEn) {
227 if (type2 == 1) posEn += Corner1 / 2.;
228 if (type2 == 2) posEn += Corner2 / 2.;
229 if (type2 == 4) posEn += Corner4 / 2.;
230 if (type1 == 1) {
231 mEntry.col(0) = dir01;
232 posEn -= Corner1 / 2.;
233 }
234 if (type1 == 2) {
235 mEntry.col(0) = dir02;
236 posEn -= Corner2 / 2.;
237 }
238 if (type1 == 4) {
239 mEntry.col(0) = dir04;
240 posEn -= Corner4 / 2.;
241 }
243 typeCheck = type2;
244 }
245 }
246
248 if (crossingEn) {
249 posXEn = entrance - dirT * pathEn.z();
250 if (typeCheck == 1) {
251 double dphiCheck =
252 acos(
cos(posXEn.phi()) *
cos((CellPhimax + CellPhimin) / 2.) +
sin(posXEn.phi()) *
sin((CellPhimax + CellPhimin) / 2.));
253 if (dphiCheck > fabs(CellPhimax - CellPhimin)) { crossingEn = false; }
254 }
255 if (typeCheck == 2) {
256 if (posXEn.perp() < CellRmin) crossingEn = false;
257 if (posXEn.perp() > CellRmax) crossingEn = false;
258 }
259 if (typeCheck == 4) {
260 if (isign * posXEn.z() < isign * CellZmin) crossingEn = false;
261 if (isign * posXEn.z() > isign * CellZmax) crossingEn = false;
262 }
263 }
264
265 if (!crossingEn) return 0.;
266
267
268
271 typeCheck = type0;
272 if (!crossingEx) {
273 int type1 =
int((type - 100 *
int(type / 100)) / 10);
274 int type2 =
int(type / 100);
275 if (type1 == 1) posEx += Corner7 / 2.;
276 if (type1 == 2) posEx += Corner4 / 2.;
277 if (type1 == 4) posEx += Corner2 / 2.;
278 if (type0 == 1) {
279 mExit.col(1) = dir67;
280 posEx -= Corner7 / 2.;
281 }
282 if (type0 == 2) {
283 mExit.col(1) = dir64;
284 posEx -= Corner4 / 2.;
285 }
286 if (type0 == 4) {
287 mExit.col(1) = dir62;
288 posEx -= Corner2 / 2.;
289 }
291 typeCheck = type1;
292 if (!crossingEx) {
293 if (type2 == 1) posEx += Corner7 / 2.;
294 if (type2 == 2) posEx += Corner4 / 2.;
295 if (type2 == 4) posEx += Corner2 / 2.;
296 if (type1 == 1) {
297 mExit.col(0) = dir67;
298 posEx -= Corner7 / 2.;
299 }
300 if (type1 == 2) {
301 mExit.col(0) = dir64;
302 posEx -= Corner4 / 2.;
303 }
304 if (type1 == 4) {
305 mExit.col(0) = dir62;
306 posEx -= Corner2 / 2.;
307 }
309 typeCheck = type2;
310 }
311 }
312
314 if (crossingEx) {
315 posXEx = entrance - dirT * pathEx.z();
316 if (typeCheck == 1) {
317 double dphiCheck =
318 acos(
cos(posXEx.phi()) *
cos((CellPhimax + CellPhimin) / 2.) +
sin(posXEx.phi()) *
sin((CellPhimax + CellPhimin) / 2.));
319 if (dphiCheck > fabs(CellPhimax - CellPhimin)) { crossingEx = false; }
320 }
321 if (typeCheck == 2) {
322 if (posXEx.perp() < CellRmin) crossingEx = false;
323 if (posXEx.perp() > CellRmax) crossingEx = false;
324 }
325 if (typeCheck == 4) {
326 if (isign * posXEx.z() < isign * CellZmin) crossingEx = false;
327 if (isign * posXEx.z() > isign * CellZmax) crossingEx = false;
328 }
329 }
331 if (crossingEn && crossingEx) {
332 path = (posXEx - posXEn).
mag();
333 }
334
336}
Scalar mag() const
mag method
static bool crossingMatrix(const AmgMatrix(3, 3)&Matrix, const Amg::Vector3D &entry, Amg::Vector3D &path)
Eigen::Matrix< double, 3, 1 > Vector3D
const double r0
electron radius{cm}
path
python interpreter configuration --------------------------------------—