Belle II Software development
SameSignChecker.h
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#pragma once
9
10namespace Belle2 {
15 namespace TrackFindingCDC {
16
21
22 public:
24 static bool sameSign(double n1, double n2)
25 {
26 return ((n1 > 0 and n2 > 0) or (n1 < 0 and n2 < 0));
27 }
28
30 static bool sameSign(double n1, double n2, double n3, double n4)
31 {
32 return ((n1 > 0 and n2 > 0 and n3 > 0 and n4 > 0) or
33 (n1 < 0 and n2 < 0 and n3 < 0 and n4 < 0));
34 }
35
37 static bool sameSign(double n1, double n2, double n3, double n4,
38 double n5, double n6, double n7, double n8)
39 {
40 return ((n1 > 0 and n2 > 0 and n3 > 0 and n4 > 0 and
41 n5 > 0 and n6 > 0 and n7 > 0 and n8 > 0)
42 or
43 (n1 < 0 and n2 < 0 and n3 < 0 and n4 < 0 and
44 n5 < 0 and n6 < 0 and n7 < 0 and n8 < 0));
45 }
46
48 static bool isIn(double x, double y, double x1, double x2, double y1, double y2)
49 {
50 return sameSign(x - x1, x2 - x, y - y1, y2 - y);
51 }
52 };
53
54 }
56}
Small helper for checking the same sign of two, four or eight floats.
static bool sameSign(double n1, double n2)
Check if two values have the same sign.
static bool sameSign(double n1, double n2, double n3, double n4, double n5, double n6, double n7, double n8)
Check if eight values have the same sign.
static bool isIn(double x, double y, double x1, double x2, double y1, double y2)
Check if two values are in the rectangle spanned by the other four values.
static bool sameSign(double n1, double n2, double n3, double n4)
Check if four values have the same sign.
Abstract base class for different kinds of events.