LArSoft  v06_85_00
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 
410  std::vector< std::vector<double> > dQdx;
411  std::vector<double> mom(2, util::kBogusD);
412  tcol->push_back(recob::Track(xyz, dircos, dQdx, mom, tcol->size()));
413 
414  // make associations between the track and space points
415  util::CreateAssn(*this, evt, *tcol, *spcol, *tspassn, spStart, spEnd);
416 
417  // now the track and clusters
418  //util::CreateAssn(*this, evt, *tcol, clustersPerTrack, *tcassn);
419 
420  // and the hits and track
421  std::vector<art::Ptr<recob::Hit> > trkhits;
422  for (size_t ihit = 0; ihit<hitlist.size(); ++ihit){
423  //if (fCTAlg.usehit[ihit] == 1){
424  trkhits.push_back(hitlist[ihit]);
425  //}
426  }
427  util::CreateAssn(*this, evt, *tcol, trkhits, *thassn);
428  }
429  }
430  }//itrk
431 
432  // by default creates a spacepoint and direction for each hit
433  if (!fTrajOnly){
434  std::vector<std::vector<unsigned int>> trkidx;
435  //stitch tracks from different TPCs
436  if (fStitchTracks){
437  for (size_t itrk1 = 0; itrk1<trkpts.size(); ++itrk1){
438  for (size_t itrk2 = itrk1+1; itrk2<trkpts.size(); ++itrk2){
439  if (MatchTrack(trkpts[itrk1], trkpts[itrk2], fDisCut, fAngCut)){
440  int found1 = -1;
441  int found2 = -1;
442  for (size_t i = 0; i<trkidx.size(); ++i){
443  for (size_t j = 0; j<trkidx[i].size(); ++j){
444  if (trkidx[i][j]==itrk1) found1 = i;
445  if (trkidx[i][j]==itrk2) found2 = i;
446  }
447  }
448  //std::cout<<itrk1<<" "<<itrk2<<" "<<found1<<" "<<found2<<std::endl;
449  if (found1==-1&&found2==-1){
450  std::vector<unsigned int> tmp;
451  tmp.push_back(itrk1);
452  tmp.push_back(itrk2);
453  trkidx.push_back(tmp);
454  }
455  else if(found1==-1&&found2!=-1){
456  trkidx[found2].push_back(itrk1);
457  }
458  else if(found1!=-1&&found2==-1){
459  trkidx[found1].push_back(itrk2);
460  }
461  else if (found1!=found2){//merge two vectors
462  trkidx[found1].insert(trkidx[found1].end(),
463  trkidx[found2].begin(),
464  trkidx[found2].end());
465  trkidx.erase(trkidx.begin()+found2);
466  }
467  }//found match
468  }//itrk2
469  }//itrk1
470  for (size_t itrk = 0; itrk<trkpts.size(); ++itrk){
471  bool found = false;
472  for (size_t i = 0; i<trkidx.size(); ++i){
473  for (size_t j = 0; j<trkidx[i].size(); ++j){
474  if (trkidx[i][j]==itrk) found = true;
475  }
476  }
477  if (!found) {
478  std::vector<unsigned int> tmp;
479  tmp.push_back(itrk);
480  trkidx.push_back(tmp);
481  }
482  }
483  }//stitch
484  else{
485  trkidx.resize(trkpts.size());
486  for (size_t i = 0; i<trkpts.size(); ++i){
487  trkidx[i].push_back(i);
488  }
489  }
490 
491  //make recob::track and associations
492  for (size_t i = 0; i<trkidx.size(); ++i){
493  //all track points
494  std::vector<trkPoint> finaltrkpts;
495  //all the clusters associated with the current track
496  std::vector<art::Ptr<recob::Cluster>> clustersPerTrack;
497  //all hits
498  std::vector<art::Ptr<recob::Hit> > hitlist;
499  for(size_t j = 0; j<trkidx[i].size(); ++j){
500  for (size_t k = 0; k<trkpts[trkidx[i][j]].size(); ++k){
501  finaltrkpts.push_back(trkpts[trkidx[i][j]][k]);
502  hitlist.push_back(trkpts[trkidx[i][j]][k].hit);
503  }//k
504  for (size_t iclu = 0; iclu<matchedclusters[trkidx[i][j]].size(); ++iclu){
505  art::Ptr <recob::Cluster> cluster(clusterListHandle,matchedclusters[trkidx[i][j]][iclu]);
506  clustersPerTrack.push_back(cluster);
507  }
508 
509  }//j
510  if (fStitchTracks){
511  if (fSortDir=="+x") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_x0);
512  if (fSortDir=="-x") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_x1);
513  if (fSortDir=="+y") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_y0);
514  if (fSortDir=="-y") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_y1);
515  if (fSortDir=="+z") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_z0);
516  if (fSortDir=="-z") std::sort(finaltrkpts.begin(),finaltrkpts.end(),sp_sort_z1);
517  }
518  size_t spStart = spcol->size();
519  std::vector<recob::SpacePoint> spacepoints;
520  for (size_t ipt = 0; ipt<finaltrkpts.size(); ++ipt){
522  sp_hits.push_back(finaltrkpts[ipt].hit);
523  double hitcoord[3];
524  hitcoord[0] = finaltrkpts[ipt].pos.X();
525  hitcoord[1] = finaltrkpts[ipt].pos.Y();
526  hitcoord[2] = finaltrkpts[ipt].pos.Z();
527  //std::cout<<"hitcoord "<<hitcoord[0]<<" "<<hitcoord[1]<<" "<<hitcoord[2]<<std::endl;
528  double err[6] = {util::kBogusD};
529  recob::SpacePoint mysp(hitcoord,
530  err,
531  util::kBogusD,
532  spStart + spacepoints.size());//3d point at end of track
533  spacepoints.push_back(mysp);
534  spcol->push_back(mysp);
535  util::CreateAssn(*this, evt, *spcol, sp_hits, *shassn);
536  }//ipt
537  size_t spEnd = spcol->size();
538  if(spacepoints.size()>0){
539  // make a vector of the trajectory points along the track
540  std::vector<TVector3> xyz(spacepoints.size());
541  std::vector<TVector3> dircos(spacepoints.size());
542  for(size_t s = 0; s < spacepoints.size(); ++s){
543  xyz[s] = TVector3(spacepoints[s].XYZ());
544  dircos[s] = finaltrkpts[s].dir;
545  //flip direction if needed.
546  if (spacepoints.size()>1){
547  if (s==0){
548  TVector3 xyz1 = TVector3(spacepoints[s+1].XYZ());
549  TVector3 dir = xyz1-xyz[s];
550  if (dir.Angle(dircos[s])>0.8*TMath::Pi()){
551  dircos[s] = -dircos[s];
552  }
553  }
554  else{
555  TVector3 dir = xyz[s]-xyz[s-1];
556  if (dir.Angle(dircos[s])>0.8*TMath::Pi()){
557  dircos[s] = -dircos[s];
558  }
559  }
560  }
561  //std::cout<<s<<" "<<xyz[s].X()<<" "<<xyz[s].Y()<<" "<<xyz[s].Z()<<" "<<dircos[s].X()<<" "<<dircos[s].Y()<<" "<<dircos[s].Z()<<std::endl;
562  }
563  std::vector< std::vector<double> > dQdx;
564  std::vector<double> mom(2, util::kBogusD);
565  tcol->push_back(recob::Track(xyz, dircos, dQdx, mom, tcol->size()));
566 
567  // make associations between the track and space points
568  util::CreateAssn(*this, evt, *tcol, *spcol, *tspassn, spStart, spEnd);
569 
570  // now the track and clusters
571  util::CreateAssn(*this, evt, *tcol, clustersPerTrack, *tcassn);
572 
573  // and the hits and track
574  std::vector<art::Ptr<recob::Hit> > trkhits;
575  for (size_t ihit = 0; ihit<hitlist.size(); ++ihit){
576  //if (fCTAlg.usehit[ihit] == 1){
577  trkhits.push_back(hitlist[ihit]);
578  //}
579  }
580  util::CreateAssn(*this, evt, *tcol, trkhits, *thassn);
581  }
582 
583  }//i
584  }
585  mf::LogVerbatim("Summary") << std::setfill('-')
586  << std::setw(175)
587  << "-"
588  << std::setfill(' ');
589  mf::LogVerbatim("Summary") << "CosmicTracker Summary:";
590  for(unsigned int i = 0; i<tcol->size(); ++i) mf::LogVerbatim("Summary") << tcol->at(i) ;
591  mf::LogVerbatim("Summary") << "CosmicTracker Summary End:";
592 
593  evt.put(std::move(tcol));
594  evt.put(std::move(spcol));
595  evt.put(std::move(tspassn));
596  evt.put(std::move(tcassn));
597  evt.put(std::move(thassn));
598  evt.put(std::move(shassn));
599 
600  return;
601  }
602 
604 
605 } // 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)
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
Declaration of signal hit object.
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
void beginJob()
Definition: Breakpoints.cc:14
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
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.
cluster::ClusterMatchTQ fClusterMatch
Declaration of cluster object.
Provides recob::Track data product.
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
const double * XYZ() const
Definition: SpacePoint.h:64
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
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:51
#define a1
std::vector< std::vector< art::Ptr< recob::Hit > > > trajHit