9 #include "dqm_core/AlgorithmConfig.h"
10 #include "dqm_core/AlgorithmManager.h"
29 , m_greaterThan(false)
30 , m_valueThresholds(false)
51 if (!
object.
IsA()->InheritsFrom(
"TH1")) {
52 throw dqm_core::BadConfig(ERS_HERE,
name,
"does not inherit from TH1");
56 throw dqm_core::BadConfig(ERS_HERE,
name,
"has more than one dimension");
67 if (m_getEntries == 0) {
68 while ((
histogram.GetBinContent(currentBin) == 0) && (currentBin > 0)) --currentBin;
69 }
else if (m_getEntries == 1) {
71 }
else if (m_getEntries == 2) { }
73 result->tags_[
"LastBinNumber"] = currentBin;
78 for (
int i = 0;
i < m_nBinsToWatch; ++
i) {
79 if (currentBin == 0)
break;
81 if (m_valueThresholds) {
85 if (exceeds(
content, m_grn)) ++grnExceeded;
86 if (exceeds(
content, m_red)) ++redExceeded;
90 result->tags_[
"GreenExceeded"] = grnExceeded;
91 result->tags_[
"RedExceeded"] = redExceeded;
92 if (grnExceeded < redExceeded)
93 throw dqm_core::BadConfig(ERS_HERE,
name,
"more bins exceeded the red threshold than the green threshold, this shouldn't happen");
96 else if (redExceeded < m_nBinsToExceed)
result->status_ = dqm_core::Result::Yellow;
103 out << m_name <<
": Checks whether the last bin(s) of a histogram exceed the given thresholds.\n"
104 "Mandatory green/red thresholds: Threshold - the thresholds against which the bin contents are compared.\n"
105 "Optional parameter: NBinsToWatch - number of final bins that will be checked. (NBinsToWatch >= 1, default = 1)\n"
106 " The result of the algorithm is the worst-case result of all checked bins.\n"
107 "Optional parameter: NBinsToExceed - minimal number of checked bins that have to exceed the given thresholds\n"
108 " before the corresponding result is returned. (1 <= NBinsToExceed <= NBinsToWatch, default = 1)\n"
109 "Optional parameter: GreaterThan - how the values will be compared. (GreaterThan = {0, 1}, default = 1)\n"
110 " GreaterThan == 0: the given thresholds are lower thresholds. (requires green >= red)\n"
111 " GreaterThan == 1: the given thresholds are upper thresholds. (requires green <= red)\n"
112 "Optional parameter: ValueThresholds - which values will be compared. (ValueThresholds = {0, 1}, default = 0)\n"
113 " ValueThresholds == 0: the thresholds correspond to the bin content.\n"
114 " ValueThresholds == 1: the thresholds correspond to the bin x-axis value.\n"
115 "Optional parameter: GetEntries - how to determine which bin is the last. (GetEntries = {0, 1, 2}, default = 0)\n"
116 " GetEntries == 0: find the rightmost non-zero bin, ignore trailing zero bins.\n"
117 " GetEntries == 1: take the return value of TH1::GetEntries() as the number of the last bin.\n"
118 " GetEntries == 2: take the rightmost bin as the last bin, regardless of the bin content.\n"
119 "Returned value: LastBinNumber - the bin number of the last checked (i. e. non-zero) bin.\n"
120 "Returned value: LastBinCenter - the centre of that bin on the horizontal axis.\n"
121 "Returned value: GreenExceeded - how many bins exceeded the green threshold.\n"
122 "Returned value: RedExceeded - how many bins exceeded the red threshold." << std::endl;
138 throw dqm_core::BadConfig(ERS_HERE,
name,
"NBinsToWatch must be 1 or greater");
140 throw dqm_core::BadConfig(ERS_HERE,
name,
"NBinsToExceed must be 1 or greater");
142 throw dqm_core::BadConfig(ERS_HERE,
name,
"NBinsToExceed must not be greater than NBinsToWatch");
143 if ((par2 != 0) && (par2 != 1))
144 throw dqm_core::BadConfig(ERS_HERE,
name,
"GreaterThan must be 0 or 1");
145 if ((par3 != 0) && (par3 != 1))
146 throw dqm_core::BadConfig(ERS_HERE,
name,
"ValueThresholds must be 0 or 1");
147 if ((par4 != 0) && (par4 != 1) && (par4 != 2))
148 throw dqm_core::BadConfig(ERS_HERE,
name,
"GetEntries must be 0, 1 or 2");
150 m_nBinsToWatch =
static_cast<int>(par0);
151 m_nBinsToExceed =
static_cast<int>(par1);
152 m_greaterThan =
static_cast<bool>(par2);
153 m_valueThresholds =
static_cast<bool>(par3);
154 m_getEntries =
static_cast<int>(par4);
162 if (m_greaterThan && (m_red < m_grn))
163 throw dqm_core::BadConfig(ERS_HERE,
name,
"using greater-than comparison, but red threshold is less than green threshold");
164 else if (!m_greaterThan && (m_red > m_grn))
165 throw dqm_core::BadConfig(ERS_HERE,
name,
"using less-than comparison, but red threshold is greater than green threshold");