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

#include <CpaCrossCosmicIdAlg.h>

Classes

struct  BeamTime
 
struct  Config
 
struct  Fiducial
 

Public Member Functions

 CpaCrossCosmicIdAlg (const core::ProviderManager &manager, const Config &config)
 
 CpaCrossCosmicIdAlg (const core::ProviderManager &manager, const fhicl::ParameterSet &pset)
 
 ~CpaCrossCosmicIdAlg ()
 
void reconfigure (const Config &config)
 
std::pair< double, bool > T0FromCpaStitching (recob::Track t1, std::vector< recob::Track > tracks)
 
bool CpaCrossCosmicId (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
 
detinfo::DetectorPropertiesStandard
const * 
fDetectorProperties
 
TPCGeoAlg fTpcGeo
 

Detailed Description

Definition at line 39 of file sbnana/sbnanalysis/ana/SBNOscReco/CosmicIDAlgs/CpaCrossCosmicIdAlg.h.

Constructor & Destructor Documentation

ana::CpaCrossCosmicIdAlg::CpaCrossCosmicIdAlg ( const core::ProviderManager manager,
const Config config 
)

Definition at line 5 of file sbnana/sbnanalysis/ana/SBNOscReco/CosmicIDAlgs/CpaCrossCosmicIdAlg.cc.

5  {
6  this->reconfigure(config);
8 }
const detinfo::DetectorPropertiesStandard * GetDetectorPropertiesProvider() const
ana::CpaCrossCosmicIdAlg::CpaCrossCosmicIdAlg ( const core::ProviderManager manager,
const fhicl::ParameterSet &  pset 
)
inline

Definition at line 103 of file sbnana/sbnanalysis/ana/SBNOscReco/CosmicIDAlgs/CpaCrossCosmicIdAlg.h.

103  :
104  CpaCrossCosmicIdAlg(manager, fhicl::Table<Config>(pset, {})()) {}
CpaCrossCosmicIdAlg(const core::ProviderManager &manager, const Config &config)
ana::CpaCrossCosmicIdAlg::~CpaCrossCosmicIdAlg ( )

Member Function Documentation

bool ana::CpaCrossCosmicIdAlg::CpaCrossCosmicId ( recob::Track  track,
std::vector< recob::Track tracks,
art::FindManyP< recob::Hit hitAssoc 
)

Definition at line 107 of file sbnana/sbnanalysis/ana/SBNOscReco/CosmicIDAlgs/CpaCrossCosmicIdAlg.cc.

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

Definition at line 17 of file sbnana/sbnanalysis/ana/SBNOscReco/CosmicIDAlgs/CpaCrossCosmicIdAlg.cc.

17  {
18 
19  fCpaStitchDistance = config.CpaStitchDistance();
20  fCpaStitchAngle = config.CpaStitchAngle();
21  fCpaXDifference = config.CpaXDifference();
22  fMinX = config.FiducialCuts().MinX();
23  fMinY = config.FiducialCuts().MinY();
24  fMinZ = config.FiducialCuts().MinZ();
25  fMaxX = config.FiducialCuts().MaxX();
26  fMaxY = config.FiducialCuts().MaxY();
27  fMaxZ = config.FiducialCuts().MaxZ();
28  fBeamTimeMin = config.BeamTimeLimits().BeamTimeMin();
29  fBeamTimeMax = config.BeamTimeLimits().BeamTimeMax();
30 
31  return;
32 }
std::pair< double, bool > ana::CpaCrossCosmicIdAlg::T0FromCpaStitching ( recob::Track  t1,
std::vector< recob::Track tracks 
)

Definition at line 35 of file sbnana/sbnanalysis/ana/SBNOscReco/CosmicIDAlgs/CpaCrossCosmicIdAlg.cc.

35  {
36 
37  std::vector<std::pair<double, std::pair<double, bool>>> matchCandidates;
38  double matchedTime = -99999;
39  std::pair<double, bool> returnVal = std::make_pair(matchedTime, false);
40 
41  TVector3 trk1Front = t1.Vertex<TVector3>();
42  TVector3 trk1Back = t1.End<TVector3>();
43  double closestX1 = std::min(std::abs(trk1Front.X()), std::abs(trk1Back.X()));
44 
45  // Loop over all tracks in other TPC
46  for(auto & track : tracks){
47 
48  TVector3 trk2Front = track.Vertex<TVector3>();
49  TVector3 trk2Back = track.End<TVector3>();
50  double closestX2 = std::min(std::abs(trk2Front.X()), std::abs(trk2Back.X()));
51 
52  // Try to match if their ends have similar x positions
53  if(std::abs(closestX1-closestX2) > fCpaXDifference) continue;
54 
55  // Find which point is closest to CPA
56  TVector3 t1Pos = trk1Front;
57  TVector3 t1PosEnd = trk1Back;
58  TVector3 t1Dir = t1.VertexDirection<TVector3>();
59  if(std::abs(trk1Back.X()) == closestX1){
60  t1Pos = trk1Back;
61  t1PosEnd = trk1Front;
62  t1Dir = t1.EndDirection<TVector3>();
63  }
64 
65  TVector3 t2Pos = trk2Front;
66  TVector3 t2PosEnd = trk2Back;
67  TVector3 t2Dir = track.VertexDirection<TVector3>();
68  if(std::abs(trk2Back.X()) == closestX2){
69  t2Pos = trk2Back;
70  t2PosEnd = trk2Front;
71  t2Dir = track.EndDirection<TVector3>();
72  }
73 
74  // Calculate the angle between the tracks
75  double trkCos = std::abs(t1Dir.Dot(t2Dir));
76  // Calculate the distance between the tracks at the middle of the CPA
77  t1Pos[0] = 0.;
78  t2Pos[0] = 0.;
79  double dist = (t1Pos-t2Pos).Mag();
80 
81  // Does the track enter and exit the fiducial volume when merged?
82  geo::Point_t mergeStart {t1PosEnd.X(), t1PosEnd.Y(), t1PosEnd.Z()};
83  geo::Point_t mergeEnd {t2PosEnd.X(), t2PosEnd.Y(), t2PosEnd.Z()};
84  bool exits = false;
85  if(!fTpcGeo.InFiducial(mergeStart, fMinX, fMinY, fMinZ, fMaxX, fMaxY, fMaxZ)
86  && !fTpcGeo.InFiducial(mergeEnd, fMinX, fMinY, fMinZ, fMaxX, fMaxY, fMaxZ)) exits = true;
87 
88  // If the distance and angle are within the acceptable limits then record candidate
89  if(dist < fCpaStitchDistance && trkCos > cos(TMath::Pi() * fCpaStitchAngle / 180.)){
90  matchCandidates.push_back(std::make_pair(trkCos, std::make_pair(closestX1, exits)));
91  }
92  }
93 
94  // Choose the candidate with the smallest angle
95  if(matchCandidates.size() > 0){
96  std::sort(matchCandidates.begin(), matchCandidates.end(), [](auto& left, auto& right){
97  return left.first < right.first;});
98  double shiftX = matchCandidates[0].second.first;
99  matchedTime = -((shiftX - fTpcGeo.CpaWidth())/fDetectorProperties->DriftVelocity()); //subtract CPA width
100  returnVal = std::make_pair(matchedTime, matchCandidates[0].second.second);
101  }
102 
103  return returnVal;
104 }
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
double DriftVelocity(double efield=0., double temperature=0.) const override
cm/us
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

Member Data Documentation

double ana::CpaCrossCosmicIdAlg::fBeamTimeMax
private
double ana::CpaCrossCosmicIdAlg::fBeamTimeMin
private
double ana::CpaCrossCosmicIdAlg::fCpaStitchAngle
private
double ana::CpaCrossCosmicIdAlg::fCpaStitchDistance
private
double ana::CpaCrossCosmicIdAlg::fCpaXDifference
private
detinfo::DetectorPropertiesStandard const* ana::CpaCrossCosmicIdAlg::fDetectorProperties
private
double ana::CpaCrossCosmicIdAlg::fMaxX
private
double ana::CpaCrossCosmicIdAlg::fMaxY
private
double ana::CpaCrossCosmicIdAlg::fMaxZ
private
double ana::CpaCrossCosmicIdAlg::fMinX
private
double ana::CpaCrossCosmicIdAlg::fMinY
private
double ana::CpaCrossCosmicIdAlg::fMinZ
private
TPCGeoAlg ana::CpaCrossCosmicIdAlg::fTpcGeo
private

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