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