Belle II Software  release-05-02-19
RangeInBox.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/numerics/Weight.h>
13 #include <cmath>
14 
15 namespace Belle2 {
20  namespace TrackFindingCDC {
21 
26  template<class AHitInBoxAlgorithm>
27  class RangeInBox {
28  public:
30  using HoughBox = typename AHitInBoxAlgorithm::HoughBox;
31 
36  template<class ARangeObject>
37  Weight operator()(const ARangeObject& rangeObject,
38  const HoughBox* box)
39  {
40  AHitInBoxAlgorithm hitInBoxAlgorithm;
41  double sumOfWeights = 0;
42  double numberOfPassedItems = 0;
43  for (const auto& item : rangeObject) {
44  const double hitWeight = hitInBoxAlgorithm(item, box);
45  if (not std::isnan(hitWeight)) {
46  numberOfPassedItems++;
47  sumOfWeights += hitWeight;
48  }
49  }
50 
51  if (numberOfPassedItems > minimalRatio * static_cast<double>(rangeObject.size())) {
52  return sumOfWeights;
53  } else {
54  return NAN;
55  }
56  }
57 
59  const double minimalRatio = 0.6;
60  };
61  }
63 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::RangeInBox::operator()
Weight operator()(const ARangeObject &rangeObject, const HoughBox *box)
When called, it goes through all items in the range object (e.g.
Definition: RangeInBox.h:45
Belle2::TrackFindingCDC::RangeInBox::minimalRatio
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:67
Belle2::TrackFindingCDC::RangeInBox::HoughBox
typename AHitInBoxAlgorithm::HoughBox HoughBox
The type of the underlaying HoughBox (copied from the udnerlaying hit algorithm)
Definition: RangeInBox.h:38