Belle II Software light-2406-ragdoll
PrescaleModule.cc
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
9#include <framework/modules/core/PrescaleModule.h>
10#include <TRandom.h>
11
12using namespace Belle2;
13
14//-----------------------------------------------------------------
15// Register the Module
16//-----------------------------------------------------------------
17REG_MODULE(Prescale);
18
19//-----------------------------------------------------------------
20// Implementation
21//-----------------------------------------------------------------
22
24{
25 //Set module properties
26 setDescription("Returns True or False randomly for each event. "
27 "Fraction of the time that True is returned is set by the 'prescale' parameter. "
28 "You can use conditional basf2 paths to allow only the events that return True (or False) to continue.");
29
31
32 addParam("prescale", m_prescale, "Fraction of events that will return True from this module. Range(0.0 -> 1.0)", double(1.0));
33}
34
36{
37 setReturnValue(gRandom->Uniform() < m_prescale);
38}
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:220
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
virtual void event() override
Sets the return value by running a RNG vs.
double m_prescale
Prescale module parameter, this fraction of events will return True.
PrescaleModule()
Constructor of the module.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24