Belle II Software development
fourHitFilters.cc
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#include <gtest/gtest.h>
10
11#include <tracking/spacePointCreation/SpacePoint.h>
12#include <tracking/trackFindingVXD/filterMap/threeHitVariables/CircleCenterXY.h>
13#include <tracking/trackFindingVXD/filterMap/fourHitVariables/DeltaPt.h>
14#include <tracking/trackFindingVXD/filterMap/fourHitVariables/DeltaCircleRadius.h>
15#include <tracking/trackFindingVXD/filterMap/fourHitVariables/DeltaDistCircleCenter.h>
16#include <tracking/trackFindingVXD/filterTools/SelectionVariableHelper.h>
17
18#include <tracking/trackFindingVXD/filterMap/filterFramework/Shortcuts.h>
19
20#include <framework/geometry/B2Vector3.h>
21
22#include <vxd/geometry/SensorInfoBase.h>
23
24#include <math.h>
25
26
27using namespace std;
28using namespace Belle2;
29
30namespace VXDTFfourHitFilterTest {
31
33 class FourHitFilterTest : public ::testing::Test {
34 protected:
35 };
36
37
38
40 VXD::SensorInfoBase createSensorInfo(VxdID aVxdID, double globalX = 0., double globalY = 0., double globalZ = -0.)
41 {
42 // (SensorType type, VxdID id, double width, double length, double thickness, int uCells, int vCells, double width2=-1, double splitLength=-1, int vCells2=0)
43 VXD::SensorInfoBase sensorInfoBase(VXD::SensorInfoBase::PXD, aVxdID, 2.3, 4.2, 0.3, 2, 4, -1);
44
45 TGeoRotation r1;
46 r1.SetAngles(45, 20, 30); // rotation defined by Euler angles
47 TGeoTranslation t1(globalX, globalY, globalZ);
48 TGeoCombiTrans c1(t1, r1);
49 TGeoHMatrix transform = c1;
50 sensorInfoBase.setTransformation(transform);
51 // also need to set the reco-transform
52 sensorInfoBase.setTransformation(transform, true);
53
54 return sensorInfoBase;
55 }
56
57
58
60 SpacePoint provideSpacePointDummy(double X, double Y, double Z)
61 {
62 VxdID aVxdID = VxdID(1, 1, 1);
63 VXD::SensorInfoBase sensorInfoBase = createSensorInfo(aVxdID, X, Y, Z);
64
65 PXDCluster aCluster = PXDCluster(aVxdID, 0., 0., 0.1, 0.1, 0, 0, 1, 1, 1, 1, 1, 1);
66
67 return SpacePoint(&aCluster, &sensorInfoBase);
68 }
69
70
71
73 double lastResult = 0.;
74
75
76
79 public:
81 template<class Var, typename ... otherTypes>
82 static void notify(const Var& filterType,
83 typename Var::variableType fResult,
84 otherTypes ...)
85 {
86 B2INFO("ResultsObserver: Filter " << filterType.name() << " got result of " << fResult);
87 lastResult = fResult;
88 }
89
90 };
91
92
94 TEST_F(FourHitFilterTest, SpacePointCreation)
95 {
96 SpacePoint testSP = provideSpacePointDummy(1.2, 2.3, 4.2);
97 EXPECT_FLOAT_EQ(1.2, testSP.getPosition().X()) ;
98 EXPECT_FLOAT_EQ(2.3, testSP.getPosition().Y()) ;
99 EXPECT_FLOAT_EQ(4.2, testSP.getPosition().Z()) ;
100 }
101
102
104 TEST_F(FourHitFilterTest, SelectionVariableName)
105 {
106 auto dDCircleCenter = DeltaDistCircleCenter<SpacePoint>();
107 EXPECT_EQ("DeltaDistCircleCenter", dDCircleCenter.name());
108 auto dPt = DeltaPt<SpacePoint>();
109 EXPECT_EQ("DeltaPt", dPt.name());
110 }
111
112
114 TEST_F(FourHitFilterTest, TestDeltaPtAndDeltaDistCircleCenter)
115 {
116 SpacePoint outerSP = provideSpacePointDummy(0, 0, 0.);
117 SpacePoint outerCenterSP = provideSpacePointDummy(-2, 0, 0.);
118 SpacePoint innerCenterSP = provideSpacePointDummy(0, 2, 0.);
119 SpacePoint innerSP = provideSpacePointDummy(2, 0, 0.);
120
121 B2Vector3D centerO_OC_IC = CircleCenterXY<SpacePoint>::value(outerSP, outerCenterSP, innerCenterSP);
122 B2Vector3D centerOC_IC_I = CircleCenterXY<SpacePoint>::value(outerCenterSP, innerCenterSP, innerSP);
123 EXPECT_FLOAT_EQ(-1., centerO_OC_IC[0]);
124 EXPECT_FLOAT_EQ(1., centerO_OC_IC[1]);
125 EXPECT_FLOAT_EQ(0., centerOC_IC_I[0]);
126 EXPECT_FLOAT_EQ(0., centerOC_IC_I[1]);
127
128 Filter< DeltaDistCircleCenter<SpacePoint>, Range<double, double>, ResultsObserver > filterDeltaDistCircleCenter(
129 Range<double, double>(1.41, 1.42));
130 EXPECT_TRUE(filterDeltaDistCircleCenter.accept(outerSP, outerCenterSP, innerCenterSP, innerSP));
131 EXPECT_FLOAT_EQ(sqrt(2), lastResult);
132
133 Filter< DeltaPt<SpacePoint>, Range<double, double>, ResultsObserver > filteDeltaPt(Range<double, double>(0.002, 0.003));
134 EXPECT_TRUE(filteDeltaPt.accept(outerSP, outerCenterSP, innerCenterSP, innerSP));
135 EXPECT_FLOAT_EQ(0.00263349, lastResult);
136
137 Filter< DeltaCircleRadius<SpacePoint>, Range<double, double>, ResultsObserver > filteDeltaCircleRadius(Range<double, double>(-0.59,
138 -0.58));
139 EXPECT_TRUE(filteDeltaCircleRadius.accept(outerSP, outerCenterSP, innerCenterSP, innerSP));
140 EXPECT_FLOAT_EQ(-0.58578646, lastResult); // outerRad = 1.41..., innerRad = 2 -> outer - inner
141 }
142
143}
144
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
This class is used to select pairs, triplets... of objects.
Definition: Filter.h:34
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
Represents a range of arithmetic types.
Definition: Range.h:29
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
const B2Vector3D & getPosition() const
return the position vector in global coordinates
Definition: SpacePoint.h:138
Base class to provide Sensor Information for PXD and SVD.
The most CPU efficient Observer for the VXDTF filter tools (even if useless).
Definition: VoidObserver.h:30
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
Test class for these new and shiny two-hit-filters.
takes result, prints it and stores it to lastResult
static void notify(const Var &filterType, typename Var::variableType fResult, otherTypes ...)
notify function is called by the filter, this one takes result, prints it and stores it to lastResult...
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.
STL namespace.