LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
StitchAlg.cxx
Go to the documentation of this file.
1 
2 
4 //
5 // StitchAlg.cxx
6 //
7 // echurch@fnal.gov
8 //
9 // This alg is called by TrackStich_module.cc in order to stitch together
10 // tracks which point at each other and have gaps to within user-set
11 // tolerances.
13 
14 
16 
17 // C/C++ standard libraries
18 #include <time.h>
19 #include <cmath>
20 #include <iostream>
21 #include <fstream>
22 #include <cstdlib>
23 #include <vector>
24 
25 //Framework includes:
27 #include "fhiclcpp/ParameterSet.h"
31 
32 // LArSoft libraries
34 
35 
37 {
38  ftNo = 0;
40  this->reconfigure(pset);
41 }
42 
43 //----------------------------------------------------------
44 
45 //----------------------------------------------------------
47 {
48 
49  fCosAngTol = pset.get< double >("CosAngTolerance", 0.95);
50  fSepTol = pset.get< double >("SpptSepTolerance", 10.0); //cm
51 }
52 
53 
54 void trkf::StitchAlg::FindHeadsAndTails( const art::Event& EvtArg, const std::string& trackModuleLabelArg )
55 {
56 
57  fTrackVec.clear();
58  fTrackComposite.clear();
59  fHT.clear();
60 
61  EvtArg.getByLabel(trackModuleLabelArg,ftListHandle);
62 
63  // An element of fh and ft for each outer track. Keep the cos and sep parameters of the match and a string that indicates whether it's the second track's head or tail that gives the match, along with ii, jj, the indices of the outer and inner tracks.
64  ft.clear();
65  fh.clear();
66 
67  int ntrack = ftListHandle->size();
68  // std::cout << "StitchAlg.FindHeadsAndTails: Number of tracks in " << ntrack << std::endl;
69  for(int ii = 0; ii < ntrack; ++ii) {
71  const recob::Track& track1 = *ptrack1;
72  const TVector3 start1(track1.Vertex());
73  const TVector3 end1(track1.End());
74  const TVector3 start1Dir(track1.VertexDirection());
75  const TVector3 end1Dir(track1.EndDirection());
76  // For each outer track, make a vector of 1 candidate track. Doesn't need to be a vector except for desire to have a 2-iteration history.
77  std::vector< std::tuple< std::string, int, int, double, double> > headvv;
78  std::vector< std::tuple< std::string, int, int, double, double> > tailvv;
79 
80  // For head/tail keep a vector of candidate (cos,sep)
81  std::vector< std::vector<std::pair< double, double>> > matchhead;
82  std::vector< std::vector<std::pair< double, double>> > matchtail;
83  // Neither end of track1 is yet matched:
84  bool head(false);
85  bool tail(false);
86  std::vector<art::Ptr <recob::Track> >::iterator ith, itt;
87 
88  for(int jj = ii+1; jj < ntrack; ++jj) {
90  const recob::Track& track2 = *ptrack2;
91  const TVector3& start2(track2.Vertex());
92  const TVector3& end2(track2.End());
93  const TVector3& start2Dir(track2.VertexDirection());
94  const TVector3& end2Dir(track2.EndDirection());
95  std::string sHT2("NA"); // track2 (receptor track) H or T is tagged as matched
96 
97 
98  bool c12((std::abs(start1Dir.Dot(end2Dir))>fCosAngTol) && ((start1-end2).Mag()<fSepTol));
99  bool c21((std::abs(end1Dir.Dot(start2Dir))>fCosAngTol) && ((start2-end1).Mag()<fSepTol));
100  bool c11((std::abs(start1Dir.Dot(start2Dir))>fCosAngTol) && ((start1-start2).Mag()<fSepTol));
101  bool c22((std::abs(end1Dir.Dot(end2Dir))>fCosAngTol) && ((end1-end2).Mag()<fSepTol));
102 
103  if ( c12 || c21 || c11 || c22 )
104  {
105 
106  sHT2 = "NA";
107  if (c12||c11) { head=true; }
108  if (c11) { sHT2 = "H"; } else if (c12) { sHT2 = "T"; }
109  if (c21||c22) { tail=true; }
110  if (c21) { sHT2 = "H"; } else if (c22) { sHT2 = "T"; }
111 
112  if (head && tail) // split the tie by distance
113  {
114  head = false; tail = false;
115  if ( ((start1-end2).Mag() < (start2-end1).Mag()) || ((start1-end2).Mag() < (start2-end2).Mag()) || ((start1-start2).Mag() < (start2-end1).Mag()) || ((start1-start2).Mag() < (start2-end2).Mag()) )
116  { head = true; tail = false; }
117  else
118  { head = false; tail = true; }
119  }
120 
121  if (head)
122  {
123  // 2-deep vector, for head and tail of 2nd track
124  std::vector< std::pair <double,double> > headv;
125  headv.push_back(std::pair<double,double>(abs(start1Dir.Dot(start2Dir)), (start1-start2).Mag()) );
126  headv.push_back(std::pair<double,double>(abs(start1Dir.Dot(end2Dir)), (start1-end2).Mag()) );
127 
128  matchhead.push_back( headv );
129  // if inferior, drop the new elements; if superior, replace the old
130  if ( ((matchhead.size() > 1) && ( (matchhead.back().at(0).second < matchhead.front().at(0).second) || (matchhead.back().at(1).second < matchhead.front().at(1).second ) ) ) || matchhead.size()==1 )
131  {
132  if (matchhead.size()>1) matchhead.erase(matchhead.begin());
133  if (headvv.size()>1) headvv.erase(headvv.begin());
134  if (!sHT2.compare("H"))
135  {
136  auto tupTmp =std::make_tuple(sHT2,ii,jj,matchhead.back().at(0).first,matchhead.back().at(0).second);
137  headvv.push_back (tupTmp);
138  }
139  else
140  {
141  auto tupTmp = std::make_tuple(sHT2,ii,jj,matchhead.back().at(1).first,matchhead.back().at(1).second);
142  headvv.push_back (tupTmp);
143  }
144  }
145  else
146  matchhead.pop_back();
147 
148 
149 
150  // std::cout << "TrackStitcher: satisfied head. " << std::endl;
151  } // head
152 
153  else if (tail) // else if to prevent same stitching candidate being
154  // allowed at both head and tail
155  {
156  // 2-deep vector, for head and tail of 2nd track
157  std::vector< std::pair <double,double> > tailv;
158  tailv.push_back(std::pair<double,double>( abs(end1Dir.Dot(start2Dir)),(start2-end1).Mag() ) );
159  tailv.push_back(std::pair<double,double>( abs(end1Dir.Dot(end2Dir)),(end1-end2).Mag() ) );
160  matchtail.push_back( tailv );
161  // if inferior, drop the new elements; if superior, replace the old
162  if ( ((matchtail.size() > 1) && ( (matchtail.back().at(0).second < matchtail.front().at(0).second) || (matchtail.back().at(1).second < matchtail.front().at(1).second ) ) ) || matchtail.size()==1 )
163  {
164  if (matchtail.size()>1) matchtail.erase(matchtail.begin());
165  if (tailvv.size()>1) tailvv.erase(tailvv.begin());
166  if (!sHT2.compare("T"))
167  {
168  auto tupTmp = std::make_tuple(sHT2,ii,jj,matchtail.back().at(0).first,matchtail.back().at(0).second);
169  tailvv.push_back(tupTmp);
170  }
171  else
172  {
173  auto tupTmp = std::make_tuple(sHT2,ii,jj,matchtail.back().at(1).first,matchtail.back().at(1).second);
174  tailvv.push_back(tupTmp);
175  }
176  }
177  else
178  matchtail.pop_back();
179 
180  // std::cout << "TrackStitcher: satisfied tail. " << std::endl;
181  } //tail
182  /*
183  std::cout << "abs(start1Dir.Dot(end2Dir)) " << std::abs(start1Dir.Dot(end2Dir)) << ", start1-end2.Mag(): " << (start1-end2).Mag() << std::endl;
184  std::cout << "abs(end1Dir.Dot(start2Dir)) " << std::abs(end1Dir.Dot(start2Dir)) << ", start2-end1.Mag(): " << (start2-end1).Mag() << std::endl;
185  std::cout << "abs(start1Dir.Dot(start2Dir)) " << std::abs(start1Dir.Dot(start2Dir)) << ", start1-start2.Mag(): " << (start1-start2).Mag() << std::endl;
186  std::cout << "abs(end1Dir.Dot(end2Dir)) " << std::abs(end1Dir.Dot(end2Dir)) << ", end1-end2.Mag(): " << (end1-end2).Mag() << std::endl;
187  std::cout << "sHT2 " << sHT2 << std::endl;
188  */
189  } // end c11||c12||c21||c22
190 
191  // We've been careful to pick the best jj match for this iith track head and tail.
192  // Now we need to be sure that for the jjth track head/tail we don't have two ii trks.
193  if (headvv.size())
194  {
195  int otrk = std::get<2>(headvv.back()); // jj'th track for this iith trk
196  // H or T of this jj'th trk we're matched to.
197  std::string sotrkht(std::get<0>(headvv.back()));
198  for (int kk=0;kk<ii;++kk)
199  {
200  if (std::get<2>(fh.at(kk)) == otrk && !sotrkht.compare(std::get<0>(fh.at(kk)) ) )
201  {
202  // check matching sep and pick the best one. Either erase this
203  // headvv (and it'll get null settings later below) or null out
204  // the parameters in fh.
205  if (std::get<4>(headvv.back()) < std::get<4>(fh.at(kk)) && std::get<4>(headvv.back())!=0.0)
206  {
207  auto tupTmp2 = std::make_tuple(std::string("NA"),kk,-12,0.0,0.0);
208  fh.at(kk) = tupTmp2;
209  }
210  else if (std::get<4>(headvv.back())!=0.0)
211  {
212  headvv.pop_back();
213  break;
214  }
215  }
216  }
217  }
218  if (tailvv.size())
219  {
220  int otrk = std::get<2>(tailvv.back()); // jj'th track for this iith trk
221  // H or T of this jj'th trk we're matched to.
222  std::string sotrkht(std::get<0>(tailvv.back()));
223  for (int kk=0;kk<ii;++kk)
224  {
225  if (std::get<2>(ft.at(kk)) == otrk && !sotrkht.compare(std::get<0>(ft.at(kk)) ) )
226  {
227  // check matching sep and pick the best one. erase either this
228  // tailvv or null out the parameters in ft.
229  if (std::get<4>(tailvv.back()) < std::get<4>(ft.at(kk)) && std::get<4>(tailvv.back())!=0.0)
230  {
231  auto tupTmp2 = std::make_tuple(std::string("NA"),kk,-12,0.0,0.0);
232  ft.at(kk) = tupTmp2;
233  }
234  else if (std::get<4>(tailvv.back())!=0.0)
235  {
236  tailvv.pop_back();
237  break;
238  }
239  }
240  }
241  }
242 
243 
244  } // jj
245 
246 
247  auto tupTmp2 = std::make_tuple(std::string("NA"),ii,-12,0.0,0.0);
248  // We always have our best 1-element tailvv and headvv for trk o at this point
249  if (!headvv.size()) headvv.push_back(tupTmp2);
250  if (!tailvv.size()) tailvv.push_back(tupTmp2);
251  // std::cout << "StitchAlg::FindHeadsAndTails: headvv, tailvv .get<0> is " << std::get<0>(headvv.back()) << ", " << std::get<0>(tailvv.back()) << std::endl;
252  fh.push_back(headvv.back());
253  ft.push_back(tailvv.back());
254 
255  } // ii
256 
257  // std::cout << "fh.size, ft.size are " << fh.size() << ", " << ft.size() << std::endl;
258 
259 }
260 
262 {
263  // take the vector of tracks, walk through each track's vectors of xyz, dxdydz, etc
264  // and concatenate them into longer vectors. Use those to instantiate one new
265  // Stitched-together track.
266  std::vector<TVector3> xyz;
267  std::vector<TVector3> dxdydz;
268  std::vector<TMatrixT<double> > cov;
269  std::vector<double> mom;
270  std::vector< std::vector <double> > dQdx;
271  //art::PtrVector<recob::Track>::const_iterator
272 
273 
274  size_t cnt(0);
275  for (auto it = (*itvvArg).begin(); it!=(*itvvArg).end(); ++it)
276  {
277 
278  cnt++;
279  // std::cout << "Stitching track cnt is: " << cnt << std::endl;
280 
281  for (size_t pt = 0; pt!=(*it).get()->NumberTrajectoryPoints(); pt++)
282  {
283  size_t ptHere(pt);
284  // ask if 1st character of 2-character string is an H. If so, reverse order
285  // of the concatenation. Note however that I've had my notion of head & tail backwards
286  // throughout this whole class! start1, end1 are really T, H, not H, T as I've labeled 'em till now.
287  // hence flip the direction if this character is a T/H, when expecting H/T! -- EC, 29-June-2014.
288 
289  auto itvfHT = fHT.begin() + size_t (itvArg - fTrackVec.begin());
290  if ( (*itvfHT).size() &&
291  (
292  // was fHT.back()
293  (cnt==1 && !(*itvfHT).at(cnt-1).compare(0,1,"H")) ||
294  (cnt>1 && !(*itvfHT).at(cnt-2).compare(1,1,"T"))
295  )
296  )
297  ptHere = (*it).get()->NumberTrajectoryPoints() - pt - 1;
298 
299  try
300  {
301  xyz.push_back((*it).get()->LocationAtPoint(ptHere));
302  // std::cout << "Stitching track number " << cnt << " with TrajPt at ptHere " << ptHere << " at x,y,z: " << xyz.back().X() << ", " << xyz.back().Y() << ", " << xyz.back().Z() << std::endl;
303  dxdydz.push_back((*it).get()->DirectionAtPoint(ptHere));
304  TMatrixT<double> dumc(5,5);
305  if (ptHere<(*it).get()->NumberCovariance())
306  dumc = (*it).get()->CovarianceAtPoint(ptHere);
307  cov.push_back(dumc);
308  double dumm(0.0);
309  if ((*it).get()->HasMomentum())
310  dumm = (*it).get()->MomentumAtPoint(ptHere);
311  mom.push_back(dumm);
312  std::vector <double> dum;
313  if (ptHere<(*it).get()->NumberdQdx(geo::kZ))
314  dum.push_back((*it).get()->DQdxAtPoint(ptHere,geo::kZ));
315  else
316  dum.push_back(0.0);
317  dQdx.push_back(dum);
318 
319  }
320  catch (cet::exception &e)
321  {
322  mf::LogVerbatim("TrackStitcher bailing. ") << " One or more of xyz, dxdydz, cov, mom, dQdx elements from original Track is out of range..." << e.what() << __LINE__;
323  break;
324  }
325  }
326  }
327 
331 
332  const recob::Track t(xyz,dxdydz,cov,dQdx,mom,ftNo++);
333  //const art::Ptr<recob::Track> t(xyz,dxdydz,cov,dQdx,mom,ftNo++);
334  fTrackVec.insert(itvArg,t);
335 
336 }
337 
339 {
340 
342  std::vector <std::string> trackStatus (fh.size(),"NotDone"); // H or T
343  std::vector <std::string> HT2 ; // H or T
344 
345 
346  for (unsigned int ii=0; ii<fh.size(); ++ii) // same as t.size()
347 
348  {
349  if (!trackStatus.at(ii).compare("Done")) continue;
350 
351  const art::Ptr<recob::Track> th(ftListHandle, ii);
352  compTrack.push_back(th);
353  // Should there not be an HT.push_back here??
354 
355  // start with track 1: see if head goes anywhere, walk with it. Add to compTrack.
356  // Go until the other tuple's other vtx string says "NA." Then change status string
357  // of vtxsJoined to "Done" for that track.
358  bool chain(true);
359  int walk(ii);
360  std::string sh(std::get<0>(fh.at(walk)));
361  std::string st("NA");
362  while (chain)
363  {
364  int hInd = -12;
365  int tInd = -12;
366  if (walk!=(int)ii)
367  {
368  sh = std::get<0>(fh.at(walk));
369  st = std::get<0>(ft.at(walk));
370  }
371 
372  // std::cout << "StichAlg::WalkStitch(): Inside head chain. walk(track), sh, st, " << walk << ", " << sh << ", "<<st <<", connected to tracks: " << std::get<2>(fh.at(walk))<<", " << std::get<2>(ft.at(walk)) <<std::endl;
373  if (!sh.compare("H") || !sh.compare("T"))
374  {
375 
376  hInd = std::get<2>(fh.at(walk)); // index of track that walk is connected to.
377  // std::cout << "WalkStitch(): hInd is " << hInd << std::endl;
378 
379  const art::Ptr<recob::Track> th2( ftListHandle, hInd );
380  compTrack.push_back(th2);
381  HT2.push_back("H"+sh);
382  }
383 
384  if ((!st.compare("H") || !st.compare("T")))
385  {
386  tInd = std::get<2>(ft.at(walk));
387  // std::cout << "WalkStitch(): tInd is " << tInd << std::endl;
388  const art::Ptr<recob::Track> th2( ftListHandle, tInd );
389  compTrack.push_back(th2);
390  HT2.push_back("T"+st); // since we will eventually read from 0th element forward
391  }
392  if (hInd!=-12) walk = hInd;
393  if (tInd!=-12) walk = tInd;
394  if (!sh.compare("NA") && !st.compare("NA"))
395  chain = false;
396 
397  trackStatus.at(walk) = "Done";
398  } // while
399 
400  // It is possible that our first (ii'th) track had a head _and_ a tail match. Thus, we must
401  // see if tail goes anywhere. walk with it. Insert, don't push_back, to compTrack.
402  chain = true;
403  walk = ii;
404  sh = "NA";
405  st = std::get<0>(ft.at(walk));
406  while (chain)
407  {
408  int hInd = -12;
409  int tInd = -12;
410  if (walk!=(int)ii)
411  {
412  sh = std::get<0>(fh.at(walk));
413  st = std::get<0>(ft.at(walk));
414  }
415 
416  // std::cout << "StichAlg::WalkStitch(): Inside tail chain. walk(track), sh, st, " << walk << ", " << sh << ", "<<st <<", connected to tracks: " << std::get<2>(fh.at(walk))<<", " << std::get<2>(ft.at(walk)) <<std::endl;
417  if (!sh.compare("H") || !sh.compare("T"))
418  {
419 
420  hInd = std::get<2>(fh.at(walk)); // index of track that walk is connected to.
421  // std::cout << "WalkStitch(): hInd is " << hInd << std::endl;
422 
423  const art::Ptr<recob::Track> th2( ftListHandle, hInd );
424  compTrack.insert(compTrack.begin(),th2);
425  HT2.insert(HT2.begin(),sh+"H");
426  }
427 
428  if ((!st.compare("H") || !st.compare("T")))
429  {
430  tInd = std::get<2>(ft.at(walk));
431  // std::cout << "WalkStitch(): tInd is " << tInd << std::endl;
432  const art::Ptr<recob::Track> th2( ftListHandle, tInd );
433  compTrack.insert(compTrack.begin(),th2);
434  HT2.insert(HT2.begin(),st+"T"); // since we will eventually read from 0th element forward
435  }
436  if (hInd!=-12) walk = hInd;
437  if (tInd!=-12) walk = tInd;
438  if (!sh.compare("NA") && !st.compare("NA"))
439  chain = false;
440 
441  trackStatus.at(walk) = "Done";
442  } // while
443 
444 
445  // inside FirstStitch() push_back onto the vec<vec> of components and the vec of stitched composite.
446  if (compTrack.size())
447  {
448  // protect against stitching a component twice, as when somehow the same track has been matched to a
449  // head and a tail of another track. remove the repeat appearances of that track.
450  for (auto iit = compTrack.begin(); iit!=compTrack.end();++iit)
451  {
452  int cjit(0);
453  for (auto jit = iit+1; jit!=compTrack.end();++jit)
454  {
455  // std::cout<< " cjit is ." << cjit << std::endl;
456  if (*iit==*jit)
457  {
458  // std::cout<< " About to do cjit erase." << std::endl;
459  compTrack.erase(jit); //std::cout<< "Survived the compTrack jit erase." << std::endl;
460  HT2.erase(HT2.begin()+cjit); //std::cout<< "Survived the HT2 cjit erase." << std::endl;
461  break;
462  }
463  cjit++;
464  }
465  }
466  fTrackComposite.push_back(compTrack);
467  fHT.push_back(HT2);
468  // std::cout << "WalkStitch:: calling FirstStitch(). fTrackComposite.size(), fHT.size() " << fTrackComposite.size()<< ", " << fHT.size() << std::endl;
469  //std::cout << "WalkStitch:: calling FirstStitch(). fTrackComposite.back().size(), fHT.back().size() " << fTrackComposite.back().size()<< ", " << fHT.back().size() << std::endl;
470  /*
471  for (unsigned int ll=0; ll<fHT.back().size() ; ++ll)
472  {
473  std::cout << fHT.back().at(ll); std::cout << ", ";
474  }
475  std::cout << "." << std::endl;
476  */
477  // want the last vector of fTrackComposite, and will want to insert on fTrackVec, hence
478  // -1 and not -1, respectively.
479  FirstStitch(fTrackComposite.end()-1, fTrackVec.end());
480  }
481  compTrack.clear();
482  HT2.clear();
483 
484 
485  } // end ii loop on head/tail vector of tuples.
486 
487 }
488 
489  // This method will join separate composite tracks in which one common component is joined by its head in one
490  // and by its tail in another. This can happen if the common component has a higher track index than either of
491  // the the two it is separately stitched to. e.g., ____(1) -------(4) ___________(3).
492  //
494 {
495  // "os" for outer scope.
496  int osciit(-12), oscjit(-12);
497  std::vector < art::PtrVector<recob::Track> >::iterator osiComposite, osjComposite;
499 
500 
501  bool match(false);
502  int ciit(0);
503  for (auto iit = fTrackComposite.begin(); iit!=fTrackComposite.end()&&!match; ++iit)
504  {
505  ciit++;
506  int cjit(ciit);
507  for (auto jit = iit+1; jit!=fTrackComposite.end()&&!match; ++jit)
508  {
509  cjit++;
510  for (auto iiit = iit->begin(); iiit!=iit->end()&&!match; ++iiit)
511  {
512  for (auto jjit = jit->begin(); jjit!=jit->end()&&!match; ++jjit)
513  {
514  if (*iiit == *jjit) // 2 components from 2 different composites are the same
515  {
516  // head is attached to one trk and tail to another.
517  // std::cout << "StitchAlg::CommonComponentStitch: We have two aggregate tracks that have a common component and need to be further stitched. " << std::endl;
518 
519  match = true;
520  osiComposite = iit;
521  osjComposite = jit;
522  osciit = ciit;
523  oscjit = cjit;
524  osiAgg = iiit;
525  osjAgg = jjit; // yes, unneeded, but we keep it for notational clarity
526 
527  }
528  }
529 
530  }
531  }
532  }
533  if (!match) return match;
534 
535  // Proceed to stitch 'em all together, dropping the one redundant component. Then
536  // erase the first occurence of the composite and the matching aggregate trk.
537 
538 
539  // std::cout << "StitchAlg::CommonComponentStitch: pre erase: " << osiComposite->size() << std::endl;
540  (*osiComposite).erase(osiAgg); // erase redundant component track
541  // do not erase this fHT element, however
542 
543  // std::cout << "StitchAlg::CommonComponentStitch: post erase: " << osiComposite->size() << std::endl;
544  // std::cout << "StitchAlg::CommonComponentStitch: fHT.size(): " << fHT.size() << std::endl;
545 
546  // Next is a loop over all remaining components in osiComposite.
547  // insert the non-redundant osciit tracks onto front (back) of osjit
548  // insert the non-redundant osciit vtx links onto front (back) of fHT.begin()+oscjit-1
549 
550  std::vector< std::vector<std::string> >::iterator siit(fHT.begin()+osciit-1);
551  std::vector< std::vector<std::string> >::iterator sjit(fHT.begin()+oscjit-1);
552  size_t itdiff(osiComposite->end()-osiComposite->begin());
553  if (osjAgg == osjComposite->begin())
554  {
555 
556  // std::cout << "StitchAlg::begin insert starting: " << std::endl;
557  // std::cout << "StitchAlg::CommonComponentStitch: itdiff: " << itdiff << std::endl;
558  //std::cout << "StitchAlg::CommonComponentStitch: osiComposite.end-begin: " << osiComposite->end()-osiComposite->begin()<< std::endl;
559  //std::cout << "StitchAlg::CommonComponentStitch: osjComposite.end-begin: " << osjComposite->end()-osjComposite->begin()<< std::endl;
560  (*osjComposite).insert(osjComposite->begin(),osiComposite->begin(),osiComposite->begin()+itdiff);
561  //std::cout << "StitchAlg::CommonComponentStitch: siit.end-begin: " << siit->end()-siit->begin()<< std::endl;
562  //std::cout << "StitchAlg::CommonComponentStitch: sjit.end-begin: " << sjit->end()-sjit->begin()<< std::endl;
563  (*sjit).insert(sjit->begin(),siit->begin(),siit->begin()+itdiff);
564  //std::cout << "StitchAlg::begin insert done: " << std::endl;
565  }
566  else if (osjAgg == (osjComposite->end()-1))
567  {
568  // std::cout << "StitchAlg::end insert starting: " << std::endl;
569  (*osjComposite).insert(osjComposite->end(),osiComposite->begin(),osiComposite->begin()+itdiff);
570  (*sjit).insert(sjit->end(),siit->begin(),siit->begin()+itdiff);
571  // std::cout << "StitchAlg::end insert done: " << std::endl;
572  }
573 
574  // std::cout << "StitchAlg:: 1: " << std::endl;
575  fTrackVec.erase(fTrackVec.begin()+oscjit-1); // erase old Stitched Track, which we'll recreate now...
576 
577  // std::cout << "StitchAlg:: 2: " << std::endl;
578  FirstStitch(osjComposite,fTrackVec.begin()+oscjit-1); // Create new Stitched Track
579  // fTrackComposite.insert(fTrackComposite.begin()+oscjit-1-1,*osjComposite); // erase old composite Track
580  // std::cout << "StitchAlg:: 3: " << std::endl;
581  fTrackVec.erase(fTrackVec.begin()+osciit-1); // erase old Stitched Track
582  // std::cout << "StitchAlg:: 6: " << std::endl;
583  fTrackComposite.erase(osiComposite); // erase old composite Track
584  // std::cout << "StitchAlg:: 4: " << std::endl;
585  fHT.erase(fHT.begin()+osciit-1); // erase old vec of vtx links
586  // std::cout << "StitchAlg:: 5: " << std::endl;
587 
588  return match;
589 
590 } // end of bool CommonComponentStitch()
591 
std::vector< std::tuple< std::string, int, int, double, double > > fh
Definition: StitchAlg.h:49
StitchAlg(fhicl::ParameterSet const &pset)
Definition: StitchAlg.cxx:36
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
art::Handle< std::vector< recob::Track > > ftListHandle
Definition: StitchAlg.h:43
std::vector< recob::Track > fTrackVec
Definition: StitchAlg.h:57
void FindHeadsAndTails(const art::Event &e, const std::string &t)
Definition: StitchAlg.cxx:54
TVector3 VertexDirection() const
Covariance matrices are either set or not.
Definition: Track.h:247
intermediate_table::iterator iterator
bool CommonComponentStitch()
Definition: StitchAlg.cxx:493
iterator begin()
Definition: PtrVector.h:223
iterator erase(iterator position)
Definition: PtrVector.h:508
Planes which measure Z direction.
Definition: geo_types.h:79
void FirstStitch(const std::vector< art::PtrVector< recob::Track >>::iterator itvvArg, const std::vector< recob::Track >::iterator itvArg)
Definition: StitchAlg.cxx:261
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
std::vector< std::vector< std::string > > fHT
Definition: StitchAlg.h:58
double fSepTol
Definition: StitchAlg.h:53
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
T get(std::string const &key) const
Definition: ParameterSet.h:231
iterator end()
Definition: PtrVector.h:237
TMarker * pt
Definition: egs.C:25
void reconfigure(fhicl::ParameterSet const &pset)
Definition: StitchAlg.cxx:46
Definition of data types for geometry description.
data_t::iterator iterator
Definition: PtrVector.h:60
size_type size() const
Definition: PtrVector.h:308
double fCosAngTol
Definition: StitchAlg.h:52
iterator insert(iterator position, Ptr< U > const &p)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void clear()
Definition: Handle.h:237
TVector3 Vertex() const
Covariance matrices are either set or not.
Definition: Track.h:245
TVector3 EndDirection() const
Covariance matrices are either set or not.
Definition: Track.h:248
std::vector< std::tuple< std::string, int, int, double, double > > ft
Definition: StitchAlg.h:50
Float_t e
Definition: plot.C:34
TVector3 End() const
Covariance matrices are either set or not.
Definition: Track.h:246
std::vector< art::PtrVector< recob::Track > > fTrackComposite
Definition: StitchAlg.h:56
void clear()
Definition: PtrVector.h:537
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:51
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33