Belle II Software  release-05-02-19
BackgroundMetaData.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <framework/dataobjects/BackgroundMetaData.h>
12 #include <framework/logging/Logger.h>
13 
14 using namespace std;
15 using namespace Belle2;
16 
17 
18 bool BackgroundMetaData::canBeMerged(const BackgroundMetaData* otherObj)
19 {
20 
21  if (otherObj->getBackgroundType() != m_backgroundType) {
22  B2ERROR("BackgroundMetaData: objects cannot be merged (different backgroundType)");
23  return false;
24  }
25 
26  if (otherObj->getBackgroundTag() != m_backgroundTag) {
27  B2ERROR("BackgroundMetaData: objects cannot be merged (different backgroundTag)");
28  return false;
29  }
30 
31  if (otherObj->getFileType() != m_fileType) {
32  B2ERROR("BackgroundMetaData: objects cannot be merged (different fileType)");
33  return false;
34  }
35 
36  return true;
37 }
38 
39 
41 {
42  auto otherObj = static_cast<const BackgroundMetaData*>(other);
43 
44  if (otherObj->getBackgroundType().empty()) return; // no merge for empty object
45 
46  if (m_backgroundType.empty()) { // empty, replace it with other
47  *this = *otherObj;
48  return;
49  }
50 
51  if (!canBeMerged(otherObj)) throw BackgroundMetaDataNotMergeable();
52 
53  m_realTime += otherObj->getRealTime();
54 
55 }
56 
57 void BackgroundMetaData::clear()
58 {
59  m_realTime = 0;
60 }
Belle2::BackgroundMetaData::getBackgroundType
const std::string & getBackgroundType() const
Returns the type of background.
Definition: BackgroundMetaData.h:116
Belle2::BackgroundMetaData::getRealTime
float getRealTime() const
Returns real time that corresponds to this background sample.
Definition: BackgroundMetaData.h:128
Belle2::merge
std::vector< std::vector< double > > merge(std::vector< std::vector< std::vector< double >>> toMerge)
merge { vector<double> a, vector<double> b} into {a, b}
Definition: tools.h:44
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BackgroundMetaData
Metadata information about the beam background file.
Definition: BackgroundMetaData.h:34
Belle2::BackgroundMetaData::getFileType
EFileType getFileType() const
Returns file type.
Definition: BackgroundMetaData.h:134
Belle2::BackgroundMetaData::getBackgroundTag
BG_TAG getBackgroundTag() const
Returns background tag value.
Definition: BackgroundMetaData.h:122
Belle2::Mergeable
Abstract base class for objects that can be merged.
Definition: Mergeable.h:33