All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Private Attributes | List of all members
sbnd::CpaCrossCosmicIdAlg Class Reference

#include <CpaCrossCosmicIdAlg.h>

Classes

struct  BeamTime
 
struct  Config
 
struct  Fiducial
 

Public Member Functions

 CpaCrossCosmicIdAlg (const Config &config)
 
 CpaCrossCosmicIdAlg (const fhicl::ParameterSet &pset)
 
 ~CpaCrossCosmicIdAlg ()
 
void reconfigure (const Config &config)
 
std::pair< double, bool > T0FromCpaStitching (detinfo::DetectorPropertiesData const &detProp, recob::Track t1, std::vector< recob::Track > tracks)
 
bool CpaCrossCosmicId (detinfo::DetectorPropertiesData const &detProp, recob::Track track, std::vector< recob::Track > tracks, art::FindManyP< recob::Hit > hitAssoc)
 

Private Attributes

double fCpaStitchDistance
 
double fCpaStitchAngle
 
double fCpaXDifference
 
double fMinX
 
double fMinY
 
double fMinZ
 
double fMaxX
 
double fMaxY
 
double fMaxZ
 
double fBeamTimeMin
 
double fBeamTimeMax
 
TPCGeoAlg fTpcGeo
 

Detailed Description

Definition at line 38 of file sbndcode/sbndcode/CosmicId/Algs/CpaCrossCosmicIdAlg.h.

Constructor & Destructor Documentation

sbnd::CpaCrossCosmicIdAlg::CpaCrossCosmicIdAlg ( const Config config)

Definition at line 7 of file sbndcode/sbndcode/CosmicId/Algs/CpaCrossCosmicIdAlg.cc.

7  {
8 
9  this->reconfigure(config);
10 
11 }
sbnd::CpaCrossCosmicIdAlg::CpaCrossCosmicIdAlg ( const fhicl::ParameterSet &  pset)
inline

Definition at line 102 of file sbndcode/sbndcode/CosmicId/Algs/CpaCrossCosmicIdAlg.h.

102  :
103  CpaCrossCosmicIdAlg(fhicl::Table<Config>(pset, {})()) {}
sbnd::CpaCrossCosmicIdAlg::~CpaCrossCosmicIdAlg ( )

Definition at line 19 of file sbndcode/sbndcode/CosmicId/Algs/CpaCrossCosmicIdAlg.cc.

19  {
20 
21 }

Member Function Documentation

bool sbnd::CpaCrossCosmicIdAlg::CpaCrossCosmicId ( detinfo::DetectorPropertiesData const &  detProp,
recob::Track  track,
std::vector< recob::Track tracks,
art::FindManyP< recob::Hit hitAssoc 
)

Definition at line 115 of file sbndcode/sbndcode/CosmicId/Algs/CpaCrossCosmicIdAlg.cc.

116  {
117 
118  // Sort tracks by tpc
119  std::vector<recob::Track> tpcTracksTPC0;
120  std::vector<recob::Track> tpcTracksTPC1;
121  // Loop over the tpc tracks
122  for(auto const& tpcTrack : tracks){
123  // Work out where the associated wire hits were detected
124  std::vector<art::Ptr<recob::Hit>> hits = hitAssoc.at(tpcTrack.ID());
125  int tpc = fTpcGeo.DetectedInTPC(hits);
126  double startX = tpcTrack.Start().X();
127  double endX = tpcTrack.End().X();
128  if(tpc == 0 && !(startX>0 || endX>0)) tpcTracksTPC0.push_back(tpcTrack);
129  else if(tpc == 1 && !(startX<0 || endX<0)) tpcTracksTPC1.push_back(tpcTrack);
130  }
131 
132  std::vector<art::Ptr<recob::Hit>> hits = hitAssoc.at(track.ID());
133  int tpc = fTpcGeo.DetectedInTPC(hits);
134 
135  double stitchTime = -99999;
136  bool stitchExit = false;
137  // Try to match tracks from CPA crossers
138  if(tpc == 0){
139  std::pair<double, bool> stitchResults = T0FromCpaStitching(detProp, track, tpcTracksTPC1);
140  stitchTime = stitchResults.first;
141  stitchExit = stitchResults.second;
142  }
143  else if(tpc == 1){
144  std::pair<double, bool> stitchResults = T0FromCpaStitching(detProp, track, tpcTracksTPC0);
145  stitchTime = stitchResults.first;
146  stitchExit = stitchResults.second;
147  }
148 
149  // If tracks are stitched, get time and remove any outside of beam window
150  if(stitchTime != -99999 && (stitchTime < fBeamTimeMin || stitchTime > fBeamTimeMax || stitchExit)) return true;
151 
152  return false;
153 
154 }
std::pair< double, bool > T0FromCpaStitching(detinfo::DetectorPropertiesData const &detProp, recob::Track t1, std::vector< recob::Track > tracks)
int DetectedInTPC(std::vector< art::Ptr< recob::Hit >> hits)
auto const detProp
void sbnd::CpaCrossCosmicIdAlg::reconfigure ( const Config config)

Definition at line 24 of file sbndcode/sbndcode/CosmicId/Algs/CpaCrossCosmicIdAlg.cc.

