29 pt_xml = fmin(20.,
pt);
30 pt_scale = 1.2 / (1 - 0.015 * pt_xml);
39 float pt_unscale = -99;
43 pt_unscale = 1 / (1.2 + 0.015 *
pt);
44 pt_unscale = fmax(pt_unscale, (1 - 0.015 * 20) / 1.2);
58 int nHits = (
mode / 8) + ((
mode % 8) / 4) + ((
mode % 4) / 2) + ((
mode % 2) / 1);
63 int iA = -1, iB = -1, iC = -1, iD = -1;
64 int iAB, iAC, iAD, iBC, iCD;
131 iAB = (iA >= 0 && iB >= 0) ? iA + iB - (iA == 0) : -1;
132 iAC = (iA >= 0 && iC >= 0) ? iA + iC - (iA == 0) : -1;
133 iAD = (iA >= 0 && iD >= 0) ? 2 : -1;
134 iBC = (iB >= 0 && iC >= 0) ? iB + iC : -1;
135 iCD = (iC >= 0 && iD >= 0) ? 5 : -1;
138 int st1_ring2 =
data.st1_ring2;
140 int dPhiAB =
data.delta_ph[iAB];
141 int dPhiBC =
data.delta_ph[iBC];
142 int dPhiCD =
data.delta_ph[iCD];
143 int sPhiAB =
data.sign_ph[iAB];
144 int sPhiBC = (
data.sign_ph[iBC] == sPhiAB);
145 int sPhiCD = (
data.sign_ph[iCD] == sPhiAB);
146 int dTheta =
data.delta_th[iAD] * (
data.sign_th[iAD] ? 1 : -1);
147 int frA =
data.fr[iA];
148 int clctA =
data.cpattern[iA];
149 int clctB =
data.cpattern[iB];
150 int clctC =
data.cpattern[iC];
151 int clctD =
data.cpattern[iD];
162 address |= (dPhiAB & ((1 << 7) - 1)) << (0);
163 address |= (dPhiBC & ((1 << 5) - 1)) << (0 + 7);
164 address |= (dPhiCD & ((1 << 4) - 1)) << (0 + 7 + 5);
165 address |= (sPhiBC & ((1 << 1) - 1)) << (0 + 7 + 5 + 4);
166 address |= (sPhiCD & ((1 << 1) - 1)) << (0 + 7 + 5 + 4 + 1);
167 address |= (dTheta & ((1 << 2) - 1)) << (0 + 7 + 5 + 4 + 1 + 1);
168 address |= (frA & ((1 << 1) - 1)) << (0 + 7 + 5 + 4 + 1 + 1 + 2);
169 address |= (mode15_8b & ((1 << 8) - 1)) << (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1);
170 address |= (mode_ID & ((1 << 1) - 1)) << (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1 + 8);
172 }
else if (nHits == 3) {
173 int dPhiAB =
data.delta_ph[iAB];
174 int dPhiBC =
data.delta_ph[iBC];
175 int sPhiAB =
data.sign_ph[iAB];
176 int sPhiBC = (
data.sign_ph[iBC] == sPhiAB);
177 int dTheta =
data.delta_th[iAC] * (
data.sign_th[iAC] ? 1 : -1);
178 int frA =
data.fr[iA];
179 int frB =
data.fr[iB];
180 int clctA =
data.cpattern[iA];
181 int clctB =
data.cpattern[iB];
182 int clctC =
data.cpattern[iC];
194 address |= (dPhiAB & ((1 << 7) - 1)) << (0);
195 address |= (dPhiBC & ((1 << 5) - 1)) << (0 + 7);
196 address |= (sPhiBC & ((1 << 1) - 1)) << (0 + 7 + 5);
197 address |= (dTheta & ((1 << 3) - 1)) << (0 + 7 + 5 + 1);
198 address |= (frA & ((1 << 1) - 1)) << (0 + 7 + 5 + 1 + 3);
201 address |= (frB & ((1 << 1) - 1)) << (0 + 7 + 5 + 1 + 3 + 1);
204 address |= (clctA & ((1 << 2) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit);
205 address |= (rpc_2b & ((1 << 2) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2);
206 address |= (
theta & ((1 << 5) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2);
208 address |= (mode_ID & ((1 << 2) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5);
211 address |= (mode_ID & ((1 << 1) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5);
215 }
else if (nHits == 2) {
216 int dPhiAB =
data.delta_ph[iAB];
217 int sPhiAB =
data.sign_ph[iAB];
218 int dTheta =
data.delta_th[iAB] * (
data.sign_th[iAB] ? 1 : -1);
219 int frA =
data.fr[iA];
220 int frB =
data.fr[iB];
221 int clctA =
data.cpattern[iA];
222 int clctB =
data.cpattern[iB];
232 address |= (dPhiAB & ((1 << 7) - 1)) << (0);
233 address |= (dTheta & ((1 << 3) - 1)) << (0 + 7);
234 address |= (frA & ((1 << 1) - 1)) << (0 + 7 + 3);
235 address |= (frB & ((1 << 1) - 1)) << (0 + 7 + 3 + 1);
236 address |= (clctA & ((1 << 3) - 1)) << (0 + 7 + 3 + 1 + 1);
237 address |= (clctB & ((1 << 3) - 1)) << (0 + 7 + 3 + 1 + 1 + 3);
238 address |= (
theta & ((1 << 5) - 1)) << (0 + 7 + 3 + 1 + 1 + 3 + 3);
239 address |= (mode_ID & ((1 << 3) - 1)) << (0 + 7 + 3 + 1 + 1 + 3 + 3 + 5);
255 int nHits = -1,
mode = -1;
258 if (address >=
pow(2, 29)) {
261 }
else if (address >=
pow(2, 27)) {
263 }
else if (address >=
pow(2, 26)) {
266 }
else if (address >=
pow(2, 24)) {
272 int mode_ID,
theta, dTheta;
273 int dPhiAB, dPhiBC = -1, dPhiCD = -1;
274 int sPhiAB, sPhiBC = -1, sPhiCD = -1;
276 int clctA, clctB = -1;
277 int rpcA, rpcB, rpcC, rpcD;
285 dPhiAB = (address >> (0) & ((1 << 7) - 1));
286 dPhiBC = (address >> (0 + 7) & ((1 << 5) - 1));
287 dPhiCD = (address >> (0 + 7 + 5) & ((1 << 4) - 1));
288 sPhiBC = (address >> (0 + 7 + 5 + 4) & ((1 << 1) - 1));
289 sPhiCD = (address >> (0 + 7 + 5 + 4 + 1) & ((1 << 1) - 1));
290 dTheta = (address >> (0 + 7 + 5 + 4 + 1 + 1) & ((1 << 2) - 1));
291 frA = (address >> (0 + 7 + 5 + 4 + 1 + 1 + 2) & ((1 << 1) - 1));
292 mode15_8b = (address >> (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1) & ((1 << 8) - 1));
293 mode_ID = (address >> (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1 + 8) & ((1 << 1) - 1));
295 }
else if (nHits == 3) {
296 dPhiAB = (address >> (0) & ((1 << 7) - 1));
297 dPhiBC = (address >> (0 + 7) & ((1 << 5) - 1));
298 sPhiBC = (address >> (0 + 7 + 5) & ((1 << 1) - 1));
299 dTheta = (address >> (0 + 7 + 5 + 1) & ((1 << 3) - 1));
300 frA = (address >> (0 + 7 + 5 + 1 + 3) & ((1 << 1) - 1));
303 frB = (address >> (0 + 7 + 5 + 1 + 3 + 1) & ((1 << 1) - 1));
306 clctA = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit) & ((1 << 2) - 1));
307 rpc_2b = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2) & ((1 << 2) - 1));
308 theta = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2) & ((1 << 5) - 1));
310 mode_ID = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5) & ((1 << 2) - 1));
313 mode_ID = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5) & ((1 << 1) - 1));
316 }
else if (nHits == 2) {
317 dPhiAB = (address >> (0) & ((1 << 7) - 1));
318 dTheta = (address >> (0 + 7) & ((1 << 3) - 1));
319 frA = (address >> (0 + 7 + 3) & ((1 << 1) - 1));
320 frB = (address >> (0 + 7 + 3 + 1) & ((1 << 1) - 1));
321 clctA = (address >> (0 + 7 + 3 + 1 + 1) & ((1 << 3) - 1));
322 clctB = (address >> (0 + 7 + 3 + 1 + 1 + 3) & ((1 << 3) - 1));
323 theta = (address >> (0 + 7 + 3 + 1 + 1 + 3 + 3) & ((1 << 5) - 1));
324 mode_ID = (address >> (0 + 7 + 3 + 1 + 1 + 3 + 3 + 5) & ((1 << 3) - 1));
329 if (nHits == 3 &&
mode != 7) {
343 }
else if (nHits == 2) {
381 }
else if (nHits == 3) {
394 }
else if (nHits == 2) {
411 std::vector<int> predictors;
414 int dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi;
419 theta, St1_ring2, dPhiAB, dPhiBC, dPhiCD, dPhiAB + dPhiBC, dPhiAB + dPhiBC + dPhiCD, dPhiBC + dPhiCD, frA, clctA};
428 dPhiAB + dPhiBC + dPhiCD,
433 int tmp[10] = {dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi, dTheta, rpcA, rpcB, rpcC, rpcD};
434 predictors.insert(predictors.end(),
tmp,
tmp + 10);
435 }
else if (nHits == 3) {
437 predictors = {
theta, St1_ring2, dPhiAB, dPhiBC, dPhiAB + dPhiBC, frA, frB, clctA, dTheta, rpcA, rpcB, rpcC};
439 predictors = {
theta, St1_ring2, dPhiAB, dPhiAB + dPhiBC, dPhiBC, frA, frB, clctA, dTheta, rpcA, rpcB, rpcC};
441 predictors = {
theta, St1_ring2, dPhiBC, dPhiAB, dPhiAB + dPhiBC, frA, frB, clctA, dTheta, rpcA, rpcB, rpcC};
443 predictors = {
theta, dPhiAB, dPhiBC, dPhiAB + dPhiBC, frA, clctA, dTheta, rpcA, rpcB, rpcC};
444 }
else if (nHits == 2 &&
mode >= 8) {
445 predictors = {
theta, St1_ring2, dPhiAB, frA, frB, clctA, clctB, dTheta, (clctA == 0), (clctB == 0)};
446 }
else if (nHits == 2 &&
mode < 8) {
447 predictors = {
theta, dPhiAB, frA, frB, clctA, clctB, dTheta, (clctA == 0), (clctB == 0)};
453 std::vector<double> tree_data(predictors.cbegin(), predictors.cend());
455 auto tree_event = std::make_unique<emtf::Event>();
456 tree_event->predictedValue = 0;
457 tree_event->data = tree_data;
467 float inv_pt = tree_event->predictedValue;
468 pt_xml = 1.0 / fmax(0.001, inv_pt);
480 auto contain = [](
const std::vector<int>& vec,
int elem) {
481 return (
std::find(vec.begin(), vec.end(), elem) != vec.end());
492 int st1 = (
mode >= 8);
493 int st2 = ((
mode % 8) >= 4);
494 int st3 = ((
mode % 4) >= 2);
495 int st4 = ((
mode % 2) == 1);
498 int dPhi_12, dPhi_13, dPhi_14, dPhi_23, dPhi_24, dPhi_34, dPhiSign;
499 int dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi;
500 int dTh_12, dTh_13, dTh_14, dTh_23, dTh_24, dTh_34;
501 int FR_1, FR_2, FR_3, FR_4;
502 int bend_1, bend_2, bend_3, bend_4;
503 int RPC_1, RPC_2, RPC_3, RPC_4;
504 int St1_ring2 =
data.st1_ring2;
506 int ph1 = -99, ph2 = -99, ph3 = -99, ph4 = -99;
507 int th1 = -99, th2 = -99, th3 = -99, th4 = -99;
508 int pat1 = -99, pat2 = -99, pat3 = -99, pat4 = -99;
515 ph1 = ph2 -
data.delta_ph[0] * (
data.sign_ph[0] ? 1 : -1);
517 th1 = th2 -
data.delta_th[0] * (
data.sign_th[0] ? 1 : -1);
519 ph3 = ph2 +
data.delta_ph[3] * (
data.sign_ph[3] ? 1 : -1);
522 ph4 = ph3 +
data.delta_ph[5] * (
data.sign_ph[5] ? 1 : -1);
524 ph4 = ph2 +
data.delta_ph[4] * (
data.sign_ph[4] ? 1 : -1);
529 th3 = th1 +
data.delta_th[1] * (
data.sign_th[1] ? 1 : -1);
531 th3 = th2 +
data.delta_th[3] * (
data.sign_th[3] ? 1 : -1);
533 th4 = th1 +
data.delta_th[2] * (
data.sign_th[2] ? 1 : -1);
535 th4 = th2 +
data.delta_th[4] * (
data.sign_th[4] ? 1 : -1);
540 ph1 = ph3 -
data.delta_ph[1] * (
data.sign_ph[1] ? 1 : -1);
542 th1 = th3 -
data.delta_th[1] * (
data.sign_th[1] ? 1 : -1);
544 ph4 = ph3 +
data.delta_ph[5] * (
data.sign_ph[5] ? 1 : -1);
546 th4 = th1 +
data.delta_th[2] * (
data.sign_th[2] ? 1 : -1);
548 th4 = th3 +
data.delta_th[5] * (
data.sign_th[5] ? 1 : -1);
553 ph1 = ph4 -
data.delta_ph[2] * (
data.sign_ph[2] ? 1 : -1);
555 th1 = th4 -
data.delta_th[2] * (
data.sign_th[2] ? 1 : -1);
559 pat1 =
data.cpattern[0];
561 pat2 =
data.cpattern[1];
563 pat3 =
data.cpattern[2];
565 pat4 =
data.cpattern[3];
590 aux().
calcDeltaThetas(dTh_12, dTh_13, dTh_14, dTh_23, dTh_24, dTh_34, th1, th2, th3, th4,
mode,
true);
592 FR_1 = (st1 ?
data.fr[0] : -99);
593 FR_2 = (st2 ?
data.fr[1] : -99);
594 FR_3 = (st3 ?
data.fr[2] : -99);
595 FR_4 = (st4 ?
data.fr[3] : -99);
597 aux().
calcBends(bend_1, bend_2, bend_3, bend_4, pat1, pat2, pat3, pat4, dPhiSign,
endcap,
mode,
true);
599 RPC_1 = (st1 ? (pat1 == 0) : -99);
600 RPC_2 = (st2 ? (pat2 == 0) : -99);
601 RPC_3 = (st3 ? (pat3 == 0) : -99);
602 RPC_4 = (st4 ? (pat4 == 0) : -99);
610 std::vector<int> predictors;
613 predictors = {
theta, St1_ring2, dPhi_12, dPhi_23, dPhi_34, dPhi_13, dPhi_14, dPhi_24, FR_1, bend_1,
614 dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi, dTh_14, RPC_1, RPC_2, RPC_3, RPC_4};
617 predictors = {
theta, St1_ring2, dPhi_12, dPhi_23, dPhi_13, FR_1, FR_2, bend_1, dTh_13, RPC_1, RPC_2, RPC_3};
620 predictors = {
theta, St1_ring2, dPhi_12, dPhi_14, dPhi_24, FR_1, FR_2, bend_1, dTh_14, RPC_1, RPC_2, RPC_4};
623 predictors = {
theta, St1_ring2, dPhi_34, dPhi_13, dPhi_14, FR_1, FR_3, bend_1, dTh_14, RPC_1, RPC_3, RPC_4};
626 predictors = {
theta, dPhi_23, dPhi_34, dPhi_24, FR_2, bend_2, dTh_24, RPC_2, RPC_3, RPC_4};
629 predictors = {
theta, St1_ring2, dPhi_12, FR_1, FR_2, bend_1, bend_2, dTh_12, RPC_1, RPC_2};
632 predictors = {
theta, St1_ring2, dPhi_13, FR_1, FR_3, bend_1, bend_3, dTh_13, RPC_1, RPC_3};
635 predictors = {
theta, St1_ring2, dPhi_14, FR_1, FR_4, bend_1, bend_4, dTh_14, RPC_1, RPC_4};
638 predictors = {
theta, dPhi_23, FR_2, FR_3, bend_2, bend_3, dTh_23, RPC_2, RPC_3};
641 predictors = {
theta, dPhi_24, FR_2, FR_4, bend_2, bend_4, dTh_24, RPC_2, RPC_4};
644 predictors = {
theta, dPhi_34, FR_3, FR_4, bend_3, bend_4, dTh_34, RPC_3, RPC_4};
648 std::vector<double> tree_data(predictors.cbegin(), predictors.cend());
650 auto tree_event = std::make_unique<emtf::Event>();
651 tree_event->predictedValue = 0;
652 tree_event->data = tree_data;
662 float inv_pt = tree_event->predictedValue;
663 pt_xml = 1.0 / fmax(0.001, inv_pt);