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")
47 for (
int iSt = 0; iSt < 4; iSt++) {
49 for (
int iTS = 0; iTS <
m_nWires[iSt] / 2; iTS++) {
90 for (
int iLayer = 0; iLayer < 4; iLayer++) {
94 for (
int i = 0; i < 4; i++) {
95 m_rr[i] = geometryVariables[i];
98 m_nWires[i] = (int)geometryVariables[i + 12];
113 cout <<
"[Error] 3DFinder mode is not correct. Current mode is " <<
m_mode <<
"." << endl;
136 const vector<vector<int> >& stTSDrift)
140 for (
int iLayer = 0; iLayer < 4; iLayer++) {
146 int charge = (int)trackVariables[0];
147 double rho = trackVariables[1];
148 double fitPhi0 = trackVariables[2];
151 vector<double > tsArcS;
152 vector<vector<double> > tsZ;
153 for (
unsigned i = 0; i < 4; i++) {
155 tsZ.push_back(vector<double>());
156 for (
unsigned j = 0; j < stTSs[i].size(); j++) {
187 m_z0End = (int)initVariables[3];
214 if (
false) cout << initVariables.size() << endl;
221 for (
int iLayer = 0; iLayer < 4; iLayer++)
m_geoCandidatesPhi->push_back(vector<double> ());
229 if (
false) cout << initVariables.size() << endl;
233 for (
int i = 0; i < 4; i++) {
235 for (
int j = 0; j <
m_nWires[i] / 2; j++) {
241 for (
int iSt = 0; iSt < 4; iSt++) {
243 for (
int iTS = 0; iTS <
m_nWires[iSt] / 2; iTS++) {
253 for (
int iLayer = 0; iLayer < 4; iLayer++)
m_geoCandidatesPhi->push_back(vector<double> ());
304 for (
int i = 0; i < 4; i++) {
308 for (
int iSt = 0; iSt < 4; iSt++) {
330 const vector<double>& tsArcS,
331 const vector<vector<double> >& tsZ)
334 int charge = (int)trackVariables[0];
335 double rho = trackVariables[1];
336 double fitPhi0 = trackVariables[2];
341 for (
int k = 0; k < 4; k++) {
351 double tempZ0Start, tempZ0End;
352 double tempZ01, tempZ02;
354 double actualCot, actualZ0;
359 for (
int cotStep = 0; cotStep <
m_nCotSteps; cotStep++) {
366 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
367 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
369 tempZ01 = -tsArcS[iLayer] * tempCotStart + tsZ[iLayer][iTS];
370 tempZ02 = -tsArcS[iLayer] * tempCotEnd + tsZ[iLayer][iTS];
373 if (tempZ01 < tempZ02) {
374 tempZ0Start = tempZ01;
377 tempZ0Start = tempZ02;
384 if (tempZ0Start > 0) {
404 for (
int z0Step =
int(tempZ0Start); z0Step <= int(tempZ0End); z0Step++) {
408 cout <<
"cutoff because z0step is bigger or smaller than z0 limit ";
415 }
else { tempHoughZ0 = z0Step; }
425 m_minDiffHough = abs(actualCot * tsArcS[iLayer] + actualZ0 - tsZ[iLayer][iTS]);
436 for (
int houghCot = 0; houghCot <
m_nCotSteps; houghCot++) {
437 for (
int houghZ0 = 0; houghZ0 <
m_nZ0Steps; houghZ0++) {
442 tempHoughZ0 = houghZ0;
448 if (
false) cout << actualCot << actualZ0 << endl;
450 for (
int layer = 0; layer < 4; layer++) {
461 for (
int houghCot = 0; houghCot <
m_nCotSteps; houghCot++) {
462 for (
int houghZ0 = 0; houghZ0 <
m_nZ0Steps; houghZ0++) {
466 }
else { tempHoughZ0 = houghZ0;}
501 for (
int i = 0; i < 4; i++) {
511 double minDiff[4] = {999, 999, 999, 999};
512 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
513 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
514 if (minDiff[iLayer] > abs(
m_foundPhiSt[iLayer] - stTSs[iLayer][iTS])) {
515 minDiff[iLayer] = abs(
m_foundPhiSt[iLayer] - stTSs[iLayer][iTS]);
516 m_bestTS[iLayer] = stTSs[iLayer][iTS];
526 const std::vector<std::vector<int> >& stTSDrift)
530 for (
int iLayer = 0; iLayer < 4; iLayer++) {
531 (*m_geoCandidatesIndex)[iLayer].clear();
532 (*m_geoCandidatesPhi)[iLayer].clear();
533 (*m_geoCandidatesDiffStWires)[iLayer].clear();
536 int charge = (int)trackVariables[0];
537 double rho = trackVariables[1];
538 double fitPhi0 = trackVariables[2];
542 for (
int iLayer = 0; iLayer < 4; iLayer++) {
546 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
549 int t_priorityPosition = (stTSDrift[iLayer][iTS] & 3);
553 if (t_priorityPosition != 3)
continue;
555 tsDiffSt =
m_stAxPhi[iLayer] - stTSs[iLayer][iTS];
561 if (iLayer % 2 == 0) {
562 if (tsDiffSt > 0 && tsDiffSt <= 10) {
563 (*m_geoCandidatesIndex)[iLayer].push_back(iTS);
564 (*m_geoCandidatesPhi)[iLayer].push_back(stTSs[iLayer][iTS]);
565 (*m_geoCandidatesDiffStWires)[iLayer].push_back(tsDiffSt);
568 if (tsDiffSt < 0 && tsDiffSt >= -10) {
569 (*m_geoCandidatesIndex)[iLayer].push_back(iTS);
570 (*m_geoCandidatesPhi)[iLayer].push_back(stTSs[iLayer][iTS]);
571 (*m_geoCandidatesDiffStWires)[iLayer].push_back(tsDiffSt);
592 double meanWireDiff[4] = { 3.68186, 3.3542, 3.9099, 4.48263 };
593 for (
int iLayer = 0; iLayer < 4; iLayer++) {
599 double bestDiff = 999;
601 tsDiffSt =
m_stAxPhi[iLayer] - stTSs[iLayer][(*m_geoCandidatesIndex)[iLayer][iTS]];
607 if (abs(abs(tsDiffSt) - meanWireDiff[iLayer]) < bestDiff) {
609 bestDiff = abs(abs(tsDiffSt) - meanWireDiff[iLayer]);
610 m_bestTS[iLayer] = stTSs[iLayer][(*m_geoCandidatesIndex)[iLayer][iTS]];
611 m_bestTSIndex[iLayer] = (*m_geoCandidatesIndex)[iLayer][iTS];
627 const vector<vector<int> >& stTSDrift)
630 int m_verboseFlag =
m_mBool[
"fVerbose"];
632 if (m_verboseFlag) cout <<
"####geoFinder start####" << endl;
635 for (
int iLayer = 0; iLayer < 4; iLayer++) {
636 (*m_geoCandidatesPhi)[iLayer].clear();
637 (*m_geoCandidatesIndex)[iLayer].clear();
638 (*m_geoCandidatesDiffStWires)[iLayer].clear();
641 for (
int iLayer = 0; iLayer < 4; iLayer++) {
642 for (
int iTS = 0; iTS <
m_nWires[iLayer] / 2; iTS++) {
647 for (
int iSt = 0; iSt < 4; iSt++) {
648 for (
int iTS = 0; iTS <
m_nWires[iSt] / 2; iTS++) {
654 int charge = (int)trackVariables[0];
655 double rho = trackVariables[1];
656 double fitPhi0 = trackVariables[2];
661 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
663 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
664 iHitTS = int(stTSs[iLayer][iTS] *
m_nWires[iLayer] / 2 / 2 /
m_Trg_PI + 0.5);
665 driftInfo = stTSDrift[iLayer][iTS];
666 if (m_verboseFlag) cout <<
"[" << iLayer <<
"] TSId: " << iHitTS <<
" stTSs: " << stTSs[iLayer][iTS] <<
" driftInfo:" << driftInfo
667 <<
" priorityPosition:" << (driftInfo & 3) << endl;
709 std::map<std::string, std::vector<double> > mConstV;
710 std::map<std::string, double > mConstD;
711 std::map<std::string, double > mDouble;
723 double rhoMax = 2500;
727 mConstV[
"rr"] = vector<double> (9);
728 mConstV[
"rr3D"] = vector<double> (4);
729 mConstV[
"nTSs"] = vector<double> (9);
730 for (
unsigned iSt = 0; iSt < 4; iSt++) {
732 mConstV[
"rr"][2 * iSt + 1] =
m_rr[iSt] * 100;
733 mConstV[
"rr3D"][iSt] =
m_rr[iSt] * 100;
734 mConstV[
"nTSs"][2 * iSt + 1] =
m_nWires[iSt] / 2;
736 mConstD[
"acosLUTInBitSize"] = rhoBitSize;
737 mConstD[
"acosLUTOutBitSize"] = phiBitSize - 1;
742 mDouble[
"rho"] = rho * 100;
743 if (mDouble[
"rho"] > rhoMax) {
744 mDouble[
"rho"] = rhoMax;
745 mDouble[
"pt"] = rhoMax * 0.3 * 1.5 * 0.01;
750 mDouble[
"phi0"] = fitPhi0;
753 if (mDouble[
"phi0"] > mConstD[
"Trg_PI"]) mDouble[
"phi0"] -= 2 * mConstD[
"Trg_PI"];
754 else if (mDouble[
"phi0"] < -mConstD[
"Trg_PI"]) mDouble[
"phi0"] += 2 * mConstD[
"Trg_PI"];
761 vector<tuple<string, double, int, double, double, int> > t_values = {
762 make_tuple(
"phi0", mDouble[
"phi0"], phiBitSize, phiMin, phiMax, 0),
763 make_tuple(
"rho", mDouble[
"rho"], rhoBitSize, rhoMin, rhoMax, 0),
764 make_tuple(
"charge", (
int)(charge == 1 ? 1 : 0), 1, 0, 1.5, 0),
777 for (
unsigned iSt = 0; iSt < 4; iSt++) {
778 string t_invMinName =
"invPhiAxMin_" + to_string(iSt);
779 double t_actual =
m_mSignalStorage[
"rho_c_" + to_string(iSt)].getMinActual();
782 string t_invMaxName =
"invPhiAxMax_" + to_string(iSt);
790 for (
unsigned iSt = 0; iSt < 4; iSt++) {
791 string t_valueName =
"phiAx_" + to_string(iSt);
792 string t_minName =
"phiAxMin_" + to_string(iSt);
793 string t_maxName =
"phiAxMax_" + to_string(iSt);
794 string t_invMinName =
"invPhiAxMin_" + to_string(iSt);
795 string t_invMaxName =
"invPhiAxMax_" + to_string(iSt);
799 double t_parameter = mConstV.at(
"rr3D")[iSt];
801 [ = ](
double aValue) ->
double{
return acos(t_parameter / 2 / aValue);},
804 (int)mConstD.at(
"acosLUTInBitSize"), (int)mConstD.at(
"acosLUTOutBitSize"));
810 for (
unsigned iSt = 0; iSt < 4; iSt++) {
812 string t_valueName =
"phiAx_" + to_string(iSt);
819 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
824 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
831 t_data.push_back(make_pair(t_compare, t_assigns));
842 t_data.push_back(make_pair(t_compare, t_assigns));
865 for (
unsigned iSt = 0; iSt < 4; iSt++) {
866 string t_valueName =
"dPhiAx_" + to_string(iSt);
868 string t_maxName =
"dPhiAxMax_" + to_string(iSt);
869 string t_minName =
"dPhiAxMin_" + to_string(iSt);
870 string t_2PiName =
"dPhiAx2Pi_" + to_string(iSt);
878 for (
unsigned iSt = 0; iSt < 4; iSt++) {
879 string t_in1Name =
"dPhiAx_" + to_string(iSt);
881 string t_valueName =
"dPhiAx_c_" + to_string(iSt);
882 string t_maxName =
"dPhiAxMax_" + to_string(iSt);
883 string t_minName =
"dPhiAxMin_" + to_string(iSt);
884 string t_2PiName =
"dPhiAx2Pi_" + to_string(iSt);
886 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
890 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
894 t_data.push_back(make_pair(t_compare, t_assigns));
902 t_data.push_back(make_pair(t_compare, t_assigns));
910 t_data.push_back(make_pair(t_compare, t_assigns));
921 for (
unsigned iSt = 0; iSt < 4; iSt++) {
922 int nShiftBits = int(log(pow(2, 24) * 2 * mConstD.at(
"Trg_PI") / mConstV.at(
"nTSs")[2 * iSt + 1] /
925 t_name =
"wireFactor_" + to_string(iSt);
933 for (
unsigned iSt = 0; iSt < 4; iSt++) {
935 iSt)].getToReal()) / log(2);
937 iSt)] *
m_mSignalStorage[
"wireFactor_" + to_string(iSt)]).shift(nShiftBits, 0);
941 vector< int > nCandidates = { 10, 10, 10, 13 };
943 vector<vector<bool> > t_stCandHitmap(4);
944 for (
unsigned iSt = 0; iSt < 4; iSt++) t_stCandHitmap[iSt] = vector<bool> (nCandidates[iSt]);
946 vector<vector<int> > t_stCandDriftmap(4);
947 for (
unsigned iSt = 0; iSt < 4; iSt++) t_stCandDriftmap[iSt] = vector<int> (nCandidates[iSt] + 1);
949 vector<tuple<string, double, int, double, double, int> > resultValues;
951 vector<pair<string, int> > t_chooseSignals = {
952 make_pair(
"wireDPhiAx_0", 1), make_pair(
"wireDPhiAx_1", 1), make_pair(
"wireDPhiAx_2", 1), make_pair(
"wireDPhiAx_3", 1)
956 vector<double> t_wireDPhiAx = {std::get<1>(resultValues[0]), std::get<1>(resultValues[1]), std::get<1>(resultValues[2]), std::get<1>(resultValues[3])};
959 for (
int iSt = 0; iSt < 4; iSt++) {
960 int indexTS = t_wireDPhiAx[iSt];
961 for (
int iTS = 0; iTS < nCandidates[iSt]; iTS++) {
963 t_stCandHitmap[iSt][iTS] =
m_hitMap[iSt][indexTS];
964 t_stCandDriftmap[iSt][iTS] =
m_driftMap[iSt][indexTS];
969 if (indexTS < 0) indexTS =
m_nWires[iSt] / 2 - 1;
973 if (indexTS >=
m_nWires[iSt] / 2) indexTS = 0;
979 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
980 cout <<
"iSt:" << iLayer <<
" t_wireDPhiAx:" << t_wireDPhiAx[iLayer];
982 if (iLayer % 2 == 0) t_endTSId = t_wireDPhiAx[iLayer] - (nCandidates[iLayer] - 1);
983 else t_endTSId = t_wireDPhiAx[iLayer] + (nCandidates[iLayer] - 1);
984 if (t_endTSId < 0) t_endTSId += mConstV[
"nTSs"][2 * iLayer + 1];
985 else if (t_endTSId >= mConstV[
"nTSs"][2 * iLayer + 1]) t_endTSId -= mConstV[
"nTSs"][2 * iLayer + 1];
987 cout <<
" t_stCandHitmap[" << iLayer <<
"]: " << t_endTSId <<
"=> ";
988 for (
int iTS = nCandidates[iLayer] - 1; iTS >= 0; iTS--) {
989 cout << t_stCandHitmap[iLayer][iTS];
991 cout <<
" <= " << t_wireDPhiAx[iLayer] << endl;
1000 vector<double> t_targetWirePosition = { 3, 2, 3, 3};
1002 vector<int> t_bestRelTSId(4);
1003 for (
unsigned iSt = 0; iSt < 4; iSt++) t_bestRelTSId[iSt] = nCandidates[iSt];
1004 vector<int> t_bestDiff = {16, 16, 16, 16};
1006 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1007 for (
int iTS = 0; iTS < nCandidates[iSt]; iTS++) {
1008 int t_priorityPosition = (t_stCandDriftmap[iSt][iTS] & 3);
1010 if (t_stCandHitmap[iSt][iTS] == 0)
continue;
1011 if (t_priorityPosition != 3)
continue;
1012 double tsDiffTarget = fabs(t_targetWirePosition[iSt] - iTS);
1013 if (t_bestDiff[iSt] > tsDiffTarget) {
1014 t_bestDiff[iSt] = tsDiffTarget;
1015 t_bestRelTSId[iSt] = iTS;
1020 if (m_verboseFlag) {
1021 for (
unsigned iSt = 0; iSt < 4;
1022 iSt++) cout <<
"iSt:" << iSt <<
" bestRelTS:" << t_bestRelTSId[iSt] <<
" diff:" << t_bestDiff[iSt] << endl;
1025 vector<double> t_bestTSId(4);
1026 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1027 if (iSt % 2 == 0) t_bestTSId[iSt] = t_wireDPhiAx[iSt] - t_bestRelTSId[iSt];
1028 else t_bestTSId[iSt] = t_wireDPhiAx[iSt] + t_bestRelTSId[iSt];
1031 vector<double> t_bestDriftInfo(4);
1032 for (
unsigned iSt = 0; iSt < 4; iSt++) t_bestDriftInfo[iSt] = t_stCandDriftmap[iSt][t_bestRelTSId[iSt]];
1036 if (m_verboseFlag) {
1037 for (
unsigned iSt = 0; iSt < 4; iSt++)cout <<
"iSt:" << iSt <<
" bestDriftInfo:" << t_bestDriftInfo[iSt] << endl;
1041 vector<double> t_bestTSId_c(4);
1042 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1043 if (t_bestTSId[iSt] >= mConstV[
"nTSs"][2 * iSt + 1]) t_bestTSId_c[iSt] = t_bestTSId[iSt] - mConstV[
"nTSs"][2 * iSt + 1];
1044 else if (t_bestTSId[iSt] < 0) t_bestTSId_c[iSt] = t_bestTSId[iSt] + mConstV[
"nTSs"][2 * iSt + 1];
1045 else t_bestTSId_c[iSt] = t_bestTSId[iSt];
1048 if (m_verboseFlag) {
1049 for (
unsigned iSt = 0; iSt < 4; iSt++)cout <<
"iSt:" << iSt <<
" bestTS_c:" << t_bestTSId_c[iSt] << endl;
1053 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1054 if (t_bestDriftInfo[iSt] != 0)
m_bestTS[iSt] = t_bestTSId_c[iSt] * 2 * mConstD[
"Trg_PI"] / mConstV[
"nTSs"][2 * iSt + 1] ;
1061 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1062 if (t_bestDriftInfo[iSt] == 0) {
1065 for (
unsigned iTS = 0; iTS < stTSs[iSt].size(); iTS++) {
1066 if (fabs(
m_bestTS[iSt] - stTSs[iSt][iTS]) < 0.0001) {
1081 (*it).second.setName((*it).first);
1130 for (
unsigned iSt = 0; iSt < 4;
1137 if (m_verboseFlag) cout <<
"####geoFinder end####" << endl;
1146 if (input ==
"bestCot") {
1149 if (input ==
"bestZ0") {
1152 if (input ==
"houghMax") {
1155 if (input ==
"minDiffHough") {
1158 if (input ==
"foundZ") {
1164 if (input ==
"foundPhiSt") {
1170 if (input ==
"bestTS") {
1176 if (input ==
"bestTSIndex") {
1182 if (input ==
"st0GeoCandidatesPhi") {
1186 if (input ==
"st1GeoCandidatesPhi") {
1190 if (input ==
"st2GeoCandidatesPhi") {
1194 if (input ==
"st3GeoCandidatesPhi") {
1199 if (input ==
"st0GeoCandidatesDiffStWires") {
1203 if (input ==
"st1GeoCandidatesDiffStWires") {
1207 if (input ==
"st2GeoCandidatesDiffStWires") {
1211 if (input ==
"st3GeoCandidatesDiffStWires") {
1216 if (input ==
"st0GeoCandidatesIndex") {
1220 if (input ==
"st1GeoCandidatesIndex") {
1224 if (input ==
"st2GeoCandidatesIndex") {
1228 if (input ==
"st3GeoCandidatesIndex") {
1233 if (input ==
"stAxPhi") {
1240 if (input ==
"extreme") {
1263 if (input ==
"hitmapLayer1") {
1264 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[0] / 2); iOutput++) {
1265 result.push_back(
m_hitMap[0][iOutput]);
1269 if (input ==
"hitmapLayer2") {
1270 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[1] / 2); iOutput++) {
1271 result.push_back(
m_hitMap[1][iOutput]);
1275 if (input ==
"hitmapLayer3") {
1276 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[2] / 2); iOutput++) {
1277 result.push_back(
m_hitMap[2][iOutput]);
1281 if (input ==
"hitmapLayer4") {
1282 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[3] / 2); iOutput++) {
1283 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 intger 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 intger 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.
double m_Trg_PI
Hold the PI value.
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.