Belle II Software  release-05-02-19
BackgroundInfo.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 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 #pragma once
12 
13 #include <framework/pcore/Mergeable.h>
14 #include <framework/dataobjects/BackgroundMetaData.h>
15 #include <framework/core/FrameworkExceptions.h>
16 #include <string>
17 #include <vector>
18 
19 namespace Belle2 {
28  class BackgroundInfo: public Mergeable {
29 
30  public:
31 
35  BELLE2_DEFINE_EXCEPTION(BackgroundInfoNotMergeable,
36  "BackgroundInfo: objects cannot be merged");
37 
41  enum EMethod {c_Unknown = 0,
42  c_Mixing = 1,
43  c_Overlay = 2
44  };
45 
49  struct BackgroundDescr {
51  std::string type;
53  std::vector<std::string> fileNames;
54  double realTime = 0;
55  unsigned numEvents = 0;
56  double scaleFactor = 1;
57  double rate = 0;
58  unsigned reused = 0;
59  };
60 
65  {}
66 
70  ~BackgroundInfo() {}
71 
76  void setMethod(EMethod method) {m_method = method;}
77 
83  unsigned appendBackgroundDescr(const BackgroundDescr& bgDescr)
84  {
85  m_backgrounds.push_back(bgDescr);
86  return m_backgrounds.size() - 1;
87  }
88 
93  void setComponents(const std::vector<std::string>& components)
94  {
95  m_components = components;
96  }
97 
102  void setMinTime(double minTime) {m_minTime = minTime;}
103 
108  void setMaxTime(double maxTime) {m_maxTime = maxTime;}
109 
114  void setMinTimeECL(double minTimeECL) {m_minTimeECL = minTimeECL;}
115 
120  void setMaxTimeECL(double maxTimeECL) {m_maxTimeECL = maxTimeECL;}
121 
126  void setMinTimePXD(double minTimePXD) {m_minTimePXD = minTimePXD;}
127 
132  void setMaxTimePXD(double maxTimePXD) {m_maxTimePXD = maxTimePXD;}
133 
138  void setWrapAround(bool wrapAround) {m_wrapAround = wrapAround;}
139 
144  void setMaxEdepECL(double maxEdepECL) {m_maxEdepECL = maxEdepECL;}
145 
151  void setExtensionName(const std::string& name) {m_extensionName = name;}
152 
157  void incrementReusedCounter(unsigned index)
158  {
159  if (index < m_backgrounds.size()) m_backgrounds[index].reused++;
160  }
161 
166  EMethod getMethod() const {return m_method;}
167 
172  const std::vector<BackgroundDescr>& getBackgrounds() const {return m_backgrounds;}
173 
178  const std::vector<std::string>& getComponents() const {return m_components;}
179 
184  double getMinTime() const {return m_minTime;}
185 
190  double getMaxTime() const {return m_maxTime;}
191 
196  double getMinTimeECL() const {return m_minTimeECL;}
197 
202  double getMaxTimeECL() const {return m_maxTimeECL;}
203 
208  double getMinTimePXD() const {return m_minTimePXD;}
209 
214  double getMaxTimePXD() const {return m_maxTimePXD;}
215 
220  bool getWrapAround() const {return m_wrapAround;}
221 
226  double getMaxEdepECL() const {return m_maxEdepECL;}
227 
233  const std::string& getExtensionName() const {return m_extensionName;}
234 
238  virtual void merge(const Mergeable* other) override;
239 
243  virtual void clear() override;
244 
248  void print() const;
249 
250  private:
251 
257  bool canBeMerged(const BackgroundInfo* other);
258 
262  void printForMixing() const;
263 
267  void printForOverlay() const;
268 
270  std::vector<BackgroundDescr> m_backgrounds;
271  std::vector<std::string> m_components;
272  double m_minTime = 0;
273  double m_maxTime = 0;
274  double m_minTimeECL = 0;
275  double m_maxTimeECL = 0;
276  double m_minTimePXD = 0;
277  double m_maxTimePXD = 0;
278  bool m_wrapAround = false;
279  double m_maxEdepECL = 0;
280  std::string m_extensionName;
283  };
285 }
286 
287 
Belle2::BackgroundInfo::BackgroundDescr::scaleFactor
double scaleFactor
scale factor for the rate
Definition: BackgroundInfo.h:64
Belle2::BackgroundInfo::m_minTimeECL
double m_minTimeECL
minimal time shift of background event for ECL
Definition: BackgroundInfo.h:282
Belle2::BackgroundInfo::ClassDefOverride
ClassDefOverride(BackgroundInfo, 4)
Class definition.
Belle2::BackgroundInfo::merge
virtual void merge(const Mergeable *other) override
Implementation of abstract class function.
Definition: BackgroundInfo.cc:96
Belle2::BackgroundInfo::getExtensionName
const std::string & getExtensionName() const
Returns name added to default branch names of background collections Used primarily to pass this name...
Definition: BackgroundInfo.h:241
Belle2::BackgroundInfo::c_Mixing
@ c_Mixing
BG mixing.
Definition: BackgroundInfo.h:50
Belle2::BackgroundInfo::setMaxEdepECL
void setMaxEdepECL(double maxEdepECL)
Set maximal alowed energy deposited in ECL to use BG events.
Definition: BackgroundInfo.h:152
Belle2::BackgroundInfo::BackgroundDescr::fileNames
std::vector< std::string > fileNames
file names
Definition: BackgroundInfo.h:61
Belle2::BackgroundInfo::BackgroundInfo
BackgroundInfo()
Default constructor.
Definition: BackgroundInfo.h:72
Belle2::BackgroundInfo::getMethod
EMethod getMethod() const
Returns method enum used to add BG.
Definition: BackgroundInfo.h:174
Belle2::BackgroundInfo::~BackgroundInfo
~BackgroundInfo()
Destructor.
Definition: BackgroundInfo.h:78
Belle2::BackgroundInfo::m_minTime
double m_minTime
minimal time shift of background event
Definition: BackgroundInfo.h:280
Belle2::BackgroundInfo::getMaxEdepECL
double getMaxEdepECL() const
Returns maximal alowed energy deposited in ECL to use BG events.
Definition: BackgroundInfo.h:234
Belle2::BackgroundInfo
This class stores the information about what background was mixed or overlayed.
Definition: BackgroundInfo.h:36
Belle2::BackgroundInfo::setMaxTimePXD
void setMaxTimePXD(double maxTimePXD)
Set upper edge of PXD time window.
Definition: BackgroundInfo.h:140
Belle2::BackgroundMetaData::EFileType
EFileType
Enum for BG file types.
Definition: BackgroundMetaData.h:77
Belle2::BackgroundInfo::BackgroundDescr
Structure for background description.
Definition: BackgroundInfo.h:57
Belle2::BackgroundInfo::appendBackgroundDescr
unsigned appendBackgroundDescr(const BackgroundDescr &bgDescr)
Append background description of a sample.
Definition: BackgroundInfo.h:91
Belle2::BackgroundInfo::getMaxTimeECL
double getMaxTimeECL() const
Returns upper edge of ECL time window.
Definition: BackgroundInfo.h:210
Belle2::BackgroundInfo::getBackgrounds
const std::vector< BackgroundDescr > & getBackgrounds() const
Returns background descriptions.
Definition: BackgroundInfo.h:180
Belle2::BackgroundInfo::m_extensionName
std::string m_extensionName
name added to default branch names of background
Definition: BackgroundInfo.h:288
Belle2::BackgroundInfo::getMinTimePXD
double getMinTimePXD() const
Returns lower edge of PXD time window.
Definition: BackgroundInfo.h:216
Belle2::BackgroundInfo::setMaxTimeECL
void setMaxTimeECL(double maxTimeECL)
Set upper edge of ECL time window.
Definition: BackgroundInfo.h:128
Belle2::BackgroundInfo::BackgroundDescr::realTime
double realTime
real time of BG samlpe
Definition: BackgroundInfo.h:62
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BackgroundInfo::getMinTime
double getMinTime() const
Returns lower edge of the narrow time window.
Definition: BackgroundInfo.h:192
Belle2::BackgroundInfo::BackgroundDescr::tag
BackgroundMetaData::BG_TAG tag
background tag denoting type
Definition: BackgroundInfo.h:58
Belle2::BackgroundInfo::m_maxTimePXD
double m_maxTimePXD
maximal time shift of background event for PXD
Definition: BackgroundInfo.h:285
Belle2::BackgroundInfo::EMethod
EMethod
enum for methods used to add BG
Definition: BackgroundInfo.h:49
Belle2::BackgroundInfo::m_maxTimeECL
double m_maxTimeECL
maximal time shift of background event for ECL
Definition: BackgroundInfo.h:283
Belle2::BackgroundInfo::setMaxTime
void setMaxTime(double maxTime)
Set upper edge of the narrow time window.
Definition: BackgroundInfo.h:116
Belle2::BackgroundInfo::printForMixing
void printForMixing() const
Print info when BG mixing is used.
Definition: BackgroundInfo.cc:159
Belle2::BackgroundInfo::m_wrapAround
bool m_wrapAround
wrap around events in the tail after maxTime
Definition: BackgroundInfo.h:286
Belle2::BackgroundInfo::BackgroundDescr::rate
double rate
background rate of the sample
Definition: BackgroundInfo.h:65
Belle2::BackgroundInfo::m_method
EMethod m_method
method
Definition: BackgroundInfo.h:277
Belle2::BackgroundMetaData::bg_none
@ bg_none
No background.
Definition: BackgroundMetaData.h:41
Belle2::BackgroundInfo::setWrapAround
void setWrapAround(bool wrapAround)
Set wrap-around flag.
Definition: BackgroundInfo.h:146
Belle2::BackgroundInfo::BackgroundDescr::type
std::string type
background type
Definition: BackgroundInfo.h:59
Belle2::BackgroundInfo::m_backgrounds
std::vector< BackgroundDescr > m_backgrounds
background descriptions
Definition: BackgroundInfo.h:278
Belle2::BackgroundInfo::setMinTime
void setMinTime(double minTime)
Set lower edge of the narrow time window.
Definition: BackgroundInfo.h:110
Belle2::BackgroundInfo::printForOverlay
void printForOverlay() const
Print info when BG overlay is used.
Definition: BackgroundInfo.cc:202
Belle2::BackgroundInfo::print
void print() const
Print the info.
Definition: BackgroundInfo.cc:141
Belle2::BackgroundInfo::m_minTimePXD
double m_minTimePXD
minimal time shift of background event for PXD
Definition: BackgroundInfo.h:284
Belle2::BackgroundInfo::setMinTimePXD
void setMinTimePXD(double minTimePXD)
Set lower edge of PXD time window.
Definition: BackgroundInfo.h:134
Belle2::BackgroundInfo::c_Unknown
@ c_Unknown
unknown
Definition: BackgroundInfo.h:49
Belle2::BackgroundInfo::BackgroundDescr::numEvents
unsigned numEvents
number of events (tree entries) in the sample
Definition: BackgroundInfo.h:63
Belle2::BackgroundInfo::incrementReusedCounter
void incrementReusedCounter(unsigned index)
Increments sample reused counter.
Definition: BackgroundInfo.h:165
Belle2::BackgroundInfo::m_components
std::vector< std::string > m_components
detector components included
Definition: BackgroundInfo.h:279
Belle2::BackgroundInfo::clear
virtual void clear() override
Implementation of abstract class function.
Definition: BackgroundInfo.cc:131
Belle2::BackgroundInfo::BELLE2_DEFINE_EXCEPTION
BELLE2_DEFINE_EXCEPTION(BackgroundInfoNotMergeable, "BackgroundInfo: objects cannot be merged")
Exception definition.
Belle2::BackgroundInfo::getMaxTime
double getMaxTime() const
Returns upper edge of the narrow time window.
Definition: BackgroundInfo.h:198
Belle2::BackgroundInfo::m_maxEdepECL
double m_maxEdepECL
maximal allowed deposited energy in ECL
Definition: BackgroundInfo.h:287
Belle2::BackgroundInfo::BackgroundDescr::reused
unsigned reused
number of times the sample is reused
Definition: BackgroundInfo.h:66
Belle2::BackgroundMetaData::c_Usual
@ c_Usual
usual BG file
Definition: BackgroundMetaData.h:77
Belle2::BackgroundInfo::c_Overlay
@ c_Overlay
BG overlay.
Definition: BackgroundInfo.h:51
Belle2::BackgroundInfo::BackgroundDescr::fileType
BackgroundMetaData::EFileType fileType
file type
Definition: BackgroundInfo.h:60
Belle2::BackgroundInfo::setMethod
void setMethod(EMethod method)
Set method that is used to add BG.
Definition: BackgroundInfo.h:84
Belle2::BackgroundInfo::canBeMerged
bool canBeMerged(const BackgroundInfo *other)
Checks if other object can be merged with this object.
Definition: BackgroundInfo.cc:20
Belle2::BackgroundInfo::getMinTimeECL
double getMinTimeECL() const
Returns lower edge of ECL time window.
Definition: BackgroundInfo.h:204
Belle2::BackgroundInfo::getWrapAround
bool getWrapAround() const
Returns wrap-around flag.
Definition: BackgroundInfo.h:228
Belle2::BackgroundInfo::setExtensionName
void setExtensionName(const std::string &name)
Set name that is added to default branch names of background collections Used primarily to pass this ...
Definition: BackgroundInfo.h:159
Belle2::BackgroundInfo::m_maxTime
double m_maxTime
maximal time shift of background event
Definition: BackgroundInfo.h:281
Belle2::BackgroundInfo::setComponents
void setComponents(const std::vector< std::string > &components)
Set components included.
Definition: BackgroundInfo.h:101
Belle2::BackgroundMetaData::BG_TAG
BG_TAG
Enum for background tags.
Definition: BackgroundMetaData.h:41
Belle2::BackgroundInfo::getComponents
const std::vector< std::string > & getComponents() const
Returns included components.
Definition: BackgroundInfo.h:186
Belle2::BackgroundInfo::setMinTimeECL
void setMinTimeECL(double minTimeECL)
Set lower edge of ECL time window.
Definition: BackgroundInfo.h:122
Belle2::Mergeable
Abstract base class for objects that can be merged.
Definition: Mergeable.h:33
Belle2::BackgroundInfo::getMaxTimePXD
double getMaxTimePXD() const
Returns upper edge of PXD time window.
Definition: BackgroundInfo.h:222