59 unsigned short minLen = 9999;
60 unsigned short maxLen = 0;
61 unsigned short nPlnsWithHits = 0;
62 unsigned short ipl, aPlane = 3;
63 for(ipl = 0; ipl < 3; ++ipl) {
64 if(trkX[ipl].
size() == 0)
continue;
66 if(trkX[ipl].
size() < minLen) {
67 minLen = trkX[ipl].size();
69 if(trkX[ipl].
size() > maxLen) {
70 maxLen = trkX[ipl].size();
74 if(
prt) mf::LogVerbatim(
"TTA")<<
"trkX sizes "<<trkX[0].size()<<
" "<<trkX[1].size()<<
" "<<trkX[2].size()<<
" "<<
" nPlnsWithHits "<<nPlnsWithHits;
75 if(nPlnsWithHits < 2)
return;
76 if(aPlane > 2)
return;
86 iht = trkX[aPlane].size() - 1;
87 if(trkX[aPlane][0] > trkX[aPlane][iht]) {
89 for(ipl = 0; ipl < 3; ++ipl) {
90 if(trkX[ipl].
size() == 0)
continue;
91 std::reverse(trkWID[ipl].
begin(), trkWID[ipl].
end());
92 std::reverse(trkX[ipl].
begin(), trkX[ipl].
end());
93 std::reverse(trkXErr[ipl].
begin(), trkXErr[ipl].
end());
95 if(
prt) mf::LogVerbatim(
"TTA")<<
"Swapped order";
99 mf::LogVerbatim myprt(
"TTA");
101 for(ipl = 0; ipl < 3; ++ipl) {
102 if(trkX[ipl].
size() == 0)
continue;
103 myprt<<
" "<<trkX[ipl][0];
107 for(ipl = 0; ipl < 3; ++ipl) {
108 if(trkX[ipl].
size() == 0)
continue;
109 iht = trkX[ipl].size() - 1;
110 myprt<<
" "<<trkX[ipl][iht];
121 for(
unsigned short ipl = 0; ipl < 3; ++ipl) {
122 if(trkX[ipl].
size() == 0)
continue;
123 if(trkX[ipl][0] <
minX) {
127 iht = trkX[ipl].size() - 1;
128 if(trkX[ipl][iht] >
maxX) {
129 maxX = trkX[ipl][iht];
138 double aveHitXErr = 0;
139 unsigned short nHit = 0;
140 for(ipl = 0; ipl < 3; ++ipl) {
141 for(iht = 0; iht < trkXErr[ipl].size(); ++iht) {
142 aveHitXErr += trkXErr[ipl][iht];
146 aveHitXErr /= (double)nHit;
148 unsigned short npt = (
maxX -
minX) / (1 * aveHitXErr);
150 if(npt > maxLen) npt = maxLen;
152 if(
prt) mf::LogVerbatim(
"TTA")<<
" aveHitXErr "<<aveHitXErr<<
" number of traj points ";
154 double maxBinX = (
maxX -
minX) / (
double)(npt - 1);
155 double binX = maxBinX;
156 double xOrigin =
minX;
160 std::vector<geo::WireID> hitWID;
161 std::vector<double> hitX;
162 std::vector<double> hitXErr;
166 std::vector<TVector3> STPos;
167 std::vector<TVector3> STDir;
170 if(STPos.size() != 2 || STDir.size() != STPos.size()) {
174 for(ipl = 0; ipl < 3; ++ipl) {
175 if(trkX[ipl].
size() == 0)
continue;
176 std::reverse(trkWID[ipl].
begin(), trkWID[ipl].
end());
177 std::reverse(trkX[ipl].
begin(), trkX[ipl].
end());
178 std::reverse(trkXErr[ipl].
begin(), trkXErr[ipl].
end());
185 mf::LogVerbatim(
"TTA")<<
"STPos";
186 for(
unsigned short ii = 0; ii < STPos.size(); ++ii) mf::LogVerbatim(
"TTA")<<ii<<
" "<<std::fixed<<std::setprecision(1)<<STPos[ii](0)<<
" "<<STPos[ii](1)<<
" "<<STPos[ii](2);
189 if(maxLen < 4 || npt < 2) {
194 std::reverse(TrajPos.begin(), TrajPos.end());
195 std::reverse(TrajDir.begin(), TrajDir.end());
196 for(ipl = 0; ipl < 3; ++ipl) {
197 if(trkX[ipl].
size() == 0)
continue;
198 std::reverse(trkWID[ipl].
begin(), trkWID[ipl].
end());
199 std::reverse(trkX[ipl].
begin(), trkX[ipl].
end());
200 std::reverse(trkXErr[ipl].
begin(), trkXErr[ipl].
end());
207 std::array<unsigned short, 3> hStart;
208 for(ipl = 0; ipl < 3; ++ipl) hStart[ipl] = 0;
210 bool gotLastPoint =
false;
211 for(
unsigned short ipt = 0; ipt < npt + 1; ++ipt) {
215 for(ipl = 0; ipl < 3; ++ipl) {
216 for(iht = hStart[ipl]; iht < trkX[ipl].size(); ++iht) {
217 if(trkX[ipl][iht] < xOrigin - binX)
continue;
218 if(trkX[ipl][iht] > xOrigin + binX)
break;
219 hitWID.push_back(trkWID[ipl][iht]);
220 hitX.push_back(trkX[ipl][iht]);
221 hitXErr.push_back(trkXErr[ipl][iht]);
225 if(
prt) mf::LogVerbatim(
"TTA")<<
"ipt "<<ipt<<
" xOrigin "<<xOrigin<<
" binX "<<binX<<
" hitX size "<<hitX.size();
226 if(hitX.size() > 3) {
228 if(
prt) mf::LogVerbatim(
"TTA")<<
" xyz "<<xyz(0)<<
" "<<xyz(1)<<
" "<<xyz(2)<<
" dir "<<
dir(0)<<
" "<<
dir(1)<<
" "<<
dir(2)<<
" ChiDOF "<<ChiDOF<<
" hitX size "<<hitX.size();
229 }
else if(ipt == 0 && STPos.size() == 2) {
234 if(
prt && hitX.size() < 4) mf::LogVerbatim(
"TTA")<<
"\n";
235 if(xOrigin >=
maxX)
break;
237 if(
maxX - xOrigin < binX) {
242 if(ChiDOF < 0 || ChiDOF > 100)
continue;
243 TrajPos.push_back(xyz);
244 TrajDir.push_back(dir);
245 if(ipt == npt) gotLastPoint =
true;
248 mf::LogVerbatim(
"TTA")<<
"gotLastPoint "<<gotLastPoint<<
" TTA Traj \n";
249 for(
unsigned short ii = 0; ii < TrajPos.size(); ++ii) mf::LogVerbatim(
"TTA")<<ii<<
" "<<std::fixed<<std::setprecision(1)<<TrajPos[ii](0)<<
" "<<TrajPos[ii](1)<<
" "<<TrajPos[ii](2);
252 if(!gotLastPoint && STPos.size() == 2) {
254 TrajPos.push_back(STPos[1]);
255 TrajDir.push_back(STDir[1]);
258 if(TrajPos.size() < 2) {
265 std::reverse(TrajPos.begin(), TrajPos.end());
266 std::reverse(TrajDir.begin(), TrajDir.end());
267 for(ipl = 0; ipl < 3; ++ipl) {
268 if(trkX[ipl].
size() == 0)
continue;
269 std::reverse(trkWID[ipl].
begin(), trkWID[ipl].
end());
270 std::reverse(trkX[ipl].
begin(), trkX[ipl].
end());
271 std::reverse(trkXErr[ipl].
begin(), trkXErr[ipl].
end());
276 mf::LogVerbatim(
"TTA")<<
"TTA Traj2\n";
277 for(
unsigned short ii = 0; ii < TrajPos.size(); ++ii) mf::LogVerbatim(
"TTA")<<ii<<
" "<<std::fixed<<std::setprecision(1)<<TrajPos[ii](0)<<
" "<<TrajPos[ii](1)<<
" "<<TrajPos[ii](2);
void TrkLineFit(std::vector< geo::WireID > &hitWID, std::vector< double > &hitX, std::vector< double > &hitXErr, double XOrigin, TVector3 &Pos, TVector3 &Dir, float &ChiDOF) const
TrackLineFitAlg fTrackLineFitAlg
unsigned short fMaxTrajPoints
std::size_t size(FixedBins< T, C > const &) noexcept
auto end(FixedBins< T, C > const &) noexcept
void ShortTrackTrajectory(std::array< std::vector< geo::WireID >, 3 > trkWID, std::array< std::vector< double >, 3 > trkX, std::array< std::vector< double >, 3 > trkXErr, std::vector< TVector3 > &TrajPos, std::vector< TVector3 > &TrajDir)
auto begin(FixedBins< T, C > const &) noexcept