ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ZScanVertexFinder.ipp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ZScanVertexFinder.ipp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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 template <typename vfitter_t>
11  const std::vector<const InputTrack_t*>& trackVector,
12  const VertexingOptions<InputTrack_t>& vertexingOptions) const
14  // Determine if we use constraint or not
15  bool useConstraint = false;
16  if (vertexingOptions.vertexConstraint.fullCovariance().determinant() != 0) {
17  useConstraint = true;
18  }
19 
20  double ZResult = 0.;
21  // Prepare the vector of points, on which the 3d mode has later to be
22  // calculated
23  std::vector<std::pair<double, double>> zPositions;
24 
25  for (const auto& iTrk : trackVector) {
26  // Extract BoundParameters from InputTrack_t object
27  const BoundParameters& params = m_extractParameters(*iTrk);
28 
29  std::pair<double, double> z0AndWeight;
31  if (useConstraint &&
32  vertexingOptions.vertexConstraint.covariance()(0, 0) != 0) {
33  auto estRes = m_cfg.ipEstimator.estimateImpactParameters(
34  params, vertexingOptions.vertexConstraint,
35  vertexingOptions.geoContext, vertexingOptions.magFieldContext);
36  if (estRes.ok()) {
37  ipas = *estRes;
38  } else {
39  return estRes.error();
40  }
41  }
42 
43  if (ipas.sigmad0 > 0) {
44  // calculate z0
45  z0AndWeight.first =
46  ipas.IPz0 + vertexingOptions.vertexConstraint.position().z();
47 
48  // calculate chi2 of IP
49  double chi2IP = std::pow(ipas.IPd0 / ipas.sigmad0, 2);
50 
51  if (!m_cfg.disableAllWeights) {
52  z0AndWeight.second =
53  1. / (1. + std::exp((chi2IP - m_cfg.constraintcutoff) /
54  m_cfg.constrainttemp));
55  // overflow protection
56  if (!std::isnormal(z0AndWeight.second)) {
57  z0AndWeight.second = 0.;
58  }
59  } else {
60  z0AndWeight.second = 1.;
61  }
62  } else {
63  ACTS_DEBUG(
64  "Unable to compute IP significance. "
65  "Setting IP weight to 1.");
66 
67  z0AndWeight.first = params.position()[eZ];
68  z0AndWeight.second = 1.;
69  }
70 
71  // apply pT weighting as/if configured
72  if (!m_cfg.disableAllWeights && (m_cfg.usePt || m_cfg.useLogPt)) {
73  double Pt = std::abs(1. / params.parameters()[ParID_t::eQOP]) *
74  std::sin(params.parameters()[ParID_t::eTHETA]);
75  if (m_cfg.usePt) {
76  z0AndWeight.second *= std::pow(Pt, m_cfg.expPt);
77  } else {
78  z0AndWeight.second *=
79  Pt > m_cfg.minPt ? std::log(Pt / m_cfg.minPt) : 0.;
80  }
81  }
82 
83  if (z0AndWeight.second >= m_cfg.minWeight) {
84  zPositions.push_back(z0AndWeight);
85  }
86  } // end of loop over perigeeList
87 
88  if (!zPositions.empty()) {
89  auto res = m_cfg.mode1dFinder.getMode(zPositions);
90  if (res.ok()) {
91  ZResult = *res;
92  } else {
93  return res.error();
94  }
95 
96  ACTS_DEBUG("Resulting mean Z position found: " << ZResult);
97  }
98 
99  // constraint x()/y() equals 0 if no constraint
100  SpacePointVector output(vertexingOptions.vertexConstraint.position().x(),
101  vertexingOptions.vertexConstraint.position().y(),
102  ZResult, vertexingOptions.vertexConstraint.time());
103  Vertex<InputTrack_t> vtxResult = Vertex<InputTrack_t>(output);
104 
105  // Vector to be filled with one single vertex
106  std::vector<Vertex<InputTrack_t>> vertexCollection;
107 
108  // Add vertex to vertexCollection
109  vertexCollection.push_back(vtxResult);
110 
111  return vertexCollection;
112 }