Belle II Software  release-08-01-10
trackletFilters.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/spacePointCreation/SpacePointTrackCand.h>
13 #include <tracking/trackFindingVXD/filterMap/trackletVariables/ZiggZaggXY.h>
14 #include <tracking/trackFindingVXD/filterMap/trackletVariables/ZiggZaggXYWithSigma.h>
15 #include <tracking/trackFindingVXD/filterMap/trackletVariables/ZiggZaggRZ.h>
16 
17 #include <tracking/trackFindingVXD/filterMap/filterFramework/Shortcuts.h>
18 
19 #include <vxd/geometry/SensorInfoBase.h>
20 
21 using namespace std;
22 using namespace Belle2;
23 
24 namespace VXDTFtrackletFilterTest {
25 
27  class TrackletFilterTest : public ::testing::Test {
28  protected:
29  };
30 
31 
32 
34  VXD::SensorInfoBase createSensorInfo(VxdID aVxdID, double globalX = 0., double globalY = 0., double globalZ = -0.)
35  {
36  // (SensorType type, VxdID id, double width, double length, double thickness, int uCells, int vCells, double width2=-1, double splitLength=-1, int vCells2=0)
37  VXD::SensorInfoBase sensorInfoBase(VXD::SensorInfoBase::PXD, aVxdID, 2.3, 4.2, 0.3, 2, 4, -1);
38 
39  TGeoRotation r1;
40  r1.SetAngles(45, 20, 30); // rotation defined by Euler angles
41  TGeoTranslation t1(globalX, globalY, globalZ);
42  TGeoCombiTrans c1(t1, r1);
43  TGeoHMatrix transform = c1;
44  sensorInfoBase.setTransformation(transform);
45  // also need the reco-transform
46  sensorInfoBase.setTransformation(transform, true);
47 
48  return sensorInfoBase;
49  }
50 
51 
52 
54  SpacePoint provideSpacePointDummy(double X, double Y, double Z)
55  {
56  VxdID aVxdID = VxdID(1, 1, 1);
57  VXD::SensorInfoBase sensorInfoBase = createSensorInfo(aVxdID, X, Y, Z);
58 
59  PXDCluster aCluster = PXDCluster(aVxdID, 0., 0., 0.1, 0.1, 0, 0, 1, 1, 1, 1, 1, 1);
60 
61  return SpacePoint(&aCluster, &sensorInfoBase);
62  }
63 
64 
65 
67  int lastResult = 0;
68 
69 
70 
72  class ResultsObserver : public VoidObserver {
73  public:
75  template<class Var, typename ... otherTypes>
76  static void notify(const Var& filterType,
77  typename Var::variableType fResult,
78  otherTypes ...)
79  {
80  B2INFO("ResultsObserver: Filter " << filterType.name() << " got result of " << fResult);
81  lastResult = fResult;
82  }
83 
84  };
85 
86 
88  TEST_F(TrackletFilterTest, SpacePointCreation)
89  {
90  SpacePoint testSP = provideSpacePointDummy(1.2, 2.3, 4.2);
91  EXPECT_FLOAT_EQ(1.2, testSP.getPosition().X()) ;
92  EXPECT_FLOAT_EQ(2.3, testSP.getPosition().Y()) ;
93  EXPECT_FLOAT_EQ(4.2, testSP.getPosition().Z()) ;
94  }
95 
96 
98  TEST_F(TrackletFilterTest, SelectionVariableName)
99  {
100  auto ziggZaggXYChecker = ZiggZaggXY<SpacePoint, SpacePointTrackCand>();
101  EXPECT_EQ("ZiggZaggXY", ziggZaggXYChecker.name());
102 
103  auto ziggZaggXYWithSigmaChecker = ZiggZaggXYWithSigma<SpacePoint, SpacePointTrackCand>();
104  EXPECT_EQ("ZiggZaggXYWithSigma", ziggZaggXYWithSigmaChecker.name());
105 
106  auto ziggZaggRZChecker = ZiggZaggRZ<SpacePoint, SpacePointTrackCand>();
107  EXPECT_EQ("ZiggZaggRZ", ziggZaggRZChecker.name());
108  }
109 
110 
112  TEST_F(TrackletFilterTest, TestZiggZagg)
113  {
114  // Info: the actual position is not important, the naming just indicates the way one should add hits to the containers!
115  SpacePoint outerSP = provideSpacePointDummy(1.1, 1., 1.); // R: 1.48660687
116  SpacePoint outerCenterSP = provideSpacePointDummy(2., 2., 2.); // R: 2.82842712
117  SpacePoint innerCenterSP = provideSpacePointDummy(3., 2.1, 3.); // R: 3.66196668
118  SpacePoint innerSP = provideSpacePointDummy(4., 3., 3.); // R: 5
119  SpacePoint innermostSP = provideSpacePointDummy(5., 3, 6.); // R: 5.83095189
120 
122  const std::vector<const Belle2::SpacePoint*> aSpacePointVec = { &outerSP, &outerCenterSP, &innerCenterSP, &innerSP };
123 
125  ziggZaggXYChecker4VecSPs(
126  ClosedRange<int, int>(1, 1));
127  EXPECT_FALSE(ziggZaggXYChecker4VecSPs.accept(aSpacePointVec));
128  EXPECT_EQ(2, lastResult);
129 
131  // should be ziggZagg:
132  SpacePointTrackCand aSpacePointTC = SpacePointTrackCand(aSpacePointVec, 11, -1, 23);
133 
134  Filter< ZiggZaggXY<SpacePoint, SpacePointTrackCand>, ClosedRange<int, int>, ResultsObserver > ziggZaggXYChecker4SPTC(
135  ClosedRange<int, int>(1, 1));
136  EXPECT_FALSE(ziggZaggXYChecker4SPTC.accept(aSpacePointTC));
137  EXPECT_EQ(2, lastResult);
139  ziggZaggXYWithSigmaChecker4SPTC(
140  ClosedRange<int, int>(0, 1));
141  EXPECT_FALSE(ziggZaggXYWithSigmaChecker4SPTC.accept(aSpacePointTC));
142  EXPECT_EQ(2, lastResult);
143  Filter< ZiggZaggRZ<SpacePoint, SpacePointTrackCand>, ClosedRange<int, int>, ResultsObserver > ziggZaggRZChecker4SPTC(
144  ClosedRange<int, int>(1, 1));
145  EXPECT_FALSE(ziggZaggRZChecker4SPTC.accept(aSpacePointTC));
146  EXPECT_EQ(2, lastResult);
147 
148 
149  // should be ziggZagg:
150  const std::vector<const Belle2::SpacePoint*> aSpacePointVec2 = { &outerSP, &outerCenterSP, &innerCenterSP, &innerSP, &innerSP };
151  SpacePointTrackCand aSpacePointTC2 = SpacePointTrackCand(aSpacePointVec2, 11, -1, 23);
152 
153  EXPECT_FALSE(ziggZaggXYChecker4SPTC.accept(aSpacePointTC2));
154  EXPECT_EQ(3, lastResult); // last two hits are identical, will be detected in Filter.
155  EXPECT_FALSE(ziggZaggXYWithSigmaChecker4SPTC.accept(aSpacePointTC2));
156  EXPECT_EQ(2, lastResult);
157  EXPECT_FALSE(ziggZaggRZChecker4SPTC.accept(aSpacePointTC2));
158  EXPECT_EQ(3, lastResult);
159 
160 
161  // should _not_ be ziggZagg:
162  const std::vector<const Belle2::SpacePoint*> aSpacePointVec3 = { &outerSP, &outerCenterSP, &innerSP, &innermostSP };
163  SpacePointTrackCand aSpacePointTC3 = SpacePointTrackCand(aSpacePointVec3, 11, -1, 23);
164 
165  EXPECT_TRUE(ziggZaggXYChecker4SPTC.accept(aSpacePointTC3));
166  EXPECT_EQ(1, lastResult);
167  EXPECT_TRUE(ziggZaggXYWithSigmaChecker4SPTC.accept(aSpacePointTC3));
168  EXPECT_EQ(1, lastResult);
169  EXPECT_FALSE(ziggZaggRZChecker4SPTC.accept(aSpacePointTC3));
170  EXPECT_EQ(2, lastResult);
171 
172 
173  // /** Difference between ZiggZaggs (no RZ-test here) **/
174  SpacePoint testSP1 = provideSpacePointDummy(1.001, 1., 0.); // sets to positionSigma of ~0.1 in x,y,z!
175  SpacePoint testSP2 = provideSpacePointDummy(2., 2.0002, 0.); // sets to positionSigma of ~0.1 in x,y,z!
176  SpacePoint testSP3 = provideSpacePointDummy(3.0005, 3., 0.); // sets to positionSigma of ~0.1 in x,y,z!
177  SpacePoint testSP4 = provideSpacePointDummy(4., 4.0003, 0.); // sets to positionSigma of ~0.1 in x,y,z!
178  SpacePoint testSP5 = provideSpacePointDummy(5.001, 5., 0.); // sets to positionSigma of ~0.1 in x,y,z!
179  const std::vector<const Belle2::SpacePoint*> aSpacePointVec4 = { &testSP1, &testSP2, &testSP3, &testSP4, &testSP5 };
180  SpacePointTrackCand aSpacePointTC4 = SpacePointTrackCand(aSpacePointVec4, 11, -1, 23);
181 
182  EXPECT_FALSE(ziggZaggXYChecker4SPTC.accept(aSpacePointTC4));
183  EXPECT_EQ(2, lastResult);
184  EXPECT_TRUE(ziggZaggXYWithSigmaChecker4SPTC.accept(aSpacePointTC4)); // does not ziggZagg due to positionSigma != 0
185  EXPECT_EQ(0, lastResult);
186 
187  }
188 
189 }
190 
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
Represents a closed set of arithmetic types.
Definition: ClosedRange.h:32
This class is used to select pairs, triplets...
Definition: Filter.h:34
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
Storage for (VXD) SpacePoint-based track candidates.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
const B2Vector3< double > & 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
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.
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Definition: globalLabel.cc:72
Abstract base class for different kinds of events.