LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
CosmicTracker_module.cc File Reference
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include "art/Framework/Core/EDProducer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "canvas/Persistency/Common/FindManyP.h"
#include "art/Framework/Principal/Event.h"
#include "fhiclcpp/ParameterSet.h"
#include "art/Framework/Principal/Handle.h"
#include "canvas/Persistency/Common/Ptr.h"
#include "canvas/Persistency/Common/PtrVector.h"
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "art/Framework/Services/Optional/TFileService.h"
#include "art/Framework/Services/Optional/TFileDirectory.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include "larcore/Geometry/Geometry.h"
#include "larcorealg/Geometry/PlaneGeo.h"
#include "larcorealg/Geometry/WireGeo.h"
#include "lardataobj/RecoBase/Hit.h"
#include "lardataobj/RecoBase/Cluster.h"
#include "lardataobj/RecoBase/Track.h"
#include "lardataobj/RecoBase/SpacePoint.h"
#include "lardata/Utilities/AssociationUtil.h"
#include "larreco/RecoAlg/ClusterMatchTQ.h"
#include "larreco/RecoAlg/CosmicTrackerAlg.h"
#include "TVectorD.h"
#include "TF1.h"
#include "TGraph.h"
#include "TMath.h"
#include "TH1D.h"
#include "TVirtualFitter.h"

Go to the source code of this file.

Classes

struct  trkPoint
 
class  trkf::CosmicTracker
 

Namespaces

 trkf
 

Functions

bool AnglesConsistent (const TVector3 &p1, const TVector3 &p2, const TVector3 &a1, const TVector3 &a2, double angcut)
 
bool MatchTrack (const std::vector< trkPoint > &trkpts1, const std::vector< trkPoint > &trkpts2, double discut, double angcut)
 
bool SortByWire (art::Ptr< recob::Hit > const &h1, art::Ptr< recob::Hit > const &h2)
 
bool sp_sort_x0 (const trkPoint &tp1, const trkPoint &tp2)
 
bool sp_sort_x1 (const trkPoint &tp1, const trkPoint &tp2)
 
bool sp_sort_y0 (const trkPoint &tp1, const trkPoint &tp2)
 
bool sp_sort_y1 (const trkPoint &tp1, const trkPoint &tp2)
 
bool sp_sort_z0 (const trkPoint &tp1, const trkPoint &tp2)
 
bool sp_sort_z1 (const trkPoint &tp1, const trkPoint &tp2)
 
bool spt_sort_x0 (const recob::SpacePoint h1, const recob::SpacePoint h2)
 
bool spt_sort_x1 (const recob::SpacePoint h1, const recob::SpacePoint h2)
 
bool spt_sort_y0 (const recob::SpacePoint h1, const recob::SpacePoint h2)
 
bool spt_sort_y1 (const recob::SpacePoint h1, const recob::SpacePoint h2)
 
bool spt_sort_z0 (const recob::SpacePoint h1, const recob::SpacePoint h2)
 
bool spt_sort_z1 (const recob::SpacePoint h1, const recob::SpacePoint h2)
 

Function Documentation

bool AnglesConsistent ( const TVector3 &  p1,
const TVector3 &  p2,
const TVector3 &  a1,
const TVector3 &  a2,
double  angcut 
)

Definition at line 70 of file CosmicTracker_module.cc.

Referenced by MatchTrack().

70  {
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 }
#define a2
#define a1
bool MatchTrack ( const std::vector< trkPoint > &  trkpts1,
const std::vector< trkPoint > &  trkpts2,
double  discut,
double  angcut 
)

Definition at line 80 of file CosmicTracker_module.cc.

References AnglesConsistent(), trkPoint::dir, and trkPoint::pos.

Referenced by trkf::CosmicTracker::produce().

80  {
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 }
bool AnglesConsistent(const TVector3 &p1, const TVector3 &p2, const TVector3 &a1, const TVector3 &a2, double angcut)
Detector simulation of raw signals on wires.
TDirectory * dir
Definition: macro.C:5
bool SortByWire ( art::Ptr< recob::Hit > const &  h1,
art::Ptr< recob::Hit > const &  h2 
)

Definition at line 116 of file CosmicTracker_module.cc.

References geo::WireID::Wire, and recob::Hit::WireID().

116  {
117  return h1->WireID().Wire < h2->WireID().Wire;
118 }
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:313
bool sp_sort_x0 ( const trkPoint tp1,
const trkPoint tp2 
)

Definition at line 120 of file CosmicTracker_module.cc.

References trkPoint::pos.

Referenced by trkf::CosmicTracker::produce().

