Analysis Software
Documentation for sPHENIX simulation 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,
13  State& /*state*/) const -> Result<std::vector<Vertex<InputTrack_t>>> {
14  double ZResult = 0.;
15  // Prepare the vector of points, on which the 3d mode has later to be
16  // calculated
17  std::vector<std::pair<double, double>> zPositions;
18 
19  for (const auto& iTrk : trackVector) {
20  // Extract BoundTrackParameters from InputTrack_t object
21  const BoundTrackParameters& params = m_extractParameters(*iTrk);
22 
23  std::pair<double, double> z0AndWeight;
25  if (vertexingOptions.useConstraintInFit &&
26  vertexingOptions.constraint.covariance()(0, 0) != 0) {
27  auto estRes = m_cfg.ipEstimator.getImpactParameters(
28  params, vertexingOptions.constraint, vertexingOptions.geoContext,
29  vertexingOptions.magFieldContext);
30  if (estRes.ok()) {
31  ipas = *estRes;
32  } else {
33  return estRes.error();
34  }
35  }
36 
37  if (ipas.sigmaD0 > 0) {
38  // calculate z0
39  z0AndWeight.first = ipas.z0 + vertexingOptions.constraint.position().z();
40 
41  // calculate chi2 of IP
42  double chi2IP = std::pow(ipas.d0 / ipas.sigmaD0, 2);
43 
44  if (!m_cfg.disableAllWeights) {
45  z0AndWeight.second =
46  1. / (1. + std::exp((chi2IP - m_cfg.constraintcutoff) /
47  m_cfg.constrainttemp));
48  // overflow protection
49  if (!std::isnormal(z0AndWeight.second)) {
50  z0AndWeight.second = 0.;
51  }
52  } else {
53  z0AndWeight.second = 1.;
54  }
55  } else {
56  ACTS_DEBUG(
57  "Unable to compute IP significance. "
58  "Setting IP weight to 1.");
59 
60  z0AndWeight.first = params.position(vertexingOptions.geoContext)[eZ];
61  z0AndWeight.second = 1.;
62  }
63 
64  // apply pT weighting as/if configured
65  if (!m_cfg.disableAllWeights && (m_cfg.usePt || m_cfg.useLogPt)) {
66  double Pt =
67  std::abs(1. / params.parameters()[BoundIndices::eBoundQOverP]) *
68  std::sin(params.parameters()[BoundIndices::eBoundTheta]);
69  if (m_cfg.usePt) {
70  z0AndWeight.second *= std::pow(Pt, m_cfg.expPt);
71  } else {
72  z0AndWeight.second *=
73  Pt > m_cfg.minPt ? std::log(Pt / m_cfg.minPt) : 0.;
74  }
75  }
76 
77  if (z0AndWeight.second >= m_cfg.minWeight) {
78  zPositions.push_back(z0AndWeight);
79  }
80  } // end of loop over perigeeList
81 
82  if (!zPositions.empty()) {
83  auto res = m_cfg.mode1dFinder.getMode(zPositions);
84  if (res.ok()) {
85  ZResult = *res;
86  } else {
87  return res.error();
88  }
89 
90  ACTS_DEBUG("Resulting mean Z position found: " << ZResult);
91  }
92 
93  // constraint x()/y() equals 0 if no constraint
94  Vector4 output(vertexingOptions.constraint.position().x(),
95  vertexingOptions.constraint.position().y(), ZResult,
96  vertexingOptions.constraint.time());
98 
99  // Vector to be filled with one single vertex
100  std::vector<Vertex<InputTrack_t>> vertexCollection;
101 
102  // Add vertex to vertexCollection
103  vertexCollection.push_back(vtxResult);
104 
105  return vertexCollection;
106 }