Classes | Typedefs | Functions
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)
 
template<typename T , typename U >
double Dist2 (const T &v1, const U &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 (detinfo::DetectorPropertiesData const &detProp, unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo)
 
TVector2 CmToWireDrift (detinfo::DetectorPropertiesData const &detProp, 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 25 of file PmaTrkCandidate.h.

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

Definition at line 33 of file Utilities.h.

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

Definition at line 48 of file PMAlgTracking.h.

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

Definition at line 24 of file PmaTrkCandidate.h.

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

Definition at line 30 of file Utilities.h.

Definition at line 31 of file Utilities.h.

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

Definition at line 23 of file PmaTrkCandidate.h.

Function Documentation

TVector2 pma::CmToWireDrift ( detinfo::DetectorPropertiesData const &  detProp,
float  xw,
float  yd,
unsigned int  plane,
unsigned int  tpc,
unsigned int  cryo 
)

Definition at line 307 of file Utilities.cxx.

313 {
315  return TVector2(xw / geom->TPC(tpc, cryo).Plane(plane).WirePitch(),
316  detProp.ConvertXToTicks(yd, plane, tpc, cryo));
317 }
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:263
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:411
recob::Track pma::convertFrom ( const pma::Track3D src,
unsigned int  tidx,
int  pdg = 0 
)

Definition at line 25 of file PMAlgTracking.cxx.

26 {
27  std::vector<Point_t> positions;
28  positions.reserve(src.size());
29  std::vector<Vector_t> momenta;
30  momenta.reserve(src.size());
31  std::vector<recob::TrajectoryPointFlags> outFlags;
32  outFlags.reserve(src.size());
33 
34  for (size_t i = 0, h = 0; i < src.size(); i++)
35  if (src[i]->IsEnabled()) {
36  auto const& point3d = src[i]->Point3D();
37  positions.emplace_back(point3d.X(), point3d.Y(), point3d.Z());
38  momenta.push_back(src.GetDirection3D(i));
39  outFlags.emplace_back(h++, recob::TrajectoryPointFlags::makeMask());
40  }
41 
42  int ndof = 0;
43  float totChi2 = 0;
44 
45  SMatrixSym55 covStart, covEnd;
46  return recob::Track(
47  recob::TrackTrajectory(std::move(positions), std::move(momenta), std::move(outFlags), false),
48  pdg,
49  totChi2,
50  ndof,
51  covStart,
52  covEnd,
53  tidx);
54 }
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:378
A trajectory in space reconstructed from hits.
def move(depos, offset)
Definition: depos.py:107
recob::tracking::SMatrixSym55 SMatrixSym55
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1036
size_t size() const
Definition: PmaTrack3D.h:108
double pma::Dist2 ( const TVector2 &  v1,
const TVector2 &  v2 
)

Definition at line 37 of file Utilities.cxx.

38 {
39  double const dx = v1.X() - v2.X(), dy = v1.Y() - v2.Y();
40  return cet::sum_of_squares(dx, dy);
41 }
constexpr T sum_of_squares(T x, T y)
Definition: pow.h:139
double pma::Dist2 ( const Vector2D v1,
const Vector2D v2 
)

Definition at line 43 of file Utilities.cxx.

44 {
45  double const dx = v1.X() - v2.X(), dy = v1.Y() - v2.Y();
46  return cet::sum_of_squares(dx, dy);
47 }
constexpr T sum_of_squares(T x, T y)
Definition: pow.h:139
template<typename T , typename U >
double pma::Dist2 ( const T &  v1,
const U &  v2 
)

Definition at line 49 of file Utilities.h.

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

Definition at line 50 of file Utilities.cxx.

51 {
52  if (view == geo::kUnknown) { return hits.size(); }
53  return ranges::count_if(hits, [view](auto hit) { return view == hit->View2D(); });
54 }
Unknown view.
Definition: geo_types.h:136
Detector simulation of raw signals on wires.
double pma::GetHitsRadius2D ( const std::vector< pma::Hit3D * > &  hits,
bool  exact = false 
)

Definition at line 98 of file Utilities.cxx.

99 {
100  if (hits.empty()) return 0.0;
101 
102  if (!exact && (hits.size() < 5)) return 0.0;
103 
104  using namespace ranges;
105  auto to_2d_point = [](auto hit) -> decltype(auto) { return hit->Point2D(); };
106  auto const mean_point =
107  accumulate(hits | views::transform(to_2d_point), TVector2{}) * (1. / hits.size());
108 
109  auto to_dist2_from_mean = [&mean_point](auto hit) {
110  return pma::Dist2(hit->Point2D(), mean_point);
111  };
112  auto const max_r2 = max(hits | views::transform(to_dist2_from_mean));
113  return sqrt(max_r2);
114 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:37
static int max(int a, int b)
Detector simulation of raw signals on wires.
double pma::GetHitsRadius3D ( const std::vector< pma::Hit3D * > &  hits,
bool  exact = false 
)

Definition at line 79 of file Utilities.cxx.

80 {
81  if (hits.empty()) return 0.0;
82 
83  if (!exact && (hits.size() < 5)) return 0.0;
84 
85  using namespace ranges;
86  auto to_3d_point = [](auto hit) -> decltype(auto) { return hit->Point3D(); };
87  auto const mean_point =
88  accumulate(hits | views::transform(to_3d_point), TVector3{}) * (1. / hits.size());
89 
90  auto to_dist2_from_mean = [&mean_point](auto hit) {
91  return pma::Dist2(hit->Point3D(), mean_point);
92  };
93  auto const max_r2 = max(hits | views::transform(to_dist2_from_mean));
94  return sqrt(max_r2);
95 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:37
static int max(int a, int b)
Detector simulation of raw signals on wires.
TVector2 pma::GetProjectionToPlane ( const TVector3 &  p,
unsigned int  plane,
unsigned int  tpc,
unsigned int  cryo 
)

Definition at line 270 of file Utilities.cxx.

274 {
276 
277  return TVector2(geom->TPC(tpc, cryo).Plane(plane).PlaneCoordinate(p), p.X());
278 }
p
Definition: test.py:223
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:263
double PlaneCoordinate(geo::Point_t const &point) const
Returns the coordinate of the point on the plane.
Definition: PlaneGeo.h:861
TVector2 pma::GetProjectionToSegment ( const TVector2 &  p,
const TVector2 &  p0,
const TVector2 &  p1 
)

Definition at line 149 of file Utilities.cxx.

150 {
151  TVector2 const v1(p1 - p0);
152  double const b = GetSegmentProjVector(p, p0, p1);
153  return p0 + v1 * b;
154 }
p
Definition: test.py:223
double GetSegmentProjVector(const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
Definition: Utilities.cxx:117
static bool * b
Definition: config.cpp:1043
TVector3 pma::GetProjectionToSegment ( const TVector3 &  p,
const TVector3 &  p0,
const TVector3 &  p1 
)

Definition at line 157 of file Utilities.cxx.

158 {
159  TVector3 const v1(p1 - p0);
160  double const b = GetSegmentProjVector(p, p0, p1);
161  return p0 + v1 * b;
162 }
p
Definition: test.py:223
double GetSegmentProjVector(const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
Definition: Utilities.cxx:117
static bool * b
Definition: config.cpp:1043
double pma::GetSegmentProjVector ( const TVector2 &  p,
const TVector2 &  p0,
const TVector2 &  p1 
)

Definition at line 117 of file Utilities.cxx.

118 {
119  TVector2 const v0(p - p0);
120  TVector2 const v1(p1 - p0);
121  return v0 * v1 / v1.Mod2();
122 }
p
Definition: test.py:223
double pma::GetSegmentProjVector ( const Vector2D p,
const Vector2D p0,
const Vector2D p1 
)

Definition at line 125 of file Utilities.cxx.

126 {
127  pma::Vector2D const v0(p - p0);
128  pma::Vector2D const v1(p1 - p0);
129  return v0.Dot(v1) / v1.Mag2();
130 }
p
Definition: test.py:223
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double > > Vector2D
Definition: Utilities.h:30
double pma::GetSegmentProjVector ( const TVector3 &  p,
const TVector3 &  p0,
const TVector3 &  p1 
)

Definition at line 133 of file Utilities.cxx.

134 {
135  TVector3 const v0(p - p0);
136  TVector3 const v1(p1 - p0);
137  return v0.Dot(v1) / v1.Mag2();
138 }
p
Definition: test.py:223
double pma::GetSegmentProjVector ( const Vector3D p,
const Vector3D p0,
const Vector3D p1 
)

Definition at line 141 of file Utilities.cxx.

142 {
143  pma::Vector3D const v0(p - p0);
144  pma::Vector3D const v1(p1 - p0);
145  return v0.Dot(v1) / v1.Mag2();
146 }
recob::tracking::Vector_t Vector3D
Definition: Utilities.h:31
p
Definition: test.py:223
double pma::GetSummedADC ( const std::vector< pma::Hit3D * > &  hits,
unsigned int  view = geo::kUnknown 
)

Definition at line 57 of file Utilities.cxx.

58 {
59  using namespace ranges;
60  auto to_summed_adc = [](auto hit) { return hit->SummedADC(); };
61  if (view == geo::kUnknown) { return accumulate(hits | views::transform(to_summed_adc), 0.); }
62  return accumulate(hits | views::filter([view](auto hit) { return view == hit->View2D(); }) |
63  views::transform(to_summed_adc),
64  0.);
65 }
Unknown view.
Definition: geo_types.h:136
Detector simulation of raw signals on wires.
static unsigned filter(unsigned char *out, const unsigned char *in, unsigned w, unsigned h, const LodePNG_InfoColor *info)
Definition: lodepng.cpp:3576
double pma::GetSummedAmpl ( const std::vector< pma::Hit3D * > &  hits,
unsigned int  view = geo::kUnknown 
)

Definition at line 68 of file Utilities.cxx.

69 {
70  using namespace ranges;
71  auto to_amplitude = [](auto hit) { return hit->GetAmplitude(); };
72  if (view == geo::kUnknown) { return accumulate(hits | views::transform(to_amplitude), 0.); }
73  return accumulate(hits | views::filter([view](auto hit) { return view == hit->View2D(); }) |
74  views::transform(to_amplitude),
75  0.);
76 }
Unknown view.
Definition: geo_types.h:136
Detector simulation of raw signals on wires.
static unsigned filter(unsigned char *out, const unsigned char *in, unsigned w, unsigned h, const LodePNG_InfoColor *info)
Definition: lodepng.cpp:3576
TVector2 pma::GetVectorProjectionToPlane ( const TVector3 &  v,
unsigned int  plane,
unsigned int  tpc,
unsigned int  cryo 
)

Definition at line 281 of file Utilities.cxx.

285 {
286  TVector3 v0_3d(0., 0., 0.);
287  TVector2 v0_2d = GetProjectionToPlane(v0_3d, plane, tpc, cryo);
288  TVector2 v1_2d = GetProjectionToPlane(v, plane, tpc, cryo);
289 
290  return v1_2d - v0_2d;
291 }
TVector2 GetProjectionToPlane(const TVector3 &p, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:270
double pma::SolveLeastSquares3D ( const std::vector< std::pair< TVector3, TVector3 >> &  lines,
TVector3 &  result 
)

Definition at line 165 of file Utilities.cxx.

166 {
167  // RS: please, ask me if you need examples/explanation of formulas as they
168  // are not easy to derive from the code solely; I have Mathcad sources that
169  // were used to test the solving method, weighting, etc.
170 
171  result.SetXYZ(0., 0., 0.);
172  if (lines.size() < 2) {
173  mf::LogError("pma::SolveLeastSquares3D") << "Need min. two lines.";
174  return -1.0;
175  }
176 
177  double m;
178  std::vector<TVectorT<double>> U, P;
179  for (size_t v = 0; v < lines.size(); v++) {
180  TVector3 point = lines[v].first;
181  TVector3 dir = lines[v].second;
182  dir -= point;
183  m = dir.Mag();
184  if (m > 0.0) {
185  dir *= 1.0 / m;
186 
187  P.push_back(TVectorT<double>(3));
188  P.back()[0] = point.X();
189  P.back()[1] = point.Y();
190  P.back()[2] = point.Z();
191 
192  U.push_back(TVectorT<double>(3));
193  U.back()[0] = dir.X();
194  U.back()[1] = dir.Y();
195  U.back()[2] = dir.Z();
196  }
197  else
198  mf::LogWarning("pma::SolveLeastSquares3D") << "Line undefined.";
199  }
200  if (P.size() < 2) {
201  mf::LogError("pma::SolveLeastSquares3D") << "Need min. two lines.";
202  return -1.0;
203  }
204 
205  TVectorT<double> x(3), y(3), w(3);
206  TMatrixT<double> A(3, 3);
207  double ur, uc, pc;
208  double s_uc2[3], s_ur_uc[3];
209  double s_p_uc2[3], s_p_ur_uc[3];
210 
211  w[0] = 1.0;
212  w[1] = 1.0;
213  w[2] = 1.0;
214  for (size_t r = 0; r < 3; r++) {
215  y[r] = 0.0;
216  for (size_t c = 0; c < 3; c++) {
217  s_uc2[c] = 0.0;
218  s_ur_uc[c] = 0.0;
219  s_p_uc2[c] = 0.0;
220  s_p_ur_uc[c] = 0.0;
221 
222  for (size_t v = 0; v < P.size(); v++) {
223  //w[1] = fWeights[v]; // to remember that individual coordinates can be supressed...
224  //w[2] = fWeights[v];
225 
226  ur = U[v][r];
227  uc = U[v][c];
228  pc = P[v][c];
229 
230  s_uc2[c] += w[r] * w[c] * (1 - uc * uc);
231  s_p_uc2[c] += w[r] * w[r] * pc * (1 - uc * uc);
232 
233  s_ur_uc[c] += w[r] * w[c] * ur * uc;
234  s_p_ur_uc[c] += w[r] * w[r] * pc * ur * uc;
235  }
236 
237  if (r == c) {
238  y[r] += s_p_uc2[c];
239  A(r, c) = s_uc2[c];
240  }
241  else {
242  y[r] -= s_p_ur_uc[c];
243  A(r, c) = -s_ur_uc[c];
244  }
245  }
246  }
247  try {
248  x = A.InvertFast() * y;
249  }
250  catch (...) {
251  result.SetXYZ(0., 0., 0.);
252  return 1.0e12;
253  }
254 
255  result.SetXYZ(x[0], x[1], x[2]);
256 
257  double mse = 0.0;
258  for (size_t v = 0; v < lines.size(); v++) {
259  TVector3 const pproj = pma::GetProjectionToSegment(result, lines[v].first, lines[v].second);
260 
261  double const dx = result.X() - pproj.X(); // dx, dy, dz and the result point can be weighted
262  double const dy = result.Y() - pproj.Y(); // here (linearly) by each line uncertainty
263  double const dz = result.Z() - pproj.Z();
264  mse += cet::sum_of_squares(dx, dy, dz);
265  }
266  return mse / lines.size();
267 }
static QCString result
constexpr T sum_of_squares(T x, T y)
Definition: pow.h:139
std::pair< float, std::string > P
string dir
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
TVector2 GetProjectionToSegment(const TVector2 &p, const TVector2 &p0, const TVector2 &p1)
Definition: Utilities.cxx:149
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
#define A
Definition: memgrp.cpp:38
list x
Definition: train.py:276
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
TVector2 pma::WireDriftToCm ( detinfo::DetectorPropertiesData const &  detProp,
unsigned int  wire,
float  drift,
unsigned int  plane,
unsigned int  tpc,
unsigned int  cryo 
)

Definition at line 294 of file Utilities.cxx.

300 {
302  return TVector2(geom->TPC(tpc, cryo).Plane(plane).WirePitch() * wire,
303  detProp.ConvertTicksToX(drift, plane, tpc, cryo));
304 }
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:263
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:411