121 {
122  return tp1.pos.X() < tp2.pos.X();
123 }
bool sp_sort_x1 ( const trkPoint tp1,
const trkPoint tp2 
)

Definition at line 125 of file CosmicTracker_module.cc.

References trkPoint::pos.

Referenced by trkf::CosmicTracker::produce().

126 {
127  return tp1.pos.X() > tp2.pos.X();
128 }
bool sp_sort_y0 ( const trkPoint tp1,
const trkPoint tp2 
)

Definition at line 130 of file CosmicTracker_module.cc.

References trkPoint::pos.

Referenced by trkf::CosmicTracker::produce().

131 {
132  return tp1.pos.Y() < tp2.pos.Y();
133 }
bool sp_sort_y1 ( const trkPoint tp1,
const trkPoint tp2 
)

Definition at line 135 of file CosmicTracker_module.cc.

References trkPoint::pos.

Referenced by trkf::CosmicTracker::produce().

136 {
137  return tp1.pos.Y() > tp2.pos.Y();
138 }
bool sp_sort_z0 ( const trkPoint tp1,
const trkPoint tp2 
)

Definition at line 140 of file CosmicTracker_module.cc.

References trkPoint::pos.

Referenced by trkf::CosmicTracker::produce().

141 {
142  return tp1.pos.Z() < tp2.pos.Z();
143 }
bool sp_sort_z1 ( const trkPoint tp1,
const trkPoint tp2 
)

Definition at line 145 of file CosmicTracker_module.cc.

References trkPoint::pos.

Referenced by trkf::CosmicTracker::produce().

146 {
147  return tp1.pos.Z() > tp2.pos.Z();
148 }
bool spt_sort_x0 ( const recob::SpacePoint  h1,
const recob::SpacePoint  h2 
)

Definition at line 150 of file CosmicTracker_module.cc.

References recob::SpacePoint::XYZ().

Referenced by trkf::CosmicTracker::produce().

151 {
152  const double* xyz1 = h1.XYZ();
153  const double* xyz2 = h2.XYZ();
154  return xyz1[0] < xyz2[0];
155 }
const double * XYZ() const
Definition: SpacePoint.h:64
bool spt_sort_x1 ( const recob::SpacePoint  h1,
const recob::SpacePoint  h2 
)

Definition at line 157 of file CosmicTracker_module.cc.

References recob::SpacePoint::XYZ().

Referenced by trkf::CosmicTracker::produce().

158 {
159  const double* xyz1 = h1.XYZ();
160  const double* xyz2 = h2.XYZ();
161  return xyz1[0] > xyz2[0];
162 }
const double * XYZ() const
Definition: SpacePoint.h:64
bool spt_sort_y0 ( const recob::SpacePoint  h1,
const recob::SpacePoint  h2 
)

Definition at line 164 of file CosmicTracker_module.cc.

References recob::SpacePoint::XYZ().

Referenced by trkf::CosmicTracker::produce().

165 {
166  const double* xyz1 = h1.XYZ();
167  const double* xyz2 = h2.XYZ();
168  return xyz1[1] < xyz2[1];
169 }
const double * XYZ() const
Definition: SpacePoint.h:64
bool spt_sort_y1 ( const recob::SpacePoint  h1,
const recob::SpacePoint  h2 
)

Definition at line 171 of file CosmicTracker_module.cc.

References recob::SpacePoint::XYZ().

Referenced by trkf::CosmicTracker::produce().

172 {
173  const double* xyz1 = h1.XYZ();
174  const double* xyz2 = h2.XYZ();
175  return xyz1[1] > xyz2[1];
176 }
const double * XYZ() const
Definition: SpacePoint.h:64
bool spt_sort_z0 ( const recob::SpacePoint  h1,
const recob::SpacePoint  h2 
)

Definition at line 178 of file CosmicTracker_module.cc.

References recob::SpacePoint::XYZ().

Referenced by trkf::CosmicTracker::produce().

179 {
180  const double* xyz1 = h1.XYZ();
181  const double* xyz2 = h2.XYZ();
182  return xyz1[2] < xyz2[2];
183 }
const double * XYZ() const
Definition: SpacePoint.h:64
bool spt_sort_z1 ( const recob::SpacePoint  h1,
const recob::SpacePoint  h2 
)

Definition at line 185 of file CosmicTracker_module.cc.

References recob::SpacePoint::XYZ().

Referenced by trkf::CosmicTracker::produce().

186 {
187  const double* xyz1 = h1.XYZ();
188  const double* xyz2 = h2.XYZ();
189  return xyz1[2] > xyz2[2];
190 }
const double * XYZ() const
Definition: SpacePoint.h:64