Belle II Software development
IoVDependentConditionModule.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#include <framework/modules/core/IoVDependentConditionModule.h>
9#include <framework/core/ModuleParam.templateDetails.h>
10
11using namespace Belle2;
12
13REG_MODULE(IoVDependentCondition);
14
16{
17 setDescription("Module which sets its return value based on the fact, if the event is in the given "
18 "run/exp interval or not. If you set the maximal value of experiment and run to -1, "
19 "there will be no upper limit for the interval. If you only set the maximal run to -1, "
20 "there is no upper limit on the run number.");
22
23 addParam("iovList", m_iovList, "The list of IoV to test in the format [(min exp, min run, max exp, max run), ...]."
24 "If multiple IoVs are given, their union will be checked against the event's IoV.");
25}
26
28{
29 m_eventMetaData.isRequired();
30
31 B2ASSERT("You did not specify any IoVs to test!", not m_iovList.empty());
32 for (const auto& iovAsTuple : m_iovList) {
33 double minimalExpNumber, minimalRunNumber, maximalExpNumber, maximalRunNumber;
34 std::tie(minimalExpNumber, minimalRunNumber, maximalExpNumber, maximalRunNumber) = iovAsTuple;
35 const IntervalOfValidity iovToCheck(minimalExpNumber, minimalRunNumber, maximalExpNumber, maximalRunNumber);
36
37 B2ASSERT("One of the specified interval of exp/run is empty. This is probably not what you want!",
38 not iovToCheck.empty());
39
40 m_iovsToCheck.push_back(iovToCheck);
41 }
42
43}
44
46{
47 m_conditionIsMet = false;
48 for (const IntervalOfValidity& iov : m_iovsToCheck) {
49 if (iov.contains(*m_eventMetaData)) {
50 m_conditionIsMet = true;
51 break;
52 }
53 }
54}
55
57{
59}
A class that describes the interval of experiments/runs for which an object in the database is valid.
bool empty() const
Function that checks whether the validity interval is empty.
IoVDependentConditionModule()
Add the module parameters and the description.
void initialize() override
Require the event meta data and turn the minimal/maximal exp/runs to an IoV.
std::vector< std::tuple< int, int, int, int > > m_iovList
Parameter for the input iov list.
void event() override
Returns true, if the event is in the given IoV.
bool m_conditionIsMet
Internal condition: true if run/exp is in IoV.
std::vector< IntervalOfValidity > m_iovsToCheck
Returns true if in this IoV.
StoreObjPtr< EventMetaData > m_eventMetaData
Storage for the event meta data.
void beginRun() override
Set the m_conditionIsMet according to the new run.
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
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.