Belle II Software  release-06-02-00
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 
12 using namespace Belle2;
13 
14 //-----------------------------------------------------------------
15 // Register the Module
16 //-----------------------------------------------------------------
17 REG_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 
30  setPropertyFlags(c_ParallelProcessingCertified);
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 setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:220
The Prescale module.
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.
#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.