Belle II Software development
ZiggZaggRZ.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
9#pragma once
10
11#include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariable.h>
12#include <tracking/trackFindingVXD/filterTools/SelectionVariableHelper.h>
13#include <framework/geometry/B2Vector3.h>
14#include <boost/math/special_functions/sign.hpp>
15
16#include <vector>
17#include <algorithm>
18
19
20#define ZIGGZAGGRZ_NAME ZiggZaggRZ
21
22namespace Belle2 {
32 template <typename PointType, typename PointContainerType >
33 class ZIGGZAGGRZ_NAME : public SelectionVariable< PointContainerType, 0, int > {
34 public:
37
38
40 static int value(const PointContainerType& hitContainer)
41 {
42 const unsigned nHits = hitContainer.size();
43 if (nHits < 4) return 1;
44
46 using boost::math::sign;
47
48 std::vector<B2Vector3D> vecRZ;
49 vecRZ.reserve(nHits);
50 for (const auto* hit : hitContainer) { // collect RZ-Vrsions of the hits:
51 vecRZ.push_back(B2Vector3D(Helper::calcPerp(*hit), hit->Z(), 0.));
52 }
53
54 std::vector<int> chargeSigns;
55 chargeSigns.reserve(nHits - 2);
56 for (unsigned i = 0; i < nHits - 2; ++i) {
57 int signVal = sign((vecRZ.at(i + 1) - vecRZ.at(i + 2)).Orthogonal() * (vecRZ.at(i) - vecRZ.at(i + 1)));
58 chargeSigns.push_back(signVal);
59 }
60
61 std::sort(chargeSigns.begin(), chargeSigns.end());
62 auto newEnd = std::unique(chargeSigns.begin(), chargeSigns.end());
63
64 return std::distance(chargeSigns.begin(), newEnd);
65 } // return unit: none
66 };
67
69}
Base class of the selection variable objects used for pair filtering.
checks whether chain of segments are zigg-zagging (changing sign of curvature of neighbouring segment...
Definition: ZiggZaggRZ.h:33
static int value(const PointContainerType &hitContainer)
checks whether chain of segments are zigg-zagging (changing sign of curvature of neighbouring segment...
Definition: ZiggZaggRZ.h:40
PUT_NAME_FUNCTION(ZIGGZAGGRZ_NAME)
is replaced by "static const std:string name(void)" frunction which returns name of the Class
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516
Abstract base class for different kinds of events.
contains a collection of functions and related stuff needed for SelectionVariables implementing 2-,...