24  {
25 
26  fCpaStitchDistance = config.CpaStitchDistance();
27  fCpaStitchAngle = config.CpaStitchAngle();
28  fCpaXDifference = config.CpaXDifference();
29  fMinX = config.FiducialCuts().MinX();
30  fMinY = config.FiducialCuts().MinY();
31  fMinZ = config.FiducialCuts().MinZ();
32  fMaxX = config.FiducialCuts().MaxX();
33  fMaxY = config.FiducialCuts().MaxY();
34  fMaxZ = config.FiducialCuts().MaxZ();
35  fBeamTimeMin = config.BeamTimeLimits().BeamTimeMin();
36  fBeamTimeMax = config.BeamTimeLimits().BeamTimeMax();
37 
38  return;
39 }
std::pair< double, bool > sbnd::CpaCrossCosmicIdAlg::T0FromCpaStitching ( detinfo::DetectorPropertiesData const &  detProp,
recob::Track  t1,
std::vector< recob::Track tracks 
)

Definition at line 42 of file sbndcode/sbndcode/CosmicId/Algs/CpaCrossCosmicIdAlg.cc.

43  {
44 
45  std::vector<std::pair<double, std::pair<double, bool>>> matchCandidates;
46  double matchedTime = -99999;
47  std::pair<double, bool> returnVal = std::make_pair(matchedTime, false);
48 
49  TVector3 trk1Front = t1.Vertex<TVector3>();
50  TVector3 trk1Back = t1.End<TVector3>();
51  double closestX1 = std::min(std::abs(trk1Front.X()), std::abs(trk1Back.X()));
52 
53  // Loop over all tracks in other TPC
54  for(auto & track : tracks){
55 
56  TVector3 trk2Front = track.Vertex<TVector3>();
57  TVector3 trk2Back = track.End<TVector3>();
58  double closestX2 = std::min(std::abs(trk2Front.X()), std::abs(trk2Back.X()));
59 
60  // Try to match if their ends have similar x positions
61  if(std::abs(closestX1-closestX2) > fCpaXDifference) continue;
62 
63  // Find which point is closest to CPA
64  TVector3 t1Pos = trk1Front;
65  TVector3 t1PosEnd = trk1Back;
66  TVector3 t1Dir = t1.VertexDirection<TVector3>();
67  if(std::abs(trk1Back.X()) == closestX1){
68  t1Pos = trk1Back;
69  t1PosEnd = trk1Front;
70  t1Dir = t1.EndDirection<TVector3>();
71  }
72 
73  TVector3 t2Pos = trk2Front;
74  TVector3 t2PosEnd = trk2Back;
75  TVector3 t2Dir = track.VertexDirection<TVector3>();
76  if(std::abs(trk2Back.X()) == closestX2){
77  t2Pos = trk2Back;
78  t2PosEnd = trk2Front;
79  t2Dir = track.EndDirection<TVector3>();
80  }
81 
82  // Calculate the angle between the tracks
83  double trkCos = std::abs(t1Dir.Dot(t2Dir));
84  // Calculate the distance between the tracks at the middle of the CPA
85  t1Pos[0] = 0.;
86  t2Pos[0] = 0.;
87  double dist = (t1Pos-t2Pos).Mag();
88 
89  // Does the track enter and exit the fiducial volume when merged?
90  geo::Point_t mergeStart {t1PosEnd.X(), t1PosEnd.Y(), t1PosEnd.Z()};
91  geo::Point_t mergeEnd {t2PosEnd.X(), t2PosEnd.Y(), t2PosEnd.Z()};
92  bool exits = false;
93  if(!fTpcGeo.InFiducial(mergeStart, fMinX, fMinY, fMinZ, fMaxX, fMaxY, fMaxZ)
94  && !fTpcGeo.InFiducial(mergeEnd, fMinX, fMinY, fMinZ, fMaxX, fMaxY, fMaxZ)) exits = true;
95 
96  // If the distance and angle are within the acceptable limits then record candidate
97  if(dist < fCpaStitchDistance && trkCos > cos(TMath::Pi() * fCpaStitchAngle / 180.)){
98  matchCandidates.push_back(std::make_pair(trkCos, std::make_pair(closestX1, exits)));
99  }
100  }
101 
102  // Choose the candidate with the smallest angle
103  if(matchCandidates.size() > 0){
104  std::sort(matchCandidates.begin(), matchCandidates.end(), [](auto& left, auto& right){
105  return left.first < right.first;});
106  double shiftX = matchCandidates[0].second.first;
107  matchedTime = -((shiftX - fTpcGeo.CpaWidth())/detProp.DriftVelocity()); //subtract CPA width
108  returnVal = std::make_pair(matchedTime, matchCandidates[0].second.second);
109  }
110 
111  return returnVal;
112 }
walls no right
Definition: selectors.fcl:105
Vector_t VertexDirection() const
process_name use argoneut_mc_hitfinder track
T abs(T value)
Point_t const & Vertex() const
walls no left
Definition: selectors.fcl:105
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
Vector_t EndDirection() const
Point_t const & End() const
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
auto const detProp
bool InFiducial(geo::Point_t point, double fiducial)

Member Data Documentation

double sbnd::CpaCrossCosmicIdAlg::fBeamTimeMax
private
double sbnd::CpaCrossCosmicIdAlg::fBeamTimeMin
private
double sbnd::CpaCrossCosmicIdAlg::fCpaStitchAngle
private
double sbnd::CpaCrossCosmicIdAlg::fCpaStitchDistance
private
double sbnd::CpaCrossCosmicIdAlg::fCpaXDifference
private
double sbnd::CpaCrossCosmicIdAlg::fMaxX
private
double sbnd::CpaCrossCosmicIdAlg::fMaxY
private
double sbnd::CpaCrossCosmicIdAlg::fMaxZ
private
double sbnd::CpaCrossCosmicIdAlg::fMinX
private
double sbnd::CpaCrossCosmicIdAlg::fMinY
private
double sbnd::CpaCrossCosmicIdAlg::fMinZ
private
TPCGeoAlg sbnd::CpaCrossCosmicIdAlg::fTpcGeo
private

The documentation for this class was generated from the following files: