LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
pma Namespace Reference

Classes

class  bDistCenterLess2D
 
class  bDistCenterLess3D
 
class  bSegmentProjLess
 
struct  bTrack3DLonger
 
struct  bTrajectory3DDistLess
 
struct  bTrajectory3DOrderLess
 
class  Element3D
 
class  Hit3D
 
class  Node3D
 
class  PMAlgCosmicTagger
 
class  PMAlgFitter
 
class  PMAlgStitching
 
class  PMAlgTracker
 
class  PMAlgTrackingBase
 
class  PMAlgVertexing
 
class  ProjectionMatchingAlg
 
class  Segment3D
 
class  SortedBranchBase
 
class  SortedObjectBase
 
class  Track3D
 
class  TrkCandidate
 
class  TrkCandidateColl
 
class  VtxCandidate
 

Typedefs

typedef std::map< unsigned int, std::vector< art::Ptr< recob::Hit > > > view_hitmap
 
typedef std::map< unsigned int, view_hitmaptpc_view_hitmap
 
typedef std::map< unsigned int, tpc_view_hitmapcryo_tpc_view_hitmap
 
typedef ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double > > Vector2D
 
typedef recob::tracking::Vector_t Vector3D
 
typedef std::map< size_t, std::vector< double > > dedx_map
 
typedef std::map< size_t, pma::TrkCandidateColltpc_track_map
 

Functions

double Dist2 (const TVector2 &v1, const TVector2 &v2)
 
double Dist2 (const Vector2D &v1, const Vector2D &v2)
 
double Dist2 (const TVector3 &v1, const TVector3 &v2)
 
double Dist2 (const Vector3D &v1, const Vector3D &v2)
 
size_t GetHitsCount (const std::vector< pma::Hit3D * > &hits, unsigned int view)
 
double GetSummedADC (const std::vector< pma::Hit3D * > &hits, unsigned int view=geo::kUnknown)
 
double GetSummedAmpl (const std::vector< pma::Hit3D * > &hits, unsigned int view=geo::kUnknown)
 
double GetHitsRadius3D (const std::vector< pma::Hit3D * > &hits, bool exact=false)
 
double GetHitsRadius2D (const std::vector< pma::Hit3D * > &hits, bool exact=false)
 
