9#include <gtest/gtest.h>
11#include <tracking/spacePointCreation/SpacePoint.h>
12#include <tracking/trackFindingVXD/filterMap/threeHitVariables/Angle3DSimple.h>
13#include <tracking/trackFindingVXD/filterMap/threeHitVariables/Angle3DFull.h>
14#include <tracking/trackFindingVXD/filterMap/threeHitVariables/CosAngleXY.h>
15#include <tracking/trackFindingVXD/filterMap/threeHitVariables/AngleXYFull.h>
16#include <tracking/trackFindingVXD/filterMap/threeHitVariables/AngleRZSimple.h>
17#include <tracking/trackFindingVXD/filterMap/threeHitVariables/AngleRZFull.h>
18#include <tracking/trackFindingVXD/filterMap/threeHitVariables/CircleDist2IP.h>
19#include <tracking/trackFindingVXD/filterMap/threeHitVariables/SignCurvatureXY.h>
20#include <tracking/trackFindingVXD/filterMap/threeHitVariables/SignCurvatureXYError.h>
21#include <tracking/trackFindingVXD/filterMap/threeHitVariables/DeltaSlopeRZ.h>
22#include <tracking/trackFindingVXD/filterMap/threeHitVariables/DeltaSlopeZoverS.h>
23#include <tracking/trackFindingVXD/filterMap/threeHitVariables/DeltaSoverZ.h>
24#include <tracking/trackFindingVXD/filterMap/threeHitVariables/HelixParameterFit.h>
25#include <tracking/trackFindingVXD/filterMap/threeHitVariables/Pt.h>
26#include <tracking/trackFindingVXD/filterMap/threeHitVariables/CircleRadius.h>
27#include <tracking/trackFindingVXD/filterTools/SelectionVariableHelper.h>
29#include <tracking/trackFindingVXD/filterMap/filterFramework/Shortcuts.h>
31#include <vxd/geometry/SensorInfoBase.h>
39namespace VXDTFthreeHitFilterTest {
55 r1.SetAngles(45, 20, 30);
56 TGeoTranslation t1(globalX, globalY, globalZ);
57 TGeoCombiTrans c1(t1, r1);
58 TGeoHMatrix transform = c1;
59 sensorInfoBase.setTransformation(transform);
61 sensorInfoBase.setTransformation(transform,
true);
63 return sensorInfoBase;
69 SpacePoint provideSpacePointDummy(
double X,
double Y,
double Z)
74 PXDCluster aCluster =
PXDCluster(aVxdID, 0., 0., 0.1, 0.1, 0, 0, 1, 1, 1, 1, 1, 1);
81 SpacePoint provideSpacePointDummyError(
double X,
double Y,
double Z,
double eX,
double eY,
double eZ)
94 double lastResult = 0.;
102 template<
class Var,
typename ... otherTypes>
103 static void notify(
const Var& filterType,
104 typename Var::variableType fResult,
107 B2INFO(
"ResultsObserver: Filter " << filterType.name() <<
" got result of " << fResult);
108 lastResult = fResult;
115 TEST_F(ThreeHitFilterTest, SpacePointCreation)
117 SpacePoint testSP = provideSpacePointDummy(1.2, 2.3, 4.2);
125 TEST_F(ThreeHitFilterTest, SelectionVariableName)
127 auto angle3DS = Angle3DSimple<SpacePoint>();
128 EXPECT_EQ(
"Angle3DSimple", angle3DS.name());
129 auto angle3DF = Angle3DFull<SpacePoint>();
130 EXPECT_EQ(
"Angle3DFull", angle3DF.name());
131 auto angleXYF = AngleXYFull<SpacePoint>();
132 EXPECT_EQ(
"AngleXYFull", angleXYF.name());
133 auto angleXYS = CosAngleXY<SpacePoint>();
134 EXPECT_EQ(
"CosAngleXY", angleXYS.name());
135 auto angleRZF = AngleRZFull<SpacePoint>();
136 EXPECT_EQ(
"AngleRZFull", angleRZF.name());
137 auto angleRZS = AngleRZSimple<SpacePoint>();
138 EXPECT_EQ(
"AngleRZSimple", angleRZS.name());
139 auto dSlopeRZ = DeltaSlopeRZ<SpacePoint>();
140 EXPECT_EQ(
"DeltaSlopeRZ", dSlopeRZ.name());
141 auto helixFit = HelixParameterFit<SpacePoint>();
142 EXPECT_EQ(
"HelixParameterFit", helixFit.name());
143 auto dSlopeZS = DeltaSlopeZoverS<SpacePoint>();
144 EXPECT_EQ(
"DeltaSlopeZoverS", dSlopeZS.name());
145 auto dSZ = DeltaSoverZ<SpacePoint>();
146 EXPECT_EQ(
"DeltaSoverZ", dSZ.name());
147 auto pT = Pt<SpacePoint>();
148 EXPECT_EQ(
"Pt", pT.name());
149 auto cDist2IP = CircleDist2IP<SpacePoint>();
150 EXPECT_EQ(
"CircleDist2IP", cDist2IP.name());
155 TEST_F(ThreeHitFilterTest, BasicFilterTestAngle3DSimple)
160 SpacePoint x1 = provideSpacePointDummy(0., 0., 0.);
161 SpacePoint x2 = provideSpacePointDummy(.5, 0., 0.);
162 SpacePoint x3 = provideSpacePointDummy(2., 0., 0.);
164 EXPECT_FALSE(
filter.accept(x1, x2, x3));
170 TEST_F(ThreeHitFilterTest, TestAngles)
172 SpacePoint outerSP = provideSpacePointDummy(6., 4., 1.);
173 SpacePoint centerSP = provideSpacePointDummy(3., 3., 0.);
174 SpacePoint innerSP = provideSpacePointDummy(1., 1., 0.);
179 EXPECT_TRUE(filterAngle3D.accept(outerSP, centerSP, innerSP));
180 EXPECT_FLOAT_EQ(0.090909090909090909091, lastResult);
184 EXPECT_TRUE(filterAngle3Dfull.accept(outerSP, centerSP, innerSP));
185 EXPECT_FLOAT_EQ(31.4821541052938556040832384555411729852856, lastResult);
190 EXPECT_TRUE(filterAngleXYfull.accept(outerSP, centerSP, innerSP));
191 EXPECT_FLOAT_EQ(26.5650511770779893515721937204532946712042, lastResult);
195 EXPECT_TRUE(filterAngleXY.accept(outerSP, centerSP, innerSP));
196 EXPECT_NEAR(0.89442718, lastResult, 0.0000001);
201 EXPECT_TRUE(filterAngleRZfull.accept(outerSP, centerSP, innerSP));
202 EXPECT_NEAR(17.548400613792298064, lastResult, 0.001);
206 EXPECT_TRUE(filterAngleRZ.accept(outerSP, centerSP, innerSP));
207 EXPECT_NEAR(cos(17.54840061379229806435203716652846677620 * M_PI / 180.), lastResult, 0.001);
213 TEST_F(ThreeHitFilterTest, TestSignAndOtherFilters)
215 SpacePoint outerSP = provideSpacePointDummy(6., 4., 1.);
216 SpacePoint centerSP = provideSpacePointDummy(3., 3., 0.);
217 SpacePoint innerSP = provideSpacePointDummy(1., 1., 0.);
218 SpacePoint outerHighSP = provideSpacePointDummy(4., 6., 1.);
219 B2Vector3D sigma(.01, .01, .01), unrealsigma(2, 2, 2);
221 SpacePoint outerSPsigma = provideSpacePointDummyError(6., 4., 1., 0.01, 0.01, 0.01);
222 SpacePoint centerSPsigma = provideSpacePointDummyError(3., 3., 0., 0.01, 0.01, 0.01);
223 SpacePoint innerSPsigma = provideSpacePointDummyError(1., 1., 0., 0.01, 0.01, 0.01);
224 SpacePoint outerHighSPsigma = provideSpacePointDummyError(4., 6., 1., 0.01, 0.01, 0.01);
226 SpacePoint outerSPunrealsigma = provideSpacePointDummyError(6., 4., 1., 2., 2., 2.);
227 SpacePoint centerSPunrealsigma = provideSpacePointDummyError(3., 3., 0., 2., 2., 2.);
228 SpacePoint innerSPunrealsigma = provideSpacePointDummyError(1., 1., 0., 2., 2., 2.);
232 EXPECT_TRUE(filterDeltaSlopeRZ.accept(outerSP, centerSP, innerSP));
233 EXPECT_FLOAT_EQ(0.30627736916966945608, lastResult);
237 EXPECT_TRUE(filterHelixFit.accept(outerSP, centerSP, innerSP));
238 EXPECT_FLOAT_EQ(0., lastResult);
240 EXPECT_DOUBLE_EQ(1., SignCurvatureXYError<SpacePoint>::value(outerSPsigma, centerSPsigma, innerSPsigma));
241 EXPECT_DOUBLE_EQ(-1., SignCurvatureXYError<SpacePoint>::value(outerHighSPsigma, centerSPsigma, innerSPsigma));
242 EXPECT_DOUBLE_EQ(-1., SignCurvatureXYError<SpacePoint>::value(innerSPsigma, centerSPsigma, outerSPsigma));
244 EXPECT_DOUBLE_EQ(0., SignCurvatureXYError<SpacePoint>::value(outerSPunrealsigma, centerSPunrealsigma, innerSPunrealsigma));
246 EXPECT_LT(0., SignCurvatureXY<SpacePoint>::value(outerSP, centerSP, innerSP));
247 EXPECT_GT(0., SignCurvatureXY<SpacePoint>::value(outerHighSP, centerSP, innerSP));
248 EXPECT_GT(0., SignCurvatureXY<SpacePoint>::value(innerSP, centerSP, outerSP));
249 EXPECT_LT(0., SignCurvatureXY<SpacePoint>::value(outerSP, centerSP, innerSP));
251 EXPECT_DOUBLE_EQ(1., SignCurvatureXY<SpacePoint>::value(outerSP, centerSP, innerSP));
252 EXPECT_DOUBLE_EQ(-1., SignCurvatureXY<SpacePoint>::value(outerHighSP, centerSP, innerSP));
253 EXPECT_DOUBLE_EQ(-1., SignCurvatureXY<SpacePoint>::value(innerSP, centerSP, outerSP));
259 TEST_F(ThreeHitFilterTest, TestDeltaSOverZ)
262 B2Vector3D iVec(1., 1., 0.), cVec(3., 3., 1.), oVec(6., 4., 3.);
263 SpacePoint outerSP = provideSpacePointDummy(oVec.X(), oVec.Y(), oVec.Z());
264 SpacePoint centerSP = provideSpacePointDummy(cVec.X(), cVec.Y(), cVec.Z());
265 SpacePoint innerSP = provideSpacePointDummy(iVec.X(), iVec.Y(), iVec.Z());
270 EXPECT_TRUE(filterDeltaSlopeZOverS.accept(outerSP, centerSP, innerSP));
271 EXPECT_NEAR(0.31823963, lastResult, 0.00001);
275 EXPECT_TRUE(filterDeltaSOverZ.accept(outerSP, centerSP, innerSP));
276 EXPECT_FLOAT_EQ(-0.38471845, lastResult);
283 SpacePoint outerSP2 = provideSpacePointDummy(oVec.X(), oVec.Y(), oVec.Z());
284 SpacePoint centerSP2 = provideSpacePointDummy(cVec.X(), cVec.Y(), cVec.Z());
285 SpacePoint innerSP2 = provideSpacePointDummy(iVec.X(), iVec.Y(), iVec.Z());
287 EXPECT_TRUE(filterDeltaSlopeZOverS.accept(outerSP2, centerSP2, innerSP2));
288 EXPECT_NEAR(0.31823963, lastResult, 0.00001);
290 EXPECT_TRUE(filterDeltaSOverZ.accept(outerSP2, centerSP2, innerSP2));
291 EXPECT_FLOAT_EQ(-0.38471845, lastResult);
297 TEST_F(ThreeHitFilterTest, TestCalcPt)
301 SpacePoint outerSP = provideSpacePointDummy(3., 4., 3.);
302 SpacePoint centerSP = provideSpacePointDummy(3., 2., 1.);
303 SpacePoint innerSP = provideSpacePointDummy(1., 2., 0.);
305 SpacePoint outerSPEvil = provideSpacePointDummy(6., 3., 0.);
306 SpacePoint centerSP2 = provideSpacePointDummy(3., 3., 0.);
307 SpacePoint innerSP2 = provideSpacePointDummy(1., 1., 0.);
310 rawRadius = 1.414213562373095048801688724209698078570;
311 ptTrue = Helper::calcPt(rawRadius);
313 EXPECT_TRUE(filterPt.accept(outerSP, centerSP, innerSP));
314 EXPECT_FLOAT_EQ(ptTrue, lastResult);
316 ptTrue = 0.017118925181688543;
317 EXPECT_TRUE(filterPt.accept(outerSPEvil, centerSP2, innerSP2));
318 EXPECT_FLOAT_EQ(ptTrue, lastResult);
321 EXPECT_ANY_THROW(filterPt.accept(outerSP, outerSP, innerSP));
323 Helper::resetMagneticField(0.976);
324 double ptTrue1p5 = ptTrue;
325 ptTrue = Helper::calcPt(rawRadius);
326 EXPECT_FALSE(filterPt.accept(outerSP, centerSP, innerSP));
327 EXPECT_FLOAT_EQ(ptTrue, lastResult);
328 EXPECT_LT(ptTrue, ptTrue1p5);
330 Helper::resetMagneticField(1.5);
335 TEST_F(ThreeHitFilterTest, TestCircleRadius)
337 SpacePoint outerSP = provideSpacePointDummy(3., 4., 3.);
338 SpacePoint centerSP = provideSpacePointDummy(3., 2., 1.);
339 SpacePoint innerSP = provideSpacePointDummy(1., 2., 0.);
341 double rawRadius = 1.414213562373095048801688724209698078570;
343 EXPECT_TRUE(filterCrad.accept(outerSP, centerSP, innerSP));
344 EXPECT_FLOAT_EQ(rawRadius, lastResult);
347 EXPECT_ANY_THROW(filterCrad.accept(outerSP, outerSP, innerSP));
350 EXPECT_FLOAT_EQ(rawRadius, lastResult);
354 TEST_F(ThreeHitFilterTest, TestCircleDist2IP)
356 SpacePoint outerSPEvil = provideSpacePointDummy(6., 3., 0.);
357 SpacePoint outerSPSimple = provideSpacePointDummy(6., 4., 0.);
358 SpacePoint centerSP = provideSpacePointDummy(3., 3., 0.);
359 SpacePoint innerSP = provideSpacePointDummy(1., 1., 0.);
363 EXPECT_TRUE(filteCircleDist2IP.accept(outerSPSimple, centerSP, innerSP));
364 EXPECT_NEAR(0.44499173338941, lastResult, 0.00001);
366 EXPECT_FALSE(filteCircleDist2IP.accept(outerSPEvil, centerSP, innerSP));
367 EXPECT_FLOAT_EQ(0.719806016136754, lastResult);
371 Helper::resetMagneticField(0.976);
373 EXPECT_TRUE(filteCircleDist2IP.accept(outerSPSimple, centerSP, innerSP));
374 EXPECT_NEAR(0.44499173338941, lastResult, 0.00001);
376 EXPECT_FALSE(filteCircleDist2IP.accept(outerSPEvil, centerSP, innerSP));
377 EXPECT_FLOAT_EQ(0.719806016136754, lastResult);
379 Helper::resetMagneticField(1.5);
DataType Z() const
access variable Z (= .at(2) without boundary check)
DataType X() const
access variable X (= .at(0) without boundary check)
DataType Y() const
access variable Y (= .at(1) without boundary check)
This class is used to select pairs, triplets... of objects.
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Represents a range of arithmetic types.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
const B2Vector3D & getPosition() const
return the position vector in global coordinates
Base class to provide Sensor Information for PXD and SVD.
The most CPU efficient Observer for the VXDTF filter tools (even if useless).
Class to uniquely identify a any structure of the PXD and SVD.
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...
Test class for these new and shiny two-hit-filters.
std::map< ExpRun, std::pair< double, double > > filter(const std::map< ExpRun, std::pair< double, double > > &runs, double cut, std::map< ExpRun, std::pair< double, double > > &runsRemoved)
filter events to remove runs shorter than cut, it stores removed runs in runsRemoved
Abstract base class for different kinds of events.
contains a collection of functions and related stuff needed for SelectionVariables implementing 2-,...