9#include "trg/cdc/Fitter3DUtility.h"
10#include "trg/cdc/Hough3DUtility.h"
11#include "trg/cdc/JSignal.h"
12#include "trg/cdc/JLUT.h"
13#include "trg/cdc/JSignalData.h"
14#include "trg/cdc/FpgaUtility.h"
25 m_mode(0), m_nWires(), m_rr(), m_ztostraw(), m_anglest(),
26 m_cotStart(0), m_cotEnd(0), m_z0Start(0), m_z0End(0),
27 m_nCotSteps(0), m_nZ0Steps(0), m_cotStepSize(0), m_z0StepSize(0),
28 m_houghMeshLayerDiff(0), m_houghMeshLayer(0), m_houghMesh(0), m_houghMeshDiff(0),
29 m_hitMap(0), m_driftMap(0), m_geoCandidatesIndex(0), m_geoCandidatesPhi(0),
30 m_geoCandidatesDiffStWires(0), m_stAxPhi(), m_bestCot(0), m_bestZ0(0),
31 m_houghMax(0), m_minDiffHough(0), m_foundZ(), m_foundPhiSt(), m_bestTSIndex(),
32 m_bestTS(), m_inputFileName(
"GeoFinder.input"), m_findRhoMax(0), m_findRhoMin(0),
33 m_findRhoIntMax(0), m_findRhoIntMin(0),
34 m_findPhi0Max(0), m_findPhi0Min(0), m_findPhi0IntMax(0), m_findPhi0IntMin(0),
35 m_findArcCosMax(0), m_findArcCosMin(0), m_findArcCosIntMax(0), m_findArcCosIntMin(0),
36 m_findPhiZMax(0), m_findPhiZMin(0), m_findPhiZIntMax(0), m_findPhiZIntMin(0),
37 m_rhoMax(0), m_rhoMin(0), m_rhoBit(0), m_phi0Max(0), m_phi0Min(0), m_phi0Bit(0),
38 m_stAxWireFactor(0), m_LUT(0),
39 m_arcCosLUT(0), m_wireConvertLUT(0),
40 m_commonData(0), m_outputVhdlDirname(
"./VHDL/finder3D")
46 for (
int iSt = 0; iSt < 4; iSt++) {
48 for (
int iTS = 0; iTS <
m_nWires[iSt] / 2; iTS++) {
89 for (
int iLayer = 0; iLayer < 4; iLayer++) {
93 for (
int i = 0; i < 4; i++) {
94 m_rr[i] = geometryVariables[i];
97 m_nWires[i] = (int)geometryVariables[i + 12];
112 cout <<
"[Error] 3DFinder mode is not correct. Current mode is " <<
m_mode <<
"." << endl;
135 const vector<vector<int> >& stTSDrift)
139 for (
int iLayer = 0; iLayer < 4; iLayer++) {
145 int charge = (int)trackVariables[0];
146 double rho = trackVariables[1];
147 double fitPhi0 = trackVariables[2];
150 vector<double > tsArcS;
151 vector<vector<double> > tsZ;
152 for (
unsigned i = 0; i < 4; i++) {
154 tsZ.push_back(vector<double>());
155 for (
unsigned j = 0; j < stTSs[i].size(); j++) {
186 m_z0End = (int)initVariables[3];
213 if (
false) cout << initVariables.size() << endl;
220 for (
int iLayer = 0; iLayer < 4; iLayer++)
m_geoCandidatesPhi->push_back(vector<double> ());
228 if (
false) cout << initVariables.size() << endl;
232 for (
int i = 0; i < 4; i++) {
234 for (
int j = 0; j <
m_nWires[i] / 2; j++) {
240 for (
int iSt = 0; iSt < 4; iSt++) {
242 for (
int iTS = 0; iTS <
m_nWires[iSt] / 2; iTS++) {
252 for (
int iLayer = 0; iLayer < 4; iLayer++)
m_geoCandidatesPhi->push_back(vector<double> ());
303 for (
int i = 0; i < 4; i++) {
307 for (
int iSt = 0; iSt < 4; iSt++) {
329 const vector<double>& tsArcS,
330 const vector<vector<double> >& tsZ)
333 int charge = (int)trackVariables[0];
334 double rho = trackVariables[1];
335 double fitPhi0 = trackVariables[2];
340 for (
int k = 0; k < 4; k++) {
350 double tempZ0Start, tempZ0End;
351 double tempZ01, tempZ02;
353 double actualCot, actualZ0;
358 for (
int cotStep = 0; cotStep <
m_nCotSteps; cotStep++) {
365 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
366 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
368 tempZ01 = -tsArcS[iLayer] * tempCotStart + tsZ[iLayer][iTS];
369 tempZ02 = -tsArcS[iLayer] * tempCotEnd + tsZ[iLayer][iTS];
372 if (tempZ01 < tempZ02) {
373 tempZ0Start = tempZ01;
376 tempZ0Start = tempZ02;
383 if (tempZ0Start > 0) {
403 for (
int z0Step =
int(tempZ0Start); z0Step <= int(tempZ0End); z0Step++) {
407 cout <<
"cutoff because z0step is bigger or smaller than z0 limit ";
414 }
else { tempHoughZ0 = z0Step; }
424 m_minDiffHough = abs(actualCot * tsArcS[iLayer] + actualZ0 - tsZ[iLayer][iTS]);
435 for (
int houghCot = 0; houghCot <
m_nCotSteps; houghCot++) {
436 for (
int houghZ0 = 0; houghZ0 <
m_nZ0Steps; houghZ0++) {
447 for (
int layer = 0; layer < 4; layer++) {
458 for (
int houghCot = 0; houghCot <
m_nCotSteps; houghCot++) {
459 for (
int houghZ0 = 0; houghZ0 <
m_nZ0Steps; houghZ0++) {
463 }
else { tempHoughZ0 = houghZ0;}
498 for (
int i = 0; i < 4; i++) {
508 double minDiff[4] = {999, 999, 999, 999};
509 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
510 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
511 if (minDiff[iLayer] > abs(
m_foundPhiSt[iLayer] - stTSs[iLayer][iTS])) {
512 minDiff[iLayer] = abs(
m_foundPhiSt[iLayer] - stTSs[iLayer][iTS]);
513 m_bestTS[iLayer] = stTSs[iLayer][iTS];
523 const std::vector<std::vector<int> >& stTSDrift)
527 for (
int iLayer = 0; iLayer < 4; iLayer++) {
528 (*m_geoCandidatesIndex)[iLayer].clear();
529 (*m_geoCandidatesPhi)[iLayer].clear();
530 (*m_geoCandidatesDiffStWires)[iLayer].clear();
533 int charge = (int)trackVariables[0];
534 double rho = trackVariables[1];
535 double fitPhi0 = trackVariables[2];
539 for (
int iLayer = 0; iLayer < 4; iLayer++) {
543 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
546 int t_priorityPosition = (stTSDrift[iLayer][iTS] & 3);
550 if (t_priorityPosition != 3)
continue;
552 tsDiffSt =
m_stAxPhi[iLayer] - stTSs[iLayer][iTS];
553 if (tsDiffSt > M_PI) tsDiffSt -= 2 * M_PI;
554 if (tsDiffSt < -M_PI) tsDiffSt += 2 * M_PI;
555 tsDiffSt = tsDiffSt / 2 / M_PI *
m_nWires[iLayer] / 2;
558 if (iLayer % 2 == 0) {
559 if (tsDiffSt > 0 && tsDiffSt <= 10) {
560 (*m_geoCandidatesIndex)[iLayer].push_back(iTS);
561 (*m_geoCandidatesPhi)[iLayer].push_back(stTSs[iLayer][iTS]);
562 (*m_geoCandidatesDiffStWires)[iLayer].push_back(tsDiffSt);
565 if (tsDiffSt < 0 && tsDiffSt >= -10) {
566 (*m_geoCandidatesIndex)[iLayer].push_back(iTS);
567 (*m_geoCandidatesPhi)[iLayer].push_back(stTSs[iLayer][iTS]);
568 (*m_geoCandidatesDiffStWires)[iLayer].push_back(tsDiffSt);
589 const double meanWireDiff[4] = { 3.68186, 3.3542, 3.9099, 4.48263 };
590 for (
int iLayer = 0; iLayer < 4; iLayer++) {
596 double bestDiff = 999;
598 tsDiffSt =
m_stAxPhi[iLayer] - stTSs[iLayer][(*m_geoCandidatesIndex)[iLayer][iTS]];
599 if (tsDiffSt > M_PI) tsDiffSt -= 2 * M_PI;
600 if (tsDiffSt < -M_PI) tsDiffSt += 2 * M_PI;
601 tsDiffSt = tsDiffSt / 2 / M_PI *
m_nWires[iLayer] / 2;
604 if (abs(abs(tsDiffSt) - meanWireDiff[iLayer]) < bestDiff) {
606 bestDiff = abs(abs(tsDiffSt) - meanWireDiff[iLayer]);
607 m_bestTS[iLayer] = stTSs[iLayer][(*m_geoCandidatesIndex)[iLayer][iTS]];
608 m_bestTSIndex[iLayer] = (*m_geoCandidatesIndex)[iLayer][iTS];
624 const vector<vector<int> >& stTSDrift)
627 int m_verboseFlag =
m_mBool[
"fVerbose"];
629 if (m_verboseFlag) cout <<
"####geoFinder start####" << endl;
632 for (
int iLayer = 0; iLayer < 4; iLayer++) {
633 (*m_geoCandidatesPhi)[iLayer].clear();
634 (*m_geoCandidatesIndex)[iLayer].clear();
635 (*m_geoCandidatesDiffStWires)[iLayer].clear();
638 for (
int iLayer = 0; iLayer < 4; iLayer++) {
639 for (
int iTS = 0; iTS <
m_nWires[iLayer] / 2; iTS++) {
644 for (
int iSt = 0; iSt < 4; iSt++) {
645 for (
int iTS = 0; iTS <
m_nWires[iSt] / 2; iTS++) {
651 int charge = (int)trackVariables[0];
652 double rho = trackVariables[1];
653 double fitPhi0 = trackVariables[2];
658 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
660 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
661 iHitTS = int(stTSs[iLayer][iTS] *
m_nWires[iLayer] / 2 / 2 / M_PI + 0.5);
662 driftInfo = stTSDrift[iLayer][iTS];
663 if (m_verboseFlag) cout <<
"[" << iLayer <<
"] TSId: " << iHitTS <<
" stTSs: " << stTSs[iLayer][iTS] <<
" driftInfo:" << driftInfo
664 <<
" priorityPosition:" << (driftInfo & 3) << endl;
706 std::map<std::string, std::vector<double> > mConstV;
707 std::map<std::string, double > mConstD;
708 std::map<std::string, double > mDouble;
715 double phiMax = M_PI;
717 double phiMin = -M_PI;
722 double rhoMax = 2500;
726 mConstV[
"rr"] = vector<double> (9);
727 mConstV[
"rr3D"] = vector<double> (4);
728 mConstV[
"nTSs"] = vector<double> (9);
729 for (
unsigned iSt = 0; iSt < 4; iSt++) {
731 mConstV[
"rr"][2 * iSt + 1] =
m_rr[iSt] * 100;
732 mConstV[
"rr3D"][iSt] =
m_rr[iSt] * 100;
733 mConstV[
"nTSs"][2 * iSt + 1] =
m_nWires[iSt] / 2;
735 mConstD[
"acosLUTInBitSize"] = rhoBitSize;
736 mConstD[
"acosLUTOutBitSize"] = phiBitSize - 1;
737 mConstD[
"Trg_PI"] = M_PI;
741 mDouble[
"rho"] = rho * 100;
742 if (mDouble[
"rho"] > rhoMax) {
743 mDouble[
"rho"] = rhoMax;
744 mDouble[
"pt"] = rhoMax * 0.3 * 1.5 * 0.01;
749 mDouble[
"phi0"] = fitPhi0;
752 if (mDouble[
"phi0"] > mConstD[
"Trg_PI"]) mDouble[
"phi0"] -= 2 * mConstD[
"Trg_PI"];
753 else if (mDouble[
"phi0"] < -mConstD[
"Trg_PI"]) mDouble[
"phi0"] += 2 * mConstD[
"Trg_PI"];
760 vector<tuple<string, double, int, double, double, int> > t_values = {
761 make_tuple(
"phi0", mDouble[
"phi0"], phiBitSize, phiMin, phiMax, 0),
762 make_tuple(
"rho", mDouble[
"rho"], rhoBitSize, rhoMin, rhoMax, 0),
763 make_tuple(
"charge", (
int)(charge == 1 ? 1 : 0), 1, 0, 1.5, 0),
776 for (
unsigned iSt = 0; iSt < 4; iSt++) {
777 string t_invMinName =
"invPhiAxMin_" + to_string(iSt);
778 double t_actual =
m_mSignalStorage[
"rho_c_" + to_string(iSt)].getMinActual();
781 string t_invMaxName =
"invPhiAxMax_" + to_string(iSt);
789 for (
unsigned iSt = 0; iSt < 4; iSt++) {
790 string t_valueName =
"phiAx_" + to_string(iSt);
791 string t_minName =
"phiAxMin_" + to_string(iSt);
792 string t_maxName =
"phiAxMax_" + to_string(iSt);
793 string t_invMinName =
"invPhiAxMin_" + to_string(iSt);
794 string t_invMaxName =
"invPhiAxMax_" + to_string(iSt);
798 double t_parameter = mConstV.at(
"rr3D")[iSt];
800 [ = ](
double aValue) ->
double{
return acos(t_parameter / 2 / aValue);},
803 (int)mConstD.at(
"acosLUTInBitSize"), (int)mConstD.at(
"acosLUTOutBitSize"));
809 for (
unsigned iSt = 0; iSt < 4; iSt++) {
811 string t_valueName =
"phiAx_" + to_string(iSt);
818 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
823 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
830 t_data.push_back(make_pair(t_compare, t_assigns));
841 t_data.push_back(make_pair(t_compare, t_assigns));
864 for (
unsigned iSt = 0; iSt < 4; iSt++) {
865 string t_valueName =
"dPhiAx_" + to_string(iSt);
867 string t_maxName =
"dPhiAxMax_" + to_string(iSt);
868 string t_minName =
"dPhiAxMin_" + to_string(iSt);
869 string t_2PiName =
"dPhiAx2Pi_" + to_string(iSt);
877 for (
unsigned iSt = 0; iSt < 4; iSt++) {
878 string t_in1Name =
"dPhiAx_" + to_string(iSt);
880 string t_valueName =
"dPhiAx_c_" + to_string(iSt);
881 string t_maxName =
"dPhiAxMax_" + to_string(iSt);
882 string t_minName =
"dPhiAxMin_" + to_string(iSt);
883 string t_2PiName =
"dPhiAx2Pi_" + to_string(iSt);
885 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
889 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
893 t_data.push_back(make_pair(t_compare, t_assigns));
901 t_data.push_back(make_pair(t_compare, t_assigns));
909 t_data.push_back(make_pair(t_compare, t_assigns));
920 for (
unsigned iSt = 0; iSt < 4; iSt++) {
921 int nShiftBits = int(log(pow(2, 24) * 2 * mConstD.at(
"Trg_PI") / mConstV.at(
"nTSs")[2 * iSt + 1] /
924 t_name =
"wireFactor_" + to_string(iSt);
932 for (
unsigned iSt = 0; iSt < 4; iSt++) {
934 iSt)].getToReal()) / log(2);
936 iSt)] *
m_mSignalStorage[
"wireFactor_" + to_string(iSt)]).shift(nShiftBits, 0);
940 vector< int > nCandidates = { 10, 10, 10, 13 };
942 vector<vector<bool> > t_stCandHitmap(4);
943 for (
unsigned iSt = 0; iSt < 4; iSt++) t_stCandHitmap[iSt] = vector<bool> (nCandidates[iSt]);
945 vector<vector<int> > t_stCandDriftmap(4);
946 for (
unsigned iSt = 0; iSt < 4; iSt++) t_stCandDriftmap[iSt] = vector<int> (nCandidates[iSt] + 1);
948 vector<tuple<string, double, int, double, double, int> > resultValues;
950 vector<pair<string, int> > t_chooseSignals = {
951 make_pair(
"wireDPhiAx_0", 1), make_pair(
"wireDPhiAx_1", 1), make_pair(
"wireDPhiAx_2", 1), make_pair(
"wireDPhiAx_3", 1)
955 vector<double> t_wireDPhiAx = {std::get<1>(resultValues[0]), std::get<1>(resultValues[1]), std::get<1>(resultValues[2]), std::get<1>(resultValues[3])};
958 for (
int iSt = 0; iSt < 4; iSt++) {
959 int indexTS = t_wireDPhiAx[iSt];
960 for (
int iTS = 0; iTS < nCandidates[iSt]; iTS++) {
962 t_stCandHitmap[iSt][iTS] =
m_hitMap[iSt][indexTS];
963 t_stCandDriftmap[iSt][iTS] =
m_driftMap[iSt][indexTS];
968 if (indexTS < 0) indexTS =
m_nWires[iSt] / 2 - 1;
972 if (indexTS >=
m_nWires[iSt] / 2) indexTS = 0;
978 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
979 cout <<
"iSt:" << iLayer <<
" t_wireDPhiAx:" << t_wireDPhiAx[iLayer];
981 if (iLayer % 2 == 0) t_endTSId = t_wireDPhiAx[iLayer] - (nCandidates[iLayer] - 1);
982 else t_endTSId = t_wireDPhiAx[iLayer] + (nCandidates[iLayer] - 1);
983 if (t_endTSId < 0) t_endTSId += mConstV[
"nTSs"][2 * iLayer + 1];
984 else if (t_endTSId >= mConstV[
"nTSs"][2 * iLayer + 1]) t_endTSId -= mConstV[
"nTSs"][2 * iLayer + 1];
986 cout <<
" t_stCandHitmap[" << iLayer <<
"]: " << t_endTSId <<
"=> ";
987 for (
int iTS = nCandidates[iLayer] - 1; iTS >= 0; iTS--) {
988 cout << t_stCandHitmap[iLayer][iTS];
990 cout <<
" <= " << t_wireDPhiAx[iLayer] << endl;
999 vector<double> t_targetWirePosition = { 3, 2, 3, 3};
1001 vector<int> t_bestRelTSId(4);
1002 for (
unsigned iSt = 0; iSt < 4; iSt++) t_bestRelTSId[iSt] = nCandidates[iSt];
1003 vector<int> t_bestDiff = {16, 16, 16, 16};
1005 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1006 for (
int iTS = 0; iTS < nCandidates[iSt]; iTS++) {
1007 int t_priorityPosition = (t_stCandDriftmap[iSt][iTS] & 3);
1009 if (t_stCandHitmap[iSt][iTS] == 0)
continue;
1010 if (t_priorityPosition != 3)
continue;
1011 double tsDiffTarget = fabs(t_targetWirePosition[iSt] - iTS);
1012 if (t_bestDiff[iSt] > tsDiffTarget) {
1013 t_bestDiff[iSt] = tsDiffTarget;
1014 t_bestRelTSId[iSt] = iTS;
1019 if (m_verboseFlag) {
1020 for (
unsigned iSt = 0; iSt < 4;
1021 iSt++) cout <<
"iSt:" << iSt <<
" bestRelTS:" << t_bestRelTSId[iSt] <<
" diff:" << t_bestDiff[iSt] << endl;
1024 vector<double> t_bestTSId(4);
1025 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1026 if (iSt % 2 == 0) t_bestTSId[iSt] = t_wireDPhiAx[iSt] - t_bestRelTSId[iSt];
1027 else t_bestTSId[iSt] = t_wireDPhiAx[iSt] + t_bestRelTSId[iSt];
1030 vector<double> t_bestDriftInfo(4);
1031 for (
unsigned iSt = 0; iSt < 4; iSt++) t_bestDriftInfo[iSt] = t_stCandDriftmap[iSt][t_bestRelTSId[iSt]];
1035 if (m_verboseFlag) {
1036 for (
unsigned iSt = 0; iSt < 4; iSt++)cout <<
"iSt:" << iSt <<
" bestDriftInfo:" << t_bestDriftInfo[iSt] << endl;
1040 vector<double> t_bestTSId_c(4);
1041 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1042 if (t_bestTSId[iSt] >= mConstV[
"nTSs"][2 * iSt + 1]) t_bestTSId_c[iSt] = t_bestTSId[iSt] - mConstV[
"nTSs"][2 * iSt + 1];
1043 else if (t_bestTSId[iSt] < 0) t_bestTSId_c[iSt] = t_bestTSId[iSt] + mConstV[
"nTSs"][2 * iSt + 1];
1044 else t_bestTSId_c[iSt] = t_bestTSId[iSt];
1047 if (m_verboseFlag) {
1048 for (
unsigned iSt = 0; iSt < 4; iSt++)cout <<
"iSt:" << iSt <<
" bestTS_c:" << t_bestTSId_c[iSt] << endl;
1052 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1053 if (t_bestDriftInfo[iSt] != 0)
m_bestTS[iSt] = t_bestTSId_c[iSt] * 2 * mConstD[
"Trg_PI"] / mConstV[
"nTSs"][2 * iSt + 1] ;
1060 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1061 if (t_bestDriftInfo[iSt] == 0) {
1064 for (
unsigned iTS = 0; iTS < stTSs[iSt].size(); iTS++) {
1065 if (fabs(
m_bestTS[iSt] - stTSs[iSt][iTS]) < 0.0001) {
1080 (*it).second.setName((*it).first);
1129 for (
unsigned iSt = 0; iSt < 4;
1136 if (m_verboseFlag) cout <<
"####geoFinder end####" << endl;
1145 if (input ==
"bestCot") {
1148 if (input ==
"bestZ0") {
1151 if (input ==
"houghMax") {
1154 if (input ==
"minDiffHough") {
1157 if (input ==
"foundZ") {
1163 if (input ==
"foundPhiSt") {
1169 if (input ==
"bestTS") {
1175 if (input ==
"bestTSIndex") {
1181 if (input ==
"st0GeoCandidatesPhi") {
1185 if (input ==
"st1GeoCandidatesPhi") {
1189 if (input ==
"st2GeoCandidatesPhi") {
1193 if (input ==
"st3GeoCandidatesPhi") {
1198 if (input ==
"st0GeoCandidatesDiffStWires") {
1202 if (input ==
"st1GeoCandidatesDiffStWires") {
1206 if (input ==
"st2GeoCandidatesDiffStWires") {
1210 if (input ==
"st3GeoCandidatesDiffStWires") {
1215 if (input ==
"st0GeoCandidatesIndex") {
1219 if (input ==
"st1GeoCandidatesIndex") {
1223 if (input ==
"st2GeoCandidatesIndex") {
1227 if (input ==
"st3GeoCandidatesIndex") {
1232 if (input ==
"stAxPhi") {
1239 if (input ==
"extreme") {
1262 if (input ==
"hitmapLayer1") {
1263 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[0] / 2); iOutput++) {
1264 result.push_back(
m_hitMap[0][iOutput]);
1268 if (input ==
"hitmapLayer2") {
1269 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[1] / 2); iOutput++) {
1270 result.push_back(
m_hitMap[1][iOutput]);
1274 if (input ==
"hitmapLayer3") {
1275 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[2] / 2); iOutput++) {
1276 result.push_back(
m_hitMap[2][iOutput]);
1280 if (input ==
"hitmapLayer4") {
1281 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[3] / 2); iOutput++) {
1282 result.push_back(
m_hitMap[3][iOutput]);
A class to use LUTs for TRGCDC.
A class to hold common data for JSignals.
A class to use Signals for TRGCDC 3D tracker.
static double calStAxPhi(int charge, double anglest, double ztostraw, double rr, double rho, double phi0)
Calculates the fitted axial phi for the stereo super layer.
static double calZ(int charge, double anglest, double ztostraw, double rr, double phi, double rho, double phi0)
Calculates z.
static double calS(double rho, double rr)
Calculates arc length.
static void constrainRPerStSl(std::map< std::string, std::vector< double > > const &mConstV, std::map< std::string, Belle2::TRGCDCJSignal > &mSignalStorage)
Constrains R for each SL differently using JSignal and multiple constants.
static void writeSignals(std::string outFilePath, std::map< std::string, std::vector< signed long long > > &data)
COE file functions.
static void multipleWriteCoe(int lutInBitsize, std::map< std::string, std::vector< signed long long > > &data, const std::string &fileDirectory)
Writes multiple signal values to a file in coe format.
void initialize(const TVectorD &geometryVariables, std::vector< float > &initVariables)
Geometry variables.
double m_findPhi0Max
Holds the maximum value for phi0.
int m_nWires[4]
Holds the number of wires for stereo superlayer.
double m_findRhoMin
Holds the minimum value for rho.
bool *** m_houghMeshLayer
Map to check if there is a Hough vote in a stereo superlayer.
double m_houghMax
The maximum vote number for track.
std::vector< std::vector< double > > * m_geoCandidatesDiffStWires
The number of wires difference from fitted axial phi location.
void runFinderVersion3(const std::vector< double > &trackVariables, std::vector< std::vector< double > > &stTSs, const std::vector< std::vector< int > > &stTSDrift)
Uses the 3D finder for mode 3.
std::vector< std::vector< double > > * m_geoCandidatesPhi
The phi for stereo superlayer hits.
std::map< std::string, bool > m_mBool
Map to hold input options.
Belle2::TRGCDCJSignalData * m_commonData
For VHDL code.
double m_findPhiZMin
Holds the minimum value for fitted axial phi location between superlayers.
double m_cotEnd
Hough mesh cot end range.
double m_z0StepSize
Holds the size of Hough mesh for z0.
std::map< std::string, std::vector< signed long long > > m_mSavedSignals
Array of saved signals.
std::string m_outputVhdlDirname
Output directory for vhdl.
double m_findArcCosMax
Holds the maximum value for arc cos(radius/2/rho).
void destVersion3(void)
Destructs the 3D finder for mode 3.
double m_rr[4]
Holds the radius for stereo super layer in cm.
double m_cotStart
Hough finder variables.
bool ** m_hitMap
Hit map for all streo superlayers.
double m_bestCot
Finder results.
void initVersion1(const std::vector< float > &initVariables)
Init variables.
double m_stAxPhi[4]
The fitted axial phi for stereo superlayers.
double m_findRhoIntMin
Holds the minimum value for integer rho.
double m_findPhiZMax
Holds the maximum for fitted axial phi location between superlayers.
double m_findArcCosIntMax
Holds the maximum value for integer arc cos(radius/2/rho).
double m_anglest[4]
Holds the tan theta of streo super layer in radian.
double m_findPhi0Min
Holds the minimum value for phi0.
Hough3DFinder(void)
3D finder constructor.
double m_findPhi0IntMin
Holds the minimum value for integer phi0.
std::string m_inputFileName
Version3 (GeoFinder Integer space) GeoFinder input file for parameters.
int ** m_driftMap
Drift map for all streo superlayers.
void runFinderVersion2(const std::vector< double > &trackVariables, std::vector< std::vector< double > > &stTSs, const std::vector< std::vector< int > > &stTSDrift)
Uses the 3D finder for mode 2.
void setInputFileName(const std::string &inputFileName)
Sets the config file for the GeoFinder.
std::map< std::string, Belle2::TRGCDCJSignal > m_mSignalStorage
Map to hold JSignals.
std::string m_outputLutDirname
Output directory for luts.
float ** m_houghMeshDiff
Map that combines the z differences for all stereo superlayers.
void destVersion2(void)
Destructs the 3D finder for mode 2.
int m_nCotSteps
Number of Hough meshes for cot.
int m_nZ0Steps
Number of Hough meshes for z0.
double m_ztostraw[4]
Holds the length of for stereo super layer from center in cm.
~Hough3DFinder(void)
3D finder destructor.
double m_z0Start
Hough mesh z0 start range.
double m_findPhiZIntMax
Holds the maximum value for fitted integer axial phi location between superlayers.
int getMode(void)
Gets which 3D finder is used.
double m_bestTS[4]
The phi location of the found TSs.
double m_findRhoIntMax
Holds the maximum value for integer rho.
void initVersion2(std::vector< float > &initVariables)
Initializes the 3D finder for mode 2.
void setMode(int mode)
Sets which 3D finder to use.
double m_findArcCosIntMin
Holds the minimum value for integer arc cos(radius/2/rho).
float *** m_houghMeshLayerDiff
Hold the minimum z differences for the Hough vote in a stereo superlayer.
double m_minDiffHough
The minimum z diff between all Hough votes that have maximum vote number.
std::vector< std::vector< int > > * m_geoCandidatesIndex
GeoFinder Variables.
double m_foundPhiSt[4]
The phi location for streo superlayer using found z0 and cot values for track.
void runFinder(const std::vector< double > &trackVariables, std::vector< std::vector< double > > &stTSs, const std::vector< std::vector< int > > &stTSDrift)
Track variables.
double m_bestZ0
The found z0 value for track.
double m_cotStepSize
Holds the size of Hough mesh for cot.
void initVersion3(std::vector< float > &initVariables)
Initializes the 3D finder for mode 3.
double m_z0End
Hough mesh z0 end range.
void getValues(const std::string &input, std::vector< double > &result)
Gets results from the 3D finder.
void getHoughMeshLayer(bool ***&houghMeshLayer)
Gets the Hough plane for the 3D finder.
double m_findPhiZIntMin
Holds the minimum value for fitted integer axial phi location between superlayers.
double m_findArcCosMin
Holds the minimum value for arc cos(radius/2/rho).
double m_foundZ[4]
The z location for stereo superlayer using found z0 and cot values for track.
void destVersion1(void)
Destructs the 3D finder for mode 1.
std::map< std::string, std::vector< signed long long > > m_mSavedIoSignals
Array of I/O signals.
std::map< std::string, Belle2::TRGCDCJLUT * > m_mLutStorage
Map to hold JLuts.
double m_findPhi0IntMax
Holds the maximum value for integer phi0.
void destruct(void)
Destructs the 3D finder.
void runFinderVersion1(const std::vector< double > &trackVariables, const std::vector< std::vector< double > > &stTSs, const std::vector< double > &tsArcS, const std::vector< std::vector< double > > &tsZ)
Uses the 3D finder for mode 1.
double m_findRhoMax
Find min and max values Holds the maximum value for rho.
int ** m_houghMesh
Map that combines the number of Hough votes for all stereo superlayers.
int m_bestTSIndex[4]
The hit index of the found TSs.
void printToFile()
Utilities Function to print VHDL code.
static void valuesToMapSignals(std::vector< std::tuple< std::string, double, int, double, double, int > > const &inValues, Belle2::TRGCDCJSignalData *inCommonData, std::map< std::string, Belle2::TRGCDCJSignal > &outMap)
Values => [name, value, bitwidth, min, max, clock] Changes values to signals.
bool getPrintVhdl() const
Gets the status of m_printVhdl.
static void ifElse(std::vector< std::pair< TRGCDCJSignal, std::vector< std::pair< TRGCDCJSignal *, TRGCDCJSignal > > > > &data, int targetClock)
If else implementation with target clock.
bool getPrintedToFile() const
Gets the status of m_printedToFile.
void entryVhdlCode()
Function to print entry VHDL code.
void signalsVhdlCode()
Function to print definition of signal VHDL code.
void setVhdlOutputFile(const std::string &)
Sets the filename for VHDL output.
void buffersVhdlCode()
Function to print buffer VHDL code.
void setPrintVhdl(bool)
Sets if to print VHDL output.
static void mapSignalsToValues(std::map< std::string, Belle2::TRGCDCJSignal >const &inMap, std::vector< std::pair< std::string, int > > const &inChoose, std::vector< std::tuple< std::string, double, int, double, double, int > > &outValues)
Choose => [signalName, FpgaEffects(=1)/NoFpgaEffects(=0)] Values => [name, value, bitwidth,...
static TRGCDCJSignal comp(TRGCDCJSignal const &lhs, const std::string &operate, TRGCDCJSignal const &rhs)
Compare two signals.