EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GaussianTrackDensity.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GaussianTrackDensity.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
12 
13 #include <map>
14 #include <set>
15 
16 namespace Acts {
17 
23 template <typename input_track_t>
25  public:
27  struct TrackEntry {
29  TrackEntry() = default;
37  TrackEntry(double z_, double c0_, double c1_, double c2_,
38  double lowerBound_, double upperBound_)
39  : z(z_),
40  c0(c0_),
41  c1(c1_),
42  c2(c2_),
43  lowerBound(lowerBound_),
44  upperBound(upperBound_) {}
45 
46  double z = 0;
47  // Cached information for a single track
48  // z-independent term in exponent
49  double c0 = 0;
50  // linear coefficient in exponent
51  double c1 = 0;
52  // quadratic coefficient in exponent
53  double c2 = 0;
54  // The lower bound
55  double lowerBound = 0;
56  // The upper bound
57  double upperBound = 0;
58  };
59 
61  struct Config {
62  Config(double d0Sig = 3.5, double z0Sig = 12.)
63  : d0MaxSignificance(d0Sig),
64  z0MaxSignificance(z0Sig),
65  d0SignificanceCut(d0Sig * d0Sig),
66  z0SignificanceCut(z0Sig * z0Sig) {}
67 
68  // Assumed shape of density function:
69  // Gaussian (true) or parabolic (false)
70  bool isGaussianShaped = true;
71 
72  // Maximum d0 impact parameter significance to use a track
74  // Maximum z0 impact parameter significance to use a track
76  // Correspondig cut values
79  };
80 
82  struct State {
83  // Constructor with size track map
84  State(unsigned int nTracks) { trackEntries.reserve(nTracks); }
85  // Vector to cache track information
86  std::vector<TrackEntry> trackEntries;
87  };
88 
90  GaussianTrackDensity() = default;
91 
93  GaussianTrackDensity(const Config& cfg) : m_cfg(cfg) {}
94 
114  std::pair<double, double> globalMaximumWithWidth(
115  State& state, const std::vector<const input_track_t*>& trackList,
116  const std::function<BoundTrackParameters(input_track_t)>&
117  extractParameters) const;
118 
127  double globalMaximum(State& state,
128  const std::vector<const input_track_t*>& trackList,
129  const std::function<BoundTrackParameters(input_track_t)>&
130  extractParameters) const;
131 
132  private:
135 
142  void addTracks(State& state,
143  const std::vector<const input_track_t*>& trackList,
144  const std::function<BoundTrackParameters(input_track_t)>&
145  extractParameters) const;
146 
154  std::tuple<double, double, double> trackDensityAndDerivatives(State& state,
155  double z) const;
156 
164  std::tuple<double, double, double> updateMaximum(
165  double newZ, double newValue, double newSecondDerivative, double maxZ,
166  double maxValue, double maxSecondDerivative) const;
167 
175  double stepSize(double y, double dy, double ddy) const;
176 
177  // Helper class to evaluate and store track density at specific position
179  public:
180  // Initialise at the z coordinate at which the density is to be evaluated
181  GaussianTrackDensityStore(double z_coordinate) : m_z(z_coordinate) {}
182 
183  // Add the contribution of a single track to the density
184  void addTrackToDensity(const TrackEntry& entry);
185 
186  // Return density, first and second derivatives
187  inline std::tuple<double, double, double> densityAndDerivatives() const {
189  }
190 
191  private:
192  // Store density and derivatives for z position m_z
193  double m_z;
194  double m_density{0};
195  double m_firstDerivative{0};
197  };
198 };
199 
201 } // namespace Acts