double GetSegmentProjVector (const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
 
double GetSegmentProjVector (const Vector2D &p, const Vector2D &p0, const Vector2D &p1)
 
double GetSegmentProjVector (const TVector3 &p, const TVector3 &p0, const TVector3 &p1)
 
double GetSegmentProjVector (const Vector3D &p, const Vector3D &p0, const Vector3D &p1)
 
TVector2 GetProjectionToSegment (const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
 
TVector3 GetProjectionToSegment (const TVector3 &p, const TVector3 &p0, const TVector3 &p1)
 
double SolveLeastSquares3D (const std::vector< std::pair< TVector3, TVector3 > > &lines, TVector3 &result)
 
TVector2 GetProjectionToPlane (const TVector3 &p, unsigned int plane, unsigned int tpc, unsigned int cryo)
 
TVector2 GetVectorProjectionToPlane (const TVector3 &v, unsigned int plane, unsigned int tpc, unsigned int cryo)
 
TVector2 WireDriftToCm (unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo)
 
TVector2 CmToWireDrift (float xw, float yd, unsigned int plane, unsigned int tpc, unsigned int cryo)
 
recob::Track convertFrom (const pma::Track3D &src, unsigned int tidx, int pdg=0)
 

Typedef Documentation

typedef std::map< unsigned int, tpc_view_hitmap > pma::cryo_tpc_view_hitmap

Definition at line 22 of file PmaTrkCandidate.h.

typedef std::map< size_t, std::vector<double> > pma::dedx_map

Definition at line 31 of file Utilities.h.

typedef std::map< size_t, pma::TrkCandidateColl > pma::tpc_track_map

Definition at line 46 of file PMAlgTracking.h.

typedef std::map< unsigned int, view_hitmap > pma::tpc_view_hitmap

Definition at line 21 of file PmaTrkCandidate.h.

typedef ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D<double> > pma::Vector2D

Definition at line 28 of file Utilities.h.

Definition at line 29 of file Utilities.h.

typedef std::map< unsigned int, std::vector< art::Ptr<recob::Hit> > > pma::view_hitmap

Definition at line 20 of file PmaTrkCandidate.h.

Function Documentation

TVector2 pma::CmToWireDrift ( float  xw,
float  yd,
unsigned int  plane,
unsigned int  tpc,
unsigned int  cryo 
)

Definition at line 318 of file Utilities.cxx.

References detinfo::DetectorProperties::ConvertXToTicks(), geo::TPCGeo::Plane(), geo::GeometryCore::TPC(), and geo::PlaneGeo::WirePitch().

Referenced by pma::Track3D::DriftsOfWireIntersection(), and pma::Track3D::WireDriftRange().

319 {
321  const detinfo::DetectorProperties* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
322 
323  return TVector2(
324  xw / geom->TPC(tpc, cryo).Plane(plane).WirePitch(),
325  detprop->ConvertXToTicks(yd, plane, tpc, cryo)
326  );
327 }
virtual double ConvertXToTicks(double X, int p, int t, int c) const =0
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:298
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:367
recob::Track pma::convertFrom ( const pma::Track3D src,
unsigned int  tidx,
int  pdg = 0 
)

Definition at line 21 of file PMAlgTracking.cxx.

References pma::Track3D::GetDirection3D(), recob::TrajectoryPointFlags::makeMask(), and pma::Track3D::size().

Referenced by trkf::PMAlgTrajFitter::produce(), and trkf::PMAlgTrackMaker::produce().

22 {
23  std::vector<Point_t> positions; positions.reserve(src.size());
24  std::vector<Vector_t> momenta; momenta.reserve(src.size());
25  std::vector<recob::TrajectoryPointFlags> outFlags; outFlags.reserve(src.size());
26 
27  for (size_t i = 0, h = 0; i < src.size(); i++)
28  if (src[i]->IsEnabled())
29  {
30  auto const & point3d = src[i]->Point3D();
31  positions.emplace_back(point3d.X(), point3d.Y(), point3d.Z());
32  momenta.push_back(src.GetDirection3D(i));
33  outFlags.emplace_back(h++, recob::TrajectoryPointFlags::makeMask());
34  }
35 
36  int ndof = 0;
37  float totChi2 = 0;
38 
39  SMatrixSym55 covStart, covEnd;
40  return recob::Track(
41  recob::TrackTrajectory(std::move(positions), std::move(momenta), std::move(outFlags), false),
42  pdg, totChi2, ndof, covStart, covEnd, tidx);
43 }
static constexpr Mask_t makeMask(Flags...flags)
Returns a bit mask with only the specified bit set.
pma::Vector3D GetDirection3D(size_t index) const
Get trajectory direction at given hit index.
Definition: PmaTrack3D.cxx:373
A trajectory in space reconstructed from hits.
recob::tracking::SMatrixSym55 SMatrixSym55
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1035
size_t size() const
Definition: PmaTrack3D.h:76
double pma::Dist2 ( const TVector2 &  v1,
const TVector2 &  v2 
)

Definition at line 19 of file Utilities.cxx.

Referenced by pma::ProjectionMatchingAlg::alignTracks(), ems::MultiEMShowers::analyze(), pma::PMAlgTracker::areCoLinear(), pma::Track3D::AttachTo(), pma::ProjectionMatchingAlg::buildMultiTPCTrack(), tss::Segmentation2D::buildSegment(), pma::ProjectionMatchingAlg::buildSegment(), tss::Cluster2D::closest(), ems::MergeEMShower3D::collectshowers(), pma::PMAlgTracker::collectSingleViewEnd(), pma::PMAlgTracker::collectSingleViewFront(), ems::DirOfGamma::ComputeMaxDist(), tss::Cluster2D::dist2(), pma::ProjectionMatchingAlg::FilterOutSmallParts(), ems::DirOfGamma::FindCandidates(), ems::DirOfGamma::FindInitialPart(), ems::MergeEMShower3D::getBestPoint(), ems::EMShower3D::GetCloseHits(), pma::ProjectionMatchingAlg::GetCloseHits(), ems::MergeEMShower3D::getCos3D(), pma::Hit3D::GetDist2ToProj(), pma::Node3D::GetDistance2To(), GetHitsRadius2D(), GetHitsRadius3D(), ems::Bin2D::GetIniHits(), ems::MultiEMShowers::getMinDist(), pma::Track3D::HitDxByView(), pma::Element3D::HitsRadius3D(), pma::Track3D::InitFromHits(), pma::VtxCandidate::JoinTracks(), pma::Track3D::Length(), tss::Cluster2D::length2(), pma::Segment3D::Length2(), pma::PMAlgVertexing::makeVertices(), pma::PMAlgTracker::mergeCoLinear(), tss::Segmentation2D::mergeDenseParts(), pma::ProjectionMatchingAlg::mergeTracks(), pma::VtxCandidate::MergeWith(), tss::bDistToPointLess::operator()(), pma::bTrack3DLonger::operator()(), pma::bDistCenterLess2D::operator()(), pma::bDistCenterLess3D::operator()(), tss::Cluster2D::outermost(), ems::MergeEMShower3D::produce(), ems::EMShower3D::Reoptimize(), tss::Segmentation2D::run(), tss::Segmentation2D::selectRing(), ems::ShowerInfo::SetP0Dist(), pma::ProjectionMatchingAlg::ShortenSeg(), tss::Segmentation2D::splitHitsNaive(), pma::Node3D::SumDist2Hits(), tss::Segmentation2D::tagDenseEnds(), pma::ProjectionMatchingAlg::TestTrk(), ems::EMShower3D::Validate(), pma::ProjectionMatchingAlg::validate(), and pma::ProjectionMatchingAlg::validate_on_adc_test().

20 {
21  double dx = v1.X() - v2.X(), dy = v1.Y() - v2.Y();
22  return dx * dx + dy * dy;
23 }
double pma::Dist2 ( const Vector2D v1,
const Vector2D v2 
)

Definition at line 24 of file Utilities.cxx.

25 {
26  double dx = v1.X() - v2.X(), dy = v1.Y() - v2.Y();
27  return dx * dx + dy * dy;
28 }
double pma::Dist2 ( const TVector3 &  v1,
const TVector3 &  v2 
)

Definition at line 30 of file Utilities.cxx.

31 {
32  double dx = v1.X() - v2.X(), dy = v1.Y() - v2.Y(), dz = v1.Z() - v2.Z();
33  return dx * dx + dy * dy + dz * dz;
34 }
double pma::Dist2 ( const Vector3D v1,
const Vector3D v2 
)

Definition at line 35 of file Utilities.cxx.

36 {
37  double dx = v1.X() - v2.X(), dy = v1.Y() - v2.Y(), dz = v1.Z() - v2.Z();
38  return dx * dx + dy * dy + dz * dz;
39 }
size_t pma::GetHitsCount ( const std::vector< pma::Hit3D * > &  hits,
unsigned int  view 
)

Definition at line 41 of file Utilities.cxx.

References geo::kUnknown, and n.

42 {
43  size_t n = 0;
44  for (auto const& hit : hits)
45  if ((view == geo::kUnknown) || (view == hit->View2D())) n++;
46  return n;
47 }
Unknown view.
Definition: geo_types.h:83
Detector simulation of raw signals on wires.
Char_t n[5]
double pma::GetHitsRadius2D ( const std::vector< pma::Hit3D * > &  hits,
bool  exact = false 
)

Definition at line 89 of file Utilities.cxx.

References Dist2(), and pmtana::mean().

Referenced by pma::Element3D::UpdateHitParams(), and pma::Track3D::UpdateHitsRadius().

90 {
91  if (!exact && (hits.size() < 5)) return 0.0;
92 
93  if (hits.size() == 0) return 0.0;
94 
95  TVector2 mean(0, 0);
96  for (size_t i = 0; i < hits.size(); i++)
97  {
98  mean += hits[i]->Point2D();
99  }
100  mean *= (1.0 / hits.size());
101 
102  double r2, max_r2 = pma::Dist2(hits.front()->Point2D(), mean);
103  for (size_t i = 1; i < hits.size(); i++)
104  {
105  r2 = pma::Dist2(hits[i]->Point2D(), mean);
106  if (r2 > max_r2) max_r2 = r2;
107  }
108  return sqrt(max_r2);
109 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:15
double pma::GetHitsRadius3D ( const std::vector< pma::Hit3D * > &  hits,
bool  exact = false 
)

Definition at line 67 of file Utilities.cxx.

References Dist2(), and pmtana::mean().

68 {
69  if (!exact && (hits.size() < 5)) return 0.0;
70 
71  if (hits.size() == 0) return 0.0;
72 
73  TVector3 mean(0, 0, 0);
74  for (size_t i = 0; i < hits.size(); i++)
75  {
76  mean += hits[i]->Point3D();
77  }
78  mean *= (1.0 / hits.size());
79 
80  double r2, max_r2 = pma::Dist2(hits.front()->Point3D(), mean);
81  for (size_t i = 1; i < hits.size(); i++)
82  {
83  r2 = pma::Dist2(hits[i]->Point3D(), mean);
84  if (r2 > max_r2) max_r2 = r2;
85  }
86  return sqrt(max_r2);
87 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:15
TVector2 pma::GetProjectionToPlane ( const TVector3 &  p,
unsigned int  plane,
unsigned int  tpc,
unsigned int  cryo 
)

Definition at line 291 of file Utilities.cxx.

References geo::TPCGeo::Plane(), geo::PlaneGeo::PlaneCoordinate(), and geo::GeometryCore::TPC().

Referenced by pma::ProjectionMatchingAlg::buildShowerSeg(), pma::VtxCandidate::ComputeMse2D(), ems::MultiEMShowers::getMinDist(), GetVectorProjectionToPlane(), and ems::EMShower3D::Validate().

292 {
294 
295  return TVector2(geom->TPC(tpc, cryo).Plane(plane).PlaneCoordinate(p), p.X());
296 }
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:298
double PlaneCoordinate(geo::Point_t const &point) const
Returns the coordinate of the point on the plane.
Definition: PlaneGeo.h:704
TVector2 pma::GetProjectionToSegment ( const TVector2 &  p,
const TVector2 &  p0,
const TVector2 &  p1 
)

Definition at line 167 of file Utilities.cxx.

References GetSegmentProjVector().

Referenced by pma::PMAlgTracker::areCoLinear(), tss::Segmentation2D::buildSegment(), ems::MergeEMShower3D::collectshowers(), pma::VtxCandidate::Compute(), pma::VtxCandidate::JoinTracks(), ems::ShowerInfo::Pointsto(), and SolveLeastSquares3D().

168 {
169  TVector2 v1(p1); v1 -= p0;
170 
171  double b = GetSegmentProjVector(p, p0, p1);
172  TVector2 r(p0);
173  r += (v1 * b);
174  return r;
175 }
double GetSegmentProjVector(const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
Definition: Utilities.cxx:111
TVector3 pma::GetProjectionToSegment ( const TVector3 &  p,
const TVector3 &  p0,
const TVector3 &  p1 
)

Definition at line 177 of file Utilities.cxx.

References GetSegmentProjVector().

178 {
179  TVector3 v1(p1); v1 -= p0;
180 
181  double b = GetSegmentProjVector(p, p0, p1);
182  TVector3 r(p0);
183  r += (v1 * b);
184  return r;
185 }
double GetSegmentProjVector(const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
Definition: Utilities.cxx:111
double pma::GetSegmentProjVector ( const TVector2 &  p,
const TVector2 &  p0,
const TVector2 &  p1 
)

Definition at line 111 of file Utilities.cxx.

Referenced by GetProjectionToSegment(), pma::VtxCandidate::JoinTracks(), pma::bSegmentProjLess::operator()(), pma::ProjectionMatchingAlg::validate(), pma::ProjectionMatchingAlg::validate_on_adc(), and pma::ProjectionMatchingAlg::validate_on_adc_test().

112 {
113  TVector2 v0(p); v0 -= p0;
114  TVector2 v1(p1); v1 -= p0;
115 
116  double v0Norm = v0.Mod();
117  double v1Norm = v1.Mod();
118  double mag = v0Norm * v1Norm;
119  double cosine = 0.0;
120  if (mag != 0.0) cosine = v0 * v1 / mag;
121 
122  return v0Norm * cosine / v1Norm;
123 }
double pma::GetSegmentProjVector ( const Vector2D p,
const Vector2D p0,
const Vector2D p1 
)

Definition at line 125 of file Utilities.cxx.

126 {
127  pma::Vector2D v0(p); v0 -= p0;
128  pma::Vector2D v1(p1); v1 -= p0;
129 
130  double v0Norm = v0.R();
131  double v1Norm = v1.R();
132  double mag = v0Norm * v1Norm;
133  double cosine = 0.0;
134  if (mag != 0.0) cosine = v0.Dot(v1) / mag;
135 
136  return v0Norm * cosine / v1Norm;
137 }
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double > > Vector2D
Definition: Utilities.h:28
double pma::GetSegmentProjVector ( const TVector3 &  p,
const TVector3 &  p0,
const TVector3 &  p1 
)

Definition at line 139 of file Utilities.cxx.

140 {
141  TVector3 v0(p); v0 -= p0;
142  TVector3 v1(p1); v1 -= p0;
143 
144  double v0Norm = v0.Mag();
145  double v1Norm = v1.Mag();
146  double mag = v0Norm * v1Norm;
147  double cosine = 0.0;
148  if (mag != 0.0) cosine = v0 * v1 / mag;
149 
150  return v0Norm * cosine / v1Norm;
151 }
double pma::GetSegmentProjVector ( const Vector3D p,
const Vector3D p0,
const Vector3D p1 
)

Definition at line 153 of file Utilities.cxx.

154 {
155  pma::Vector3D v0(p); v0 -= p0;
156  pma::Vector3D v1(p1); v1 -= p0;
157 
158  double v0Norm = v0.R();
159  double v1Norm = v1.R();
160  double mag = v0Norm * v1Norm;
161  double cosine = 0.0;
162  if (mag != 0.0) cosine = v0.Dot(v1) / mag;
163 
164  return v0Norm * cosine / v1Norm;
165 }
recob::tracking::Vector_t Vector3D
Definition: Utilities.h:29
double pma::GetSummedADC ( const std::vector< pma::Hit3D * > &  hits,
unsigned int  view = geo::kUnknown 
)

Definition at line 49 of file Utilities.cxx.

References geo::kUnknown.

50 {
51  double sum = 0.0;
52  for (auto const& hit : hits)
53  if ((view == geo::kUnknown) || (view == hit->View2D()))
54  sum += hit->SummedADC();
55  return sum;
56 }
Unknown view.
Definition: geo_types.h:83
Detector simulation of raw signals on wires.
double pma::GetSummedAmpl ( const std::vector< pma::Hit3D * > &  hits,
unsigned int  view = geo::kUnknown 
)

Definition at line 58 of file Utilities.cxx.

References geo::kUnknown.

59 {
60  double sum = 0.0;
61  for (auto const& hit : hits)
62  if ((view == geo::kUnknown) || (view == hit->View2D()))
63  sum += hit->GetAmplitude();
64  return sum;
65 }
Unknown view.
Definition: geo_types.h:83
Detector simulation of raw signals on wires.
TVector2 pma::GetVectorProjectionToPlane ( const TVector3 &  v,
unsigned int  plane,
unsigned int  tpc,
unsigned int  cryo 
)

Definition at line 298 of file Utilities.cxx.

References GetProjectionToPlane().

299 {
300  TVector3 v0_3d(0., 0., 0.);
301  TVector2 v0_2d = GetProjectionToPlane(v0_3d, plane, tpc, cryo);
302  TVector2 v1_2d = GetProjectionToPlane(v, plane, tpc, cryo);
303 
304  return v1_2d - v0_2d;
305 }
TVector2 GetProjectionToPlane(const TVector3 &p, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:291
double pma::SolveLeastSquares3D ( const std::vector< std::pair< TVector3, TVector3 > > &  lines,
TVector3 &  result 
)

Definition at line 187 of file Utilities.cxx.

References dir, GetProjectionToSegment(), w, x, and y.

Referenced by ems::MultiEMShowers::analyze(), ems::MergeEMShower3D::collectshowers(), pma::VtxCandidate::Compute(), and ems::ShowerInfo::Pointsto().

188 {
189  // RS: please, ask me if you need examples/explanation of formulas as they
190  // are not easy to derive from the code solely; I have Mathcad sources that
191  // were used to test the solving method, weighting, etc.
192 
193  result.SetXYZ(0., 0., 0.);
194  if (lines.size() < 2)
195  {
196  mf::LogError("pma::SolveLeastSquares3D") << "Need min. two lines.";
197  return -1.0;
198  }
199 
200  double m;
201  std::vector< TVectorT<double> > U, P;
202  for (size_t v = 0; v < lines.size(); v++)
203  {
204  TVector3 point = lines[v].first;
205  TVector3 dir = lines[v].second;
206  dir -= point; m = dir.Mag();
207  if (m > 0.0)
208  {
209  dir *= 1.0 / m;
210 
211  P.push_back(TVectorT<double>(3));
212  P.back()[0] = point.X(); P.back()[1] = point.Y(); P.back()[2] = point.Z();
213 
214  U.push_back(TVectorT<double>(3));
215  U.back()[0] = dir.X(); U.back()[1] = dir.Y(); U.back()[2] = dir.Z();
216  }
217  else mf::LogWarning("pma::SolveLeastSquares3D") << "Line undefined.";
218  }
219  if (P.size() < 2)
220  {
221  mf::LogError("pma::SolveLeastSquares3D") << "Need min. two lines.";
222  return -1.0;
223  }
224 
225  TVectorT<double> x(3), y(3), w(3);
226  TMatrixT<double> A(3, 3);
227  double ur, uc, pc;
228  double s_uc2[3], s_ur_uc[3];
229  double s_p_uc2[3], s_p_ur_uc[3];
230 
231  w[0] = 1.0; w[1] = 1.0; w[2] = 1.0;
232  for (size_t r = 0; r < 3; r++)
233  {
234  y[r] = 0.0;
235  for (size_t c = 0; c < 3; c++)
236  {
237  s_uc2[c] = 0.0; s_ur_uc[c] = 0.0;
238  s_p_uc2[c] = 0.0; s_p_ur_uc[c] = 0.0;
239 
240  for (size_t v = 0; v < P.size(); v++)
241  {
242  //w[1] = fWeights[v]; // to remember that individual coordinates can be supressed...
243  //w[2] = fWeights[v];
244 
245  ur = U[v][r];
246  uc = U[v][c];
247  pc = P[v][c];
248 
249  s_uc2[c] += w[r] * w[c] * (1 - uc * uc);
250  s_p_uc2[c] += w[r] * w[r] * pc * (1 - uc * uc);
251 
252  s_ur_uc[c] += w[r] * w[c] * ur * uc;
253  s_p_ur_uc[c] += w[r] * w[r] * pc * ur * uc;
254  }
255 
256  if (r == c)
257  {
258  y[r] += s_p_uc2[c];
259  A(r, c) = s_uc2[c];
260  }
261  else
262  {
263  y[r] -= s_p_ur_uc[c];
264  A(r, c) = -s_ur_uc[c];
265  }
266  }
267  }
268  try { x = A.InvertFast() * y; }
269  catch (...)
270  {
271  result.SetXYZ(0., 0., 0.); return 1.0e12;
272  }
273 
274  result.SetXYZ(x[0], x[1], x[2]);
275 
276  TVector3 pproj;
277  double dx, dy, dz, mse = 0.0;
278  for (size_t v = 0; v < lines.size(); v++)
279  {
280  pproj = pma::GetProjectionToSegment(result, lines[v].first, lines[v].second);
281 
282  dx = result.X() - pproj.X(); // dx, dy, dz and the result point can be weighted
283  dy = result.Y() - pproj.Y(); // here (linearly) by each line uncertainty
284  dz = result.Z() - pproj.Z();
285 
286  mse += dx * dx + dy * dy + dz * dz;
287  }
288  return mse / lines.size();
289 }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
TVector2 GetProjectionToSegment(const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
Definition: Utilities.cxx:167
TDirectory * dir
Definition: macro.C:5
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t w
Definition: plot.C:23
TVector2 pma::WireDriftToCm ( unsigned int  wire,
float  drift,
unsigned int  plane,
unsigned int  tpc,
unsigned int  cryo 
)

Definition at line 307 of file Utilities.cxx.

References detinfo::DetectorProperties::ConvertTicksToX(), geo::TPCGeo::Plane(), geo::GeometryCore::TPC(), and geo::PlaneGeo::WirePitch().

Referenced by pma::ProjectionMatchingAlg::FilterOutSmallParts(), ems::EMShower3D::GetCloseHits(), ems::MultiEMShowers::getMinDist(), pma::Track3D::GetUnconstrainedProj3D(), tss::Hit2D::Hit2D(), pma::Hit3D::Hit3D(), pma::Track3D::TestHitsMse(), and pma::ProjectionMatchingAlg::validate().

308 {
310  const detinfo::DetectorProperties* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
311 
312  return TVector2(
313  geom->TPC(tpc, cryo).Plane(plane).WirePitch() * wire,
314  detprop->ConvertTicksToX(drift, plane, tpc, cryo)
315  );
316 }
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:298
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:367