ATLAS Offline Software
Loading...
Searching...
No Matches
SkewnessTest.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#include <cmath>
17
18
19#include <dqm_core/AlgorithmManager.h>
20
21namespace
22{
23 dqm_algorithms::SkewnessTest skweness_GreaterThan( "GreaterThan" );
24 dqm_algorithms::SkewnessTest skewness_LessThan( "LessThan" );
25 dqm_algorithms::SkewnessTest skewness_GreaterThanAbs( "GreaterThanAbs" );
26 dqm_algorithms::SkewnessTest skewness_LessThanAbs( "LessThanAbs" );
27}
28
29
31 : m_name( name )
32{
33 dqm_core::AlgorithmManager::instance().registerAlgorithm("SkewnessTest_"+name,this);
34}
35
41
42
43dqm_core::Result *
44dqm_algorithms::SkewnessTest::execute( const std::string & name,
45 const TObject & object,
46 const dqm_core::AlgorithmConfig & config )
47{
48 const TH1 * histogram;
49
50 if( object.IsA()->InheritsFrom( "TH1" ) ) {
51 histogram = static_cast<const TH1*>(&object);
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->GetEffectiveEntries() < minstat ) {
59 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
60 result->tags_["InsufficientEffectiveEntries"] = histogram->GetEffectiveEntries();
61 return result;
62 }
63
64 double gthreshold;
65 double rthreshold;
66
67 const int axis = (int) dqm_algorithms::tools::GetFirstFromMap( "Axis", config.getParameters(), 1);
68
69 try {
70 rthreshold = dqm_algorithms::tools::GetFromMap( "S", config.getRedThresholds() );
71 gthreshold = dqm_algorithms::tools::GetFromMap( "S", config.getGreenThresholds() );
72 }
73 catch ( dqm_core::Exception & ex ) {
74 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
75 }
76 ERS_DEBUG(1,"Axis for skewness calculation:"<<axis);
77
78 Double_t skewness = histogram->GetSkewness( axis );
79 Double_t skewness_e = histogram->GetSkewness( axis + 10 );
80
81 dqm_core::Result* result = new dqm_core::Result();
82 ERS_DEBUG(1,"Skewness = "<<skewness<<" +- "<<skewness_e);
83 result->tags_["Skewness"] = skewness;
84 result->tags_["ApproxStandardError"]=skewness_e;
85
86 if ( CompareSkewnessTest( m_name , skewness ,gthreshold) ) {
87 result->status_ = dqm_core::Result::Green;
88 } else if ( CompareSkewnessTest( m_name, skewness, rthreshold) ) {
89 result->status_ = dqm_core::Result::Yellow;
90 } else {
91 result->status_ = dqm_core::Result::Red;
92 }
93
94 return result;
95
96}
97
98bool
99dqm_algorithms::SkewnessTest::CompareSkewnessTest(const std::string & type, double value, double threshold) {
100
101 if (type == "GreaterThan") return (value > threshold);
102 if (type == "LessThan") return (value < threshold);
103 if (type == "GreaterThanAbs") return ( std::abs(value) > threshold );
104 if (type == "LessThanAbs") return ( std::abs(value) < threshold);
105 return 0;
106}
107
108
109void
111{
112 out<<"SkewnessTest_"+m_name+" : Checks if the Skewness of the distribution is "+m_name+" threshold value\n"<<std::endl;
113
114 out<<"Mandatory Green/Red Threshold: S: Value of Skewness"<<std::endl;
115
116 out<<"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm"<<std::endl;
117 out<<"Optional Parameter: Axis: Axis along which compute Skewness: 1=X, 2=Y, 3=Z"<<std::endl;
118
119}
120
file declares the dqm_algorithms::SkewnessTest class.
std::string histogram
Definition chains.cxx:52
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
bool CompareSkewnessTest(const std::string &type, double value, double threshold)
void printDescription(std::ostream &out)
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
SkewnessTest(const std::string &name)
#define IsA
Declare the TObject style functions.