LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PMAlgVertexing.h
Go to the documentation of this file.
1 // Class: PMAlgVertexing
3 // Author: D.Stefan (Dorota.Stefan@ncbj.gov.pl) and R.Sulej (Robert.Sulej@cern.ch), August 2015
4 //
5 // 3D vertex finding for Projection Matching Algorithm
6 //
7 // Uses collection of pma::Track3D to find vertex candidates, then joins tracks in these points
8 // and reoptimizes full structure of tracks.
9 //
11 
12 #ifndef PMAlgVertexing_h
13 #define PMAlgVertexing_h
14 
15 #include "fhiclcpp/types/Atom.h"
16 #include "fhiclcpp/types/Comment.h"
17 #include "fhiclcpp/types/Name.h"
18 #include "fhiclcpp/types/Table.h"
19 
22 
23 // ROOT & C++
24 #include <memory>
25 #include <utility>
26 #include <vector>
27 
28 namespace detinfo {
29  class DetectorPropertiesData;
30 }
31 
32 namespace pma {
33  class PMAlgVertexing;
34 }
35 
37 public:
38  struct Config {
39  using Name = fhicl::Name;
41 
42  fhicl::Atom<double> MinTrackLength{
43  Name("MinTrackLength"),
44  Comment("min. length of tracks used to find vtx candidates (short tracks attached later)")};
45 
46  fhicl::Atom<bool> FindKinks{Name("FindKinks"),
47  Comment("detect significant kinks on long tracks")};
48 
49  fhicl::Atom<double> KinkMinDeg{Name("KinkMinDeg"), Comment("min. angle [deg] in XY of a kink")};
50 
51  fhicl::Atom<double> KinkMinStd{
52  Name("KinkMinStd"),
53  Comment("threshold in no. of stdev of all segment angles needed to tag a kink")};
54  };
55 
56  PMAlgVertexing(const Config& config);
57 
59  {}
60 
61  ~PMAlgVertexing(); // delete last produced tracks (if not passed to output)
62 
63  void reset() { cleanTracks(); }
64 
69  size_t run(const detinfo::DetectorPropertiesData& detProp, pma::TrkCandidateColl& trk_input);
70 
76  size_t run(pma::TrkCandidateColl& trk_input, const std::vector<TVector3>& vtx_input);
77 
78  std::vector<std::pair<TVector3, std::vector<std::pair<size_t, bool>>>> getVertices(
79  const pma::TrkCandidateColl& tracks,
80  bool onlyBranching = false) const;
81 
82  std::vector<std::pair<TVector3, size_t>> getKinks(const pma::TrkCandidateColl& tracks) const;
83 
84 private:
85  bool has(const std::vector<size_t>& v, size_t idx) const
86  {
87  for (auto c : v)
88  if (c == idx) return true;
89  return false;
90  }
91 
92  std::vector<pma::VtxCandidate> firstPassCandidates() const;
93  std::vector<pma::VtxCandidate> secondPassCandidates() const;
94  size_t makeVertices(detinfo::DetectorPropertiesData const& detProp,
95  std::vector<pma::VtxCandidate>& candidates);
96 
98  std::vector<std::pair<double, double>> getdQdx(const pma::Track3D& trk) const;
99 
101  double convolute(size_t idx, size_t len, double* adc, double const* shape) const;
102 
104  bool isSingleParticle(pma::Track3D* trk1, pma::Track3D* trk2) const;
105 
108  void mergeBrokenTracks(pma::TrkCandidateColl& trk_input) const;
109 
111  void splitMergedTracks(pma::TrkCandidateColl& trk_input) const;
112 
114  void findKinksOnTracks(const detinfo::DetectorPropertiesData& detProp,
115  pma::TrkCandidateColl& trk_input) const;
116 
117  pma::TrkCandidateColl fOutTracks, fShortTracks, fEmTracks;
119  void cleanTracks();
120 
121  void sortTracks(const pma::TrkCandidateColl& trk_input);
122  void collectTracks(pma::TrkCandidateColl& result);
123 
124  // Parameters used in the algorithm
125 
126  double fMinTrackLength; // min. length of tracks used to find vtx candidates
127  // (short tracks attached later)
128 
129  bool fFindKinks; // detect significant kinks on long tracks (need min. 5 nodes
130  // to collect angle stats)
131  double fKinkMinDeg; // min. angle [deg] in XY of a kink
132  double fKinkMinStd; // threshold in no. of stdev of all segment angles needed to tag a kink
133 
134  // just to remember:
135  //double fInputVtxDist2D; // use vtx given at input if dist. [cm] to track in all 2D projections is below this max. value
136  //double fInputVtxDistY; // use vtx given at input if dist. [cm] to track in 3D-Y is below this max. value
137 };
138 
139 #endif
Vertex finding helper for the Projection Matching Algorithm.
pma::TrkCandidateColl fShortTracks
parameter set interface
pma::TrkCandidateColl fExcludedTracks
General LArSoft Utilities.
Track finding helper for the Projection Matching Algorithm.
PMAlgVertexing(const fhicl::ParameterSet &pset)
bool has(const std::vector< size_t > &v, size_t idx) const
map< int, array< map< int, double >, 2 >> Table
Definition: plot.C:18