LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
CosmicTracker_module.cc
Go to the documentation of this file.
1 //
3 // CosmicTracker
4 //
5 // Tracker to reconstruct cosmic ray muons and neutrino interactions
6 //
7 // tjyang@fnal.gov
8 //
9 //
10 // ** Modified by Muhammad Elnimr to check multiple TPCs for the 35t prototype.
11 //
12 // mmelnimr@as.ua.edu
13 // April 2014
14 //
15 // Major modifications to separate algorithms from the module and
16 // use Bruce's TrackTrajectoryAlg to get trajectory points. T. Yang
17 // June 2015
19 
20 // C++ includes
21 #include <math.h>
22 #include <algorithm>
23 #include <iostream>
24 #include <iomanip>
25 #include <fstream>
26 #include <vector>
27 #include <string>
28 
29 // Framework includes
34 #include "fhiclcpp/ParameterSet.h"
42 
43 // LArSoft includes
54 
55 // ROOT includes
56 #include "TVectorD.h"
57 #include "TF1.h"
58 #include "TGraph.h"
59 #include "TMath.h"
60 #include "TH1D.h"
61 #include "TVirtualFitter.h"
62 
63 struct trkPoint{
64 public:
65  TVector3 pos;
66  TVector3 dir; //direction cosines
68 };
69 
70 bool AnglesConsistent(const TVector3& p1, const TVector3& p2, const TVector3& a1, const TVector3& a2, double angcut){
71  double angle1 = a1.Angle(a2);
72  if (angle1>TMath::PiOver2()) angle1 = TMath::Pi() - angle1;
73  double angle2 = a1.Angle(p1-p2);
74  if (angle2>TMath::PiOver2()) angle2 = TMath::Pi() - angle2;
75  if (angle1<angcut&&angle2<angcut) return true;
76  else return false;
77 }
78 
79 // compare end points and directions
80 bool MatchTrack(const std::vector<trkPoint>& trkpts1, const std::vector<trkPoint>& trkpts2, double discut, double angcut){
81  bool match = false;
82  if (!trkpts1.size()) return match;
83  if (!trkpts2.size()) return match;
84  if ((trkpts1[0].hit)->WireID().Cryostat == (trkpts2[0].hit)->WireID().Cryostat &&
85  (trkpts1[0].hit)->WireID().TPC == (trkpts2[0].hit)->WireID().TPC) return match;
86 // art::ServiceHandle<geo::Geometry> geom;
87 // const geo::TPCGeo &thetpc1 = geom->TPC((trkpts1[0].hit)->WireID().TPC, (trkpts1[0].hit)->WireID().Cryostat);
88 // const geo::TPCGeo &thetpc2 = geom->TPC((trkpts2[0].hit)->WireID().TPC, (trkpts2[0].hit)->WireID().Cryostat);
89 
90  //std::cout<<trkpts1[0].pos.Y()<<" "<<trkpts1.back().pos.Y()<<" "<<trkpts1[0].pos.Z()<<" "<<trkpts1.back().pos.Z()<<std::endl;
91  //std::cout<<trkpts2[0].pos.Y()<<" "<<trkpts2.back().pos.Y()<<" "<<trkpts2[0].pos.Z()<<" "<<trkpts2.back().pos.Z()<<std::endl;
92 
93 // if (thetpc1.InFiducialY(trkpts1[0].pos.Y(),5)&&
94 // thetpc1.InFiducialY(trkpts1.back().pos.Y(),5)&&
95 // thetpc1.InFiducialZ(trkpts1[0].pos.Z(),5)&&
96 // thetpc1.InFiducialZ(trkpts1.back().pos.Z(),5)) return match;
97 // //std::cout<<"pass 1"<<std::endl;
98 // if (thetpc2.InFiducialY(trkpts2[0].pos.Y(),5)&&
99 // thetpc2.InFiducialY(trkpts2.back().pos.Y(),5)&&
100 // thetpc2.InFiducialZ(trkpts2[0].pos.Z(),5)&&
101 // thetpc2.InFiducialZ(trkpts2.back().pos.Z(),5)) return match;
102 // //std::cout<<"pass 2"<<std::endl;
103 
104  if (AnglesConsistent(trkpts1[0].pos, trkpts2[0].pos,
105  trkpts1[0].dir, trkpts2[0].dir, angcut)) match = true;
106  if (AnglesConsistent(trkpts1.back().pos, trkpts2[0].pos,
107  trkpts1.back().dir, trkpts2[0].dir, angcut)) match = true;
108  if (AnglesConsistent(trkpts1[0].pos, trkpts2.back().pos,
109  trkpts1[0].dir, trkpts2.back().dir, angcut)) match = true;
110  if (AnglesConsistent(trkpts1.back().pos, trkpts2.back().pos,
111  trkpts1.back().dir, trkpts2.back().dir, angcut)) match = true;
112 
113  return match;
114 }
115 
117  return h1->WireID().Wire < h2->WireID().Wire;
118 }
119 
120 bool sp_sort_x0(const trkPoint &tp1, const trkPoint &tp2)
121 {
122  return tp1.pos.X() < tp2.pos.X();
123 }
124 
125 bool sp_sort_x1(const trkPoint &tp1, const trkPoint &tp2)
126 {
127  return tp1.pos.X() > tp2.pos.X();
128 }
129 
130 bool sp_sort_y0(const trkPoint &tp1, const trkPoint &tp2)
131 {
132  return tp1.pos.Y() < tp2.pos.Y();
133 }
134 
135 bool sp_sort_y1(const trkPoint &tp1, const trkPoint &tp2)
136 {
137  return tp1.pos.Y() > tp2.pos.Y();
138 }
139 
140 bool sp_sort_z0(const trkPoint &tp1, const trkPoint &tp2)
141 {
142  return tp1.pos.Z() < tp2.pos.Z();
143 }
144 
145 bool sp_sort_z1(const trkPoint &tp1, const trkPoint &tp2)
146 {
147  return tp1.pos.Z() > tp2.pos.Z();
148 }
149 
151 {
152  const double* xyz1 = h1.XYZ();
153  const double* xyz2 = h2.XYZ();
154  return xyz1[0] < xyz2[0];
155 }
156 
158 {
159  const double* xyz1 = h1.XYZ();
160  const double* xyz2 = h2.XYZ();
161  return xyz1[0] > xyz2[0];
162 }
163 
165 {
166  const double* xyz1 = h1.XYZ();
167  const double* xyz2 = h2.XYZ();
168  return xyz1[1] < xyz2[1];
169 }
170 
172 {
173  const double* xyz1 = h1.XYZ();
174  const double* xyz2 = h2.XYZ();
175  return xyz1[1] > xyz2[1];
176 }
177 
179 {
180  const double* xyz1 = h1.XYZ();
181  const double* xyz2 = h2.XYZ();
182  return xyz1[2] < xyz2[2];
183 }
184 
186 {
187  const double* xyz1 = h1.XYZ();
188  const double* xyz2 = h2.XYZ();
189  return xyz1[2] > xyz2[2];
190 }
191 
192 
193 namespace trkf {
194 
196 
197  public:
198 
199  explicit CosmicTracker(fhicl::ParameterSet const& pset);
200 
202  void reconfigure(fhicl::ParameterSet const& p);
203  void produce(art::Event& evt);
204  void beginJob();
205  void endJob();
206 
207  private:
208 
211 
212  std::string fClusterModuleLabel;
213 
214  std::string fSortDir;
215 
217  double fDisCut;
218  double fAngCut;
219 
220  bool fTrajOnly;
221 
222 
223  }; // class CosmicTracker
224 
225 }
226 
227 namespace trkf {
228 
229  //-------------------------------------------------
230  CosmicTracker::CosmicTracker(fhicl::ParameterSet const& pset) :
231  fClusterMatch(pset.get< fhicl::ParameterSet >("ClusterMatch")),
232  fCTAlg(pset.get< fhicl::ParameterSet >("CTAlg"))
233  {
234  this->reconfigure(pset);
235  produces< std::vector<recob::Track> >();
236  produces< std::vector<recob::SpacePoint> >();
237  produces< art::Assns<recob::Track, recob::Cluster> >();
238  produces< art::Assns<recob::Track, recob::SpacePoint> >();
239  produces< art::Assns<recob::SpacePoint, recob::Hit> >();
240  produces< art::Assns<recob::Track, recob::Hit> >();
241 
242  }
243 
244  //-------------------------------------------------
246  {
247  fClusterModuleLabel = pset.get< std::string >("ClusterModuleLabel");
248  fSortDir = pset.get< std::string >("SortDirection","+z");
249  fStitchTracks = pset.get< bool >("StitchTracks");
250  fDisCut = pset.get< double >("DisCut");
251  fAngCut = pset.get< double >("AngCut");
252  fTrajOnly = pset.get< bool >("TrajOnly");
253  }
254 
255  //-------------------------------------------------
257  {
258  }
259 
260  //-------------------------------------------------
262  {
263  }
264 
265  //------------------------------------------------------------------------------------//
267 
268  // get services
270 
271  std::unique_ptr<std::vector<recob::Track> > tcol (new std::vector<recob::Track>);
272  std::unique_ptr<std::vector<recob::SpacePoint> > spcol(new std::vector<recob::SpacePoint>);
273  std::unique_ptr<art::Assns<recob::Track, recob::SpacePoint> > tspassn(new art::Assns<recob::Track, recob::SpacePoint>);
274  std::unique_ptr<art::Assns<recob::Track, recob::Cluster> > tcassn(new art::Assns<recob::Track, recob::Cluster>);
275  std::unique_ptr<art::Assns<recob::Track, recob::Hit> > thassn(new art::Assns<recob::Track, recob::Hit>);
276  std::unique_ptr<art::Assns<recob::SpacePoint, recob::Hit> > shassn(new art::Assns<recob::SpacePoint, recob::Hit>);
277 
278  //double timetick = detprop->SamplingRate()*1e-3; //time sample in us
279  //double presamplings = detprop->TriggerOffset(); // presamplings in ticks
280  //double plane_pitch = geom->PlanePitch(0,1); //wire plane pitch in cm
281  //double wire_pitch = geom->WirePitch(); //wire pitch in cm
282  //double Efield_drift = larprop->Efield(0); // Electric Field in the drift region in kV/cm
283  //double Temperature = detprop->Temperature(); // LAr Temperature in K
284 
285  //double driftvelocity = larprop->DriftVelocity(Efield_drift,Temperature); //drift velocity in the drift region (cm/us)
286  //double timepitch = driftvelocity*timetick; //time sample (cm)
287 
288 
289  // get input Cluster object(s).
290  art::Handle< std::vector<recob::Cluster> > clusterListHandle;
291  std::vector<art::Ptr<recob::Cluster> > clusterlist;
292  if (evt.getByLabel(fClusterModuleLabel,clusterListHandle))
293  art::fill_ptr_vector(clusterlist, clusterListHandle);
294 
295  art::FindManyP<recob::Hit> fm(clusterListHandle, evt, fClusterModuleLabel);
296 
297  // find matched clusters
298  fClusterMatch.ClusterMatch(clusterlist,fm);
299  std::vector<std::vector<unsigned int> > &matchedclusters = fClusterMatch.matchedclusters;
300 
301  // get track space points
302  std::vector<std::vector<trkPoint>> trkpts(matchedclusters.size());
303  for (size_t itrk = 0; itrk<matchedclusters.size(); ++itrk){//loop over tracks
304 
305  std::vector<art::Ptr<recob::Hit> > hitlist;
306  for (size_t iclu = 0; iclu<matchedclusters[itrk].size(); ++iclu){//loop over clusters
307 
308  std::vector< art::Ptr<recob::Hit> > hits = fm.at(matchedclusters[itrk][iclu]);
309  for (size_t ihit = 0; ihit<hits.size(); ++ihit){
310  hitlist.push_back(hits[ihit]);
311  }
312  }
313  //reconstruct space points and directions
314  fCTAlg.SPTReco(hitlist);
315  if (!fTrajOnly){
316  if (!fCTAlg.trkPos.size()) continue;
317  for (size_t i = 0; i<hitlist.size(); ++i){
318  trkPoint trkpt;
319  trkpt.pos = fCTAlg.trkPos[i];
320  trkpt.dir = fCTAlg.trkDir[i];
321  trkpt.hit = hitlist[i];
322  trkpts[itrk].push_back(trkpt);
323  }
324  if (fSortDir=="+x") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_x0);
325  if (fSortDir=="-x") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_x1);
326  if (fSortDir=="+y") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_y0);
327  if (fSortDir=="-y") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_y1);
328  if (fSortDir=="+z") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_z0);
329  if (fSortDir=="-z") std::sort(trkpts[itrk].begin(),trkpts[itrk].end(),sp_sort_z1);
330  }
331 
332  if (fTrajOnly){//debug only
333  if (!fCTAlg.trajPos.size()) continue;
334  size_t spStart = spcol->size();
335  std::vector<recob::SpacePoint> spacepoints;
336  // for (size_t ihit = 0; ihit<hitlist.size(); ++ihit){
337  // if (fCTAlg.usehit[ihit] == 1){
338  for (size_t ipt = 0; ipt<fCTAlg.trajPos.size(); ++ipt){
340  //sp_hits.push_back(hitlist[ihit]);
341  double hitcoord[3];
342  hitcoord[0] = fCTAlg.trajPos[ipt].X();
343  hitcoord[1] = fCTAlg.trajPos[ipt].Y();
344  hitcoord[2] = fCTAlg.trajPos[ipt].Z();
345 // if (itrk==1){
346 // std::cout<<"hitcoord "<<hitcoord[0]<<" "<<hitcoord[1]<<" "<<hitcoord[2]<<std::endl;
347 // }
348  double err[6] = {util::kBogusD};
349  recob::SpacePoint mysp(hitcoord,
350  err,
351  util::kBogusD,
352  spStart + spacepoints.size());//3d point at end of track
353  spacepoints.push_back(mysp);
354  spcol->push_back(mysp);
355  util::CreateAssn(*this, evt, *spcol, fCTAlg.trajHit[ipt], *shassn);
356  //}//
357  }//ihit
358  size_t spEnd = spcol->size();
359  //sort in z direction
360  //std::sort(spacepoints.begin(),spacepoints.end(),sp_sort_z0);
361  //std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,sp_sort_z0);
362  if (fSortDir == "+x"){
363  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_x0);
364  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_x0);
365  }
366  if (fSortDir == "-x"){
367  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_x1);
368  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_x1);
369  }
370  if (fSortDir == "+y"){
371  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_y0);
372  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_y0);
373  }
374  if (fSortDir == "-y"){
375  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_y1);
376  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_y1);
377  }
378  if (fSortDir == "+z"){
379  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_z0);
380  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_z0);
381  }
382  if (fSortDir == "-z"){
383  std::sort(spacepoints.begin(),spacepoints.end(),spt_sort_z1);
384  std::sort(spcol->begin()+spStart,spcol->begin()+spEnd,spt_sort_z1);
385  }
386 
387  if(spacepoints.size()>0){
388 
389  // make a vector of the trajectory points along the track
390  std::vector<TVector3> xyz(spacepoints.size());
391  for(size_t s = 0; s < spacepoints.size(); ++s){
392  xyz[s] = TVector3(spacepoints[s].XYZ());
393  }
394  //Calculate track direction cosines
395  TVector3 startpointVec,endpointVec, DirCos;
396  startpointVec = xyz[0];
397  endpointVec = xyz.back();
398  DirCos = endpointVec - startpointVec;
399  //SetMag casues a crash if the magnitude of the vector is zero
400  try
401  {
402  DirCos.SetMag(1.0);//normalize vector
403  }
404  catch(...){std::cout<<"The Spacepoint is infinitely small"<<std::endl;
405  continue;
406  }
407  //std::cout<<DirCos.x()<<" "<<DirCos.y()<<" "<<DirCos.z()<<std::endl;
408  std::vector<TVector3> dircos(spacepoints.size(), DirCos);
409 
412  recob::Track::Flags_t(xyz.size()), false),
413  0, -1., 0, recob::tracking::SMatrixSym55(), recob::tracking::SMatrixSym55(), tcol->size()));
414 
415  // make associations between the track and space points
416  util::CreateAssn(*this, evt, *tcol, *spcol, *tspassn, spStart, spEnd);
417 
418  // now the track and clusters
419  //util::CreateAssn(*this, evt, *tcol, clustersPerTrack, *tcassn);
420 
421  // and the hits and track
422  std::vector<art::Ptr<recob::Hit> > trkhits;
423  for (size_t ihit = 0; ihit<hitlist.size(); ++ihit){
424  //if (fCTAlg.usehit[ihit] == 1){
425  trkhits.push_back(hitlist[ihit]);
426  //}
427  }
428  util::CreateAssn(*this, evt, *tcol, trkhits, *thassn);
429  }
430  }
431  }//itrk
432 
433  // by default creates a spacepoint and direction for each hit
434  if (!fTrajOnly){
435  std::vector<std::vector<unsigned int>> trkidx;
436  //stitch tracks from different TPCs
437  if (fStitchTracks){
438  for (size_t itrk1 = 0; itrk1<trkpts.size(); ++itrk1){
439  for (size_t itrk2 = itrk1+1; itrk2<trkpts.size(); ++itrk2){
440  if (MatchTrack(trkpts[itrk1], trkpts[itrk2], fDisCut, fAngCut)){
441  int found1 = -1;
442  int found2 = -1;
443  for (size_t i = 0; i<trkidx.size(); ++i){
444  for (size_t j = 0; j<trkidx[i].size(); ++j){
445  if (trkidx[i][j]==itrk1) found1 = i;
446  if (trkidx[i][j]==itrk2) found2 = i;
447  }
448  }
449  //std::cout<<itrk1<<" "<<itrk2<<" "<<found1<<" "<<found2<<std::endl;
450  if (found1==-1&&found2==-1){
451  std::vector<unsigned int> tmp;
452  tmp.push_back(itrk1);
453  tmp.push_back(itrk2);
454  trkidx.push_back(tmp);
455  }
456  else if(found1==-1&&found2!=-1){
457  trkidx[found2].push_back(itrk1);
458  }
459  else if(found1!=-1&&found2==-1){
460  trkidx[found1].push_back(itrk2);
461  }
462  else if (found1!=found2){//merge two vectors
463  trkidx[found1].insert(trkidx[found1].end(),
464  trkidx[found2].begin(),
465  trkidx[found2].end());
466  trkidx.erase(trkidx.begin()+found2);
467  }
468  }//found match
469  }//itrk2
470  }//itrk1
471  for (size_t itrk = 0; itrk<trkpts.size(); ++itrk){
472  bool found = false;
473  for (size_t i = 0; i<trkidx.size(); ++i){
474  for (size_t j = 0; j<trkidx[i].size(); ++j){
475  if (trkidx[i][j]==itrk) found = true;
476  }
477  }
478  if (!found) {
479  std::vector<unsigned int> tmp;
480  tmp.push_back(itrk);
481  trkidx.push_back(tmp);
482  }
483  }
484  }//stitch
485  else{
486  trkidx.resize(trkpts.size());
487  for (size_t i = 0; i<trkpts.size(); ++i){
488  trkidx[i].push_back(i);
489  }
490  }
491 
492  //make recob::track and associations
493  for (size_t i = 0; i<trkidx.size(); ++i){
494  //all track points
495  std::vector<trkPoint> finaltrkpts;
496  //all the clusters associated with the current track
497  std::vector<art::Ptr<recob::Cluster>> clustersPerTrack;
498  //all hits
499  std::vector<art::Ptr<recob::Hit> > hitlist;
500  for(size_t j = 0; j<trkidx[i].size(); ++j){
501  for (size_t k = 0; k<trkpts[trkidx[i][j]].size(); ++k){
502  finaltrkpts.push_back(trkpts[trkidx[i][j]][k]);
503  hitlist.push_back(trkpts[trkidx[i][j]][k].hit);
504  }//k
505  for (size_t iclu = 0; iclu<matchedclusters[trkidx[i][j]].size(); ++iclu){
506  art::Ptr <recob::Cluster> cluster(clusterListHandle,matchedclusters[trkidx[i][j]][iclu]);
507  clustersPerTrack.push_back(cluster);
508  }
509 
510  }//j
511  if (fStitchTracks){
512  if (fSortDir=="+x") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_x0);
513  if (fSortDir=="-x") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_x1);
514  if (fSortDir=="+y") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_y0);
515  if (fSortDir=="-y") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_y1);
516  if (fSortDir=="+z") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_z0);
517  if (fSortDir=="-z") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_z1);
518  }
519  size_t spStart = spcol->size();
520  std::vector<recob::SpacePoint> spacepoints;
521  for (size_t ipt = 0; ipt<finaltrkpts.size(); ++ipt){
523  sp_hits.push_back(finaltrkpts[ipt].hit);
524  double hitcoord[3];
525  hitcoord[0] = finaltrkpts[ipt].pos.X();
526  hitcoord[1] = finaltrkpts[ipt].pos.Y();
527  hitcoord[2] = finaltrkpts[ipt].pos.Z();
528  //std::cout<<"hitcoord "<<hitcoord[0]<<" "<<hitcoord[1]<<" "<<hitcoord[2]<<std::endl;
529  double err[6] = {util::kBogusD};
530  recob::SpacePoint mysp(hitcoord,
531  err,
532  util::kBogusD,
533  spStart + spacepoints.size());//3d point at end of track
534  spacepoints.push_back(mysp);
535  spcol->push_back(mysp);
536  util::CreateAssn(*this, evt, *spcol, sp_hits, *shassn);
537  }//ipt
538  size_t spEnd = spcol->size();
539  if(spacepoints.size()>0){
540  // make a vector of the trajectory points along the track
541  std::vector<TVector3> xyz(spacepoints.size());
542  std::vector<TVector3> dircos(spacepoints.size());
543  for(size_t s = 0; s < spacepoints.size(); ++s){
544  xyz[s] = TVector3(spacepoints[s].XYZ());
545  dircos[s] = finaltrkpts[s].dir;
546  //flip direction if needed.
547  if (spacepoints.size()>1){
548  if (s==0){
549  TVector3 xyz1 = TVector3(spacepoints[s+1].XYZ());
550  TVector3 dir = xyz1-xyz[s];
551  if (dir.Angle(dircos[s])>0.8*TMath::Pi()){
552  dircos[s] = -dircos[s];
553  }
554  }
555  else{
556  TVector3 dir = xyz[s]-xyz[s-1];
557  if (dir.Angle(dircos[s])>0.8*TMath::Pi()){
558  dircos[s] = -dircos[s];
559  }
560  }
561  }
562  //std::cout<<s<<" "<<xyz[s].X()<<" "<<xyz[s].Y()<<" "<<xyz[s].Z()<<" "<<dircos[s].X()<<" "<<dircos[s].Y()<<" "<<dircos[s].Z()<<std::endl;
563  }
566  recob::Track::Flags_t(xyz.size()), false),
567  0, -1., 0, recob::tracking::SMatrixSym55(), recob::tracking::SMatrixSym55(), tcol->size()));
568 
569  // make associations between the track and space points
570  util::CreateAssn(*this, evt, *tcol, *spcol, *tspassn, spStart, spEnd);
571 
572  // now the track and clusters
573  util::CreateAssn(*this, evt, *tcol, clustersPerTrack, *tcassn);
574 
575  // and the hits and track
576  std::vector<art::Ptr<recob::Hit> > trkhits;
577  for (size_t ihit = 0; ihit<hitlist.size(); ++ihit){
578  //if (fCTAlg.usehit[ihit] == 1){
579  trkhits.push_back(hitlist[ihit]);
580  //}
581  }
582  util::CreateAssn(*this, evt, *tcol, trkhits, *thassn);
583  }
584 
585  }//i
586  }
587  mf::LogVerbatim("Summary") << std::setfill('-')
588  << std::setw(175)
589  << "-"
590  << std::setfill(' ');
591  mf::LogVerbatim("Summary") << "CosmicTracker Summary:";
592  for(unsigned int i = 0; i<tcol->size(); ++i) mf::LogVerbatim("Summary") << tcol->at(i) ;
593  mf::LogVerbatim("Summary") << "CosmicTracker Summary End:";
594 
595  evt.put(std::move(tcol));
596  evt.put(std::move(spcol));
597  evt.put(std::move(tspassn));
598  evt.put(std::move(tcassn));
599  evt.put(std::move(thassn));
600  evt.put(std::move(shassn));
601 
602  return;
603  }
604 
606 
607 } // namespace
bool spt_sort_x1(const recob::SpacePoint h1, const recob::SpacePoint h2)
Float_t s
Definition: plot.C:23
bool sp_sort_x1(const trkPoint &tp1, const trkPoint &tp2)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void SPTReco(std::vector< art::Ptr< recob::Hit > > &fHits)
bool sp_sort_y1(const trkPoint &tp1, const trkPoint &tp2)
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 > > SMatrixSym55
Definition: TrackingTypes.h:85
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
Definition: TrackingTypes.h:58
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
Declaration of signal hit object.
TrackTrajectory::Flags_t Flags_t
Definition: Track.h:71
std::vector< TVector3 > trajPos
bool sp_sort_z1(const trkPoint &tp1, const trkPoint &tp2)
bool MatchTrack(const std::vector< trkPoint > &trkpts1, const std::vector< trkPoint > &trkpts2, double discut, double angcut)
art::Ptr< recob::Hit > hit
std::vector< TVector3 > trkDir
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:313
Float_t tmp
Definition: plot.C:37
bool fTrajOnly
Only use trajectory points from TrackTrajectoryAlg for debugging.
Cluster finding and building.
trkf::CosmicTrackerAlg fCTAlg
bool fStitchTracks
Stitch tracks from different TPCs.
void reconfigure(fhicl::ParameterSet const &p)
double fAngCut
Angle cut for track merging.
bool sp_sort_z0(const trkPoint &tp1, const trkPoint &tp2)
bool sp_sort_y0(const trkPoint &tp1, const trkPoint &tp2)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
bool sp_sort_x0(const trkPoint &tp1, const trkPoint &tp2)
#define a2
bool AnglesConsistent(const TVector3 &p1, const TVector3 &p2, const TVector3 &a1, const TVector3 &a2, double angcut)
void hits()
Definition: readHits.C:15
bool SortByWire(art::Ptr< recob::Hit > const &h1, art::Ptr< recob::Hit > const &h2)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
Provides recob::Track data product.
void beginJob()
Definition: Breakpoints.cc:14
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
A trajectory in space reconstructed from hits.
parameter set interface
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< std::vector< unsigned int > > matchedclusters
bool spt_sort_y0(const recob::SpacePoint h1, const recob::SpacePoint h2)
bool spt_sort_z1(const recob::SpacePoint h1, const recob::SpacePoint h2)
void ClusterMatch(const std::vector< art::Ptr< recob::Cluster > > &clusterlist, const art::FindManyP< recob::Hit > &fm)
void produce(art::Event &evt)
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
const Double32_t * XYZ() const
Definition: SpacePoint.h:65
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
Definition: TrackingTypes.h:55
cluster::ClusterMatchTQ fClusterMatch
Declaration of cluster object.
double fDisCut
Distance cut for track merging.
Detector simulation of raw signals on wires.
TH1F * h2
Definition: plot.C:46
Encapsulate the geometry of a wire.
std::vector< TVector3 > trkPos
std::string fClusterModuleLabel
label for input cluster collection
bool spt_sort_z0(const recob::SpacePoint h1, const recob::SpacePoint h2)
Utility object to perform functions of association.
Encapsulate the construction of a single detector plane.
TDirectory * dir
Definition: macro.C:5
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
bool spt_sort_x0(const recob::SpacePoint h1, const recob::SpacePoint h2)
bool spt_sort_y1(const recob::SpacePoint h1, const recob::SpacePoint h2)
TH1F * h1
Definition: plot.C:43
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
constexpr double kBogusD
obviously bogus double value
TCEvent evt
Definition: DataStructs.cxx:5
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
std::string fSortDir
sort space points
art framework interface to geometry description
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:52
#define a1
std::vector< std::vector< art::Ptr< recob::Hit > > > trajHit