9#include <framework/dataobjects/BackgroundInfo.h>
10#include <framework/logging/Logger.h>
12#include <unordered_set>
22 B2ERROR(
"BackgroundInfo: objects cannot be merged (different method)");
26 std::unordered_set<int> bgThis;
28 int key = bg.tag * 16 + bg.fileType;
31 std::unordered_set<int> bgOther;
33 int key = bg.tag * 16 + bg.fileType;
36 if (bgOther != bgThis) {
37 B2ERROR(
"BackgroundInfo: objects cannot be merged (different backgrounds)");
42 std::sort(compThis.begin(), compThis.end());
44 std::sort(compOther.begin(), compOther.end());
45 if (compOther != compThis) {
46 B2ERROR(
"BackgroundInfo: objects cannot be merged (different components)");
51 B2ERROR(
"BackgroundInfo: objects cannot be merged (different minTime)");
56 B2ERROR(
"BackgroundInfo: objects cannot be merged (different maxTime)");
61 B2ERROR(
"BackgroundInfo: objects cannot be merged (different minTimeECL)");
66 B2ERROR(
"BackgroundInfo: objects cannot be merged (different maxTimeECL)");
71 B2ERROR(
"BackgroundInfo: objects cannot be merged (different minTimePXD)");
76 B2ERROR(
"BackgroundInfo: objects cannot be merged (different maxTimePXD)");
81 B2ERROR(
"BackgroundInfo: objects cannot be merged (different wrapAround)");
86 B2ERROR(
"BackgroundInfo: objects cannot be merged (different maxEdepECL)");
99 if (otherObj->getMethod() ==
c_Unknown and otherObj->getBackgrounds().empty())
107 if (!
canBeMerged(otherObj))
throw BackgroundInfoNotMergeable();
109 for (
const auto& otherBg : otherObj->getBackgrounds()) {
112 if (otherBg.tag != bg.tag)
continue;
113 if (otherBg.fileType != bg.fileType)
continue;
114 if (otherBg.runNumber != bg.runNumber)
continue;
115 if (otherBg.fileNames == bg.fileNames) {
116 if (otherBg.scaleFactor != bg.scaleFactor) {
117 B2ERROR(
"BackgroundInfo: objects cannot be merged (different scaleFactor)");
118 throw BackgroundInfoNotMergeable();
120 bg.reused += otherBg.reused;
144 cout <<
"Method: BG mixing" << endl;
148 cout <<
"Method: BG overlay" << endl;
152 cout <<
"Method: unknown" << endl;
160 cout <<
"Components: ";
164 for (
const auto& component :
m_components) cout << component <<
" ";
168 cout <<
"Time window: ";
174 cout <<
"Wrapping around: ";
182 cout <<
"ECL deposited energy cut: " <<
m_maxEdepECL <<
" GeV" << endl;
184 cout <<
"Samples: " << endl;
186 cout <<
" " << bkg.type << endl;
187 cout <<
" equivalent time: " << bkg.realTime / 1000000 <<
" ms";
188 cout <<
", events: " << bkg.numEvents;
189 cout <<
", scale factor: " << bkg.scaleFactor;
190 cout <<
", rate: " << bkg.rate <<
" GHz";
191 cout <<
", re-used: " << bkg.reused <<
" times";
194 for (
const auto& fileName : bkg.fileNames) cout <<
" " << fileName << endl;
203 cout <<
"Components: ";
207 for (
const auto& component :
m_components) cout << component <<
" ";
211 cout <<
"Samples: " << endl;
213 cout <<
" " << bkg.type << endl;
214 cout <<
" run number: " << bkg.runNumber << endl;
215 cout <<
" events: " << bkg.numEvents;
216 cout <<
", re-used: " << bkg.reused <<
" times";
219 for (
const auto& fileName : bkg.fileNames) cout <<
" " << fileName << endl;
This class stores the information about what background was mixed or overlayed.
double m_maxEdepECL
maximal allowed deposited energy in ECL
double m_maxTimeECL
maximal time shift of background event for ECL
std::vector< std::string > m_components
detector components included
double getMaxTime() const
Returns upper edge of the narrow time window.
void printForOverlay() const
Print info when BG overlay is used.
double m_minTimePXD
minimal time shift of background event for PXD
double getMaxTimeECL() const
Returns upper edge of ECL time window.
std::vector< BackgroundDescr > m_backgrounds
background descriptions
double getMaxEdepECL() const
Returns maximal alowed energy deposited in ECL to use BG events.
EMethod getMethod() const
Returns method enum used to add BG.
double m_maxTime
maximal time shift of background event
bool getWrapAround() const
Returns wrap-around flag.
double m_minTime
minimal time shift of background event
bool m_wrapAround
wrap around events in the tail after maxTime
double getMaxTimePXD() const
Returns upper edge of PXD time window.
double m_maxTimePXD
maximal time shift of background event for PXD
void printForMixing() const
Print info when BG mixing is used.
double getMinTimePXD() const
Returns lower edge of PXD time window.
virtual void merge(const Mergeable *other) override
Implementation of abstract class function.
const std::vector< std::string > & getComponents() const
Returns included components.
bool canBeMerged(const BackgroundInfo *other)
Checks if other object can be merged with this object.
const std::vector< BackgroundDescr > & getBackgrounds() const
Returns background descriptions.
void print() const
Print the info.
double getMinTimeECL() const
Returns lower edge of ECL time window.
double m_minTimeECL
minimal time shift of background event for ECL
virtual void clear() override
Implementation of abstract class function.
double getMinTime() const
Returns lower edge of the narrow time window.
Abstract base class for objects that can be merged.
Abstract base class for different kinds of events.