LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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/Table.h"
17 
20 
21 // ROOT & C++
22 #include <memory>
23 
24 namespace pma
25 {
26  class PMAlgVertexing;
27 }
28 
30 {
31 public:
32 
33  struct Config {
34  using Name = fhicl::Name;
36 
38  Name("MinTrackLength"),
39  Comment("min. length of tracks used to find vtx candidates (short tracks attached later)")
40  };
41 
43  Name("FindKinks"),
44  Comment("detect significant kinks on long tracks")
45  };
46 
48  Name("KinkMinDeg"),
49  Comment("min. angle [deg] in XY of a kink")
50  };
51 
53  Name("KinkMinStd"),
54  Comment("threshold in no. of stdev of all segment angles needed to tag a kink")
55  };
56  };
57 
58  PMAlgVertexing(const Config& config);
59  void reconfigure(const Config& config);
60 
62  PMAlgVertexing(fhicl::Table<Config>(pset, {})())
63  {}
64 
65  virtual ~PMAlgVertexing(void); // delete last produced tracks (if not passed to output)
66 
67  void reset(void) { cleanTracks(); }
68 
73  size_t run(pma::TrkCandidateColl & trk_input);
74 
80  size_t run(pma::TrkCandidateColl & trk_input,
81  const std::vector< TVector3 >& vtx_input);
82 
83  std::vector< std::pair< TVector3, std::vector< std::pair< size_t, bool > > > >
84  getVertices(const pma::TrkCandidateColl& tracks, bool onlyBranching = false) const;
85 
86  std::vector< std::pair< TVector3, size_t > > getKinks(const pma::TrkCandidateColl& tracks) const;
87 
88 private:
89  bool has(const std::vector<size_t>& v, size_t idx) const
90  {
91  for (auto c : v) if (c == idx) return true;
92  return false;
93  }
94 
95  std::vector< pma::VtxCandidate > firstPassCandidates(void);
96  std::vector< pma::VtxCandidate > secondPassCandidates(void);
97  size_t makeVertices(std::vector< pma::VtxCandidate >& candidates);
98 
100  std::vector< std::pair<double, double> > getdQdx(const pma::Track3D& trk) const;
101 
103  double convolute(size_t idx, size_t len, double* adc, double const* shape) const;
104 
106  bool isSingleParticle(pma::Track3D* trk1, pma::Track3D* trk2) const;
107 
110  void mergeBrokenTracks(pma::TrkCandidateColl& trk_input) const;
111 
113  void splitMergedTracks(pma::TrkCandidateColl& trk_input) const;
114 
116  void findKinksOnTracks(pma::TrkCandidateColl& trk_input) const;
117 
120  void cleanTracks(void);
121 
122  void sortTracks(const pma::TrkCandidateColl & trk_input);
123  void collectTracks(pma::TrkCandidateColl & result);
124 
125  // Parameters used in the algorithm
126 
127  double fMinTrackLength; // min. length of tracks used to find vtx candidates (short tracks attached later)
128 
129  bool fFindKinks; // detect significant kinks on long tracks (need min. 5 nodes to collect angle stats)
130  double fKinkMinDeg; // min. angle [deg] in XY of a kink
131  double fKinkMinStd; // threshold in no. of stdev of all segment angles needed to tag a kink
132 
133  // just to remember:
134  //double fInputVtxDist2D; // use vtx given at input if dist. [cm] to track in all 2D projections is below this max. value
135  //double fInputVtxDistY; // use vtx given at input if dist. [cm] to track in 3D-Y is below this max. value
136 };
137 
138 #endif
Vertex finding helper for the Projection Matching Algorithm.
pma::TrkCandidateColl fEmTracks
pma::TrkCandidateColl fShortTracks
std::vector< std::pair< TVector3, size_t > > getKinks(const pma::TrkCandidateColl &tracks) const
void collectTracks(pma::TrkCandidateColl &result)
void reconfigure(const Config &config)
fhicl::Atom< double > MinTrackLength
std::vector< std::pair< TVector3, std::vector< std::pair< size_t, bool > > > > getVertices(const pma::TrkCandidateColl &tracks, bool onlyBranching=false) const
PMAlgVertexing(const Config &config)
void findKinksOnTracks(pma::TrkCandidateColl &trk_input) const
Remove penalty on the angle if kink detected and reopt track.
fhicl::Atom< bool > FindKinks
parameter set interface
std::vector< std::pair< double, double > > getdQdx(const pma::Track3D &trk) const
Get dQ/dx sequence to detect various features.
pma::TrkCandidateColl fOutTracks
fhicl::Atom< double > KinkMinStd
pma::TrkCandidateColl fExcludedTracks
size_t makeVertices(std::vector< pma::VtxCandidate > &candidates)
Track finding helper for the Projection Matching Algorithm.
double convolute(size_t idx, size_t len, double *adc, double const *shape) const
Get convolution value.
void sortTracks(const pma::TrkCandidateColl &trk_input)
PMAlgVertexing(const fhicl::ParameterSet &pset)
virtual ~PMAlgVertexing(void)
bool isSingleParticle(pma::Track3D *trk1, pma::Track3D *trk2) const
Check if colinear in 3D and dQ/dx with no significant step.
std::vector< pma::VtxCandidate > secondPassCandidates(void)
void splitMergedTracks(pma::TrkCandidateColl &trk_input) const
Split track and add vertex and reoptimize when dQ/dx step detected.
fhicl::Atom< double > KinkMinDeg
size_t run(pma::TrkCandidateColl &trk_input)
std::vector< pma::VtxCandidate > firstPassCandidates(void)
bool has(const std::vector< size_t > &v, size_t idx) const
void mergeBrokenTracks(pma::TrkCandidateColl &trk_input) const