Belle II Software  release-05-01-25
ZiggZaggRZ.h
1 /**************************************************************************
2 * BASF2 (Belle Analysis Framework 2) *
3 * Copyright(C) 2014 - Belle II Collaboration *
4 * *
5 * Author: The Belle II Collaboration *
6 * Contributors: Jakob Lettenbichler (jakob.lettenbichler@oeaw.ac.at) *
7 * *
8 * This software is provided "as is" without any warranty. *
9 **************************************************************************/
10 
11 #pragma once
12 
13 #include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariable.h>
14 #include <tracking/trackFindingVXD/filterTools/SelectionVariableHelper.h>
15 #include <framework/geometry/B2Vector3.h>
16 #include <boost/math/special_functions/sign.hpp>
17 
18 #include <vector>
19 #include <algorithm>
20 
21 
22 #define ZIGGZAGGRZ_NAME ZiggZaggRZ
23 
24 namespace Belle2 {
34  template <typename PointType, typename PointContainerType >
35  class ZIGGZAGGRZ_NAME : public SelectionVariable< PointContainerType , 0, int > {
36  public:
39 
40 
42  static int value(const PointContainerType& hitContainer)
43  {
44  const unsigned nHits = hitContainer.size();
45  if (nHits < 4) return 1;
46 
47  typedef SelVarHelper<PointType, double> Helper;
48  using boost::math::sign;
49 
50  std::vector<B2Vector3D> vecRZ;
51  vecRZ.reserve(nHits);
52  for (const auto* hit : hitContainer) { // collect RZ-Vrsions of the hits:
53  vecRZ.push_back(B2Vector3D(Helper::calcPerp(*hit) , hit->Z(), 0.));
54  }
55 
56  std::vector<int> chargeSigns;
57  chargeSigns.reserve(nHits - 2);
58  for (unsigned i = 0; i < nHits - 2; ++i) {
59  int signVal = sign((vecRZ.at(i + 1) - vecRZ.at(i + 2)).Orthogonal() * (vecRZ.at(i) - vecRZ.at(i + 1)));
60  chargeSigns.push_back(signVal);
61  }
62 
63  std::sort(chargeSigns.begin(), chargeSigns.end());
64  auto newEnd = std::unique(chargeSigns.begin(), chargeSigns.end());
65 
66  return std::distance(chargeSigns.begin(), newEnd);
67  } // return unit: none
68  };
69 
71 }
Belle2::SelVarHelper
contains a collection of functions and related stuff needed for SelectionVariables implementing 2-,...
Definition: SelectionVariableHelper.h:31
Belle2::ZIGGZAGGRZ_NAME::PUT_NAME_FUNCTION
PUT_NAME_FUNCTION(ZIGGZAGGRZ_NAME)
is replaced by "static const std:string name(void)" frunction which returns name of the Class
Belle2::ZIGGZAGGRZ_NAME
checks whether chain of segments are zigg-zagging (changing sign of curvature of neighbouring segment...
Definition: ZiggZaggRZ.h:35
Belle2::B2Vector3D
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:507
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SelectionVariable
Base class of the selection variable objects used for pair filtering.
Definition: SelectionVariable.h:54
Belle2::ZIGGZAGGRZ_NAME::value
static int value(const PointContainerType &hitContainer)
checks whether chain of segments are zigg-zagging (changing sign of curvature of neighbouring segment...
Definition: ZiggZaggRZ.h:42