12 #include <trg/grl/modules/trggrl/TRGGRLMatchModule.h>
13 #include <trg/grl/dataobjects/TRGGRLMATCH.h>
14 #include <trg/grl/dataobjects/TRGGRLMATCHKLM.h>
15 #include <trg/grl/dataobjects/TRGGRLPHOTON.h>
16 #include <trg/cdc/dataobjects/CDCTriggerTrack.h>
17 #include <trg/ecl/dataobjects/TRGECLCluster.h>
18 #include <trg/klm/dataobjects/KLMTriggerTrack.h>
19 #include <trg/cdc/dataobjects/CDCTriggerSegmentHit.h>
20 #include <trg/grl/dataobjects/TRGGRLInfo.h>
21 #include <trg/grl/dataobjects/TRGGRLShortTrack.h>
24 #include <framework/datastore/StoreArray.h>
25 #include <framework/datastore/StoreObjPtr.h>
28 #include <framework/logging/Logger.h>
29 #include <framework/core/ModuleParamList.templateDetails.h>
47 setDescription(
"match CDC trigger tracks and ECL trigger clusters");
48 setPropertyFlags(c_ParallelProcessingCertified);
49 addParam(
"SimulationMode", m_simulationMode,
"TRGGRL simulation switch", 1);
50 addParam(
"FastSimulationMode", m_fastSimulationMode,
"TRGGRL fast simulation mode", m_fastSimulationMode);
51 addParam(
"FirmwareSimulationMode", m_firmwareSimulationMode,
"TRGGRL firmware simulation mode", m_firmwareSimulationMode);
53 addParam(
"DrMatch", m_dr_threshold,
"the threshold of dr between track and cluster if they are matched successfully", 25.);
54 addParam(
"DzMatch", m_dz_threshold,
"the threshold of dz between track and cluster if they are matched successfully", 30.);
55 addParam(
"DphidMatch", m_dphi_d_threshold,
"the threshold of dphi_d between track and cluster if they are matched successfully", 2);
56 addParam(
"Ephoton", m_e_threshold,
"the threshold of cluster energy as a photon", 1.0);
57 addParam(
"KLMMatch", m_dphi_klm_threshold,
58 "the threshold of dphi (in degree) between track and KLM sector if they are matched successfully", 65.0);
59 addParam(
"2DtrackCollection", m_2d_tracklist,
"the 2d track list used in the match", std::string(
"TRGCDC2DFinderTracks"));
60 addParam(
"3DtrackCollection", m_3d_tracklist,
"the 3d track list used in the match", std::string(
"TRGCDCNeuroTracks"));
61 addParam(
"TRGECLClusterCollection", m_clusterlist,
"the cluster list used in the match", std::string(
"TRGECLClusters"));
62 addParam(
"KLMTriggerTrack", m_klmtracklist,
"the KLM track list used in the match", std::string(
"TRGKLMTracks"));
63 addParam(
"2DmatchCollection", m_2dmatch_tracklist,
"the 2d tracklist with associated cluster", std::string(
"TRG2DMatchTracks"));
64 addParam(
"PhimatchCollection", m_phimatch_tracklist,
"the 2d tracklist with associated cluster", std::string(
"TRGPhiMatchTracks"));
65 addParam(
"3DmatchCollection", m_3dmatch_tracklist,
"the 3d NN tracklist with associated cluster", std::string(
"TRG3DMatchTracks"));
66 addParam(
"KLMmatchCollection", m_klmmatch_tracklist,
"the 2d tracklist with associated KLM track",
67 std::string(
"TRGKLMMatchTracks"));
68 addParam(
"GRLphotonCollection", m_grlphotonlist,
"the isolated cluster list", std::string(
"TRGGRLPhotons"));
69 addParam(
"hitCollectionName", m_hitCollectionName,
"Name of the input StoreArray of CDCTriggerSegmentHits.", std::string(
""));
70 addParam(
"TrgGrlInformation", m_TrgGrlInformationName,
71 "Name of the StoreArray holding the information of tracks and clusters from cdc ecl klm.",
72 std::string(
"TRGGRLObjects"));
73 addParam(
"grlstCollectionName", m_grlstCollectionName,
"Name of the output StoreArray of TRGGRLShortTrack.",
74 std::string(
"TRGGRLShortTracks"));
85 B2DEBUG(100,
"TRGGRLMatchModule processing");
88 track2Dlist.isRequired();
89 track3Dlist.isRequired();
91 clusterslist.isRequired();
95 klmtracklist.isRequired();
149 for (
int p = 0; p < 137; p++) {
192 for (
int i = 0; i < 36; i++) {
198 for (
int i = 0; i < track2Dlist.
getEntries(); i++) {
200 double dr_tmp = 99999.;
201 int dphi_d_tmp = 100;
202 int dphi_klm_tmp = 100;
203 int cluster_ind = -1;
204 int cluster_ind_phi = -1;
205 int klmtrack_ind_phi = -1;
208 for (
int j = 0; j < klmtracklist.
getEntries(); j++) {
209 double dphi_klm = 99999.9;
211 if (dphi_klm_tmp > dphi_klm) {
212 dphi_klm_tmp = dphi_klm;
213 klmtrack_ind_phi = j;
217 for (
int j = 0; j < clusterlist.
getEntries(); j++) {
219 double _cluster_x = clusterlist[j]->getPositionX();
220 double _cluster_y = clusterlist[j]->getPositionY();
221 double _cluster_z = clusterlist[j]->getPositionZ();
222 double _cluster_theta = atan(_cluster_z / (sqrt(_cluster_x * _cluster_x + _cluster_y * _cluster_y)));
223 _cluster_theta = 0.5 * M_PI - _cluster_theta;
224 if (_cluster_theta < M_PI * 35.0 / 180.0 || _cluster_theta > M_PI * 126.0 / 180.0)
continue;
226 double ds_ct[2] = {99999., 99999.};
231 if (dr_tmp > ds_ct[0]) {
235 if (dphi_d_tmp > dphi_d) {
248 clusterlist[cluster_ind]->addRelationTo(track2Dlist[i]);
255 matphi->
set_e(clusterlist[cluster_ind_phi]->getEnergyDep());
257 clusterlist[cluster_ind_phi]->addRelationTo(track2Dlist[i]);
265 klmtracklist[klmtrack_ind_phi]->addRelationTo(track2Dlist[i]);
272 for (
int i = 0; i < track3Dlist.
getEntries(); i++) {
274 double dr_tmp = 99999.;
275 double dz_tmp = 99999.;
276 int cluster_ind = -1;
277 for (
int j = 0; j < clusterlist.
getEntries(); j++) {
279 double _cluster_x = clusterlist[j]->getPositionX();
280 double _cluster_y = clusterlist[j]->getPositionY();
281 double _cluster_z = clusterlist[j]->getPositionZ();
282 double _cluster_theta = atan(_cluster_z / (sqrt(_cluster_x * _cluster_x + _cluster_y * _cluster_y)));
283 _cluster_theta = 0.5 * M_PI - _cluster_theta;
284 if (_cluster_theta < M_PI * 35.0 / 180.0 || _cluster_theta > M_PI * 126.0 / 180.0)
continue;
286 double ds_ct[2] = {99999., 99999.};
288 if (dr_tmp > ds_ct[0]) {
303 clusterlist[cluster_ind]->addRelationTo(track3Dlist[i]);
310 for (
int j = 0; j < clusterlist.
getEntries(); j++) {
313 photon->
set_e(clusterlist[j]->getEnergyDep());
319 std::vector<bool> map_veto(64, 0);
337 double _r = 1.0 / _track->getOmega() ;
338 double _phi = _track->getPhi0() ;
344 double _R = sqrt(_cluster_x * _cluster_x + _cluster_y * _cluster_y);
349 if (_R > abs(2 * _r)) {
352 double theta0 = _phi - asin(_R / (2 * _r));
354 double ex_x0 = _R * cos(theta0), ex_y0 = _R * sin(theta0);
355 ds[0] = sqrt((ex_x0 - _cluster_x) * (ex_x0 - _cluster_x) + (ex_y0 - _cluster_y) * (ex_y0 - _cluster_y));
359 double _z0 = _track->getZ0();
360 double _slope = _track->getCotTheta();
361 double _ex_z = _z0 + _slope * 2 * _r * asin(_R / (2 * _r));
362 ds[1] = fabs(_cluster_z - _ex_z);
369 std::vector<bool>& phimap, std::vector<bool>& phimap_i)
373 double _r = 1.0 / _track->getOmega() ;
374 double _phi = _track->getPhi0() ;
377 double phi_p = acos(126.0 / (2 * fabs(_r)));
379 if (_r > 0) {charge = 1;}
380 else if (_r < 0) {charge = -1;}
383 double phi_CDC = 0.0;
385 phi_CDC = _phi + phi_p - 0.5 * M_PI;
386 }
else if (charge == -1) {
387 phi_CDC = _phi - phi_p + 0.5 * M_PI;
392 if (phi_CDC > 2 * M_PI) {phi_CDC = phi_CDC - 2 * M_PI;}
393 else if (phi_CDC < 0) {phi_CDC = phi_CDC + 2 * M_PI;}
394 if (_phi > 2 * M_PI) {_phi = _phi - 2 * M_PI;}
395 else if (_phi < 0) {_phi = _phi + 2 * M_PI;}
402 double phi_ECL = 0.0;
403 if (_cluster_x >= 0 && _cluster_y >= 0) {phi_ECL = atan(_cluster_y / _cluster_x);}
404 else if (_cluster_x < 0 && _cluster_y >= 0) {phi_ECL = atan(_cluster_y / _cluster_x) + M_PI;}
405 else if (_cluster_x < 0 && _cluster_y < 0) {phi_ECL = atan(_cluster_y / _cluster_x) + M_PI;}
406 else if (_cluster_x >= 0 && _cluster_y < 0) {phi_ECL = atan(_cluster_y / _cluster_x) + 2 * M_PI;}
408 int phi_ECL_d = 0, phi_CDC_d = 0, phi_i_d = 0;
410 for (
int i = 0; i < 36; i++) {
411 if (phi_ECL > i * M_PI / 18 && phi_ECL < (i + 1)*M_PI / 18) {phi_ECL_d = i;}
412 if (_phi > i * M_PI / 18 && _phi < (i + 1)*M_PI / 18) {phi_i_d = i;}
413 if (phi_CDC > i * M_PI / 18 && phi_CDC < (i + 1)*M_PI / 18) {phi_CDC_d = i;}
416 phimap[phi_CDC_d] =
true;
417 phimap_i[phi_i_d] =
true;
419 if (abs(phi_ECL_d - phi_CDC_d) == 0 || abs(phi_ECL_d - phi_CDC_d) == 36) {dphi_d = 0;}
420 else if (abs(phi_ECL_d - phi_CDC_d) == 1 || abs(phi_ECL_d - phi_CDC_d) == 35) {dphi_d = 1;}
421 else if (abs(phi_ECL_d - phi_CDC_d) == 2 || abs(phi_ECL_d - phi_CDC_d) == 34) {dphi_d = 2;}
422 else if (abs(phi_ECL_d - phi_CDC_d) == 3 || abs(phi_ECL_d - phi_CDC_d) == 33) {dphi_d = 3;}
423 else if (abs(phi_ECL_d - phi_CDC_d) == 4 || abs(phi_ECL_d - phi_CDC_d) == 32) {dphi_d = 4;}
424 else if (abs(phi_ECL_d - phi_CDC_d) == 5 || abs(phi_ECL_d - phi_CDC_d) == 31) {dphi_d = 5;}
425 else if (abs(phi_ECL_d - phi_CDC_d) == 6 || abs(phi_ECL_d - phi_CDC_d) == 30) {dphi_d = 6;}
426 else if (abs(phi_ECL_d - phi_CDC_d) == 7 || abs(phi_ECL_d - phi_CDC_d) == 29) {dphi_d = 7;}
427 else if (abs(phi_ECL_d - phi_CDC_d) == 8 || abs(phi_ECL_d - phi_CDC_d) == 28) {dphi_d = 8;}
428 else if (abs(phi_ECL_d - phi_CDC_d) == 9 || abs(phi_ECL_d - phi_CDC_d) == 27) {dphi_d = 9;}
429 else if (abs(phi_ECL_d - phi_CDC_d) == 10 || abs(phi_ECL_d - phi_CDC_d) == 26) {dphi_d = 10;}
430 else if (abs(phi_ECL_d - phi_CDC_d) == 11 || abs(phi_ECL_d - phi_CDC_d) == 25) {dphi_d = 11;}
431 else if (abs(phi_ECL_d - phi_CDC_d) == 12 || abs(phi_ECL_d - phi_CDC_d) == 24) {dphi_d = 12;}
432 else if (abs(phi_ECL_d - phi_CDC_d) == 13 || abs(phi_ECL_d - phi_CDC_d) == 23) {dphi_d = 13;}
433 else if (abs(phi_ECL_d - phi_CDC_d) == 14 || abs(phi_ECL_d - phi_CDC_d) == 22) {dphi_d = 14;}
434 else if (abs(phi_ECL_d - phi_CDC_d) == 15 || abs(phi_ECL_d - phi_CDC_d) == 21) {dphi_d = 15;}
435 else if (abs(phi_ECL_d - phi_CDC_d) == 16 || abs(phi_ECL_d - phi_CDC_d) == 20) {dphi_d = 16;}
436 else if (abs(phi_ECL_d - phi_CDC_d) == 17 || abs(phi_ECL_d - phi_CDC_d) == 19) {dphi_d = 17;}
437 else if (abs(phi_ECL_d - phi_CDC_d) == 18) {dphi_d = 18;}
445 double _r = 1.0 / _track->getOmega() ;
446 double _phi = _track->getPhi0() ;
449 double phi_p = acos(176.0 / (2 * fabs(_r)));
451 if (_r > 0) {charge = 1;}
452 else if (_r < 0) {charge = -1;}
455 double phi_CDC = 0.0;
457 phi_CDC = _phi + phi_p - 0.5 * M_PI;
458 }
else if (charge == -1) {
459 phi_CDC = _phi - phi_p + 0.5 * M_PI;
464 if (phi_CDC > 2 * M_PI) {phi_CDC = phi_CDC - 2 * M_PI;}
465 else if (phi_CDC < 0) {phi_CDC = phi_CDC + 2 * M_PI;}
469 double _sector_central = 0.25 * M_PI * _sector;
471 if (fabs(phi_CDC - _sector_central) < M_PI) { dphi = fabs(phi_CDC - _sector_central); }
472 else { dphi = 2 * M_PI - fabs(phi_CDC - _sector_central); }
483 double _cluster_theta = atan(_cluster_z / (sqrt(_cluster_x * _cluster_x + _cluster_y * _cluster_y)));
484 _cluster_theta = 0.5 * M_PI - _cluster_theta;
486 if (_cluster_theta < M_PI * 35.0 / 180.0 || _cluster_theta > M_PI * 126.0 / 180.0) {barrel =
false;}
490 double phi_ECL = 0.0;
491 if (_cluster_x >= 0 && _cluster_y >= 0) {phi_ECL = atan(_cluster_y / _cluster_x);}
492 else if (_cluster_x < 0 && _cluster_y >= 0) {phi_ECL = atan(_cluster_y / _cluster_x) + M_PI;}
493 else if (_cluster_x < 0 && _cluster_y < 0) {phi_ECL = atan(_cluster_y / _cluster_x) + M_PI;}
494 else if (_cluster_x >= 0 && _cluster_y < 0) {phi_ECL = atan(_cluster_y / _cluster_x) + 2 * M_PI;}
498 for (
int i = 0; i < 36; i++) {
499 if (phi_ECL > i * M_PI / 18 && phi_ECL < (i + 1)*M_PI / 18) {phi_ECL_d = i;}
502 int index = phi_ECL_d, index_p = phi_ECL_d + 1, index_m = phi_ECL_d - 1;
503 if (index_p > 35) {index_p = index_p - 36;}
504 if (index_m < 0) {index_m = index_m + 36;}
506 if (!phimap[index] && !phimap[index_p] && !phimap[index_m] && _cluster_e >= e_threshold && barrel) {
return true;}
507 else if (!barrel) {
return true;}
528 patt.push_back({ 0, 0, 0, 0});
529 patt.push_back({ 0, -1, 0, 0});
530 patt.push_back({ 0, -1, 1, 0});
531 patt.push_back({ 0, -1, -1, 0});
532 patt.push_back({ 0, -2, 0, 0});
533 patt.push_back({ 0, -2, 1, 0});
534 patt.push_back({ 0, -2, 2, 0});
535 patt.push_back({ 0, -2, 3, 0});
536 patt.push_back({ 0, -3, 1, 0});
537 patt.push_back({ 0, -3, 2, 0});
538 patt.push_back({ 0, -3, 3, 0});
539 patt.push_back({ 0, -4, 2, 0});
540 patt.push_back({ 0, -4, 3, 0});
541 patt.push_back({ 0, 0, 0, 1});
542 patt.push_back({ 0, 0, 1, 1});
543 patt.push_back({ 0, -1, 0, 1});
544 patt.push_back({ 0, -1, 1, 1});
545 patt.push_back({ 0, -1, 2, 1});
546 patt.push_back({ 0, -2, 2, 1});
547 patt.push_back({ 0, -2, 3, 1});
548 patt.push_back({ 0, -3, 2, 1});
549 patt.push_back({ 0, -3, 3, 1});
550 patt.push_back({ 0, 0, 0, -1});
551 patt.push_back({ 0, 0, -1, -1});
552 patt.push_back({ 0, -1, 0, -1});
553 patt.push_back({ 0, -1, -1, -1});
554 patt.push_back({ 0, -2, 0, -1});
555 patt.push_back({ 0, -2, 1, -1});
556 patt.push_back({ 0, -3, 1, -1});
557 patt.push_back({ 0, -3, 2, -1});
558 patt.push_back({ -1, -1, 0, 0});
559 patt.push_back({ -1, -1, 1, 0});
560 patt.push_back({ -1, -2, 0, 0});
561 patt.push_back({ -1, -2, 1, 0});
562 patt.push_back({ -1, -3, 1, 0});
563 patt.push_back({ -1, -3, 2, 0});
564 patt.push_back({ -1, -3, 3, 0});
565 patt.push_back({ -1, -4, 2, 0});
566 patt.push_back({ -1, -4, 3, 0});
567 patt.push_back({ 1, 0, 1, 0});
568 patt.push_back({ 1, 0, 0, 0});
569 patt.push_back({ 1, 0, -1, 0});
570 patt.push_back({ 1, -1, 0, 0});
571 patt.push_back({ 1, -1, 1, 0});
572 patt.push_back({ 1, -2, 2, 0});
573 patt.push_back({ 1, -2, 3, 0});
574 patt.push_back({ 1, -3, 2, 0});
575 patt.push_back({ 1, -3, 3, 0});
576 patt.push_back({ -1, -1, 0, 1});
577 patt.push_back({ -1, -1, 1, 1});
578 patt.push_back({ -1, -2, 0, 1});
579 patt.push_back({ -1, -2, 1, 1});
580 patt.push_back({ -1, -2, 2, 1});
581 patt.push_back({ -1, -3, 1, 1});
582 patt.push_back({ -1, -3, 2, 1});
583 patt.push_back({ -1, -3, 3, 1});
584 patt.push_back({ -1, -4, 2, 1});
585 patt.push_back({ -1, -4, 3, 1});
586 patt.push_back({ 1, 0, -1, -1});
587 patt.push_back({ 1, 0, 0, -1});
588 patt.push_back({ 1, -1, -1, -1});
589 patt.push_back({ 1, -1, 0, -1});
590 patt.push_back({ 1, -1, 1, -1});
591 patt.push_back({ 1, -2, 1, -1});
592 patt.push_back({ 1, -2, 2, -1});
593 patt.push_back({ 1, -3, 1, -1});
594 patt.push_back({ 1, -3, 2, -1});
595 patt.push_back({ -1, -1, 1, 2});
596 patt.push_back({ -1, -1, 2, 2});
597 patt.push_back({ -1, -2, 1, 2});
598 patt.push_back({ -1, -2, 2, 2});
599 patt.push_back({ -1, -2, 3, 2});
600 patt.push_back({ -1, -3, 2, 2});
601 patt.push_back({ -1, -3, 3, 2});
602 patt.push_back({ -1, -3, 4, 2});
603 patt.push_back({ 1, 0, -1, -2});
604 patt.push_back({ 1, 0, 0, -2});
605 patt.push_back({ 1, -1, 1, -2});
606 patt.push_back({ 1, -1, 0, -2});
607 patt.push_back({ 1, -1, -1, -2});
608 patt.push_back({ 1, -2, 0, -2});
609 patt.push_back({ 1, -2, 1, -2});
610 patt.push_back({ -2, -2, 0, 1});
611 patt.push_back({ -2, -2, 1, 1});
612 patt.push_back({ -2, -3, 1, 1});
613 patt.push_back({ -2, -3, 2, 1});
614 patt.push_back({ -2, -4, 2, 1});
615 patt.push_back({ -2, -4, 3, 1});
616 patt.push_back({ -2, -5, 3, 1});
617 patt.push_back({ 2, 1, 0, -1});
618 patt.push_back({ 2, 0, 1, -1});
619 patt.push_back({ 2, 0, 0, -1});
620 patt.push_back({ 2, 0, -1, -1});
621 patt.push_back({ 2, -1, 1, -1});
622 patt.push_back({ 2, -1, 0, -1});
623 patt.push_back({ 2, -2, 2, -1});
624 patt.push_back({ 2, -2, 1, -1});
625 patt.push_back({ -2, -2, 1, 2});
626 patt.push_back({ -2, -2, 2, 2});
627 patt.push_back({ -2, -3, 1, 2});
628 patt.push_back({ -2, -3, 2, 2});
629 patt.push_back({ -2, -3, 3, 2});
630 patt.push_back({ -2, -4, 2, 2});
631 patt.push_back({ -2, -4, 3, 2});
632 patt.push_back({ -2, -4, 4, 2});
633 patt.push_back({ 2, 1, 0, -2});
634 patt.push_back({ 2, 1, -1, -2});
635 patt.push_back({ 2, 0, 1, -2});
636 patt.push_back({ 2, 0, 0, -2});
637 patt.push_back({ 2, 0, -1, -2});
638 patt.push_back({ 2, 0, -2, -2});
639 patt.push_back({ 2, -1, 2, -2});
640 patt.push_back({ 2, -1, 1, -2});
641 patt.push_back({ 2, -1, 0, -2});
642 patt.push_back({ 2, -1, -1, -2});
643 patt.push_back({ 2, -2, 0, -2});
644 patt.push_back({ 2, -2, 1, -2});
645 patt.push_back({ -2, -2, 1, 3});
646 patt.push_back({ -2, -2, 2, 3});
647 patt.push_back({ -2, -3, 2, 3});
648 patt.push_back({ -2, -3, 3, 3});
649 patt.push_back({ -2, -3, 4, 3});
650 patt.push_back({ -2, -4, 3, 3});
651 patt.push_back({ -2, -4, 4, 3});
652 patt.push_back({ 2, 1, -1, -3});
653 patt.push_back({ 2, 0, -1, -3});
654 patt.push_back({ 2, 0, -2, -3});
655 patt.push_back({ 2, -1, 0, -3});
656 patt.push_back({ 2, -2, 0, -3});
657 patt.push_back({ 2, -2, 1, -3});
658 patt.push_back({ -2, -2, 2, 4});
659 patt.push_back({ -2, -3, 3, 4});
660 patt.push_back({ -2, -3, 4, 4});
661 patt.push_back({ -2, -4, 4, 4});
662 patt.push_back({ 2, -1, 0, 4});
663 patt.push_back({ 2, -1, -1, 4});
664 patt.push_back({ 2, -2, 0, 4});
670 for (
int i = 0; i < track2Dlist.
getEntries(); i++) {
671 int _w = (int)(2271.7 * track2Dlist[i]->getOmega()) ;
672 if (_w >= 33) { _w = 33;}
673 else if (_w <= -33) { _w = -33;}
674 int _phi = (int)((track2Dlist[i]->getPhi0() + 2 * M_PI) / (M_PI / 32.0));
677 if (_w > 0) {charge = 1;}
678 else if (_w < 0) {charge = -1;}
683 int L = _phi, R = _phi;
684 if (_w >= 0 && _w <= 8) { L = _phi; }
685 else if (_w >= 9 && _w <= 15) {
686 if (charge < 0) { L = _phi + 1; }
688 }
else if (_w >= 16 && _w <= 24) {
689 if (charge < 0) { L = _phi + 2; }
691 }
else if (_w >= 25 && _w <= 27) {
692 if (charge < 0) { L = _phi + 3; }
694 }
else if (_w >= 28 && _w <= 30) {
695 if (charge < 0) { L = _phi + 3; }
696 else { L = _phi + 1; }
697 }
else if (_w >= 31 && _w <= 32) {
698 if (charge < 0) { L = _phi + 4; }
699 else { L = _phi + 1; }
701 if (charge < 0) { L = _phi + 5; }
702 else { L = _phi + 1; }
705 if (_w >= 0 && _w <= 8) { R = _phi; }
706 else if (_w >= 9 && _w <= 15) {
707 if (charge < 0) { R = _phi; }
708 else { R = _phi - 1; }
709 }
else if (_w >= 16 && _w <= 24) {
710 if (charge < 0) { R = _phi; }
711 else { R = _phi - 2; }
712 }
else if (_w >= 25 && _w <= 27) {
713 if (charge < 0) { R = _phi; }
714 else { R = _phi - 3; }
715 }
else if (_w >= 28 && _w <= 30) {
716 if (charge < 0) { R = _phi + 1; }
717 else { R = _phi - 3; }
718 }
else if (_w >= 21 && _w <= 32) {
719 if (charge < 0) { R = _phi + 1; }
720 else { R = _phi - 4; }
722 if (charge < 0) { R = _phi + 1; }
723 else { R = _phi - 5; }
727 for (
int j = R - 1; j < L + 2; j++) {
728 map_veto[
N64(j)] =
true;
735 std::vector<bool> phimap_i,
736 std::vector< std::vector<int> >& pattern_base0, std::vector< std::vector<int> >& pattern_base2,
740 std::vector<bool> SL0(64, 0);
741 std::vector<bool> SL1(64, 0);
742 std::vector<bool> SL2(64, 0);
743 std::vector<bool> SL3(64, 0);
744 std::vector<bool> SL4(64, 0);
745 std::vector<bool> ST0(64, 0);
746 std::vector<bool> ST0_36b(36, 0);
747 std::vector<bool> ST2(64, 0);
748 std::vector<int> patt_ID(64, -1);
756 for (
int i = 0; i < tslist.
getEntries(); i++) {
757 int id = tslist[i]->getSegmentID();
759 if (
id >= 0 * 32 &&
id < 5 * 32) {sl = 0;
id -= 0;}
760 else if (
id >= 5 * 32 &&
id < 10 * 32) {sl = 1;
id -= 5 * 32;}
761 else if (
id >= 10 * 32 &&
id < 16 * 32) {sl = 2;
id -= 10 * 32;}
762 else if (
id >= 16 * 32 &&
id < 23 * 32) {sl = 3;
id -= 16 * 32;}
763 else if (
id >= 23 * 32 &&
id < 31 * 32) {sl = 4;
id -= 23 * 32;}
767 int X = (int)(
id / 5), Y =
id % 5;
768 if (Y == 0 || Y == 1) { SL0[2 * X] =
true; }
769 else if (Y == 3 || Y == 4) { SL0[2 * X + 1] =
true; }
770 else { SL0[2 * X] =
true; SL0[2 * X + 1] =
true; }
771 }
else if (sl == 1) {
772 int X = (int)(
id / 5), Y =
id % 5;
773 if (Y == 0 || Y == 1) { SL1[2 * X] =
true; }
774 else if (Y == 3 || Y == 4) { SL1[2 * X + 1] =
true; }
775 else { SL1[2 * X] =
true; SL1[2 * X + 1] =
true; }
776 }
else if (sl == 2) {
777 int X = (int)(
id / 3);
779 }
else if (sl == 3) {
780 int X = (int)(
id / 7), Y =
id % 7;
781 if (Y == 0 || Y == 1 || Y == 2) { SL3[2 * X] =
true; }
782 else if (Y == 4 || Y == 5 || Y == 6) { SL3[2 * X + 1] =
true; }
783 else { SL3[2 * X] =
true; SL3[2 * X + 1] =
true; }
784 }
else if (sl == 4) {
785 int X = (int)(
id / 4);
792 for (
int i = 0; i < 64; i++) {
793 if (map_veto[i]) {SL0[i] =
false; SL1[i] =
false; SL2[i] =
false;}
811 std::vector< std::vector<int> > stlist_buf(0);
814 for (
int i = 0; i < 64; i++) {
821 stlist_buf.push_back({0, 0, 0, 0, 0, 0});
823 if (!SL2[i])
continue;
824 bool SL2_already_found =
false;
826 for (
int p = 0; p < 137; p++) {
829 if (p == 4)
continue;
830 if (p == 5)
continue;
831 if (p == 17)
continue;
832 if (p == 26)
continue;
833 if (p == 38)
continue;
834 if (p == 41)
continue;
835 if (p == 42)
continue;
836 if (p == 47)
continue;
837 if (p == 50)
continue;
838 if (p == 60)
continue;
839 if (p == 63)
continue;
840 if (p == 64)
continue;
841 if (p == 74)
continue;
842 if (p == 93)
continue;
843 if (p == 94)
continue;
844 if (p == 95)
continue;
845 if (p == 96)
continue;
846 if (p == 104)
continue;
847 if (p == 113)
continue;
848 if (p == 114)
continue;
849 if (p == 115)
continue;
850 if (p == 123)
continue;
851 if (p == 134)
continue;
852 if (p == 135)
continue;
853 if (p == 136)
continue;
855 int x0 = pattern_base2[p][0];
856 int x1 = pattern_base2[p][1];
857 int x3 = pattern_base2[p][2];
858 int x4 = pattern_base2[p][3];
861 if (SL2[i] && SL0[
N64(i + x0)] && SL1[
N64(i + x1)] && SL3[
N64(i + x3)] && SL4[
N64(i + x4)] && !SL2_already_found) {
868 SL2_already_found =
true;
872 if (SL2_already_found)
break;
876 if (SL2_already_found) {
877 stlist_buf[i][0] = 1;
878 stlist_buf[i][1] = ID0;
879 stlist_buf[i][2] = ID1;
880 stlist_buf[i][3] = ID2;
881 stlist_buf[i][4] = ID3;
882 stlist_buf[i][5] = ID4;
887 for (
int i = 0; i < 64; i++) {
889 if (!SL0[i])
continue;
890 bool SL0_already_found =
false;
892 for (
int p = 0; p < 137; p++) {
895 if (p == 4)
continue;
896 if (p == 5)
continue;
897 if (p == 17)
continue;
898 if (p == 26)
continue;
899 if (p == 38)
continue;
900 if (p == 41)
continue;
901 if (p == 42)
continue;
902 if (p == 47)
continue;
903 if (p == 50)
continue;
904 if (p == 60)
continue;
905 if (p == 63)
continue;
906 if (p == 64)
continue;
907 if (p == 74)
continue;
908 if (p == 93)
continue;
909 if (p == 94)
continue;
910 if (p == 95)
continue;
911 if (p == 96)
continue;
912 if (p == 104)
continue;
913 if (p == 113)
continue;
914 if (p == 114)
continue;
915 if (p == 115)
continue;
916 if (p == 123)
continue;
917 if (p == 134)
continue;
918 if (p == 135)
continue;
919 if (p == 136)
continue;
921 int y1 = pattern_base0[p][0];
922 int y2 = pattern_base0[p][1];
923 int y3 = pattern_base0[p][2];
924 int y4 = pattern_base0[p][3];
926 if (SL0[i] && SL1[
N64(i + y1)] && SL2[
N64(i + y2)] && SL3[
N64(i + y3)] && SL4[
N64(i + y4)] && !SL0_already_found) {
928 if (patt_ID[i] < 0) { patt_ID[i] = p; }
929 SL0_already_found =
true;
933 if (SL0_already_found)
break;
956 for (
int i = 0; i < 4; i++) {
957 ST0_36b[0 + 9 * i] = ST0[0 + 16 * i] or ST0[1 + 16 * i];
958 ST0_36b[1 + 9 * i] = ST0[1 + 16 * i] or ST0[2 + 16 * i] or ST0[3 + 16 * i];
959 ST0_36b[2 + 9 * i] = ST0[3 + 16 * i] or ST0[4 + 16 * i] or ST0[5 + 16 * i];
960 ST0_36b[3 + 9 * i] = ST0[5 + 16 * i] or ST0[6 + 16 * i] or ST0[7 + 16 * i];
961 ST0_36b[4 + 9 * i] = ST0[7 + 16 * i] or ST0[8 + 16 * i];
962 ST0_36b[5 + 9 * i] = ST0[8 + 16 * i] or ST0[9 + 16 * i] or ST0[10 + 16 * i];
963 ST0_36b[6 + 9 * i] = ST0[10 + 16 * i] or ST0[11 + 16 * i] or ST0[12 + 16 * i];
964 ST0_36b[7 + 9 * i] = ST0[12 + 16 * i] or ST0[13 + 16 * i] or ST0[14 + 16 * i];
965 ST0_36b[8 + 9 * i] = ST0[14 + 16 * i] or ST0[15 + 16 * i];
1001 for (
int i = 0; i < 64; i++) {
1005 int L = i - 1, R = i + 1;
1006 while (ST2[
N64(L)]) {
1007 ST2[
N64(L)] =
false;
1010 while (ST2[
N64(R)]) {
1011 ST2[
N64(R)] =
false;
1017 int index =
N64((L + R) / 2);
1019 st->set_TS_ID(0, stlist_buf[index][1]);
1020 st->set_TS_ID(1, stlist_buf[index][2]);
1021 st->set_TS_ID(2, stlist_buf[index][3]);
1022 st->set_TS_ID(3, stlist_buf[index][4]);
1023 st->set_TS_ID(4, stlist_buf[index][5]);
1028 for (
int i = 0; i < 36; i++) {
1029 s2s3 = (ST0_36b[i] and (ST0_36b[
N36(i + 18)] or ST0_36b[
N36(i + 17)] or ST0_36b[
N36(i + 19)])) or s2s3;
1030 s2s5 = (ST0_36b[i] and (ST0_36b[
N36(i + 18)] or ST0_36b[
N36(i + 17)] or ST0_36b[
N36(i + 19)]
1031 or ST0_36b[
N36(i + 16)] or ST0_36b[
N36(i + 20)])) or s2s5;
1032 s2so = (ST0_36b[i] and (ST0_36b[
N36(i + 18)] or ST0_36b[
N36(i + 17)] or ST0_36b[
N36(i + 19)]
1033 or ST0_36b[
N36(i + 16)] or ST0_36b[
N36(i + 20)]
1034 or ST0_36b[
N36(i + 15)] or ST0_36b[
N36(i + 21)]
1035 or ST0_36b[
N36(i + 14)] or ST0_36b[
N36(i + 22)]
1036 or ST0_36b[
N36(i + 13)] or ST0_36b[
N36(i + 23)]
1037 or ST0_36b[
N36(i + 12)] or ST0_36b[
N36(i + 24)]
1038 or ST0_36b[
N36(i + 11)] or ST0_36b[
N36(i + 25)]
1039 or ST0_36b[
N36(i + 10)] or ST0_36b[
N36(i + 26)]
1040 or ST0_36b[
N36(i + 9)] or ST0_36b[
N36(i + 27)])) or s2so ;
1042 s2f3 = (phimap_i[i] and (ST0_36b[
N36(i + 18)] or ST0_36b[
N36(i + 17)] or ST0_36b[
N36(i + 19)])) or s2f3;
1043 s2f5 = (phimap_i[i] and (ST0_36b[
N36(i + 18)] or ST0_36b[
N36(i + 17)] or ST0_36b[
N36(i + 19)]
1044 or ST0_36b[
N36(i + 16)] or ST0_36b[
N36(i + 20)])) or s2f5;
1045 s2fo = (phimap_i[i] and (ST0_36b[
N36(i + 18)] or ST0_36b[
N36(i + 17)] or ST0_36b[
N36(i + 19)]
1046 or ST0_36b[
N36(i + 16)] or ST0_36b[
N36(i + 20)]
1047 or ST0_36b[
N36(i + 15)] or ST0_36b[
N36(i + 21)]
1048 or ST0_36b[
N36(i + 14)] or ST0_36b[
N36(i + 22)]
1049 or ST0_36b[
N36(i + 13)] or ST0_36b[
N36(i + 23)]
1050 or ST0_36b[
N36(i + 12)] or ST0_36b[
N36(i + 24)]
1051 or ST0_36b[
N36(i + 11)] or ST0_36b[
N36(i + 25)]
1052 or ST0_36b[
N36(i + 10)] or ST0_36b[
N36(i + 26)]
1053 or ST0_36b[
N36(i + 9)] or ST0_36b[
N36(i + 27)])) or s2fo ;
1057 trgInfo->setNshorttrk(N_ST);
1058 trgInfo->sets2s3(s2s3);
1059 trgInfo->sets2s5(s2s5);
1060 trgInfo->sets2so(s2so);
1061 trgInfo->sets2f3(s2f3);
1062 trgInfo->sets2f5(s2f5);
1063 trgInfo->sets2fo(s2fo);
1064 trgInfo->setbwdsb(0);
1065 trgInfo->setbwdnb(0);
1066 trgInfo->setfwdsb(0);
1067 trgInfo->setfwdnb(0);
1068 trgInfo->setbrlfb(0);
1069 trgInfo->setbrlnb(0);
1077 if (pattern == 6) {ec = 1; l = 0; r = 1;}
1078 if (pattern == 7) {ec = 1; l = 0; r = 1;}
1079 if (pattern == 8) {ec = 1; l = 0; r = 1;}
1080 if (pattern == 9) {ec = 1; l = 0; r = 2;}
1081 if (pattern == 10) {ec = 1; l = 0; r = 2;}
1082 if (pattern == 11) {ec = 1; l = 0; r = 1;}
1083 if (pattern == 12) {ec = 1; l = 0; r = 2;}
1084 if (pattern == 18) {ec = 1; l = 0; r = 2;}
1085 if (pattern == 19) {ec = 1; l = 0; r = 2;}
1086 if (pattern == 20) {ec = 1; l = 0; r = 4;}
1087 if (pattern == 21) {ec = 1; l = 0; r = 4;}
1088 if (pattern == 28) {ec = 1; l = -4; r = 0;}
1089 if (pattern == 29) {ec = 1; l = -3; r = 0;}
1090 if (pattern == 34) {ec = 1; l = 0; r = 1;}
1091 if (pattern == 35) {ec = 1; l = 0; r = 3;}
1092 if (pattern == 36) {ec = 1; l = 1; r = 3;}
1093 if (pattern == 37) {ec = 1; l = 0; r = 3;}
1094 if (pattern == 44) {ec = 1; l = -4; r = 0;}
1095 if (pattern == 45) {ec = 1; l = -2; r = 0;}
1096 if (pattern == 46) {ec = 1; l = -3; r = 0;}
1097 if (pattern == 54) {ec = 1; l = 1; r = 7;}
1098 if (pattern == 55) {ec = 1; l = 1; r = 6;}
1099 if (pattern == 56) {ec = 1; l = 1; r = 5;}
1100 if (pattern == 57) {ec = 1; l = 1; r = 5;}
1101 if (pattern == 64) {ec = 1; l = -6; r = -1;}
1102 if (pattern == 73) {ec = 1; l = 3; r = 13;}
1103 if (pattern == 81) {ec = 1; l = -10; r = -3;}
1104 if (pattern == 86) {ec = 1; l = 3; r = 12;}
1105 if (pattern == 87) {ec = 1; l = 3; r = 6;}
1106 if (pattern == 100) {ec = 1; l = 7; r = 20;}
1107 if (pattern == 101) {ec = 1; l = 5; r = 20;}
1108 if (pattern == 102) {ec = 1; l = 5; r = 20;}
1109 if (pattern == 103) {ec = 1; l = 4; r = 14;}
1110 if (pattern == 111) {ec = 1; l = -12; r = -5;}
1111 if (pattern == 112) {ec = 1; l = -18; r = -5;}
1112 if (pattern == 116) {ec = 1; l = -11; r = -6;}
1113 if (pattern == 120) {ec = 1; l = 7; r = 21;}
1114 if (pattern == 121) {ec = 1; l = 7; r = 14;}
1115 if (pattern == 122) {ec = 1; l = 7; r = 21;}
1116 if (pattern == 127) {ec = 1; l = -21; r = -8;}
1117 if (pattern == 128) {ec = 1; l = -15; r = -7;}
1118 if (pattern == 129) {ec = 1; l = -12; r = -7;}
1119 if (pattern == 132) {ec = 1; l = 10; r = 18;}
1120 if (pattern == 133) {ec = 1; l = 8; r = 18;}
1122 if (pattern == 0) {ec = 2; l = -3; r = 1;}
1123 if (pattern == 1) {ec = 2; l = -3; r = 1;}
1124 if (pattern == 3) {ec = 2; l = -3; r = 0;}
1125 if (pattern == 13) {ec = 2; l = 0; r = 3;}
1126 if (pattern == 14) {ec = 2; l = 0; r = 4;}
1127 if (pattern == 15) {ec = 2; l = 0; r = 5;}
1128 if (pattern == 22) {ec = 2; l = -4; r = -1;}
1129 if (pattern == 23) {ec = 2; l = -5; r = -1;}
1130 if (pattern == 24) {ec = 2; l = -3; r = 0;}
1131 if (pattern == 25) {ec = 2; l = -4; r = 0;}
1132 if (pattern == 30) {ec = 2; l = 1; r = 5;}
1133 if (pattern == 39) {ec = 2; l = -2; r = 0;}
1134 if (pattern == 40) {ec = 2; l = -2; r = 0;}
1135 if (pattern == 48) {ec = 2; l = 2; r = 6;}
1136 if (pattern == 49) {ec = 2; l = 3; r = 8;}
1137 if (pattern == 58) {ec = 2; l = -9; r = -3;}
1138 if (pattern == 59) {ec = 2; l = -9; r = -3;}
1139 if (pattern == 67) {ec = 2; l = 5; r = 11;}
1140 if (pattern == 75) {ec = 2; l = -13; r = -6;}
1141 if (pattern == 82) {ec = 2; l = 5; r = 9;}
1142 if (pattern == 83) {ec = 2; l = 5; r = 9;}
1143 if (pattern == 89) {ec = 2; l = -10; r = -4;}
1144 if (pattern == 92) {ec = 2; l = -10; r = -4;}
1145 if (pattern == 97) {ec = 2; l = 7; r = 19;}
1146 if (pattern == 105) {ec = 2; l = -16; r = -10;}
1147 if (pattern == 106) {ec = 2; l = -17; r = -7;}
1148 if (pattern == 109) {ec = 2; l = -17; r = -6;}
1149 if (pattern == 111) {ec = 2; l = -16; r = -7;}
1150 if (pattern == 117) {ec = 2; l = 9; r = 19;}
1151 if (pattern == 118) {ec = 2; l = 9; r = 19;}
1152 if (pattern == 124) {ec = 2; l = -17; r = -8;}
1153 if (pattern == 125) {ec = 2; l = -17; r = -8;}
1154 if (pattern == 126) {ec = 2; l = -17; r = -8;}