ATLAS Offline Software
Loading...
Searching...
No Matches
TRTHistogramHasNonZeroEntries.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
8
10#include "dqm_core/AlgorithmManager.h"
11#include "dqm_core/AlgorithmConfig.h"
12#include "dqm_core/exceptions.h"
14#include "dqm_core/Result.h"
15#include "ers/ers.h"
16
17#include "TH1.h"
18#include "TF1.h"
19#include "TClass.h"
20
21#include <cmath>
22#include <iostream>
23#include <map>
24
26
27namespace dqm_algorithms
28{
29
31{
32 dqm_core::AlgorithmManager::instance().registerAlgorithm(m_name, this);
33}
34
38
40{
41 return new TRTHistogramHasNonZeroEntries(*this);
42}
43
44dqm_core::Result *TRTHistogramHasNonZeroEntries::execute(const std::string &name, const TObject &object, const dqm_core::AlgorithmConfig &config)
45{
46 const TH1 *histogram;
47
48 if (object.IsA()->InheritsFrom("TH1")) {
49 histogram = static_cast<const TH1*>(&object);
50 if (histogram->GetDimension() > 3) {
51 throw dqm_core::BadConfig(ERS_HERE, name, "dimension > 3 ");
52 }
53 } else {
54 throw dqm_core::BadConfig(ERS_HERE, name, "does not inherit from TH1");
55 }
56
57 const double minstat = dqm_algorithms::tools::GetFirstFromMap("MinStat", config.getParameters(), -1);
58
59 if (histogram->GetEntries() < minstat) {
60 // ERS_INFO("Histogram does not satisfy MinStat requirement " << histogram->GetName());
61 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
62 result->tags_["InsufficientEntries"] = histogram->GetEntries();
63 return result;
64 }
65
66 dqm_core::Result *result = new dqm_core::Result();
67
68 if (histogram->GetEntries() == 0 || histogram->Integral() == 0) {
69 ERS_DEBUG(1, "Histogram " << histogram->GetName() << " is Empty");
70 result->status_ = dqm_core::Result::Red;
71 result->tags_["Integral"] = histogram->Integral();
72 } else {
73 ERS_DEBUG(1, "Histogram " << histogram->GetName() << " is Not Empty");
74 result->status_ = dqm_core::Result::Green;
75 result->tags_["Integral"] = histogram->Integral();
76 }
77 return result;
78}
79
81{
82 out << m_name << ": Checks if histogram has entries that are not zero." << std::endl;
83}
84
85} // namespace dqm_algorithms
static dqm_algorithms::AveragePrint staticInstance
file declares the dqm_algorithms::TRTHistogramHasNonZeroEntries class.
std::string histogram
Definition chains.cxx:52
virtual dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
#define IsA
Declare the TObject style functions.