Belle II Software  release-05-02-19
PrescaleModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: David Dossett *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <framework/modules/core/PrescaleModule.h>
12 #include <TRandom.h>
13 
14 using namespace Belle2;
15 
16 //-----------------------------------------------------------------
17 // Register the Module
18 //-----------------------------------------------------------------
19 REG_MODULE(Prescale)
20 
21 //-----------------------------------------------------------------
22 // Implementation
23 //-----------------------------------------------------------------
24 
26 {
27  //Set module properties
28  setDescription("Returns True or False randomly for each event. "
29  "Fraction of the time that True is returned is set by the 'prescale' parameter. "
30  "You can use conditional basf2 paths to allow only the events that return True (or False) to continue.");
31 
32  setPropertyFlags(c_ParallelProcessingCertified);
33 
34  addParam("prescale", m_prescale, "Fraction of events that will return True from this module. Range(0.0 -> 1.0)", double(1.0));
35 }
36 
38 {
39  setReturnValue(gRandom->Uniform() < m_prescale);
40 }
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::PrescaleModule::event
virtual void event() override
Sets the return value by running a RNG vs.
Definition: PrescaleModule.cc:37
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Module::setReturnValue
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:222
Belle2::PrescaleModule
The Prescale module.
Definition: PrescaleModule.h:36
Belle2::PrescaleModule::m_prescale
double m_prescale
Prescale module parameter, this fraction of events will return True.
Definition: PrescaleModule.h:52