Belle II Software  release-05-01-25
SloppyFilter.icc.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/filters/base/SloppyFilter.dcl.h>
13 
14 #include <framework/core/ModuleParamList.templateDetails.h>
15 
16 #include <TRandom.h>
17 
18 namespace Belle2 {
23  namespace TrackFindingCDC {
24 
25  template<class AFilter>
26  void Sloppy<AFilter>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
27  {
28  Super::exposeParameters(moduleParamList, prefix);
29  moduleParamList->addParameter("sloppinessFactor",
30  m_param_sloppinessFactor,
31  "Only accept every <sloppinessFactor>th instance "
32  "that would normally pass the filter.",
33  m_param_sloppinessFactor);
34  }
35 
36  template<class AFilter>
37  Weight Sloppy<AFilter>::operator()(const typename Super::Object& object)
38  {
39  Weight response = Super::operator()(object);
40 
41  if (std::isnan(response)) {
42  const unsigned int randomNumber = gRandom->Integer(m_param_sloppinessFactor);
43  if (randomNumber != 0) {
44  return NAN;
45  }
46  }
47  return response;
48  }
49  }
51 }
Belle2::TrackFindingCDC::Sloppy::operator()
Weight operator()(const typename Super::Object &object) override
Reject an item if the truth variable is 0 or in some fractions of the events, else accept it.
Definition: SloppyFilter.icc.h:45
Belle2::TrackFindingCDC::Sloppy::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the set of parameters of the filter to the module parameter list.
Definition: SloppyFilter.icc.h:34
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19