ATLAS Offline Software
Loading...
Searching...
No Matches
BasicHistoCheckModuleStatus.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
9#include <dqm_core/AlgorithmConfig.h>
12#include <TH1.h>
13#include <TF1.h>
14#include <TClass.h>
15#include <ers/ers.h>
16
17#include <dqm_core/AlgorithmManager.h>
18
19namespace
20{
21 dqm_algorithms::BasicHistoCheckModuleStatus BinsFilled( "ModuleStatus_All_Bins_Filled" );
22
23}
24
25
27 : m_name( name )
28{
29 dqm_core::AlgorithmManager::instance().registerAlgorithm(name, this);
30}
31
38
39
40dqm_core::Result *
42 const TObject & object,
43 const dqm_core::AlgorithmConfig & config)
44{
45 const TH1 * histogram;
46
47 if( object.IsA()->InheritsFrom( "TH1" ) ) {
48 histogram = static_cast<const TH1*>(&object);
49 if (histogram->GetDimension() > 3 ){
50 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 3 " );
51 }
52 } else {
53 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
54 }
55
56 const double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
57
58 if (histogram->GetEntries() < minstat ) {
59 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
60 result->tags_["InsufficientEntries"] = histogram->GetEntries();
61 return result;
62 }
63
64
65
66 if ( m_name == "ModuleStatus_All_Bins_Filled" ) {
67 unsigned int nbinsX_filled = 0;
68 const unsigned int binsx = histogram->GetNbinsX();
69 //const unsigned int binsy = histogram->GetNbinsY();
70 //const unsigned int binsz = histogram->GetNbinsZ();
71 for ( unsigned int i(1); i <= binsx; ++i ) {
72 //for ( unsigned int j(1); j <= binsy; ++j ) {
73 //for ( unsigned int k(1); k<= binsz; ++k ) {
74 double content= histogram -> GetBinContent(i);
75 if ( content == 0) {
76 // ERS_DEBUG(1, "Histogram " <<histogram->GetName()<<" has empty bins");
77// return new dqm_core::Result(dqm_core::Result::Red);
78
79 nbinsX_filled++;
80 }
81
82 }
83
84 if(histogram->GetEffectiveEntries() == 0){
85
86 ERS_DEBUG(1, "Histogram " <<histogram->GetName()<<" does not have all filled bins");
87 return new dqm_core::Result(dqm_core::Result::Disabled);
88
89 }
90
91
92 if(nbinsX_filled >0 && nbinsX_filled < binsx){
93 ERS_DEBUG(1, "Histogram " <<histogram->GetName()<<" has empty bins");
94 return new dqm_core::Result(dqm_core::Result::Red);
95 }
96
97
98 ERS_DEBUG(1, "Histogram " <<histogram->GetName()<<" has all filled bins");
99 return new dqm_core::Result(dqm_core::Result::Green);
100
101 }
102
103 else {
104 return new dqm_core::Result();
105 }
106
107
108}
109
110void
112{
113 if ( m_name == "All_Bins_Filled"){
114 out<<"All_Bins_Filled: Checks that all bins of histogram are filled\n"<<std::endl;
115 }
116
117 out<<"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm\n"<<std::endl;
118}
119
std::string histogram
Definition chains.cxx:52
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
#define IsA
Declare the TObject style functions.