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,
13  State& /*state*/) const -> Result<std::vector<Vertex<InputTrack_t>>> {
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 BoundTrackParameters from InputTrack_t object
27  const BoundTrackParameters& 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(vertexingOptions.geoContext)[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 =
75  std::sin(params.parameters()[BoundIndices::eBoundTheta]);
76  if (m_cfg.usePt) {
77  z0AndWeight.second *= std::pow(Pt, m_cfg.expPt);
78  } else {
79  z0AndWeight.second *=
80  Pt > m_cfg.minPt ? std::log(Pt / m_cfg.minPt) : 0.;
81  }
82  }
83 
84  if (z0AndWeight.second >= m_cfg.minWeight) {
85  zPositions.push_back(z0AndWeight);
86  }
87  } // end of loop over perigeeList
88 
89  if (!zPositions.empty()) {
90  auto res = m_cfg.mode1dFinder.getMode(zPositions);
91  if (res.ok()) {
92  ZResult = *res;
93  } else {
94  return res.error();
95  }
96 
97  ACTS_DEBUG("Resulting mean Z position found: " << ZResult);
98  }
99 
100  // constraint x()/y() equals 0 if no constraint
101  Vector4D output(vertexingOptions.vertexConstraint.position().x(),
102  vertexingOptions.vertexConstraint.position().y(), ZResult,
103  vertexingOptions.vertexConstraint.time());
104  Vertex<InputTrack_t> vtxResult = Vertex<InputTrack_t>(output);
105 
106  // Vector to be filled with one single vertex
107  std::vector<Vertex<InputTrack_t>> vertexCollection;
108 
109  // Add vertex to vertexCollection
110  vertexCollection.push_back(vtxResult);
111 
112  return vertexCollection;
113 }