Belle II Software  release-08-01-10
TrackletVariables.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #pragma once
9 
10 #include <tracking/vxdHoughTracking/filters/pathFilters/ThreeHitVariables.h>
11 #include <tracking/spacePointCreation/SpacePoint.h>
12 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
13 #include <framework/geometry/B2Vector3.>
14 
15 #include <cmath>
16 
17 namespace Belle2 {
22  namespace vxdHoughTracking {
23 
26  int calculateZiggZaggRZ(const SpacePointTrackCand& sptc)
27  {
28  const unsigned nHits = sptc.size();
29  if (nHits < 4) return 1;
30 
31  using boost::math::sign;
32 
33  std::vector<B2Vector3D> vecRZ;
34  vecRZ.reserve(nHits);
35  for (const auto* hit : sptc) { // collect RZ-Vrsions of the hits:
36  vecRZ.push_back(B2Vector3D(hit->Perp(), hit->Z(), 0.));
37  }
38 
39  std::vector<int> chargeSigns;
40  chargeSigns.reserve(nHits - 2);
41  for (unsigned i = 0; i < nHits - 2; ++i) {
42  int signVal = sign((vecRZ.at(i + 1) - vecRZ.at(i + 2)).Orthogonal() * (vecRZ.at(i) - vecRZ.at(i + 1)));
43  chargeSigns.push_back(signVal);
44  }
45 
46  std::sort(chargeSigns.begin(), chargeSigns.end());
47  auto newEnd = std::unique(chargeSigns.begin(), chargeSigns.end());
48 
49  return std::distance(chargeSigns.begin(), newEnd);
50  }
51 
52 
55  static int calculateZiggZaggXY(const SpacePointTrackCand& sptc)
56  {
57  if (sptc.size() < 4) return 1;
58 
59  std::vector<int> chargeSigns;
60  chargeSigns.reserve(sptc.size() - 2);
61 
62  auto iterPos = sptc.begin();
63  auto stopPos = sptc.end() - 2;
64 
65  ThreeHitVariables threeHitVariables;
66 
67  for (; iterPos < stopPos; ++iterPos) {
68  int signVal = threeHitVariables.getCurvatureSign(**iterPos, **(iterPos + 1), **(iterPos + 2));
69  chargeSigns.push_back(signVal);
70  }
71 
72  std::sort(chargeSigns.begin(), chargeSigns.end());
73  auto newEnd = std::unique(chargeSigns.begin(), chargeSigns.end());
74 
75  return std::distance(chargeSigns.begin(), newEnd);
76  }
77 
78  }
80 }
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516
Abstract base class for different kinds of events.