5 #include <dqm_core/AlgorithmConfig.h>
18 #include <dqm_core/AlgorithmManager.h>
24 LastBinGreaterThanThreshold(
"LastBinGreaterThanThreshold");
27 LastBinLessThanThreshold(
"LastBinLessThanThreshold");
30 LastBinDifferentThanThreshold(
"LastBinDifferentThanThreshold");
33 TileDataCorruptionFractionGreaterThanThreshold(
"TileDataCorruptionGreaterThanThreshold");
37 double averageBinContent,
double lastBinContent)
const {
39 const char* actionPath =
std::getenv(
"TILE_DQ_ACTION_PATH");
40 if (actionPath !=
nullptr)
action = std::string(actionPath) +
"/" +
action;
45 std::string
module(
"UNKNOWN");
59 std::system(
action.c_str());
63 template<
class Exceed,
class Action>
70 template<
class Exceed,
class Action>
79 const TObject&
object,
80 const dqm_core::AlgorithmConfig&
config )
84 if(
object.
IsA()->InheritsFrom(
"TProfile" ) ) {
87 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension > 2 " );
90 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TProfile" );
102 std::map<std::string, std::string>::const_iterator itAction =
config.getGenericParameters().find(
"Action");
103 if (itAction !=
config.getGenericParameters().end()) {
104 action = itAction->second;
107 if (
histogram->GetEntries() < minStat ) {
114 double greenThreshold;
120 }
catch ( dqm_core::Exception & ex ) {
121 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
126 int nBinsOverThreshold = 0;
131 if (nBinsToWatch > 0) {
132 while ((
histogram->GetBinEntries(lastBin) == 0) && (lastBin > 1)) --lastBin;
133 firstBin = (lastBin > nBinsToWatch) ? (lastBin - nBinsToWatch + 1) : 1;
135 result->tags_[
"LastBinNumber"] = lastBin;
139 double lastBinOverThresholdContent(0.0);
140 double binsOverThresholdContent(0.0);
142 for (
int bin = firstBin;
bin <= lastBin; ++
bin) {
143 if (ignoreEmpty && (
histogram->GetBinEntries(
bin) == 0)) {
147 if (m_exceeds(
content, binThreshold, fixedError)) {
148 ++nBinsOverThreshold;
149 lastBinOverThresholdContent =
content;
150 binsOverThresholdContent +=
content;
151 if (publish && nBinsOverThreshold < maxPublish){
157 ERS_DEBUG(1,
"Number of bins exceeded threshold of " << binThreshold <<
" is " << nBinsOverThreshold );
158 ERS_DEBUG(1,
"Green threshold: "<< greenThreshold <<
" bin(s); Red threshold : " << redThreshold <<
" bin(s) ");
160 result->tags_[
"NBins"] = nBinsOverThreshold;
161 if (greenThreshold > redThreshold) {
162 if (nBinsOverThreshold >= greenThreshold) {
164 }
else if (nBinsOverThreshold > redThreshold) {
165 result->status_ = dqm_core::Result::Yellow;
170 if (nBinsOverThreshold <= greenThreshold) {
172 }
else if (nBinsOverThreshold < redThreshold) {
173 result->status_ = dqm_core::Result::Yellow;
179 if (!
action.empty() && nBinsOverThreshold >= nBinsForAction) {
180 double averageBinContent = binsOverThresholdContent / nBinsOverThreshold;
181 std::string histogramName(
histogram->GetName());
182 m_doAction(histogramName,
action, lastBinOverThresholdContent, averageBinContent);
189 template<
class Exceed,
class Action>
192 out << m_name +
": Checks for number of bins exceded threshold value" << std::endl;
193 out <<
"Mandatory Parameter: BinThreshold: Look for bins exceeded BinTreshold; Count number of bins satifying requirement" << std::endl;
194 out <<
"Mandatory Green/Red Threshold: NBins: Number of bins satifying BinThreshold constraint to give Green/Red result" << std::endl;
196 out <<
"Optional Parameter: FixedError: override the histogram errors with this value" << std::endl;
197 out <<
"Optional Parameter: IgnoreEmpty: Ignore bins which have zero entries in histogram" << std::endl;
198 out <<
"Optional Parameter: PublishBins: Save bins which are different from average in Result (set to 1)" << std::endl;
199 out <<
"Optional Parameter: MaxPublish: Max number of bins to save (default 20)" << std::endl;
200 out <<
"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm" << std::endl;
201 out <<
"Optional parameter: NBinsToWatch - number of final bins that will be checked. (NBinsToWatch >= 1, default = -1)" << std::endl;