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++) {
441 tempHoughZ0 = houghZ0;
447 if (
false) cout << actualCot << actualZ0 << endl;
449 for (
int layer = 0; layer < 4; layer++) {
460 for (
int houghCot = 0; houghCot <
m_nCotSteps; houghCot++) {
461 for (
int houghZ0 = 0; houghZ0 <
m_nZ0Steps; houghZ0++) {
465 }
else { tempHoughZ0 = houghZ0;}
500 for (
int i = 0; i < 4; i++) {
510 double minDiff[4] = {999, 999, 999, 999};
511 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
512 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
513 if (minDiff[iLayer] > abs(
m_foundPhiSt[iLayer] - stTSs[iLayer][iTS])) {
514 minDiff[iLayer] = abs(
m_foundPhiSt[iLayer] - stTSs[iLayer][iTS]);
515 m_bestTS[iLayer] = stTSs[iLayer][iTS];
525 const std::vector<std::vector<int> >& stTSDrift)
529 for (
int iLayer = 0; iLayer < 4; iLayer++) {
530 (*m_geoCandidatesIndex)[iLayer].clear();
531 (*m_geoCandidatesPhi)[iLayer].clear();
532 (*m_geoCandidatesDiffStWires)[iLayer].clear();
535 int charge = (int)trackVariables[0];
536 double rho = trackVariables[1];
537 double fitPhi0 = trackVariables[2];
541 for (
int iLayer = 0; iLayer < 4; iLayer++) {
545 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
548 int t_priorityPosition = (stTSDrift[iLayer][iTS] & 3);
552 if (t_priorityPosition != 3)
continue;
554 tsDiffSt =
m_stAxPhi[iLayer] - stTSs[iLayer][iTS];
555 if (tsDiffSt > M_PI) tsDiffSt -= 2 * M_PI;
556 if (tsDiffSt < -M_PI) tsDiffSt += 2 * M_PI;
557 tsDiffSt = tsDiffSt / 2 / M_PI *
m_nWires[iLayer] / 2;
560 if (iLayer % 2 == 0) {
561 if (tsDiffSt > 0 && tsDiffSt <= 10) {
562 (*m_geoCandidatesIndex)[iLayer].push_back(iTS);
563 (*m_geoCandidatesPhi)[iLayer].push_back(stTSs[iLayer][iTS]);
564 (*m_geoCandidatesDiffStWires)[iLayer].push_back(tsDiffSt);
567 if (tsDiffSt < 0 && tsDiffSt >= -10) {
568 (*m_geoCandidatesIndex)[iLayer].push_back(iTS);
569 (*m_geoCandidatesPhi)[iLayer].push_back(stTSs[iLayer][iTS]);
570 (*m_geoCandidatesDiffStWires)[iLayer].push_back(tsDiffSt);
591 const double meanWireDiff[4] = { 3.68186, 3.3542, 3.9099, 4.48263 };
592 for (
int iLayer = 0; iLayer < 4; iLayer++) {
598 double bestDiff = 999;
600 tsDiffSt =
m_stAxPhi[iLayer] - stTSs[iLayer][(*m_geoCandidatesIndex)[iLayer][iTS]];
601 if (tsDiffSt > M_PI) tsDiffSt -= 2 * M_PI;
602 if (tsDiffSt < -M_PI) tsDiffSt += 2 * M_PI;
603 tsDiffSt = tsDiffSt / 2 / M_PI *
m_nWires[iLayer] / 2;
606 if (abs(abs(tsDiffSt) - meanWireDiff[iLayer]) < bestDiff) {
608 bestDiff = abs(abs(tsDiffSt) - meanWireDiff[iLayer]);
609 m_bestTS[iLayer] = stTSs[iLayer][(*m_geoCandidatesIndex)[iLayer][iTS]];
610 m_bestTSIndex[iLayer] = (*m_geoCandidatesIndex)[iLayer][iTS];
626 const vector<vector<int> >& stTSDrift)
629 int m_verboseFlag =
m_mBool[
"fVerbose"];
631 if (m_verboseFlag) cout <<
"####geoFinder start####" << endl;
634 for (
int iLayer = 0; iLayer < 4; iLayer++) {
635 (*m_geoCandidatesPhi)[iLayer].clear();
636 (*m_geoCandidatesIndex)[iLayer].clear();
637 (*m_geoCandidatesDiffStWires)[iLayer].clear();
640 for (
int iLayer = 0; iLayer < 4; iLayer++) {
641 for (
int iTS = 0; iTS <
m_nWires[iLayer] / 2; iTS++) {
646 for (
int iSt = 0; iSt < 4; iSt++) {
647 for (
int iTS = 0; iTS <
m_nWires[iSt] / 2; iTS++) {
653 int charge = (int)trackVariables[0];
654 double rho = trackVariables[1];
655 double fitPhi0 = trackVariables[2];
660 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
662 for (
unsigned iTS = 0; iTS < stTSs[iLayer].size(); iTS++) {
663 iHitTS = int(stTSs[iLayer][iTS] *
m_nWires[iLayer] / 2 / 2 / M_PI + 0.5);
664 driftInfo = stTSDrift[iLayer][iTS];
665 if (m_verboseFlag) cout <<
"[" << iLayer <<
"] TSId: " << iHitTS <<
" stTSs: " << stTSs[iLayer][iTS] <<
" driftInfo:" << driftInfo
666 <<
" priorityPosition:" << (driftInfo & 3) << endl;
708 std::map<std::string, std::vector<double> > mConstV;
709 std::map<std::string, double > mConstD;
710 std::map<std::string, double > mDouble;
717 double phiMax = M_PI;
719 double phiMin = -M_PI;
724 double rhoMax = 2500;
728 mConstV[
"rr"] = vector<double> (9);
729 mConstV[
"rr3D"] = vector<double> (4);
730 mConstV[
"nTSs"] = vector<double> (9);
731 for (
unsigned iSt = 0; iSt < 4; iSt++) {
733 mConstV[
"rr"][2 * iSt + 1] =
m_rr[iSt] * 100;
734 mConstV[
"rr3D"][iSt] =
m_rr[iSt] * 100;
735 mConstV[
"nTSs"][2 * iSt + 1] =
m_nWires[iSt] / 2;
737 mConstD[
"acosLUTInBitSize"] = rhoBitSize;
738 mConstD[
"acosLUTOutBitSize"] = phiBitSize - 1;
739 mConstD[
"Trg_PI"] = M_PI;
743 mDouble[
"rho"] = rho * 100;
744 if (mDouble[
"rho"] > rhoMax) {
745 mDouble[
"rho"] = rhoMax;
746 mDouble[
"pt"] = rhoMax * 0.3 * 1.5 * 0.01;
751 mDouble[
"phi0"] = fitPhi0;
754 if (mDouble[
"phi0"] > mConstD[
"Trg_PI"]) mDouble[
"phi0"] -= 2 * mConstD[
"Trg_PI"];
755 else if (mDouble[
"phi0"] < -mConstD[
"Trg_PI"]) mDouble[
"phi0"] += 2 * mConstD[
"Trg_PI"];
762 vector<tuple<string, double, int, double, double, int> > t_values = {
763 make_tuple(
"phi0", mDouble[
"phi0"], phiBitSize, phiMin, phiMax, 0),
764 make_tuple(
"rho", mDouble[
"rho"], rhoBitSize, rhoMin, rhoMax, 0),
765 make_tuple(
"charge", (
int)(charge == 1 ? 1 : 0), 1, 0, 1.5, 0),
778 for (
unsigned iSt = 0; iSt < 4; iSt++) {
779 string t_invMinName =
"invPhiAxMin_" + to_string(iSt);
780 double t_actual =
m_mSignalStorage[
"rho_c_" + to_string(iSt)].getMinActual();
783 string t_invMaxName =
"invPhiAxMax_" + to_string(iSt);
791 for (
unsigned iSt = 0; iSt < 4; iSt++) {
792 string t_valueName =
"phiAx_" + to_string(iSt);
793 string t_minName =
"phiAxMin_" + to_string(iSt);
794 string t_maxName =
"phiAxMax_" + to_string(iSt);
795 string t_invMinName =
"invPhiAxMin_" + to_string(iSt);
796 string t_invMaxName =
"invPhiAxMax_" + to_string(iSt);
800 double t_parameter = mConstV.at(
"rr3D")[iSt];
802 [ = ](
double aValue) ->
double{
return acos(t_parameter / 2 / aValue);},
805 (int)mConstD.at(
"acosLUTInBitSize"), (int)mConstD.at(
"acosLUTOutBitSize"));
811 for (
unsigned iSt = 0; iSt < 4; iSt++) {
813 string t_valueName =
"phiAx_" + to_string(iSt);
820 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
825 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
832 t_data.push_back(make_pair(t_compare, t_assigns));
843 t_data.push_back(make_pair(t_compare, t_assigns));
866 for (
unsigned iSt = 0; iSt < 4; iSt++) {
867 string t_valueName =
"dPhiAx_" + to_string(iSt);
869 string t_maxName =
"dPhiAxMax_" + to_string(iSt);
870 string t_minName =
"dPhiAxMin_" + to_string(iSt);
871 string t_2PiName =
"dPhiAx2Pi_" + to_string(iSt);
879 for (
unsigned iSt = 0; iSt < 4; iSt++) {
880 string t_in1Name =
"dPhiAx_" + to_string(iSt);
882 string t_valueName =
"dPhiAx_c_" + to_string(iSt);
883 string t_maxName =
"dPhiAxMax_" + to_string(iSt);
884 string t_minName =
"dPhiAxMin_" + to_string(iSt);
885 string t_2PiName =
"dPhiAx2Pi_" + to_string(iSt);
887 vector<pair<Belle2::TRGCDCJSignal, vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > > > t_data;
891 vector<pair<Belle2::TRGCDCJSignal*, Belle2::TRGCDCJSignal> > t_assigns = {
895 t_data.push_back(make_pair(t_compare, t_assigns));
903 t_data.push_back(make_pair(t_compare, t_assigns));
911 t_data.push_back(make_pair(t_compare, t_assigns));
922 for (
unsigned iSt = 0; iSt < 4; iSt++) {
923 int nShiftBits = int(log(pow(2, 24) * 2 * mConstD.at(
"Trg_PI") / mConstV.at(
"nTSs")[2 * iSt + 1] /
926 t_name =
"wireFactor_" + to_string(iSt);
934 for (
unsigned iSt = 0; iSt < 4; iSt++) {
936 iSt)].getToReal()) / log(2);
938 iSt)] *
m_mSignalStorage[
"wireFactor_" + to_string(iSt)]).shift(nShiftBits, 0);
942 vector< int > nCandidates = { 10, 10, 10, 13 };
944 vector<vector<bool> > t_stCandHitmap(4);
945 for (
unsigned iSt = 0; iSt < 4; iSt++) t_stCandHitmap[iSt] = vector<bool> (nCandidates[iSt]);
947 vector<vector<int> > t_stCandDriftmap(4);
948 for (
unsigned iSt = 0; iSt < 4; iSt++) t_stCandDriftmap[iSt] = vector<int> (nCandidates[iSt] + 1);
950 vector<tuple<string, double, int, double, double, int> > resultValues;
952 vector<pair<string, int> > t_chooseSignals = {
953 make_pair(
"wireDPhiAx_0", 1), make_pair(
"wireDPhiAx_1", 1), make_pair(
"wireDPhiAx_2", 1), make_pair(
"wireDPhiAx_3", 1)
957 vector<double> t_wireDPhiAx = {std::get<1>(resultValues[0]), std::get<1>(resultValues[1]), std::get<1>(resultValues[2]), std::get<1>(resultValues[3])};
960 for (
int iSt = 0; iSt < 4; iSt++) {
961 int indexTS = t_wireDPhiAx[iSt];
962 for (
int iTS = 0; iTS < nCandidates[iSt]; iTS++) {
964 t_stCandHitmap[iSt][iTS] =
m_hitMap[iSt][indexTS];
965 t_stCandDriftmap[iSt][iTS] =
m_driftMap[iSt][indexTS];
970 if (indexTS < 0) indexTS =
m_nWires[iSt] / 2 - 1;
974 if (indexTS >=
m_nWires[iSt] / 2) indexTS = 0;
980 for (
unsigned iLayer = 0; iLayer < 4; iLayer++) {
981 cout <<
"iSt:" << iLayer <<
" t_wireDPhiAx:" << t_wireDPhiAx[iLayer];
983 if (iLayer % 2 == 0) t_endTSId = t_wireDPhiAx[iLayer] - (nCandidates[iLayer] - 1);
984 else t_endTSId = t_wireDPhiAx[iLayer] + (nCandidates[iLayer] - 1);
985 if (t_endTSId < 0) t_endTSId += mConstV[
"nTSs"][2 * iLayer + 1];
986 else if (t_endTSId >= mConstV[
"nTSs"][2 * iLayer + 1]) t_endTSId -= mConstV[
"nTSs"][2 * iLayer + 1];
988 cout <<
" t_stCandHitmap[" << iLayer <<
"]: " << t_endTSId <<
"=> ";
989 for (
int iTS = nCandidates[iLayer] - 1; iTS >= 0; iTS--) {
990 cout << t_stCandHitmap[iLayer][iTS];
992 cout <<
" <= " << t_wireDPhiAx[iLayer] << endl;
1001 vector<double> t_targetWirePosition = { 3, 2, 3, 3};
1003 vector<int> t_bestRelTSId(4);
1004 for (
unsigned iSt = 0; iSt < 4; iSt++) t_bestRelTSId[iSt] = nCandidates[iSt];
1005 vector<int> t_bestDiff = {16, 16, 16, 16};
1007 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1008 for (
int iTS = 0; iTS < nCandidates[iSt]; iTS++) {
1009 int t_priorityPosition = (t_stCandDriftmap[iSt][iTS] & 3);
1011 if (t_stCandHitmap[iSt][iTS] == 0)
continue;
1012 if (t_priorityPosition != 3)
continue;
1013 double tsDiffTarget = fabs(t_targetWirePosition[iSt] - iTS);
1014 if (t_bestDiff[iSt] > tsDiffTarget) {
1015 t_bestDiff[iSt] = tsDiffTarget;
1016 t_bestRelTSId[iSt] = iTS;
1021 if (m_verboseFlag) {
1022 for (
unsigned iSt = 0; iSt < 4;
1023 iSt++) cout <<
"iSt:" << iSt <<
" bestRelTS:" << t_bestRelTSId[iSt] <<
" diff:" << t_bestDiff[iSt] << endl;
1026 vector<double> t_bestTSId(4);
1027 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1028 if (iSt % 2 == 0) t_bestTSId[iSt] = t_wireDPhiAx[iSt] - t_bestRelTSId[iSt];
1029 else t_bestTSId[iSt] = t_wireDPhiAx[iSt] + t_bestRelTSId[iSt];
1032 vector<double> t_bestDriftInfo(4);
1033 for (
unsigned iSt = 0; iSt < 4; iSt++) t_bestDriftInfo[iSt] = t_stCandDriftmap[iSt][t_bestRelTSId[iSt]];
1037 if (m_verboseFlag) {
1038 for (
unsigned iSt = 0; iSt < 4; iSt++)cout <<
"iSt:" << iSt <<
" bestDriftInfo:" << t_bestDriftInfo[iSt] << endl;
1042 vector<double> t_bestTSId_c(4);
1043 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1044 if (t_bestTSId[iSt] >= mConstV[
"nTSs"][2 * iSt + 1]) t_bestTSId_c[iSt] = t_bestTSId[iSt] - mConstV[
"nTSs"][2 * iSt + 1];
1045 else if (t_bestTSId[iSt] < 0) t_bestTSId_c[iSt] = t_bestTSId[iSt] + mConstV[
"nTSs"][2 * iSt + 1];
1046 else t_bestTSId_c[iSt] = t_bestTSId[iSt];
1049 if (m_verboseFlag) {
1050 for (
unsigned iSt = 0; iSt < 4; iSt++)cout <<
"iSt:" << iSt <<
" bestTS_c:" << t_bestTSId_c[iSt] << endl;
1054 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1055 if (t_bestDriftInfo[iSt] != 0)
m_bestTS[iSt] = t_bestTSId_c[iSt] * 2 * mConstD[
"Trg_PI"] / mConstV[
"nTSs"][2 * iSt + 1] ;
1062 for (
unsigned iSt = 0; iSt < 4; iSt++) {
1063 if (t_bestDriftInfo[iSt] == 0) {
1066 for (
unsigned iTS = 0; iTS < stTSs[iSt].size(); iTS++) {
1067 if (fabs(
m_bestTS[iSt] - stTSs[iSt][iTS]) < 0.0001) {
1082 (*it).second.setName((*it).first);
1131 for (
unsigned iSt = 0; iSt < 4;
1138 if (m_verboseFlag) cout <<
"####geoFinder end####" << endl;
1147 if (input ==
"bestCot") {
1150 if (input ==
"bestZ0") {
1153 if (input ==
"houghMax") {
1156 if (input ==
"minDiffHough") {
1159 if (input ==
"foundZ") {
1165 if (input ==
"foundPhiSt") {
1171 if (input ==
"bestTS") {
1177 if (input ==
"bestTSIndex") {
1183 if (input ==
"st0GeoCandidatesPhi") {
1187 if (input ==
"st1GeoCandidatesPhi") {
1191 if (input ==
"st2GeoCandidatesPhi") {
1195 if (input ==
"st3GeoCandidatesPhi") {
1200 if (input ==
"st0GeoCandidatesDiffStWires") {
1204 if (input ==
"st1GeoCandidatesDiffStWires") {
1208 if (input ==
"st2GeoCandidatesDiffStWires") {
1212 if (input ==
"st3GeoCandidatesDiffStWires") {
1217 if (input ==
"st0GeoCandidatesIndex") {
1221 if (input ==
"st1GeoCandidatesIndex") {
1225 if (input ==
"st2GeoCandidatesIndex") {
1229 if (input ==
"st3GeoCandidatesIndex") {
1234 if (input ==
"stAxPhi") {
1241 if (input ==
"extreme") {
1264 if (input ==
"hitmapLayer1") {
1265 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[0] / 2); iOutput++) {
1266 result.push_back(
m_hitMap[0][iOutput]);
1270 if (input ==
"hitmapLayer2") {
1271 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[1] / 2); iOutput++) {
1272 result.push_back(
m_hitMap[1][iOutput]);
1276 if (input ==
"hitmapLayer3") {
1277 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[2] / 2); iOutput++) {
1278 result.push_back(
m_hitMap[2][iOutput]);
1282 if (input ==
"hitmapLayer4") {
1283 for (
unsigned iOutput = 0; iOutput < unsigned(
m_nWires[3] / 2); iOutput++) {
1284 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.
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.