Belle II Software development
SloppyFilter.icc.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/filters/base/SloppyFilter.dcl.h>
11
12#include <framework/core/ModuleParamList.templateDetails.h>
13
14#include <TRandom.h>
15
16namespace Belle2 {
21 namespace TrackFindingCDC {
22
23 template<class AFilter>
24 void Sloppy<AFilter>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
25 {
26 Super::exposeParameters(moduleParamList, prefix);
27 moduleParamList->addParameter("sloppinessFactor",
28 m_param_sloppinessFactor,
29 "Only accept every <sloppinessFactor>th instance "
30 "that would normally pass the filter.",
31 m_param_sloppinessFactor);
32 }
33
34 template<class AFilter>
35 Weight Sloppy<AFilter>::operator()(const typename Super::Object& object)
36 {
37 Weight response = Super::operator()(object);
38
39 if (std::isnan(response)) {
40 const unsigned int randomNumber = gRandom->Integer(m_param_sloppinessFactor);
41 if (randomNumber != 0) {
42 return NAN;
43 }
44 }
45 return response;
46 }
47 }
49}
The Module parameter list class.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the set of parameters of the filter to the module parameter list.
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.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.