22#include <trg/cdc/modules/trgcdct3dConverter/TRGCDCT3DConverterModule.h>
24#include "trg/cdc/Fitter3D.h"
25#include "trg/cdc/Fitter3DUtility.h"
26#include "trg/cdc/JSignal.h"
27#include "trg/cdc/JSignalData.h"
28#include "boost/multi_array.hpp"
33using namespace TRGCDCT3DCONVERTERSPACE;
39 return string(
"1.00");
46 string desc =
"TRGCDCT3DConverterModule(" +
version() +
")";
49 "Name of the input StoreArray of CDCTriggerSegmentHits.",
50 string(
"CDCTriggerSegmentHits0"));
52 "If true, adds TS to datastore",
55 "Name of the event time object.",
56 string(
"BinnedEventT00"));
58 "If true, adds event time to datastore",
61 "Name of the StoreArray holding the input tracks from the 2D finder.",
62 string(
"TRGCDC2DFinderTracks0"));
64 "If true, adds 2D Finder results to datastore",
67 "Name of the StoreArray holding the 3D output tracks.",
68 string(
"TRGCDC3DFitterTracks0"));
70 "If true, adds 3D results to datastore",
73 "0: use firmware results. 1: Fits with fast TSIM. 2: Fits with firm TSIM",
76 "Name of the StoreArray holding the firmware results.",
77 string(
"TRGCDCT3DUnpackerStores0"));
79 "If not zero, prints detail information.",
81 B2INFO(
"TRGCDCT3DConverter: Constructor done.");
121 multi_array<double, 4> stTsfFirmwareInfo{extents[4][15][48][5]};
125 multi_array<double, 3> stTsfInfo{extents[4][0][5]};
136 multi_array<double, 3> t2DFirmwareInfo{extents[4][48][5]};
138 multi_array<double, 4> t2DTsfFirmwareInfo{extents[4][48][5][4]};
142 multi_array<double, 2> t2DInfo{extents[0][3]};
144 multi_array<double, 3> t2DTsfInfo{extents[0][5][5]};
146 filter2DData(t2DFirmwareInfo, t2DTsfFirmwareInfo, t2DInfo, t2DTsfInfo);
153 bool validEventTime = 0;
157 if (result->m_t3dtrk0_evtTimeValid_delay) {
159 eventTime = result->m_t3dtrk0_evtTime_delay;
162 if (validEventTime) {
166 if (validEventTime) cout <<
"[ET] valid: 1 eventTime:" << eventTime << endl;
167 else cout <<
"[ET] valid: 0" << endl;
173 multi_array<double, 3> t3DFirmwareInfo{extents[4][48][11]};
184 multi_array<double, 2> t3DInfo{extents[0][7]};
230 vector<int> nWires = {160, 160, 192, 224, 256, 288, 320, 352, 384};
232 for (
int i = 0; i < (int)iSL; i++) {
238 id =
id + iWire + nWires[(int)iSL] / 4.0 * 0;
239 if (iWire + nWires[(
int)iSL] / 4.0 * 0 > nWires[(int)iSL]) {
240 id =
id - nWires[(int)iSL];
243 id =
id + iWire + nWires[(int)iSL] / 4.0 * 1;
244 if (iWire + nWires[(
int)iSL] / 4.0 * 1 > nWires[(int)iSL]) {
245 id =
id - nWires[(int)iSL];
248 id =
id + iWire + nWires[(int)iSL] / 4.0 * 2;
249 if (iWire + nWires[(
int)iSL] / 4.0 * 2 > nWires[(int)iSL]) {
250 id =
id - nWires[(int)iSL];
253 id =
id + iWire + nWires[(int)iSL] / 4.0 * 3;
254 if (iWire + nWires[(
int)iSL] / 4.0 * 3 > nWires[(int)iSL]) {
255 id =
id - nWires[(int)iSL];
264 int signMask = 1 << (nBits - 1);
265 if (value & signMask) {
266 int mask = (1 << nBits) - 1;
287 double phiReal = 45 + 90. / 80 * (1 + phi);
288 if (
toSigned(rho, 7) >= 0) phiReal -= 90;
291 while (phiReal > 180) {
294 while (phiReal < -180) {
298 int phiInt = phiReal * (pow(2, 12) - 0.5) / 180;
303 multi_array<double, 3>& tsfInfo)
306 for (
unsigned iSL = 0; iSL < tsfFirmwareInfo.shape()[0]; iSL++) {
307 unsigned iTS_filter = 0;
308 for (
unsigned iTS = 0; iTS < tsfFirmwareInfo.shape()[1]; iTS++) {
309 for (
unsigned iClk = 0; iClk < tsfFirmwareInfo.shape()[2]; iClk++) {
310 double id = tsfFirmwareInfo[iSL][iTS][iClk][0];
311 double rt = tsfFirmwareInfo[iSL][iTS][iClk][1];
312 double lr = tsfFirmwareInfo[iSL][iTS][iClk][2];
313 double pr = tsfFirmwareInfo[iSL][iTS][iClk][3];
314 double ft = tsfFirmwareInfo[iSL][iTS][iClk][4];
317 double ts_ref[5] = {id, rt, lr, pr, ft};
318 multi_array_ref<double, 1> ts((
double*)ts_ref, extents[5]);
319 tsfInfo.resize(extents[4][tsfInfo.shape()[1] + 1][5]);
320 tsfInfo[iSL][iTS_filter++] = ts;
359 multi_array<double, 4>& t2DTsfFirmwareInfo, multi_array<double, 2>& t2DInfo,
360 multi_array<double, 3>& t2DTsfInfo)
363 for (
unsigned iTrack = 0; iTrack < t2DFirmwareInfo.shape()[0]; iTrack++) {
364 for (
unsigned iClk = 0; iClk < t2DFirmwareInfo.shape()[1]; iClk++) {
365 if (t2DFirmwareInfo[iTrack][iClk][0] == 0)
continue;
371 double track_ref[3] = {t2DFirmwareInfo[iTrack][iClk][2], t2DFirmwareInfo[iTrack][iClk][3], t2DFirmwareInfo[iTrack][iClk][4]};
372 multi_array_ref<double, 1> track((
double*)track_ref, extents[3]);
373 t2DInfo.resize(extents[t2DInfo.shape()[0] + 1][3]);
374 t2DInfo[t2DInfo.shape()[0] - 1] = track;
377 multi_array<double, 2> axTSInfo{extents[5][5]};
378 for (
unsigned iAx = 0; iAx < t2DTsfFirmwareInfo.shape()[2]; iAx++) {
379 double id = t2DTsfFirmwareInfo[iTrack][iClk][iAx][0];
380 double rt = t2DTsfFirmwareInfo[iTrack][iClk][iAx][1];
381 double lr = t2DTsfFirmwareInfo[iTrack][iClk][iAx][2];
382 double pr = t2DTsfFirmwareInfo[iTrack][iClk][iAx][3];
384 axTSInfo[iAx][0] = id;
385 axTSInfo[iAx][1] = rt;
386 axTSInfo[iAx][2] = lr;
387 axTSInfo[iAx][3] = pr;
388 axTSInfo[iAx][4] = -9999;
390 t2DTsfInfo.resize(extents[t2DTsfInfo.shape()[0] + 1][5][5]);
391 t2DTsfInfo[t2DTsfInfo.shape()[0] - 1] = axTSInfo;
454 multi_array<double, 3>& t2DTsfInfo)
457 for (
unsigned iTrack = 0; iTrack < t2DInfo.shape()[0]; ++iTrack) {
458 double charge = 0, phi0_i = 0, omega = 0, chi2D = 0;
461 charge = t2DInfo[iTrack][0] == 2 ? -1 : 1;
465 phi0_i = (45 + 90. / 80 * (1 + t2DInfo[iTrack][2])) / 180 * M_PI;
469 phi0_i = phi0_i + (M_PI / 2.0) * 0;
471 phi0_i = phi0_i + (M_PI / 2.0) * 1;
473 phi0_i = phi0_i + (M_PI / 2.0) * 2;
475 phi0_i = phi0_i + (M_PI / 2.0) * 3;
479 while (phi0_i > M_PI) {
482 while (phi0_i < -M_PI) {
489 omega =
toSigned(t2DInfo[iTrack][1], 7) / 33.0 * 3.2;
494 if (
m_isVerbose) cout <<
"[2D] iTrack:" << iTrack <<
" charge:" << charge <<
" phi0_i:" << phi0_i <<
" " << phi0_i * 180 / M_PI <<
495 " omega:" << omega <<
" pt:" << charge / omega * 0.3 * 1.5 * 0.01 << endl;
497 for (
unsigned iAx = 0; iAx < t2DTsfInfo.shape()[1]; ++iAx) {
498 double rawId = t2DTsfInfo[iTrack][iAx][0];
500 if (iAx != 4)
id = rawId;
503 if (
id < 0)
id += 384;
505 double rt = t2DTsfInfo[iTrack][iAx][1];
506 double lr = t2DTsfInfo[iTrack][iAx][2];
507 double pr = t2DTsfInfo[iTrack][iAx][3];
508 double ft = t2DTsfInfo[iTrack][iAx][4];
509 if (pr == 0)
continue;
510 CDCHit prHit(rt, 0, iAx * 2, pr == 3 ? 2 : 3,
id);
513 if (
m_isVerbose) cout <<
"[2D] iTrack: " << iTrack <<
" iAx:" << iAx <<
" id:" <<
id <<
" rt:" << rt <<
" lr:" << lr <<
" pr:" << pr
514 <<
" ft:" << ft << endl;
523 for (
unsigned iSL = 0; iSL < tsfInfo.shape()[0]; iSL++) {
524 for (
unsigned iTS = 0; iTS < tsfInfo.shape()[1]; iTS++) {
525 double id = tsfInfo[iSL][iTS][0];
526 double rt = tsfInfo[iSL][iTS][1];
527 double lr = tsfInfo[iSL][iTS][2];
528 double pr = tsfInfo[iSL][iTS][3];
529 double ft = tsfInfo[iSL][iTS][4];
530 if (
m_isVerbose) cout <<
"[TSF] iSL:" << iSL <<
" iTS:" << iTS <<
" id:" <<
id <<
" rt:" << rt <<
" lr:" << lr <<
" pr:" << pr <<
531 " ft:" << ft << endl;
533 CDCHit prHit(rt, 0, iSL * 2 + isSt, pr == 3 ? 2 : 3,
id);
545 tsfInfo[0][0][iClk][0] = result->m_tsf1ts0_id;
546 tsfInfo[0][0][iClk][1] = result->m_tsf1ts0_rt;
547 tsfInfo[0][0][iClk][2] = result->m_tsf1ts0_lr;
548 tsfInfo[0][0][iClk][3] = result->m_tsf1ts0_pr;
549 tsfInfo[0][0][iClk][4] = result->m_tsf1_cc;
550 tsfInfo[0][1][iClk][0] = result->m_tsf1ts1_id;
551 tsfInfo[0][1][iClk][1] = result->m_tsf1ts1_rt;
552 tsfInfo[0][1][iClk][2] = result->m_tsf1ts1_lr;
553 tsfInfo[0][1][iClk][3] = result->m_tsf1ts1_pr;
554 tsfInfo[0][1][iClk][4] = result->m_tsf1_cc;
555 tsfInfo[0][2][iClk][0] = result->m_tsf1ts2_id;
556 tsfInfo[0][2][iClk][1] = result->m_tsf1ts2_rt;
557 tsfInfo[0][2][iClk][2] = result->m_tsf1ts2_lr;
558 tsfInfo[0][2][iClk][3] = result->m_tsf1ts2_pr;
559 tsfInfo[0][2][iClk][4] = result->m_tsf1_cc;
560 tsfInfo[0][3][iClk][0] = result->m_tsf1ts3_id;
561 tsfInfo[0][3][iClk][1] = result->m_tsf1ts3_rt;
562 tsfInfo[0][3][iClk][2] = result->m_tsf1ts3_lr;
563 tsfInfo[0][3][iClk][3] = result->m_tsf1ts3_pr;
564 tsfInfo[0][3][iClk][4] = result->m_tsf1_cc;
565 tsfInfo[0][4][iClk][0] = result->m_tsf1ts4_id;
566 tsfInfo[0][4][iClk][1] = result->m_tsf1ts4_rt;
567 tsfInfo[0][4][iClk][2] = result->m_tsf1ts4_lr;
568 tsfInfo[0][4][iClk][3] = result->m_tsf1ts4_pr;
569 tsfInfo[0][4][iClk][4] = result->m_tsf1_cc;
570 tsfInfo[0][5][iClk][0] = result->m_tsf1ts5_id;
571 tsfInfo[0][5][iClk][1] = result->m_tsf1ts5_rt;
572 tsfInfo[0][5][iClk][2] = result->m_tsf1ts5_lr;
573 tsfInfo[0][5][iClk][3] = result->m_tsf1ts5_pr;
574 tsfInfo[0][5][iClk][4] = result->m_tsf1_cc;
575 tsfInfo[0][6][iClk][0] = result->m_tsf1ts6_id;
576 tsfInfo[0][6][iClk][1] = result->m_tsf1ts6_rt;
577 tsfInfo[0][6][iClk][2] = result->m_tsf1ts6_lr;
578 tsfInfo[0][6][iClk][3] = result->m_tsf1ts6_pr;
579 tsfInfo[0][6][iClk][4] = result->m_tsf1_cc;
580 tsfInfo[0][7][iClk][0] = result->m_tsf1ts7_id;
581 tsfInfo[0][7][iClk][1] = result->m_tsf1ts7_rt;
582 tsfInfo[0][7][iClk][2] = result->m_tsf1ts7_lr;
583 tsfInfo[0][7][iClk][3] = result->m_tsf1ts7_pr;
584 tsfInfo[0][7][iClk][4] = result->m_tsf1_cc;
585 tsfInfo[0][8][iClk][0] = result->m_tsf1ts8_id;
586 tsfInfo[0][8][iClk][1] = result->m_tsf1ts8_rt;
587 tsfInfo[0][8][iClk][2] = result->m_tsf1ts8_lr;
588 tsfInfo[0][8][iClk][3] = result->m_tsf1ts8_pr;
589 tsfInfo[0][8][iClk][4] = result->m_tsf1_cc;
590 tsfInfo[0][9][iClk][0] = result->m_tsf1ts9_id;
591 tsfInfo[0][9][iClk][1] = result->m_tsf1ts9_rt;
592 tsfInfo[0][9][iClk][2] = result->m_tsf1ts9_lr;
593 tsfInfo[0][9][iClk][3] = result->m_tsf1ts9_pr;
594 tsfInfo[0][9][iClk][4] = result->m_tsf1_cc;
595 tsfInfo[0][10][iClk][0] = result->m_tsf1ts10_id;
596 tsfInfo[0][10][iClk][1] = result->m_tsf1ts10_rt;
597 tsfInfo[0][10][iClk][2] = result->m_tsf1ts10_lr;
598 tsfInfo[0][10][iClk][3] = result->m_tsf1ts10_pr;
599 tsfInfo[0][10][iClk][4] = result->m_tsf1_cc;
600 tsfInfo[0][11][iClk][0] = result->m_tsf1ts11_id;
601 tsfInfo[0][11][iClk][1] = result->m_tsf1ts11_rt;
602 tsfInfo[0][11][iClk][2] = result->m_tsf1ts11_lr;
603 tsfInfo[0][11][iClk][3] = result->m_tsf1ts11_pr;
604 tsfInfo[0][11][iClk][4] = result->m_tsf1_cc;
605 tsfInfo[0][12][iClk][0] = result->m_tsf1ts12_id;
606 tsfInfo[0][12][iClk][1] = result->m_tsf1ts12_rt;
607 tsfInfo[0][12][iClk][2] = result->m_tsf1ts12_lr;
608 tsfInfo[0][12][iClk][3] = result->m_tsf1ts12_pr;
609 tsfInfo[0][12][iClk][4] = result->m_tsf1_cc;
610 tsfInfo[0][13][iClk][0] = result->m_tsf1ts13_id;
611 tsfInfo[0][13][iClk][1] = result->m_tsf1ts13_rt;
612 tsfInfo[0][13][iClk][2] = result->m_tsf1ts13_lr;
613 tsfInfo[0][13][iClk][3] = result->m_tsf1ts13_pr;
614 tsfInfo[0][13][iClk][4] = result->m_tsf1_cc;
615 tsfInfo[0][14][iClk][0] = result->m_tsf1ts14_id;
616 tsfInfo[0][14][iClk][1] = result->m_tsf1ts14_rt;
617 tsfInfo[0][14][iClk][2] = result->m_tsf1ts14_lr;
618 tsfInfo[0][14][iClk][3] = result->m_tsf1ts14_pr;
619 tsfInfo[0][14][iClk][4] = result->m_tsf1_cc;
621 tsfInfo[1][0][iClk][0] = result->m_tsf3ts0_id;
622 tsfInfo[1][0][iClk][1] = result->m_tsf3ts0_rt;
623 tsfInfo[1][0][iClk][2] = result->m_tsf3ts0_lr;
624 tsfInfo[1][0][iClk][3] = result->m_tsf3ts0_pr;
625 tsfInfo[1][0][iClk][4] = result->m_tsf3_cc;
626 tsfInfo[1][1][iClk][0] = result->m_tsf3ts1_id;
627 tsfInfo[1][1][iClk][1] = result->m_tsf3ts1_rt;
628 tsfInfo[1][1][iClk][2] = result->m_tsf3ts1_lr;
629 tsfInfo[1][1][iClk][3] = result->m_tsf3ts1_pr;
630 tsfInfo[1][1][iClk][4] = result->m_tsf3_cc;
631 tsfInfo[1][2][iClk][0] = result->m_tsf3ts2_id;
632 tsfInfo[1][2][iClk][1] = result->m_tsf3ts2_rt;
633 tsfInfo[1][2][iClk][2] = result->m_tsf3ts2_lr;
634 tsfInfo[1][2][iClk][3] = result->m_tsf3ts2_pr;
635 tsfInfo[1][2][iClk][4] = result->m_tsf3_cc;
636 tsfInfo[1][3][iClk][0] = result->m_tsf3ts3_id;
637 tsfInfo[1][3][iClk][1] = result->m_tsf3ts3_rt;
638 tsfInfo[1][3][iClk][2] = result->m_tsf3ts3_lr;
639 tsfInfo[1][3][iClk][3] = result->m_tsf3ts3_pr;
640 tsfInfo[1][3][iClk][4] = result->m_tsf3_cc;
641 tsfInfo[1][4][iClk][0] = result->m_tsf3ts4_id;
642 tsfInfo[1][4][iClk][1] = result->m_tsf3ts4_rt;
643 tsfInfo[1][4][iClk][2] = result->m_tsf3ts4_lr;
644 tsfInfo[1][4][iClk][3] = result->m_tsf3ts4_pr;
645 tsfInfo[1][4][iClk][4] = result->m_tsf3_cc;
646 tsfInfo[1][5][iClk][0] = result->m_tsf3ts5_id;
647 tsfInfo[1][5][iClk][1] = result->m_tsf3ts5_rt;
648 tsfInfo[1][5][iClk][2] = result->m_tsf3ts5_lr;
649 tsfInfo[1][5][iClk][3] = result->m_tsf3ts5_pr;
650 tsfInfo[1][5][iClk][4] = result->m_tsf3_cc;
651 tsfInfo[1][6][iClk][0] = result->m_tsf3ts6_id;
652 tsfInfo[1][6][iClk][1] = result->m_tsf3ts6_rt;
653 tsfInfo[1][6][iClk][2] = result->m_tsf3ts6_lr;
654 tsfInfo[1][6][iClk][3] = result->m_tsf3ts6_pr;
655 tsfInfo[1][6][iClk][4] = result->m_tsf3_cc;
656 tsfInfo[1][7][iClk][0] = result->m_tsf3ts7_id;
657 tsfInfo[1][7][iClk][1] = result->m_tsf3ts7_rt;
658 tsfInfo[1][7][iClk][2] = result->m_tsf3ts7_lr;
659 tsfInfo[1][7][iClk][3] = result->m_tsf3ts7_pr;
660 tsfInfo[1][7][iClk][4] = result->m_tsf3_cc;
661 tsfInfo[1][8][iClk][0] = result->m_tsf3ts8_id;
662 tsfInfo[1][8][iClk][1] = result->m_tsf3ts8_rt;
663 tsfInfo[1][8][iClk][2] = result->m_tsf3ts8_lr;
664 tsfInfo[1][8][iClk][3] = result->m_tsf3ts8_pr;
665 tsfInfo[1][8][iClk][4] = result->m_tsf3_cc;
666 tsfInfo[1][9][iClk][0] = result->m_tsf3ts9_id;
667 tsfInfo[1][9][iClk][1] = result->m_tsf3ts9_rt;
668 tsfInfo[1][9][iClk][2] = result->m_tsf3ts9_lr;
669 tsfInfo[1][9][iClk][3] = result->m_tsf3ts9_pr;
670 tsfInfo[1][9][iClk][4] = result->m_tsf3_cc;
671 tsfInfo[1][10][iClk][0] = result->m_tsf3ts10_id;
672 tsfInfo[1][10][iClk][1] = result->m_tsf3ts10_rt;
673 tsfInfo[1][10][iClk][2] = result->m_tsf3ts10_lr;
674 tsfInfo[1][10][iClk][3] = result->m_tsf3ts10_pr;
675 tsfInfo[1][10][iClk][4] = result->m_tsf3_cc;
676 tsfInfo[1][11][iClk][0] = result->m_tsf3ts11_id;
677 tsfInfo[1][11][iClk][1] = result->m_tsf3ts11_rt;
678 tsfInfo[1][11][iClk][2] = result->m_tsf3ts11_lr;
679 tsfInfo[1][11][iClk][3] = result->m_tsf3ts11_pr;
680 tsfInfo[1][11][iClk][4] = result->m_tsf3_cc;
681 tsfInfo[1][12][iClk][0] = result->m_tsf3ts12_id;
682 tsfInfo[1][12][iClk][1] = result->m_tsf3ts12_rt;
683 tsfInfo[1][12][iClk][2] = result->m_tsf3ts12_lr;
684 tsfInfo[1][12][iClk][3] = result->m_tsf3ts12_pr;
685 tsfInfo[1][12][iClk][4] = result->m_tsf3_cc;
686 tsfInfo[1][13][iClk][0] = result->m_tsf3ts13_id;
687 tsfInfo[1][13][iClk][1] = result->m_tsf3ts13_rt;
688 tsfInfo[1][13][iClk][2] = result->m_tsf3ts13_lr;
689 tsfInfo[1][13][iClk][3] = result->m_tsf3ts13_pr;
690 tsfInfo[1][13][iClk][4] = result->m_tsf3_cc;
691 tsfInfo[1][14][iClk][0] = result->m_tsf3ts14_id;
692 tsfInfo[1][14][iClk][1] = result->m_tsf3ts14_rt;
693 tsfInfo[1][14][iClk][2] = result->m_tsf3ts14_lr;
694 tsfInfo[1][14][iClk][3] = result->m_tsf3ts14_pr;
695 tsfInfo[1][14][iClk][4] = result->m_tsf3_cc;
697 tsfInfo[2][0][iClk][0] = result->m_tsf5ts0_id;
698 tsfInfo[2][0][iClk][1] = result->m_tsf5ts0_rt;
699 tsfInfo[2][0][iClk][2] = result->m_tsf5ts0_lr;
700 tsfInfo[2][0][iClk][3] = result->m_tsf5ts0_pr;
701 tsfInfo[2][0][iClk][4] = result->m_tsf5_cc;
702 tsfInfo[2][1][iClk][0] = result->m_tsf5ts1_id;
703 tsfInfo[2][1][iClk][1] = result->m_tsf5ts1_rt;
704 tsfInfo[2][1][iClk][2] = result->m_tsf5ts1_lr;
705 tsfInfo[2][1][iClk][3] = result->m_tsf5ts1_pr;
706 tsfInfo[2][1][iClk][4] = result->m_tsf5_cc;
707 tsfInfo[2][2][iClk][0] = result->m_tsf5ts2_id;
708 tsfInfo[2][2][iClk][1] = result->m_tsf5ts2_rt;
709 tsfInfo[2][2][iClk][2] = result->m_tsf5ts2_lr;
710 tsfInfo[2][2][iClk][3] = result->m_tsf5ts2_pr;
711 tsfInfo[2][2][iClk][4] = result->m_tsf5_cc;
712 tsfInfo[2][3][iClk][0] = result->m_tsf5ts3_id;
713 tsfInfo[2][3][iClk][1] = result->m_tsf5ts3_rt;
714 tsfInfo[2][3][iClk][2] = result->m_tsf5ts3_lr;
715 tsfInfo[2][3][iClk][3] = result->m_tsf5ts3_pr;
716 tsfInfo[2][3][iClk][4] = result->m_tsf5_cc;
717 tsfInfo[2][4][iClk][0] = result->m_tsf5ts4_id;
718 tsfInfo[2][4][iClk][1] = result->m_tsf5ts4_rt;
719 tsfInfo[2][4][iClk][2] = result->m_tsf5ts4_lr;
720 tsfInfo[2][4][iClk][3] = result->m_tsf5ts4_pr;
721 tsfInfo[2][4][iClk][4] = result->m_tsf5_cc;
722 tsfInfo[2][5][iClk][0] = result->m_tsf5ts5_id;
723 tsfInfo[2][5][iClk][1] = result->m_tsf5ts5_rt;
724 tsfInfo[2][5][iClk][2] = result->m_tsf5ts5_lr;
725 tsfInfo[2][5][iClk][3] = result->m_tsf5ts5_pr;
726 tsfInfo[2][5][iClk][4] = result->m_tsf5_cc;
727 tsfInfo[2][6][iClk][0] = result->m_tsf5ts6_id;
728 tsfInfo[2][6][iClk][1] = result->m_tsf5ts6_rt;
729 tsfInfo[2][6][iClk][2] = result->m_tsf5ts6_lr;
730 tsfInfo[2][6][iClk][3] = result->m_tsf5ts6_pr;
731 tsfInfo[2][6][iClk][4] = result->m_tsf5_cc;
732 tsfInfo[2][7][iClk][0] = result->m_tsf5ts7_id;
733 tsfInfo[2][7][iClk][1] = result->m_tsf5ts7_rt;
734 tsfInfo[2][7][iClk][2] = result->m_tsf5ts7_lr;
735 tsfInfo[2][7][iClk][3] = result->m_tsf5ts7_pr;
736 tsfInfo[2][7][iClk][4] = result->m_tsf5_cc;
737 tsfInfo[2][8][iClk][0] = result->m_tsf5ts8_id;
738 tsfInfo[2][8][iClk][1] = result->m_tsf5ts8_rt;
739 tsfInfo[2][8][iClk][2] = result->m_tsf5ts8_lr;
740 tsfInfo[2][8][iClk][3] = result->m_tsf5ts8_pr;
741 tsfInfo[2][8][iClk][4] = result->m_tsf5_cc;
742 tsfInfo[2][9][iClk][0] = result->m_tsf5ts9_id;
743 tsfInfo[2][9][iClk][1] = result->m_tsf5ts9_rt;
744 tsfInfo[2][9][iClk][2] = result->m_tsf5ts9_lr;
745 tsfInfo[2][9][iClk][3] = result->m_tsf5ts9_pr;
746 tsfInfo[2][9][iClk][4] = result->m_tsf5_cc;
747 tsfInfo[2][10][iClk][0] = result->m_tsf5ts10_id;
748 tsfInfo[2][10][iClk][1] = result->m_tsf5ts10_rt;
749 tsfInfo[2][10][iClk][2] = result->m_tsf5ts10_lr;
750 tsfInfo[2][10][iClk][3] = result->m_tsf5ts10_pr;
751 tsfInfo[2][10][iClk][4] = result->m_tsf5_cc;
752 tsfInfo[2][11][iClk][0] = result->m_tsf5ts11_id;
753 tsfInfo[2][11][iClk][1] = result->m_tsf5ts11_rt;
754 tsfInfo[2][11][iClk][2] = result->m_tsf5ts11_lr;
755 tsfInfo[2][11][iClk][3] = result->m_tsf5ts11_pr;
756 tsfInfo[2][11][iClk][4] = result->m_tsf5_cc;
757 tsfInfo[2][12][iClk][0] = result->m_tsf5ts12_id;
758 tsfInfo[2][12][iClk][1] = result->m_tsf5ts12_rt;
759 tsfInfo[2][12][iClk][2] = result->m_tsf5ts12_lr;
760 tsfInfo[2][12][iClk][3] = result->m_tsf5ts12_pr;
761 tsfInfo[2][12][iClk][4] = result->m_tsf5_cc;
762 tsfInfo[2][13][iClk][0] = result->m_tsf5ts13_id;
763 tsfInfo[2][13][iClk][1] = result->m_tsf5ts13_rt;
764 tsfInfo[2][13][iClk][2] = result->m_tsf5ts13_lr;
765 tsfInfo[2][13][iClk][3] = result->m_tsf5ts13_pr;
766 tsfInfo[2][13][iClk][4] = result->m_tsf5_cc;
767 tsfInfo[2][14][iClk][0] = result->m_tsf5ts14_id;
768 tsfInfo[2][14][iClk][1] = result->m_tsf5ts14_rt;
769 tsfInfo[2][14][iClk][2] = result->m_tsf5ts14_lr;
770 tsfInfo[2][14][iClk][3] = result->m_tsf5ts14_pr;
771 tsfInfo[2][14][iClk][4] = result->m_tsf5_cc;
773 tsfInfo[3][0][iClk][0] = result->m_tsf7ts0_id;
774 tsfInfo[3][0][iClk][1] = result->m_tsf7ts0_rt;
775 tsfInfo[3][0][iClk][2] = result->m_tsf7ts0_lr;
776 tsfInfo[3][0][iClk][3] = result->m_tsf7ts0_pr;
777 tsfInfo[3][0][iClk][4] = result->m_tsf7_cc;
778 tsfInfo[3][1][iClk][0] = result->m_tsf7ts1_id;
779 tsfInfo[3][1][iClk][1] = result->m_tsf7ts1_rt;
780 tsfInfo[3][1][iClk][2] = result->m_tsf7ts1_lr;
781 tsfInfo[3][1][iClk][3] = result->m_tsf7ts1_pr;
782 tsfInfo[3][1][iClk][4] = result->m_tsf7_cc;
783 tsfInfo[3][2][iClk][0] = result->m_tsf7ts2_id;
784 tsfInfo[3][2][iClk][1] = result->m_tsf7ts2_rt;
785 tsfInfo[3][2][iClk][2] = result->m_tsf7ts2_lr;
786 tsfInfo[3][2][iClk][3] = result->m_tsf7ts2_pr;
787 tsfInfo[3][2][iClk][4] = result->m_tsf7_cc;
788 tsfInfo[3][3][iClk][0] = result->m_tsf7ts3_id;
789 tsfInfo[3][3][iClk][1] = result->m_tsf7ts3_rt;
790 tsfInfo[3][3][iClk][2] = result->m_tsf7ts3_lr;
791 tsfInfo[3][3][iClk][3] = result->m_tsf7ts3_pr;
792 tsfInfo[3][3][iClk][4] = result->m_tsf7_cc;
793 tsfInfo[3][4][iClk][0] = result->m_tsf7ts4_id;
794 tsfInfo[3][4][iClk][1] = result->m_tsf7ts4_rt;
795 tsfInfo[3][4][iClk][2] = result->m_tsf7ts4_lr;
796 tsfInfo[3][4][iClk][3] = result->m_tsf7ts4_pr;
797 tsfInfo[3][4][iClk][4] = result->m_tsf7_cc;
798 tsfInfo[3][5][iClk][0] = result->m_tsf7ts5_id;
799 tsfInfo[3][5][iClk][1] = result->m_tsf7ts5_rt;
800 tsfInfo[3][5][iClk][2] = result->m_tsf7ts5_lr;
801 tsfInfo[3][5][iClk][3] = result->m_tsf7ts5_pr;
802 tsfInfo[3][5][iClk][4] = result->m_tsf7_cc;
803 tsfInfo[3][6][iClk][0] = result->m_tsf7ts6_id;
804 tsfInfo[3][6][iClk][1] = result->m_tsf7ts6_rt;
805 tsfInfo[3][6][iClk][2] = result->m_tsf7ts6_lr;
806 tsfInfo[3][6][iClk][3] = result->m_tsf7ts6_pr;
807 tsfInfo[3][6][iClk][4] = result->m_tsf7_cc;
808 tsfInfo[3][7][iClk][0] = result->m_tsf7ts7_id;
809 tsfInfo[3][7][iClk][1] = result->m_tsf7ts7_rt;
810 tsfInfo[3][7][iClk][2] = result->m_tsf7ts7_lr;
811 tsfInfo[3][7][iClk][3] = result->m_tsf7ts7_pr;
812 tsfInfo[3][7][iClk][4] = result->m_tsf7_cc;
813 tsfInfo[3][8][iClk][0] = result->m_tsf7ts8_id;
814 tsfInfo[3][8][iClk][1] = result->m_tsf7ts8_rt;
815 tsfInfo[3][8][iClk][2] = result->m_tsf7ts8_lr;
816 tsfInfo[3][8][iClk][3] = result->m_tsf7ts8_pr;
817 tsfInfo[3][8][iClk][4] = result->m_tsf7_cc;
818 tsfInfo[3][9][iClk][0] = result->m_tsf7ts9_id;
819 tsfInfo[3][9][iClk][1] = result->m_tsf7ts9_rt;
820 tsfInfo[3][9][iClk][2] = result->m_tsf7ts9_lr;
821 tsfInfo[3][9][iClk][3] = result->m_tsf7ts9_pr;
822 tsfInfo[3][9][iClk][4] = result->m_tsf7_cc;
823 tsfInfo[3][10][iClk][0] = result->m_tsf7ts10_id;
824 tsfInfo[3][10][iClk][1] = result->m_tsf7ts10_rt;
825 tsfInfo[3][10][iClk][2] = result->m_tsf7ts10_lr;
826 tsfInfo[3][10][iClk][3] = result->m_tsf7ts10_pr;
827 tsfInfo[3][10][iClk][4] = result->m_tsf7_cc;
828 tsfInfo[3][11][iClk][0] = result->m_tsf7ts11_id;
829 tsfInfo[3][11][iClk][1] = result->m_tsf7ts11_rt;
830 tsfInfo[3][11][iClk][2] = result->m_tsf7ts11_lr;
831 tsfInfo[3][11][iClk][3] = result->m_tsf7ts11_pr;
832 tsfInfo[3][11][iClk][4] = result->m_tsf7_cc;
833 tsfInfo[3][12][iClk][0] = result->m_tsf7ts12_id;
834 tsfInfo[3][12][iClk][1] = result->m_tsf7ts12_rt;
835 tsfInfo[3][12][iClk][2] = result->m_tsf7ts12_lr;
836 tsfInfo[3][12][iClk][3] = result->m_tsf7ts12_pr;
837 tsfInfo[3][12][iClk][4] = result->m_tsf7_cc;
838 tsfInfo[3][13][iClk][0] = result->m_tsf7ts13_id;
839 tsfInfo[3][13][iClk][1] = result->m_tsf7ts13_rt;
840 tsfInfo[3][13][iClk][2] = result->m_tsf7ts13_lr;
841 tsfInfo[3][13][iClk][3] = result->m_tsf7ts13_pr;
842 tsfInfo[3][13][iClk][4] = result->m_tsf7_cc;
843 tsfInfo[3][14][iClk][0] = result->m_tsf7ts14_id;
844 tsfInfo[3][14][iClk][1] = result->m_tsf7ts14_rt;
845 tsfInfo[3][14][iClk][2] = result->m_tsf7ts14_lr;
846 tsfInfo[3][14][iClk][3] = result->m_tsf7ts14_pr;
847 tsfInfo[3][14][iClk][4] = result->m_tsf7_cc;
855 multi_array<double, 4>& t2DTsfFirmwareInfo)
860 bitset<6> t2d_fnf(
int(result->m_t2d_fnf));
861 bitset<6> t2d_oldfnf(
int(result->m_t3d_2doldtrk));
865 t2DFirmwareInfo[0][iClk][0] = t2d_fnf[5];
866 t2DFirmwareInfo[0][iClk][1] = t2d_oldfnf[5];;
867 t2DFirmwareInfo[0][iClk][2] = result->m_t2d0_charge;
868 t2DFirmwareInfo[0][iClk][3] = result->m_t2d0_rho_s;
869 t2DFirmwareInfo[0][iClk][4] = result->m_t2d0_phi;
871 t2DFirmwareInfo[1][iClk][0] = t2d_fnf[4];
872 t2DFirmwareInfo[1][iClk][1] = t2d_oldfnf[4];;
873 t2DFirmwareInfo[1][iClk][2] = result->m_t2d1_charge;
874 t2DFirmwareInfo[1][iClk][3] = result->m_t2d1_rho_s;
875 t2DFirmwareInfo[1][iClk][4] = result->m_t2d1_phi;
877 t2DFirmwareInfo[2][iClk][0] = t2d_fnf[3];
878 t2DFirmwareInfo[2][iClk][1] = t2d_oldfnf[3];;
879 t2DFirmwareInfo[2][iClk][2] = result->m_t2d2_charge;
880 t2DFirmwareInfo[2][iClk][3] = result->m_t2d2_rho_s;
881 t2DFirmwareInfo[2][iClk][4] = result->m_t2d2_phi;
883 t2DFirmwareInfo[3][iClk][0] = t2d_fnf[2];
884 t2DFirmwareInfo[3][iClk][1] = t2d_oldfnf[2];;
885 t2DFirmwareInfo[3][iClk][2] = result->m_t2d3_charge;
886 t2DFirmwareInfo[3][iClk][3] = result->m_t2d3_rho_s;
887 t2DFirmwareInfo[3][iClk][4] = result->m_t2d3_phi;
889 t2DTsfFirmwareInfo[0][iClk][0][0] = result->m_t2d0ts0_id;
890 t2DTsfFirmwareInfo[0][iClk][0][1] = result->m_t2d0ts0_rt;
891 t2DTsfFirmwareInfo[0][iClk][0][2] = result->m_t2d0ts0_lr;
892 t2DTsfFirmwareInfo[0][iClk][0][3] = result->m_t2d0ts0_pr;
893 t2DTsfFirmwareInfo[0][iClk][1][0] = result->m_t2d0ts2_id;
894 t2DTsfFirmwareInfo[0][iClk][1][1] = result->m_t2d0ts2_rt;
895 t2DTsfFirmwareInfo[0][iClk][1][2] = result->m_t2d0ts2_lr;
896 t2DTsfFirmwareInfo[0][iClk][1][3] = result->m_t2d0ts2_pr;
897 t2DTsfFirmwareInfo[0][iClk][2][0] = result->m_t2d0ts4_id;
898 t2DTsfFirmwareInfo[0][iClk][2][1] = result->m_t2d0ts4_rt;
899 t2DTsfFirmwareInfo[0][iClk][2][2] = result->m_t2d0ts4_lr;
900 t2DTsfFirmwareInfo[0][iClk][2][3] = result->m_t2d0ts4_pr;
901 t2DTsfFirmwareInfo[0][iClk][3][0] = result->m_t2d0ts6_id;
902 t2DTsfFirmwareInfo[0][iClk][3][1] = result->m_t2d0ts6_rt;
903 t2DTsfFirmwareInfo[0][iClk][3][2] = result->m_t2d0ts6_lr;
904 t2DTsfFirmwareInfo[0][iClk][3][3] = result->m_t2d0ts6_pr;
905 t2DTsfFirmwareInfo[0][iClk][4][0] = result->m_t2d0ts8_id;
906 t2DTsfFirmwareInfo[0][iClk][4][1] = result->m_t2d0ts8_rt;
907 t2DTsfFirmwareInfo[0][iClk][4][2] = result->m_t2d0ts8_lr;
908 t2DTsfFirmwareInfo[0][iClk][4][3] = result->m_t2d0ts8_pr;
910 t2DTsfFirmwareInfo[1][iClk][0][0] = result->m_t2d1ts0_id;
911 t2DTsfFirmwareInfo[1][iClk][0][1] = result->m_t2d1ts0_rt;
912 t2DTsfFirmwareInfo[1][iClk][0][2] = result->m_t2d1ts0_lr;
913 t2DTsfFirmwareInfo[1][iClk][0][3] = result->m_t2d1ts0_pr;
914 t2DTsfFirmwareInfo[1][iClk][1][0] = result->m_t2d1ts2_id;
915 t2DTsfFirmwareInfo[1][iClk][1][1] = result->m_t2d1ts2_rt;
916 t2DTsfFirmwareInfo[1][iClk][1][2] = result->m_t2d1ts2_lr;
917 t2DTsfFirmwareInfo[1][iClk][1][3] = result->m_t2d1ts2_pr;
918 t2DTsfFirmwareInfo[1][iClk][2][0] = result->m_t2d1ts4_id;
919 t2DTsfFirmwareInfo[1][iClk][2][1] = result->m_t2d1ts4_rt;
920 t2DTsfFirmwareInfo[1][iClk][2][2] = result->m_t2d1ts4_lr;
921 t2DTsfFirmwareInfo[1][iClk][2][3] = result->m_t2d1ts4_pr;
922 t2DTsfFirmwareInfo[1][iClk][3][0] = result->m_t2d1ts6_id;
923 t2DTsfFirmwareInfo[1][iClk][3][1] = result->m_t2d1ts6_rt;
924 t2DTsfFirmwareInfo[1][iClk][3][2] = result->m_t2d1ts6_lr;
925 t2DTsfFirmwareInfo[1][iClk][3][3] = result->m_t2d1ts6_pr;
926 t2DTsfFirmwareInfo[1][iClk][4][0] = result->m_t2d1ts8_id;
927 t2DTsfFirmwareInfo[1][iClk][4][1] = result->m_t2d1ts8_rt;
928 t2DTsfFirmwareInfo[1][iClk][4][2] = result->m_t2d1ts8_lr;
929 t2DTsfFirmwareInfo[1][iClk][4][3] = result->m_t2d1ts8_pr;
931 t2DTsfFirmwareInfo[2][iClk][0][0] = result->m_t2d2ts0_id;
932 t2DTsfFirmwareInfo[2][iClk][0][1] = result->m_t2d2ts0_rt;
933 t2DTsfFirmwareInfo[2][iClk][0][2] = result->m_t2d2ts0_lr;
934 t2DTsfFirmwareInfo[2][iClk][0][3] = result->m_t2d2ts0_pr;
935 t2DTsfFirmwareInfo[2][iClk][1][0] = result->m_t2d2ts2_id;
936 t2DTsfFirmwareInfo[2][iClk][1][1] = result->m_t2d2ts2_rt;
937 t2DTsfFirmwareInfo[2][iClk][1][2] = result->m_t2d2ts2_lr;
938 t2DTsfFirmwareInfo[2][iClk][1][3] = result->m_t2d2ts2_pr;
939 t2DTsfFirmwareInfo[2][iClk][2][0] = result->m_t2d2ts4_id;
940 t2DTsfFirmwareInfo[2][iClk][2][1] = result->m_t2d2ts4_rt;
941 t2DTsfFirmwareInfo[2][iClk][2][2] = result->m_t2d2ts4_lr;
942 t2DTsfFirmwareInfo[2][iClk][2][3] = result->m_t2d2ts4_pr;
943 t2DTsfFirmwareInfo[2][iClk][3][0] = result->m_t2d2ts6_id;
944 t2DTsfFirmwareInfo[2][iClk][3][1] = result->m_t2d2ts6_rt;
945 t2DTsfFirmwareInfo[2][iClk][3][2] = result->m_t2d2ts6_lr;
946 t2DTsfFirmwareInfo[2][iClk][3][3] = result->m_t2d2ts6_pr;
947 t2DTsfFirmwareInfo[2][iClk][4][0] = result->m_t2d2ts8_id;
948 t2DTsfFirmwareInfo[2][iClk][4][1] = result->m_t2d2ts8_rt;
949 t2DTsfFirmwareInfo[2][iClk][4][2] = result->m_t2d2ts8_lr;
950 t2DTsfFirmwareInfo[2][iClk][4][3] = result->m_t2d2ts8_pr;
952 t2DTsfFirmwareInfo[3][iClk][0][0] = result->m_t2d3ts0_id;
953 t2DTsfFirmwareInfo[3][iClk][0][1] = result->m_t2d3ts0_rt;
954 t2DTsfFirmwareInfo[3][iClk][0][2] = result->m_t2d3ts0_lr;
955 t2DTsfFirmwareInfo[3][iClk][0][3] = result->m_t2d3ts0_pr;
956 t2DTsfFirmwareInfo[3][iClk][1][0] = result->m_t2d3ts2_id;
957 t2DTsfFirmwareInfo[3][iClk][1][1] = result->m_t2d3ts2_rt;
958 t2DTsfFirmwareInfo[3][iClk][1][2] = result->m_t2d3ts2_lr;
959 t2DTsfFirmwareInfo[3][iClk][1][3] = result->m_t2d3ts2_pr;
960 t2DTsfFirmwareInfo[3][iClk][2][0] = result->m_t2d3ts4_id;
961 t2DTsfFirmwareInfo[3][iClk][2][1] = result->m_t2d3ts4_rt;
962 t2DTsfFirmwareInfo[3][iClk][2][2] = result->m_t2d3ts4_lr;
963 t2DTsfFirmwareInfo[3][iClk][2][3] = result->m_t2d3ts4_pr;
964 t2DTsfFirmwareInfo[3][iClk][3][0] = result->m_t2d3ts6_id;
965 t2DTsfFirmwareInfo[3][iClk][3][1] = result->m_t2d3ts6_rt;
966 t2DTsfFirmwareInfo[3][iClk][3][2] = result->m_t2d3ts6_lr;
967 t2DTsfFirmwareInfo[3][iClk][3][3] = result->m_t2d3ts6_pr;
968 t2DTsfFirmwareInfo[3][iClk][4][0] = result->m_t2d3ts8_id;
969 t2DTsfFirmwareInfo[3][iClk][4][1] = result->m_t2d3ts8_rt;
970 t2DTsfFirmwareInfo[3][iClk][4][2] = result->m_t2d3ts8_lr;
971 t2DTsfFirmwareInfo[3][iClk][4][3] = result->m_t2d3ts8_pr;
986 bitset<6> t3d_oldfnf(
int(result->m_t3d_2doldtrk));
992 t3DFirmwareInfo[0][iClk][0] = t3d_fnf[5];
993 t3DFirmwareInfo[0][iClk][1] = t3d_oldfnf[5];
994 t3DFirmwareInfo[0][iClk][2] = tsf_fnf[0];
997 t3DFirmwareInfo[0][iClk][5] = result->m_t2d0_charge;
998 t3DFirmwareInfo[0][iClk][6] = result->m_t2d0_rho_s;
999 t3DFirmwareInfo[0][iClk][7] = result->m_t2d0_phi;
1004 t3DFirmwareInfo[1][iClk][0] = t3d_fnf[4];
1005 t3DFirmwareInfo[1][iClk][1] = t3d_oldfnf[4];
1006 t3DFirmwareInfo[1][iClk][2] = tsf_fnf[1];
1009 t3DFirmwareInfo[1][iClk][5] = result->m_t2d1_charge;
1010 t3DFirmwareInfo[1][iClk][6] = result->m_t2d1_rho_s;
1011 t3DFirmwareInfo[1][iClk][7] = result->m_t2d1_phi;
1016 t3DFirmwareInfo[2][iClk][0] = t3d_fnf[3];
1017 t3DFirmwareInfo[2][iClk][1] = t3d_oldfnf[3];
1018 t3DFirmwareInfo[2][iClk][2] = tsf_fnf[2];
1021 t3DFirmwareInfo[2][iClk][5] = result->m_t2d2_charge;
1022 t3DFirmwareInfo[2][iClk][6] = result->m_t2d2_rho_s;
1023 t3DFirmwareInfo[2][iClk][7] = result->m_t2d2_phi;
1028 t3DFirmwareInfo[3][iClk][0] = t3d_fnf[2];
1029 t3DFirmwareInfo[3][iClk][1] = t3d_oldfnf[2];
1030 t3DFirmwareInfo[3][iClk][2] = tsf_fnf[3];
1033 t3DFirmwareInfo[3][iClk][5] = result->m_t2d3_charge;
1034 t3DFirmwareInfo[3][iClk][6] = result->m_t2d3_rho_s;
1035 t3DFirmwareInfo[3][iClk][7] = result->m_t2d3_phi;
1054 if (bitset<6> (result->m_t2d_fnf)[5] == 0)
continue;
1059 double radius = resultDebug->
m_t3dtrk0_rho * 2500 / (pow(2, 11) - 0.5);
1064 vector<vector<int> > rawStTSs(4, vector<int> (3));
1079 map<string, vector<double> > stGeometry;
1080 vector<vector<double> > stXts;
1084 double z0 = 0, cot = 0, chi2 = 0;
1085 Fitter3DUtility::fitter3D(stGeometry, stXts, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, z0, cot, chi2);
1089 bitset<6> t2d_oldfnf(
int(result->m_t3d_2doldtrk));
1093 t3DFirmwareInfo[0][iClk][0] = t2d_fnf[5];
1094 t3DFirmwareInfo[0][iClk][1] = t2d_oldfnf[5];
1095 t3DFirmwareInfo[0][iClk][2] = tsf_fnf[3];
1099 t3DFirmwareInfo[0][iClk][5] = charge;
1100 t3DFirmwareInfo[0][iClk][6] = radius;
1101 t3DFirmwareInfo[0][iClk][7] = phi_c;
1102 t3DFirmwareInfo[0][iClk][8] = z0;
1103 t3DFirmwareInfo[0][iClk][9] = cot;
1104 t3DFirmwareInfo[0][iClk][10] = chi2;
1117 if (bitset<6> (result->m_t2d_fnf)[5] == 0)
continue;
1122 double radius = resultDebug->
m_t3dtrk0_rho * 2500 / (pow(2, 11) - 0.5);
1127 vector<vector<int> > rawStTSs(4, vector<int> (3));
1142 map<string, vector<double> > stGeometry;
1143 vector<vector<double> > stXts;
1148 map<string, vector<double> > mConstV;
1149 map<string, double> mConstD;
1159 bitset<6> t2d_oldfnf(
int(result->m_t3d_2doldtrk));
1163 t3DFirmwareInfo[0][iClk][0] = t2d_fnf[5];
1164 t3DFirmwareInfo[0][iClk][1] = t2d_oldfnf[5];
1165 t3DFirmwareInfo[0][iClk][2] = tsf_fnf[3];
1169 t3DFirmwareInfo[0][iClk][5] = charge;
1170 t3DFirmwareInfo[0][iClk][6] = radius;
1171 t3DFirmwareInfo[0][iClk][7] = phi_c;
1172 t3DFirmwareInfo[0][iClk][8] = z0;
1173 t3DFirmwareInfo[0][iClk][9] = cot;
1174 t3DFirmwareInfo[0][iClk][10] = chi2;
1307 if (result->m_t2d_fnf && iClk < 48 - 17 - 1 && bitset<6> (result->m_t2d_fnf)[5]) {
1314 double radius = resultDebug->
m_t3dtrk0_rho * 2500 / (pow(2, 11) - 0.5);
1319 vector<vector<int> > rawStTSs(4, vector<int> (3));
1334 map<string, vector<double> > stGeometry;
1335 vector<vector<double> > stXts;
1369 Fitter3DUtility::fitter3D(stGeometry, stXts, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, z0, cot, chi2);
1372 map<string, vector<double> > mConstV;
1373 map<string, double> mConstD;
1421 bitset<6> t2d_oldfnf(
int(result->m_t3d_2doldtrk));
1422 cout <<
"iClk:" << iClk << endl;
1423 cout <<
" [2D] fnf:" << result->m_t2d_fnf <<
" " << bitset<6> (result->m_t2d_fnf) <<
" oldfnf: " << t2d_oldfnf << endl;
1426 cout <<
" [debug] MSB" << endl;
1437 cout <<
" [3D] fnf:" << result3D->
m_t3d_2dfnf <<
" " << bitset<6> (result3D->
m_t3d_2dfnf) <<
" tsValid: " <<
1457 cout <<
" [Store information]" << endl;
1458 cout <<
" charge: " << charge <<
" radius(cm): " << radius <<
" phi_c(rad): " << phi_c << endl;
1459 cout <<
" eventTime: " << eventTime <<
" valid: " << eventTimeValid << endl;
1460 cout <<
" rawStTSs[0] id:" << rawStTSs[0][0] <<
" lr: " << rawStTSs[0][1] <<
" rt: " << rawStTSs[0][2] << endl;
1461 cout <<
" rawStTSs[1] id:" << rawStTSs[1][0] <<
" lr: " << rawStTSs[1][1] <<
" rt: " << rawStTSs[1][2] << endl;
1462 cout <<
" rawStTSs[2] id:" << rawStTSs[2][0] <<
" lr: " << rawStTSs[2][1] <<
" rt: " << rawStTSs[2][2] << endl;
1463 cout <<
" rawStTSs[3] id:" << rawStTSs[3][0] <<
" lr: " << rawStTSs[3][1] <<
" rt: " << rawStTSs[3][2] << endl;
1465 cout <<
" [Calculate fast]" << endl;
1466 cout <<
" [z0] " << z0 <<
" [cot] " << cot <<
" [chi2] " << chi2 << endl;
1468 cout <<
" [Calculate firm]" << endl;
1488 bitset<6> t2d_fnf(
int(result->m_t3d_2dfnf));
1489 bitset<4> tsf_fnf(
int(result->m_t3d_validTS));
1490 bitset<6> t2d_oldfnf(
int(result->m_t3d_2doldtrk));
1491 cout <<
"iClk:" << iClk << endl;
1492 cout <<
" [2D] fnf:" << result->m_t2d_fnf <<
" " << bitset<6> (result->m_t2d_fnf) <<
" oldfnf: " << t2d_oldfnf << endl;
1493 cout <<
" [0] rho: " << result->m_t2d0_rho_s <<
" " <<
toSigned(result->m_t2d0_rho_s,
1494 7) <<
" " << int(0.3 * 34 / 30 / 1.5e-4 / abs(
toSigned(result->m_t2d0_rho_s, 7)) * (pow(2,
1495 11) - 0.5) / 2500) <<
" phi0: " << result->m_t2d0_phi << endl;
1496 cout <<
" [1] rho: " << result->m_t2d1_rho_s <<
" " <<
toSigned(result->m_t2d1_rho_s,
1497 7) <<
" " << int(0.3 * 34 / 30 / 1.5e-4 / abs(
toSigned(result->m_t2d1_rho_s, 7)) * (pow(2,
1498 11) - 0.5) / 2500) <<
" phi0: " << result->m_t2d1_phi << endl;
1499 cout <<
" [2] rho: " << result->m_t2d2_rho_s <<
" " <<
toSigned(result->m_t2d2_rho_s,
1500 7) <<
" " << int(0.3 * 34 / 30 / 1.5e-4 / abs(
toSigned(result->m_t2d2_rho_s, 7)) * (pow(2,
1501 11) - 0.5) / 2500) <<
" phi0: " << result->m_t2d2_phi << endl;
1502 cout <<
" [3] rho: " << result->m_t2d3_rho_s <<
" " <<
toSigned(result->m_t2d3_rho_s,
1503 7) <<
" " << int(0.3 * 34 / 30 / 1.5e-4 / abs(
toSigned(result->m_t2d3_rho_s, 7)) * (pow(2,
1504 11) - 0.5) / 2500) <<
" phi0: " << result->m_t2d3_phi << endl;
1505 cout <<
" [3D] fnf:" << result->m_t3d_2dfnf <<
" " << t2d_fnf <<
" " << t2d_fnf[5] <<
" tsValid: " << result->m_t3d_validTS <<
" "
1506 << tsf_fnf << endl;;
1507 cout <<
" [0] z0: " << result->m_t3dtrk0_z0_s <<
" cot: " << result->m_t3dtrk0_cot_s <<
" chi2: " << result->m_t3dtrk0_zchisq
1509 cout <<
" [1] z0: " << result->m_t3dtrk1_z0_s <<
" cot: " << result->m_t3dtrk1_cot_s <<
" chi2: " << result->m_t3dtrk1_zchisq
1511 cout <<
" [2] z0: " << result->m_t3dtrk2_z0_s <<
" cot: " << result->m_t3dtrk2_cot_s <<
" chi2: " << result->m_t3dtrk2_zchisq
1513 cout <<
" [3] z0: " << result->m_t3dtrk3_z0_s <<
" cot: " << result->m_t3dtrk3_cot_s <<
" chi2: " << result->m_t3dtrk3_zchisq
1515 cout <<
" [debug] MSB" << endl;
1516 cout <<
" evtTime: " << result->m_t3dtrk0_evtTime_delay <<
" evtTimeValid: " << result->m_t3dtrk0_evtTimeValid_delay <<
1518 cout <<
" charge: " << result->m_t3dtrk0_charge <<
" rho: " << result->m_t3dtrk0_rho <<
" phi0: " << result->m_t3dtrk0_phi0
1520 cout <<
" ts0 id: " << result->m_t3dtrk0ts0_id <<
" lr: " << result->m_t3dtrk0ts0_lr <<
" rt: " << result->m_t3dtrk0ts0_rt
1522 cout <<
" ts1 id: " << result->m_t3dtrk0ts1_id <<
" lr: " << result->m_t3dtrk0ts1_lr <<
" rt: " << result->m_t3dtrk0ts1_rt
1524 cout <<
" ts2 id: " << result->m_t3dtrk0ts2_id <<
" lr: " << result->m_t3dtrk0ts2_lr <<
" rt: " << result->m_t3dtrk0ts2_rt
1526 cout <<
" ts3 id: " << result->m_t3dtrk0ts3_id <<
" lr: " << result->m_t3dtrk0ts3_lr <<
" rt: " << result->m_t3dtrk0ts3_rt
1528 cout <<
" [debug] LSB" << endl;
1529 cout <<
" evtTime: " << result->m_t3dtrk1_evtTime_delay <<
" evtTimeValid: " << result->m_t3dtrk1_evtTimeValid_delay <<
1531 cout <<
" charge: " << result->m_t3dtrk1_charge <<
" rho: " << result->m_t3dtrk1_rho <<
" phi0: " << result->m_t3dtrk1_phi0
1533 cout <<
" ts0 id: " << result->m_t3dtrk1ts0_id <<
" lr: " << result->m_t3dtrk1ts0_lr <<
" rt: " << result->m_t3dtrk1ts0_rt
1535 cout <<
" ts1 id: " << result->m_t3dtrk1ts1_id <<
" lr: " << result->m_t3dtrk1ts1_lr <<
" rt: " << result->m_t3dtrk1ts1_rt
1537 cout <<
" ts2 id: " << result->m_t3dtrk1ts2_id <<
" lr: " << result->m_t3dtrk1ts2_lr <<
" rt: " << result->m_t3dtrk1ts2_rt
1539 cout <<
" ts3 id: " << result->m_t3dtrk1ts3_id <<
" lr: " << result->m_t3dtrk1ts3_lr <<
" rt: " << result->m_t3dtrk1ts3_rt
1549 multi_array<double, 2>& t3DInfo)
1551 for (
unsigned iTrack = 0; iTrack < t3DFirmwareInfo.shape()[0]; iTrack++) {
1552 for (
unsigned iClk = 0; iClk < t3DFirmwareInfo.shape()[1]; iClk++) {
1555 if (t3DFirmwareInfo[iTrack][iClk][0] == 0)
continue;
1567 double track3D_ref[7] = {t3DFirmwareInfo[iTrack][iClk][4], t3DFirmwareInfo[iTrack][iClk][5], t3DFirmwareInfo[iTrack][iClk][6], t3DFirmwareInfo[iTrack][iClk][7], t3DFirmwareInfo[iTrack][iClk][8], t3DFirmwareInfo[iTrack][iClk][9], t3DFirmwareInfo[iTrack][iClk][10]};
1569 multi_array_ref<double, 1> track3D((
double*)track3D_ref, extents[7]);
1571 t3DInfo.resize(extents[t3DInfo.shape()[0] + 1][7]);
1572 t3DInfo[t3DInfo.shape()[0] - 1] = track3D;
1581 for (
unsigned iTrack = 0; iTrack < t3DInfo.shape()[0]; ++iTrack) {
1582 double charge = 0, phi0_i = 0, omega = 0, chi2D = 0, z0 = 0, cot = 0, zchi2 = 0;
1585 charge = t3DInfo[iTrack][1] == 2 ? -1 : 1;
1586 phi0_c =
t2DPhiTot3DPhi(t3DInfo[iTrack][3], t3DInfo[iTrack][2]) / (pow(2, 12) - 0.5) * M_PI;
1588 phi0_i = (45 + 90. / 80 * (1 + t3DInfo[iTrack][3])) / 180 * M_PI;
1590 omega =
toSigned(t3DInfo[iTrack][2], 7) / 33.0 * 3.2;
1591 z0 =
toSigned(t3DInfo[iTrack][4], 11) * 0.0382;
1592 cot =
toSigned(t3DInfo[iTrack][5], 11) * 0.00195;
1593 zchi2 = t3DInfo[iTrack][6];
1595 charge = t3DInfo[iTrack][1] == 1 ? 1 : -1;
1596 phi0_c =
t2DPhiTot3DPhi((t3DInfo[iTrack][3] - 34 / 90.*80 - 1), t3DInfo[iTrack][2]) / (pow(2, 12) - 0.5) * M_PI;
1597 phi0_i = t3DInfo[iTrack][3];
1598 omega = t3DInfo[iTrack][2];
1599 z0 = t3DInfo[iTrack][4];
1600 cot = t3DInfo[iTrack][5];
1601 zchi2 = t3DInfo[iTrack][6];
1606 phi0_c = phi0_c + (M_PI / 2.0) * 0;
1607 phi0_i = phi0_i + (M_PI / 2.0) * 0;
1609 phi0_c = phi0_c + (M_PI / 2.0) * 1;
1610 phi0_i = phi0_i + (M_PI / 2.0) * 1;
1612 phi0_c = phi0_c + (M_PI / 2.0) * 2;
1613 phi0_i = phi0_i + (M_PI / 2.0) * 2;
1615 phi0_c = phi0_c + (M_PI / 2.0) * 3;
1616 phi0_i = phi0_i + (M_PI / 2.0) * 3;
1619 while (phi0_c > M_PI) {
1622 while (phi0_i < -M_PI) {
1625 while (phi0_i > M_PI) {
1628 while (phi0_i < -M_PI) {
1633 if (
m_isVerbose) cout <<
"[3D] iTrack:" << iTrack <<
" charge: " << charge <<
" phi0_i:" << phi0_i <<
" " << phi0_i * 180 / M_PI <<
1634 " omega:" << omega <<
" pt:" << charge / omega * 0.3 * 1.5 * 0.01 <<
" z0:" << z0 <<
" cot:" << cot <<
" zchi2:" << zchi2 << endl;
void addBinnedEventT0(int eventT0, Const::EDetector detector)
Store a binned event t0 for the given detector replacing any other hypothesis for this detector.
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Track created by the CDC trigger.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
bool isValid() const
Check whether the object was created.
A class to hold common data for JSignals.
std::string m_EventTimeName
name of the event time StoreObjPtr
unsigned m_fit3DWithTSIM
Mode for fitting with TSIM.
StoreArray< CDCTriggerTrack > m_tracks2D
list of 2D input tracks
void debug3DFirmware()
Used for debugging 3D firmware.
void addTSDatastore(boost::multi_array< double, 3 > &tsfInfo, int isSt=1)
adds tsfInfo to TS data store
bool m_add2DFinderToDatastore
Flag for adding 2D finder to datastore.
void store3DFirmSimData(boost::multi_array< double, 3 > &t3DFirmwareInfo)
uses firm sim with debug
Belle2::TRGCDCJSignalData * m_commonData
TRGCDCJSignalData for VHDL generation (jbkim's class)
int toSigned(int value, int nBits)
converts to signed value
void store3DFastSimData(boost::multi_array< double, 3 > &t3DFirmwareInfo)
uses fast sim with debug
virtual void initialize() override
Initilizes TRGCDCT3DConverterModule.
virtual void event() override
Called event by event.
std::string m_outputCollectionName
Name of the StoreArray containing the resulting 3D tracks.
StoreArray< CDCTriggerSegmentHit > m_hits
list of track segment hits
void filterTSData(boost::multi_array< double, 4 > &tsfFirmwareInfo, boost::multi_array< double, 3 > &tsfInfo)
filters tsfFirmwareInfo to tsfInfo
virtual void endRun() override
Called when run ended.
std::map< std::string, TRGCDCJLUT * > m_mLutStorage
TRGCDCJLUT for VHDL generation (jbkim's class)
virtual void terminate() override
Called when processing ended.
void add3DDatastore(boost::multi_array< double, 2 > &t3DInfo, bool doConvert=1)
adds t3DInfo to track data store
std::map< std::string, TRGCDCJSignal > m_mSignalStorage
TRGCDCJSignal for VHDL generation (jbkim's class)
void store2DFirmwareData(boost::multi_array< double, 3 > &t2DFirmwareInfo, boost::multi_array< double, 4 > &axTsfFirmwareInfo)
converts firmwareResults of 2D to a vector
std::string m_inputCollectionName
Name of the StoreArray containing the input tracks from the 2D fitter.
unsigned m_isVerbose
Switch printing detail information.
void store3DFirmwareData(boost::multi_array< double, 3 > &t3DFirmwareInfo)
converts firmwareResults of 3D to a vector
virtual void beginRun() override
Called when new run started.
bool m_add3DToDatastore
Flag for adding 3D to datastore.
virtual ~TRGCDCT3DConverterModule()
Destructor.
void storeTSFirmwareData(boost::multi_array< double, 4 > &tsfInfo)
converts firmwareResults of TS to a vector
bool m_addTSToDatastore
Flag for adding TS to datastore.
TRGCDCT3DConverterModule()
Constructor.
bool m_addEventTimeToDatastore
Flag for adding event time to datastore.
StoreArray< CDCTriggerTrack > m_tracks3D
list of 3D output tracks
StoreObjPtr< BinnedEventT0 > m_eventTime
StoreObjPtr containing the event time.
void filter3DData(boost::multi_array< double, 3 > &t3DFirmwareInfo, boost::multi_array< double, 2 > &t3DInfo)
filters t3DFirmwareInfo to t3DInfo
std::string version() const
returns version of TRGCDCT3DConverterModule.
void filter2DData(boost::multi_array< double, 3 > &t2DFirmwareInfo, boost::multi_array< double, 4 > &t2DTsfFirmwareInfo, boost::multi_array< double, 2 > &t2DInfo, boost::multi_array< double, 3 > &t2DTsfInfo)
** filters t2DFirmwareInfo to t2DInfo*/
int toTSID(int iSL, int iWire)
converts sl, iWire to continuous TS ID [0,2335]
std::string m_hitCollectionName
Name of the StoreArray containing the input track segment hits.
std::string m_firmwareResultCollectionName
Name of the StoreArray containing the input firmware results.
void add2DDatastore(boost::multi_array< double, 2 > &t2DInfo, boost::multi_array< double, 3 > &t2DTsfInfo)
adds t2DInfo to track data store
int t2DPhiTot3DPhi(int phi, int rho)
converts to 2D rho to 3D rho value, obselete
StoreArray< TRGCDCT3DUnpackerStore > m_firmwareResults
list of firmware results
int m_t3dtrk3_cot_s
m_t3dtrk3_cot_s leaf
int m_t3dtrk3_zchisq
m_t3dtrk3_zchisq leaf
int m_t3dtrk0_evtTimeValid_delay
m_t3dtrk0_evtTimeValid_delay leaf
int m_t3dtrk0ts2_id
m_t3dtrk0ts2_id leaf
int m_t3dtrk0_rho
m_t3dtrk0_rho leaf
int m_t3dtrk0ts0_rt
m_t3dtrk0ts0_rt leaf
int m_t3dtrk0ts3_lr
m_t3dtrk0ts3_lr leaf
int m_t3dtrk0ts1_id
m_t3dtrk0ts1_id leaf
int m_t3dtrk2_zchisq
m_t3dtrk2_zchisq leaf
int m_t3dtrk3_z0_s
m_t3dtrk3_z0_s leaf
int m_t3dtrk2_cot_s
m_t3dtrk2_cot_s leaf
int m_t3dtrk0ts3_id
m_t3dtrk0ts3_id leaf
int m_t3d_validTS
m_t3d_validTS leaf
int m_t3dtrk0ts0_lr
m_t3dtrk0ts0_lr leaf
int m_t3dtrk0_zchisq
m_t3dtrk0_zchisq leaf
int m_t3dtrk1_cot_s
m_t3dtrk1_cot_s leaf
int m_t3d_2dfnf
m_t3d_2dfnf leaf
int m_t3dtrk0ts0_id
m_t3dtrk0ts0_id leaf
int m_t3dtrk0_cot_s
m_t3dtrk0_cot_s leaf
int m_t3dtrk0_evtTime_delay
m_t3dtrk0_evtTime_delay leaf
int m_t3dtrk0_z0_s
m_t3dtrk0_z0_s leaf
int m_t3dtrk0ts2_lr
m_t3dtrk0ts2_lr leaf
int m_t3dtrk0ts1_rt
m_t3dtrk0ts1_rt leaf
int m_t3dtrk0_phi0
m_t3dtrk0_phi0 leaf
int m_t3dtrk0ts3_rt
m_t3dtrk0ts3_rt leaf
int m_t3dtrk2_z0_s
m_t3dtrk2_z0_s leaf
int m_t3dtrk0_charge
m_t3dtrk0_charge leaf
int m_t3dtrk1_z0_s
m_t3dtrk1_z0_s leaf
int m_t3dtrk0ts1_lr
m_t3dtrk0ts1_lr leaf
int m_t3dtrk0ts2_rt
m_t3dtrk0ts2_rt leaf
int m_t3dtrk1_zchisq
m_t3dtrk1_zchisq leaf
static void fitter3DFirm(std::map< std::string, double > &mConstD, const std::map< std::string, std::vector< double > > &mConstV, int eventTimeValid, int eventTime, std::vector< std::vector< int > > const &rawStTSs, int charge, double radius, double phi_c, Belle2::TRGCDCJSignalData *commonData, std::map< std::string, Belle2::TRGCDCJSignal > &mSignalStorage, std::map< std::string, Belle2::TRGCDCJLUT * > &mLutStorage)
Combines several functions for fitter3D firmware.
static void fitter3D(std::map< std::string, std::vector< double > > &stGeometry, std::vector< std::vector< double > > const &stXts, int eventTimeValid, int eventTime, std::vector< std::vector< int > > const &rawStTSs, int charge, double radius, double phi_c, double &z0, double &cot, double &chi2)
Combines several functions for fitter3D.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
static void getStereoGeometry(std::map< std::string, std::vector< double > > &stGeometry)
Get stereo geometry.
static void getStereoXt(std::vector< double > const &stPriorityLayer, std::vector< std::vector< double > > &stXts, bool isSimple=0)
Get stereo Xt.
static void getConstants(std::map< std::string, double > &mConstD, std::map< std::string, std::vector< double > > &mConstV, bool isXtSimple=0)
Get constants for firmwareFit.
Abstract base class for different kinds of events.