Belle II Software  release-06-02-00
twoHitFilters.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/twoHitVariables/Distance3DSquared.h>
13 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance2DXYSquared.h>
14 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance1DZ.h>
15 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/SlopeRZ.h>
16 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/CosDirectionXY.h>
17 #include <tracking/trackFindingVXD/filterMap/twoHitVariables/Distance3DNormed.h>
18 
19 #include <tracking/trackFindingVXD/filterMap/filterFramework/Shortcuts.h>
20 
21 #include <vxd/geometry/SensorInfoBase.h>
22 #include <iostream>
23 #include <math.h>
24 
25 #include <functional>
26 
27 using namespace std;
28 
29 using namespace Belle2;
30 
31 namespace VXDTFtwoHitFilterTest {
32 
34  class TwoHitFilterTest : public ::testing::Test {
35  protected:
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 the reco transform
52  sensorInfoBase.setTransformation(transform, true);
53 
54  return sensorInfoBase;
55  }
56 
57 
59  SpacePoint provideSpacePointDummy(double X, double Y, double Z)
60  {
61  VxdID aVxdID = VxdID(1, 1, 1);
62  VXD::SensorInfoBase sensorInfoBase = createSensorInfo(aVxdID, X, Y, Z);
63 
64  PXDCluster aCluster = PXDCluster(aVxdID, 0., 0., 0.1, 0.1, 0, 0, 1, 1, 1, 1, 1, 1);
65 
66  return SpacePoint(&aCluster, &sensorInfoBase);
67  }
68 
69 
71  template < class T>
72  class counter {
73  public:
74  static unsigned int used;
75  static unsigned int accepted;
76  static unsigned int rejected;
77  static unsigned int wasInf;
78  static unsigned int wasNan;
79  counter() {};
80  ~counter() {};
81  static void resetCounter()
82  {
83  counter<T>::used = 0;
88  }
89  };
90 
91 
92 
94  template<class T>
95  unsigned int counter<T>::used(0);
96  template<class T>
97  unsigned int counter<T>::accepted(0);
98  template<class T>
99  unsigned int counter<T>::rejected(0);
100  template<class T>
101  unsigned int counter<T>::wasInf(0);
102  template<class T>
103  unsigned int counter<T>::wasNan(0);
104 
105 
106 
109  public:
111  template<class Var, typename ... otherTypes>
112  static void notify(const Var&,
113  otherTypes ...)
114  {
115  counter<Var>::used ++ ;
116  }
117 
118  };
119 
120 
121 
122 
123 
125  class ErrorObserver : public VoidObserver {
126  public:
127  template<class Var, class Range, typename ... otherTypes>
129  static void notify(const Var& filterType,
130  typename Var::variableType fResult,
131  const Range& range,
132  const typename Var::argumentType& outerHit,
133  const typename Var::argumentType& innerHit,
134  otherTypes ...)
135  {
136  B2ERROR(" Filter " << filterType.name() << " got result of " << fResult);
137  }
138 
139  };
140 
141 
142 
143 
144 
146  class InfoObserver : public VoidObserver {
147  public:
149  template<class Var, class Range, typename ... otherTypes>
150  static void notify(const Var& filterType,
151  typename Var::variableType fResult,
152  const Range&,
153  const typename Var::argumentType& outerHit,
154  const typename Var::argumentType& innerHit,
155  otherTypes ...)
156  {
157  B2WARNING(" Filter " << filterType.name() << " with outerhit/innerhit: " << outerHit.getPosition().PrintStringXYZ() << "/" <<
158  innerHit.getPosition().PrintStringXYZ() << " got result of " << fResult);
159  }
160 
161  };
162 
163 
164 
165 
167  template<class FilterType> class VectorOfObservers : public VoidObserver {
168  public:
169 
171  typedef std::function< void (const typename FilterType::argumentType&, const typename FilterType::argumentType&, const FilterType&, typename FilterType::variableType)>
173 
175  using CStyleFunctionPointer = void(*)(const typename FilterType::argumentType&, const typename FilterType::argumentType&,
176  const FilterType&, typename FilterType::variableType) ;
177 
179  template<typename ... otherTypes>
180  static void notify(const FilterType& filterType,
181  typename FilterType::variableType fResult,
182  const typename FilterType::argumentType& outerHit,
183  const typename FilterType::argumentType& innerHit,
184  otherTypes ...)
185  {
186  B2INFO(" Filter " << filterType.name() << " with Mag of outer-/innerHit " << outerHit.getPosition().Mag() << "/" <<
187  innerHit.getPosition().Mag() << " got result of " << fResult << " and Observer-Vector sm_collectedObservers got " <<
188  VectorOfObservers<FilterType>::sm_collectedObservers.size() << " observers collected");
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_collectedObserversCSTYLE got " <<
191  VectorOfObservers<FilterType>::sm_collectedObserversCSTYLE.size() << " observers collected");
192 
194  // for(auto& anObserver : CollectedObservers<FilterType>::collectedObservers) {
195  // anObserver(outerHit, innerHit, fResult);
196  // }
198  }
199 
200 
202  template <typename ObserverType>
203  static void addObserver(observerFunction newObserver)
204  {
205  VectorOfObservers<FilterType>::sm_collectedObservers.push_back(std::bind(&newObserver, std::placeholders::_1, std::placeholders::_2,
206  FilterType(), std::placeholders::_3));
207  }
208 
209 
211  static std::vector< observerFunction > sm_collectedObservers;
213  static std::vector< CStyleFunctionPointer > sm_collectedObserversCSTYLE;
214 
216 // 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;
217  };
218 
220  template<typename FilterType> std::vector< typename VectorOfObservers<FilterType>::observerFunction >
223  template<typename FilterType> std::vector< typename VectorOfObservers<FilterType>::CStyleFunctionPointer >
224  VectorOfObservers<FilterType>::sm_collectedObserversCSTYLE = {};
226 // template<typename FilterType> std::vector< typename VectorOfObservers<FilterType>::CStyleFunctionPointer > VectorOfObservers<FilterType>::sm_collectedObserversTry2 = {};
227 
228 
229 
231  TEST_F(TwoHitFilterTest, TestObserverFlexibility)
232  {
233  // Very verbose declaration, see below for convenient shortcuts
235  1.));
236 
237  // Filter< Distance3DSquared<SpacePoint>, Range<double, double>, VectorOfObservers<Distance3DSquared> > filter(unobservedFilter);
238  Filter< Distance3DSquared<SpacePoint>, Range<double, double>, InfoObserver > filter(unobservedFilter);
239  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
240  SpacePoint x2 = provideSpacePointDummy(0.5f , 0.0f, 0.0f);
241  SpacePoint x3 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
242  auto myCounter = counter<Distance3DSquared<SpacePoint>>();
243  myCounter.resetCounter();
244 
246 // auto storeFuncVariantA = std::bind( ((VectorOfObservers<Distance3DSquared>::observerFunction) &CountingObserver::notify), std::placeholders::_1, std::placeholders::_2, Distance3DSquared(), std::placeholders::_3);
247  // VectorOfObservers<Distance3DSquared>::sm_collectedObservers.push_back(storeFuncVariantA);
248 
250  auto storeFuncVariantB = std::bind(((VectorOfObservers<Distance3DSquared<SpacePoint>>::CStyleFunctionPointer)
251  &CountingObserver::notify), std::placeholders::_1, std::placeholders::_2, Distance3DSquared<SpacePoint>(),
252  std::placeholders::_3);
253 
254  char* realname(nullptr);
255  int status(0);
256  realname = abi::__cxa_demangle(typeid(storeFuncVariantB).name(), 0, 0, &status);
257  std::string name(realname);
258  free(realname);
259  B2INFO("storeFuncVariantB is of type: " << name);
260 
261 // VectorOfObservers<Distance3DSquared>::sm_collectedObserversTry2.push_back(storeFuncVariantB);
262 
263 
265 // VectorOfObservers<Distance3DSquared>::sm_collectedObserversCSTYLE.push_back(storeFuncVariantB);
266 
268  // VectorOfObservers<Distance3DSquared>::addObserver(CountingObserver);
269  // VectorOfObservers<Distance3DSquared>::addObserver(WarningObserver);
270 
271 
272  filter.accept(x2, x1);
273  filter.accept(x3, x1);
274  EXPECT_EQ(0 , myCounter.used);
275 
276  }
277 
278 
279 
281  TEST_F(TwoHitFilterTest, SpacePointCreation)
282  {
283  SpacePoint testSP = provideSpacePointDummy(1.2, 2.3, 4.2);
284  EXPECT_FLOAT_EQ(1.2, testSP.getPosition().X()) ;
285  EXPECT_FLOAT_EQ(2.3, testSP.getPosition().Y()) ;
286  EXPECT_FLOAT_EQ(4.2, testSP.getPosition().Z()) ;
287 
288  }
289 
290 
292  TEST_F(TwoHitFilterTest, SelectionVariableName)
293  {
294  auto dist3D = Distance3DSquared<SpacePoint>();
295  EXPECT_EQ("Distance3DSquared" , dist3D.name());
296  auto dist2DXY = Distance2DXYSquared<SpacePoint>();
297  EXPECT_EQ("Distance2DXYSquared" , dist2DXY.name());
298  auto dist1DZ = Distance1DZ<SpacePoint>();
299  EXPECT_EQ("Distance1DZ" , dist1DZ.name());
300  auto slopeRZ = SlopeRZ<SpacePoint>();
301  EXPECT_EQ("SlopeRZ" , slopeRZ.name());
302 
303  }
304 
305 
307  TEST_F(TwoHitFilterTest, BasicFilterTestDistance3DSquared)
308  {
309  // Very verbose declaration, see below for convenient shortcuts
311 
312  SpacePoint x1 = provideSpacePointDummy(0. , 0., 0.);
313  SpacePoint x2 = provideSpacePointDummy(.5 , 0., 0.);
314  SpacePoint x3 = provideSpacePointDummy(2. , 0., 0.);
315 
316  EXPECT_TRUE(filter.accept(x1, x2));
317  EXPECT_FALSE(filter.accept(x1, x3));
318 
319  }
320 
321 
323  TEST_F(TwoHitFilterTest, BasicFilterTestDistance2DXYSquared)
324  {
325  // Very verbose declaration, see below for convenient shortcuts
327 
328  SpacePoint x1 = provideSpacePointDummy(0. , 0., 0.);
329  SpacePoint x2 = provideSpacePointDummy(.5 , 0., 0.);
330  SpacePoint x3 = provideSpacePointDummy(2. , 0., 0.);
331  SpacePoint x4 = provideSpacePointDummy(0. , 0., 2.);
332 
333  EXPECT_TRUE(filter.accept(x1, x2));
334  EXPECT_FALSE(filter.accept(x1, x3));
335  EXPECT_TRUE(filter.accept(x2, x4));
336 
337  }
338 
339 
341  TEST_F(TwoHitFilterTest, BasicFilterTestDistance1DZ)
342  {
343  // Very verbose declaration, see below for convenient shortcuts
345 
346  SpacePoint x1 = provideSpacePointDummy(0. , 0., 0.);
347  SpacePoint x2 = provideSpacePointDummy(0. , 0., .5);
348  SpacePoint x3 = provideSpacePointDummy(.25 , .25, 0.);
349  SpacePoint x4 = provideSpacePointDummy(0. , 0., 1.);
350 
351  EXPECT_TRUE(filter.accept(x2, x1));
352  EXPECT_FALSE(filter.accept(x1, x2)); // the input order is relevant
353  EXPECT_FALSE(filter.accept(x1, x3));
354  EXPECT_FALSE(filter.accept(x1, x4));
355 
356  }
357 
358 
360  TEST_F(TwoHitFilterTest, TemplateFilterTestDistance1DZ)
361  {
362  // Very verbose declaration, see below for convenient shortcuts
364 
365  SpacePoint x1 = provideSpacePointDummy(0. , 0., 0.);
366  SpacePoint x2 = provideSpacePointDummy(0. , 0., .5);
367  SpacePoint x3 = provideSpacePointDummy(.25 , .25, 0.);
368  SpacePoint x4 = provideSpacePointDummy(0. , 0., 1.);
369 
370  EXPECT_TRUE(filter.accept(x2, x1));
371  EXPECT_FALSE(filter.accept(x1, x2)); // the input order is relevant
372  EXPECT_FALSE(filter.accept(x1, x3));
373  EXPECT_FALSE(filter.accept(x1, x4));
374 
375  }
376 
377 
379  TEST_F(TwoHitFilterTest, BasicFilterTestSlopeRZ)
380  {
381  // Very verbose declaration, see below for convenient shortcuts
383 
384  SpacePoint innerSP = provideSpacePointDummy(1 , 2, 3);
385  SpacePoint outerSP1 = provideSpacePointDummy(1 , 4, 4);
386  SpacePoint outerSP2 = provideSpacePointDummy(1 , 4, 3.95);
387  SpacePoint outerSP3 = provideSpacePointDummy(1 , 4, 4.05);
388  SpacePoint outerSP4 = provideSpacePointDummy(1 , 3, 3.45);
389  SpacePoint outerSP5 = provideSpacePointDummy(1 , 3, 3.55);
390  SpacePoint outerSP6 = provideSpacePointDummy(1 , 4, 3);
391  SpacePoint outerSP7 = provideSpacePointDummy(1 , 0, 4);
392 
393  EXPECT_FALSE(filter.accept(outerSP3, innerSP));
394  EXPECT_FALSE(filter.accept(outerSP1, innerSP));
395  EXPECT_TRUE(filter.accept(outerSP2, innerSP));
396  EXPECT_FALSE(filter.accept(innerSP, outerSP2)); // reverse order not same result (because of z)
397  EXPECT_TRUE(filter.accept(outerSP4, innerSP));
398  EXPECT_FALSE(filter.accept(outerSP5, innerSP));
399  EXPECT_EQ(filter.accept(outerSP1, innerSP), filter.accept(outerSP7,
400  innerSP)); // (direction of r-vector not relevant, only its length)
401 
402 
403  auto sRZ = SlopeRZ<SpacePoint>();
404  EXPECT_FLOAT_EQ(0., sRZ.value(innerSP, innerSP));
405  EXPECT_FLOAT_EQ(atan(2.), sRZ.value(outerSP1, innerSP));
406  EXPECT_FLOAT_EQ(atan(2. / 0.95), sRZ.value(outerSP2, innerSP));
407  EXPECT_FLOAT_EQ(M_PI - sRZ.value(outerSP2, innerSP),
408  sRZ.value(innerSP, outerSP2)); // with latest bugfix reverse order will result in (Pi - SlopeRZ)
409  EXPECT_FLOAT_EQ(atan(2. / 1.05), sRZ.value(outerSP3, innerSP));
410  EXPECT_FLOAT_EQ(atan(1. / 0.45), sRZ.value(outerSP4, innerSP));
411  EXPECT_FLOAT_EQ(atan(1. / 0.55), sRZ.value(outerSP5, innerSP));
412  EXPECT_FLOAT_EQ(M_PI * 0.5, sRZ.value(outerSP6, innerSP)); // no problem with division by 0 in Z
413  EXPECT_FLOAT_EQ(atan(2. / 1.05), sRZ.value(outerSP3, innerSP));
414  EXPECT_FLOAT_EQ(sRZ.value(outerSP1, innerSP), sRZ.value(outerSP7,
415  innerSP)); // (direction of r-vector not relevant, only its length)
416 
417  }
418 
419 
421  TEST_F(TwoHitFilterTest, BasicFilterTestDistance3DNormed)
422  {
423  // prepare spacePoints for new stuff
424  SpacePoint innerSP = provideSpacePointDummy(1 , 2, 3);
425  SpacePoint outerSP1 = provideSpacePointDummy(2 , 3, 4);
426  SpacePoint outerSP2 = provideSpacePointDummy(1 , 2, 4);
427  SpacePoint outerSP3 = provideSpacePointDummy(2 , 3, 3);
428 
429  auto d3Dn = Distance3DNormed<SpacePoint>();
430  EXPECT_FLOAT_EQ(2. / 3., d3Dn.value(outerSP1, innerSP));
431  EXPECT_FLOAT_EQ(0., d3Dn.value(outerSP2, innerSP));
432  EXPECT_FLOAT_EQ(1., d3Dn.value(outerSP3, innerSP));
433  EXPECT_FLOAT_EQ(0., d3Dn.value(innerSP, innerSP));
434 
435  }
436 
437 
439  TEST_F(TwoHitFilterTest, ObservedFilter)
440  {
441  // Very verbose declaration, see below for convenient shortcuts
443  1.));
444 
445  Filter< Distance3DSquared<SpacePoint>, Range<double, double>, CountingObserver > filter(unobservedFilter);
446  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
447  SpacePoint x2 = provideSpacePointDummy(0.5f , 0.0f, 0.0f);
448  SpacePoint x3 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
449  auto myCounter = counter<Distance3DSquared<SpacePoint>>();
450  myCounter.resetCounter();
451 
452  EXPECT_TRUE(filter.accept(x1, x2));
453  EXPECT_FALSE(filter.accept(x1, x3));
454  EXPECT_EQ(2 , myCounter.used);
455  }
456 
457 
459  TEST_F(TwoHitFilterTest, BypassableFilter)
460  {
461  bool bypassControl(false);
462  // Very verbose declaration, see below for convenient shortcuts
464  (0., 1.));
465  auto filter = nonBypassableFilter.bypass(bypassControl);
466  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
467  SpacePoint x2 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
468  auto myCounter = counter<Distance3DSquared<SpacePoint>>();
469  myCounter.resetCounter();
470 
471  EXPECT_FALSE(filter.accept(x1, x2));
472  EXPECT_EQ(1 , myCounter.used);
473 
474  bypassControl = true;
475  EXPECT_TRUE(filter.accept(x1, x2));
476  EXPECT_EQ(2 , myCounter.used);
477 
478  }
479 
480 
482  TEST_F(TwoHitFilterTest, Shortcuts)
483  {
484 
485  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
486  SpacePoint x2 = provideSpacePointDummy(0.5f , 0.0f, 0.0f);
487  SpacePoint x3 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
488 
489  auto filterSup = (Distance3DSquared<SpacePoint>() < 1.) ;
490  EXPECT_TRUE(filterSup.accept(x1, x2));
491  EXPECT_FALSE(filterSup.accept(x1, x3));
492 
493  auto filterSup2 = (1 > Distance3DSquared<SpacePoint>()) ;
494  EXPECT_TRUE(filterSup2.accept(x1, x2));
495  EXPECT_FALSE(filterSup2.accept(x1, x3));
496 
497  auto filterInf = (Distance3DSquared<SpacePoint>() > 1.) ;
498  EXPECT_TRUE(filterInf.accept(x1, x3));
499  EXPECT_FALSE(filterInf.accept(x1, x2));
500 
501  auto filterInf2 = (1 < Distance3DSquared<SpacePoint>()) ;
502  EXPECT_TRUE(filterInf2.accept(x1, x3));
503  EXPECT_FALSE(filterInf2.accept(x1, x2));
504 
505  auto filterRange = (0.1 < Distance3DSquared<SpacePoint>() < 1);
506  EXPECT_FALSE(filterRange.accept(x1, x1));
507  EXPECT_TRUE(filterRange.accept(x1, x2));
508  EXPECT_FALSE(filterRange.accept(x1, x3));
509 
510  }
511 
512 
514  TEST_F(TwoHitFilterTest, BooleanOperations)
515  {
516 
517  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
518  SpacePoint x2 = provideSpacePointDummy(1.0f , 0.0f, 0.0f);
519  SpacePoint x3 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
520 
521  auto filter = !(Distance3DSquared<SpacePoint>() > 1.);
522  EXPECT_TRUE(filter.accept(x1, x2));
523  EXPECT_TRUE(filter.accept(x1, x1));
524  EXPECT_FALSE(filter.accept(x1, x3));
525 
526  auto filter2 =
527  !(Distance3DSquared<SpacePoint>() > 1.) &&
528  !(Distance3DSquared<SpacePoint>() < 1);
529  // i.e. Distance3DSquared == 1
530  EXPECT_TRUE(filter2.accept(x1, x2));
531  EXPECT_FALSE(filter2.accept(x1, x1));
532  EXPECT_FALSE(filter2.accept(x1, x3));
533 
534 
535  auto filter3 =
536  (Distance3DSquared<SpacePoint>() > 1.) ||
537  (Distance3DSquared<SpacePoint>() < 1);
538  // i.e. Distance3DSquared != 1
539  EXPECT_FALSE(filter3.accept(x1, x2));
540  EXPECT_TRUE(filter3.accept(x1, x1));
541  EXPECT_TRUE(filter3.accept(x1, x3));
542 
543  }
544 
545 
547  TEST_F(TwoHitFilterTest, ShortCircuitsEvaluation)
548  {
549  auto filter(
550  ((Distance2DXYSquared<SpacePoint>() < 1) &&
551  (Distance3DSquared<SpacePoint>() < 1)).observe(CountingObserver())
552  );
553 
554  SpacePoint x1 = provideSpacePointDummy(0.0f , 0.0f, 0.0f);
555  SpacePoint x3 = provideSpacePointDummy(2.0f , 0.0f, 0.0f);
556 
557  auto counter3D = counter<Distance3DSquared<SpacePoint>>();
558  auto counter2D = counter<Distance2DXYSquared<SpacePoint>>();
559  counter3D.used = 0;
560  counter2D.used = 0;
561 
562  EXPECT_FALSE(filter.accept(x1, x3));
563  EXPECT_EQ(1 , counter2D.used);
564  EXPECT_EQ(0 , counter3D.used);
565 
566  EXPECT_TRUE(filter.accept(x1, x1));
567  EXPECT_EQ(2 , counter2D.used);
568  EXPECT_EQ(1 , counter3D.used);
569 
570  }
571 
573  TEST_F(TwoHitFilterTest, TestCosDirectionXY)
574  {
575  SpacePoint x1 = provideSpacePointDummy(2.0f , 1.0f, 0.0f);
576  SpacePoint x2 = provideSpacePointDummy(1.0f , -2.0f, 0.0f);
577  SpacePoint x3 = provideSpacePointDummy(1.0f , 0.0f, 0.0f);
578  SpacePoint x4 = provideSpacePointDummy(0.5f , 0.86602540378443f, 0.0f);
579 
580  EXPECT_FLOAT_EQ(0., CosDirectionXY<SpacePoint>::value(x1, x2));
581  EXPECT_NEAR(0.5, CosDirectionXY<SpacePoint>::value(x3, x4), 0.0000001);
582  }
583 }
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:420
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:416
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:418
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
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 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
this observer does simply count the number of times, the attached Filter was used
static void notify(const Var &, otherTypes ...)
notifier counting how often a SelectionVariable was used
this observer does simply print the name of the SelectionVariable and the result of its value-functio...
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.
this observer does simply print the name of the SelectionVariable and the result of its value-functio...
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.
Test class for these new and shiny two-hit-filters.
this observer does simply collect other observers which are to be executed during ::notify
static std::vector< observerFunction > sm_collectedObservers
collects observers with std::function to be executed during notify (variant A)
static std::vector< CStyleFunctionPointer > sm_collectedObserversCSTYLE
collects observers with c-style function pointers to be executed during notify (variant B)
static void addObserver(observerFunction newObserver)
collects observers to be executed during notify (can not be used so far, but is long-term goal)
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
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
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)
a tiny counter class for counting stuff
static unsigned int accepted
count number of times result was accepted
static void resetCounter()
destructor.
static unsigned int wasInf
count number of times result was inf
static unsigned int used
count number of times used
static unsigned int rejected
count number of times result was rejected
static unsigned int wasNan
count number of times result was nan
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Definition: globalLabel.cc:72
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:40
Abstract base class for different kinds of events.