Belle II Software  release-05-01-25
twoHitFilters.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Eugenio Paoloni (eugenio.paoloni@pi.infn.it) *
7  * Jakob Lettenbichler (jakob.lettenbichler@oeaw.ac.at) *
8  * *
9  * This software is provided "as is" without any warranty. *
10  **************************************************************************/
11 
12 #include <gtest/gtest.h>
13 
14 #include <tracking/spacePointCreation/SpacePoint.h>
15 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance3DSquared.h>
16 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance2DXYSquared.h>
17 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance1DZ.h>
18 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/SlopeRZ.h>
19 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/CosDirectionXY.h>
20 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance3DNormed.h>
21 
22 #include <tracking/trackFindingVXD/filterMap/filterFramework/Shortcuts.h>
23 
24 #include <vxd/geometry/SensorInfoBase.h>
25 #include <iostream>
26 #include <math.h>
27 
28 #include <functional>
29 
30 using namespace std;
31 
32 using namespace Belle2;
33 
34 namespace VXDTFtwoHitFilterTest {
35 
37  class TwoHitFilterTest : public ::testing::Test {
38  protected:
39  };
40 
41 
43  VXD::SensorInfoBase createSensorInfo(VxdID aVxdID, double globalX = 0., double globalY = 0., double globalZ = -0.)
44  {
45  // (SensorType type, VxdID id, double width, double length, double thickness, int uCells, int vCells, double width2=-1, double splitLength=-1, int vCells2=0)
46  VXD::SensorInfoBase sensorInfoBase(VXD::SensorInfoBase::PXD, aVxdID, 2.3, 4.2, 0.3, 2, 4, -1);
47 
48  TGeoRotation r1;
49  r1.SetAngles(45, 20, 30); // rotation defined by Euler angles
50  TGeoTranslation t1(globalX, globalY, globalZ);
51  TGeoCombiTrans c1(t1, r1);
52  TGeoHMatrix transform = c1;
53  sensorInfoBase.setTransformation(transform);
54  // also need the reco transform
55  sensorInfoBase.setTransformation(transform, true);
56 
57  return sensorInfoBase;
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 
74  template < class T>
75  class counter {
76  public:
77  static unsigned int used;
78  static unsigned int accepted;
79  static unsigned int rejected;
80  static unsigned int wasInf;
81  static unsigned int wasNan;
82  counter() {};
83  ~counter() {};
84  static void resetCounter()
85  {
86  counter<T>::used = 0;
91  }
92  };
93 
94 
95 
97  template<class T>
98  unsigned int counter<T>::used(0);
99  template<class T>
100  unsigned int counter<T>::accepted(0);
101  template<class T>
102  unsigned int counter<T>::rejected(0);
103  template<class T>
104  unsigned int counter<T>::wasInf(0);
105  template<class T>
106  unsigned int counter<T>::wasNan(0);
107 
108 
109 
112  public:
114  template<class Var, typename ... otherTypes>
115  static void notify(const Var&,
116  otherTypes ...)
117  {
118  counter<Var>::used ++ ;
119  }
120 
121  };
122 
123 
124 
125 
126 
128  class ErrorObserver : public VoidObserver {
129  public:
130  template<class Var, class Range, typename ... otherTypes>
132  static void notify(const Var& filterType,
133  typename Var::variableType fResult,
134  const Range& range,
135  const typename Var::argumentType& outerHit,
136  const typename Var::argumentType& innerHit,
137  otherTypes ...)
138  {
139  B2ERROR(" Filter " << filterType.name() << " got result of " << fResult);
140  }
141 
142  };
143 
144 
145 
146 
147 
149  class InfoObserver : public VoidObserver {
150  public:
152  template<class Var, class Range, typename ... otherTypes>
153  static void notify(const Var& filterType,
154  typename Var::variableType fResult,
155  const Range&,
156  const typename Var::argumentType& outerHit,
157  const typename Var::argumentType& innerHit,
158  otherTypes ...)
159  {
160  B2WARNING(" Filter " << filterType.name() << " with outerhit/innerhit: " << outerHit.getPosition().PrintStringXYZ() << "/" <<
161  innerHit.getPosition().PrintStringXYZ() << " got result of " << fResult);
162  }
163 
164  };
165 
166 
167 
168 
170  template<class FilterType> class VectorOfObservers : public VoidObserver {
171  public:
172 
174  typedef std::function< void (const typename FilterType::argumentType&, const typename FilterType::argumentType&, const FilterType&, typename FilterType::variableType)>
176 
178  using CStyleFunctionPointer = void(*)(const typename FilterType::argumentType&, const typename FilterType::argumentType&,
179  const FilterType&, typename FilterType::variableType) ;
180 
182  template<typename ... otherTypes>
183  static void notify(const FilterType& filterType,
184  typename FilterType::variableType fResult,
185  const typename FilterType::argumentType& outerHit,
186  const typename FilterType::argumentType& innerHit,
187  otherTypes ...)
188  {
189  B2INFO(" Filter " << filterType.name() << " with Mag of outer-/innerHit " << outerHit.getPosition().Mag() << "/" <<
190  innerHit.getPosition().Mag() << " got result of " << fResult << " and Observer-Vector sm_collectedObservers got " <<
191  VectorOfObservers<FilterType>::sm_collectedObservers.size() << " observers collected");
192  B2INFO(" Filter " << filterType.name() << " with Mag of outer-/innerHit " << outerHit.getPosition().Mag() << "/" <<
193  innerHit.getPosition().Mag() << " got result of " << fResult << " and Observer-Vector sm_collectedObserversCSTYLE got " <<
194  VectorOfObservers<FilterType>::sm_collectedObserversCSTYLE.size() << " observers collected");
195 
197  // for(auto& anObserver : CollectedObservers<FilterType>::collectedObservers) {
198  // anObserver(outerHit, innerHit, fResult);
199  // }
201  }
202 
203 
205  template <typename ObserverType>
206  static void addObserver(observerFunction newObserver)
207  {
208  VectorOfObservers<FilterType>::sm_collectedObservers.push_back(std::bind(&newObserver, std::placeholders::_1, std::placeholders::_2,
209  FilterType(), std::placeholders::_3));
210  }
211 
212 
214  static std::vector< observerFunction > sm_collectedObservers;
216  static std::vector< CStyleFunctionPointer > sm_collectedObserversCSTYLE;
217 
219 // static std::vector< std::_Bind<void (*(std::_Placeholder<1>, std::_Placeholder<2>, Belle2::Distance3DSquared, std::_Placeholder<3>))(Belle2::SpacePoint const&, Belle2::SpacePoint const&, Belle2::Distance3DSquared const&, float)> > sm_collectedObserversTry2;
220  };
221 
223  template<typename FilterType> std::vector< typename VectorOfObservers<FilterType>::observerFunction >
226  template<typename FilterType> std::vector< typename VectorOfObservers<FilterType>::CStyleFunctionPointer >
227  VectorOfObservers<FilterType>::sm_collectedObserversCSTYLE = {};
229 // template<typename FilterType> std::vector< typename VectorOfObservers<FilterType>::CStyleFunctionPointer > VectorOfObservers<FilterType>::sm_collectedObserversTry2 = {};
230 
231 
232 
234  TEST_F(TwoHitFilterTest, TestObserverFlexibility)
235  {
236  // Very verbose declaration, see below for convenient shortcuts
238  1.));
239 
240  // Filter< Distance3DSquared<SpacePoint>, Range<double, double>, VectorOfObservers<Distance3DSquared> > filter(unobservedFilter);
241  Filter< Distance3DSquared<SpacePoint>, Range<double, double>, InfoObserver > filter(unobservedFilter);
242  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
243  SpacePoint x2 = provideSpacePointDummy(0.5f , 0.0f, 0.0f);
244  SpacePoint x3 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
245  auto myCounter = counter<Distance3DSquared<SpacePoint>>();
246  myCounter.resetCounter();
247 
249 // auto storeFuncVariantA = std::bind( ((VectorOfObservers<Distance3DSquared>::observerFunction) &CountingObserver::notify), std::placeholders::_1, std::placeholders::_2, Distance3DSquared(), std::placeholders::_3);
250  // VectorOfObservers<Distance3DSquared>::sm_collectedObservers.push_back(storeFuncVariantA);
251 
253  auto storeFuncVariantB = std::bind(((VectorOfObservers<Distance3DSquared<SpacePoint>>::CStyleFunctionPointer)
254  &CountingObserver::notify), std::placeholders::_1, std::placeholders::_2, Distance3DSquared<SpacePoint>(),
255  std::placeholders::_3);
256 
257  char* realname(NULL);
258  int status(0);
259  realname = abi::__cxa_demangle(typeid(storeFuncVariantB).name(), 0, 0, &status);
260  std::string name(realname);
261  free(realname);
262  B2INFO("storeFuncVariantB is of type: " << name);
263 
264 // VectorOfObservers<Distance3DSquared>::sm_collectedObserversTry2.push_back(storeFuncVariantB);
265 
266 
268 // VectorOfObservers<Distance3DSquared>::sm_collectedObserversCSTYLE.push_back(storeFuncVariantB);
269 
271  // VectorOfObservers<Distance3DSquared>::addObserver(CountingObserver);
272  // VectorOfObservers<Distance3DSquared>::addObserver(WarningObserver);
273 
274 
275  filter.accept(x2, x1);
276  filter.accept(x3, x1);
277  EXPECT_EQ(0 , myCounter.used);
278 
279  }
280 
281 
282 
284  TEST_F(TwoHitFilterTest, SpacePointCreation)
285  {
286  SpacePoint testSP = provideSpacePointDummy(1.2, 2.3, 4.2);
287  EXPECT_FLOAT_EQ(1.2, testSP.getPosition().X()) ;
288  EXPECT_FLOAT_EQ(2.3, testSP.getPosition().Y()) ;
289  EXPECT_FLOAT_EQ(4.2, testSP.getPosition().Z()) ;
290 
291  }
292 
293 
295  TEST_F(TwoHitFilterTest, SelectionVariableName)
296  {
297  auto dist3D = Distance3DSquared<SpacePoint>();
298  EXPECT_EQ("Distance3DSquared" , dist3D.name());
299  auto dist2DXY = Distance2DXYSquared<SpacePoint>();
300  EXPECT_EQ("Distance2DXYSquared" , dist2DXY.name());
301  auto dist1DZ = Distance1DZ<SpacePoint>();
302  EXPECT_EQ("Distance1DZ" , dist1DZ.name());
303  auto slopeRZ = SlopeRZ<SpacePoint>();
304  EXPECT_EQ("SlopeRZ" , slopeRZ.name());
305 
306  }
307 
308 
310  TEST_F(TwoHitFilterTest, BasicFilterTestDistance3DSquared)
311  {
312  // Very verbose declaration, see below for convenient shortcuts
314 
315  SpacePoint x1 = provideSpacePointDummy(0. , 0., 0.);
316  SpacePoint x2 = provideSpacePointDummy(.5 , 0., 0.);
317  SpacePoint x3 = provideSpacePointDummy(2. , 0., 0.);
318 
319  EXPECT_TRUE(filter.accept(x1, x2));
320  EXPECT_FALSE(filter.accept(x1, x3));
321 
322  }
323 
324 
326  TEST_F(TwoHitFilterTest, BasicFilterTestDistance2DXYSquared)
327  {
328  // Very verbose declaration, see below for convenient shortcuts
330 
331  SpacePoint x1 = provideSpacePointDummy(0. , 0., 0.);
332  SpacePoint x2 = provideSpacePointDummy(.5 , 0., 0.);
333  SpacePoint x3 = provideSpacePointDummy(2. , 0., 0.);
334  SpacePoint x4 = provideSpacePointDummy(0. , 0., 2.);
335 
336  EXPECT_TRUE(filter.accept(x1, x2));
337  EXPECT_FALSE(filter.accept(x1, x3));
338  EXPECT_TRUE(filter.accept(x2, x4));
339 
340  }
341 
342 
344  TEST_F(TwoHitFilterTest, BasicFilterTestDistance1DZ)
345  {
346  // Very verbose declaration, see below for convenient shortcuts
348 
349  SpacePoint x1 = provideSpacePointDummy(0. , 0., 0.);
350  SpacePoint x2 = provideSpacePointDummy(0. , 0., .5);
351  SpacePoint x3 = provideSpacePointDummy(.25 , .25, 0.);
352  SpacePoint x4 = provideSpacePointDummy(0. , 0., 1.);
353 
354  EXPECT_TRUE(filter.accept(x2, x1));
355  EXPECT_FALSE(filter.accept(x1, x2)); // the input order is relevant
356  EXPECT_FALSE(filter.accept(x1, x3));
357  EXPECT_FALSE(filter.accept(x1, x4));
358 
359  }
360 
361 
363  TEST_F(TwoHitFilterTest, TemplateFilterTestDistance1DZ)
364  {
365  // Very verbose declaration, see below for convenient shortcuts
367 
368  SpacePoint x1 = provideSpacePointDummy(0. , 0., 0.);
369  SpacePoint x2 = provideSpacePointDummy(0. , 0., .5);
370  SpacePoint x3 = provideSpacePointDummy(.25 , .25, 0.);
371  SpacePoint x4 = provideSpacePointDummy(0. , 0., 1.);
372 
373  EXPECT_TRUE(filter.accept(x2, x1));
374  EXPECT_FALSE(filter.accept(x1, x2)); // the input order is relevant
375  EXPECT_FALSE(filter.accept(x1, x3));
376  EXPECT_FALSE(filter.accept(x1, x4));
377 
378  }
379 
380 
382  TEST_F(TwoHitFilterTest, BasicFilterTestSlopeRZ)
383  {
384  // Very verbose declaration, see below for convenient shortcuts
386 
387  SpacePoint innerSP = provideSpacePointDummy(1 , 2, 3);
388  SpacePoint outerSP1 = provideSpacePointDummy(1 , 4, 4);
389  SpacePoint outerSP2 = provideSpacePointDummy(1 , 4, 3.95);
390  SpacePoint outerSP3 = provideSpacePointDummy(1 , 4, 4.05);
391  SpacePoint outerSP4 = provideSpacePointDummy(1 , 3, 3.45);
392  SpacePoint outerSP5 = provideSpacePointDummy(1 , 3, 3.55);
393  SpacePoint outerSP6 = provideSpacePointDummy(1 , 4, 3);
394  SpacePoint outerSP7 = provideSpacePointDummy(1 , 0, 4);
395 
396  EXPECT_FALSE(filter.accept(outerSP3, innerSP));
397  EXPECT_FALSE(filter.accept(outerSP1, innerSP));
398  EXPECT_TRUE(filter.accept(outerSP2, innerSP));
399  EXPECT_FALSE(filter.accept(innerSP, outerSP2)); // reverse order not same result (because of z)
400  EXPECT_TRUE(filter.accept(outerSP4, innerSP));
401  EXPECT_FALSE(filter.accept(outerSP5, innerSP));
402  EXPECT_EQ(filter.accept(outerSP1, innerSP), filter.accept(outerSP7,
403  innerSP)); // (direction of r-vector not relevant, only its length)
404 
405 
406  auto sRZ = SlopeRZ<SpacePoint>();
407  EXPECT_FLOAT_EQ(0., sRZ.value(innerSP, innerSP));
408  EXPECT_FLOAT_EQ(atan(2.), sRZ.value(outerSP1, innerSP));
409  EXPECT_FLOAT_EQ(atan(2. / 0.95), sRZ.value(outerSP2, innerSP));
410  EXPECT_FLOAT_EQ(M_PI - sRZ.value(outerSP2, innerSP),
411  sRZ.value(innerSP, outerSP2)); // with latest bugfix reverse order will result in (Pi - SlopeRZ)
412  EXPECT_FLOAT_EQ(atan(2. / 1.05), sRZ.value(outerSP3, innerSP));
413  EXPECT_FLOAT_EQ(atan(1. / 0.45), sRZ.value(outerSP4, innerSP));
414  EXPECT_FLOAT_EQ(atan(1. / 0.55), sRZ.value(outerSP5, innerSP));
415  EXPECT_FLOAT_EQ(M_PI * 0.5, sRZ.value(outerSP6, innerSP)); // no problem with division by 0 in Z
416  EXPECT_FLOAT_EQ(atan(2. / 1.05), sRZ.value(outerSP3, innerSP));
417  EXPECT_FLOAT_EQ(sRZ.value(outerSP1, innerSP), sRZ.value(outerSP7,
418  innerSP)); // (direction of r-vector not relevant, only its length)
419 
420  }
421 
422 
424  TEST_F(TwoHitFilterTest, BasicFilterTestDistance3DNormed)
425  {
426  // Very verbose declaration, the old normed distance 3D has only an upper cut, no lower one:
428 
429  // prepare spacePoints for new stuff
430  SpacePoint innerSP = provideSpacePointDummy(1 , 2, 3);
431  SpacePoint outerSP1 = provideSpacePointDummy(2 , 3, 4);
432  SpacePoint outerSP2 = provideSpacePointDummy(1 , 2, 4);
433  SpacePoint outerSP3 = provideSpacePointDummy(2 , 3, 3);
434 
435  auto d3Dn = Distance3DNormed<SpacePoint>();
436  EXPECT_FLOAT_EQ(2. / 3., d3Dn.value(outerSP1, innerSP));
437  EXPECT_FLOAT_EQ(0., d3Dn.value(outerSP2, innerSP));
438  EXPECT_FLOAT_EQ(1., d3Dn.value(outerSP3, innerSP));
439  EXPECT_FLOAT_EQ(0., d3Dn.value(innerSP, innerSP));
440 
441  }
442 
443 
445  TEST_F(TwoHitFilterTest, ObservedFilter)
446  {
447  // Very verbose declaration, see below for convenient shortcuts
449  1.));
450 
451  Filter< Distance3DSquared<SpacePoint>, Range<double, double>, CountingObserver > filter(unobservedFilter);
452  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
453  SpacePoint x2 = provideSpacePointDummy(0.5f , 0.0f, 0.0f);
454  SpacePoint x3 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
455  auto myCounter = counter<Distance3DSquared<SpacePoint>>();
456  myCounter.resetCounter();
457 
458  EXPECT_TRUE(filter.accept(x1, x2));
459  EXPECT_FALSE(filter.accept(x1, x3));
460  EXPECT_EQ(2 , myCounter.used);
461  }
462 
463 
465  TEST_F(TwoHitFilterTest, BypassableFilter)
466  {
467  bool bypassControl(false);
468  // Very verbose declaration, see below for convenient shortcuts
470  (0., 1.));
471  auto filter = nonBypassableFilter.bypass(bypassControl);
472  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
473  SpacePoint x2 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
474  auto myCounter = counter<Distance3DSquared<SpacePoint>>();
475  myCounter.resetCounter();
476 
477  EXPECT_FALSE(filter.accept(x1, x2));
478  EXPECT_EQ(1 , myCounter.used);
479 
480  bypassControl = true;
481  EXPECT_TRUE(filter.accept(x1, x2));
482  EXPECT_EQ(2 , myCounter.used);
483 
484  }
485 
486 
488  TEST_F(TwoHitFilterTest, Shortcuts)
489  {
490 
491  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
492  SpacePoint x2 = provideSpacePointDummy(0.5f , 0.0f, 0.0f);
493  SpacePoint x3 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
494 
495  auto filterSup = (Distance3DSquared<SpacePoint>() < 1.) ;
496  EXPECT_TRUE(filterSup.accept(x1, x2));
497  EXPECT_FALSE(filterSup.accept(x1, x3));
498 
499  auto filterSup2 = (1 > Distance3DSquared<SpacePoint>()) ;
500  EXPECT_TRUE(filterSup2.accept(x1, x2));
501  EXPECT_FALSE(filterSup2.accept(x1, x3));
502 
503  auto filterInf = (Distance3DSquared<SpacePoint>() > 1.) ;
504  EXPECT_TRUE(filterInf.accept(x1, x3));
505  EXPECT_FALSE(filterInf.accept(x1, x2));
506 
507  auto filterInf2 = (1 < Distance3DSquared<SpacePoint>()) ;
508  EXPECT_TRUE(filterInf2.accept(x1, x3));
509  EXPECT_FALSE(filterInf2.accept(x1, x2));
510 
511  auto filterRange = (0.1 < Distance3DSquared<SpacePoint>() < 1);
512  EXPECT_FALSE(filterRange.accept(x1, x1));
513  EXPECT_TRUE(filterRange.accept(x1, x2));
514  EXPECT_FALSE(filterRange.accept(x1, x3));
515 
516  }
517 
518 
520  TEST_F(TwoHitFilterTest, BooleanOperations)
521  {
522 
523  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
524  SpacePoint x2 = provideSpacePointDummy(1.0f , 0.0f, 0.0f);
525  SpacePoint x3 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
526 
527  auto filter = !(Distance3DSquared<SpacePoint>() > 1.);
528  EXPECT_TRUE(filter.accept(x1, x2));
529  EXPECT_TRUE(filter.accept(x1, x1));
530  EXPECT_FALSE(filter.accept(x1, x3));
531 
532  auto filter2 =
533  !(Distance3DSquared<SpacePoint>() > 1.) &&
534  !(Distance3DSquared<SpacePoint>() < 1);
535  // i.e. Distance3DSquared == 1
536  EXPECT_TRUE(filter2.accept(x1, x2));
537  EXPECT_FALSE(filter2.accept(x1, x1));
538  EXPECT_FALSE(filter2.accept(x1, x3));
539 
540 
541  auto filter3 =
542  (Distance3DSquared<SpacePoint>() > 1.) ||
543  (Distance3DSquared<SpacePoint>() < 1);
544  // i.e. Distance3DSquared != 1
545  EXPECT_FALSE(filter3.accept(x1, x2));
546  EXPECT_TRUE(filter3.accept(x1, x1));
547  EXPECT_TRUE(filter3.accept(x1, x3));
548 
549  }
550 
551 
553  TEST_F(TwoHitFilterTest, ShortCircuitsEvaluation)
554  {
555  auto filter(
556  ((Distance2DXYSquared<SpacePoint>() < 1) &&
557  (Distance3DSquared<SpacePoint>() < 1)).observe(CountingObserver())
558  );
559 
560  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
561  SpacePoint x3 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
562 
563  auto counter3D = counter<Distance3DSquared<SpacePoint>>();
564  auto counter2D = counter<Distance2DXYSquared<SpacePoint>>();
565  counter3D.used = 0;
566  counter2D.used = 0;
567 
568  EXPECT_FALSE(filter.accept(x1, x3));
569  EXPECT_EQ(1 , counter2D.used);
570  EXPECT_EQ(0 , counter3D.used);
571 
572  EXPECT_TRUE(filter.accept(x1, x1));
573  EXPECT_EQ(2 , counter2D.used);
574  EXPECT_EQ(1 , counter3D.used);
575 
576  }
577 
579  TEST_F(TwoHitFilterTest, TestCosDirectionXY)
580  {
581  SpacePoint x1 = provideSpacePointDummy(2.0f , 1.0f, 0.0f);
582  SpacePoint x2 = provideSpacePointDummy(1.0f , -2.0f, 0.0f);
583  SpacePoint x3 = provideSpacePointDummy(1.0f , 0.0f, 0.0f);
584  SpacePoint x4 = provideSpacePointDummy(0.5f , 0.86602540378443f, 0.0f);
585 
586  EXPECT_FLOAT_EQ(0., CosDirectionXY<SpacePoint>::value(x1, x2));
587  EXPECT_NEAR(0.5, CosDirectionXY<SpacePoint>::value(x3, x4), 0.0000001);
588  }
589 }
VXDTFtwoHitFilterTest::ErrorObserver
this observer does simply print the name of the SelectionVariable and the result of its value-functio...
Definition: twoHitFilters.cc:128
VXDTFtwoHitFilterTest::InfoObserver
this observer does simply print the name of the SelectionVariable and the result of its value-functio...
Definition: twoHitFilters.cc:149
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
VXDTFtwoHitFilterTest::TwoHitFilterTest
Test class for these new and shiny two-hit-filters.
Definition: twoHitFilters.cc:37
VXDTFtwoHitFilterTest::CountingObserver
this observer does simply count the number of times, the attached Filter was used
Definition: twoHitFilters.cc:111
Belle2::VXD::SensorInfoBase
Base class to provide Sensor Information for PXD and SVD.
Definition: SensorInfoBase.h:40
Belle2::filter
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
Definition: Splitter.cc:43
VXDTFtwoHitFilterTest::counter::~counter
~counter()
constructor.
Definition: twoHitFilters.cc:83
Belle2::B2Vector3::Z
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:434
VXDTFtwoHitFilterTest::VectorOfObservers::sm_collectedObserversCSTYLE
static std::vector< CStyleFunctionPointer > sm_collectedObserversCSTYLE
collects observers with c-style function pointers to be executed during notify (variant B)
Definition: twoHitFilters.cc:216
VXDTFtwoHitFilterTest::VectorOfObservers::notify
static void notify(const FilterType &filterType, typename FilterType::variableType fResult, const typename FilterType::argumentType &outerHit, const typename FilterType::argumentType &innerHit, otherTypes ...)
iterate over all stored Observers and execute their notify-function
Definition: twoHitFilters.cc:183
VXDTFtwoHitFilterTest::VectorOfObservers::addObserver
static void addObserver(observerFunction newObserver)
collects observers to be executed during notify (can not be used so far, but is long-term goal)
Definition: twoHitFilters.cc:206
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::UpperBoundedSet
Represents an upper bounded set of arithmetic types.
Definition: UpperBoundedSet.h:39
Belle2::SpacePoint::getPosition
const B2Vector3< double > & getPosition() const
return the position vector in global coordinates
Definition: SpacePoint.h:148
VXDTFtwoHitFilterTest::counter::accepted
static unsigned int accepted
count number of times result was accepted
Definition: twoHitFilters.cc:78
VXDTFtwoHitFilterTest::counter::wasInf
static unsigned int wasInf
count number of times result was inf
Definition: twoHitFilters.cc:80
VXDTFtwoHitFilterTest::ErrorObserver::notify
static void notify(const Var &filterType, typename Var::variableType fResult, const Range &range, const typename Var::argumentType &outerHit, const typename Var::argumentType &innerHit, otherTypes ...)
notifier: print the name of the SelectionVariable and the result of its value-function as an Error.
Definition: twoHitFilters.cc:132
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
VXDTFtwoHitFilterTest::VectorOfObservers::sm_collectedObservers
static std::vector< observerFunction > sm_collectedObservers
collects observers with std::function to be executed during notify (variant A)
Definition: twoHitFilters.cc:214
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
VXDTFtwoHitFilterTest::VectorOfObservers::observerFunction
std::function< void(const typename FilterType::argumentType &, const typename FilterType::argumentType &, const FilterType &, typename FilterType::variableType)> observerFunction
a typedef to make the stuff more readable
Definition: twoHitFilters.cc:175
VXDTFtwoHitFilterTest::counter::rejected
static unsigned int rejected
count number of times result was rejected
Definition: twoHitFilters.cc:79
VXDTFtwoHitFilterTest::counter::wasNan
static unsigned int wasNan
count number of times result was nan
Definition: twoHitFilters.cc:81
VXDTFtwoHitFilterTest::VectorOfObservers::CStyleFunctionPointer
void(*)(const typename FilterType::argumentType &, const typename FilterType::argumentType &, const FilterType &, typename FilterType::variableType) CStyleFunctionPointer
a typedef to make the c-style pointer more readable (can not be done with classic typedef)
Definition: twoHitFilters.cc:179
Belle2::B2Vector3::X
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:430
VXDTFtwoHitFilterTest::VectorOfObservers
this observer does simply collect other observers which are to be executed during ::notify
Definition: twoHitFilters.cc:170
Belle2::Filter
This class is used to select pairs, triplets...
Definition: Filter.h:44
VXDTFtwoHitFilterTest::counter::used
static unsigned int used
count number of times used
Definition: twoHitFilters.cc:77
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
VXDTFtwoHitFilterTest::InfoObserver::notify
static void notify(const Var &filterType, typename Var::variableType fResult, const Range &, const typename Var::argumentType &outerHit, const typename Var::argumentType &innerHit, otherTypes ...)
notifier: print the name of the SelectionVariable and the result of its value-function as a Warning.
Definition: twoHitFilters.cc:153
VXDTFtwoHitFilterTest::counter
a tiny counter class for counting stuff
Definition: twoHitFilters.cc:75
VXDTFtwoHitFilterTest::CountingObserver::notify
static void notify(const Var &, otherTypes ...)
notifier counting how often a SelectionVariable was used
Definition: twoHitFilters.cc:115