Belle II Software  release-05-02-19
IoVDependentConditionModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <framework/modules/core/IoVDependentConditionModule.h>
11 #include <framework/core/ModuleParam.templateDetails.h>
12 
13 using namespace Belle2;
14 
15 REG_MODULE(IoVDependentCondition)
16 
18 {
19  setDescription("Module which sets its return value based on the fact, if the event is in the given "
20  "run/exp interval or not. If you set the maximal value of experiment and run to -1, "
21  "there will be no upper limit for the interval. If you only set the maximal run to -1, "
22  "there is no upper limit on the run number.");
23  setPropertyFlags(Module::EModulePropFlags::c_ParallelProcessingCertified);
24 
25  addParam("iovList", m_iovList, "The list of IoV to test in the format [(min exp, min run, max exp, max run), ...]."
26  "If multiple IoVs are given, their union will be checked against the event's IoV.");
27 }
28 
30 {
31  m_eventMetaData.isRequired();
32 
33  B2ASSERT("You did not specify any IoVs to test!", not m_iovList.empty());
34  for (const auto& iovAsTuple : m_iovList) {
35  double minimalExpNumber, minimalRunNumber, maximalExpNumber, maximalRunNumber;
36  std::tie(minimalExpNumber, minimalRunNumber, maximalExpNumber, maximalRunNumber) = iovAsTuple;
37  const IntervalOfValidity iovToCheck(minimalExpNumber, minimalRunNumber, maximalExpNumber, maximalRunNumber);
38 
39  B2ASSERT("One of the specified interval of exp/run is empty. This is probably not what you want!",
40  not iovToCheck.empty());
41 
42  m_iovsToCheck.push_back(iovToCheck);
43  }
44 
45 }
46 
48 {
49  m_conditionIsMet = false;
50  for (const IntervalOfValidity& iov : m_iovsToCheck) {
51  if (iov.contains(*m_eventMetaData)) {
52  m_conditionIsMet = true;
53  break;
54  }
55  }
56 }
57 
59 {
61 }
Belle2::IntervalOfValidity
A class that describes the interval of experiments/runs for which an object in the database is valid.
Definition: IntervalOfValidity.h:35
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::IoVDependentConditionModule::m_iovList
std::vector< std::tuple< int, int, int, int > > m_iovList
Parameter for the input iov list.
Definition: IoVDependentConditionModule.h:59
Belle2::IoVDependentConditionModule::beginRun
void beginRun() override
Set the m_conditionIsMet according to the new run.
Definition: IoVDependentConditionModule.cc:47
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::IoVDependentConditionModule::m_iovsToCheck
std::vector< IntervalOfValidity > m_iovsToCheck
Returns true if in this IoV.
Definition: IoVDependentConditionModule.h:50
Belle2::Module::setReturnValue
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:222
Belle2::IoVDependentConditionModule::m_eventMetaData
StoreObjPtr< EventMetaData > m_eventMetaData
Storage for the event meta data.
Definition: IoVDependentConditionModule.h:56
Belle2::IoVDependentConditionModule
Module which sets its return value based on the fact, if the event is in the given run/exp interval o...
Definition: IoVDependentConditionModule.h:34
Belle2::IoVDependentConditionModule::m_conditionIsMet
bool m_conditionIsMet
Internal condition: true if run/exp is in IoV.
Definition: IoVDependentConditionModule.h:53
Belle2::IoVDependentConditionModule::initialize
void initialize() override
Require the event meta data and turn the minimal/maximal exp/runs to an IoV.
Definition: IoVDependentConditionModule.cc:29
Belle2::IntervalOfValidity::empty
bool empty() const
Function that checks whether the validity interval is empty.
Definition: IntervalOfValidity.h:65
Belle2::IoVDependentConditionModule::event
void event() override
Returns true, if the event is in the given IoV.
Definition: IoVDependentConditionModule.cc:58