ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
dqm_algorithms
src
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>
10
#include <
dqm_algorithms/SkewnessTest.h
>
11
#include <
dqm_algorithms/tools/AlgorithmHelper.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
21
namespace
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
30
dqm_algorithms::SkewnessTest::SkewnessTest
(
const
std::string & name )
31
:
m_name
( name )
32
{
33
dqm_core::AlgorithmManager::instance().registerAlgorithm(
"SkewnessTest_"
+name,
this
);
34
}
35
36
dqm_algorithms::SkewnessTest
*
37
dqm_algorithms::SkewnessTest::clone
()
38
{
39
return
new
SkewnessTest
(
m_name
);
40
}
41
42
43
dqm_core::Result *
44
dqm_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
98
bool
99
dqm_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
109
void
110
dqm_algorithms::SkewnessTest::printDescription
(std::ostream& out)
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
AlgorithmHelper.h
SkewnessTest.h
file declares the dqm_algorithms::SkewnessTest class.
histogram
std::string histogram
Definition
chains.cxx:52
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string ¶mName, const std::map< std::string, double > ¶ms)
Definition
AlgorithmHelper.cxx:346
dqm_algorithms::tools::GetFromMap
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > ¶ms)
Definition
AlgorithmHelper.h:109
type
dqm_algorithms::SkewnessTest
Definition
SkewnessTest.h:19
dqm_algorithms::SkewnessTest::CompareSkewnessTest
bool CompareSkewnessTest(const std::string &type, double value, double threshold)
Definition
SkewnessTest.cxx:99
dqm_algorithms::SkewnessTest::printDescription
void printDescription(std::ostream &out)
Definition
SkewnessTest.cxx:110
dqm_algorithms::SkewnessTest::m_name
std::string m_name
Definition
SkewnessTest.h:29
dqm_algorithms::SkewnessTest::clone
SkewnessTest * clone()
Definition
SkewnessTest.cxx:37
dqm_algorithms::SkewnessTest::execute
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
Definition
SkewnessTest.cxx:44
dqm_algorithms::SkewnessTest::SkewnessTest
SkewnessTest(const std::string &name)
Definition
SkewnessTest.cxx:30
threshold
Definition
chainparser.cxx:74
IsA
#define IsA
Declare the TObject style functions.
Definition
xAODTEventBranch.h:59
Generated on
for ATLAS Offline Software by
1.17.0