Belle II Software development
RangeInBox.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
10#include <tracking/trackFindingCDC/numerics/Weight.h>
11#include <cmath>
12
13namespace Belle2 {
18 namespace TrackFindingCDC {
19
24 template<class AHitInBoxAlgorithm>
25 class RangeInBox {
26 public:
28 using HoughBox = typename AHitInBoxAlgorithm::HoughBox;
29
34 template<class ARangeObject>
35 Weight operator()(const ARangeObject& rangeObject,
36 const HoughBox* box)
37 {
38 AHitInBoxAlgorithm hitInBoxAlgorithm;
39 double sumOfWeights = 0;
40 double numberOfPassedItems = 0;
41 for (const auto& item : rangeObject) {
42 const double hitWeight = hitInBoxAlgorithm(item, box);
43 if (not std::isnan(hitWeight)) {
44 numberOfPassedItems++;
45 sumOfWeights += hitWeight;
46 }
47 }
48
49 if (numberOfPassedItems > minimalRatio * static_cast<double>(rangeObject.size())) {
50 return sumOfWeights;
51 } else {
52 return NAN;
53 }
54 }
55
57 const double minimalRatio = 0.6;
58 };
59 }
61}
Predicate class to check for the containment of items in a rangeobject in a hough space part.
Definition: RangeInBox.h:25
Weight operator()(const ARangeObject &rangeObject, const HoughBox *box)
When called, it goes through all items in the range object (e.g.
Definition: RangeInBox.h:35
typename AHitInBoxAlgorithm::HoughBox HoughBox
The type of the underlaying HoughBox (copied from the udnerlaying hit algorithm)
Definition: RangeInBox.h:28
const double minimalRatio
The minimal percentage of items of a given range that must belong to the box the be called a hit.
Definition: RangeInBox.h:57
Abstract base class for different kinds of events.